fluxflow-cli 4.25.4 → 4.25.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunks/{ai-OPCGIZAK.js → ai-ZBSCEHTS.js} +1 -1
- package/dist/chunks/{app-D33R52FZ.js → app-EIBVHMQV.js} +85 -85
- package/dist/chunks/{chunk-SXRQ4ACF.js → chunk-KA7IQD5D.js} +164 -176
- package/dist/chunks/{invoke-G5IJ3VPK.js → invoke-R75DZFQB.js} +2 -2
- package/dist/chunks/{invokeSync-PAOUTNOW.js → invokeSync-JS3JUZLM.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Vt}from"./chunk-56EJGQU3.js";import{a as
|
|
1
|
+
import{a as Vt}from"./chunk-56EJGQU3.js";import{a as ao}from"./chunk-7SFAWGE2.js";import{a as Ai,c as Ci}from"./chunk-U2NRX2PX.js";import{a as Es,g as Ei}from"./chunk-VYTQ6J56.js";import{a as Ri}from"./chunk-RZTZPIC5.js";import{c as As,g as Ti,h as Si,i as _i,m as Cs}from"./chunk-6NWU3ML6.js";import{a as Oo}from"./chunk-FQBBOFNP.js";import{a as oe}from"./chunk-Y5JU726N.js";import{b as Ss}from"./chunk-3CZWTXIR.js";import{d as Do,i as Mt,k as Bt,m as _s,n as ki}from"./chunk-4XXLWMY6.js";import{a as ro}from"./chunk-GRQ7JZZP.js";import{k as ut,l as Io,o as pe}from"./chunk-OSDQRSY6.js";import{c as vt,d as zn}from"./chunk-L3W2X74K.js";import{a as nn,d as En,e as Ro,k as Un,l as vo,m as ks,r as Ts,v as Mo,w as so,x as io}from"./chunk-DSVLWYIT.js";import{GoogleGenAI as Kr,ThinkingLevel as Xe,HarmBlockThreshold as Mn,HarmCategory as In}from"@google/genai";var vi=(e=!0,t=!0)=>`
|
|
2
2
|
To use tools, must output exactly '[action:ActionName(arg1="value1")]' structured string in chat response \u2190 no exception
|
|
3
3
|
|
|
4
4
|
-- Chat Management Tools --
|
|
@@ -25,17 +25,7 @@ Usage Rules:
|
|
|
25
25
|
- Chat title is mandatory
|
|
26
26
|
- Temporary memory is mandatory
|
|
27
27
|
- When called user memory, still use Temporary Memory
|
|
28
|
-
- Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var Lo={xHigh
|
|
29
|
-
Prefer simplest correct solution
|
|
30
|
-
Make direct deductions; avoid branching & token waste`,High:`Effort: High
|
|
31
|
-
Prefer simplest correct solution
|
|
32
|
-
Make direct deductions; avoid branching & token waste`,Medium:`Effort: Medium
|
|
33
|
-
Prefer simplest correct solution
|
|
34
|
-
Make direct deductions; avoid branching & token waste`,Minimal:`Effort: Low
|
|
35
|
-
Prefer simplest correct solution
|
|
36
|
-
Make direct deductions; avoid branching & token waste`,Off:`Effort: Lowest
|
|
37
|
-
No thinking. Immediate response
|
|
38
|
-
Verify imports, tool results & system stability`};import co from"fs";var yn=null,Rs=()=>{try{if(co.existsSync(vo)){let e=co.readFileSync(vo,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return yn=t,yn}}catch{}return yn=yn||{},yn},vi=e=>{try{return co.existsSync(en)||co.mkdirSync(en,{recursive:!0}),co.writeFileSync(vo,JSON.stringify(e,null,2),"utf-8"),yn=e,!0}catch{return!1}},He=(e,t,n)=>{if(!e||!t||!n)return null;let s=yn||Rs(),o=`${e}::${t}`,c=s[o];if(c&&typeof c=="object"){let f=n.toLowerCase();if(c[f]!==void 0&&c[f]!==null)return c[f];for(let[l,k]of Object.entries(c))if(l.toLowerCase()===f)return k}return null},ul=(e,t,n,s)=>{if(!e||!t||!n||!s)return{success:!1,reason:"Invalid arguments"};let o=yn||Rs(),c=`${e}::${t}`;return(!o[c]||typeof o[c]!="object")&&(o[c]={}),o[c][n.toLowerCase()]=s,{success:vi(o)}},gl=(e,t,n)=>{if(!e||!t)return{success:!1,reason:"Invalid arguments"};let s=yn||Rs(),o=`${e}::${t}`;return s[o]&&(n?(delete s[o][n.toLowerCase()],Object.keys(s[o]).length===0&&delete s[o]):delete s[o],vi(s)),{success:!0}};import tn from"fs";import cn from"path";import ma from"os";import ln from"fs";import Rn from"path";import Gi from"fs";import Ms from"path";import{execSync as ji}from"child_process";import{fileURLToPath as ha}from"url";var Ii=`# FluxFlow CLI Startup & Flags Reference
|
|
28
|
+
- Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var Lo={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching",High:"Use minimal reasoning. Prefer simplest path; avoid branching",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching",no:"Use minimal reasoning. Prefer simplest path; avoid branching",Off:"No thinking. Immediate response. Verify imports, tool results & system stability"};import lo from"fs";var xn=null,Rs=()=>{try{if(lo.existsSync(Mo)){let e=lo.readFileSync(Mo,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return xn=t,xn}}catch{}return xn=xn||{},xn},Mi=e=>{try{return lo.existsSync(nn)||lo.mkdirSync(nn,{recursive:!0}),lo.writeFileSync(Mo,JSON.stringify(e,null,2),"utf-8"),xn=e,!0}catch{return!1}},He=(e,t,n)=>{if(!e||!t||!n)return null;let s=xn||Rs(),o=`${e}::${t}`,c=s[o];if(c&&typeof c=="object"){let f=n.toLowerCase();if(c[f]!==void 0&&c[f]!==null)return c[f];for(let[l,k]of Object.entries(c))if(l.toLowerCase()===f)return k}return null},gl=(e,t,n,s)=>{if(!e||!t||!n||!s)return{success:!1,reason:"Invalid arguments"};let o=xn||Rs(),c=`${e}::${t}`;return(!o[c]||typeof o[c]!="object")&&(o[c]={}),o[c][n.toLowerCase()]=s,{success:Mi(o)}},hl=(e,t,n)=>{if(!e||!t)return{success:!1,reason:"Invalid arguments"};let s=xn||Rs(),o=`${e}::${t}`;return s[o]&&(n?(delete s[o][n.toLowerCase()],Object.keys(s[o]).length===0&&delete s[o]):delete s[o],Mi(s)),{success:!0}};import on from"fs";import fn from"path";import pa from"os";import dn from"fs";import Rn from"path";import Gi from"fs";import vs from"path";import{execSync as ji}from"child_process";import{fileURLToPath as ma}from"url";var Ii=`# FluxFlow CLI Startup & Flags Reference
|
|
39
29
|
|
|
40
30
|
Launch command syntax:
|
|
41
31
|
fluxflow [options]
|
|
@@ -64,7 +54,7 @@ fluxflow [options]
|
|
|
64
54
|
* --help commands \u2192 In-chat slash commands list
|
|
65
55
|
* --playground \u2192 Launch Playground mode
|
|
66
56
|
* --prompt, -p \u2192 Non interactive CLI chat, no tools. --new for new headless chat. Holds conversation context upto 10m inactivity or 69 turns. Supports piping from shell, --run if want the command to visible in context. eg \`fluxflow --run "git diff" -p "summarize this" --new\`
|
|
67
|
-
`;var
|
|
57
|
+
`;var Di=`# Env Variables
|
|
68
58
|
|
|
69
59
|
* Locations:
|
|
70
60
|
* Shell
|
|
@@ -93,7 +83,7 @@ fluxflow [options]
|
|
|
93
83
|
|
|
94
84
|
* I_HAVE_TOO_MUCH_MONEY \u2192 (true|false, default: false) Fun Flag; inserts random padding in system prompt to break provider caching. Not intended for paid APIs unless user hate money
|
|
95
85
|
* GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
|
|
96
|
-
`;var
|
|
86
|
+
`;var Oi=`# Fluxflow in-app /commands
|
|
97
87
|
|
|
98
88
|
Trigger in chat via /command
|
|
99
89
|
|
|
@@ -433,7 +423,7 @@ Instruction for this model ID across all providers.
|
|
|
433
423
|
|
|
434
424
|
* On-Demand Reference System:
|
|
435
425
|
* Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
|
|
436
|
-
`;var Po="v4";try{let e=
|
|
426
|
+
`;var Po="v4";try{let e=vs.dirname(ma(import.meta.url)),t=[vs.join(e,"../../package.json"),vs.join(e,"../package.json")],n=!1;for(let s of t)if(Gi.existsSync(s)){let o=JSON.parse(Gi.readFileSync(s,"utf8"));if(o.version){Po=o.version,n=!0;break}}if(!n)try{let s=ji("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(Po=s,n=!0)}catch{}if(!n)try{let s=ji("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(s);o.version&&(Po=o.version)}catch{}}catch{}var Ms={"SKILL.md":`---
|
|
437
427
|
name: fluxflow
|
|
438
428
|
description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
|
|
439
429
|
---
|
|
@@ -460,39 +450,37 @@ Public Docs: https://fluxflow-cli.onrender.com
|
|
|
460
450
|
|
|
461
451
|
Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
|
|
462
452
|
|
|
463
|
-
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Ui,"references/PROVIDERS.md":Wi,"references/PLUGINS.md":Hi,"references/STARTUP.md":Ii,"references/ENV.md":
|
|
464
|
-
`,p=null;
|
|
465
|
-
`)},Qi=()=>
|
|
453
|
+
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Ui,"references/PROVIDERS.md":Wi,"references/PLUGINS.md":Hi,"references/STARTUP.md":Ii,"references/ENV.md":Di,"references/COMMANDS.md":Oi,"references/SETTINGS.md":Li,"references/TOOLS.md":Pi,"references/ARCHITECTURE.md":$i,"references/SUB_AGENTS.md":Ni,"references/SECURITY.md":Fi,"references/IDE.md":Bi};var Ki=()=>{try{let e=Rn.join(nn,"skills","fluxflow"),t=Rn.join(e,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS===!0||!1){dn.existsSync(e)&&dn.rmSync(e,{recursive:!0,force:!0});return}let s=new Set(Object.keys(Ms).map(o=>Rn.normalize(o)));for(let[o,c]of Object.entries(Ms)){let f=Rn.join(e,o),l=Rn.dirname(f);dn.existsSync(l)||dn.mkdirSync(l,{recursive:!0});let k=c.trim()+`
|
|
454
|
+
`,p=null;dn.existsSync(f)&&(p=dn.readFileSync(f,"utf8")),p!==k&&dn.writeFileSync(f,k,"utf8")}if(dn.existsSync(t)){let o=dn.readdirSync(t);for(let c of o){let f=Rn.normalize(Rn.join("references",c));if(!s.has(f)){let l=Rn.join(t,c);try{dn.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};var go=(e,t)=>{try{if(!on.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=on.readdirSync(e);for(let o of n){let c=s.find(f=>f.toLowerCase()===o);if(c){let f=fn.join(e,c);if(on.statSync(f).isFile())return f}}}catch{}return null},$s=(e,t)=>{let n=go(e,t);if(n)try{return on.readFileSync(n,"utf8")}catch{}return""},Vi=new Set([".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".pnpm",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".skills","skills"]),Ns=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!on.existsSync(e))return s;let o=on.readdirSync(e,{withFileTypes:!0});for(let c of o){let f=c.name,l=fn.join(e,f);if(c.isDirectory())!Vi.has(f)&&!Vi.has(f.toLowerCase())&&s.push(...Ns(l,t+1,n));else if(c.isFile()){let k=f.toLowerCase();(k==="agents.md"||k==="agent.md")&&s.push(l)}}}catch{}return s},Yi=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
|
|
455
|
+
`)},Qi=()=>go(nn,["agents.md","agent.md"]),Zi=()=>go(process.cwd(),["agents.md","agent.md"]),er=()=>go(nn,["fluxflow.md"]),tr=()=>go(process.cwd(),["fluxflow.md"]),$o=Qi(),Ls=Zi(),vn=Ns(),No=er(),Fo=tr(),qi=null,Ps="",nr=!1,ya=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],s=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(Ps=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(nr=!0),s.trim()},xa=()=>($o=Qi(),$o?$s(nn,["agents.md","agent.md"]).trim():""),ba=()=>{if(vn=Ns(),Ls=Zi(),!vn||vn.length===0)return"";let e=process.cwd(),t=[...vn].sort((s,o)=>{let c=fn.relative(e,s).replace(/\\/g,"/"),f=fn.relative(e,o).replace(/\\/g,"/"),l=!c.includes("/"),k=!f.includes("/");return l&&!k?-1:!l&&k?1:c.localeCompare(f)}),n=[];for(let s of t)try{let o=on.readFileSync(s,"utf8").trim();if(!o)continue;let c=fn.relative(e,s).replace(/\\/g,"/");if(!c.includes("/"))n.push(Yi(o,2));else{let l=fn.dirname(c)+"/:";n.push(`${l}
|
|
466
456
|
${Yi(o,2)}`)}}catch{}return n.join(`
|
|
467
457
|
|
|
468
|
-
`).trim()},Fs=()=>{No=er();let e=No?$s(
|
|
458
|
+
`).trim()},Fs=()=>{No=er();let e=No?$s(nn,["fluxflow.md"]).trim():"";return ya(e)},Bs=()=>(Fo=tr(),Fo?$s(process.cwd(),["fluxflow.md"]).trim():""),Us=xa(),Bo=ba(),fo=Fs(),uo=Bs(),zi=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),c=fn.posix.basename(o),f=s&&o?`${s}::${o}`:"",l=s&&c?`${s}::${c}`:"",k=g=>!g||!o?!1:g===o||g===c||g===f||g===l,p=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(g,T,m,i)=>{if(s&&T.trim().toLowerCase()===i.trim().toLowerCase()&&T.trim().toLowerCase()===s){let b=m.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(D,h,A,$)=>{if(h.trim().toLowerCase()===$.trim().toLowerCase()){let E=h.trim().toLowerCase();if(k(E)){let x=A.trim();x&&p.push(x)}}return""}).trim();b&&p.push(b)}return""}),e.replace(/<start_model_([^>\r\n]+::[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+::[^>\r\n]+)>/gi,(g,T,m,i)=>{if(T.trim().toLowerCase()===i.trim().toLowerCase()){let u=T.trim().toLowerCase();if(f&&(u===f||l&&u===l)){let b=m.trim();b&&p.push(b)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(g,T,m,i)=>{if(T.includes("::"))return"";if(T.trim().toLowerCase()===i.trim().toLowerCase()){let u=T.trim().toLowerCase();if(o&&(u===o||u===c)){let b=m.trim();b&&p.push(b)}}return""}),p.join(`
|
|
469
459
|
|
|
470
|
-
`).trim()},
|
|
471
|
-
`),ir=or(
|
|
460
|
+
`).trim()},wa=(e="",t="")=>{let n=`${e||""}::${t||""}`.toLowerCase().trim();qi!==n&&(qi=n,fo=Fs(),uo=Bs())};Ki();var ka=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",c="",f=n.match(/^name:\s*(.+)$/m),l=n.match(/^description:\s*(.+)$/m);return f&&(o=f[1].trim().replace(/^["']|["']$/g,"")),l&&(c=l[1].trim().replace(/^["']|["']$/g,"")),o&&c?{name:o,description:c}:null},Ta=e=>{let t=[];if(!e||!on.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let c=on.readdirSync(s,{withFileTypes:!0});for(let f of c){let l=fn.join(s,f.name),k=f.name.toLowerCase();f.isFile()?k==="skill.md"&&t.push(l):f.isDirectory()&&(o===0?(k==="skills"||k===".skills"||k==="skill"||k===".skill")&&n(l,o+1):n(l,o+1))}}catch{}};return n(e,0),t},or=e=>{let t=Ta(e),n=[];for(let s of t)try{let o=on.readFileSync(s,"utf8"),c=ka(o);c&&n.push({...c,filePath:s})}catch{}return n},sr=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
|
|
461
|
+
`),ir=or(nn),rr=or(process.cwd()),Is=sr(ir),Ds=sr(rr),ar=e=>{if(!e)return!1;let t=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return t.includes("/skills/fluxflow/skill.md")||t.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},lr=()=>(ir||[]).filter(e=>!ar(e)),cr=()=>(rr||[]).filter(e=>!ar(e)),lc=(Us?1:0)+(vn?.length||(Bo?1:0))+(fo?1:0)+(uo?1:0)+lr().length+cr().length,Os=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=pa.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=fn.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},cc=()=>{fo=Fs(),uo=Bs();let e=[];$o&&Us.length>0&&e.push({scope:"Global",path:$o}),vn&&vn.length>0&&Bo.length>0?vn.forEach(c=>{e.push({scope:"Project",path:c})}):Ls&&Bo.length>0&&e.push({scope:"Project",path:Ls}),No&&fo.length>0&&e.push({scope:"Global",path:No}),Fo&&uo.length>0&&e.push({scope:"Project",path:Fo});let t=lr(),n=cr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
|
|
472
462
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
|
|
473
463
|
\u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${s} ${s===1?"file":"files"} active)`),e.length>0&&(o.push(`
|
|
474
|
-
\x1B[1mInstructions:\x1B[22m`),e.forEach(c=>{o.push(` \u2022 [${c.scope}] ${
|
|
475
|
-
\x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(c=>{o.push(` \u2022 [Global] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${
|
|
476
|
-
`)},dr=!1;(async()=>{try{let e=await
|
|
477
|
-
`):
|
|
464
|
+
\x1B[1mInstructions:\x1B[22m`),e.forEach(c=>{o.push(` \u2022 [${c.scope}] ${Os(c.path,c.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
|
|
465
|
+
\x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(c=>{o.push(` \u2022 [Global] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Os(c.filePath,"Global")}\x1B[22m`)}),n?.length>0&&n.forEach(c=>{o.push(` \u2022 [Project] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Os(c.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
|
|
466
|
+
`)},dr=!1;(async()=>{try{let e=await ro();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(dr=!0)}}catch{}})();var Xi=null,co=null,Ji=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",dc=process.env.NO_DEV||!1,Sa=(e,t)=>{if(!t)return"";if(e!==Xi||co===null){Xi=e;try{let n=vt(Un,[]);Array.isArray(n)&&n.length>0?co=n.map(s=>`- ${s.memory}`).join(`
|
|
467
|
+
`):co=""}catch(n){co="",on.appendFileSync(`${En}/memory/error.txt`,`${n.message}
|
|
478
468
|
-------------------------------------------------
|
|
479
469
|
|
|
480
|
-
`)}}return
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
Prefer simplest correct solution
|
|
484
|
-
Make direct deductions; avoid branching & token waste`)}let u=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
470
|
+
`)}}return co};var fr=(e,t,n,s,o=!0,c=!1,f="Google",l=!1,k,p,g=!1,T="")=>{let m=!1;process.env.forcedReasoning&&(m=!0);let i="";if(!k&&f==="Google"){let ee=t;t==="Fast"&&(ee="Off"),t==="Low"&&(ee="Minimal"),t==="Standard"&&(ee="Medium"),(t==="xHigh"||t==="Max")&&(ee="xHigh"),i=Lo[ee]||Lo.Medium}(k||f!=="Google")&&(i=Lo.xHigh,t==="Fast"?i=`No thinking. Immediate response
|
|
471
|
+
Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(i=`Effort: Max
|
|
472
|
+
Plan step by step`));let u=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
485
473
|
|
|
486
474
|
`:"",b=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
|
|
487
475
|
${u.length?"":`
|
|
488
|
-
`}`:"",
|
|
476
|
+
`}`:"",D=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
489
477
|
${b.length||u.length?"":`
|
|
490
|
-
`}`:"",h=process.cwd(),A=
|
|
478
|
+
`}`:"",h=process.cwd(),A=Sa(p,o),$=A?.length>0?`--- Saved Memories ---
|
|
491
479
|
${A}
|
|
492
480
|
|
|
493
|
-
`:"";
|
|
481
|
+
`:"";wa(f,T);let E=zi(fo,T,f).trim(),_=[Us,E].filter(ee=>ee&&ee.length>0).join(`
|
|
494
482
|
|
|
495
|
-
`).trim(),I=zi(
|
|
483
|
+
`).trim(),I=zi(uo,T,f).trim(),a=[Bo,I].filter(ee=>ee&&ee.length>0).join(`
|
|
496
484
|
|
|
497
485
|
`).trim(),R=_.length>0||a.length>0?`--- Additional Instructions ---
|
|
498
486
|
${_.length>0?`-- Global --
|
|
@@ -501,14 +489,14 @@ ${_}`:""}${a.length>0?`${_.length>0?`
|
|
|
501
489
|
`:""}-- Project --
|
|
502
490
|
${a}`:""}
|
|
503
491
|
|
|
504
|
-
`:"",d=(()=>{let
|
|
492
|
+
`:"",d=(()=>{let ee=process.cwd().toLowerCase();if(process.platform==="win32"){let we=process.env.SystemRoot?.toLowerCase()||"c:\\windows",ce=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",rt=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return ee.startsWith(we)||ee.startsWith(ce)||ee.startsWith(rt)}else return ee==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(ce=>ee.startsWith(ce))})(),r=new Date,C=r.getFullYear(),v=r.toLocaleString("en-US",{month:"short"}).toUpperCase(),U=String(r.getDate()).padStart(2,"0"),O=`${C}-${v}-${U}`,P=!!s?.autoExcludeMetadata,le=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0||!1,fe=process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||!1;return`${le?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT ===
|
|
505
493
|
Identity: ${Ps.length>1?Ps.trim():"Flux Flow. Sassy, CLI Assistant"}
|
|
506
494
|
${nr?"":`${n==="Flux"?"Run Automated Tests":n==="Flow"?"Concise, Humorous, Sarcastic":n==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids overlapping/close to target, keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids overlapping/close to target, keyboard shortcuts > mouse clicks. Workspace Tools if faster. Focus on Productivity"}`}${dr&&n.toLowerCase().includes("cu")?`
|
|
507
495
|
- 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`:""}
|
|
508
496
|
|
|
509
497
|
- OS: ${Ji}${!fe&&T.length>1?`
|
|
510
|
-
- Model: ${
|
|
511
|
-
- Date: ${
|
|
498
|
+
- Model: ${fn.basename(T.trim()).replace(":free","").replace("-free","").replace("/free","").replace("_free","").replace("free_","").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,ee=>ee.toUpperCase())}`.trimEnd():""}${P?`
|
|
499
|
+
- Date: ${O}`:""}
|
|
512
500
|
|
|
513
501
|
-- REASONING GUIDANCE --
|
|
514
502
|
${f==="Mistral"||f==="Google"&&!k?`${i.trimEnd()}${m||t!=="Fast"&&(f==="Mistral"&&t==="Low"&&!k||t!=="High"&&!k)?`
|
|
@@ -518,19 +506,19 @@ Use <think>...</think> for reasoning before responding any queries
|
|
|
518
506
|
`:""}`:`${i}
|
|
519
507
|
`}${g?"":`Before calling actions, provide user facing summary of plans & decisions
|
|
520
508
|
`}
|
|
521
|
-
${
|
|
509
|
+
${Ci(n,Ji,l,f,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTodo)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
|
|
522
510
|
|
|
523
511
|
-- SECURITY POLICIES --
|
|
524
512
|
- Dont operate on ANY confidential screens`:""}
|
|
525
|
-
=== END SYSTEM PROMPT ===${(Is.length>0||
|
|
513
|
+
=== END SYSTEM PROMPT ===${(Is.length>0||Ds.length>0)&&n.toLowerCase().includes("flux")?`
|
|
526
514
|
|
|
527
515
|
- Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
|
|
528
516
|
|
|
529
517
|
${b}${u}${R}${Is.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
|
|
530
518
|
${Is}
|
|
531
519
|
|
|
532
|
-
`:""}${
|
|
533
|
-
${
|
|
520
|
+
`:""}${Ds.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
|
|
521
|
+
${Ds}
|
|
534
522
|
|
|
535
523
|
`:""}${$}`.trim()},ur=(e="",t=!0,n=!0)=>`=== SYSTEM PROMPT (strict headless logic worker: zero user-facing text policy, strictly follow) ===
|
|
536
524
|
identity: silent background system process, have no mouth, only output is valid tool calls
|
|
@@ -549,11 +537,11 @@ identity: silent background system process, have no mouth, only output is valid
|
|
|
549
537
|
YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks
|
|
550
538
|
${t?"If user tell something that is important (like, hobbies, preferences, facts about user, hates, likes, etc) to know user better over time, use user memory tools":""}
|
|
551
539
|
|
|
552
|
-
${
|
|
540
|
+
${vi(t,n)}
|
|
553
541
|
=== END SYSTEM PROMPT ===${e?`
|
|
554
542
|
|
|
555
543
|
-- current saved user memories --
|
|
556
|
-
${e}`:""}`.trim();var gr=()=>import("./web_search-2PFIJKIL.js").then(e=>e.web_search),hr=()=>import("./web_scrape-BHSQTMX4.js").then(e=>e.web_scrape),mr=()=>import("./memory-M7ASUB6J.js").then(e=>e.memory),pr=()=>import("./chat-MELTWDZ3.js").then(e=>e.chat),yr=()=>import("./view_file-2THVIMD6.js").then(e=>e.view_file),xr=()=>import("./write_file-7X2GQFWK.js").then(e=>e.write_file),br=()=>import("./update_file-KNEQRJAG.js").then(e=>e.update_file),wr=()=>import("./exec_command-J23EG77W.js").then(e=>e.exec_command),kr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ws=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Tr=()=>import("./write_pdf-N2Q4Z3YP.js").then(e=>e.write_pdf),Sr=()=>import("./write_docx-4Y43QJUV.js").then(e=>e.write_docx),Uo=()=>import("./search_keyword-CSRQFPHQ.js").then(e=>e.search_keyword),_r=()=>import("./generate_image-4LIDEIYO.js").then(e=>e.generate_image),Wo=()=>import("./saveSummary-UGNDVNI5.js").then(e=>e.saveSummary),mo=()=>import("./addMemScore-BCPTSMKD.js").then(e=>e.addMemScore),Ar=()=>import("./file_map-KS6Y7BP3.js").then(e=>e.file_map),Ho=()=>import("./todo-GFMPH2JV.js").then(e=>e.todo),Er=()=>import("./invokeSync-PAOUTNOW.js").then(e=>e.invokeSync),Sa=()=>import("./invoke-G5IJ3VPK.js").then(e=>e.invoke),Cr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),_a=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Rr=()=>import("./emergency_rollback-6X27LZE4.js").then(e=>e.emergency_rollback),po=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),yo=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),Go=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),jo=()=>import("./computer_action-RTEC7VUX.js").then(e=>e.computer_action),Mr=()=>import("./click-5I5YOSNC.js").then(e=>e.click),vr=()=>import("./drag-6TRBT2C3.js").then(e=>e.drag),Ir=()=>import("./scroll-7JYRU34H.js").then(e=>e.scroll),Hs=()=>import("./keyboard_typing-F2SAZLI2.js").then(e=>e.keyboard_typing),Gs=()=>import("./key_press-Z3OXF74E.js").then(e=>e.key_press),js=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),Ko=()=>import("./find_file-A6NYLQJS.js").then(e=>e.find_file),Aa={web_search:gr,web_scrape:hr,memory:mr,chat:pr,view_file:yr,write_file:xr,update_file:br,exec_command:wr,read_folder:kr,write_pdf:Tr,write_docx:Sr,search_keyword:Uo,generate_image:_r,saveSummary:Wo,addMemScore:mo,file_map:Ar,todo:Ho,Todo:Ho,goal:Ho,Goal:Ho,invokeSync:Er,invoke:Sa,getProgress:Cr,cancel:_a,awaitSubagent:po,answerSubagent:yo,steerSubagent:Go,computer_action:jo,computer_use:jo,ComputerAction:jo,ComputerUse:jo,click:Mr,Click:Mr,drag:vr,Drag:vr,scroll:Ir,Scroll:Ir,keyboard_typing:Hs,KeyboardTyping:Hs,keyboardtyping:Hs,key_press:Gs,KeyPress:Gs,keypress:Gs,recapture_screen:js,RecaptureScreen:js,recapturescreen:js,invoke_sync:Er,get_progress:Cr,await_subagent:po,answer_subagent:yo,steer_subagent:Go,steer:Go,Steer:Go,ask:Ws,Ask:Ws,AskUser:Ws,WebSearch:gr,WebScrape:hr,ReadFile:yr,ReadFolder:kr,WriteFile:xr,PatchFile:br,WritePDF:Tr,WriteDoc:Sr,Run:wr,SearchKeyword:Uo,CodeSearch:Uo,code_search:Uo,Memory:mr,Chat:pr,GenerateImage:_r,saveSumary:Wo,SaveSummary:Wo,SaveSumary:Wo,add_mem_score:mo,AddMemScore:mo,addMemoryScore:mo,AddMemoryScore:mo,FileMap:Ar,answer:yo,Answer:yo,AnswerSubagent:yo,await:po,Await:po,AwaitSubagent:po,EmergencyRollback:Rr,emergency_rollback:Rr,find_file:Ko,findFile:Ko,FindFile:Ko,findfile:Ko},xo=async(e,t,n={})=>{let s=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),f=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await"].some(g=>o.includes(g))||o==="ask",k=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer"].some(g=>o.includes(g));if(!f){if(s==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(s==="icu"){if(!k)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let p=Aa[e];if(!p){let g=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],T={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},m=o.replace(/[^a-z0-9]/g,""),i=T[m]||null;if(!i){let b=0,O=A=>{let $=new Set;for(let C=0;C<A.length-1;C++)$.add(A.slice(C,C+2));return $},h=O(m);for(let A of g){let $=A.toLowerCase().replace(/[^a-z0-9]/g,"");if(m===$){i=A;break}let C=0;($.includes(m)||m.includes($))&&(C+=.6);let x=O($),_=0;for(let y of h)x.has(y)&&_++;let I=2*_/(h.size+x.size||1);C=Math.max(C,I),C>b&&C>=.35&&(b=C,i=A)}}let u=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${u}`}try{return await(await p())(t,n)}catch(g){let T=g instanceof Error?g.message:String(g);return`ERROR: Execution failed for [${e}]: ${T}`}};import ae from"path";import Ue from"fs";import Ea from"gradient-string";var Ks=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var Or=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],bo={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"]},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"]},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"]},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"]},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:void 0,diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:void 0,diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"]},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:void 0,diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:void 0,diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"]},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"]},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"]}};var Vo=null;var Dr=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Vo||(Vo=Or[Math.floor(Math.random()*Or.length)]),t={...Vo,id:"Mystery"}):(Vo=null,bo[e]?t=bo[e]:e==="GitHub"?t=bo["GitHub Dark"]:e==="Transparent"?t=bo["Transparent Dark"]:t=bo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan";return{...t,codeText:n}};var Ca=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",yc=(e=2)=>{let t=Ca();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},xc=(e="...",t="Loading...",n="Dark")=>{let s=Ks[Math.floor(Math.random()*Ks.length)],o=Dr(n),c=o.logoTextAnsi,f=o.logoBodyAnsi,l=o.logoMutedAnsi,k="\x1B[0m",p=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],g=o.logoGradient||["#0077ff","#ff00ff"],T=Ea(g).multiline(p.join(`
|
|
544
|
+
${e}`:""}`.trim();var gr=()=>import("./web_search-2PFIJKIL.js").then(e=>e.web_search),hr=()=>import("./web_scrape-BHSQTMX4.js").then(e=>e.web_scrape),mr=()=>import("./memory-M7ASUB6J.js").then(e=>e.memory),pr=()=>import("./chat-MELTWDZ3.js").then(e=>e.chat),yr=()=>import("./view_file-2THVIMD6.js").then(e=>e.view_file),xr=()=>import("./write_file-7X2GQFWK.js").then(e=>e.write_file),br=()=>import("./update_file-KNEQRJAG.js").then(e=>e.update_file),wr=()=>import("./exec_command-J23EG77W.js").then(e=>e.exec_command),kr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ws=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Tr=()=>import("./write_pdf-N2Q4Z3YP.js").then(e=>e.write_pdf),Sr=()=>import("./write_docx-4Y43QJUV.js").then(e=>e.write_docx),Uo=()=>import("./search_keyword-CSRQFPHQ.js").then(e=>e.search_keyword),_r=()=>import("./generate_image-4LIDEIYO.js").then(e=>e.generate_image),Wo=()=>import("./saveSummary-UGNDVNI5.js").then(e=>e.saveSummary),ho=()=>import("./addMemScore-BCPTSMKD.js").then(e=>e.addMemScore),Ar=()=>import("./file_map-KS6Y7BP3.js").then(e=>e.file_map),Ho=()=>import("./todo-GFMPH2JV.js").then(e=>e.todo),Cr=()=>import("./invokeSync-JS3JUZLM.js").then(e=>e.invokeSync),_a=()=>import("./invoke-R75DZFQB.js").then(e=>e.invoke),Er=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),Aa=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Rr=()=>import("./emergency_rollback-6X27LZE4.js").then(e=>e.emergency_rollback),mo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),po=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),Go=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),jo=()=>import("./computer_action-RTEC7VUX.js").then(e=>e.computer_action),vr=()=>import("./click-5I5YOSNC.js").then(e=>e.click),Mr=()=>import("./drag-6TRBT2C3.js").then(e=>e.drag),Ir=()=>import("./scroll-7JYRU34H.js").then(e=>e.scroll),Hs=()=>import("./keyboard_typing-F2SAZLI2.js").then(e=>e.keyboard_typing),Gs=()=>import("./key_press-Z3OXF74E.js").then(e=>e.key_press),js=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),Ko=()=>import("./find_file-A6NYLQJS.js").then(e=>e.find_file),Ca={web_search:gr,web_scrape:hr,memory:mr,chat:pr,view_file:yr,write_file:xr,update_file:br,exec_command:wr,read_folder:kr,write_pdf:Tr,write_docx:Sr,search_keyword:Uo,generate_image:_r,saveSummary:Wo,addMemScore:ho,file_map:Ar,todo:Ho,Todo:Ho,goal:Ho,Goal:Ho,invokeSync:Cr,invoke:_a,getProgress:Er,cancel:Aa,awaitSubagent:mo,answerSubagent:po,steerSubagent:Go,computer_action:jo,computer_use:jo,ComputerAction:jo,ComputerUse:jo,click:vr,Click:vr,drag:Mr,Drag:Mr,scroll:Ir,Scroll:Ir,keyboard_typing:Hs,KeyboardTyping:Hs,keyboardtyping:Hs,key_press:Gs,KeyPress:Gs,keypress:Gs,recapture_screen:js,RecaptureScreen:js,recapturescreen:js,invoke_sync:Cr,get_progress:Er,await_subagent:mo,answer_subagent:po,steer_subagent:Go,steer:Go,Steer:Go,ask:Ws,Ask:Ws,AskUser:Ws,WebSearch:gr,WebScrape:hr,ReadFile:yr,ReadFolder:kr,WriteFile:xr,PatchFile:br,WritePDF:Tr,WriteDoc:Sr,Run:wr,SearchKeyword:Uo,CodeSearch:Uo,code_search:Uo,Memory:mr,Chat:pr,GenerateImage:_r,saveSumary:Wo,SaveSummary:Wo,SaveSumary:Wo,add_mem_score:ho,AddMemScore:ho,addMemoryScore:ho,AddMemoryScore:ho,FileMap:Ar,answer:po,Answer:po,AnswerSubagent:po,await:mo,Await:mo,AwaitSubagent:mo,EmergencyRollback:Rr,emergency_rollback:Rr,find_file:Ko,findFile:Ko,FindFile:Ko,findfile:Ko},yo=async(e,t,n={})=>{let s=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),f=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await"].some(g=>o.includes(g))||o==="ask",k=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer"].some(g=>o.includes(g));if(!f){if(s==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(s==="icu"){if(!k)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let p=Ca[e];if(!p){let g=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],T={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},m=o.replace(/[^a-z0-9]/g,""),i=T[m]||null;if(!i){let b=0,D=A=>{let $=new Set;for(let E=0;E<A.length-1;E++)$.add(A.slice(E,E+2));return $},h=D(m);for(let A of g){let $=A.toLowerCase().replace(/[^a-z0-9]/g,"");if(m===$){i=A;break}let E=0;($.includes(m)||m.includes($))&&(E+=.6);let x=D($),_=0;for(let y of h)x.has(y)&&_++;let I=2*_/(h.size+x.size||1);E=Math.max(E,I),E>b&&E>=.35&&(b=E,i=A)}}let u=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${u}`}try{return await(await p())(t,n)}catch(g){let T=g instanceof Error?g.message:String(g);return`ERROR: Execution failed for [${e}]: ${T}`}};import ae from"path";import Ue from"fs";import Ea from"gradient-string";var Ks=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var Dr=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],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"]},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"]},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"]},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"]},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:void 0,diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:void 0,diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"]},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:void 0,diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:void 0,diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"]},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"]},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"]}};var Vo=null;var Or=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Vo||(Vo=Dr[Math.floor(Math.random()*Dr.length)]),t={...Vo,id:"Mystery"}):(Vo=null,xo[e]?t=xo[e]: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";return{...t,codeText:n}};var Ra=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",xc=(e=2)=>{let t=Ra();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},bc=(e="...",t="Loading...",n="Dark")=>{let s=Ks[Math.floor(Math.random()*Ks.length)],o=Or(n),c=o.logoTextAnsi,f=o.logoBodyAnsi,l=o.logoMutedAnsi,k="\x1B[0m",p=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],g=o.logoGradient||["#0077ff","#ff00ff"],T=Ea(g).multiline(p.join(`
|
|
557
545
|
`)).split(`
|
|
558
546
|
`),m=i=>`${l}${i}${k}`;return`${T[0]}
|
|
559
547
|
${T[1]} ${c}Selected Provider: ${t}${k}
|
|
@@ -563,50 +551,50 @@ ${T[4]}
|
|
|
563
551
|
${T[5]} ${f}See /help for additional commands.${k}
|
|
564
552
|
${T[6]} ${m(s)}
|
|
565
553
|
${T[7]}
|
|
566
|
-
`};import{WebSocket as Yo}from"ws";var Ut=null,
|
|
554
|
+
`};import{WebSocket as Yo}from"ws";var Ut=null,Xn=!1,va="ws://localhost:56832",Vs=[],Jn=null,Ys=null,Lr="2.0.0",Tc=e=>{Lr=e,Pr()},qs=e=>{Ys=e},Pr=()=>{if(Ut||Xn)return;Xn=!0;let e=new Yo(va);e.on("open",()=>{for(Ut=e,Xn=!1,Ut.send(JSON.stringify({command:"version",version:Lr,pid:process.pid,ppid:process.ppid}));Vs.length>0;)Ut.send(JSON.stringify(Vs.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&Jn?(Jn(n.data),Jn=null):n.command==="securityResponse"&&Ys&&Ys(n.result)}catch{}}),e.on("error",()=>{Xn=!1,Ut=null}),e.on("close",()=>{Xn=!1,Ut=null})},qo=e=>{Ut&&Ut.readyState===Yo.OPEN?Ut.send(JSON.stringify(e)):(Vs.push(e),Xn||Pr())},zo=()=>Ut!==null&&Ut.readyState===Yo.OPEN,Sc=e=>{qo({command:"status",status:e})},Wn=()=>new Promise(e=>{if(!Ut||Ut.readyState!==Yo.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}Jn=e,Ut.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{Jn===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),Jn=null)},1e3)}),$r=e=>{qo({command:"open",filePath:e})},zs=(e,t,n)=>{qo({command:"showDiff",filePath:e,originalContent:t,modifiedContent:n})},Nr=(e,t)=>{qo({command:"closeDiff",filePath:e,result:t})};import Xs from"path";import Ma from"fs";var Ia=e=>{try{return Ma.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Js=(e,t=4,n=1,s=Ia,o=[],c=null)=>{let f=c||s(e),l=" ".repeat(n-1),k=n===1?new Set([...so,...o,...io(e),...io(process.cwd())]):o instanceof Set?o:new Set([...so,...o]),p=x=>k.has(x),g=f.filter(x=>!p(x.name)),T=f.filter(x=>p(x.name)).length,m=g.filter(x=>!x.isDirectory()).map(x=>x.name).sort(),i=g.filter(x=>x.isDirectory()).sort((x,_)=>x.name.localeCompare(_.name)),u=x=>{let _=x.length;if(_===0)return"no files";let I=Array.from(new Set(x.map(a=>{let R=typeof a=="string"?a:a.name;return Xs.extname(R).slice(1)}).filter(Boolean))).sort(),y="*";return I.length===1?y=`*.${I[0]}`:I.length>1&&(y=`*.{${I.join(", ")}}`),_===1?y:`${y} ${_} files`},b="";if(n===1){let x=m.join(", "),_=T>0?` [${T} ignored]`:"";(x||_)&&(b+=`${l}${x?x+(_?`${_}`:""):_.trim()}
|
|
567
555
|
`)}else m.length>0&&(b+=`${l}[${u(m)}]
|
|
568
|
-
`);let
|
|
569
|
-
`);for(let{displayName:x,subDirPath:_,subEntries:I,nextDepth:y}of
|
|
556
|
+
`);let D=10,h=i.slice(0,D),A=i.length>D,$=[],E=[];for(let x of h){let _=Xs.join(e,x.name),I=x.name,y=n,a=s(_),R=a.filter(v=>!p(v.name)),d=R.filter(v=>v.isDirectory()),r=R.filter(v=>!v.isDirectory());for(;r.length===0&&d.length===1&&y<t;)I=`${I}/${d[0].name}`,_=Xs.join(_,d[0].name),y++,a=s(_),R=a.filter(v=>!p(v.name)),d=R.filter(v=>v.isDirectory()),r=R.filter(v=>!v.isDirectory());let C=d.length>0;if(C&&y<t)E.push({displayName:I,subDirPath:_,subEntries:a,nextDepth:y+1});else{let v=u(r),U=C&&y>=t?" ...max scan depth":"";$.push(`${I}/${v}${U}`)}}$.length>0&&(b+=`${l}${$.join(", ")}
|
|
557
|
+
`);for(let{displayName:x,subDirPath:_,subEntries:I,nextDepth:y}of E)b+=`${l}${x}/
|
|
570
558
|
`,b+=Js(_,t,y,s,k,I);return A&&(b+=`${l}...max scan width, ReadFolder if needed
|
|
571
|
-
`),b};import Qs from"path";import
|
|
572
|
-
`;let k="",p=c,g=f.filter(i=>!p.includes(i.name)&&!i.name.startsWith(".")),T=f.filter(i=>p.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();g.sort((i,u)=>i.isDirectory()&&!u.isDirectory()?-1:!i.isDirectory()&&u.isDirectory()?1:i.name.localeCompare(u.name));let m=[...g.map(i=>({name:i.name,isDir:i.isDirectory()})),...T.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return m.forEach((i,u)=>{let b=u===m.length-1,
|
|
559
|
+
`),b};import Qs from"path";import Da from"fs";var Oa=e=>{try{return Da.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Zs=(e,t,n="",s=1,o=Oa,c=[])=>{let f=o(e),l=Qs.sep;if(f.length>100)return`${n}\u2514\u2500\u2500 ${Qs.basename(e)}${l} ...100+ files...
|
|
560
|
+
`;let k="",p=c,g=f.filter(i=>!p.includes(i.name)&&!i.name.startsWith(".")),T=f.filter(i=>p.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();g.sort((i,u)=>i.isDirectory()&&!u.isDirectory()?-1:!i.isDirectory()&&u.isDirectory()?1:i.name.localeCompare(u.name));let m=[...g.map(i=>({name:i.name,isDir:i.isDirectory()})),...T.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return m.forEach((i,u)=>{let b=u===m.length-1,D=Qs.join(e,i.name),h=b?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",A=n+(b?" ":"\u2502 ");if(i.isCollapsed){k+=`${n}${h}${i.name}${l}...
|
|
573
561
|
`;return}i.isDir?s>t?k+=`${n}${h}${i.name}${l} ...depth exceeded...
|
|
574
|
-
`:o(
|
|
562
|
+
`:o(D).length>80?k+=`${n}${h}${i.name}${l} ...80+ files...
|
|
575
563
|
`:(k+=`${n}${h}${i.name}${l}
|
|
576
|
-
`,k+=Zs(
|
|
577
|
-
`}),k};var Ze=async(e,t,n=5,s=1e3)=>{let o=t?.signal;for(let f=0;f<n;f++){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{let l=await fetch(e,t);if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.ok||l.status!==429&&l.status<500)return l}catch(l){if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.name==="AbortError"||o?.aborted||f===n-1)throw l}o?await new Promise((l,k)=>{let p=setTimeout(()=>{o.removeEventListener("abort",g),l()},Math.min(24e3,s*Math.pow(2,f))),g=()=>{clearTimeout(p),k(new DOMException("The user aborted a request.","AbortError"))};o.addEventListener("abort",g)}):await new Promise(l=>setTimeout(l,Math.min(24e3,s*Math.pow(2,f))))}if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");let c=await fetch(e,t);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),c};async function Xo(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n).slice(0,16)].map(s=>s.toString(16).padStart(2,"0")).join("")}var
|
|
578
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),
|
|
579
|
-
`);$=d.pop();for(let r of d){let
|
|
580
|
-
`);N=
|
|
581
|
-
`);y=U.pop();for(let
|
|
582
|
-
`);for(let r of y.parts){let
|
|
583
|
-
`:"")+r.text);else d=a.text||"";p.push({role:R,content:d})}let g=He("InferX",t,o),m=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i=t&&t.toLowerCase().includes("qwen3.8-27b")&&g===null,u=t&&(t.toLowerCase().includes("qwen3.8-27b")||t.toLowerCase().includes("qwen3.6-35b-a3b-fp8")),b={model:t,messages:p.filter(a=>a.content&&String(a.content).trim().length>0),stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};!i&&m&&(b.stream_options={include_usage:!0},b.reasoning_effort=m);let
|
|
584
|
-
`);$=d.pop();for(let r of d){let
|
|
585
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),
|
|
586
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),
|
|
587
|
-
`);
|
|
588
|
-
`);
|
|
589
|
-
`);
|
|
590
|
-
`);
|
|
591
|
-
`);
|
|
592
|
-
`),b=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");f.push(i),b&&u?k=!0:k=!1}}}),p()}}return n.length},
|
|
593
|
-
`),_=s.slice(0,-1).filter(L=>L.text&&!L.text.includes("[ACTION RESULT]")&&!L.text.includes("[TOOL RESULT]")&&!L.text.includes("OBSERVATION:")&&!L.text.startsWith("[TERMINAL_RECORD]")&&!L.isTerminalRecord&&!L.isMeta&&!L.isLogo&&!String(L.id).startsWith("welcome")&&!String(L.id).startsWith("logo")).slice(-14).map(L=>{let N=qt(
|
|
564
|
+
`,k+=Zs(D,t,A,s+1,o,c)):k+=`${n}${h}${i.name}
|
|
565
|
+
`}),k};var Ze=async(e,t,n=5,s=1e3)=>{let o=t?.signal;for(let f=0;f<n;f++){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{let l=await fetch(e,t);if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.ok||l.status!==429&&l.status<500)return l}catch(l){if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.name==="AbortError"||o?.aborted||f===n-1)throw l}o?await new Promise((l,k)=>{let p=setTimeout(()=>{o.removeEventListener("abort",g),l()},Math.min(24e3,s*Math.pow(2,f))),g=()=>{clearTimeout(p),k(new DOMException("The user aborted a request.","AbortError"))};o.addEventListener("abort",g)}):await new Promise(l=>setTimeout(l,Math.min(24e3,s*Math.pow(2,f))))}if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");let c=await fetch(e,t);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),c};async function Xo(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n).slice(0,16)].map(s=>s.toString(16).padStart(2,"0")).join("")}var bn=e=>typeof e!="string"?e:e.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");var Jo=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if((a.inlineData||a.inline_data)&&f){let R=a.inlineData||a.inline_data,d=R.mimeType||R.mime_type||"image/jpeg",r=R.data;d.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${d};base64,${r}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"},T=He("DeepSeek",t,o),i=T!==null?T:o!=="Fast"?{Low:"low",Medium:"high",Standard:"high",High:"max",xHigh:"max"}[o]||"high":null;i&&i!=="disabled"&&i!=="none"&&i!=="false"&&i!==!1?(g.reasoning_effort=i,g.extra_body={thinking:{type:"enabled"}}):g.extra_body={thinking:{type:"disabled"}};let u=await Ze("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(g),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`DeepSeek Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),D=new TextDecoder,h="",A=[],$=null,E=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=D.decode(I,{stream:!0});let y=h.split(`
|
|
566
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),C=r.choices?.[0]?.delta,v=r.usage;if(r.choices?.[0]?.finish_reason&&(d=!0),v&&($={totalTokenCount:v.total_tokens||v.prompt_tokens+v.completion_tokens,promptTokenCount:v.prompt_tokens||0,candidatesTokenCount:v.completion_tokens||0,cachedContentTokenCount:v.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:v.completion_tokens_details?.reasoning_tokens||0},x=!0),C){let U=C.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),C.content&&(A.push({text:C.content}),x=!0)}}catch{}if((d||Date.now()-E>=150)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1),d)break}Date.now()-E>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1)}};var Qo=async function*(e,t,n,s,o,c,f,l,k=1,p=null){let g=[];s&&g.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let C=r.inlineData.mimeType,v=r.inlineData.data;C.startsWith("image/")&&d.push({type:"image_url",image_url:`data:${C};base64,${v}`})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}d.length>0&&g.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let T={Fast:"none",Low:"none",Medium:"high",Standard:"high",High:"high",xHigh:"high"},m=`${e.slice(-5)}${p||""}${o}${t}`,i=await Xo(m),u={model:t,messages:g,stream:!0,temperature:k,prompt_cache_key:i,tools:[],tool_choice:"none"},b=He("Mistral",t,o);b!==null&&b!=="none"?b&&b!=="none"&&b!=="disabled"&&b!==!1&&(u.reasoning_effort=b):o&&T[o]!=="none"&&(u.reasoning_effort=T[o]||"high");let D=await Ze("https://api.mistral.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(u),signal:l});if(!D.ok){let a=await D.text().catch(()=>""),R=D.statusText;try{let d=JSON.parse(a);R=d.error?.message||d.message||JSON.stringify(d.detail||d)}catch{a&&(R=a)}throw new Error(`Mistral Error (${D.status}): ${JSON.stringify(R)}`)}let h=D.body.getReader(),A=new TextDecoder,$="",E=[],x=null,_=Date.now(),I=!1,y=a=>a?typeof a=="string"?bn(a):Array.isArray(a)?a.map(y).filter(Boolean).join(""):typeof a=="object"&&a!==null?typeof a.text=="string"?bn(a.text):typeof a.content=="string"?bn(a.content):typeof a.thinking=="string"?bn(a.thinking):typeof a.reasoning_content=="string"?bn(a.reasoning_content):typeof a.reasoning=="string"?bn(a.reasoning):typeof a.value=="string"?bn(a.value):a.text?y(a.text):a.content?y(a.content):a.thinking?y(a.thinking):a.reasoning_content?y(a.reasoning_content):a.reasoning?y(a.reasoning):a.value?y(a.value):"":bn(String(a)):"";for(;;){let{done:a,value:R}=await h.read();if(a){I&&(E.length>0||x)&&(yield{candidates:E.length>0?[{content:{parts:E}}]:[],usageMetadata:x});break}$+=A.decode(R,{stream:!0});let d=$.split(`
|
|
567
|
+
`);$=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(U.choices?.[0]?.finish_reason&&(v=!0),P&&(x={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||0},I=!0),O){let le=O.thinking||O.reasoning_content||O.reasoning,fe=y(le);fe&&(E.push({text:fe,thought:!0}),I=!0);let ee=O.content||(!O.thinking&&!O.reasoning_content&&!O.reasoning?O.text:null);if(ee)if(Array.isArray(ee))for(let we of ee)if(typeof we=="object"&&we!==null){let ce=we.type==="thinking"||we.type==="reasoning"||!!we.thought,rt=y(we);rt&&(E.push({text:rt,...ce?{thought:!0}:{}}),I=!0)}else{let ce=y(we);ce&&(E.push({text:ce}),I=!0)}else if(typeof ee=="object"&&ee!==null){let we=ee.type==="thinking"||ee.type==="reasoning"||!!ee.thought,ce=y(ee);ce&&(E.push({text:ce,...we?{thought:!0}:{}}),I=!0)}else{let we=y(ee);we&&(E.push({text:we}),I=!0)}}}catch{}if((v||Date.now()-_>=150)&&I&&(yield{candidates:E.length>0?[{content:{parts:[...E]}}]:[],usageMetadata:x},E=[],_=Date.now(),I=!1),v)break}Date.now()-_>=150&&I&&(yield{candidates:E.length>0?[{content:{parts:[...E]}}]:[],usageMetadata:x},E=[],_=Date.now(),I=!1)}};var Zo=async function*(e,t,n,s,o,c,f=!1,l,k=1){let p=[];s&&p.push({role:"system",content:s}),n.forEach(ce=>{let rt=ce.role==="model"?"assistant":"user",L=[];Array.isArray(ce.parts)&&ce.parts.forEach(N=>{if(N.text)L.push({type:"text",text:N.text});else if(N.inlineData&&f){let Ce=N.inlineData.mimeType,ie=N.inlineData.data;Ce.startsWith("image/")&&ut(t)&&L.push({type:"image_url",image_url:{url:`data:${Ce};base64,${ie}`}})}}),p.push({role:rt,content:L.length===1&&L[0].type==="text"?L[0].text:L})});let g=He("NVIDIA",t,o),m=g!==null?g:{Fast:"Fast",Low:"Fast",Medium:"Standard",Standard:"Standard",High:"High",xHigh:"High"}[o]||"High",i=m!=="Fast"&&m!=="none"&&m!=="disabled"&&m!==!1,u=t.includes("kimi"),b=t.includes("gemma"),D=t.includes("deepseek"),h=t.includes("glm"),A=t.includes("mistral"),$=t.includes("minimax"),E=t.includes("gpt"),x=t.includes("qwen"),_=t.includes("nemotron"),I=t.includes("llama-3"),y=t.includes("seed"),a=t.includes("poolside"),R=t.includes("thinkingmachines")||t.includes("muse"),d=I,r={Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},C={Fast:"64",Low:"64",Medium:"4096",Standard:"4096",High:"16384",xHigh:"16384"},v={Fast:"none",Low:"minimal",Medium:"medium",Standard:"medium",High:"max",xHigh:"max"},U=$||D||a||R?16384:32768;U=process.env.NVIDIA_BASE_URL?1024:U;let O={model:t,messages:p,max_tokens:U,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none",...E&&{thinking:r[o]||"high"}};if(!(process.env.NVIDIA_BASE_URL||d))if(u)O.chat_template_kwargs={thinking:i};else if(b)O.chat_template_kwargs={enable_thinking:i};else if(D)if(i){let ce=m==="High"?"max":"high";O.chat_template_kwargs={thinking:!0,reasoning_effort:ce}}else O.chat_template_kwargs={thinking:!1};else h?O.chat_template_kwargs={enable_thinking:i,clear_thinking:!i}:A?O.reasoning_effort=i?"high":"none":$&&t.includes("minimax-m3")?O.chat_template_kwargs={thinking_mode:i?"enabled":"disabled"}:x?O.chat_template_kwargs={enable_thinking:i}:_?m==="High"?O.chat_template_kwargs={enable_thinking:!0}:m==="Standard"?O.chat_template_kwargs={enable_thinking:!0,medium_effort:!0}:O.chat_template_kwargs={enable_thinking:!1}:y?i&&(O.extra_body={thinking_budget:parseInt(C[m]??"4096")}):a?O.chat_template_kwargs={enable_thinking:i}:R&&(O.reasoning_effort=v[m]||"medium");let P=0,le=6,fe=!1,ee=process.env.NVIDIA_BASE_URL||"https://integrate.api.nvidia.com/v1/chat/completions",we=process.env.NVIDIA_API_KEY&&process.env.NVIDIA_BASE_URL?process.env.NVIDIA_API_KEY:e;for(ee.endsWith("/chat/completions")||(ee=ee.replace(/\/+$/,"")+"/chat/completions");P<le;){P++;try{let ce=await Ze(ee,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${we}`},body:JSON.stringify(O),signal:l});if(!ce.ok){let ye=await ce.text().catch(()=>""),Re=ce.statusText;try{let Ie=JSON.parse(ye);Re=Ie.error?.message||Ie.message||JSON.stringify(Ie.detail||Ie)}catch{ye&&(Re=ye)}let ve=new Error(`NVIDIA API Error (${ce.status}): ${Re}`);throw ve.status=ce.status,ve}let rt=ce.body.getReader(),L=new TextDecoder,N="",Ce=[],ie=null,B=Date.now(),G=!1;for(;;){let{done:ye,value:Re}=await rt.read();if(ye){G&&(Ce.length>0||ie)&&(yield{candidates:Ce.length>0?[{content:{parts:Ce}}]:[],usageMetadata:ie},fe=!0);break}N+=L.decode(Re,{stream:!0});let ve=N.split(`
|
|
568
|
+
`);N=ve.pop();let Ie=!1;for(let Dn of ve){let sn=Dn.trim();if(sn){if(sn==="data: [DONE]"){Ie=!0;break}if(sn.startsWith("data: ")){let pt;try{pt=JSON.parse(sn.substring(6))}catch{continue}if(pt.error)throw new Error(`NVIDIA Stream Error: ${pt.error.message||JSON.stringify(pt.error)}`);try{let Tt=pt.usage;Tt&&(ie={totalTokenCount:Tt.total_tokens||Tt.prompt_tokens+Tt.completion_tokens,promptTokenCount:Tt.prompt_tokens||0,candidatesTokenCount:Tt.completion_tokens||0,cachedContentTokenCount:Tt.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:(Tt.completion_tokens_details?.reasoning_tokens||0)+(Tt.completion_tokens_details?.thoughts_tokens||0)},G=!0);let Je=pt.choices?.[0]?.delta?.reasoning||pt.choices?.[0]?.delta?.reasoning_content||"",xe=pt.choices?.[0]?.delta?.content||"";Je&&(Ce.push({text:Je,thought:!0}),G=!0),xe&&(Ce.push({text:xe}),G=!0)}catch{}}}}if((Ie||Date.now()-B>=350)&&G&&(yield{candidates:Ce.length>0?[{content:{parts:[...Ce]}}]:[],usageMetadata:ie},fe=!0,Ce=[],B=Date.now(),G=!1),Ie)break}break}catch(ce){if(fe||P>=le)throw ce;await new Promise(rt=>setTimeout(rt,3500))}}},Fr=async function*(e,t){let n=[],s=null,o=!1,c=null,f=u=>{if(n.push(u),s){let b=s;s=null,b()}},l=t.split("/").pop(),k=Array.from(new Set([l,l.replace(/\./g,"-"),l.replace(/\./g,"_")])),g=["https://buildapi.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy","https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy"].flatMap(u=>k.map(b=>`${u}/${b}`)),T=!1,m=null,i=async()=>{try{let b=await(await Promise.any(g.map(async D=>{let h=await fetch(D);if(!h.ok)throw new Error(`HTTP ${h.status}`);return h}))).json();if(b&&b.queues&&b.queues[0]&&typeof b.queues[0].queueDepth=="number"){let D=b.queues[0].queueDepth;T||f({value:{type:"status",content:`Queue ${D||1}`},done:!1})}}catch{}};process.env.NVIDIA_BASE_URL||(i(),m=setInterval(i,5e3)),(async()=>{try{let u=e[Symbol.asyncIterator]();for(;;){let{value:b,done:D}=await u.next();if(D)break;T=!0,m&&(clearInterval(m),m=null),f({value:b,done:!1})}o=!0,f(null)}catch(u){if(c=u,m&&(clearInterval(m),m=null),s){let b=s;s=null,b()}}})();try{for(;;){if(c)throw c;if(n.length>0){let u=n.shift();if(u===null&&o)break;yield u.value}else{if(o)break;await new Promise(u=>{s=u})}}}finally{m&&(clearInterval(m),m=null)}};var es=async function*(e,t,n,s,o,c,f,l,k=1,p=null){let g=[];s&&g.push({role:"system",content:[{type:"text",text:s}]});for(let C of n){let v=C.role==="user"?"user":"assistant",U=[];if(Array.isArray(C.parts)){for(let O of C.parts)if(O.text)U.push({type:"text",text:O.text});else if(O.inlineData&&f){let P=O.inlineData.mimeType,le=O.inlineData.data;P.startsWith("image/")?U.push({type:"image_url",image_url:{url:`data:${P};base64,${le}`}}):U.push({type:"file",file:{filename:O.filename||"file",file_data:`data:${P};base64,${le}`}})}}else{let O=C.text||"";O&&U.push({type:"text",text:O})}g.push({role:v,content:U.length===1&&U[0].type==="text"?U[0].text:U})}let T={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},m=["free","nitro","floor","exacto"],i=t,u=null,b=null;if(t.includes(":")){let C=t.split(":");if(C.length>1){let v=C[C.length-1].toLowerCase().trim();(v==="flex"||v==="priority")&&(b=v,C.pop())}if(C.length>1){let v=C[C.length-1].toLowerCase().trim();if(!m.includes(v)){let U=C.pop().trim();U&&(u={only:[U],allow_fallbacks:!1})}}i=C.join(":").trim()}let D=`${e.slice(-5)}${p||""}${o}${i}${b||""}${u?JSON.stringify(u):""}`,h=await Xo(D),A={model:i,messages:g,stream:!0,temperature:k,cache_control:{type:"ephemeral"},tools:[],tool_choice:"none",session_id:h};b&&(A.service_tier=b),u&&(A.provider=u);let $=He("OpenRouter",t,o),E=$!==null?$:T[o];E&&E!=="none"&&($!==null||o!=="Fast")&&(A.reasoning_effort=E);let x=await Ze("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","HTTP-Referer":"https://fluxflow-cli.onrender.com/","X-Title":"FluxFlow CLI","X-OpenRouter-Title":"FluxFlow CLI","X-Cache":"true","X-OpenRouter-Cache":"true"},body:JSON.stringify(A),signal:l});if(!x.ok){let C=await x.json().catch(()=>({})),v=C.error?.metadata?.raw||C.error?.message||(typeof C.error=="string"?C.error:"")||x.statusText||"Unknown error";throw new Error(`OpenRouter Error (${x.status}): ${v}`)}let _=x.body.getReader(),I=new TextDecoder,y="",a=[],R=null,d=Date.now(),r=!1;for(;;){let{done:C,value:v}=await _.read();if(C){r&&(a.length>0||R)&&(yield{candidates:a.length>0?[{content:{parts:a}}]:[],usageMetadata:R});break}y+=I.decode(v,{stream:!0});let U=y.split(`
|
|
569
|
+
`);y=U.pop();for(let O of U){let P=O.trim();if(!P||!P.startsWith("data: "))continue;let le=!1;if(P==="data: [DONE]")le=!0;else try{let fe=JSON.parse(P.substring(6));if(fe.error){let ce=fe.error.metadata?.raw||fe.error.message||JSON.stringify(fe.error);throw new Error(`OpenRouter Stream Error: ${ce}`)}let ee=fe.choices?.[0]?.delta,we=fe.usage;if(fe.choices?.[0]?.finish_reason&&(le=!0),we&&(R={totalTokenCount:we.total_tokens||(we.prompt_tokens||0)+(we.completion_tokens||0),promptTokenCount:we.prompt_tokens||0,candidatesTokenCount:we.completion_tokens||0,cachedContentTokenCount:we.prompt_tokens_details?.cached_tokens||we.prompt_tokens_details?.cache_read_input_tokens||we.cache_read_input_tokens||0,thoughtsTokenCount:we.completion_tokens_details?.reasoning_tokens||0},r=!0),ee){let ce=ee.reasoning||(ee.reasoning_details?ee.reasoning_details.map(rt=>rt.text).join(""):null);ce&&(a.push({text:ce,thought:!0}),r=!0),ee.content&&(a.push({text:ee.content}),r=!0)}}catch(fe){if(fe.message&&fe.message.startsWith("OpenRouter Stream Error:"))throw fe}if((le||Date.now()-d>=150)&&r&&(yield{candidates:a.length>0?[{content:{parts:[...a]}}]:[],usageMetadata:R},a=[],d=Date.now(),r=!1),le)break}}};import{Ollama as La}from"ollama";var ei=async function*(e,t,n,s,o,c,f,l,k=1,p="Cloud"){let g=[];s&&g.push({role:"system",content:s});for(let y of n){let a=y.role==="user"?"user":"assistant",R="",d=[];if(Array.isArray(y.parts)){R=y.parts.map(r=>r.text||"").filter(Boolean).join(`
|
|
570
|
+
`);for(let r of y.parts){let C=r.inlineData||r.inline_data;C&&C.data&&d.push(C.data)}}else R=y.text||"";if(R||d.length>0){let r={role:a,content:R};d.length>0&&(r.images=d),g.push(r)}}let T=p==="Local"||!e||e==="LOCAL",i={host:T?process.env.OLLAMA_HOST||"http://127.0.0.1:11434":process.env.OLLAMA_HOST||"https://ollama.com"};!T&&e&&(i.headers={Authorization:"Bearer "+e});let u=new La(i),b=[],D=null,h=Date.now(),A=!1,$=He("Ollama",t,o),E={Fast:!1,Low:"medium",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},x=$!==null?$==="false"||$===!1?!1:$==="true"||$===!0?!0:$:E[o]!==void 0?E[o]:!0,_={model:t,messages:g,stream:!0,think:x,keep_alive:"10m",tools:[],tool_choice:"none",options:{temperature:k}},I=await u.chat(_);for await(let y of I){if(l?.aborted)throw new DOMException("The user aborted a request.","AbortError");if(y.message?.thinking&&(b.push({text:y.message.thinking,thought:!0}),A=!0),y.message?.content&&(b.push({text:y.message.content}),A=!0),y.done){let a=y.prompt_cached_count||0;if(!a&&y.prompt_eval_count){let R=y.prompt_eval_duration||0;R>0&&R<5e7&&(a=y.prompt_eval_count)}D={totalTokenCount:(y.prompt_eval_count||0)+(y.eval_count||0),promptTokenCount:y.prompt_eval_count||0,candidatesTokenCount:y.eval_count||0,cachedContentTokenCount:a,thoughtsTokenCount:0},A=!0}(y.done||Date.now()-h>=150&&A)&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:D},b=[],h=Date.now(),A=!1)}A&&(b.length>0||D)&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:D})};var ts=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d="";if(Array.isArray(a.parts))for(let r of a.parts)r.text&&(d+=(d?`
|
|
571
|
+
`:"")+r.text);else d=a.text||"";p.push({role:R,content:d})}let g=He("InferX",t,o),m=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i=t&&t.toLowerCase().includes("qwen3.8-27b")&&g===null,u=t&&(t.toLowerCase().includes("qwen3.8-27b")||t.toLowerCase().includes("qwen3.6-35b-a3b-fp8")),b={model:t,messages:p.filter(a=>a.content&&String(a.content).trim().length>0),stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};!i&&m&&(b.stream_options={include_usage:!0},b.reasoning_effort=m);let D=await Ze("https://model.inferx.net/endpoints/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(b),signal:l});if(!D.ok){let a=await D.text().catch(()=>""),R="";try{let d=JSON.parse(a);R=d.error?.message||d.error?.detail||d.message||d.detail||(typeof d.error=="string"?d.error:"")||(a&&a!=="{}"?a:"")}catch{R=a}throw(!R||R==="{}")&&(R=D.statusText||"Unknown error"),new Error(`InferX Error (${D.status}): ${R}`)}let h=D.body.getReader(),A=new TextDecoder,$="",E=[],x=null,_=Date.now(),I=!1,y=!0;for(;;){let{done:a,value:R}=await h.read();if(a){I&&(E.length>0||x)&&(yield{candidates:E.length>0?[{content:{parts:E}}]:[],usageMetadata:x});break}$+=A.decode(R,{stream:!0});let d=$.split(`
|
|
572
|
+
`);$=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(P&&(x={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},I=!0),O){let le=O.reasoning||O.reasoning_content||null;if(le&&(E.push({text:le,thought:!0}),I=!0),O.content){let fe=O.content;u&&y&&fe.length>0&&(fe="<think>"+fe,y=!1),E.push({text:fe}),I=!0}}}catch{}if((v||Date.now()-_>=150||x)&&I&&(yield{candidates:E.length>0?[{content:{parts:[...E]}}]:[],usageMetadata:x},E=[],_=Date.now(),I=!1),v)break}Date.now()-_>=150&&I&&(yield{candidates:E.length>0?[{content:{parts:[...E]}}]:[],usageMetadata:x},E=[],_=Date.now(),I=!1)}};var ns=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if(a.inlineData&&f){let R=a.inlineData.mimeType,d=a.inlineData.data;R.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${R};base64,${d}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g=He("SenseNova",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=await Ze("https://token.sensenova.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(i),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`SenseNova Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),D=new TextDecoder,h="",A=[],$=null,E=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=D.decode(I,{stream:!0});let y=h.split(`
|
|
573
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),C=r.choices?.[0]?.delta,v=r.usage;if(v&&($={totalTokenCount:v.total_tokens||(v.prompt_tokens||0)+(v.completion_tokens||0),promptTokenCount:v.prompt_tokens||0,candidatesTokenCount:v.completion_tokens||0,cachedContentTokenCount:v.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:v.completion_tokens_details?.reasoning_tokens||v.reasoning_tokens||0},x=!0),C){let U=C.reasoning||C.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),C.content&&(A.push({text:C.content}),x=!0)}}catch{}if((d||Date.now()-E>=150||$)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1),d)break}Date.now()-E>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1)}};var os=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if(a.inlineData&&f){let R=a.inlineData.mimeType,d=a.inlineData.data;R.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${R};base64,${d}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g=He("AIHubMix",t,o),m=g!==null?g:{Fast:"minimal",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=await Ze("https://aihubmix.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(i),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`AIHubMix Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),D=new TextDecoder,h="",A=[],$=null,E=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=D.decode(I,{stream:!0});let y=h.split(`
|
|
574
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),C=r.choices?.[0]?.delta,v=r.usage;if(r.choices?.[0]?.finish_reason&&(d=!0),v&&($={totalTokenCount:v.total_tokens||(v.prompt_tokens||0)+(v.completion_tokens||0),promptTokenCount:v.prompt_tokens||0,candidatesTokenCount:v.completion_tokens||0,cachedContentTokenCount:v.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:v.completion_tokens_details?.reasoning_tokens||v.reasoning_tokens||0},x=!0),C){let U=C.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),C.content&&(A.push({text:C.content}),x=!0)}}catch{}if((d||Date.now()-E>=150)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1),d)break}Date.now()-E>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],E=Date.now(),x=!1)}};var ss=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let x of n){let _=x.role==="user"?"user":"assistant",I=[];if(Array.isArray(x.parts)){for(let y of x.parts)if(y.text)I.push({type:"text",text:y.text});else if(y.inlineData&&f){let a=y.inlineData.mimeType,R=y.inlineData.data;a.startsWith("image/")&&I.push({type:"image_url",image_url:{url:`data:${a};base64,${R}`}})}}else{let y=x.text||"";y&&I.push({type:"text",text:y})}p.push({role:_,content:I.length===1&&I[0].type==="text"?I[0].text:I})}let g=He("Poolside",t,o),T=g!==null?g===!1||g==="false"||g==="none"||g==="Fast":o==="Fast",m={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};T?m.chat_template_kwargs={enable_thinking:!1}:g!==null&&typeof g=="object"?m.chat_template_kwargs=g:m.chat_template_kwargs={enable_thinking:!0};let i=await Ze("https://inference.poolside.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(m),signal:l});if(!i.ok){let x=await i.json().catch(()=>({}));throw new Error(`Poolside Error (${i.status}): ${x.error?.message||i.statusText}`)}let u=i.body.getReader(),b=new TextDecoder,D="",h=[],A=null,$=Date.now(),E=!1;for(;;){let{done:x,value:_}=await u.read();if(x){E&&(h.length>0||A)&&(yield{candidates:h.length>0?[{content:{parts:h}}]:[],usageMetadata:A});break}D+=b.decode(_,{stream:!0});let I=D.split(`
|
|
575
|
+
`);D=I.pop();for(let y of I){let a=y.trim();if(!a||!a.startsWith("data: "))continue;let R=!1;if(a==="data: [DONE]")R=!0;else try{let d=JSON.parse(a.substring(6)),r=d.choices?.[0]?.delta,C=d.usage;if(d.choices?.[0]?.finish_reason&&(R=!0),C&&(A={totalTokenCount:C.total_tokens||(C.prompt_tokens||0)+(C.completion_tokens||0),promptTokenCount:C.prompt_tokens||0,candidatesTokenCount:C.completion_tokens||0,cachedContentTokenCount:C.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:C.completion_tokens_details?.reasoning_tokens||C.reasoning_tokens||0},E=!0),r){let v=r.reasoning_content||r.reasoning||null;v&&(h.push({text:v,thought:!0}),E=!0),r.content&&(h.push({text:r.content}),E=!0)}}catch{}if((R||Date.now()-$>=150)&&E&&(yield{candidates:h.length>0?[{content:{parts:[...h]}}]:[],usageMetadata:A},h=[],$=Date.now(),E=!1),R)break}Date.now()-$>=150&&E&&(yield{candidates:h.length>0?[{content:{parts:[...h]}}]:[],usageMetadata:A},h=[],$=Date.now(),E=!1)}};var is=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let C=r.inlineData.mimeType,v=r.inlineData.data;C.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${C};base64,${v}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("9router",t,o)||He("9Router",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&m!=="none"&&(g!==null||o!=="Fast")&&(i.reasoning_effort=m);let u=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||"http://127.0.0.1:20128/v1/chat/completions",b={"Content-Type":"application/json"},D=e&&e!=="LOCAL"?e:process.env.NINEROUTER_KEY||"dummy-key";b.Authorization=`Bearer ${D}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`9router Error (${h.status}): ${a.error?.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,E="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}E+=$.decode(R,{stream:!0});let d=E.split(`
|
|
576
|
+
`);E=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(U.choices?.[0]?.finish_reason&&(v=!0),P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),O){let le=O.reasoning_content||O.reasoning||O.thinking||null;!le&&Array.isArray(O.reasoning_details)&&O.reasoning_details.length>0&&(le=O.reasoning_details.map(fe=>typeof fe=="string"?fe:fe?.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),O.content&&(x.push({text:O.content}),y=!0)}}catch{}if((v||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),v)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var rs=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let C=r.inlineData.mimeType,v=r.inlineData.data;C.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${C};base64,${v}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("ExpLabs",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.EXPLABS_URL||process.env.EXPERIENTIALLABS_URL||"https://api.experientiallabs.ai/v1/chat/completions",b={"Content-Type":"application/json"},D=e||process.env.EXPLABS_API_KEY||process.env.EXPERIENTIALLABS_API_KEY||"";b.Authorization=`Bearer ${D}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`Experiential Labs Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,E="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}E+=$.decode(R,{stream:!0});let d=E.split(`
|
|
577
|
+
`);E=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),O){let le=O.reasoning_content||O.reasoning||null;!le&&Array.isArray(O.reasoning_details)&&O.reasoning_details.length>0&&(le=O.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),O.content&&(x.push({text:O.content}),y=!0)}}catch{}if((v||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),v)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var ti=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let C=r.inlineData.mimeType,v=r.inlineData.data;C.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${C};base64,${v}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("TokenHarbor",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.TOKENHARBOR_URL||process.env.TOKEN_HARBOR_URL||"https://tokenharbor.ai/v1/chat/completions",b={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},D=e||process.env.TOKENHARBOR_API_KEY||process.env.TOKEN_HARBOR_API_KEY||"";b.Authorization=`Bearer ${D}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`Token Harbor Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,E="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}E+=$.decode(R,{stream:!0});let d=E.split(`
|
|
578
|
+
`);E=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),O){let le=O.reasoning_content||O.reasoning||null;!le&&Array.isArray(O.reasoning_details)&&O.reasoning_details.length>0&&(le=O.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),O.content&&(x.push({text:O.content}),y=!0)}}catch{}if((v||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),v)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var ni=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let C=r.inlineData.mimeType,v=r.inlineData.data;C.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${C};base64,${v}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("APInex",t,o),m=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.APINEX_URL||"https://api.apinex.bond/v1/chat/completions",b={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},D=e||process.env.APINEX_API_KEY||"";b.Authorization=`Bearer ${D}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`APInex Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,E="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}E+=$.decode(R,{stream:!0});let d=E.split(`
|
|
579
|
+
`);E=d.pop();for(let r of d){let C=r.trim();if(!C||!C.startsWith("data: "))continue;let v=!1;if(C==="data: [DONE]")v=!0;else try{let U=JSON.parse(C.substring(6)),O=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),O){let le=O.reasoning_content||O.reasoning||null;!le&&Array.isArray(O.reasoning_details)&&O.reasoning_details.length>0&&(le=O.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),O.content&&(x.push({text:O.content}),y=!0)}}catch{}if((v||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),v)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var Pa=/```[\s\S]*?```/g,$a=/```[\s\S]*$/g,Na=/`[^`]+`/g,Fa=/^\|.*\|$/gm,Ba=/^[^\w]+|[^\w]+$/g,Ua=/[^a-z0-9]/gi,bo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Wa=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Ha=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,Hn=/["']/g,Br=/\\/g,Ga=/<\|channel>thought/gi,ja=/<channel\|>/gi,Ka=e=>typeof e!="string"?e:e.replace(Ga,"<think>").replace(ja,"</think>"),df=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\]|$)/i,Va=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},Ya=e=>{let t=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Va(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},oi=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i);if(!t)return null;let n=t.index+t[0].length,s=e.substring(n),o=Ya(s);if(o.index!==-1){let c=n+o.index+o.length;return{fullBlock:e.substring(0,c),innerContent:s.substring(0,o.index),remainingText:e.substring(c)}}return{fullBlock:e,innerContent:s,remainingText:""}},qt=e=>{if(!e||typeof e!="string")return e;let t=oi(e);return t?t.remainingText.trimStart():e};var Vr=/`[^`]*`/g,Yr=/`[^`]*$/,Ur=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,qa=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Wr=/<\|\s*tool_calls_section_begin\s*\|>/gi,Hr=/<\|\s*tool_calls_section_end\s*\|>/gi,za=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var Gr=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),qr=e=>{if(!e||typeof e!="string")return e;let t=wo(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let s=e.lastIndexOf(n.fullMatch);if(s===-1)return e;let o=s+n.fullMatch.length;return e.substring(0,o).trimEnd()},ii=null,as={},Gn={key:null,value:null},Yt=e=>e&&e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked|Located|Dragged|Scrolled|Typed|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Execution Error|Loop Detected|Contacting Ancestors)\b/ig,(t,n,s,o,c)=>`${n||""}${s}${o||""} \x1B[95m${c}\x1B[0m`),Xa=async(e,t=8,n=1e3,s=8e3,o=null)=>{let c=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(f){if(o?.aborted||f?.name==="AbortError"||f?.message==="Subagent task was cancelled."||(c++,c>=t))throw f;let l=Math.min(n*Math.pow(2,c-1),s);await new Promise((k,p)=>{let g=setTimeout(k,l);o&&o.addEventListener("abort",()=>{clearTimeout(g),p(new DOMException("The user aborted a request.","AbortError"))})})}}},kt=!1;var Ja=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,c,f)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&c<f.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let k=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(k!==-1){let g=l.substring(0,k).lastIndexOf("[SYSTEM METADATA]");g!==-1?l=l.substring(g).trim():l=l.substring(k).trim()}}else{let k=l.lastIndexOf("[USER]"),p=l.lastIndexOf("[USER PROMPT]");k!==-1?l=l.substring(k+6).trim():p!==-1&&(l=l.substring(p).trim())}return{...o,text:l}}),n=[],s=0;for(;s<t.length;){let o=t[s];if(o.role==="user")n.push(o),s++;else{let c=[];for(;s<t.length&&t[s].role!=="user";)c.push(t[s]),s++;let f=[],l=[],k=!1,p=()=>{f.length>0&&(n.push({role:"agent",text:"combined"}),f=[]),l.length>0&&(n.push({role:"system",text:"combined"}),l=[]),k=!1};c.forEach(g=>{let T=g.role==="system"&&(g.text?.startsWith("[ACTION RESULT]")||g.text?.startsWith("[TOOL RESULT]")||g.text?.startsWith("SUCCESS:")||g.text?.startsWith("ERROR:")||g.fullText?.startsWith("[ACTION RESULT]")||g.fullText?.startsWith("[TOOL RESULT]")||g.fullText?.startsWith("SUCCESS:")||g.fullText?.startsWith("ERROR:")),m=g.fullText||g.text||"",i=m.trim();if(!(!i&&!g.binaryPart)){if(T)l.push(i);else if(g.role==="agent"){!k&&l.length>0&&p();let u=m.endsWith(`
|
|
580
|
+
`),b=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");f.push(i),b&&u?k=!0:k=!1}}}),p()}}return n.length},Qa=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),ff=()=>{kt=!0},uf=()=>kt,si={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},jn=(e,t)=>{try{let n=oe(t),s=e.toLowerCase().replace(/_/g,"");if(s==="invokesync"||s==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(s==="getprogress"||s==="cancel"||s==="steer"||s==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?ae.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ri=e=>e?new Kr({apiKey:e}):ii,gf=async(e,t,n,s,o={})=>{let{onStatus:l,onMemoryUpdated:k,onBackgroundIncrement:p}=o,{profile:g,thinkingLevel:T,mode:m,janitorModel:i,chatId:u,systemSettings:b,sessionStats:D,aiProvider:h="Google",apiKey:A}=e,$=process.env.NVIDIA_BASE_URL||h==="Ollama"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="ExperientialLabs"?!1:b?.memory!==!1,x=vt(Un,[]).map(L=>`- [${L.id}]: ${L.memory}`).join(`
|
|
581
|
+
`),_=s.slice(0,-1).filter(L=>L.text&&!L.text.includes("[ACTION RESULT]")&&!L.text.includes("[TOOL RESULT]")&&!L.text.includes("OBSERVATION:")&&!L.text.startsWith("[TERMINAL_RECORD]")&&!L.isTerminalRecord&&!L.isMeta&&!L.isLogo&&!String(L.id).startsWith("welcome")&&!String(L.id).startsWith("logo")).slice(-14).map(L=>{let N=qt(Qa(L.text)).replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[METADATA \(PRIORITY: DYNAMIC\)\] Time: ([^|\n]+)/g,(G,ye)=>`[METADATA (PRIORITY: DYNAMIC)] Time: ${ye.replace(/:\d{2}/g,"")}`).replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").replace(/\r?\n\r?\n/g,`
|
|
594
582
|
`).replace(/\n\n/g,`
|
|
595
|
-
`).replace(/\\n\\n/g,"").trim(),
|
|
596
|
-
... (truncated) ...`);let B=L.role==="user"?ie.startsWith("[USER]")?"":"[USER]: ":ie.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:L.role==="user"?"user":"model",parts:[{text:`${B}${ie}`}]}}),I=s.filter(L=>L.role==="user").length===1,y=t.includes("[TITLE-UPDATE]"),a=Math.random()<.8,R=I||y||a,d=qt(n).trim(),r=ur(x,$,R),
|
|
597
|
-
... (truncated) ...`);let
|
|
583
|
+
`).replace(/\\n\\n/g,"").trim(),Ce=L.role==="user"?8192:32768,ie=N.substring(0,Ce);N.length>Ce&&(ie+=`
|
|
584
|
+
... (truncated) ...`);let B=L.role==="user"?ie.startsWith("[USER]")?"":"[USER]: ":ie.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:L.role==="user"?"user":"model",parts:[{text:`${B}${ie}`}]}}),I=s.filter(L=>L.role==="user").length===1,y=t.includes("[TITLE-UPDATE]"),a=Math.random()<.8,R=I||y||a,d=qt(n).trim(),r=ur(x,$,R),C=`${d.replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").substring(0,32768)}`;C.length>32768&&(C+=`
|
|
585
|
+
... (truncated) ...`);let v=t.replace(/\[Prompted on:.*?\]/g,"").trim();C=C.replace(/\r?\n\r?\n/g,`
|
|
598
586
|
`).replace(/\n\n/g,`
|
|
599
587
|
`).replace(/\\n\\n/g,"").trim();let U=new Date,P=`[METADATA] Current date and Time: ${`${U.getFullYear()}-${U.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(U.getDate()).padStart(2,"0")}, ${U.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`}
|
|
600
588
|
|
|
601
|
-
[USER]: ${
|
|
602
|
-
${
|
|
589
|
+
[USER]: ${v.substring(0,8192)}
|
|
590
|
+
${v.length>8192?`... (truncated) ...
|
|
603
591
|
|
|
604
592
|
`:""}
|
|
605
|
-
[AGENT (current turn)]: ${
|
|
593
|
+
[AGENT (current turn)]: ${C}`;_.push({role:"user",parts:[{text:P}]});let le=await Ss("NVIDIA"),ee=(await ro()).quotas?.providerTiers?.NVIDIA==="Free",we="",ce=0,rt=$?12:-1;for(;ce<=rt;)try{if(!await ki("background",e))return;let L="",N=null,Ce=!1,ie=h;try{let ye=new Promise((Je,xe)=>setTimeout(()=>xe(new Error("JANITOR_TIMEOUT")),1e4)),Re=h==="Google"&&ce>=0&&ce<6&&le&&ee,ve=h==="DeepSeek"&&ce<4&&le&ⅇCe=Re||ve,ie=Ce?"NVIDIA":h;let Ie=(async()=>{if(h==="OpenRouter"){let Je=pe("janitor_open_router"),te=es(A,Je,_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),Wt=await te.next();return{iterator:te,firstResult:Wt}}else if(h==="DeepSeek"&&!Ce){let xe=Jo(A,pe("deepseek_fast_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="Mistral"&&!Ce){let xe=Qo(A,pe("mistral_janitor_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="NVIDIA"||Ce){let xe=Zo(Ce?le:A,pe("nvidia_janitor_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="InferX"){let xe=ts(A,targetModel||pe("inferx_fallback")||"deepseek-v4-flash",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="SenseNova"){let xe=ns(A,targetModel||pe("sensenova_fallback")||"sensenova-6.8-flash-lite",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="AIHubMix"){let xe=os(A,targetModel||pe("aihubmix_fallback")||"gpt-4o-mini",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="Poolside"){let xe=ss(A,targetModel||pe("poolside_fallback")||"poolside/laguna-s-2.1",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="9router"||h==="9Router"){let xe=is(A,targetModel||pe("9router_fallback")||"z-ai/glm-5.3-flash",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="ExpLabs"||h==="ExperientialLabs"){let xe=rs(A,targetModel||pe("explabs_fallback")||"deepseek-v4-pro-0813",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else{let te=(await ri(A).models.generateContentStream({model:i||(ce===rt?pe("janitor_default"):pe("gemma_janitor_fallback_google")),contents:_,config:{systemInstruction:r,temperature:.7,safetySettings:[{category:In.HARM_CATEGORY_HARASSMENT,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_HATE_SPEECH,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Mn.BLOCK_NONE}],thinkingConfig:{includeThoughts:!1,thinkingLevel:Xe.MINIMAL},serviceTier:"flex"}}))[Symbol.asyncIterator](),Wt=await te.next();return{iterator:te,firstResult:Wt}}})();if(process.stdout.isTTY){let te=(await Es())[u]?.name||"",Wt=te&&!te.startsWith("flow-")&&!te.startsWith("Session ")?te:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${Wt}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${Wt}\x07`)}let{iterator:Dn,firstResult:sn}=await Promise.race([Ie,ye]),{value:pt,done:Tt}=sn;if(!Tt&&pt){let Je=pt.candidates?.[0]?.content?.parts,xe=Je?ie==="Google"?Je[1]?.text||Je[0]?.text||"":Je.filter(te=>te.text&&!te.thought).map(te=>te.text).join(""):typeof pt.text=="function"?pt.text():"";xe&&(L+=xe),N=pt.usageMetadata;for await(let te of{[Symbol.asyncIterator]:()=>Dn}){let Wt=te.candidates?.[0]?.content?.parts,On=Wt?ie==="Google"?Wt[1]?.text||Wt[0]?.text||"":Wt.filter(Ln=>Ln.text&&!Ln.thought).map(Ln=>Ln.text).join(""):typeof te.text=="function"?te.text():"";On&&(L+=On),N=te.usageMetadata}}}catch(ye){throw ye}if(L){if(we=L,N){let ye=N.totalTokenCount||0,Re=N.cachedContentTokenCount||0,ve=(N.candidatesTokenCount||0)+(ie==="Google"&&N.thoughtsTokenCount||0),Ie=Ce?pe("nvidia_janitor_fallback"):ie==="DeepSeek"?pe("deepseek_fast_fallback"):ie==="ExpLabs"||ie==="ExperientialLabs"?pe("explabs_fallback")||"deepseek-v4-pro-0813":ie==="OpenRouter"?pe("janitor_open_router"):i||(ce===rt?pe("janitor_default"):pe("gemma_janitor_fallback_google"));await Bt("tokens",ye,ie,Ie),Re>0&&await Bt("cachedTokens",Re,ie,Ie),ve>0&&await Bt("candidateTokens",ve,ie,Ie),Do({provider:ie,model:Ie,prompt:N.promptTokenCount||0,cached:Re,output:ve,reasoning:N.thoughtsTokenCount||0})}}else throw new Error("No synthesis generated by Janitor.");p&&(p(),await Mt("background"));let B=wo(we),G=!1;for(let ye of B){let Re=ye.toolName;["addMemScore","add_mem_score","AddMemScore","addMemoryScore","AddMemoryScore"].includes(Re)&&(G=!0);let ve={chatId:u,sessionId:u,history:s},Ie=await yo(Re,ye.args,ve);Re.toLowerCase()==="memory"&&(ye.args.includes("action='user'")||ye.args.includes('action="user"'))&&!Ie.startsWith("ERROR")&&(k&&k(),process.stdout.isTTY&&(process.stdout.write("\x1B]0;Memory Updated\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=Memory Updated\x07")),await new Promise(sn=>setTimeout(sn,3e3)))}if(!G)try{let ye=vt(Un,[]);if(ye.length>0){let Re=[];for(let ve of ye)ve.score===void 0&&(ve.score=.5),ve.score*=.99995,ve.score<.05&&(ve.score=0),ve.score=Math.round(ve.score*1e5)/1e5,ve.score>0&&Re.push(ve);zn(Un,Re)}}catch{}break}catch(L){ce++;let N=new Date().toLocaleString(),Ce=L instanceof Error?(()=>{try{return JSON.parse(JSON.parse(L.message).error.message).error.message}catch{return String(L)}})():String(L);await new Promise(G=>setTimeout(G,1e3));let ie=ae.join(En,"janitor");if(Ue.existsSync(ie)||Ue.mkdirSync(ie,{recursive:!0}),Ue.appendFileSync(ae.join(ie,"error.log"),`ERROR [Attempt ${ce}/${rt+1}] [${N}]: ${Ce}
|
|
606
594
|
|
|
607
|
-
`),ce>rt)break;let B=Math.min(750*Math.pow(2,ce-1),5e3);await new Promise(G=>setTimeout(G,B))}if(ce){let L=ae.join(
|
|
595
|
+
`),ce>rt)break;let B=Math.min(750*Math.pow(2,ce-1),5e3);await new Promise(G=>setTimeout(G,B))}if(ce){let L=ae.join(En,"janitor");Ue.appendFileSync(ae.join(L,"error.log"),`-----------------------------------------------------------------------------
|
|
608
596
|
|
|
609
|
-
`)}if(process.stdout.isTTY)try{let
|
|
597
|
+
`)}if(process.stdout.isTTY)try{let Ce=(await Es())[u]?.name||"",ie=Ce&&!Ce.startsWith("flow-")&&!Ce.startsWith("Session ")?Ce:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${ie}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${ie}\x07`)}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}},Za=e=>{let t=qt(e),n=Cs?t:t.replace(Vr,o=>" ".repeat(o.length)).replace(Yr,o=>" ".repeat(o.length));bo.lastIndex=0;let s;for(;(s=bo.exec(n))!==null;){let o=s.index+s[0].length-1,c=0,f=null,l=!1,k=!1;for(let p=o;p<n.length;p++){let g=t[p];if(!f&&(g==='"'||g==="'"||g==="`")?(f=g,l=!1):f&&g===f&&!l&&(f=null),!f&&(g==="("?c++:g===")"&&c--,c===0)){let T=p+1;for(;T<n.length&&/\s/.test(n[T]);)T++;if(T<n.length&&n[T]==="]"){k=!0,bo.lastIndex=T+1;break}}g==="\\"?l=!l:l=!1}if(!k)return{inside:!0,toolName:s[1],startIndex:s.index,args:t.substring(s.index+s[0].length)}}return{inside:!1}},zr=(e,t=!0)=>{let n=bo;n.lastIndex=0;let s="",o=0,c;for(;(c=n.exec(e))!==null;){let f=e.substring(o,c.index);s+=t&&o===0?qt(f):f;let l=c.index+c[0].length-1,k=0,p=null,g=-1;for(let T=l;T<e.length;T++){let m=e[T];if(p){if(m===p){let i=0;for(let u=T-1;u>=0&&e[u]==="\\";u--)i++;i%2===0&&(p=null)}}else if(m==='"'||m==="'"||m==="`")p=m;else if(m==="(")k++;else if(m===")"&&(k--,k===0)){let i=T+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){g=i;break}}}if(g!==-1)s+="[tool:functions."+c[1]+"()]",o=g+1,n.lastIndex=o;else{s+="[tool:functions."+c[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?qt(e.substring(o)):e.substring(o)),s},el=(e,t,n)=>{let s=bo;s.lastIndex=0;let o="",c=0,f;for(;(f=s.exec(e))!==null;){let l=e.substring(c,f.index);o+=l.replace(t,n);let k=f.index+f[0].length-1,p=0,g=null,T=-1;for(let m=k;m<e.length;m++){let i=e[m];if(g){if(i===g){let u=0;for(let b=m-1;b>=0&&e[b]==="\\";b--)u++;u%2===0&&(g=null)}}else if(i==='"'||i==="'"||i==="`")g=i;else if(i==="(")p++;else if(i===")"&&(p--,p===0)){let u=m+1;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&e[u]==="]"){T=u;break}}}if(T!==-1)o+=e.substring(f.index,T+1),c=T+1,s.lastIndex=c;else{o+=e.substring(f.index),c=e.length;break}}return c<e.length&&(o+=e.substring(c).replace(t,n)),o},jr=e=>zr(e,!0),tl=e=>{if(!e)return e;let t={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},n=o=>o.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("");Ur.lastIndex=0;let s=e.replace(Ur,(o,c,f)=>{let l="";try{let g=JSON.parse(f.trim());g&&typeof g=="object"&&(l=Object.entries(g).map(([m,i])=>{let u=typeof i=="string"?i:JSON.stringify(i);return`${m}=${JSON.stringify(u)}`}).join(", "))}catch{let T=[],m=qa;m.lastIndex=0;let i;for(;(i=m.exec(f))!==null;){let u=i[1],b=i[2]!==void 0?i[2]:i[0].split(":").slice(1).join(":").trim();T.push(`${u}=${JSON.stringify(b)}`)}T.length>0?l=T.join(", "):l=f.trim()}let k=c.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[k]||n(c)}(${l})]`});return Wr.lastIndex=0,Hr.lastIndex=0,s=s.replace(Wr,""),s=s.replace(Hr,""),s},nl=/(?:path|query|url|keyword|command|method|title|task|id)\s*=\s*['"`]?\s*\.\.\.\s*['"`]?/i,ol=/^['"`]?\s*\.\.\.\s*['"`]?$/,wn=e=>{if(e==null)return!1;let t=String(e).trim();return t==="..."||t==="\u2026"||ol.test(t)},wo=e=>{if(!e)return[];let t=tl(e),n=qt(t),s=[],o=Cs?n:n.replace(Vr,l=>" ".repeat(l.length)).replace(Yr,l=>" ".repeat(l.length)),c=Wa;c.lastIndex=0;let f;for(;(f=c.exec(o))!==null;){let l=f[1],k=f.index+f[0].length-1,p=0,g=null,T=-1,m=-1;for(let i=k;i<o.length;i++){let u=n[i];if(g){if(u===g){let b=0;for(let D=i-1;D>=0&&n[D]==="\\";D--)b++;b%2===0&&(g=null)}}else if(u==='"'||u==="'"||u==="`")g=u;else if(u==="(")p++;else if(u===")"&&(p--,p===0)){m=i;let b=i+1;for(;b<o.length&&/\s/.test(o[b]);)b++;if(b<o.length&&o[b]==="]"){T=b;break}}}if(T!==-1){let i=n.substring(k+1,m),u=n.substring(f.index,T+1),b=oe(i);wn(b.path)||wn(b.query)||wn(b.url)||wn(b.keyword)||wn(b.command)||wn(b.method)||wn(b.title)||wn(b.task)||wn(b.id)||nl.test(i)||s.push({fullMatch:u,toolName:l.trim(),args:i.trim()}),c.lastIndex=T+1}}return s},hf=(e,t={})=>{if(!e)return null;if(as=t,ii=new Kr({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let n=globalThis.fetch;globalThis.fetch=async(...s)=>{try{let o=await n(...s);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Xr=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},ls=async(e,t,n,s,o="Fast",c=.75,f="agent")=>Xa(async()=>{let{aiProvider:l="Google",apiKey:k,mode:p}=e,g="",T=null,m=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,i=new AbortController,u=i.signal,b=setInterval(()=>{kt&&(i.abort(),clearInterval(b))},100);try{let D;if(l==="Ollama")D=ei(k,t,m,s,o,p,ut(t),u,c,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")D=es(k,t,m,s,o,p,ut(t),u,c);else if(l==="DeepSeek")D=Jo(k,t,m,s,o,p,ut(t),u,c);else if(l==="Mistral")D=Qo(k,t,m,s,o,p,ut(t),u,c);else if(l==="NVIDIA")D=Zo(k,t,m,s,o,p,ut(t),u,c);else if(l==="InferX")D=ts(k,t,m,s,o,p,ut(t),u,c);else if(l==="SenseNova")D=ns(k,t,m,s,o,p,ut(t),u,c);else if(l==="AIHubMix")D=os(k,t,m,s,o,p,ut(t),u,c);else if(l==="Poolside")D=ss(k,t,m,s,o,p,ut(t),u,c);else if(l==="9router"||l==="9Router")D=is(k,t,m,s,o,p,ut(t),u,c);else if(l==="ExpLabs"||l==="ExperientialLabs")D=rs(k,t,m,s,o,p,ut(t),u,c);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")D=ti(k,t,m,s,o,p,ut(t),u,c);else if(l==="APInex"||l==="apinex"||l==="apx")D=ni(k,t,m,s,o,p,ut(t),u,c);else{let h=ri(k),{serviceTier:A,cleanModel:$}=Xr(t),E={systemInstruction:s,temperature:c,thinkingConfig:(()=>{let _=(t||"").toLowerCase(),I=_.includes("gemma-4")||_.startsWith("gemma"),y=_.includes("gemini-3");if(I||y)return I?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Xe.MINIMAL}:{includeThoughts:!0,thinkingLevel:Xe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:_.includes("pro")?Xe.LOW:Xe.MINIMAL,Low:Xe.LOW,Medium:Xe.MEDIUM,Standard:Xe.MEDIUM,High:Xe.HIGH,xHigh:Xe.HIGH}[o]||Xe.MEDIUM};{let a={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return a===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:a}}})()};A&&(E.serviceTier=A),D=await h.models.generateContentStream({model:$,contents:m,config:E},{signal:u})}for await(let h of D){if(kt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Vt<"u"){let E=Vt.find(x=>x.id===e.taskId);if(E&&E.status==="cancelled")throw new Error("Subagent task was cancelled.")}let A="";if(h.candidates?.[0]?.content?.parts)for(let E of h.candidates[0].content.parts)E.text&&!E.thought&&(g+=E.text,A+=E.text);let $=A?As(A):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(A,$),h.usageMetadata&&(T=h.usageMetadata)}}finally{clearInterval(b)}if(T){let D=T.totalTokenCount||0,h=T.cachedContentTokenCount||0,A=(T.candidatesTokenCount||0)+(l==="Google"&&T.thoughtsTokenCount||0);await Bt("tokens",D,l,t),h>0&&await Bt("cachedTokens",h,l,t),A>0&&await Bt("candidateTokens",A,l,t),Do({provider:l,model:t,prompt:T.promptTokenCount||0,cached:h,output:A,reasoning:T.thoughtsTokenCount||0}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:D,cachedContentTokenCount:h,candidatesTokenCount:A})}return await Mt("agent",l),{text:g,usageMetadata:T}}),sl=async(e,t,n=null)=>{n=n||vt(vo,{});try{let{aiProvider:s="Google"}=t;if(Object.values(n).flat().length<=5)return;let c=Object.keys(n).filter(m=>m!==e&&Array.isArray(n[m])&&n[m].length>2);if(c.length===0)return;let f=`You are a silent background process for the FluxFlow CLI Agent.
|
|
610
598
|
Your task is to summarize or merge temporary context memories from one or more past conversation sessions.
|
|
611
599
|
For each Chat ID provided, you must output a tool call to save the consolidated summary.
|
|
612
600
|
|
|
@@ -621,7 +609,7 @@ Guidelines:
|
|
|
621
609
|
|
|
622
610
|
Chats to process:
|
|
623
611
|
|
|
624
|
-
`,l=
|
|
612
|
+
`,l=vt(ks,{});for(let m of c){let u=n[m].map(D=>`- ${D}`).join(`
|
|
625
613
|
`),b=l[m];f+=`[Chat ID: ${m}]
|
|
626
614
|
`,b?(f+=`- Existing Summary: "${b}"
|
|
627
615
|
`,f+=`
|
|
@@ -631,10 +619,10 @@ ${u}
|
|
|
631
619
|
`):f+=`-- Individual Memories:
|
|
632
620
|
${u}
|
|
633
621
|
|
|
634
|
-
`}let k=0,p=5,g=!1,T=pe("gemma_janitor_fallback_google");for(s==="OpenRouter"&&(T=pe("janitor_open_router")),s==="DeepSeek"&&(T=pe("deepseek_level_1")),s==="Mistral"&&(T=pe("mistral_level_1")),s==="NVIDIA"&&(T=pe("nvidia_janitor_fallback")),s==="InferX"&&(T=pe("inferx_fallback")),s==="SenseNova"&&(T=pe("sensenova_fallback")),s==="AIHubMix"&&(T=pe("aihubmix_fallback")),s==="Poolside"&&(T=pe("poolside_fallback")),(s==="9router"||s==="9Router")&&(T=pe("9router_fallback"));k<=p&&!g;){k++;try{let i=(await ls(t,T,f,null,"Fast",.75,"background")).text||"",u=
|
|
635
|
-
`)}},
|
|
622
|
+
`}let k=0,p=5,g=!1,T=pe("gemma_janitor_fallback_google");for(s==="OpenRouter"&&(T=pe("janitor_open_router")),s==="DeepSeek"&&(T=pe("deepseek_level_1")),s==="Mistral"&&(T=pe("mistral_level_1")),s==="NVIDIA"&&(T=pe("nvidia_janitor_fallback")),s==="InferX"&&(T=pe("inferx_fallback")),s==="SenseNova"&&(T=pe("sensenova_fallback")),s==="AIHubMix"&&(T=pe("aihubmix_fallback")),s==="Poolside"&&(T=pe("poolside_fallback")),(s==="9router"||s==="9Router")&&(T=pe("9router_fallback"));k<=p&&!g;){k++;try{let i=(await ls(t,T,f,null,"Fast",.75,"background")).text||"",u=wo(i);if(u.length===0)throw new Error("No tool calls detected in synthesis response");for(let b of u){let D=b.toolName;["saveSummary","saveSumary","SaveSummary","SaveSumary"].includes(D)&&await yo(D,b.args,{chatId:e})}g=!0}catch(m){if(k>=p)throw new Error(`Failed after ${p} attempts. Last error: ${m.message}`)}}}catch(s){let o=s instanceof Error?(()=>{try{return JSON.parse(JSON.parse(s.message).error.message).error.message}catch{return String(s)}})():String(s),c=ae.join(En,"janitor");Ue.existsSync(c)||Ue.mkdirSync(c,{recursive:!0}),Ue.appendFileSync(ae.join(c,"error.log"),`[${new Date().toLocaleString()}] Past memory batch consolidation error: ${o}
|
|
623
|
+
`)}},mf=async(e,t,n=!1)=>{let{chatId:s,aiProvider:o="Google"}=e,c=ae.join(Ro,"chat-summaries.json"),f=i=>i.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&u.role!=="think"&&!u.isVisualFeedback&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.includes("[TERMINAL_RECORD]"))&&!String(u.id).startsWith("welcome")).map(u=>{let b=u.fullText||u.text||"",D=u.role==="system"||b.startsWith("[ACTION RESULT]:")||b.startsWith("[TOOL RESULT]:")||u.text&&(u.text.startsWith("[ACTION RESULT]:")||u.text.startsWith("[TOOL RESULT]:")),h=b;return D&&(b.includes("[ACTION RESULT]:")||b.includes("[TOOL RESULT]:")||u.text&&(u.text.includes("[ACTION RESULT]:")||u.text.includes("[TOOL RESULT]:")))?h="[ACTION RESULT]: ...truncated for summary":h=h.replace(/(\[(?:tool|action):[a-zA-Z0-9_\.]+)\([\s\S]*?\)(\])/g,"$1(...)$2"),`[${D?"ACTION":u.role==="agent"?"AGENT":"USER"}]: ${h}`}).join(`
|
|
636
624
|
|
|
637
|
-
`),l=async(i,u)=>{let b="You are an expert context summarizer. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details, chat messages, file changes. Under no circumstances exceed MAX 2000 words.",
|
|
625
|
+
`),l=async(i,u)=>{let b="You are an expert context summarizer. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details, chat messages, file changes. Under no circumstances exceed MAX 2000 words.",D=u?`Here is the previous summary:
|
|
638
626
|
${u}
|
|
639
627
|
|
|
640
628
|
Here is the new conversation history:
|
|
@@ -643,22 +631,22 @@ ${i}
|
|
|
643
631
|
Provide a new consolidated summary of the entire session.`:`Here is the conversation history:
|
|
644
632
|
${i}
|
|
645
633
|
|
|
646
|
-
Provide a consolidated summary of the entire session.`,h=pe("gemma_janitor_fallback_google");o==="OpenRouter"&&(h=pe("janitor_open_router")),o==="DeepSeek"&&(h=pe("deepseek_level_1")),o==="Mistral"&&(h=pe("mistral_level_1")),o==="NVIDIA"&&(h=pe("nvidia_chat_summarizer_fallback")),o==="InferX"&&(h=pe("inferx_fallback")),o==="SenseNova"&&(h=pe("sensenova_fallback")),o==="AIHubMix"&&(h=pe("aihubmix_fallback")),o==="Poolside"&&(h=pe("poolside_fallback")),(o==="9router"||o==="9Router")&&(h=pe("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(h=pe("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(h=pe("tokenharbor_fallback")||"deepseek-v4.1-flash:free");let A=0,$=!1,
|
|
647
|
-
`),L=
|
|
648
|
-
`),N=(m?.tokens||0)>=1e4,
|
|
634
|
+
Provide a consolidated summary of the entire session.`,h=pe("gemma_janitor_fallback_google");o==="OpenRouter"&&(h=pe("janitor_open_router")),o==="DeepSeek"&&(h=pe("deepseek_level_1")),o==="Mistral"&&(h=pe("mistral_level_1")),o==="NVIDIA"&&(h=pe("nvidia_chat_summarizer_fallback")),o==="InferX"&&(h=pe("inferx_fallback")),o==="SenseNova"&&(h=pe("sensenova_fallback")),o==="AIHubMix"&&(h=pe("aihubmix_fallback")),o==="Poolside"&&(h=pe("poolside_fallback")),(o==="9router"||o==="9Router")&&(h=pe("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(h=pe("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(h=pe("tokenharbor_fallback")||"deepseek-v4.1-flash:free");let A=0,$=!1,E=null;for(;A<=3&&!$;){A++;try{E=await ls(e,h,D,b,"Fast"),$=!0}catch{if(A>3){if(o==="Google")try{let _=pe("general_fallback");return(await ls(e,_,D,b,"Fast")).text||""}catch{return""}return""}}}return E&&E.text||""},k=f(t),p=vt(c,{}),g=p[s]||{summary:"",historyLength:0};typeof g=="string"&&(g={summary:g,historyLength:0});let T=g.summary||"",m=await l(k,T);if(m){g.summary=m;let i=Ja(t);return n?g.historyLength=(g.historyLength||0)+i:g.historyLength=i,p[s]=g,zn(c,p),m}return null},pf=e=>{try{let t=ae.join(Ro,"chat-summaries.json");if(Ue.existsSync(t)){let n=vt(t,{});n[e]&&(delete n[e],zn(t,n))}}catch{}},yf=async function*(e,t,n,s,o){let{profile:c,thinkingLevel:f,mode:l,janitorModel:k,chatId:p,isPlayground:g,systemSettings:T,sessionStats:m,aiProvider:i="Google",apiTier:u,wildcardTooling:b,wildercardTooling:D}=n,h=ut(e);if(!ii&&i==="Google")throw new Error("AI not initialized");let A=process.env.NVIDIA_BASE_URL||n?.aiProvider==="Ollama"||n?.aiProvider==="InferX"||n?.aiProvider==="SenseNova"||n?.aiProvider==="AIHubMix"||n?.aiProvider==="Poolside"||n?.aiProvider==="9router"||n?.aiProvider==="ExpLabs"||n?.aiProvider==="ExperientialLabs"||n?.aiProvider==="TokenHarbor"||n?.aiProvider==="Token Harbor"||n?.aiProvider==="tokenharbor"||n?.aiProvider==="token_harbor"||n?.aiProvider==="thk"||n?.aiProvider==="APInex"||n?.aiProvider==="apinex"||n?.aiProvider==="apx"?!1:T?.memory!==!1,$=t[t.length-1].text,E=ae.join(Ro,"chat-summaries.json"),x=!1,_=t.filter(d=>d.role==="user").length===1,I=$.includes("[TITLE-UPDATE]"),y=_||I,a=$.replace(/\[TITLE-UPDATE\]/g,"").trim();a=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Oo.startTransaction(p,a),T?.advanceRollback&&await ao.takeInitialSnapshot(p),kt=!1;let R=null;try{let d=new AbortController;R=setInterval(()=>{kt&&(d.abort(),R&&(clearInterval(R),R=null))},400);let r=[...t.slice(0,-1)];{let Ke=vt(E,{})[p]||{summary:"",historyLength:0};if(Ke.summary&&Ke.historyLength>0){let gn=0,st=[];for(let Be=0;Be<r.length;Be++){let it=r[Be];(it.role==="user"||it.role==="agent"||it.role==="system")&&!String(it.id).startsWith("welcome")&&!it.isMeta&&gn++,gn>Ke.historyLength&&st.push(it)}r=st}}r=r.map(K=>{if(K.role==="user"&&K.text){let Ke=K.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Ke)return{...K,text:Ke[1].trim()}}return{...K}});let C=process.env.HIGH_CONTEXT,v=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,P={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[T?.contextLength]||256e3;if(C&&C!=="false"){let K=parseInt(C,10);!isNaN(K)&&K>=0&&K<=1e6&&(P=K)}if((i==="NVIDIA"&&(e?.includes("gpt")||e?.includes("qwen")||e?.includes("medium")||e.includes("muse"))||i==="Mistral")&&(P=126e3),i==="Google"&&e?.includes("gemma")&&v&&(P=16e3),(m?.tokens||0)>P){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(_&&A){let K=vt(vo,{});Object.values(K).flat().length>5&&(yield{type:"status",content:"Condensing past chat memories"},await sl(p,n,K))}let le=vt(vo,{}),fe=vt(ks,{}),ee=Object.entries(le).filter(([K])=>K!==p).flatMap(([K,Ke])=>Ke),ce=[...Object.entries(fe).filter(([K])=>K!==p).slice(-20).map(([K,Ke])=>`[Chat Summary]: ${Ke}`),...ee].map(K=>`- ${K}`).join(`
|
|
635
|
+
`),L=vt(Un,[]).map(K=>`- ${K.memory}`).join(`
|
|
636
|
+
`),N=(m?.tokens||0)>=1e4,Ce=new Date,ie=Ce.getFullYear(),B=Ce.toLocaleString("en-US",{month:"short"}).toUpperCase(),G=String(Ce.getDate()).padStart(2,"0"),ye=Ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}),Re=`${ie}-${B}-${G}, ${ye}`,ve=`${ye}`,Ie=K=>{try{return Ue.readdirSync(K,{withFileTypes:!0})}catch{return[]}},Dn=Array.from(new Set([...so,...io(process.cwd())])),sn=(K,Ke=4)=>T?.indentationTree!==!1?Js(K,Ke,1,Ie,Dn):Zs(K,Ke,"",1,Ie,Dn),pt=vt(Ts,{}),Tt=pt[p],Je=Tt?Tt!==process.cwd():!1;pt[p]=process.cwd(),zn(Ts,pt);let xe=vt(E,{}),te=xe[p]||{summary:"",historyLength:0};typeof te=="string"&&(te={summary:te,historyLength:0});let Wt=t.filter(K=>(K.role==="user"||K.role==="agent"||K.role==="system")&&!String(K.id).startsWith("welcome")&&!K.isMeta).length;te.historyLength&&Wt<te.historyLength&&(te.summary="",te.historyLength=0,xe[p]=te,zn(E,xe));let On=typeof te=="object"?te.summary||"":te||"",Ln=r.length>0;Ln&&On&&r[0]&&(r[0].role==="user"||r[0].role==="system")&&(r[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(r[0].text=`[SYSTEM METADATA]
|
|
649
637
|
**CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
|
|
650
|
-
${
|
|
638
|
+
${On}
|
|
651
639
|
|
|
652
|
-
[USER] ${r[0].text}`,yield{type:"summary_injected",content:{id:r[0].id,text:r[0].text}}));let cs=
|
|
640
|
+
[USER] ${r[0].text}`,yield{type:"summary_injected",content:{id:r[0].id,text:r[0].text}}));let cs=On&&!Ln?`
|
|
653
641
|
[SYSTEM METADATA]
|
|
654
642
|
**CONTEXT SUMMARY OF PREVIOUS TURNS**
|
|
655
|
-
${
|
|
656
|
-
`:"",ai=!!T?.dynamicDirAwareness,Jr=`${p}|${i}|${f}|${e}|${c}|${ai}`,Qr=!ai&&
|
|
643
|
+
${On}
|
|
644
|
+
`:"",ai=!!T?.dynamicDirAwareness,Jr=`${p}|${i}|${f}|${e}|${c}|${ai}`,Qr=!ai&&Gn.key===Jr&&Gn.value?"":`
|
|
657
645
|
**Directory**
|
|
658
646
|
CWD: `+process.cwd()+`${g?" [PLAYGROUND MODE]":""}
|
|
659
|
-
`+
|
|
647
|
+
`+sn(process.cwd(),4),yt=await Wn(),un="";if(zo()&&yt.file_focused!=="none"){un=`
|
|
660
648
|
[Additional IDE Context]
|
|
661
|
-
`;let K=ae.relative(process.cwd(),yt.file_focused),Ke=(yt.opened_editors||[]).map(st=>{let Be=ae.relative(process.cwd(),st);return Be.startsWith("..")?`[External] ${ae.basename(st)}`:Be});if(
|
|
649
|
+
`;let K=ae.relative(process.cwd(),yt.file_focused),Ke=(yt.opened_editors||[]).map(st=>{let Be=ae.relative(process.cwd(),st);return Be.startsWith("..")?`[External] ${ae.basename(st)}`:Be});if(un+=`Focused File: ${K}
|
|
662
650
|
Cursor Line: ${yt.cursor_line}
|
|
663
651
|
`,yt.selected){let st=yt.selected,Be=st.split(`
|
|
664
652
|
`);Be.length>256&&(st=Be.slice(0,240).join(`
|
|
@@ -667,29 +655,29 @@ Cursor Line: ${yt.cursor_line}
|
|
|
667
655
|
`+Be.slice(-16).join(`
|
|
668
656
|
`)),st.length>2048&&(st=st.slice(0,1920)+`
|
|
669
657
|
... [truncated] ...
|
|
670
|
-
`+st.slice(-128)),
|
|
658
|
+
`+st.slice(-128)),un+=`Current Selection: "${st}"
|
|
671
659
|
`}if(yt.manual_edits){let Be=yt.manual_edits.split(`
|
|
672
|
-
`),it=[],et=null;for(let V of Be)V.trim()&&(V.startsWith(" Line ")?et&&et.edits.push(V):(et={path:V.endsWith(":")?V.slice(0,-1):V,edits:[]},it.push(et)));for(let V of it)V.edits.length>80&&(V.edits=V.edits.slice(-80)),V.originalEditsCount=V.edits.length;let at=(V,We)=>We.reduce((
|
|
660
|
+
`),it=[],et=null;for(let V of Be)V.trim()&&(V.startsWith(" Line ")?et&&et.edits.push(V):(et={path:V.endsWith(":")?V.slice(0,-1):V,edits:[]},it.push(et)));for(let V of it)V.edits.length>80&&(V.edits=V.edits.slice(-80)),V.originalEditsCount=V.edits.length;let at=(V,We)=>We.reduce((Me,gt)=>{let It=yt.file_focused&&(gt.path===yt.file_focused||ae.resolve(process.cwd(),gt.path)===ae.resolve(yt.file_focused))?Math.ceil(V*1.2):V;return Me+Math.min(gt.edits.length,It)},0),ke=80;if(at(80,it)>300){let V=!1;for(let We=80;We>=10;We--)if(at(We,it)<=300){ke=We,V=!0;break}V||(ke=10)}let Ve=[...it];if(ke===10&&at(10,Ve)>500)for(;Ve.length>0&&at(10,Ve)>500;){let V=0,We=Ve[0].originalEditsCount;for(let Me=1;Me<Ve.length;Me++)Ve[Me].originalEditsCount<We&&(We=Ve[Me].originalEditsCount,V=Me);Ve.splice(V,1)}for(let V of Ve){let Me=yt.file_focused&&(V.path===yt.file_focused||ae.resolve(process.cwd(),V.path)===ae.resolve(yt.file_focused))?Math.ceil(ke*1.2):ke;V.edits.length>Me&&(V.edits=V.edits.slice(-Me))}for(let V of Ve){let We=`${V.path}:
|
|
673
661
|
${V.edits.join(`
|
|
674
662
|
`)}`;for(;V.edits.length>0&&We.length>4*768;)V.edits.shift(),We=`${V.path}:
|
|
675
663
|
${V.edits.join(`
|
|
676
|
-
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}let
|
|
677
|
-
`);for(;Ve.length>0&&
|
|
664
|
+
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}let an=Ve.map(V=>V.stringRepresentation).join(`
|
|
665
|
+
`);for(;Ve.length>0&&an.length>4*2048;){Ve[0].edits.length>0?Ve[0].edits.shift():Ve.shift();for(let V of Ve){let We=`${V.path}:
|
|
678
666
|
${V.edits.join(`
|
|
679
|
-
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}
|
|
680
|
-
`)}
|
|
681
|
-
${
|
|
682
|
-
`}Ke.length>0&&(
|
|
667
|
+
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}an=Ve.map(V=>V.stringRepresentation).join(`
|
|
668
|
+
`)}an.length>4*2048&&(an="... "+an.slice(-(4*2048-4))),un+=`Recent Manual Edits:
|
|
669
|
+
${an}
|
|
670
|
+
`}Ke.length>0&&(un+=`All Opened Editors: ${Ke.join(", ")}`),yt.diagnostics&&(un+=`
|
|
683
671
|
**Active File Errors**:
|
|
684
672
|
${yt.diagnostics}
|
|
685
|
-
`),(a.toLowerCase().includes("lint")||a.toLowerCase().includes("warning"))&&yt.warnings&&(
|
|
673
|
+
`),(a.toLowerCase().includes("lint")||a.toLowerCase().includes("warning"))&&yt.warnings&&(un+=`
|
|
686
674
|
**Lint Warnings**:
|
|
687
675
|
${yt.warnings}
|
|
688
|
-
`)}let li=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ci=/(?:\\)?@\[([^\]]+)\]/g,ds,fs=[];for(ci.lastIndex=0;(ds=ci.exec(li))!==null;){let K=ds[0].startsWith("\\");fs.push({tag:ds[1],isEscaped:K})}let us=[],
|
|
689
|
-
`);yield{type:"visual_feedback",content:Yt(`${
|
|
690
|
-
`)};continue}if(at===null&&!
|
|
691
|
-
`)};continue}}let
|
|
692
|
-
`);yield{type:"visual_feedback",content:Yt(`${
|
|
676
|
+
`)}let li=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ci=/(?:\\)?@\[([^\]]+)\]/g,ds,fs=[];for(ci.lastIndex=0;(ds=ci.exec(li))!==null;){let K=ds[0].startsWith("\\");fs.push({tag:ds[1],isEscaped:K})}let us=[],ko=null;for(let K=0;K<fs.length;K++){let{tag:Ke,isEscaped:gn}=fs[K];if(!gn)try{let st=Ke.trim().replace(/^["']|["']$/g,""),Be=/[:#]L?(\d+)(?:-L?(\d+))?$/i,it=st.match(Be),et=st,at=null,ke=null;it&&(at=parseInt(it[1],10),ke=it[2]?parseInt(it[2],10):at,et=st.slice(0,it.index));let Ve=ae.resolve(process.cwd(),et);if(Ue.existsSync(Ve)&&Ue.statSync(Ve).isFile()){let V=et.toLowerCase(),We=V.endsWith(".pdf"),Me=V.endsWith(".docx")||V.endsWith(".doc")||V.endsWith(".ppt")||V.endsWith(".pptx")||V.endsWith(".xls")||V.endsWith(".xlsx"),gt=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(V),Tn=gt||We||Me,It=i==="Google"||ut(e);if(Tn&&!It){let Lt=`\u2718 Unsupported Modality: ${ae.basename(et)}`,Ye=115;process.stdout.isTTY&&(Ye=process.stdout.columns-5||120);let Te=[Lt],qe=Math.max(...Te.map(en=>en.length)),Zt=Math.min(qe+4,Ye),_o=Te.map(en=>`${en.padEnd(Zt-2).substring(0,Zt-2)}`).join(`
|
|
677
|
+
`);yield{type:"visual_feedback",content:Yt(`${_o}
|
|
678
|
+
`)};continue}if(at===null&&!Tn){let Lt=0;try{Lt=Ue.readFileSync(Ve,"utf8").split(/\r\n|\r|\n/).length}catch{}if(Lt>300){let Ye=`\u21B7 Skipped (Too Large): ${ae.basename(et)}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let qe=Math.min(Ye.length+4,Te),Zt=Ye.padEnd(qe-2).substring(0,qe-2);yield{type:"visual_feedback",content:Yt(`${Zt}
|
|
679
|
+
`)};continue}}let ln=at!==null?at:1,Sn=ke!==null?ke:at!==null?at:ln+299;Sn-ln>300&&(Sn=ln+300);let Qn=`path=${JSON.stringify(et)}, startLine=${ln}, endLine=${Sn}`,Qt=await Ri(Qn,{isMultiModal:It}),xt=!1,Qe="",Ot=null;if(typeof Qt=="string"?Qt.trim().startsWith("ERROR")?xt=!0:Qe=Qt:Qt&&typeof Qt=="object"&&Qt.binaryPart?(Ot=Qt.binaryPart,Qe=Qt.text||""):xt=!0,!xt){let Lt="";if(gt?(Lt=`\u2714 Processed: ${ae.basename(et)}`,ko=Ot):We||Me?(Lt=`\u2714 Auto-Analysed: ${ae.basename(et)}`,ko=Ot):(Lt=`\u2714 Auto-Read: ${ae.basename(et)}`,us.push(Qe)),Lt){let Ye=115;process.stdout.isTTY&&(Ye=process.stdout.columns-5||120);let Te=[Lt],qe=Math.max(...Te.map(en=>en.length)),Zt=Math.min(qe+4,Ye),_o=Te.map(en=>`${en.padEnd(Zt-2).substring(0,Zt-2)}`).join(`
|
|
680
|
+
`);yield{type:"visual_feedback",content:Yt(`${_o}
|
|
693
681
|
`)}}}}}catch{}}let gs="";us.length>0&&(gs=`
|
|
694
682
|
[Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
|
|
695
683
|
`+us.join(`
|
|
@@ -698,52 +686,52 @@ ${yt.warnings}
|
|
|
698
686
|
[Tagged File Contents]
|
|
699
687
|
`);let di=li.replace(/\\(@\[[^\]]+\])/g,"$1"),fi=b?`You cannot execute tools. Instead write the action string in chat you WOULD have written
|
|
700
688
|
`:"",Zr=process.env.forcedReasoning||!1,ui=f!=="Fast"&&(i==="Mistral"&&!Io(e)||f!=="High"&&i==="Google")?`${i==="Mistral"&&!Io(e)||e.toLowerCase().startsWith("gemma")||Zr?`[system] strictly follow thinking policy as high priority. do not start a response without <think>...</think> [/system]
|
|
701
|
-
`:""}`:"",
|
|
702
|
-
Time: ${gi?
|
|
689
|
+
`:""}`:"",To="",gi=!!T?.autoExcludeMetadata,ea=!!(un||gs||fi||cs||ui||Je||T?.dynamicDirAwareness||T?.autoTruncateResults);gi&&!ea?To=di.trim():To=`[System Metadata]
|
|
690
|
+
Time: ${gi?ve:Re}${Je?`
|
|
703
691
|
WARNING: CWD Changed from previous: "${Tt}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
704
|
-
`:""}${
|
|
692
|
+
`:""}${un}
|
|
705
693
|
Action format: [action:ActionName(...)]
|
|
706
694
|
[/Metadata]
|
|
707
|
-
${cs}${ui}${gs}${fi}[user prompt] ${di.trim()} [/user prompt]`.trim();let hi={role:"user",text:
|
|
695
|
+
${cs}${ui}${gs}${fi}[user prompt] ${di.trim()} [/user prompt]`.trim();let hi={role:"user",text:To};ko&&(hi.binaryPart=ko),r.forEach(K=>{K.text&&K.role==="agent"&&(K.text=qt(K.text))}),r.push(hi),cs&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:To}});let Jt=null,kn=l==="Flux"?50:15;kn=l.toLowerCase().includes("cu")?75:kn;let ta=Math.floor(kn/2),mi=0,rn=16;yield{type:"status",content:"Connecting"},kt=!1;let hs=[],So=!1,pi=!1;for(let K=0;K<=kn;K++){let Ke=Math.floor(kn*.95);if(K>=Ke&&mi<Ke&&typeof n?.onAskUser=="function"){mi=Ke;try{let me="Agent has been running for a long time. Do you want to continue execution?",Ae=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],Z=await n.onAskUser(me,Ae);Z&&(Z.toLowerCase().includes("continue")||Z==="Continue")&&(kn+=ta)}catch{}}let gn=await _s("agent",n);if(!gn.allowed)throw new Error(gn.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let st=[];if(So=!1,l==="ICU"||l==="FluxCU")try{yield{type:"status",content:"Capturing Screen"},await new Promise(Z=>setTimeout(Z,1e3));let{captureGriddedScreenshot:me}=await import("./screen_grid-RAKJUJQA.js"),Ae=await me();if(Ae&&Ae.base64){let Z="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",Pt={inlineData:{mimeType:Ae.mimeType,data:Ae.base64}},Ct=T?.imageHistoryCU||"Standard",Et=Ct==="Low"?3:Ct==="Extended"?10:Ct==="Max"?999:5,zt=r.filter(Ge=>Array.isArray(Ge.parts)&&Ge.parts.some($t=>$t.inlineData));if(zt.length>=Et){let Ge=zt.length-Et+1;for(let $t=0;$t<Ge;$t++){let Rt=zt[$t];Array.isArray(Rt.parts)&&(Rt.parts=Rt.parts.filter(St=>!St.inlineData))}}if(r.length>0&&r[r.length-1].role==="user"){let Ge=r[r.length-1];typeof Ge.text=="string"&&(Ge.text+=`
|
|
708
696
|
|
|
709
|
-
${
|
|
697
|
+
${Z}`,Array.isArray(Ge.parts)||(Ge.parts=[{text:Ge.text}]),Ge.parts.push(Pt))}else r.push({role:"user",text:Z,parts:[{text:Z},Pt]})}}catch(me){console.error("Vision screenshot capture error:",me)}if(T?.compression===0&&(m?.tokens||0)>P&&(r=Ei(r,6)),K>0?yield{type:"status",content:"Working"}:yield{type:"status",content:"Connecting"},kt){try{let{clearPendingNudges:me}=await import("./subagent_state-LZCOZSUJ.js");me()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
710
698
|
|
|
711
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:me}=await import("./subagent_state-LZCOZSUJ.js"),Ae=me();if(Ae&&Ae.length>0){let
|
|
699
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:me}=await import("./subagent_state-LZCOZSUJ.js"),Ae=me();if(Ae&&Ae.length>0){let Z=Ae.join(`
|
|
712
700
|
|
|
713
701
|
`);r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
714
702
|
|
|
715
|
-
${
|
|
703
|
+
${Z}`:r.push({role:"user",text:Z}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let me=await s();me&&(me.startsWith("/btw")?r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
716
704
|
|
|
717
705
|
[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
718
706
|
[question] ${me.replace("/btw","").trim()} [/question]`:r.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
719
707
|
[question] ${me.replace("/btw","").trim()} [/question]`}):r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
720
708
|
|
|
721
|
-
[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`:r.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${me.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Be,it=!1,et=1,at=1,ke="",Ve=null,
|
|
709
|
+
[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`:r.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${me.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Be,it=!1,et=1,at=1,ke="",Ve=null,an=null,V=null,We=0,Me=[],gt=0,Tn=!1,It=!1,ln=!1,Sn=!1,Qn=!0,Qt=0,xt="",Qe="",Ot=!1,Lt=!1,Ye=!0,Te=e,qe="",Zt=f;for(f=f.toLowerCase()==="max"?"High":f;et<=rn&&at<=rn&&!it&&!kt;){let me=!1;try{ke="",Qn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Qn=!1,at===1&&(xt=""));let Ae=M=>{if(!M||typeof M!="string")return M;let Y="",W=oi(M);if(W&&(Y=W.fullBlock,M=W.remainingText),!M.includes("[tool:")&&!M.includes("[action:"))return(T?.keepReasoningContext?Y:"")+M;M=M.replace(za,(X,ne)=>ne.includes("[tool:")||ne.includes("[action:")?ne.trim():X);let z="",Q=0;for(;Q<M.length;){let X=M.indexOf("[tool:",Q),ne=M.indexOf("[action:",Q),tt=-1;if(X!==-1&&ne!==-1?tt=Math.min(X,ne):X!==-1?tt=X:tt=ne,tt===-1){z+=Gr(M.substring(Q));break}let F=M.substring(Q,tt);z+=Gr(F);let j=-1,Se=null,w=0;for(let Le=tt;Le<M.length;Le++){let se=M[Le];if(Se){if(se===Se){let q=0;for(let bt=Le-1;bt>=0&&M[bt]==="\\";bt--)q++;q%2===0&&(Se=null)}}else if(se==='"'||se==="'"||se==="`")Se=se;else if(se==="(")w++;else if(se===")")w--;else if(se==="]"&&w<=0){j=Le;break}}if(j===-1){z+=M.substring(tt);break}z+=M.substring(tt,j+1),Q=j+1}return(T?.keepReasoningContext?Y:"")+z},Z=r.filter(M=>(M.role==="user"||M.role==="agent"||M.role==="system")&&!String(M.id).startsWith("welcome")&&!M.isMeta&&!M.isTerminalRecord&&!(M.text&&M.text.startsWith("[TERMINAL_RECORD]"))).map((M,Y,W)=>{let z=M.text||"";A||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),M.role==="agent"&&(z=Ae(z),z=z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),z=z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let Q=[];return Array.isArray(M.parts)&&M.parts.length>0?Q=M.parts.map(X=>{if(X.text){let ne=X.text;return A||(ne=ne.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),M.role==="agent"&&(ne=Ae(ne),ne=ne.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),ne=ne.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:ne}}return X}):Q=[{text:z}],M.binaryPart&&ut(Te)&&W.slice(Y+1).filter(ne=>ne.role==="user"&&!ne.text?.startsWith("[ACTION RESULT]")&&!ne.text?.startsWith("[TOOL RESULT]")).length<=2&&Q.push(M.binaryPart),{role:M.role==="user"||M.role==="system"?"user":"model",parts:Q}});for(let M=0;M<Z.length;M++){let Y=Z[M],W=Y.parts?.[0]?.text||"";if(Y.role==="model"&&/\[(?:tool|action):/i.test(W)){let z=-1;for(let Q=M+1;Q<Z.length;Q++){let X=Z[Q],ne=X.parts?.[0]?.text||"";if(X.role==="user"&&(ne.startsWith("[ACTION RESULT]")||ne.startsWith("[TOOL RESULT]"))){z=Q;break}}if(z!==-1&&z!==M+1){let[Q]=Z.splice(z,1);Z.splice(M+1,0,Q)}}}for(let M=Z.length-2;M>=0;M--){let Y=Z[M],W=Z[M+1];Y.role==="user"&&W.role==="user"&&(W.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&Z.splice(M,1)}let Pt=[];for(let M=0;M<Z.length;M++){let Y=Z[M];if(Pt.length===0)Pt.push(Y);else{let W=Pt[Pt.length-1];W.role===Y.role?(W.parts[0].text+=`
|
|
722
710
|
|
|
723
|
-
`+(Y.parts?.[0]?.text||""),Y.parts?.length>1&&W.parts.push(...Y.parts.slice(1))):Pt.push(Y)}}
|
|
711
|
+
`+(Y.parts?.[0]?.text||""),Y.parts?.length>1&&W.parts.push(...Y.parts.slice(1))):Pt.push(Y)}}Z.length=0,Z.push(...Pt),Te=e;let Ct=`${p}|${i}|${l}|${f}|${Zt}|${Te}|${JSON.stringify(c)}|${!!T?.dynamicDirAwareness}|${!!T?.subAgents}`,Et=Gn.key===Ct&&Gn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Et=!1),Et)qe=Gn.value;else{let M=i==="Mistral"?!!Io(Te):!(Te||"gemma").toLowerCase().startsWith("gemma");qe=fr(c,((Te||"gemma").toLowerCase().startsWith("gemma"),Zt),l,T,A,_,i,i==="Google"?!0:h,M,p,!!T?.keepReasoningContext,Te),T?.dynamicDirAwareness||(qe+=`
|
|
724
712
|
${Qr.replace(`
|
|
725
713
|
**Directory**`,`
|
|
726
|
-
-- Directory --`)}`),
|
|
727
|
-
${Y} [/ERROR]`),yield{type:"status",content:"Working"}}let $t=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(T?.advanceRollback&&Ge&&Ge.role==="user"&&(Ge.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Ge.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let
|
|
714
|
+
-- Directory --`)}`),Gn.key=Ct,Gn.value=qe}let Ge=Z[Z.length-1];if(zo()&K>0){await new Promise(W=>setTimeout(W,2500)),yield{type:"status",content:"Verifying"};let M=await Wn(),Y=M?M.diagnostics:null;Y&&Ge&&Ge.role==="user"&&Ge.parts?.[0]?.text&&(Ge.parts[0].text+=`
|
|
715
|
+
${Y} [/ERROR]`),yield{type:"status",content:"Working"}}let $t=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(T?.advanceRollback&&Ge&&Ge.role==="user"&&(Ge.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Ge.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let M=await ao.getLatestFileChanges(p);if(M&&(M.newFiles.length>0||M.modifiedFiles.length>0||M.deletedFiles.length>0)){let Y=`
|
|
728
716
|
[system] File Changes:
|
|
729
|
-
`;for(let z of
|
|
730
|
-
`;for(let z of
|
|
731
|
-
`;for(let z of
|
|
732
|
-
`;Y+="[/system]",Ge.parts[0].text+=Y;let W=-1;for(let z=r.length-1;z>=0;z--)if(r[z].role==="user"&&(r[z].text?.startsWith("[ACTION RESULT]")||r[z].text?.startsWith("[TOOL RESULT]"))){W=z;break}W!==-1&&(r[W].text+=Y)}}catch{}let Rt=Math.floor(
|
|
733
|
-
[system] WARNING, Turn Limit Impending: Step ${St}/${
|
|
734
|
-
|
|
735
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(W){if(
|
|
736
|
-
`).length;je=wt,!
|
|
717
|
+
`;for(let z of M.newFiles)Y+=`* ${z} (created)
|
|
718
|
+
`;for(let z of M.modifiedFiles)Y+=`* ${z} (modified)
|
|
719
|
+
`;for(let z of M.deletedFiles)Y+=`* ${z} (deleted)
|
|
720
|
+
`;Y+="[/system]",Ge.parts[0].text+=Y;let W=-1;for(let z=r.length-1;z>=0;z--)if(r[z].role==="user"&&(r[z].text?.startsWith("[ACTION RESULT]")||r[z].text?.startsWith("[TOOL RESULT]"))){W=z;break}W!==-1&&(r[W].text+=Y)}}catch{}let Rt=Math.floor(kn*.99),St=K+1;St>=Rt&&Ge&&Ge.parts?.[0]&&(Ge.parts[0].text+=`
|
|
721
|
+
[system] WARNING, Turn Limit Impending: Step ${St}/${kn}. Wrap up quickly/prompt user to continue. [/system]`);let Dt=new Promise((M,Y)=>{d.signal.aborted&&Y(new DOMException("The user aborted a request.","AbortError")),d.signal.addEventListener("abort",()=>{Y(new DOMException("The user aborted a request.","AbortError"))})});Dt.catch(()=>{});let ht=Z;if(i==="Ollama")Be=ei(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,T?.ollamaEndpoint||"Cloud");else if(i==="OpenRouter")Be=es(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,p);else if(i==="DeepSeek")Be=Jo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="Mistral")Be=Qo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,p);else if(i==="NVIDIA"){let M=Zo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);Be=Fr(M,Te)}else if(i==="InferX")Be=ts(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="SenseNova")Be=ns(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="AIHubMix")Be=os(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="Poolside")Be=ss(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="9router"||i==="9Router")Be=is(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="ExpLabs"||i==="ExperientialLabs")Be=rs(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="TokenHarbor"||i==="Token Harbor"||i==="tokenharbor"||i==="token_harbor"||i==="thk")Be=ti(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="APInex"||i==="apinex"||i==="apx")Be=ni(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else{let M=ri(n?.apiKey),{serviceTier:Y,cleanModel:W}=Xr(Te),z={systemInstruction:qe,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:In.HARM_CATEGORY_HARASSMENT,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_HATE_SPEECH,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Mn.BLOCK_NONE},{category:In.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Mn.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let X=He("Google",Te||"gemini-3-flash-preview",f);if(X!==null){if(typeof X=="object")return X;if(X===!1||X==="false"||X==="none"||X===0||X==="0")return{includeThoughts:!1};if(typeof X=="number")return{includeThoughts:!0,thinkingBudget:X};if(typeof X=="string"){let j=X.toLowerCase();if(j==="minimal")return{includeThoughts:!0,thinkingLevel:Xe.MINIMAL};if(j==="low")return{includeThoughts:!0,thinkingLevel:Xe.LOW};if(j==="medium")return{includeThoughts:!0,thinkingLevel:Xe.MEDIUM};if(j==="high")return{includeThoughts:!0,thinkingLevel:Xe.HIGH};let Se=Number(X);if(!isNaN(Se))return{includeThoughts:!0,thinkingBudget:Se}}}let ne=(Te||"").toLowerCase(),tt=ne.includes("gemma-4")||ne.startsWith("gemma"),F=ne.includes("gemini-3");if(tt||F)return tt?f.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Xe.MINIMAL}:{includeThoughts:!0,thinkingLevel:Xe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:ne.includes("pro")?Xe.LOW:Xe.MINIMAL,Low:Xe.LOW,Medium:Xe.MEDIUM,Standard:Xe.MEDIUM,High:Xe.HIGH,xHigh:Xe.HIGH}[f]||Xe.MEDIUM};{let j={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[f]||2048;return j===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:j}}})()};Y&&(z.serviceTier=Y);let Q=M.models.generateContentStream({model:W||"gemini-3-flash-preview",contents:ht,config:z},{signal:d.signal});Be=await Promise.race([Q,Dt])}ke="",Ve=null,V=null,Me=[],gt=0,yield{type:"model_update",content:null},Qe="",Ot=xt.length>0;let cn="",ms=Date.now(),$n=async function*(){if(i==="Google"&&cn){let M=eo(cn);for(let Y of M)yield Y;cn="",ms=Date.now()}},yi=!0,Nn="",Kn=!1,_t=null,xi=!1,Vn=!1,Yn=!1,Ao=!1,_n=!1,Zn=M=>{let Y=0;for(;Y+2<M.length;)M[Y]==="`"&&M[Y+1]==="`"&&M[Y+2]==="`"?(Ao=!Ao,Y+=3):Y++},bi=M=>{if(!M)return;let Y=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,W;for(;(W=Y.exec(M))!==null;){let z=W[0].toLowerCase();z.startsWith("</")||z.startsWith("[/")||z==="<channel|>"?_n=!1:_n=!0}},ia={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|>"}},eo=M=>{let Y=[],W=M,z=Q=>{if(!Q)return;if(!xi){Y.push({type:"text",content:Q}),Zn(Q),bi(Q);return}let X=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,ne=0,tt;for(;(tt=X.exec(Q))!==null;){let j=Q.substring(ne,tt.index);if(j)if(Zn(j),_n)Y.push({type:"text",content:j});else{let Le=j.replace(/[^\n]/g,"");Le&&Y.push({type:"text",content:Le})}let Se=tt[0];Zn(Se);let w=Se.toLowerCase();w.startsWith("</")||w.startsWith("[/")||w==="<channel|>"?_n=!1:_n=!0,Y.push({type:"text",content:Se}),ne=X.lastIndex}let F=Q.substring(ne);if(F)if(Zn(F),_n)Y.push({type:"text",content:F});else{let j=F.replace(/[^\n]/g,"");j&&Y.push({type:"text",content:j})}};for(;W.length>0;)if(Kn){let Q=Nn+W,X=ia[_t];if(X){let F=!1;if(Q.length<X.startPrefix.length?X.startPrefix.startsWith(Q)||(F=!0):Q.startsWith(X.startPrefix)?Q.length>=X.fullPrefix.length&&!Q.startsWith(X.fullPrefix)&&(F=!0):F=!0,F){z(Q),Nn="",Kn=!1,_t=null,Vn=!1,Yn=!1,W="";break}}let ne=-1,tt=X?X.endTag:"]";if(_t==="tool"||_t==="action"){let F=0,j=null,Se=0,w=!1;for(let Le=0;Le<Q.length;Le++){let se=Q[Le];if(j){if(se===j){let q=0;for(let bt=Le-1;bt>=0&&Q[bt]==="\\";bt--)q++;q%2===0&&(j=null)}}else if(se==='"'||se==="'"||se==="`")j=se;else if(se==="(")F++,w=!0;else if(se===")")F--;else if(se==="[")Se++;else if(se==="]"){if(w&&F===0&&Se===1){ne=Le;break}Se--}}}else ne=Q.indexOf(tt);if(ne!==-1){let F=tt.length,j=Q.substring(0,ne+F);_t?.startsWith("kimi")||Y.push({type:"text",content:j}),Zn(j),bi(j),(_t==="tool"||_t==="action"||_t?.startsWith("kimi"))&&!Vn&&!Yn&&(xi=!0),Vn=!1,Yn=!1,Nn="",Kn=!1,_t=null,W=Q.substring(ne+F)}else{let F=_t?.startsWith("kimi")?8192:512;Q.length>F?(z(Q),Nn="",Kn=!1,_t=null,Vn=!1,Yn=!1):Nn=Q,W="";break}}else{let Q=W.indexOf("[tool"),X=W.indexOf("[action"),ne=W.indexOf("[[END]]"),tt=W.indexOf("<|tool_calls_section_begin|>"),F=W.indexOf("<|tool_call_begin|>"),j=[{type:"tool",idx:Q,start:"[tool",end:"]"},{type:"action",idx:X,start:"[action",end:"]"},{type:"end",idx:ne,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:tt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:F,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Se=>Se.idx!==-1).sort((Se,w)=>Se.idx-w.idx);if(j.length>0){let Se=j[0],w=W.substring(0,Se.idx);Se.idx>0&&z(w);let Le=Se.idx>0?W[Se.idx-1]:"";Vn=Ao||Le==="`",Yn=_n,Kn=!0,_t=Se.type,Nn="",W=W.substring(Se.idx)}else{let Se=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],w=-1;for(let Le of Se){for(let se=Le.length-1;se>0;se--)if(W.endsWith(Le.substring(0,se))){w=W.length-se;let q=Se.indexOf(Le);q===0?_t="tool":q===1?_t="action":q===2?_t="end":q===3?_t="kimi_section":_t="kimi_call";break}if(w!==-1)break}if(w!==-1){if(w>0){let se=W.substring(0,w);z(se)}let Le=w>0?W[w-1]:"";Vn=Ao||Le==="`",Yn=_n,Kn=!0,Nn=W.substring(w),W=""}else{z(W);break}}}return Y},ra=Be[Symbol.asyncIterator]();for(;;){let{value:M,done:Y}=await Promise.race([ra.next(),Dt]);if(Y)break;if(M&&M.type==="status"){yield M;continue}let W="",z=M.candidates?.[0]?.content?.parts;if(z&&z.length>0)for(let X of z){let ne=typeof X.text=="string"?X.text:X.text?parseChunkText(X.text):"";X.thought?ne&&(me||(W+="<think>",me=!0),W+=ne):ne&&(me&&(W+="</think>",me=!1),W+=ne)}else M.text&&me&&(W+="</think>",me=!1);W=Ka(W);let Q=W?As(W):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(W,Q),yi&&(yield{type:"status",content:"Thinking"},yi=!1),kt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
722
|
+
|
|
723
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(W){if(Ot){if(Qe+=W,Qe.length>=64){let F=0,j=Math.min(xt.length,Qe.length);for(let w=j;w>=10;w--)if(xt.endsWith(Qe.substring(0,w))){F=w;break}let Se=Qe.substring(F);if(Se){let Le=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?Se.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):Se.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(Le)if(ke+=Le,i==="Google")cn+=Le;else{yield*$n();let se=eo(Le);for(let q of se)yield q}}Ot=!1,Qe=""}continue}else if(ke+=W,i==="Google")cn+=W;else{yield*$n();let F=eo(W);for(let j of F)yield j}let X=Za(ke);if(X.inside){Lt=!0,V||(V=Date.now());let j={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",Answer:"answer",Steer:"steer",steer:"steer"}[X.toolName]||X.toolName,Se=X.args||"",w=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","answer"].includes(j)){let se=oe(Se),q=se.basename||se.name||se.path||se.targetFile||se.TargetFile||se.directory||se.file,bt=se.keyword,Fn=se.title||se.task,An=se.id||se.taskId,Pe=se.timeout||se.time;if(bt!=null)w=String(bt).replace(Hn,"");else if(q)w=ae.basename(String(q).replace(Hn,"").replace(Br,"/"));else if(Fn&&(j==="invoke"||j==="invoke_sync"))w=String(Fn).replace(Hn,"").substring(0,30);else if(An&&j==="get_progress")w=String(An).replace(Hn,"");else if(Pe&&j==="await"){let Nt=parseFloat(String(Pe).replace(Hn,""));isNaN(Nt)?w=String(Pe).replace(Hn,""):(Nt<5&&(Nt=5),Nt>120&&(Nt=120),w=(hn=>{if(hn>=60){let ys=Math.floor(hn/60),qn=hn%60;return`${ys}m${qn>0?` ${qn}s`:""}`}return`${hn}s`})(Nt))}else{let Nt=Se.match(Ha);if(Nt){let Ht=Nt[1].replace(Hn,"");j==="invoke"||j==="invoke_sync"||j==="get_progress"?w=Ht.substring(0,30):w=j==="search_keyword"||j==="file_map"?Ht:ae.basename(Ht.replace(Br,"/"))}}}let Le=`${si[j]||j}${w?` ${w}`:""}`;if((j!==Ve||w!==an)&&(Ve=j,an=w,yield{type:"status",content:`${Le}`},process.stdout.isTTY)){let q={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[j]||"Working";process.stdout.write(`\x1B]0;${q}...\x07`)}}if(ke.length-Qt>150){Qt=ke.length;let F=zr(ke,!1),j=oi(F),Se=j?(j.innerContent||"").trim():"",w=Se.split(/[.!?]\s+/),Le=new Set(w),se=w.length>10?(w.length-Le.size)/w.length:0,q=Se.split(/\s+/).filter($e=>$e.length>0).length,bt=.6,Fn=.8,An=!1;if(i.toLowerCase().includes("google")&&(Te||"").toLowerCase().startsWith("gemma")){let S={low:256,medium:1024,high:8192,max:16384,xhigh:16384}[f?.toLowerCase()]||2500;An=q>S}if(se>bt||An){yield{type:"status",content:`${se>bt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},It=!0,await new Promise(S=>setTimeout(S,3e3));break}let Ht=jr(ke).trim().split(/[.!?]\s+/),hn=new Set(Ht);if((Ht.length>10?(Ht.length-hn.size)/Ht.length:0)>Fn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},It=!1,Sn=!0,await new Promise($e=>setTimeout($e,3e3));break}let qn=F.replace(Pa,"").replace($a,"").replace(Na,"").replace(Fa,""),Ft=qn.toLowerCase().split(/\s+/).map($e=>$e.replace(Ba,"")).filter($e=>$e.length>0),mn=!1;if(Ft.length>=10)for(let $e=1;$e<=15;$e++){let S=Math.max(3,Math.ceil(10/$e));if(Ft.length<$e*S)continue;let H=Ft.slice(Ft.length-$e),re=H.join(" ");if($e>1&&re===H.slice(0,Math.floor($e/2)).join(" ").repeat(2).trim())continue;let ge=!0;for(let be=1;be<S;be++)if(Ft.slice(Ft.length-$e*(be+1),Ft.length-$e*be).join(" ")!==re){ge=!1;break}if(ge){mn=!0;break}}if(!mn){let $e=qn.toLowerCase().replace(Ua,"");if($e.length>=20)for(let S=1;S<=10;S++){let H=Math.max(5,Math.ceil(16/S));if($e.length<S*H)continue;let re=$e.substring($e.length-S),ge=!0;for(let be=1;be<H;be++)if($e.substring($e.length-S*(be+1),$e.length-S*be)!==re){ge=!1;break}if(ge){mn=!0;break}}}if(mn){yield{type:"status",content:"Stuttering Detected. Re-centering..."},It=!1,ln=!0,await new Promise($e=>setTimeout($e,3e3));break}}let ne=qt(ke),tt=wo(ne);for(;tt.length>gt;){yield*$n();let F=tt[gt],j=Date.now(),w={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[F.toolName]||F.toolName,Le=si[w]||F.toolName,se=jn(w,F.args);yield{type:"status",content:`${Le}${se?` ${se}`:""}`};let q="";if(w==="click"){let S=oe(F.args);q=`\u2714 Clicked: ${S.intendedClickText?`${S.intendedClickText}`:""}`}else if(w==="drag"){let S=oe(F.args);q=`\u2714 Dragged: Cell ${S.fromGridId||""} \u2192 Cell ${S.toGridId||""}`}else if(w==="scroll"){let S=oe(F.args);q=`\u2714 Scrolled: ${S.direction||"down"} (${S.amount||1})`}else if(w==="keyboard_typing"){let S=oe(F.args);q=`\u2714 Typed: ${S.text?`"${S.text.length>20?S.text.substring(0,20)+"...":S.text}"`:""}`}else if(w==="key_press")q=`\u2714 Pressed Key: ${oe(F.args).key||""}`;else if(w==="recapture_screen")q="\u2714 Recaptured Screen";else if(w==="web_search"){let{query:S,limit:H=10,aiMode:re=!1}=oe(F.args);q=`${S?"\u2714":"\u2718"} ${re?"AI Search":"Searched"}: ${S?`${S}`:"No Search Query"}${re===!1&&S?` \u2192 ${H}`:""}`}else if(w==="web_scrape"){let S=oe(F.args).url||null;q=`${S?"\u2714":"\u2718"} Visited: ${S||"No Source"}`}else if(w==="view_file"){let{path:S,StartLine:H,EndLine:re,start_line:ge,end_line:be,startLine:Fe,endLine:De}=oe(F.args),Ee=H||ge||Fe,J=re||be||De,de=parseInt(Ee)||1,ue=parseInt(J)||(Ee?de+800:800),je="...",ze=ue,he=(S||"").trim().toLowerCase().replaceAll("\\","/");if(he.startsWith("#skill"))he.startsWith("#skill/global/fluxflow")||he.startsWith("#skills/global/fluxflow")||he.includes("#skill/fluxflow")||he.includes("#skills/fluxflow")?q="\u2714 Read Documentation":q=`\u2714 Read Skill: ${ae.basename(S.replaceAll("\\","/"))}`;else{try{let _e=ae.resolve(process.cwd(),S);if(Ue.existsSync(_e)){let wt=Ue.readFileSync(_e,"utf8").split(`
|
|
724
|
+
`).length;je=wt,!Ee&&!J&&wt>800?ze=Math.min(50,wt):ze=Math.min(ue,wt)}}catch{}let Oe=(S||"").toLowerCase(),mt=Oe.endsWith(".pdf"),Ne=Oe.endsWith(".docx")||Oe.endsWith(".doc")||Oe.endsWith(".ppt")||Oe.endsWith(".pptx")||Oe.endsWith(".xls")||Oe.endsWith(".xlsx"),nt=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Oe);mt||Ne?q=`${S.length>0?"\u2714":"\u2718"} ${S?`Analyzed: ${ae.basename(S)}`:"Analyzed: File Not Found"}`:nt?q=`${S.length>0?"\u2714":"\u2718"} ${S?`Processed: ${ae.basename(S)}`:"Processed: File Not Found"}`:q=`${je!=="..."?"\u2714":"\u2718"} Read: ${S?`${ae.basename(S)} \u2192 ${je!=="..."?`Lines ${de} - ${ze} of ${je}`:"File Not Found"}`:"File Not Found"}`}}else if(w==="list_files"||w==="read_folder"){let S=w==="list_files"?"List":"Browsed",H=oe(F.args).path||null,re=oe(F.args).recurse||1;q=`${H?"\u2714":"\u2718"} ${S}: ${H?`${H==="."?`./${re>1?"*":""}`:`${H.replaceAll("\\","/")}${re>1?`${H.endsWith("/")?"*":"/*"}`:`${H.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(w==="find_file"){let S=oe(F.args),H=S.basename||S.name||S.path||S.file||S.query||"";q=`${H?"\u2714":"\u2718"} Located: ${H||"No Query"}`}else if(w==="write_file"||w==="update_file"){let S=w==="write_file"?"Created":"Edited",H=oe(F.args),re=H.path||null,be=Object.entries(H).some(([Fe,De])=>Fe.startsWith("searchContent")&&typeof De=="string"&&De.startsWith("^LINE:"))?"\u1361":":";q=`${re?"\u2714":"\u2718"} ${S}${be} ${re?re.replaceAll("\\","/"):"No File Changes"}`}else if(w==="write_pdf"){let S=oe(F.args).path||null;q=`${S?"\u2714":"\u2718"} Generated: ${S.replaceAll("\\","/")||"No PDF Generated"}`}else if(w==="write_docx"){let S=oe(F.args).path||null;q=`${S?"\u2714":"\u2718"} Generated: ${S.replaceAll("\\","/")||"No Docx Generated"}`}else if(w==="file_map"){let S=oe(F.args).path;q=`${S?"\u2714":"\u2718"} Indexed: ${S.replaceAll("\\","/")?""+S:"File Not Found"}`}else if(w.toLowerCase()==="search_keyword"||w.toLowerCase()==="todo")q="";else if(w.toLowerCase()==="generate_image"){let{path:S,outputPath:H,output:re}=oe(F.args);q=`\u2714 Generated: ${S||H||re||"generated_image.png"}`}else if(w==="invoke_sync"||w==="InvokeSync"){let S=jn(w,F.args);q=`\u2714 Called Generalist${S?`: ${S}`:""}`}else if(w==="Invoke"||w==="InvokeAsync"||w==="invoke"){let S=jn(w,F.args);q=`\u2714 Started Generalist${S?`: ${S}`:""}`}else if(w==="get_progress"||w==="GetProgress"){let S=jn(w,F.args);q=`\u2714 Checked${S?`: ${S}`:""}`}else if(w==="cancel"){let S=jn(w,F.args);q=`\u{1F6C7} Cancelled${S?`: ${S}`:""}`}else if(w==="steer"||w==="Steer"){let S=jn(w,F.args);q=`\u2714 Steered${S?`: ${S}`:""}`}else if(w==="EmergencyRollback"){let{method:S}=oe(F.args);q=S==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(w==="await"||w==="Await"){let{time:S,timeout:H}=oe(F.args),re=parseFloat(H||S)||0;re||(re=120);let ge=De=>{if(De>=60){let Ee=Math.floor(De/60),J=De%60;return`${Ee}m${J>0?` ${J}s`:""}`}return`${De}s`},be=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];q=`\u2714 ${be[Math.floor(Math.random()*be.length)]} \u2192 ${ge(re)}`}else w==="Answer"||w==="answer"?q="\u2714 Resolved Sub-Agent Query":w==="exec_command"||w==="ask"?q="":q=`Executed: ${F.toolName}`;if(yield*$n(),w==="exec_command"){let{command:S}=oe(F.args);if(S&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let H=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],re=ae.resolve(process.cwd()).substring(0,3).toLowerCase(),ge=J=>{let de=[],ue="",je=null;for(let ze=0;ze<J.length;ze++){let he=J[ze];je?(he===je&&(je=null),ue+=he):he==='"'||he==="'"?(je=he,ue+=he):he==="&"&&J[ze+1]==="&"||he==="|"&&J[ze+1]==="|"?(ue.trim()&&(de.push(ue.trim()),ue=""),ze++):he===";"||he==="|"||he==="&"?ue.trim()&&(de.push(ue.trim()),ue=""):ue+=he}return ue.trim()&&de.push(ue.trim()),de},be=J=>{let de=[],ue="",je=null;for(let ze=0;ze<J.length;ze++){let he=J[ze];je?(he===je&&(je=null),ue+=he):he==='"'||he==="'"?(je=he,ue+=he):/\s/.test(he)?ue&&(de.push(ue),ue=""):ue+=he}return ue&&de.push(ue),de},Fe=J=>{let de=J.replace(/^['"]|['"]$/g,"").trim();return!de||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(de)?!1:H.some(ue=>{if(ue.source==="[a-zA-Z]:[\\\\\\/]"){let je=de.match(/[a-zA-Z]:[\\\/]/i);return je&&je[0].toLowerCase()!==re}return ue.test(de)})};if(ge(S).some(J=>{let de=be(J);if(de.length===0)return!1;let ue=de[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(ue)){let ze=!1;return de.some(he=>{let At=he.replace(/^['"]|['"]$/g,"");if(At===">"||At===">>"||At==="<")return ze=!0,!1;if(At.startsWith(">")||At.startsWith("<")){let Oe=At.replace(/^[><]+/,"");return Fe(Oe)}return ze?(ze=!1,Fe(he)):!1})}return de.some(ze=>Fe(ze))})){let J='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(S||"No Command"),yield{type:"exec_start"},await new Promise(de=>setTimeout(de,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${J}`),await new Promise(de=>setTimeout(de,50)),n.onExecEnd&&n.onExecEnd(),Me.push({role:"user",text:`[ACTION RESULT]: ERROR: ${J}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${J}`},gt++;continue}}n.onExecStart&&n.onExecStart(S||"No Command"),yield{type:"exec_start"}}let bt=oe(F.args),Fn=bt.path||bt.targetPath||null;if(Fn){let S=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,H=ae.resolve(Fn),re=ae.resolve(process.cwd());if(S&&!H.startsWith(re)){let ge="Access Denied. You are not allowed to access files outside the current workspace.";if(w==="write_file"||w==="update_file"){let Fe=`\u2718 ${w==="write_file"?"Write Canceled":"Edit Canceled"}: ${bt.path||"..."}`,De=115;process.stdout.isTTY&&(De=process.stdout.columns-5||120);let Ee=Math.min(Fe.length+4,De),J=`${Fe.padEnd(Ee-2).substring(0,Ee-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
737
725
|
`:""}${J}
|
|
738
|
-
`)},Ye=!1}
|
|
726
|
+
`)},Ye=!1}Me.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ge}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ge}`},gt++;continue}}if(n.onToolApproval&&(w==="write_file"||w==="update_file"||w==="exec_command")){let H=n.systemSettings||{},re=H.autoExec,ge=null,be=!1,Fe=!1,De=!1;if(w==="exec_command"){let{command:Oe}=oe(F.args),mt=(Oe||"").trim(),Ne=(Gt,wt)=>{if(!wt)return!1;let tn=wt.split(",").map(jt=>jt.trim().toLowerCase()).filter(Boolean),lt=Gt.toLowerCase();return tn.some(jt=>lt.startsWith(jt))},nt=Ne(mt,H.alwaysAskCommands),_e=Ne(mt,H.autoApproveCommands);if(Fe=Ne(mt,H.autoDisallowCommands),nt?be=!0:(_e||H.autoApproveGit&&/^git\s+commit\b/i.test(mt))&&(ge="allow"),!be&&!ge){if(H.networkAccess===!1){let wt=mt.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),lt=wt[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),jt=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),ct=!1;jt.has(lt)&&(ct=!0);let ot=Cn=>wt.slice(1).some(pn=>Cn.includes(pn)),dt=Cn=>{let pn=wt.findIndex(yn=>Cn.includes(yn)),Bn=wt.findIndex(yn=>["run","exec","test"].includes(yn));return pn!==-1&&!(Bn!==-1&&Bn<pn)};lt==="git"&&ot(["clone","pull","push","fetch"])&&(ct=!0),lt==="go"&&ot(["get","install"])&&(ct=!0),lt==="npm"&&dt(["install","i","update","add"])&&(ct=!0),lt==="yarn"&&dt(["add","install","upgrade"])&&(ct=!0),lt==="pnpm"&&dt(["add","install","update"])&&(ct=!0),lt==="bun"&&dt(["add","install","update"])&&(ct=!0),lt==="deno"&&ot(["install","add"])&&(ct=!0),lt==="pip"&&ot(["install","download"])&&(ct=!0),lt==="pip3"&&ot(["install","download"])&&(ct=!0),lt==="cargo"&&ot(["install","add"])&&(ct=!0),["bash","sh","zsh","fish"].includes(lt)&&ot(["-c"])&&(ct=!0),lt==="cmd"&&ot(["/c"])&&(ct=!0),ct&&(ge="deny",De=!0)}!ge&&Fe&&(ge="deny")}!be&&!ge&&re&&(ge="allow")}else re&&(ge="allow");let Ee=ge,J="";ge==="deny"&&(De?J="network":Fe?J="settings":J="prohibited");let de=!1,ue="",je=[],ze=0,he=!1,At="";if(!Ee){if(w==="write_file"||w==="update_file")try{let Ne=oe(F.args),{path:nt}=Ne;if(nt){let _e=ae.resolve(process.cwd(),nt),Gt=ot=>ot?ot.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,dt=>dt.toUpperCase()):"",wt=Gt(_e),tn="",lt=!1,jt=await Wn(),ct=Gt(jt?.file_focused);if(jt&&ct===wt&&jt.full_content?(tn=jt.full_content,lt=!0):Ue.existsSync(_e)&&(tn=Ue.readFileSync(_e,"utf8"),lt=!0),ue=tn,await Oo.recordFileChange(_e,tn),lt){let ot=tn;if(w==="write_file"){let dt=Ne.content||Ne.newContent||"";ot=dt.endsWith(`
|
|
739
727
|
`)?dt:dt+`
|
|
740
|
-
`,At=ot}else{let{patchPairs:dt,allowMultiple:
|
|
741
|
-
${xs.map(
|
|
742
|
-
`)}`,
|
|
743
|
-
`:""}${
|
|
728
|
+
`,At=ot}else{let{patchPairs:dt,allowMultiple:Cn,error:pn}=Ti(Ne);if(pn){let Xt=`[ACTION RESULT]: ERROR: ${pn}`;Me.push({role:"user",text:Xt}),await Mt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w),yield{type:"tool_result",content:Xt,toolName:w},gt++;continue}let Bn=Ne.allowMultiple!==void 0?Ne.allowMultiple===!0||String(Ne.allowMultiple).toLowerCase()==="true":Cn;ze=dt.length;let yn=Si(tn,dt,{allowMultiple:Bn});ot=yn.content,At=ot,je=yn.results;let Co=je.filter(Xt=>Xt.success),xs=je.filter(Xt=>!Xt.success);if(Co.length===0){let Xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${ae.basename(_e)}].
|
|
729
|
+
${xs.map(Eo=>` \u2022 ${Eo.error}`).join(`
|
|
730
|
+
`)}`,no=`\u2714 Edited: ${ae.basename(_e.replaceAll("\\","/"))}`,ft=115;process.stdout.isTTY&&(ft=process.stdout.columns-5||120);let Kt=Math.min(no.length+4,ft),oo=`${no.padEnd(Kt-2).substring(0,Kt-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
731
|
+
`:""}${oo}`)},Ye=!1,Me.push({role:"user",text:Xt}),await Mt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w),yield{type:"tool_result",content:Xt,toolName:w},gt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${ae.basename(_e)}`},zs(_e,tn,ot),de=!0,await new Promise(dt=>setTimeout(dt,50))}else if(w==="write_file"){let ot=Ne.content||Ne.newContent||"",dt=ot.endsWith(`
|
|
744
732
|
`)?ot:ot+`
|
|
745
|
-
`;At=dt,Ue.existsSync(_e)||(he=!0,Ue.mkdirSync(ae.dirname(_e),{recursive:!0}),Ue.writeFileSync(_e,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${ae.basename(_e)}`},zs(_e,"",dt),de=!0,await new Promise(
|
|
746
|
-
${ue.split(/\r?\n/).map((Kt,
|
|
733
|
+
`;At=dt,Ue.existsSync(_e)||(he=!0,Ue.mkdirSync(ae.dirname(_e),{recursive:!0}),Ue.writeFileSync(_e,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${ae.basename(_e)}`},zs(_e,"",dt),de=!0,await new Promise(Cn=>setTimeout(Cn,50))}}}catch(Ne){console.error("Simulation/Diff Error:",Ne)}let Oe=null;qs(Ne=>{Oe=Ne});let mt=n.onToolApproval;if(Ee=await new Promise(async Ne=>{let nt=setInterval(()=>{Oe&&(as.onIDEApproval&&as.onIDEApproval(Oe),clearInterval(nt),Ne(Oe))},100);try{let _e=await mt(w,F.args);clearInterval(nt),Ne(_e)}catch{clearInterval(nt),Ne("deny")}}),qs(null),w==="write_file"||w==="update_file"){let{path:Ne}=oe(F.args);if(Ne){let nt=ae.resolve(process.cwd(),Ne);if(Nr(nt,Ee),Ee==="deny"&&he&&Ue.existsSync(nt))try{Ue.unlinkSync(nt)}catch{}}}Ee==="deny"&&(J="user")}if(Ee==="allow"&&de&&zo()){let{path:Oe}=oe(F.args),mt=ae.resolve(process.cwd(),Oe),Ne=ft=>ft?ae.resolve(ft).replace(/\\/g,"/").toLowerCase():"",nt=await Wn(),_e="";if(nt&&nt.file_focused&&Ne(nt.file_focused)===Ne(mt)&&nt.full_content&&(_e=nt.full_content),!_e&&Ue.existsSync(mt)){let ft=Ue.readFileSync(mt,"utf8");ft&&(_e=ft)}!_e&&At&&(_e=At),(_e||he)&&Ue.writeFileSync(mt,_e,"utf8");let Gt=_e.split(/\r?\n/),wt=Gt.length,tn=Buffer.byteLength(_e,"utf8"),lt="";ue&&(lt=`Old File contents:
|
|
734
|
+
${ue.split(/\r?\n/).map((Kt,oo)=>`${oo+1} | ${Kt}`).join(`
|
|
747
735
|
`)}
|
|
748
736
|
|
|
749
737
|
`);let jt="";if(wt<=100)jt=Gt.join(`
|
|
@@ -753,10 +741,10 @@ ${ue.split(/\r?\n/).map((Kt,so)=>`${so+1} | ${Kt}`).join(`
|
|
|
753
741
|
|
|
754
742
|
... [${wt-100} lines truncated for history stability] ...
|
|
755
743
|
|
|
756
|
-
${Kt}`}let ct="";if(w==="update_file"){let ft=_i(ue,_e,je,12,n?.compressToolResults||as?.systemSettings?.compressToolResults);ct=`File [${
|
|
744
|
+
${Kt}`}let ct="";if(w==="update_file"){let ft=_i(ue,_e,je,12,n?.compressToolResults||as?.systemSettings?.compressToolResults);ct=`File [${Oe}] updated via IDE Companion (May have user edits). [${je.length}/${ze}] blocks applied.
|
|
757
745
|
|
|
758
|
-
${ft}`}else{let ft=_e.split(/\r?\n/),Kt=ft.length,
|
|
759
|
-
${ue.split(/\r?\n/).map((ws,
|
|
746
|
+
${ft}`}else{let ft=_e.split(/\r?\n/),Kt=ft.length,oo=Buffer.byteLength(_e,"utf8"),Eo="";ue&&(Eo=`Old File contents:
|
|
747
|
+
${ue.split(/\r?\n/).map((ws,ga)=>`${ga+1} | ${ws}`).join(`
|
|
760
748
|
`)}
|
|
761
749
|
|
|
762
750
|
`);let bs="";if(Kt<=100)bs=ft.join(`
|
|
@@ -766,78 +754,78 @@ ${ue.split(/\r?\n/).map((ws,ua)=>`${ua+1} | ${ws}`).join(`
|
|
|
766
754
|
|
|
767
755
|
... [${Kt-100} lines truncated] ...
|
|
768
756
|
|
|
769
|
-
${ws}`}ct=`File [${
|
|
770
|
-
- Stats: [${Kt} lines, ${(
|
|
771
|
-
${
|
|
757
|
+
${ws}`}ct=`File [${Oe}] saved via IDE Companion (May have user edits).
|
|
758
|
+
- Stats: [${Kt} lines, ${(oo/1024).toFixed(1)} KB]
|
|
759
|
+
${Eo}- Content Preview:
|
|
772
760
|
|
|
773
|
-
${bs}`}let ot=w==="write_file"?"Created":"Edited",dt=oe(F.args),
|
|
774
|
-
`:""}${xs}`)},Ye=!1;let Xt=Date.now();We=Xt,yield{type:"tool_time",content:Xt-j};let
|
|
761
|
+
${bs}`}let ot=w==="write_file"?"Created":"Edited",dt=oe(F.args),pn=Object.entries(dt).some(([ft,Kt])=>ft.startsWith("searchContent")&&typeof Kt=="string"&&Kt.startsWith("^LINE:"))?"\u1361":":",Bn=`${Oe?"\u2714":"\u2718"} ${ot}${pn} ${Oe?Oe.replaceAll("\\","/"):"No File Changes"}`,yn=115;process.stdout.isTTY&&(yn=process.stdout.columns-5||120);let Co=Math.min(Bn.length+4,yn),xs=`${Bn.padEnd(Co-2).substring(0,Co-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
762
|
+
`:""}${xs}`)},Ye=!1;let Xt=Date.now();We=Xt,yield{type:"tool_time",content:Xt-j};let no=`[ACTION RESULT]: ${ct}`;Me.push({role:"user",text:no}),Tn=!0,await Mt("toolSuccess"),n.onToolResult&&n.onToolResult("success",w),yield{type:"tool_result",content:ct,aiContent:no,toolName:w},gt++;continue}if(Ee==="deny"){let Oe=`Permission Denied: Prohibited ${w==="exec_command"?"Command":"file edit"}.`;if(J==="user"?Oe="Permission Denied by User":J==="settings"?Oe="Permission Denied by User Policy":J==="network"?Oe="Permission Denied: Sandbox Network Access Disabled by User Policy.":J==="prohibited"&&w==="exec_command"&&(Oe="Permission Denied: Prohibited Command in User Policy"),w==="write_file"||w==="update_file"){let Ne=`\u2718 ${w==="write_file"?"Write Cancelled":"Edit Denied"}: ${oe(F.args).path.replaceAll("\\","/")||"..."}`,nt=115;process.stdout.isTTY&&(nt=process.stdout.columns-5||120);let _e=Math.min(Ne.length+4,nt),Gt=`${Ne.padEnd(_e-2).substring(0,_e-2)}`,wt=` ${" ".repeat(_e)} `;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
775
763
|
`:""}${Gt}
|
|
776
|
-
`)},Ye=!1}w==="exec_command"&&(await new Promise(mt=>setTimeout(mt,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${
|
|
764
|
+
`)},Ye=!1}w==="exec_command"&&(await new Promise(mt=>setTimeout(mt,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Oe}`),await new Promise(mt=>setTimeout(mt,50)),n.onExecEnd&&n.onExecEnd()),Me.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Oe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Oe}`},await Mt("toolDenied"),n.onToolResult&&n.onToolResult("denied",w),gt++;continue}}if(q){let S=115;process.stdout.isTTY&&(S=process.stdout.columns-5||120);let H=await s(),re=!1;H&&(re=H.trim().length>0);let ge=Math.min(q.length+4,S),be=`${q.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
777
765
|
`:""}${be}${q.includes("\u2714")&&(q.includes("Created")||q.includes("Edited"))?"":`${re?"":`
|
|
778
|
-
`}`}`)},Ye=!1}if(We>0){let S=Date.now()-We,H=Math.max(0,1e3-S);H>0&&await new Promise(re=>setTimeout(re,H))}let An={chatId:p,history:t,onChunk:S=>n.onExecChunk?n.onExecChunk(S):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:l,isMultiModal:ut(Te),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:Te,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(w==="write_file"||w==="update_file")try{let{path:S}=oe(F.args);if(S){let H=ae.resolve(process.cwd(),S),re=await
|
|
766
|
+
`}`}`)},Ye=!1}if(We>0){let S=Date.now()-We,H=Math.max(0,1e3-S);H>0&&await new Promise(re=>setTimeout(re,H))}let An={chatId:p,history:t,onChunk:S=>n.onExecChunk?n.onExecChunk(S):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:l,isMultiModal:ut(Te),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:Te,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(w==="write_file"||w==="update_file")try{let{path:S}=oe(F.args);if(S){let H=ae.resolve(process.cwd(),S),re=await Wn();re&&re.file_focused===H&&re.full_content&&(An.forcedContent=re.full_content)}}catch{}st.push(w);let Pe=await yo(w,F.args,An);if((w==="write_file"||w==="update_file")&&!Pe.startsWith("ERROR:")){let{path:S}=oe(F.args);if(S){let H=ae.resolve(process.cwd(),S);$r(H)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Nt=Date.now();We=Nt,yield{type:"tool_time",content:Nt-j},V=Nt;let Ht=null;if(typeof Pe=="object"&&Pe.binaryPart&&(Ht=Pe.binaryPart,Pe=Pe.text),w==="search_keyword"){let{keyword:S,path:H}=oe(F.args),re=typeof Pe=="string"&&Pe.startsWith("[GLOB]");re&&(Pe=Pe.slice(6).trimStart());let ge=typeof Pe=="string"&&Pe.startsWith("[DIR]");ge&&(Pe=Pe.slice(5).trimStart());let be=0;if(Pe){let he=Pe.match(/Found (\d+) match/i);he&&(be=parseInt(he[1]))}let Fe=(H||"").trim().toLowerCase().replaceAll("\\","/"),De=Fe==="#doc"||Fe==="#docs"||Fe==="#documentation"||Fe.includes("#skill/global/fluxflow")||Fe.includes("#skill/fluxflow")||Fe.includes("#skills/fluxflow")||Fe.includes("#skills/global/fluxflow"),Ee,J=115;process.stdout.isTTY&&(J=process.stdout.columns-5||120);let de=Math.max(10,(J+5)/3),ue=Math.max(10,(J+5)/4);if(De)Ee=`${S?"\u2714":"\u2718"} Searched Documentation`;else{let he=H?H.replace(/[\/\\]+$/,""):null,At=he&&he!=="."?`${re?H:ge?`${he}/*`:he}`:"./",Oe=At.length>ue?`${At.slice(0,ue)}...`:At;Ee=`${S?"\u2714":"\u2718"} Searched: "${S?S.length>J/2?`${S.slice(0,de)}...`:S:""}" in "${Oe.replaceAll("\\","/")}" \u2192 ${be} Match${be===1?"":"es"}`}let je=Math.min(Ee.length+4,J),ze=`${Ee.padEnd(je-2).substring(0,je-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
779
767
|
`:""}${ze}
|
|
780
|
-
`)},Ye=!1}if(w==="EmergencyRollback"){let{method:S}=oe(F.args);if(S==="forceRevert"){let H=0;if(Pe){let de=Pe.match(/Total\s*:\s*(\d+)/i);de&&(H=parseInt(de[1]))}let ge=Pe&&Pe.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${H} file${H===1?"":"s"} processed`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let Fe=await s(),
|
|
781
|
-
`:""}${J}${
|
|
782
|
-
`}`)},Ye=!1}}if(w==="todo"){let{method:S,tasks:H,markDone:re}=oe(F.args),ge="",be=[],Fe=
|
|
783
|
-
`)}return
|
|
768
|
+
`)},Ye=!1}if(w==="EmergencyRollback"){let{method:S}=oe(F.args);if(S==="forceRevert"){let H=0;if(Pe){let de=Pe.match(/Total\s*:\s*(\d+)/i);de&&(H=parseInt(de[1]))}let ge=Pe&&Pe.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${H} file${H===1?"":"s"} processed`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let Fe=await s(),De=!1;Fe&&(De=Fe.trim().length>0);let Ee=Math.min(ge.length+4,be),J=`${ge.padEnd(Ee-2).substring(0,Ee-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
769
|
+
`:""}${J}${De?"":`
|
|
770
|
+
`}`)},Ye=!1}}if(w==="todo"){let{method:S,tasks:H,markDone:re}=oe(F.args),ge="",be=[],Fe=De=>{if(!De)return[];let Ee=Array.isArray(De)?De:[];if(Ee.length===0&&typeof De=="string"){let J=De.trim();if(J.startsWith("[")&&J.endsWith("]")){let de=J.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);de?Ee=de.map(ue=>ue.slice(1,-1).replace(/\\(.)/g,"$1")):Ee=J.slice(1,-1).split(",").map(ue=>ue.trim()).filter(Boolean)}else Ee=De.split(`
|
|
771
|
+
`)}return Ee.filter(J=>String(J).trim()).map(J=>{let de=String(J).trim();return de.startsWith("- [")?de.substring(6).trim():de})};if(S==="create"?(ge="\x1B[32m\u2192\x1B[0m Created Goals",be=Fe(H).map(De=>`\x1B[90m\u25CB\x1B[0m ${De}`)):S==="append"?(ge="\x1B[34m\u2795\x1B[0m Added New Goals",be=Fe(H).map(De=>`\x1B[90m\u25CB\x1B[0m ${De}`)):S==="get"&&(ge=re?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",be=(Pe||"").split(`
|
|
784
772
|
`).slice(1).join(`
|
|
785
773
|
`).split(`
|
|
786
|
-
`).filter(
|
|
787
|
-
`),
|
|
788
|
-
`:""}${
|
|
789
|
-
`}`)},Ye=!1}}w==="exec_command"&&n.onExecEnd&&(await new Promise(S=>setTimeout(S,800)),n.onExecEnd());let
|
|
790
|
-
`));let
|
|
774
|
+
`).filter(Ee=>Ee.trim().startsWith("- [")).map(Ee=>{let J=Ee.trim(),de=J.startsWith("- [x]");return`${de?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${de?"\x1B[90m":"\x1B[37m"}${J.substring(6).trim()}\x1B[0m`})),ge&&be.length>0){let De=[`${ge}`,...be.map(de=>` ${de}`)].join(`
|
|
775
|
+
`),Ee=await s(),J=!1;Ee&&(J=Ee.trim().length>0),yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
776
|
+
`:""}${De}${J?"":`
|
|
777
|
+
`}`)},Ye=!1}}w==="exec_command"&&n.onExecEnd&&(await new Promise(S=>setTimeout(S,800)),n.onExecEnd());let hn=Pe&&Pe.startsWith("DENIED:");Pe&&!Pe.startsWith("ERROR:")&&!hn?(await Mt("toolSuccess"),n.onToolResult&&n.onToolResult("success",w)):hn||(await Mt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w));let Ft=(Pe||"").toString().replaceAll("[UI_CONTEXT]","");Ft.includes("[[VERIFIED]]")&&(Ft=Ft.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
|
|
778
|
+
`));let mn;if(Ft.startsWith("[[SAME]]")){let H=Ft.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),re=H.filter(be=>be.startsWith("File ")||be.trim().startsWith("- Stats:"));mn=`[ACTION RESULT]: ${re.length>0?re.join(`
|
|
791
779
|
`):H.slice(0,2).join(`
|
|
792
780
|
`)}
|
|
793
|
-
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else
|
|
781
|
+
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else mn=`[ACTION RESULT]: ${Ft}`;Me.push({role:"user",text:mn,binaryPart:Ht}),Tn=!0;let $e=`[ACTION RESULT]: ${Pe.replaceAll(`[[VERIFIED]]
|
|
794
782
|
`,"").replaceAll(`
|
|
795
|
-
[[/VERIFIED]]`,"")||""}`;(w==="view_file"||w==="web_scrape"||w==="file_map")&&($e=`[ACTION RESULT]: ${q} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:$e,aiContent:
|
|
783
|
+
[[/VERIFIED]]`,"")||""}`;(w==="view_file"||w==="web_scrape"||w==="file_map")&&($e=`[ACTION RESULT]: ${q} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:$e,aiContent:mn,binaryPart:Ht,toolName:w},w==="memory"&&!Pe.startsWith("ERROR:")&&(yield{type:"memory_updated"}),gt++}if(i==="Google"&&cn&&Date.now()-ms>=150){yield*$n();let F=eo(cn);for(let j of F)yield j;cn="",ms=Date.now()}}M.usageMetadata&&(Jt=M.usageMetadata),Jt&&(yield{type:"liveTokens",content:Jt.totalTokenCount})}if(me&&(me=!1,Ot?Qe+="</think>":(ke+="</think>",i==="Google"?cn+="</think>":yield{type:"text",content:"</think>"})),Ot&&Qe.length>0){let M=0,Y=Math.min(xt.length,Qe.length);for(let z=Y;z>0;z--)if(xt.endsWith(Qe.substring(0,z))){M=z;break}let W=Qe.substring(M);if(W){let Q=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?W.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):W.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(Q)if(ke+=Q,i==="Google")cn+=Q;else{yield*$n();let X=eo(Q);for(let ne of X)yield ne}}Ot=!1,Qe=""}if(yield*$n(),kt)break;let to=(ke||"").trim(),aa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(to.toLowerCase())||/\[\[END\]\]/i.test(to.toLowerCase()),la=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(to.toLowerCase()),ca=Me.length>0||Ve!==null,ps=qt(to).trim(),da=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(ps),fa=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(ps.trim()),ua=/[.!?}"'`’“”]$|```$/s.test(ps)||fa||da;!aa&&!la&&!ca&&to.length>0,it=!0,await Mt("agent",i)}catch(Ae){if(kt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
796
784
|
|
|
797
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Ae).includes("Incomplete JSON segment at the end")){me&&(me=!1,
|
|
785
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Ae).includes("Incomplete JSON segment at the end")){me&&(me=!1,Ot?Qe+="</think>":(ke+="</think>",yield{type:"text",content:"</think>"})),it=!0,await Mt("agent",i);break}if(me&&(me=!1,Ot?Qe+="</think>":ke+="</think>"),Ot&&Qe.length>0){let $t=0,Rt=Math.min(xt.length,Qe.length);for(let Dt=Rt;Dt>0;Dt--)if(xt.endsWith(Qe.substring(0,Dt))){$t=Dt;break}let St=Qe.substring($t);if(St){let ht=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");ht&&(ke+=ht)}Ot=!1,Qe=""}let Z=Ae instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Ae.message).error.message).error.message}catch{return String(Ae)}})():String(Ae),Pt=new Date().toLocaleString(),Ct=ae.join(En,"agent");Ue.existsSync(Ct)||Ue.mkdirSync(Ct,{recursive:!0}),Ue.appendFileSync(ae.join(Ct,"error.log"),`ERROR [${Pt}]: ${Z}
|
|
798
786
|
|
|
799
787
|
----------------------------------------------------------------------
|
|
800
788
|
|
|
801
|
-
`);let
|
|
789
|
+
`);let Et=Ae.status||Ae.statusCode||Ae.code,zt=String(Ae).includes("replicas at capacity");if(!(Et&&(Et>=500&&Et<600||Et===408||Et===429||zt)||!Et&&(/status[ :]+(5\d\d|408|429)/i.test(String(Ae))||/code[ :]+(5\d\d|408|429)/i.test(String(Ae))||/(500|503|408|429)/.test(String(Ae))))){if(et<rn-3)throw Ae;yield{type:"text",content:Z},yield{type:"status",content:"Error Occured"}}if(ke.trim().length>0||at>1)if(at<=rn){at++;let $t=Math.min(1e3*Math.pow(2,at-1),24e3);if(ke.trim().length>0){r.push({role:"agent",text:ke});let Rt=`[system]
|
|
802
790
|
- seamless continuation: resume immediately. pick up from last words with zero gap/disruption
|
|
803
791
|
- no repetition: do not repeat any text already written
|
|
804
792
|
- no re-think: do not restart or open <think> if reasoning already started. continue the thinking and close thinking block </think> before chat output
|
|
805
793
|
- mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
|
|
806
|
-
- stealth: do not mention/apologize for cutoff [/system]`;
|
|
794
|
+
- stealth: do not mention/apologize for cutoff [/system]`;Me.length>0?Me.forEach((St,Dt)=>{Dt===Me.length-1?r.push({...St,text:`${St.text}
|
|
807
795
|
|
|
808
|
-
${Rt}`}):r.push(St)}):r.push({role:"user",text:Rt}),xt+=ke}for(let Rt=$t/1e3;Rt>0&&!kt;Rt--)yield{type:"status",content:`Error Occured. Recovering Stream (${at}/${
|
|
809
|
-
Error log can be found in \`/export logs\``);else if(et<=
|
|
810
|
-
Error log can be found in \`/export logs\``)}}if(Jt){let me=Jt.totalTokenCount||0,Ae=Jt.cachedContentTokenCount||0,
|
|
811
|
-
`),Ae=qt(me).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:me,history:[...r],needTitle:y}},r.length>0&&r[r.length-1].role==="agent"?r[r.length-1].text=Ae:r.push({role:"agent",text:Ae}),r.forEach(
|
|
796
|
+
${Rt}`}):r.push(St)}):r.push({role:"user",text:Rt}),xt+=ke}for(let Rt=$t/1e3;Rt>0&&!kt;Rt--)yield{type:"status",content:`Error Occured. Recovering Stream (${at}/${rn}) [Retrying in ${Rt.toFixed(0)}s]...`},await new Promise(St=>setTimeout(St,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${rn} times)
|
|
797
|
+
Error log can be found in \`/export logs\``);else if(et<=rn){et++,at=1,xt="";let $t=Math.min(1e3*Math.pow(2,et-1),32e3),Rt=.8+Math.random()*.4,St=Math.round($t*Rt);Qn=!0,yield{type:"status",content:`Trying to reach ${e} (${et}/${rn}) [Retrying in ${(St/1e3).toFixed(0)}s]`};for(let Dt=St/1e3;Dt>0&&!kt;Dt--)yield{type:"status",content:`Trying to reach ${e} (${et}/${rn}) [Retrying in ${Dt.toFixed(0)}s]`},await new Promise(ht=>setTimeout(ht,1e3));yield{type:"status",content:`Trying to reach ${e}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${rn} times)
|
|
798
|
+
Error log can be found in \`/export logs\``)}}if(Jt){let me=Jt.totalTokenCount||0,Ae=Jt.cachedContentTokenCount||0,Z=(Jt.candidatesTokenCount||0)+(i==="Google"&&Jt.thoughtsTokenCount||0);await Bt("tokens",me,i,Te),Ae>0&&await Bt("cachedTokens",Ae,i,Te),Z>0&&await Bt("candidateTokens",Z,i,Te),Do({provider:i,model:Te,prompt:Jt.promptTokenCount||0,cached:Ae,output:Z,reasoning:Jt.thoughtsTokenCount||0}),yield{type:"usage",content:Jt}}ke=qr(ke),hs.push(ke);let _o=qt(ke),en=jr(ke),na=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(en.toLowerCase())||/\[\[END\]\]/i.test(en.toLowerCase())||!0,rl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(en.toLowerCase()),al=gt>0;yield{type:"status",content:"Thinking"};let oa=el(ke,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Pn=(na||Me.length===0)&&!It&&!ln&&!Sn;if(Pn=Me.length===0?Pn:!1,Pn=Lt||So?!1:Pn,ke&&ke.trim().endsWith('")]')&&Me.length===0&&(Pn=!1),Pn){pi=!0;let me=hs.join(`
|
|
799
|
+
`),Ae=qt(me).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:me,history:[...r],needTitle:y}},r.length>0&&r[r.length-1].role==="agent"?r[r.length-1].text=Ae:r.push({role:"agent",text:Ae}),r.forEach(Z=>{if(Z.role==="user"&&Z.text&&(Z.text=Z.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),Z.text=Z.text.replaceAll(`
|
|
812
800
|
|
|
813
801
|
[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
|
|
814
802
|
`,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
|
|
815
803
|
**strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
816
804
|
`,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
817
|
-
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),
|
|
818
|
-
[system] Action result received. Analyze output and proceed with your turn [/system]`,
|
|
819
|
-
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;
|
|
805
|
+
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),Z.text=Z.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(Z.text.startsWith("[ACTION RESULT]")||Z.text.startsWith("[TOOL RESULT]")))){let Ct=`
|
|
806
|
+
[system] Action result received. Analyze output and proceed with your turn [/system]`,Et=`
|
|
807
|
+
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;Z.text=Z.text.replaceAll(Et,"").replaceAll(Ct,"").trim()}}),yield{type:"status",content:"[end]"}}if(Pn)break;let sa=oa.trim()||"*Working...*";if(r.push({role:"agent",text:sa}),Me.length>0||Tn){if(Me.length>0){let me=Me.map(zt=>zt.text).join(`
|
|
820
808
|
|
|
821
|
-
`),Pt=(qt(ke).replace(/\[{1,2}(?:tool|action):[\s\S]*?\)\s*\]{1,2}/gi,"").match(/\[(?:tool|action):/gi)||[]).length,
|
|
809
|
+
`),Pt=(qt(ke).replace(/\[{1,2}(?:tool|action):[\s\S]*?\)\s*\]{1,2}/gi,"").match(/\[(?:tool|action):/gi)||[]).length,Ct=Me.length+Pt;if(Me.length<Ct){me+=`
|
|
822
810
|
|
|
823
|
-
[system] Only ${
|
|
811
|
+
[system] Only ${Me.length} out of ${Ct} attempted tool calls were executed. Verify proper structure compliance & try failed calls again [/system]`;let zt=Ct-Me.length;for(let Ge=0;Ge<zt;Ge++)await Mt("toolFailure")}let Et=Me.find(zt=>zt.binaryPart)?.binaryPart||null;r.push({role:"user",text:me,binaryPart:Et})}}else if(!kt){let Ae=(ke.replace(/(?:<(think|thought|thoughts)>|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|\[\/(think|thought|thoughts)\]|$)/i,"").match(/\[(?:tool|action):/gi)||[]).length;So||Lt||Ae>0?(r.push({role:"user",text:`[system] Failed to execute ${Ae} tool${Ae>1?"s":""}. Verify proper structure compliance [action:ActionName(...)] & try again [/system]`}),await Mt("toolFailure"),yield{type:"visual_feedback",content:`
|
|
824
812
|
${Yt("\u2718 Execution Error")}
|
|
825
813
|
`}):(yield{type:"visual_feedback",content:`
|
|
826
814
|
${Yt("\u2718 Loop Detected")}
|
|
827
|
-
`},r.push({role:"user",text:`[system] ${
|
|
815
|
+
`},r.push({role:"user",text:`[system] ${ln&&!It?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${It?" Over Thinking":" Loop"} Detected by Internal System${It?" for current Effort Level":""}. ${It?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`})),It=!1,ln=!1,Sn=!1}T?.advanceRollback&&await ao.recordTurnDelta(p,K+1,st),So=gt>0||Tn}if(!pi&&!kt){let K="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
|
|
828
816
|
|
|
829
817
|
${K}
|
|
830
818
|
`};let Ke=(hs.join(`
|
|
831
819
|
`)+`
|
|
832
|
-
${K}`).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:Ke,history:[...r],needTitle:y}},yield{type:"status",content:"[end]"}}}catch(d){let r=d?.cause?` (Cause: ${d.cause?.message||String(d.cause)})`:"",
|
|
820
|
+
${K}`).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:Ke,history:[...r],needTitle:y}},yield{type:"status",content:"[end]"}}}catch(d){let r=d?.cause?` (Cause: ${d.cause?.message||String(d.cause)})`:"",v=(d instanceof Error?(()=>{try{return JSON.parse(JSON.parse(d.message).error.message).error.message}catch{return(d.message?`${d.message}${r}`:"")||String(d)}})():String(d)).replace(/^(Error:\s*)+/i,"");i==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(v)&&(v=`GEMINI ERROR: ${v}`);let U=new Date().toLocaleString(),O=ae.join(En,"agent");yield{type:"text",content:`
|
|
833
821
|
|
|
834
|
-
\u2726 CRITICAL ERROR: ${
|
|
835
|
-
\u2800`},Ue.existsSync(
|
|
822
|
+
\u2726 CRITICAL ERROR: ${v.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":v}
|
|
823
|
+
\u2800`},Ue.existsSync(O)||Ue.mkdirSync(O,{recursive:!0}),Ue.appendFileSync(ae.join(O,"error.log"),`CRITICAL ERROR [${U}]: ${d}${d?.cause?`
|
|
836
824
|
CAUSE: ${d.cause?.stack||d.cause}`:""}
|
|
837
825
|
|
|
838
826
|
----------------------------------------------------------------------
|
|
839
827
|
|
|
840
|
-
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${
|
|
828
|
+
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${v}`}}finally{R&&(clearInterval(R),R=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Oo.commitTransaction(),T?.advanceRollback&&await ao.cleanup(p),await Wn()}yield{type:"status",content:null}},xf=async(e,t,n=null,s=null,o=50,c=null,f=!1)=>{let l=await ro(),k={...l,...t},p=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,g=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,T=new Date,m=`${T.getFullYear()}-${T.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(T.getDate()).padStart(2,"0")}, ${T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,u=(R=>{if(!R)return null;let d=R.toLowerCase();return d==="google"?"Google":d==="deepseek"?"DeepSeek":d==="openrouter"?"OpenRouter":d==="nvidia"?"NVIDIA":d==="mistral"?"Mistral":d==="ollama"?"Ollama":d==="inferx"?"InferX":d==="sensenova"?"SenseNova":d==="poolside"?"Poolside":d==="9router"||d==="9Router"?"9router":d==="aihubmix"||d==="aihub"?"AIHubMix":d==="explabs"||d==="experientiallabs"||d==="experimentallabs"?"ExpLabs":d==="tokenharbor"||d==="token harbor"||d==="token_harbor"||d==="thk"?"TokenHarbor":d==="apinex"||d==="apx"?"APInex":null})(g),b=k?.systemSettings?.CustomSubAgent?k?.systemSettings?.SubAgentModel:null,D=k?.systemSettings?.CustomSubAgent?k?.systemSettings?.SubAgentProvider:null,h=null;if(b==="ENV"?(h=p,p&&u&&(k.aiProvider=u)):b&&b!=="Default"?(h=b,D&&(k.aiProvider=D)):p&&u&&(k.aiProvider=u),k.aiProvider){let R=await Ss(k.aiProvider);R&&(k.apiKey=R)}let A=R=>{if(!R||typeof R!="string")return{allowed:!0};let d=[/rm\s+-[rf]{1,2}\s+[\/*.]/i,/rmdir\s+\/[sq]/i,/del\s+\/[fsq]/i,/\bformat\b\s+[a-z]:/i,/mkfs/i,/dd\s+if=/i,/\b(shutdown|reboot|poweroff|init\s+0|init\s+6)\b/i,/chmod\s+(-R\s+)?777\s+[\/*.]/i,/chown\s+(-R\s+)?root/i,/git\s+push\s+.*--force/i,/git\s+clean\s+-fdx/i,/\bsudo\s+su\b/i,/\bsu\s+-\b/i];for(let r of d)if(r.test(R))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${r.source}"`};return{allowed:!0}},$=n||h||t?.modelName||t?.activeModel||l.activeModel,E=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",x=`-- ACTIONS (path = relative to CWD, path separator: '/') --
|
|
841
829
|
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
842
830
|
Rules:
|
|
843
831
|
- JSON escape literal sequences, backslash: \\\\, newLine: \\ n
|
|
@@ -862,7 +850,7 @@ ${f?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
|
|
|
862
850
|
- ReadFile(path=string, startLine?=int, endLine?=int)
|
|
863
851
|
- 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
|
|
864
852
|
- WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
|
|
865
|
-
- Run(command=string). Runs ${
|
|
853
|
+
- Run(command=string). Runs ${E==="Windows"?Ai()?"powershell":"windows CMD":"bash"} command. Destructive command \u2192 Ask user`.trim(),_=`=== START SYSTEM PROMPT ===
|
|
866
854
|
Identity: FluxFlow subagent helping the main Agent
|
|
867
855
|
Your task is: "${e}"
|
|
868
856
|
CWD: ${process.cwd()}
|
|
@@ -875,14 +863,14 @@ Main focus: actions and task, not chatting
|
|
|
875
863
|
On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
|
|
876
864
|
|
|
877
865
|
Current Time: ${m}
|
|
878
|
-
=== END SYSTEM PROMPT ===`,I=[{role:"user",text:`Complete this task: ${e}`}],y=0,a="";for(;y<o;){let R=await _s("subagent",k);if(!R.allowed)throw new Error(R.reason||`Budget Exhausted for Provider (${k?.aiProvider||"Subagent"})`);if(kt){if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);L&&(L.status="cancelled")}throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);if(L&&L.status==="cancelled")throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let d=I.map(L=>({role:L.role==="user"?"user":"model",parts:[{text:L.text}]}));c&&c(`[Subagent Turn ${y+1}]...`);let r=["Fast","Low","Medium","High"],
|
|
866
|
+
=== END SYSTEM PROMPT ===`,I=[{role:"user",text:`Complete this task: ${e}`}],y=0,a="";for(;y<o;){let R=await _s("subagent",k);if(!R.allowed)throw new Error(R.reason||`Budget Exhausted for Provider (${k?.aiProvider||"Subagent"})`);if(kt){if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);L&&(L.status="cancelled")}throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);if(L&&L.status==="cancelled")throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let d=I.map(L=>({role:L.role==="user"?"user":"model",parts:[{text:L.text}]}));c&&c(`[Subagent Turn ${y+1}]...`);let r=["Fast","Low","Medium","High"],C=process.env.SUBAGENT_THINKING,v=r.includes(C)?C:"Low",O=(await ls(k,$,d,_,v)).text||"",P=qr(qt(O).trim());a=P,c&&c(`[Subagent Response]
|
|
879
867
|
${P}
|
|
880
|
-
`),I.push({role:"agent",text:P});let le=
|
|
868
|
+
`),I.push({role:"agent",text:P});let le=wo(P);if(le.length===0)break;let fe=le.filter(L=>L.toolName.toLowerCase()==="askmain"||L.toolName.toLowerCase()==="ask_main"),ee=!1,we="";for(let L of le){if(kt){if(t?.taskId&&typeof Vt<"u"){let B=Vt.find(G=>G.id===t.taskId);B&&(B.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Vt<"u"){let B=Vt.find(G=>G.id===t.taskId);if(B&&B.status==="cancelled")throw new Error("Subagent task was cancelled.")}let N=L.toolName.toLowerCase();if(N==="askuser"&&(N="ask"),N==="askmain"||N==="ask_main"){if(ee)continue;ee=!0;let B="";if(fe.length===1?B=oe(fe[0].args).question||fe[0].args:B=fe.map((G,ye)=>{let Re=oe(G.args);return`Q${ye+1}: ${Re.question||G.args}`}).join(`
|
|
881
869
|
`),t.onAskMain){c&&c(`[Executing Tool] AskMain("${B}")...`);let G=await t.onAskMain(B);c&&c(`[Action Result]
|
|
882
870
|
Answer from Main Agent: ${G}
|
|
883
871
|
`),we+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${G}
|
|
884
872
|
|
|
885
|
-
`,await
|
|
873
|
+
`,await Mt("toolSuccess")}else we+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
|
|
886
874
|
|
|
887
875
|
`;continue}if(!(s?s.some(B=>B.toLowerCase()===N):!0)){let B=`ERROR: Tool [${L.toolName}] is not in the allowed tools list for this subagent.`;c&&c(`[Blocked Tool Call] ${L.toolName} - not allowed
|
|
888
876
|
`),we+=`${B}
|
|
@@ -890,15 +878,15 @@ Answer from Main Agent: ${G}
|
|
|
890
878
|
`;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let B=oe(L.args).command||"",G=A(B);if(!G.allowed){let ye=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${G.reason}`;c&&c(`[Blocked Command] ${B} - ${G.reason}
|
|
891
879
|
`),we+=`${ye}
|
|
892
880
|
|
|
893
|
-
`;continue}}let ie="";if(N==="web_search"||N==="websearch")ie=`\u2714 \x1B[95mSearched\x1B[0m: ${oe(L.args).query||""}`;else if(N==="web_scrape"||N==="webscrape")ie=`\u2714 \x1B[95mScraped\x1B[0m: ${oe(L.args).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let B=oe(L.args),G=B.keyword||"",ye=B.path||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${G||"No Query"}${ye?` \u2192 ${ye.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")ie=`\u2714 \x1B[95mRead\x1B[0m: ${(oe(L.args).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let B=oe(L.args),G=B.basename||B.name||B.path||B.file||B.query||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${G||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let B=oe(L.args).path||null,G=oe(L.args).recurse||0;ie=`${B?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${B?`${B.replaceAll("\\","/")}${G>0?`${B.endsWith("/")?`*${G}`:`/*${G}`}`:`${B.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let B=oe(L.args).path||null;ie=`${B?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${B?`${B.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let B=oe(L.args),G=B.path||null,Re=Object.entries(B).some(([
|
|
881
|
+
`;continue}}let ie="";if(N==="web_search"||N==="websearch")ie=`\u2714 \x1B[95mSearched\x1B[0m: ${oe(L.args).query||""}`;else if(N==="web_scrape"||N==="webscrape")ie=`\u2714 \x1B[95mScraped\x1B[0m: ${oe(L.args).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let B=oe(L.args),G=B.keyword||"",ye=B.path||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${G||"No Query"}${ye?` \u2192 ${ye.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")ie=`\u2714 \x1B[95mRead\x1B[0m: ${(oe(L.args).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let B=oe(L.args),G=B.basename||B.name||B.path||B.file||B.query||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${G||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let B=oe(L.args).path||null,G=oe(L.args).recurse||0;ie=`${B?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${B?`${B.replaceAll("\\","/")}${G>0?`${B.endsWith("/")?`*${G}`:`/*${G}`}`:`${B.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let B=oe(L.args).path||null;ie=`${B?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${B?`${B.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let B=oe(L.args),G=B.path||null,Re=Object.entries(B).some(([ve,Ie])=>ve.startsWith("searchContent")&&typeof Ie=="string"&&Ie.startsWith("^LINE:"))?"\u1361":":";ie=`${G?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Re} ${G?`${G.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let B=oe(L.args).command||null;ie=`${B?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${B?B.slice(0,100)+(B.length>100?"...":""):"No Command"}`}else if(N==="file_map"||N==="filemap"){let B=oe(L.args).path||"";ie=`${B?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${B?`${B.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:B}=oe(L.args),G=parseFloat(B)||0;G<10&&(G=10),G>180&&(G=180),ie=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Re=>{if(Re>=60){let ve=Math.floor(Re/60),Ie=Re%60;return`${ve}m${Ie>0?` ${Ie}s`:""}`}return`${Re}s`})(G)}`}else{let B=si[N]||L.toolName,G=jn(N,L.args);ie=`\u2714 \x1B[95m${B}\x1B[0m${G?`: ${G}`:""}`}t.onVisualFeedback&&ie&&t.onVisualFeedback(ie),c&&c(`[Executing Tool] ${L.toolName}(${L.args})...`);try{let B=await yo(L.toolName,L.args,{...t,mode:"Flux"});if(c&&c(`[Action Result]
|
|
894
882
|
${B}
|
|
895
883
|
`),we+=`[ACTION RESULT for ${L.toolName}]: ${B}
|
|
896
884
|
|
|
897
|
-
`,await
|
|
898
|
-
`),ye=0,Re=0,
|
|
899
|
-
`)){if(Ie.includes("Old File contents:")){
|
|
885
|
+
`,await Mt("toolSuccess"),N==="patchfile"||N==="update_file"||N==="updatefile"||N==="patch_file"){if(B){let G=B.split(`
|
|
886
|
+
`),ye=0,Re=0,ve=!1;for(let Ie of G){if(Ie.includes("[DIFF_START]")){ve=!0;continue}if(Ie.includes("[DIFF_END]")){ve=!1;continue}ve&&(/^\+\d+/.test(Ie)?ye++:/^\-\d+/.test(Ie)&&Re++)}(ye>0||Re>0)&&(await Bt("linesAdded",ye),await Bt("linesRemoved",Re))}}else if((N==="writefile"||N==="write_file")&&B){let G=B.match(/- Stats: \[(\d+) lines/),ye=G?parseInt(G[1]):0,Re=0;if(B.includes("Old File contents:")){let ve=!1;for(let Ie of B.split(`
|
|
887
|
+
`)){if(Ie.includes("Old File contents:")){ve=!0;continue}ve&&(Ie.trim()===""?ve=!1:/^\d+ \|/.test(Ie)&&Re++)}}(ye>0||Re>0)&&(await Bt("linesAdded",ye),await Bt("linesRemoved",Re))}}catch(B){let G=`ERROR: Execution failed for [${L.toolName}]: ${B.message}`;c&&c(`[Tool Error] ${G}
|
|
900
888
|
`),we+=`${G}
|
|
901
889
|
|
|
902
|
-
`,await
|
|
890
|
+
`,await Mt("toolFailure")}}let ce="";if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);if(L&&L.pendingSteerMessages&&L.pendingSteerMessages.length>0){let N=[...L.pendingSteerMessages];L.pendingSteerMessages=[];for(let Ce of N)ce+=`
|
|
903
891
|
|
|
904
|
-
[STEERING INSTRUCTION FROM MAIN AGENT]: ${
|
|
892
|
+
[STEERING INSTRUCTION FROM MAIN AGENT]: ${Ce}`,c&&c(`[Subagent Steered] ${Ce}`)}}let rt=(we.trim()+ce).trim();I.push({role:"user",text:rt}),y++}return a};export{xo as a,Or as b,xc as c,bc as d,He as e,gl as f,hl as g,lc as h,cc as i,Tc as j,zo as k,Sc as l,Ka as m,df as n,Va as o,Ya as p,oi as q,qt as r,Gr as s,qr as t,Ja as u,ff as v,uf as w,ri as x,gf as y,hf as z,ls as A,mf as B,pf as C,yf as D,xf as E};
|