fluxflow-cli 4.16.16 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{execSync as o}from"child_process";var t=null,h=()=>{if(process.platform!=="win32")return!1;if(t!==null)return t;try{o("where.exe pwsh.exe",{stdio:"ignore",windowsHide:!0}),t=!0}catch{t=!1}return t},r=null,a=()=>{if(process.platform!=="win32")return!1;if(r!==null)return r;try{o("where.exe powershell.exe",{stdio:"ignore",windowsHide:!0}),r=!0}catch{r=!1}return r},b=()=>h()?"pwsh":a()?"powershell":"cmd",n=null,w=(e,l,c,u,d=!1,g=!0,p)=>{n===null&&(n=d);let f=`- Mandatorily JSON escape literal sequences (backslash: \\\\, newLine: \\ n, quote: \\")
1
+ import{execSync as o}from"child_process";var t=null,m=()=>{if(process.platform!=="win32")return!1;if(t!==null)return t;try{o("where.exe pwsh.exe",{stdio:"ignore",windowsHide:!0}),t=!0}catch{t=!1}return t},r=null,a=()=>{if(process.platform!=="win32")return!1;if(r!==null)return r;try{o("where.exe powershell.exe",{stdio:"ignore",windowsHide:!0}),r=!0}catch{r=!1}return r},b=()=>m()?"pwsh":a()?"powershell":"cmd",n=null,w=(e,l,c,u,d=!1,g=!0,p)=>{n===null&&(n=d);let f=`- Mandatorily JSON escape literal sequences (backslash: \\\\, newLine: \\ n, quote: \\")
2
2
  - Same file, multiple edits? One PatchFile (\u226415 blocks)${p?"":`
3
3
  - Tool denied? Ask for guidance`}
4
4
  - Need text or huge file? CodeSearch > Full Read
@@ -6,7 +6,7 @@ import{execSync as o}from"child_process";var t=null,h=()=>{if(process.platform!=
6
6
  - Dont hallucinate tool results, verify, fix errors
7
7
  - Stuck on syntax error? Tell user > waste time
8
8
  `,i=`**Workspace Tools (path = relative; first argument; separator: '/')**
9
- - ReadFile(path=string, startLine?=int, endLine?=int)${u==="Google"||c?". Supports images/docs":""}
9
+ - ReadFile(path=string, startLine?=int, endLine?=int)${u==="Google"||c?". Supports images":""}
10
10
  - ReadFolder(path=string, recurse?=int[1..3])
11
11
  - PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchor: ^LINE:...$ syntax, must for large blocks & escape sequences
12
12
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
@@ -19,7 +19,7 @@ Info: initial = current task prompt. Revert id = turn before disaster (eg. disas
19
19
  - EmergencyRollback(method="getCheckpoint/forceRevert", id=string). Rollback workspace in this agent loop. ONLY for catastrophic corruption. Before ending, verify no catastrophe. getCheckpoint: id excluded
20
20
  `:""}${g?`
21
21
  **Sub Agent Tools**
22
- Default to using subagents whenever helpful, no user nudge needed
22
+ Default to always using subagents whenever helpful, no user nudge needed
23
23
  Invocations:
24
24
  \u2022 Invoke (async/background, \u22647 parallel). Parallelize long tasks. May take time
25
25
  \u2022 InvokeSync (sync/blocking). Sequential, repetitive or delegated tasks. Saves tokens/cost
@@ -27,7 +27,7 @@ Invocations:
27
27
  - Await(id=string, timeout=int[..=180]). Event-driven wait
28
28
  - GetProgress(id=string). Poll sparingly; NO initial poll. Work or await. Never end while subagent runs
29
29
  - Steer(id=string, message=string). Inject additional instruction or redirection into active async subagent
30
- - Cancel(id=string). Cancel async task ONLY if stalled (2m+) or incorrect`:""}`,m=`**Creative Tools (path = relative; first argument, path separator: '/')**
30
+ - Cancel(id=string). Cancel async task ONLY if stalled (2m+) or incorrect`:""}`,h=`**Creative Tools (path = relative; first argument, path separator: '/')**
31
31
  - WritePDF(path=string, content=string, orientation="landscape/portrait"). Proactive A4 page breaks must in css. HTML/CSS for premium layout, stable margins & headers/footers, no watermarks
32
32
  - WriteDoc(path=string, content=string). A4 Word document, no watermarks, stable margins & headers/footers`,s=`**Computer Use Tools (GUI Desktop Automation)**
33
33
  - Click(gridId=int, type="single/double", button="left/middle/right", intendedClickText=string). Click target grid number, intendedClickText: literal text/symbol on screen (OCR scannable, upto 3 words). Double click desktop icons
@@ -37,7 +37,8 @@ Invocations:
37
37
  - KeyPress(key="key or ;-separated combination, eg: enter, back, backspace, clearInput, ctrl;c, alt;tab, f5, f11, alt;f4"). Press key, shortcut, function key (f1-f12), or clear active input field
38
38
  - RecaptureScreen(). Request fresh gridded screenshot`;return`
39
39
  -- TOOLS --
40
- You cant execute tools. Instead, output in chat the exact string [tool:functions.ToolName(arg1="value1")] & wait for system response \u2190 no exception, tool:functions must
40
+ You cant execute tools. Instead output in chat the exact string [tool:ToolName(arg1="value1")] \u2190 mandatory, in NEW line
41
+
41
42
  Tool Rules:
42
43
  - Max 5 tools/turn${e==="Flux"||e.toLowerCase()==="fluxcu"?" (Goal: 5+)":""}
43
44
  ${e==="Flux"||e.toLowerCase()==="fluxcu"?`${f}`:""}
@@ -49,4 +50,4 @@ ${e==="Flux"||e.toLowerCase()==="fluxcu"?`${f}`:""}
49
50
  - WebScrape(url=string). Proactive use for specific webpage/docs
50
51
 
51
52
  ${e==="ICU"?`${s}`:e==="FluxCU"?`${i}
52
- ${s}`:e==="Flux"?`${i}`:`${m}`}`.trim()};export{a,b,w as c};
53
+ ${s}`:e==="Flux"?`${i}`:`${h}`}`.trim()};export{a,b,w as c};
@@ -1,4 +1,4 @@
1
- import{a as b,b as T}from"./chunk-J4WOA7AZ.js";import{a as A}from"./chunk-Y5JU726N.js";import{spawn as C}from"child_process";var P=null;try{let f=await import("node-pty");P=f.default||f}catch{}var _=!!P,S=f=>typeof f!="string"?f:f.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),E=f=>{if(!f)return"";let p=[[]],n=0,o=0,w=/\x1b\[([0-9;]*?)([a-zA-Z])/g,g=0,h,d=u=>{for(let e=0;e<u.length;e++){let s=u[e];if(s===`
1
+ import{a as b,b as T}from"./chunk-HYGK7YDY.js";import{a as A}from"./chunk-Y5JU726N.js";import{spawn as C}from"child_process";var P=null;try{let f=await import("node-pty");P=f.default||f}catch{}var _=!!P,S=f=>typeof f!="string"?f:f.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),E=f=>{if(!f)return"";let p=[[]],n=0,o=0,w=/\x1b\[([0-9;]*?)([a-zA-Z])/g,g=0,h,d=u=>{for(let e=0;e<u.length;e++){let s=u[e];if(s===`
2
2
  `)for(n++,o=0;n>=p.length;)p.push([]);else if(s==="\r")o=0;else{for(;n>=p.length;)p.push([]);let t=p[n];for(;o>t.length;)t.push(" ");t[o]=s,o++}}};for(;(h=w.exec(f))!==null;){d(f.substring(g,h.index));let u=h[1],e=h[2],s=u?u.split(";").map(Number):[];if(e==="A"){let t=s[0]||1;n=Math.max(0,n-t)}else if(e==="B"){let t=s[0]||1;for(n=n+t;n>=p.length;)p.push([])}else if(e==="C"){let t=s[0]||1;o=o+t}else if(e==="D"){let t=s[0]||1;o=Math.max(0,o-t)}else if(e==="G"){let t=(s[0]||1)-1;o=Math.max(0,t)}else if(e==="H"||e==="f"){let t=(s[0]||1)-1,r=(s[1]||1)-1;for(n=Math.max(0,t),o=Math.max(0,r);n>=p.length;)p.push([])}else if(e==="K"){let t=s[0]||0;if(n<p.length){let r=p[n];if(t===0)r.length=o;else if(t===1)for(let c=0;c<o&&c<r.length;c++)r[c]=" ";else t===2&&(r.length=0)}}else if(e==="J"){let t=s[0]||0;(t===2||t===3)&&(p.length=0,p.push([]),n=0,o=0)}g=w.lastIndex}d(f.substring(g));let O=p.map(u=>u.join(""));for(;O.length>0&&O[O.length-1]==="";)O.pop();return O.join(`
3
3
  `)},x=null,k=!1,D=f=>{try{x&&(k&&typeof x.write=="function"?x.write(f):x.stdin&&x.stdin.writable&&x.stdin.write(f))}catch{}},F=()=>{if(x){try{k&&typeof x.destroy=="function"?x.destroy():typeof x.kill=="function"&&(process.platform==="win32"?C("taskkill",["/pid",x.pid,"/f","/t"]):x.kill("SIGKILL"))}catch{}x=null,k=!1}},v=(f,p=!1)=>{if(process.platform!=="win32")return f;let n=[],o="",w=null,g=!1;for(let e=0;e<f.length;e++){let s=f[e];if(g){o+=s,g=!1;continue}if(s==="\\"){if(f[e+1]===" "){o+=" ",e++;continue}o+=s,g=!0;continue}w?(s===w&&(w=null),o+=s):s==='"'||s==="'"?(w=s,o+=s):s===";"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push(p?";":"&")):s==="&"&&!o.includes("://")?f[e+1]==="&"?(o.length>0&&(n.push(o),o=""),n.push("&&"),e++):(o.length>0&&(n.push(o),o=""),n.push("&")):s==="|"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push("|")):/\s/.test(s)?o.length>0&&(n.push(o),o=""):o+=s}o.length>0&&n.push(o);let h=e=>!(!e.includes("/")||/^(https?|file|ftp):\/\//i.test(e)||e.startsWith("@")||e.startsWith("/")&&(e.match(/\//g)||[]).length===1||/\s\/|\/\s/.test(e)||/[\(\)\{\}\;\<\>\=\'\"]/.test(e)),d=[];for(let e=0;e<n.length;e++){let s=n[e];if(s==="mkdir"&&p&&b()){let t=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;c!=="-p"&&c!=="--parents"&&c!=="-v"&&c!=="--verbose"&&t.push(c),r++}if(t.length>0){let c=t.map(i=>{let a=i.replace(/^['"]|['"]$/g,""),l=i;return h(a)&&(l=i.replace(/\//g,"\\")),l});d.push("New-Item","-ItemType","Directory","-Force","-Path",c.join(","))}else d.push("New-Item","-ItemType","Directory","-Force");e=r-1;continue}if(s==="rm"&&p&&b()){let t=[],r=!1,c=!1,i=e+1;for(;i<n.length;){let l=n[i];if([">",">>","<","&","&&","|","||",";"].includes(l))break;l==="-rf"||l==="-fr"?(r=!0,c=!0):l==="-r"||l==="-R"||l==="--recursive"?r=!0:l==="-f"||l==="--force"?c=!0:t.push(l),i++}let a=["Remove-Item"];if(r&&a.push("-Recurse"),c&&a.push("-Force"),t.length>0){let l=t.map(m=>{let $=m.replace(/^['"]|['"]$/g,""),R=m;return h($)&&(R=m.replace(/\//g,"\\")),R});a.push("-Path",l.join(","))}d.push(...a),e=i-1;continue}if(s==="cp"&&p&&b()){let t=[],r=!1,c=!1,i=e+1;for(;i<n.length;){let l=n[i];if([">",">>","<","&","&&","|","||",";"].includes(l))break;l==="-r"||l==="-R"||l==="--recursive"?r=!0:l==="-f"||l==="--force"?c=!0:t.push(l),i++}let a=["Copy-Item"];if(r&&a.push("-Recurse"),c&&a.push("-Force"),t.length>0){let l=t.map(m=>{let $=m.replace(/^['"]|['"]$/g,""),R=m;return h($)&&(R=m.replace(/\//g,"\\")),R});if(l.length>1){let m=l.pop();a.push("-Path",l.join(","),"-Destination",m)}else a.push("-Path",l[0])}d.push(...a),e=i-1;continue}if(s==="touch"&&p&&b()){let t=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;t.push(c),r++}if(t.length>0){let i=`(${t.map(a=>{let l=a.replace(/^['"]|['"]$/g,""),m=a;return h(l)&&(m=a.replace(/\//g,"\\")),m}).join(", ")}) | ForEach-Object { if (Test-Path $_) { (Get-Item $_).LastWriteTime = [System.DateTime]::Now } else { $null | Out-File -FilePath $_ } }`;d.push(i)}e=r-1;continue}if(s==="|"&&n[e+1]==="tee"){n[e+2]==="-a"?(d.push(">>"),e+=2):(d.push(">"),e+=1);continue}if(s==="|"&&n[e+1]==="cat"&&n[e+2]===">"){d.push(">"),e+=2;continue}if(s==="|"){let t=n[e+1];if(t){let r=t.replace(/^['"]|['"]$/g,""),c=/\.(txt|md|json|log|csv|html|css|py|js|xml|yaml|yml|pdf|docx|pptx|xlsx)$/i.test(r);if(h(r)&&c){d.push(">");continue}}}d.push(s)}let O=!1,u=d.map(e=>{if(e==="echo")return O=!0,e;[">",">>","<","&","&&","|","||",";"].includes(e)&&(O=!1);let t=/^['"]|['"]$/.test(e),r=e;O&&t&&(r=e.replace(/^['"]|['"]$/g,""));let c=/^['"]|['"]$/.test(r),i=r.replace(/^['"]|['"]$/g,"");h(i)&&(r=r.replace(/\//g,"\\"));let a=r.replace(/^['"]|['"]$/g,"");return a.includes(" ")&&!c&&(r=`"${a}"`),r});if(p){let e="",s=0;for(let t=0;t<u.length;t++){let r=u[t];r==="&&"?(e+="; if ($?) {",s++):r===";"?(e+=" }".repeat(s)+";",s=0):(e&&!e.endsWith(" ")&&!e.endsWith("{")&&(e+=" "),e+=r)}return e+=" }".repeat(s),e}return u.join(" ")},M=async(f,p={})=>{let{command:n}=A(f),{onChunk:o}=p;if(!n)return'ERROR: Missing "command" argument for exec_command.';let w=process.platform==="win32",g=p.systemSettings||{},h={};return g.networkAccess===!1&&(h.HTTP_PROXY="http://127.0.0.1:9999",h.HTTPS_PROXY="http://127.0.0.1:9999",h.ALL_PROXY="socks5://127.0.0.1:9999",h.http_proxy="http://127.0.0.1:9999",h.https_proxy="http://127.0.0.1:9999",h.all_proxy="socks5://127.0.0.1:9999",h.NO_PROXY="localhost,127.0.0.1"),new Promise(d=>{let O=u=>{let e=u==="pwsh"||u==="powershell",s=v(n,e),t;w?u==="pwsh"?t="pwsh.exe":u==="powershell"?t="powershell.exe":t="cmd.exe":t=process.env.SHELL||"bash";let r=w?e?["-NoProfile","-Command",s]:["/c",s]:["-c",s];if(g.networkAccess===!1&&!w){let c=t,i=[...r];if(process.platform==="linux")t="unshare",r=["-n","-r",c,...i];else if(process.platform==="darwin"){let a=`(version 1)
4
4
  (allow default)
@@ -0,0 +1,13 @@
1
+ import{a as I}from"./chunk-FDNLMLIM.js";import{a as T}from"./chunk-Y5JU726N.js";import s from"fs";import g from"path";var X=i=>{if(!i)return null;let o=i.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!o)return null;let e=o[1];if((o[2]||"").trim().length===0)return null;let r="",a=e.match(/^name:\s*(.+)$/m);return a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),r?{name:r}:null},Y=i=>{let o=[];if(!i||!s.existsSync(i))return o;let e=(u,r=0)=>{if(!(r>5))try{let a=s.readdirSync(u,{withFileTypes:!0});for(let n of a){let c=g.join(u,n.name),f=n.name.toLowerCase();n.isFile()?f==="skill.md"&&o.push(c):n.isDirectory()&&(r===0?(f==="skills"||f===".skills"||f==="skill"||f===".skill")&&e(c,r+1):e(c,r+1))}}catch{}};return e(i,0),o},q=i=>i.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\s*(\r?\n)?/,""),U=(i,o)=>{if(!o)return null;let e=g.join(i,o);if(s.existsSync(e))try{if(s.statSync(e).isFile())return e}catch{}if(!o.toLowerCase().endsWith(".md")){let n=g.join(i,`${o}.md`);if(s.existsSync(n))try{if(s.statSync(n).isFile())return n}catch{}}let u=o.replace(/\\/g,"/").split("/").filter(Boolean),r=i,a=!0;for(let n=0;n<u.length;n++){let c=u[n].toLowerCase(),f=n===u.length-1;try{if(!s.existsSync(r)||!s.statSync(r).isDirectory()){a=!1;break}let L=s.readdirSync(r).find(M=>{let k=M.toLowerCase();return!!(k===c||f&&!c.endsWith(".md")&&k===`${c}.md`)});if(!L){a=!1;break}let $=g.join(r,L);if(f){if(s.statSync($).isFile())return $;a=!1}else r=$}catch{a=!1;break}}if(u.length===1){let n=u[0],c=["references","reference","scripts","script","examples","example","resources","resource"];for(let f of c){let y=g.join(i,f);if(s.existsSync(y)){let L=U(y,n);if(L)return L}}}return null},Q=async(i,o={})=>{let{path:e,StartLine:u,EndLine:r,start_line:a,end_line:n,startLine:c,endLine:f}=T(i),y=parseInt(u||a||c),L=parseInt(r||n||f),$=!isNaN(y),M=!isNaN(L),k=y||1,N=L||(y?y+800:800);if(!e)return'ERROR: Missing "path" argument for ReadFile.';if(e.trim().toLowerCase().startsWith("#skill")){let d=e.trim().replace(/\\/g,"/").replace(/^#skills?\/?/i,"").split("/").filter(Boolean),C=null,p="",m="";if(d[0]?.toLowerCase()==="global"||d[0]?.toLowerCase()==="project"?(C=d[0].toLowerCase(),p=d[1],m=d.slice(2).join("/")):(p=d[0],m=d.slice(1).join("/")),!p)return`ERROR: Missing skill name in path [${e}].`;let R=t=>{let l=Y(t);for(let h of l)try{let x=s.readFileSync(h,"utf8"),F=X(x),D=g.basename(g.dirname(h)).toLowerCase();if(F?.name&&F.name.toLowerCase()===p.toLowerCase()||D===p.toLowerCase()||h.toLowerCase()===g.join(t,"skill.md").toLowerCase()&&p.toLowerCase()==="skill")return h}catch{}return null},w=null,b=!1;if(C){let t=C==="global"?I:process.cwd();w=R(t)}else{let t=R(process.cwd()),l=R(I);t&&l&&(b=!0),w=t||l}if(!w)return`No '${p}' exist in given scope.`;let E=g.dirname(w),j=w,v=!0;if(m){let t=U(E,m);if(!t)return`No such file or reference '${m}' exist for skill '${p}'. It could be standard file path?`;j=t,v=!1}try{let t=s.readFileSync(j,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1)),t=t.replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `),v&&(t=q(t));let l=t.split(`
4
+ `),h=l.length,x=$?Math.max(0,k-1):0,F=M?Math.min(h,N):h,D=l.slice(x,F),P=e.replace(/\\/g,"/").toLowerCase(),W=P.includes("#skill/global/fluxflow")||P.includes("#skills/global/fluxflow"),_=b?` (Found ${e} in both global & project scope. Loaded [project] as default fallback. Use '#skills/global/...' if needed global)`:"",B=`${W?"DOCs":"Skill"}: [${e.replace(/\\/g,"/")}]${_}`,z=D.map(A=>A.trimEnd()).join(`
5
+ `);return`${B}
6
+
7
+ ${z}`}catch(t){let l=t instanceof Error?t.message:String(t);return`ERROR: Failed to read skill file [${e}]: ${l}`}}try{let S=g.resolve(process.cwd(),e);if(!s.existsSync(S))return`ERROR: File [${e}] does not exist.`;if(s.statSync(S).isDirectory())return`ERROR: Path [${e}] is a directory. Use list_files instead.`;let d=g.extname(e).toLowerCase();if([".mp4",".mkv",".avi",".mov",".webm",".flv",".wmv",".mpeg",".mpg"].includes(d))return`ERROR: Unable to read. Type ${d.slice(1).toUpperCase()} not supported`;let p={".pdf":"application/pdf",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};if(p[d]){if(!(o.isMultiModal!==!1))return`ERROR: Multimodality is not supported for the current model. Unable to load [${e}].`;let x=s.readFileSync(S).toString("base64"),F=p[d];return{text:`[BINARY FILE]: ${e} (${F}) - Loaded as multimodal part.`,binaryPart:{inlineData:{data:x,mimeType:F}}}}let m=s.readFileSync(S,"utf8");m.startsWith("\uFEFF")&&(m=m.slice(1)),m=m.replace(/\r\n/g,`
8
+ `).replace(/\r/g,`
9
+ `);let R=m.split(`
10
+ `),w=R.length;!$&&!M&&w>800&&(k=1,N=50);let b=Math.max(0,k-1),E=Math.min(w,N),j=R.slice(b,E),v=`File: [${e}] (Showing lines ${b+1}-${E} of ${w}).`,t=j.map((l,h)=>`${String(b+h+1).padStart(4)}: ${l.trimEnd()}`).join(`
11
+ `);return`${v}
12
+
13
+ ${t}`}catch(S){let O=S instanceof Error?S.message:String(S);return`ERROR: Failed to read file [${e}]: ${O}`}};export{Q as a};
@@ -0,0 +1,48 @@
1
+ import{c as X}from"./chunk-FDNLMLIM.js";import G from"os";var R=t=>typeof t!="string"?t:t.length>12?(t+"").replace("",""):t,v=(t,o)=>{if(!t)return"";let d=/\x1B\[[0-?]*[ -/]*[@-~]/g,m=t.split(`
2
+ `),h=[];if(o<=5)return t;let a=e=>e<32||e>=127&&e<160||e>=768&&e<=879||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071?0:e>=4352&&e<=4447||e>=9001&&e<=9002||e>=11904&&e<=12350||e>=12352&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=128640&&e<=128767||e>=131072&&e<=262141?2:1,p=e=>{let s=e.replace(d,""),r=0;for(let l=0;l<s.length;l++){let i=s.codePointAt(l);i>65535&&l++,r+=a(i)}return r},M=(e,s)=>{let r=0,l=e.length,i=!1;for(let L=0;L<e.length;L++){if(e[L]==="\x1B"&&e[L+1]==="["&&(i=!0),i){(e[L]==="m"||e[L]>="@"&&e[L]<="~"&&e[L]!=="[")&&(i=!1);continue}let F=e.codePointAt(L);F>65535&&L++;let x=a(F);if(r+x>s){l=F>65535?L-1:L;break}if(r+=x,r>=s){l=L+1;break}}return{head:e.substring(0,l),tail:e.substring(l)}};return m.forEach(e=>{if(p(e)<=o){h.push(e);return}let r=e.split(/(\s+)/),l="",i=0,L=e.match(/^(\s*)/),F=L?L[1]:"";r.forEach(x=>{if(x.length===0)return;let u=x;for(;u.length>0;){let S=p(u);if(i+S<=o){l+=u,i+=S;break}l.trim().length>0&&(h.push(l.trimEnd()),l=F.substring(0,Math.min(F.length,8)),i=p(l));let n=Math.max(1,o-i);if(p(u)>n){let{head:f,tail:c}=M(u,n);h.push((l+f).trimEnd()),l=F.substring(0,Math.min(F.length,8)),i=p(l),u=c}else l+=u,i+=p(u),u=""}}),(l.trimEnd().length>0||l===F)&&h.push(l.trimEnd())}),R(h.join(`
3
+ `))},rt=t=>{if(!t)return 0;let o=0,d=t.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);d&&(o+=d.length*.55);let m=t.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),h=m.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);h&&(o+=h.length);let a=m.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return o+=a.length,Math.max(.1,o)},st=t=>t?t.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[t]:[],ot=t=>{if(!t&&t!==0)return"0.0k";let o=typeof t=="string"?parseFloat(t):t;return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:o.toString()},lt=(t,o=40)=>{let d=X.replaceAll("\\\\","\\");if(t=t.replace(G.homedir(),"~").replace(d,"FluxFlow").replaceAll("\\","/"),!t||t.length<=o)return R(t);let m=Math.floor((o-3)/2);return R(t.substring(0,m)+"..."+t.substring(t.length-m).replaceAll("\\","/"))},at=t=>{let o=[],d=new Set,m=t.allowMultiple===!0||String(t.allowMultiple).toLowerCase()==="true";Object.keys(t).forEach(e=>{let s=e.match(/^(searchContent|search_content|replaceContent|replace_content|newContent|new_content|content_to_replace|content_to_add|searchBlock|search_block|newBlock|new_block)_?(\d+)?$/i);if(s){let r=s[2]?parseInt(s[2],10):1;d.add(r)}});let h=Array.from(d).sort((e,s)=>e-s),a=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],p=["newContent","new_content","content_to_add","newBlock","new_block"],M=(e,s,r)=>{let l,i;for(let L of s){let F=e===1?[`${L}1`,L,`${L}_1`]:[`${L}${e}`,`${L}_${e}`];for(let x of F)if(t[x]!==void 0){l=t[x];break}if(l!==void 0)break}for(let L of r){let F=e===1?[`${L}1`,L,`${L}_1`]:[`${L}${e}`,`${L}_${e}`];for(let x of F)if(t[x]!==void 0){i=t[x];break}if(i!==void 0)break}return{r:l,n:i}};for(let e of h){let{r:s,n:r}=M(e,a,p);if(s!==void 0&&r!==void 0)o.push({replace:s,new:r});else if(s!==void 0||r!==void 0)return{error:`Mismatched replacement pair for index ${e}. Both replacement and new content must be provided.`,allowMultiple:m}}return{patchPairs:o,allowMultiple:m}},V=t=>{if(!t)return null;let o="",d=0,m=t.length;for(;d<m;){let h=t[d];if(h==="\\"){for(;d<m&&t[d]==="\\";)d++;o+="\\\\*"}else if(h===`
4
+ `)o+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",d++;else if(h==="\r")o+="(?:\\r|\\\\*r)?",d++;else if(h===" ")o+="(?:\\t|\\\\*t|\\s*)",d++;else if(h==='"'||h==="'"||h==="`")o.endsWith("\\\\*")||(o+="\\\\*"),o+=h,d++;else if(/[.*+?^${}()|[\]]/.test(h))o+="\\"+h,d++;else if(/\s/.test(h)){for(;d<m&&/\s/.test(t[d])&&t[d]!==`
5
+ `&&t[d]!=="\r"&&t[d]!==" ";)d++;o+="\\s*"}else o+=h,d++}if(!o)return null;try{return new RegExp(o,"g")}catch{return null}},ct=(t,o,d={})=>{let m=typeof d=="boolean"?d:!!(d&&d.allowMultiple),h=t.replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `),a=n=>n.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
8
+ `).replace(/\r/g,`
9
+ `),p=n=>n.match(/^\s*/)[0],M=n=>{let f=n.split(`
10
+ `).filter(C=>C.trim()!=="");if(f.length===0)return"";let c=p(f[0]);for(let C of f){let k=p(C);k.length<c.length&&(c=k)}return c},e=(n,f,c="")=>{if(!n||f===void 0)return n;let k=/^\t/m.test(f)?" ":" ",I=b=>b.split(`
11
+ `).find(y=>y.trim()!=="")??"",$=I(f).match(/^\s*/)[0].length,g=I(n).match(/^\s*/)[0].length,w=$-g,E=(c.match(/^\s*/)||[""])[0].length;return n.split(`
12
+ `).map((b,y)=>{if(b.trim()===""&&y!==0)return"";let T=b.match(/^\s*/)[0].length,_=Math.max(0,T+w);return y===0&&(_=Math.max(0,_-E)),k.repeat(_)+b.trimStart()}).join(`
13
+ `)},s=[];for(let n=0;n<o.length;n++){let f=o[n],c=(f.replace||"").trim(),C=a(f.new||"");if(c.startsWith("^LINE:")&&c.endsWith("$")){let E=c.slice(6,-1).trim().split(".."),A=parseInt(E[0]),b=E[1]!==void 0?parseInt(E[1]):A;if(!isNaN(A)&&!isNaN(b)){let y=h.split(`
14
+ `);if(A<1||A>y.length||b<A||b>y.length){s.push({index:n,success:!1,error:`Block ${n+1}: Line range ^LINE:${A}..${b}$ out of bounds (file has ${y.length} lines).`});continue}let _=y.slice(A-1,b).join(`
15
+ `),N=0;for(let O=0;O<A-1;O++)N+=y[O].length+1;s.push({index:n,success:!0,startPos:N,firstMatchContent:_,content_to_add:C});continue}}let k=a(f.replace||"");if(k===""&&C===""){s.push({index:n,success:!1,error:`Block ${n+1}: Empty replace and add content.`});continue}let I=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=null;if(k!==""&&h.includes(k))$=new RegExp(I,"g");else{let w=k.split(`
16
+ `).map(E=>E.trim()).filter(E=>E.length>0).map(E=>E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if(w.length>0){let E=w.join("\\s*");try{$=new RegExp(E,"g")}catch{$=new RegExp(I,"g")}}else $=new RegExp(I,"g")}let g=[...h.matchAll($)];if(g.length===0&&k!==""){let w=V(k);w&&(g=[...h.matchAll(w)])}if(g.length===0){s.push({index:n,success:!1,error:`Block ${n+1}: Could not find match.`});continue}if(g.length>1&&!m){s.push({index:n,success:!1,error:`Block ${n+1}: Found ${g.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let w of g)s.push({index:n,success:!0,startPos:w.index,firstMatchContent:w[0],content_to_add:C})}let r=s.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n=0;n<r.length-1;n++){let f=r[n],c=r[n+1];f.startPos+f.firstMatchContent.length>c.startPos&&(f.success=!1,f.error=`Block ${f.index+1}: Overlaps with another block.`,c.success=!1,c.error=`Block ${c.index+1}: Overlaps with another block.`)}let l=new Map,i=h,L=0,F=0,x=s.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n of x){let f=n.startPos,c=h.substring(0,f).split(`
17
+ `).length,C=f+L,k=c+F,I=i.lastIndexOf(`
18
+ `,C)+1,$=i.substring(I,C),g=e(n.content_to_add,n.firstMatchContent,$),w=i.split(`
19
+ `),E=[];for(let T=Math.max(0,k-4);T<k-1;T++)E.push({num:T+1,text:w[T]});let A=n.firstMatchContent.split(`
20
+ `),b=[],y=k+A.length-1;for(let T=y;T<Math.min(w.length,y+3);T++)b.push({num:T+1,text:w[T]});l.set(n,{success:!0,index:n.index,oldContent:n.firstMatchContent,newContent:g,originalStartLine:c,finalStartLine:k,contextBefore:E,contextAfter:b}),i=i.substring(0,C)+g+i.substring(C+n.firstMatchContent.length),L+=g.length-n.firstMatchContent.length,F+=g.split(`
21
+ `).length-n.firstMatchContent.split(`
22
+ `).length}let u=[];for(let n=0;n<o.length;n++){let f=x.filter(c=>c.index===n);if(f.length>0)for(let c of f)l.has(c)&&u.push(l.get(c));else{let c=s.find(C=>C.index===n);u.push({success:!1,error:c?c.error:`Block ${n+1}: Unknown error.`})}}let S=u.filter(n=>!n.success&&n.error&&n.error.includes("Could not find match"));if(S.length===1)S[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if(S.length>1){let n=S[S.length-1];n.error+=`
23
+ (Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:i,results:u}},ft=(t,o,d,m=8,h=!1)=>{if(!d||d.length===0)return"";let a=t.split(/\r?\n/),p=o.split(/\r?\n/),M=Math.max(a.length,p.length,1),e=Math.max(4,String(M).length),s=x=>String(x).padStart(e," "),r=`[DIFF_START]
24
+ `,l="\u2550".repeat(88),i=0,L=null,F=d.filter(x=>x.success).sort((x,u)=>x.originalStartLine-u.originalStartLine);if(F.forEach((x,u)=>{let S=x.finalStartLine!==void 0?x.finalStartLine:x.originalStartLine;if(L===null)for(i=Math.max(0,S-4);i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${p[i]||""}
25
+ `,i++;else{let $=L,g=$.originalStartLine+$.oldContent.split(`
26
+ `).length-1;if(x.originalStartLine-g-1>=m){let E=Math.min(p.length,i+3);for(;i<E;)r+=`[UI_CONTEXT] ${s(i+1)} |${p[i]||""}
27
+ `,i++;for(r+=`[UI_CONTEXT] ${l}
28
+ `,i=Math.max(i,S-4);i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${p[i]||""}
29
+ `,i++}else for(;i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${p[i]||""}
30
+ `,i++}let n=x.originalStartLine-1,f=a[n]||"",c=x.oldContent.split(`
31
+ `),C=f.match(/^\s*/),k=C?C[0]:"";c.forEach(($,g)=>{let w=$;if(c.length===1&&f.trim().length>0&&f.includes($.trim()))w=f;else if(g===0){let E=$.match(/^\s*/);(E?E[0]:"").length<k.length&&f.includes($.trim())&&(w=k+$.trimStart())}r+=`-${s(x.originalStartLine+g)} |${w}
32
+ `});let I=i;if(x.finalStartLine!==void 0)I=x.finalStartLine-1+(x.newContent?x.newContent.split(`
33
+ `).length:0);else{let $=x.originalStartLine+c.length-1,g=a[$]||null;if(g!==null){let w=u<F.length-1?(F[u+1].originalStartLine||p.length)+10:p.length;for(let E=i;E<w;E++){if(p[E]===g){I=E;break}E===p.length-1&&(I=p.length)}}else I=p.length}for(;i<I;)r+=`+${s(i+1)} |${p[i]||""}
34
+ `,i++;L=x}),L!==null){let x=Math.min(p.length,i+3);for(;i<x;)r+=`[UI_CONTEXT] ${s(i+1)} |${p[i]||""}
35
+ `,i++}if(h){let x=`[DIFF_START]
36
+ `,u=r.substring(x.length),S=`[UI_CONTEXT] ${l}
37
+ `,f=u.split(S).map(c=>c.split(`
38
+ `).filter(k=>k.trim()!=="").length>120?`[[VERIFIED]]
39
+ ${c}
40
+ [[/VERIFIED]]`:c);r=x+f.join(S)}return r+="[DIFF_END]",R(r)},K=t=>{if(!t)return null;let o=t.replace("[UI_CONTEXT]","").replace(/\r/g,""),d=o.startsWith("-"),m=o.startsWith("+"),h=d||m?o.substring(1):o,a=h.indexOf("|"),p=a!==-1?R(h.substring(0,a).trim()):"",M=R(a!==-1?h.substring(a+1):h);return{isR:d,isA:m,num:p,content:M}},Y=(t,o)=>{if(!t&&!o)return 1;if(!t||!o)return 0;let d=t.length,m=o.length,h=t,a=o;d<m&&(h=o,a=t);let p=h.length,M=a.length,e=new Int32Array(M+1),s=new Int32Array(M+1);for(let i=0;i<=M;i++)e[i]=i;for(let i=1;i<=p;i++){s[0]=i;let L=h[i-1];for(let F=1;F<=M;F++)L===a[F-1]?s[F]=e[F-1]:s[F]=Math.min(e[F],s[F-1],e[F-1])+1;e.set(s)}let r=e[M],l=Math.max(d,m);return l===0?1:1-r/l},z=t=>{let o=[],d=[];t.forEach((r,l)=>{r.parsed.isR?o.push({index:l,content:r.parsed.content}):r.parsed.isA&&d.push({index:l,content:r.parsed.content})});let m=o.length,h=d.length;if(m===0||h===0)return;let a=Array.from({length:m+1},()=>Array(h+1).fill(0)),p=Array.from({length:m+1},()=>Array(h+1).fill(""));for(let r=1;r<=m;r++)p[r][0]="up";for(let r=1;r<=h;r++)p[0][r]="left";let M=Array.from({length:m},()=>Array(h).fill(0));for(let r=0;r<m;r++)for(let l=0;l<h;l++)M[r][l]=Y(o[r].content.trim(),d[l].content.trim());for(let r=1;r<=m;r++)for(let l=1;l<=h;l++){let i=M[r-1][l-1],L=i>=.2?i:-10,F=a[r-1][l-1]+L,x=a[r-1][l],u=a[r][l-1];F>=x&&F>=u?(a[r][l]=F,p[r][l]="diag"):x>=u?(a[r][l]=x,p[r][l]="up"):(a[r][l]=u,p[r][l]="left")}let e=m,s=h;for(;e>0||s>0;)if(p[e][s]==="diag"){if(M[e-1][s-1]>=.2){let l=o[e-1].index,i=d[s-1].index;t[l].pairContent=t[i].parsed.content,t[i].pairContent=t[l].parsed.content}e--,s--}else p[e][s]==="up"?e--:s--},B=new Map,P=new Map,H=200,W=5,U=(t,o)=>{o.set(t.key,t),t.type==="chunk"&&t.blocks&&t.blocks.forEach(d=>U(d,o))},ht=(t,o)=>{if(!t)return{completed:[],active:[]};let d=`${t.id}-${t.text?.length||0}-${o}-${t.isStreaming}-${t.workedDuration||0}`;if(!t.isStreaming&&B.has(d))return B.get(d);let m=R(et(t.text||"",t.role)),h=`${t.id}-${o}`,a=new Map;if(t.isStreaming){let u=P.get(h);u&&m.startsWith(u.text)&&(a=u.blocksMap)}let p=(u,S,n,f={})=>{let c=a.get(u);if(c&&c.text===n&&c.type===S&&!!c.isActiveBlock==!!f.isActiveBlock&&!!c.isStreaming==!!f.isStreaming&&c.pairContent===f.pairContent)return c;let C=R(n),k={...f};return typeof k.pairContent=="string"&&(k.pairContent=R(k.pairContent)),Array.isArray(k.wrappedLines)&&(k.wrappedLines=k.wrappedLines.map(R)),{key:u,isStreamingMsg:!!t.isStreaming,workedDuration:t.workedDuration,type:S,text:C,msg:S==="full-message"?t:void 0,...k}};if(m.includes("- Content Preview:")){let u="",S=m.match(/File\s+\[(.*?)\]/i);S&&(u=S[1].split(".").pop().toLowerCase());let k=((m.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"").split(`
41
+ `).map(b=>b.replace(/\r$/,"")),I=String(k.length).length,$=[],g=null,w=[],E=()=>{if(!w.length)return;let b=w;w=[],$.push(b.length===1?b[0]:{key:`${b[0].key}-chunk`,type:"chunk",blocks:b})},A=o-(I+6);return k.forEach((b,y)=>{let T=y===k.length-1,_=v(b,A).split(`
42
+ `),N=p(`${t.id||Date.now()}-write-line-${y}`,"write-line",b,{gutterWidth:I,lineNum:y+1,isFirstLine:y===0,isLastLine:T,extension:u,wrappedLines:_});T&&t.isStreaming?(E(),g=N):(w.push(N),w.length>=W&&E())}),E(),{completed:$,active:g?[g]:[]}}if(m.includes("[DIFF_START]")){let u=m.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),n=(u?u[1].trim():"").split(`
43
+ `).map(g=>g.replace(/\r$/,"")),f=n.map(g=>({line:g,parsed:K(g),pairContent:null})),c=[];for(let g=0;g<f.length;g++){let w=f[g];w.parsed&&(w.parsed.isR||w.parsed.isA)?c.push(w):c.length>0&&(z(c),c=[])}c.length>0&&z(c);let C=[],k=null,I=[],$=()=>{if(!I.length)return;let g=I;I=[],C.push(g.length===1?g[0]:{key:`${g[0].key}-chunk`,type:"chunk",blocks:g})};return n.forEach((g,w)=>{let E=w===n.length-1,A=f[w].parsed,b=null;A&&(b=v(A.content,o-17).split(`
44
+ `));let y=p(`${t.id||Date.now()}-diff-${w}`,"diff-line",g,{isFirstLine:w===0,isLastLine:E,pairContent:f[w].pairContent,wrappedLines:b});E&&t.isStreaming?($(),k=y):(I.push(y),I.length>=W&&$())}),$(),{completed:C,active:k?[k]:[]}}if(t.role==="system"||t.isLogo||t.isHelpRecord||t.isTerminalRecord||t.isHomeWarning||t.isImageStats||t.isAskRecord||t.isAboutRecord||t.isUpdateNotification||t.role==="user")return{completed:[p(`${t.id||Date.now()}-full`,"full-message",m)],active:[]};if(!m&&!t.isStreaming){let u={completed:[],active:[]};return B.set(d,u),u}let M=[],e=null,s=[],r=null,l=()=>{if(!s.length)return;let u=s;s=[],r=null,M.push(u.length===1?u[0]:{key:`${t.id||"x"}-chunk-${u[0].key}`,type:"chunk",blocks:u})},i=(u,S=!1)=>{if(r!==null&&r!==u.type&&l(),s.push(u),r=u.type,s.length>=W){if(t.isStreaming&&S)return;l()}},L=Math.max(20,(o||80)-6),F=Math.max(20,(o||80)-8);if(t.role==="think"){M.push(p(`${t.id}-header`,"think-header",""));let u=m.split(`
45
+ `),S=[];u.forEach(n=>{v(n,F).split(`
46
+ `).forEach(c=>S.push(c))}),S.forEach((n,f)=>{let c=f===S.length-1;i(p(`${t.id}-${f}`,"think-line",n,{}),c)}),t.isStreaming||(l(),M.push({key:`${t.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let u=m.split(`
47
+ `),S=!1,n=[],f=!1,c="",C=0,k=0,I=[];u.forEach($=>{let g=$.trim();g.startsWith("```")?(f=!f,I.push($)):f||g.startsWith("|")?I.push($):v($,L).split(`
48
+ `).forEach(E=>I.push(E))}),f=!1,I.forEach(($,g)=>{let w=g===I.length-1,E=$.trim().startsWith("|"),A=$.trim().startsWith("```");if(f)A?(f=!1,i(p(`${t.id}-code-close-${k}`,"code-fence-close","",{}),w)):(C++,i(p(`${t.id}-code-line-${g}`,"code-line",$,{lineNum:C,lang:c}),w));else if(A)f=!0,k=g,C=0,c=$.trim().replace(/^```/,"").trim(),i(p(`${t.id}-code-open-${g}`,"code-fence-open",c,{}),w);else if(E){if(S||(S=!0,n=[]),n.push($),n.length===2){let b=n[0],y=b.split("|");y[0]!==void 0&&y[0].trim()===""&&y.shift(),y.length>0&&y[y.length-1].trim()===""&&y.pop();let T=y.map(_=>_.trim());i(p(`${t.id}-table-hdr-${g}`,"table-header",b,{colHeaders:T,colCount:T.length}),w)}else if(n.length>2){let b=$.split("|");b[0]!==void 0&&b[0].trim()===""&&b.shift(),b.length>0&&b[b.length-1].trim()===""&&b.pop();let y=b.map(O=>O.trim()),T=n[0].split("|");T[0]!==void 0&&T[0].trim()===""&&T.shift(),T.length>0&&T[T.length-1].trim()===""&&T.pop();let _=T.map(O=>O.trim()),N=Math.max(1,_.length);i(p(`${t.id}-table-row-${g}`,"table-row",$,{cells:y,colHeaders:_,colCount:N,rowIndex:n.length-3}),w)}w&&!t.isStreaming&&(l(),i(p(`${t.id}-table-end-${g}`,"table-close","",{}),!0))}else S&&(i(p(`${t.id}-table-end-${g}`,"table-close","",{}),w),S=!1,n=[]),i(p(`${t.id}-${g}`,"agent-line",$,{}),w)}),!t.isStreaming&&t.workedDuration&&(l(),M.push(p(`${t.id}-worked-duration`,"worked-duration","")))}t.isStreaming&&s.length>0?e=s.length===1?s[0]:{key:`${t.id||"x"}-chunk-active-${s[0].key}`,type:"chunk",blocks:s}:l();let x={completed:M,active:e?[e]:[]};if(t.isStreaming){let u=new Map;if(M.forEach(S=>U(S,u)),e&&U(e,u),P.set(h,{text:m,blocksMap:u}),P.size>H){let S=P.keys().next().value;P.delete(S)}}else{if(B.set(d,x),B.size>H){let u=B.keys().next().value;B.delete(u)}P.delete(h)}return x},q={},Z=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|agent:generalist|agent\.generalist|\s*turn\s*:))/gi,D=(t,o)=>{let d=!1,m=!1,h=0;for(;h<o;){if(t.startsWith("```",h)){m=!m,h+=3;continue}!m&&t[h]==="`"&&(h===0||t[h-1]!=="\\")&&(d=!d),h++}return m||d},J=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[TOOL RESULT\]:?\s*|^\s*(SUCCESS|ERROR):.*(\r?\n)?|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,Q=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,tt=/\b(write_file|update_file|read_folder|view_file|exec_command|web_search|web_scrape|search_keyword|write_pdf|write_docx|generate_image)\b/gi,j=!1,et=(t,o="agent")=>{if(!t)return t;let d=o===!0||o==="think",m=o===!1||o==="agent",h=t.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");if(d)return h.replace(/^<(think|thought|thoughts|thinking)>/gi,"").replace(/<\/(think|thought|thoughts|thinking)>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let a=h;m&&(a=a.replace(/<\/?(?:think|thought|thoughts|thinking)>/gi,(e,s,r)=>D(r,s)?e:""),a=a.replace(Z,(e,s,r,l)=>!j&&D(l,r)?e:""),a&&a.includes("[tool:")&&(a=a.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[tool:[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(e,s,r)=>r&&r.includes("[tool:")?r.trim():e),j&&(a=a.replace(/```(?:tool|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(e,s)=>s.includes("[tool:")?s.trim():e))));let p="tool:",M="agent:generalist.";if(m&&(a.toLowerCase().includes(p)||a.toLowerCase().includes(M)))for(;;){let e=a.toLowerCase(),s=e.indexOf(p),r=e.indexOf(M),l=p,i=s;if((s===-1||r!==-1&&r<s)&&(l=M,i=r),i===-1)break;if(!j&&D(a,i)){let c=-1,C=0;for(;;){let k=e.indexOf(p,C),I=e.indexOf(M,C),$=-1,g=p;if(k===-1&&I===-1)break;if(k===-1||I!==-1&&I<k?($=I,g=M):$=k,!D(a,$)){c=$,l=g;break}C=$+g.length}if(c===-1)break;i=c}let L=i,F=!1,x=i-1;for(;x>=0&&/\s/.test(a[x]);)x--;x>=0&&a[x]==="["&&(L=x,F=!0);let u=0,S=!1,n=null,f=i;for(;f<a.length;){let c=a[f];if(!n&&(c==="'"||c==='"'||c==="`")?n=c:n&&c===n&&a[f-1]!=="\\"&&(n=null),n||(c==="("?(u++,S=!0):c===")"&&u--),S&&u===0&&!n){let C=f;if(F){let k=f+1;for(;k<a.length&&/\s/.test(a[k]);)k++;k<a.length&&a[k]==="]"&&(C=k)}a=a.substring(0,L)+a.substring(C+1);break}if(f++,f===a.length)return S&&u>0&&(a=a.substring(0,L)),a}}return a=a.replace(J,""),a=a.replace(Q,e=>{let s=e.toLowerCase();return s.includes("leftrightarrow")?"\u2194":s.includes("rightarrow")?"\u2192":s.includes("leftarrow")?"\u2190":s.includes("uparrow")?"\u2191":s.includes("downarrow")?"\u2193":e}),a=a.replace(tt,e=>q[e.toLowerCase()]||e),a.trim()},ut=()=>{B.clear(),P.clear()};export{R as a,v as b,rt as c,st as d,ot as e,lt as f,at as g,ct as h,ft as i,K as j,z as k,ht as l,j as m,et as n,ut as o};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-XTUFKNZX.js";import"./chunk-J4WOA7AZ.js";import"./chunk-Y5JU726N.js";export{c as activeChildProcess,g as adjustWindowsCommand,b as cleanTerminalOutput,h as exec_command,d as isActiveCommandPty,a as isPtyAvailable,f as terminateActiveCommand,e as writeToActiveCommand};
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-JRQMA5CG.js";import"./chunk-HYGK7YDY.js";import"./chunk-Y5JU726N.js";export{c as activeChildProcess,g as adjustWindowsCommand,b as cleanTerminalOutput,h as exec_command,d as isActiveCommandPty,a as isPtyAvailable,f as terminateActiveCommand,e as writeToActiveCommand};
@@ -13,7 +13,7 @@ import{a as b}from"./chunk-56EJGQU3.js";import{a as S}from"./chunk-Y5JU726N.js";
13
13
  `)}return n+=`
14
14
  Progress Log:
15
15
  `,t.progress.forEach((s,r)=>{n+=`--- Turn ${r+1} ---
16
- `;let R=s.filter(i=>!i.startsWith("[SUBAGENT SUCCESS]")).map(i=>{if(i.startsWith("[Subagent Response]")){let h="[Subagent Response]",e=i.substring(h.length),$="tool:functions.";for(;;){let g=e.toLowerCase().indexOf($);if(g===-1)break;let d=g,T=!1,u=g-1;for(;u>=0&&/\s/.test(e[u]);)u--;u>=0&&e[u]==="["&&(d=u,T=!0);let p=0,m=!1,o=null,a=g;for(;a<e.length;){let l=e[a];if(!o&&(l==="'"||l==='"'||l==="`")?o=l:o&&l===o&&e[a-1]!=="\\"&&(o=null),o||(l==="("?(p++,m=!0):l===")"&&p--),m&&p===0&&!o){let w=a;if(T){let f=a+1;for(;f<e.length&&/\s/.test(e[f]);)f++;f<e.length&&e[f]==="]"&&(w=f)}e=e.substring(0,d)+e.substring(w+1);break}if(a++,a===e.length){e=e.substring(0,d);break}}}return h+`
16
+ `;let R=s.filter(i=>!i.startsWith("[SUBAGENT SUCCESS]")).map(i=>{if(i.startsWith("[Subagent Response]")){let h="[Subagent Response]",e=i.substring(h.length),$="tool:";for(;;){let g=e.toLowerCase().indexOf($);if(g===-1)break;let d=g,T=!1,u=g-1;for(;u>=0&&/\s/.test(e[u]);)u--;u>=0&&e[u]==="["&&(d=u,T=!0);let p=0,m=!1,o=null,a=g;for(;a<e.length;){let l=e[a];if(!o&&(l==="'"||l==='"'||l==="`")?o=l:o&&l===o&&e[a-1]!=="\\"&&(o=null),o||(l==="("?(p++,m=!0):l===")"&&p--),m&&p===0&&!o){let w=a;if(T){let f=a+1;for(;f<e.length&&/\s/.test(e[f]);)f++;f<e.length&&e[f]==="]"&&(w=f)}e=e.substring(0,d)+e.substring(w+1);break}if(a++,a===e.length){e=e.substring(0,d);break}}}return h+`
17
17
  `+e.trim()}return i.startsWith("[Executing Tool]")&&i.length>256?i.substring(0,256)+"...[truncated from logs]":i});n+=R.join(`
18
18
  `)+`
19
19
 
@@ -1,6 +1,6 @@
1
- import{a as k,c as d}from"./chunk-56EJGQU3.js";import{a as b}from"./chunk-Y5JU726N.js";var I=async(w,s={})=>{let{runSubagent:U}=await import("./ai-XZ3MGIQ7.js"),l=b(w),c=l.task||l.instruction||l.prompt,C=l.model||null,E=l.title||null,m=l.tools||null;if(!c)return'ERROR: Missing "task" argument for invoke.';let f=null;if(m)try{let t=m.trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.substring(1,t.length-1)),f=t.split(",").map(n=>n.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let i=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,h=null,S=null,$=new Promise((t,n)=>{h=t,S=n}),e={id:i,title:E||c.substring(0,30),task:c,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:t=>{t&&e.pendingSteerMessages.push(t)},completionPromise:$,_resolveCompletion:h,_rejectCompletion:S,progress:[]},r={chunks:[],totalWords:0};k.push(e),s.onSubagentUpdate&&s.onSubagentUpdate();let a=[],M={...s,taskId:i,onAskMain:async t=>{let n=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,o=null,p=new Promise(g=>{o=g}),u={id:n,question:t,answered:!1,answer:null,askedAt:Date.now(),_resolve:o};return e.questions.push(u),e.status="waiting",s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" is WAITING FOR YOUR INPUT: "${t}"
1
+ import{a as k,c as d}from"./chunk-56EJGQU3.js";import{a as b}from"./chunk-Y5JU726N.js";var I=async(w,s={})=>{let{runSubagent:U}=await import("./ai-X7EEY6S3.js"),l=b(w),c=l.task||l.instruction||l.prompt,C=l.model||null,E=l.title||null,m=l.tools||null;if(!c)return'ERROR: Missing "task" argument for invoke.';let f=null;if(m)try{let t=m.trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.substring(1,t.length-1)),f=t.split(",").map(n=>n.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let i=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,h=null,S=null,$=new Promise((t,n)=>{h=t,S=n}),e={id:i,title:E||c.substring(0,30),task:c,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:t=>{t&&e.pendingSteerMessages.push(t)},completionPromise:$,_resolveCompletion:h,_rejectCompletion:S,progress:[]},r={chunks:[],totalWords:0};k.push(e),s.onSubagentUpdate&&s.onSubagentUpdate();let a=[],M={...s,taskId:i,onAskMain:async t=>{let n=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,o=null,p=new Promise(g=>{o=g}),u={id:n,question:t,answered:!1,answer:null,askedAt:Date.now(),_resolve:o};return e.questions.push(u),e.status="waiting",s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" is WAITING FOR YOUR INPUT: "${t}"
2
2
  Respond using tool: [tool:functions.Answer(id="${i}", answer="...")]
3
3
  [/SYSTEM]`),await p},onVisualFeedback:t=>{e.lastChunkTime=Date.now();let n=t.replace(/\x1b\[[0-9;]*m/g,""),o=n.match(/[✔✘✗✖🔍📖→➕↻•]\s*([A-Za-z0-9\s-]+)/);o?e.currentTool=o[1].trim():e.currentTool=n,s.onSubagentUpdate&&s.onSubagentUpdate()},onTokenChunk:(t,n)=>{let o=Date.now();if(e.lastChunkTime=o,e.currentTool="Thinking",typeof n=="number"&&n>0){r.totalWords+=n,r.chunks.push({time:o,words:n});let p=o-400;if(r.chunks=r.chunks.filter(u=>u.time>=p),r.chunks.length>0){let u=r.chunks.reduce((_,A)=>_+A.words,0),T=r.chunks[0].time,g=Math.max(.4,(o-T)/1e3);e.wps=Math.round(u/g)}}s.onSubagentUpdate&&s.onSubagentUpdate()}};return U(c,M,C,f,50,t=>{if(e.status==="cancelled")return;if(t.startsWith("[Subagent Turn")&&a.length>0&&(e.progress.push([...a]),a=[]),t.includes("[Executing Tool]")){let o=t.match(/\[Executing Tool\]\s*([a-zA-Z0-9_]+)/);o&&(!e.currentTool||e.currentTool==="Thinking")&&(e.currentTool=o[1])}let n=t;if(n.startsWith("[Tool Result]")){let o=n.split(`
4
4
  `);o.length>5&&(n=o.slice(0,4).join(`
5
5
  `)+`
6
- ... [Content/Diff Truncated from Logs] ...`)}a.push(n),s.onSubagentUpdate&&s.onSubagentUpdate()},!0).then(t=>{if(e.status==="cancelled"){e._resolveCompletion&&e._resolveCompletion(t);return}a.length>0&&(e.progress.push([...a]),a=[]),e.status="completed",e.finalAnswer=t,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) has FINISHED. Call GetProgress(id="${i}") to see the final result. [/SYSTEM]`),e._resolveCompletion&&e._resolveCompletion(t)}).catch(async t=>{let{isTerminationSignaled:n}=await import("./ai-XZ3MGIQ7.js");if(t.message==="Subagent task was cancelled."||e.status==="cancelled"||n()){e.status="cancelled",a.push("[SUBAGENT CANCELLED] Task was cancelled."),e.progress.push([...a]),s.onSubagentUpdate&&s.onSubagentUpdate(),e._resolveCompletion&&e._resolveCompletion(null);return}a.push(`[SUBAGENT FAILURE] Error: ${t.message}`),e.progress.push([...a]),e.status="failed",e.error=t.message,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) FAILED with error: ${t.message}. [/SYSTEM]`),e._rejectCompletion&&e._rejectCompletion(t)}),`SUCCESS: Background subagent started. Task ID: ${i}`};export{I as invoke};
6
+ ... [Content/Diff Truncated from Logs] ...`)}a.push(n),s.onSubagentUpdate&&s.onSubagentUpdate()},!0).then(t=>{if(e.status==="cancelled"){e._resolveCompletion&&e._resolveCompletion(t);return}a.length>0&&(e.progress.push([...a]),a=[]),e.status="completed",e.finalAnswer=t,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) has FINISHED. Call GetProgress(id="${i}") to see the final result. [/SYSTEM]`),e._resolveCompletion&&e._resolveCompletion(t)}).catch(async t=>{let{isTerminationSignaled:n}=await import("./ai-X7EEY6S3.js");if(t.message==="Subagent task was cancelled."||e.status==="cancelled"||n()){e.status="cancelled",a.push("[SUBAGENT CANCELLED] Task was cancelled."),e.progress.push([...a]),s.onSubagentUpdate&&s.onSubagentUpdate(),e._resolveCompletion&&e._resolveCompletion(null);return}a.push(`[SUBAGENT FAILURE] Error: ${t.message}`),e.progress.push([...a]),e.status="failed",e.error=t.message,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) FAILED with error: ${t.message}. [/SYSTEM]`),e._rejectCompletion&&e._rejectCompletion(t)}),`SUCCESS: Background subagent started. Task ID: ${i}`};export{I as invoke};
@@ -1,3 +1,3 @@
1
- import{a as o}from"./chunk-Y5JU726N.js";var k=async(b,t={})=>{let{runSubagent:u}=await import("./ai-XZ3MGIQ7.js"),s=o(b),a=s.task||s.instruction||s.prompt,m=s.model||null,l=s.tools||null;if(!a)return'ERROR: Missing "task" argument for invokeSync.';let r=null;if(l)try{let e=l.trim();e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),r=e.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let n=s.title||a.substring(0,30);try{t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n}`);let e=await u(a,t,m,r,50);return t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} [COMPLETED]
2
- `),e}catch(e){let{isTerminationSignaled:i}=await import("./ai-XZ3MGIQ7.js"),c=e.message==="Subagent task was cancelled by user."||i();if(t.onVisualFeedback){let d=c?"[CANCELLED]":"[FAILED]";t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} ${d}
1
+ import{a as o}from"./chunk-Y5JU726N.js";var k=async(b,t={})=>{let{runSubagent:u}=await import("./ai-X7EEY6S3.js"),s=o(b),a=s.task||s.instruction||s.prompt,m=s.model||null,l=s.tools||null;if(!a)return'ERROR: Missing "task" argument for invokeSync.';let r=null;if(l)try{let e=l.trim();e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),r=e.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let n=s.title||a.substring(0,30);try{t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n}`);let e=await u(a,t,m,r,50);return t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} [COMPLETED]
2
+ `),e}catch(e){let{isTerminationSignaled:i}=await import("./ai-X7EEY6S3.js"),c=e.message==="Subagent task was cancelled by user."||i();if(t.onVisualFeedback){let d=c?"[CANCELLED]":"[FAILED]";t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} ${d}
3
3
  `)}return`ERROR: Subagent execution failed: ${e.message}`}};export{k as invokeSync};
@@ -1,4 +1,4 @@
1
- import{g as h,h as m,i as R}from"./chunk-QA3IBTCI.js";import{a as F}from"./chunk-KFM2OZWJ.js";import{l as g}from"./chunk-AAPXJU65.js";import"./chunk-SIINYZWE.js";import"./chunk-FDNLMLIM.js";import{a as $}from"./chunk-Y5JU726N.js";import c from"fs";import M from"path";var v=async(w,S={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:C,error:p}=h(n);if(p)return`ERROR: ${p}`;if(o.length===0)return"ERROR: No valid replacement pairs found. Use searchContent1, newContent1, etc.";let E=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":C,i=M.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=S.forcedContent||c.readFileSync(i,"utf8");e.startsWith("\uFEFF")&&(e=e.slice(1));let s=e.replace(/\r\n/g,`
1
+ import{g as h,h as m,i as R}from"./chunk-ZSVBC2ZI.js";import{a as F}from"./chunk-KFM2OZWJ.js";import{l as g}from"./chunk-AAPXJU65.js";import"./chunk-SIINYZWE.js";import"./chunk-FDNLMLIM.js";import{a as $}from"./chunk-Y5JU726N.js";import c from"fs";import M from"path";var v=async(w,S={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:C,error:p}=h(n);if(p)return`ERROR: ${p}`;if(o.length===0)return"ERROR: No valid replacement pairs found. Use searchContent1, newContent1, etc.";let E=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":C,i=M.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=S.forcedContent||c.readFileSync(i,"utf8");e.startsWith("\uFEFF")&&(e=e.slice(1));let s=e.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `),{content:u,results:l}=m(s,o,{allowMultiple:E}),a=l.filter(r=>!r.success),f=l.filter(r=>r.success);if(f.length===0)return`ERROR: Patch Failed to apply to [${t}].
4
4
  ${a.map(r=>` \u2022 ${r.error}`).join(`
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-X3ZZM2GL.js";import"./chunk-FDNLMLIM.js";import"./chunk-Y5JU726N.js";export{a as view_file};
@@ -1,4 +1,4 @@
1
- import{a as P}from"./chunk-A73NNVCZ.js";import{d as M}from"./chunk-FDNLMLIM.js";import{a as k}from"./chunk-Y5JU726N.js";import v from"puppeteer";import _ from"fs";import q from"path";var V=async F=>{let{query:f,limit:j=5,aiMode:L=!1}=k(F);if(!f)return'ERROR: Missing "query" argument for web_search.';let S=3,y=null;if(L){let u=`Query: ${f}
1
+ import{a as P}from"./chunk-A73NNVCZ.js";import{d as M}from"./chunk-FDNLMLIM.js";import{a as k}from"./chunk-Y5JU726N.js";import v from"puppeteer";import _ from"fs";import q from"path";var V=async F=>{let{query:f,limit:j=5,aiMode:L=!1}=k(F);if(!f)return'ERROR: Missing "query" argument for WebSearch.';let S=3,y=null;if(L){let u=`Query: ${f}
2
2
 
3
3
  RESPONSE RULES:
4
4
  - ANSWER CONCISELY (TL;DR style) WITH REQUIRED DETAILS UNDER 300 WORDS.
@@ -13,9 +13,9 @@ Sources:
13
13
 
14
14
  - LIST ONE RAW URL PER BULLET.
15
15
  - DO NOT USE MARKDOWN LINKS.
16
- - DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.`;for(let s=1;s<=S;s++){let a=null;try{let i=P();a=await v.launch({headless:!0,executablePath:i.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let o=await a.newPage();await o.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await o.setViewport({width:1366,height:768});let g=s===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(e=>setTimeout(e,g));let N=`https://search.brave.com/ask?q=${encodeURIComponent(u)}&source=web`;await o.goto(N,{waitUntil:"domcontentloaded",timeout:18e4});let l=null,D=45e3,E=Date.now();for(;Date.now()-E<D;){if(l=await o.evaluate(()=>{let e=Array.from(document.querySelectorAll('.message:not(.user), .answer-text, .llm-content, [data-type="answer"]')),t="";if(e.length>0&&(t=e.map(T=>T.innerText.trim()).filter(Boolean).join(`
16
+ - DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.`;for(let s=1;s<=S;s++){let a=null;try{let i=P();a=await v.launch({headless:!0,executablePath:i.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let o=await a.newPage();await o.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await o.setViewport({width:1366,height:768});let g=s===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(e=>setTimeout(e,g));let N=`https://search.brave.com/ask?q=${encodeURIComponent(u)}&source=web`;await o.goto(N,{waitUntil:"domcontentloaded",timeout:18e4});let l=null,W=45e3,E=Date.now();for(;Date.now()-E<W;){if(l=await o.evaluate(()=>{let e=Array.from(document.querySelectorAll('.message:not(.user), .answer-text, .llm-content, [data-type="answer"]')),t="";if(e.length>0&&(t=e.map(T=>T.innerText.trim()).filter(Boolean).join(`
17
17
 
18
- `)),t||(t=document.body.innerText),t.includes("anomaly"))throw new Error("ANOMALY_DETECTED");let R=!!document.querySelector('.spinner, .loading, .typing, .streaming, [data-streaming="true"], [data-state="loading"], svg.animate-spin, circle[cx], div[class*="spin"]'),n=e[0]||document.body,p=n?n.innerText.trim():"",O=/^(?:[✓✔]\s*)?Finished/i.test(p)||!!(n&&n.querySelector(".status-finished, .finished")),x=!R&&(O||t.includes("Sources:")&&!R),W={};return document.querySelectorAll("a[href]").forEach(T=>{let r=T.getAttribute("href")||T.href||"";if(r.includes("uddg=")&&(r=decodeURIComponent(r.split("uddg=")[1].split("&")[0])),r.includes("url=")&&(r=decodeURIComponent(r.split("url=")[1].split("&")[0])),r&&(r.startsWith("http://")||r.startsWith("https://"))&&!r.includes("search.brave.com")){let $=T.innerText.trim();$&&(W[$]=r),T.textContent=r}}),{isFinished:x,text:t,hrefMap:W}}),l&&l.isFinished){await new Promise(e=>setTimeout(e,1e3));break}await new Promise(e=>setTimeout(e,1e3))}let c=(l?l.text:"")||"",d=l?l.hrefMap||{}:{},b="DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.";c.includes(b)&&(c=c.split(b).pop()),c=c.replace(/^.*?(Ctrl \+ Shift \+ O|Ask\nAll\nImages)/s,"").replace(/AI-generated answer\. Please verify critical facts\..*/s,"").replace(/Brave Search uses private usage metrics.*/s,"");let m=c,w="";if(c.includes("Sources:")){let e=c.split("Sources:");m=e[0],w=e.slice(1).join("Sources:")}let h=[];for(let e of m.split(`
18
+ `)),t||(t=document.body.innerText),t.includes("anomaly"))throw new Error("ANOMALY_DETECTED");let R=!!document.querySelector('.spinner, .loading, .typing, .streaming, [data-streaming="true"], [data-state="loading"], svg.animate-spin, circle[cx], div[class*="spin"]'),n=e[0]||document.body,p=n?n.innerText.trim():"",O=/^(?:[✓✔]\s*)?Finished/i.test(p)||!!(n&&n.querySelector(".status-finished, .finished")),x=!R&&(O||t.includes("Sources:")&&!R),D={};return document.querySelectorAll("a[href]").forEach(T=>{let r=T.getAttribute("href")||T.href||"";if(r.includes("uddg=")&&(r=decodeURIComponent(r.split("uddg=")[1].split("&")[0])),r.includes("url=")&&(r=decodeURIComponent(r.split("url=")[1].split("&")[0])),r&&(r.startsWith("http://")||r.startsWith("https://"))&&!r.includes("search.brave.com")){let $=T.innerText.trim();$&&(D[$]=r),T.textContent=r}}),{isFinished:x,text:t,hrefMap:D}}),l&&l.isFinished){await new Promise(e=>setTimeout(e,1e3));break}await new Promise(e=>setTimeout(e,1e3))}let c=(l?l.text:"")||"",d=l?l.hrefMap||{}:{},b="DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.";c.includes(b)&&(c=c.split(b).pop()),c=c.replace(/^.*?(Ctrl \+ Shift \+ O|Ask\nAll\nImages)/s,"").replace(/AI-generated answer\. Please verify critical facts\..*/s,"").replace(/Brave Search uses private usage metrics.*/s,"");let m=c,w="";if(c.includes("Sources:")){let e=c.split("Sources:");m=e[0],w=e.slice(1).join("Sources:")}let h=[];for(let e of m.split(`
19
19
  `)){let t=e.trim();t&&(/^(View all|Finished|Searching|Answering|Thinking)$/i.test(t)||/^[\+\-]?\d+$/.test(t)||t.includes("search.brave.com")||t.startsWith("https://www.youtube.com/watch")||t.startsWith("https://youtube.com/watch")||h.push(e))}let U=h.join(`
20
20
  `).replace(/^(?:[\+\-]?\d+\s*)+/i,"").replace(/\n{3,}/g,`
21
21
 
package/dist/cli.js CHANGED
@@ -63,4 +63,4 @@ Usage: fluxflow --export error`),process.exit(1)}if(N&&(console.log(`v${d}`),pro
63
63
  /docs View documentation
64
64
  /fluxflow init Create FluxFlow.md template
65
65
  /update check Check for new version
66
- /update latest Install latest release`),process.exit(0)),R){let y=e[1]||"latest";if(y==="check"){let l=e[2]==="latest";try{let x=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;x||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(l?`Latest version: v${x}`:x!==d?`A new version of FluxFlow is available: v${x} (current: v${d}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${d}).`)}catch(c){console.error("Error checking for updates:",c.message),process.exit(1)}process.exit(0)}else if(y==="latest"){console.log("Checking latest version and settings...");try{let n=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;n||(console.error("Error: Could not retrieve latest version."),process.exit(1)),n===d&&(console.log(`FluxFlow is already up to date (v${d}).`),process.exit(0));let x=async()=>{let t=(await import("react")).default,{useState:L}=t,{render:K,Box:f,Text:b}=await import("ink"),Q=(await import("ink-select-input")).default,Z=(await import("ink-text-input")).default;return new Promise(ee=>{let oe=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],te=({label:S,isSelected:C})=>t.createElement(f,{width:"100%"},t.createElement(b,{bold:C},"\u2514\u2500 ",C?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",S)),T,se=()=>{let[S,C]=L("select"),[ae,ne]=L(""),ie=F=>{F.value==="custom"?C("custom"):_({manager:F.value})},le=F=>{_({manager:"custom",customCommand:F})};return S==="custom"?t.createElement(f,{flexDirection:"column",marginY:1},t.createElement(f,{marginBottom:1},t.createElement(b,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),t.createElement(f,{flexDirection:"row"},t.createElement(b,{color:"cyan",bold:!0}," \u276F "),t.createElement(Z,{value:ae,onChange:ne,onSubmit:le})),t.createElement(f,{marginTop:1},t.createElement(b,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):t.createElement(f,{flexDirection:"column",marginY:1},t.createElement(f,{marginBottom:1},t.createElement(b,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),t.createElement(Q,{items:oe,onSelect:ie,itemComponent:te,indicatorComponent:()=>null}))},_=S=>{T&&T(),ee(S)},{unmount:re}=K(t.createElement(se,null));T=re})},u,O="",E;try{let{loadSettings:t}=await import("./chunks/settings-2IFZMDUD.js");E=await t(),u=E?.systemSettings?.updateManager||E?.updateManager}catch{}if(!u){let t=await x();u=t.manager,O=t.customCommand}let g="";u==="pnpm"?g=`pnpm add -g fluxflow-cli@${n}`:u==="bun"?g=`bun add -g fluxflow-cli@${n}`:u==="yarn"?g=`yarn global add fluxflow-cli@${n}`:u==="custom"?g=O||E?.customUpdateCommand||`npm install -g fluxflow-cli@${n}`:g=`npm install -g fluxflow-cli@${n}`,console.log(`Updating FluxFlow to v${n} using ${u}...`),console.log(`Running: ${g}`);let{execSync:J}=await import("child_process");J(g,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${n}.\x1B[0m`)}catch(l){console.error("\x1B[31m\u274C Update failed:\x1B[0m",l.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:Y}=await import("react"),{render:W}=await import("ink"),{default:q}=await import("./chunks/app-3WHQFSU3.js");process.env.NODE_NO_WARNINGS="1";let X=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],H=console.log,V=console.warn,z=console.error,k=o=>{let a=o.map(String).join(" ");return X.some(i=>a.includes(i))};console.log=(...o)=>!k(o)&&H(...o),console.warn=(...o)=>!k(o)&&V(...o),console.error=(...o)=>!k(o)&&z(...o);let A=e.findIndex(o=>o==="--cwd"||o==="--path");if(A!==-1&&A+1<e.length){let o=e[A+1],a=await import("path"),i=await import("fs-extra"),p=a.default.resolve(o);try{i.default.existsSync(p)&&i.default.statSync(p).isDirectory()?process.chdir(p):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(v){console.error(`[ERROR] Failed to change directory to "${o}": ${v.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let $=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",$),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{$(),process.exit(0)})}),e.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:a}=await import("./chunks/paths-PM7MFWJK.js"),i=await import("path"),p=await import("fs-extra"),v=i.default.join(a,"playground");try{p.default.ensureDirSync(v),process.chdir(v)}catch{}}W(Y.createElement(q,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
66
+ /update latest Install latest release`),process.exit(0)),R){let y=e[1]||"latest";if(y==="check"){let l=e[2]==="latest";try{let x=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;x||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(l?`Latest version: v${x}`:x!==d?`A new version of FluxFlow is available: v${x} (current: v${d}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${d}).`)}catch(c){console.error("Error checking for updates:",c.message),process.exit(1)}process.exit(0)}else if(y==="latest"){console.log("Checking latest version and settings...");try{let n=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;n||(console.error("Error: Could not retrieve latest version."),process.exit(1)),n===d&&(console.log(`FluxFlow is already up to date (v${d}).`),process.exit(0));let x=async()=>{let t=(await import("react")).default,{useState:L}=t,{render:K,Box:f,Text:b}=await import("ink"),Q=(await import("ink-select-input")).default,Z=(await import("ink-text-input")).default;return new Promise(ee=>{let oe=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],te=({label:S,isSelected:C})=>t.createElement(f,{width:"100%"},t.createElement(b,{bold:C},"\u2514\u2500 ",C?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",S)),T,se=()=>{let[S,C]=L("select"),[ae,ne]=L(""),ie=F=>{F.value==="custom"?C("custom"):_({manager:F.value})},le=F=>{_({manager:"custom",customCommand:F})};return S==="custom"?t.createElement(f,{flexDirection:"column",marginY:1},t.createElement(f,{marginBottom:1},t.createElement(b,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),t.createElement(f,{flexDirection:"row"},t.createElement(b,{color:"cyan",bold:!0}," \u276F "),t.createElement(Z,{value:ae,onChange:ne,onSubmit:le})),t.createElement(f,{marginTop:1},t.createElement(b,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):t.createElement(f,{flexDirection:"column",marginY:1},t.createElement(f,{marginBottom:1},t.createElement(b,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),t.createElement(Q,{items:oe,onSelect:ie,itemComponent:te,indicatorComponent:()=>null}))},_=S=>{T&&T(),ee(S)},{unmount:re}=K(t.createElement(se,null));T=re})},u,O="",E;try{let{loadSettings:t}=await import("./chunks/settings-2IFZMDUD.js");E=await t(),u=E?.systemSettings?.updateManager||E?.updateManager}catch{}if(!u){let t=await x();u=t.manager,O=t.customCommand}let g="";u==="pnpm"?g=`pnpm add -g fluxflow-cli@${n}`:u==="bun"?g=`bun add -g fluxflow-cli@${n}`:u==="yarn"?g=`yarn global add fluxflow-cli@${n}`:u==="custom"?g=O||E?.customUpdateCommand||`npm install -g fluxflow-cli@${n}`:g=`npm install -g fluxflow-cli@${n}`,console.log(`Updating FluxFlow to v${n} using ${u}...`),console.log(`Running: ${g}`);let{execSync:J}=await import("child_process");J(g,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${n}.\x1B[0m`)}catch(l){console.error("\x1B[31m\u274C Update failed:\x1B[0m",l.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:Y}=await import("react"),{render:W}=await import("ink"),{default:q}=await import("./chunks/app-ZHDEY5VH.js");process.env.NODE_NO_WARNINGS="1";let X=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],H=console.log,V=console.warn,z=console.error,k=o=>{let a=o.map(String).join(" ");return X.some(i=>a.includes(i))};console.log=(...o)=>!k(o)&&H(...o),console.warn=(...o)=>!k(o)&&V(...o),console.error=(...o)=>!k(o)&&z(...o);let A=e.findIndex(o=>o==="--cwd"||o==="--path");if(A!==-1&&A+1<e.length){let o=e[A+1],a=await import("path"),i=await import("fs-extra"),p=a.default.resolve(o);try{i.default.existsSync(p)&&i.default.statSync(p).isDirectory()?process.chdir(p):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(v){console.error(`[ERROR] Failed to change directory to "${o}": ${v.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let $=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",$),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{$(),process.exit(0)})}),e.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:a}=await import("./chunks/paths-PM7MFWJK.js"),i=await import("path"),p=await import("fs-extra"),v=i.default.join(a,"playground");try{p.default.ensureDirSync(v),process.chdir(v)}catch{}}W(Y.createElement(q,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.16.16",
4
- "date": "2026-09-23",
3
+ "version": "4.17.0",
4
+ "date": "2026-09-24",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & computer use.",
6
6
  "keywords": [
7
7
  "ai",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.16.16",
4
- "date": "2026-09-23",
3
+ "version": "4.17.0",
4
+ "date": "2026-09-24",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & computer use.",
6
6
  "keywords": [
7
7
  "ai",
@@ -1,48 +0,0 @@
1
- import{c as X}from"./chunk-FDNLMLIM.js";import G from"os";var R=t=>typeof t!="string"?t:t.length>12?(t+"").replace("",""):t,v=(t,o)=>{if(!t)return"";let p=/\x1B\[[0-?]*[ -/]*[@-~]/g,x=t.split(`
2
- `),h=[];if(o<=5)return t;let a=e=>e<32||e>=127&&e<160||e>=768&&e<=879||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071?0:e>=4352&&e<=4447||e>=9001&&e<=9002||e>=11904&&e<=12350||e>=12352&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=128640&&e<=128767||e>=131072&&e<=262141?2:1,d=e=>{let s=e.replace(p,""),r=0;for(let l=0;l<s.length;l++){let i=s.codePointAt(l);i>65535&&l++,r+=a(i)}return r},y=(e,s)=>{let r=0,l=e.length,i=!1;for(let $=0;$<e.length;$++){if(e[$]==="\x1B"&&e[$+1]==="["&&(i=!0),i){(e[$]==="m"||e[$]>="@"&&e[$]<="~"&&e[$]!=="[")&&(i=!1);continue}let b=e.codePointAt($);b>65535&&$++;let k=a(b);if(r+k>s){l=b>65535?$-1:$;break}if(r+=k,r>=s){l=$+1;break}}return{head:e.substring(0,l),tail:e.substring(l)}};return x.forEach(e=>{if(d(e)<=o){h.push(e);return}let r=e.split(/(\s+)/),l="",i=0,$=e.match(/^(\s*)/),b=$?$[1]:"";r.forEach(k=>{if(k.length===0)return;let u=k;for(;u.length>0;){let S=d(u);if(i+S<=o){l+=u,i+=S;break}l.trim().length>0&&(h.push(l.trimEnd()),l=b.substring(0,Math.min(b.length,8)),i=d(l));let n=Math.max(1,o-i);if(d(u)>n){let{head:f,tail:c}=y(u,n);h.push((l+f).trimEnd()),l=b.substring(0,Math.min(b.length,8)),i=d(l),u=c}else l+=u,i+=d(u),u=""}}),(l.trimEnd().length>0||l===b)&&h.push(l.trimEnd())}),R(h.join(`
3
- `))},rt=t=>{if(!t)return 0;let o=0,p=t.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);p&&(o+=p.length*.55);let x=t.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),h=x.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);h&&(o+=h.length);let a=x.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return o+=a.length,Math.max(.1,o)},st=t=>t?t.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[t]:[],ot=t=>{if(!t&&t!==0)return"0.0k";let o=typeof t=="string"?parseFloat(t):t;return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:o.toString()},lt=(t,o=40)=>{let p=X.replaceAll("\\\\","\\");if(t=t.replace(G.homedir(),"~").replace(p,"FluxFlow").replaceAll("\\","/"),!t||t.length<=o)return R(t);let x=Math.floor((o-3)/2);return R(t.substring(0,x)+"..."+t.substring(t.length-x).replaceAll("\\","/"))},at=t=>{let o=[],p=new Set,x=t.allowMultiple===!0||String(t.allowMultiple).toLowerCase()==="true";Object.keys(t).forEach(e=>{let s=e.match(/^(searchContent|search_content|replaceContent|replace_content|newContent|new_content|content_to_replace|content_to_add|searchBlock|search_block|newBlock|new_block)_?(\d+)?$/i);if(s){let r=s[2]?parseInt(s[2],10):1;p.add(r)}});let h=Array.from(p).sort((e,s)=>e-s),a=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],d=["newContent","new_content","content_to_add","newBlock","new_block"],y=(e,s,r)=>{let l,i;for(let $ of s){let b=e===1?[`${$}1`,$,`${$}_1`]:[`${$}${e}`,`${$}_${e}`];for(let k of b)if(t[k]!==void 0){l=t[k];break}if(l!==void 0)break}for(let $ of r){let b=e===1?[`${$}1`,$,`${$}_1`]:[`${$}${e}`,`${$}_${e}`];for(let k of b)if(t[k]!==void 0){i=t[k];break}if(i!==void 0)break}return{r:l,n:i}};for(let e of h){let{r:s,n:r}=y(e,a,d);if(s!==void 0&&r!==void 0)o.push({replace:s,new:r});else if(s!==void 0||r!==void 0)return{error:`Mismatched replacement pair for index ${e}. Both replacement and new content must be provided.`,allowMultiple:x}}return{patchPairs:o,allowMultiple:x}},V=t=>{if(!t)return null;let o="",p=0,x=t.length;for(;p<x;){let h=t[p];if(h==="\\"){for(;p<x&&t[p]==="\\";)p++;o+="\\\\*"}else if(h===`
4
- `)o+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",p++;else if(h==="\r")o+="(?:\\r|\\\\*r)?",p++;else if(h===" ")o+="(?:\\t|\\\\*t|\\s*)",p++;else if(h==='"'||h==="'"||h==="`")o.endsWith("\\\\*")||(o+="\\\\*"),o+=h,p++;else if(/[.*+?^${}()|[\]]/.test(h))o+="\\"+h,p++;else if(/\s/.test(h)){for(;p<x&&/\s/.test(t[p])&&t[p]!==`
5
- `&&t[p]!=="\r"&&t[p]!==" ";)p++;o+="\\s*"}else o+=h,p++}if(!o)return null;try{return new RegExp(o,"g")}catch{return null}},ct=(t,o,p={})=>{let x=typeof p=="boolean"?p:!!(p&&p.allowMultiple),h=t.replace(/\r\n/g,`
6
- `).replace(/\r/g,`
7
- `),a=n=>n.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
8
- `).replace(/\r/g,`
9
- `),d=n=>n.match(/^\s*/)[0],y=n=>{let f=n.split(`
10
- `).filter(C=>C.trim()!=="");if(f.length===0)return"";let c=d(f[0]);for(let C of f){let w=d(C);w.length<c.length&&(c=w)}return c},e=(n,f,c="")=>{if(!n||f===void 0)return n;let w=/^\t/m.test(f)?" ":" ",I=E=>E.split(`
11
- `).find(M=>M.trim()!=="")??"",L=I(f).match(/^\s*/)[0].length,g=I(n).match(/^\s*/)[0].length,m=L-g,F=(c.match(/^\s*/)||[""])[0].length;return n.split(`
12
- `).map((E,M)=>{if(E.trim()===""&&M!==0)return"";let T=E.match(/^\s*/)[0].length,_=Math.max(0,T+m);return M===0&&(_=Math.max(0,_-F)),w.repeat(_)+E.trimStart()}).join(`
13
- `)},s=[];for(let n=0;n<o.length;n++){let f=o[n],c=(f.replace||"").trim(),C=a(f.new||"");if(c.startsWith("^LINE:")&&c.endsWith("$")){let F=c.slice(6,-1).trim().split(".."),A=parseInt(F[0]),E=F[1]!==void 0?parseInt(F[1]):A;if(!isNaN(A)&&!isNaN(E)){let M=h.split(`
14
- `);if(A<1||A>M.length||E<A||E>M.length){s.push({index:n,success:!1,error:`Block ${n+1}: Line range ^LINE:${A}..${E}$ out of bounds (file has ${M.length} lines).`});continue}let _=M.slice(A-1,E).join(`
15
- `),O=0;for(let N=0;N<A-1;N++)O+=M[N].length+1;s.push({index:n,success:!0,startPos:O,firstMatchContent:_,content_to_add:C});continue}}let w=a(f.replace||"");if(w===""&&C===""){s.push({index:n,success:!1,error:`Block ${n+1}: Empty replace and add content.`});continue}let I=w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=null;if(w!==""&&h.includes(w))L=new RegExp(I,"g");else{let m=w.split(`
16
- `).map(F=>F.trim()).filter(F=>F.length>0).map(F=>F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if(m.length>0){let F=m.join("\\s*");try{L=new RegExp(F,"g")}catch{L=new RegExp(I,"g")}}else L=new RegExp(I,"g")}let g=[...h.matchAll(L)];if(g.length===0&&w!==""){let m=V(w);m&&(g=[...h.matchAll(m)])}if(g.length===0){s.push({index:n,success:!1,error:`Block ${n+1}: Could not find match.`});continue}if(g.length>1&&!x){s.push({index:n,success:!1,error:`Block ${n+1}: Found ${g.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let m of g)s.push({index:n,success:!0,startPos:m.index,firstMatchContent:m[0],content_to_add:C})}let r=s.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n=0;n<r.length-1;n++){let f=r[n],c=r[n+1];f.startPos+f.firstMatchContent.length>c.startPos&&(f.success=!1,f.error=`Block ${f.index+1}: Overlaps with another block.`,c.success=!1,c.error=`Block ${c.index+1}: Overlaps with another block.`)}let l=new Map,i=h,$=0,b=0,k=s.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n of k){let f=n.startPos,c=h.substring(0,f).split(`
17
- `).length,C=f+$,w=c+b,I=i.lastIndexOf(`
18
- `,C)+1,L=i.substring(I,C),g=e(n.content_to_add,n.firstMatchContent,L),m=i.split(`
19
- `),F=[];for(let T=Math.max(0,w-4);T<w-1;T++)F.push({num:T+1,text:m[T]});let A=n.firstMatchContent.split(`
20
- `),E=[],M=w+A.length-1;for(let T=M;T<Math.min(m.length,M+3);T++)E.push({num:T+1,text:m[T]});l.set(n,{success:!0,index:n.index,oldContent:n.firstMatchContent,newContent:g,originalStartLine:c,finalStartLine:w,contextBefore:F,contextAfter:E}),i=i.substring(0,C)+g+i.substring(C+n.firstMatchContent.length),$+=g.length-n.firstMatchContent.length,b+=g.split(`
21
- `).length-n.firstMatchContent.split(`
22
- `).length}let u=[];for(let n=0;n<o.length;n++){let f=k.filter(c=>c.index===n);if(f.length>0)for(let c of f)l.has(c)&&u.push(l.get(c));else{let c=s.find(C=>C.index===n);u.push({success:!1,error:c?c.error:`Block ${n+1}: Unknown error.`})}}let S=u.filter(n=>!n.success&&n.error&&n.error.includes("Could not find match"));if(S.length===1)S[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if(S.length>1){let n=S[S.length-1];n.error+=`
23
- (Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:i,results:u}},ft=(t,o,p,x=8,h=!1)=>{if(!p||p.length===0)return"";let a=t.split(/\r?\n/),d=o.split(/\r?\n/),y=Math.max(a.length,d.length,1),e=Math.max(4,String(y).length),s=k=>String(k).padStart(e," "),r=`[DIFF_START]
24
- `,l="\u2550".repeat(88),i=0,$=null,b=p.filter(k=>k.success).sort((k,u)=>k.originalStartLine-u.originalStartLine);if(b.forEach((k,u)=>{let S=k.finalStartLine!==void 0?k.finalStartLine:k.originalStartLine;if($===null)for(i=Math.max(0,S-4);i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${d[i]||""}
25
- `,i++;else{let L=$,g=L.originalStartLine+L.oldContent.split(`
26
- `).length-1;if(k.originalStartLine-g-1>=x){let F=Math.min(d.length,i+3);for(;i<F;)r+=`[UI_CONTEXT] ${s(i+1)} |${d[i]||""}
27
- `,i++;for(r+=`[UI_CONTEXT] ${l}
28
- `,i=Math.max(i,S-4);i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${d[i]||""}
29
- `,i++}else for(;i<S-1;)r+=`[UI_CONTEXT] ${s(i+1)} |${d[i]||""}
30
- `,i++}let n=k.originalStartLine-1,f=a[n]||"",c=k.oldContent.split(`
31
- `),C=f.match(/^\s*/),w=C?C[0]:"";c.forEach((L,g)=>{let m=L;if(c.length===1&&f.trim().length>0&&f.includes(L.trim()))m=f;else if(g===0){let F=L.match(/^\s*/);(F?F[0]:"").length<w.length&&f.includes(L.trim())&&(m=w+L.trimStart())}r+=`-${s(k.originalStartLine+g)} |${m}
32
- `});let I=i;if(k.finalStartLine!==void 0)I=k.finalStartLine-1+(k.newContent?k.newContent.split(`
33
- `).length:0);else{let L=k.originalStartLine+c.length-1,g=a[L]||null;if(g!==null){let m=u<b.length-1?(b[u+1].originalStartLine||d.length)+10:d.length;for(let F=i;F<m;F++){if(d[F]===g){I=F;break}F===d.length-1&&(I=d.length)}}else I=d.length}for(;i<I;)r+=`+${s(i+1)} |${d[i]||""}
34
- `,i++;$=k}),$!==null){let k=Math.min(d.length,i+3);for(;i<k;)r+=`[UI_CONTEXT] ${s(i+1)} |${d[i]||""}
35
- `,i++}if(h){let k=`[DIFF_START]
36
- `,u=r.substring(k.length),S=`[UI_CONTEXT] ${l}
37
- `,f=u.split(S).map(c=>c.split(`
38
- `).filter(w=>w.trim()!=="").length>120?`[[VERIFIED]]
39
- ${c}
40
- [[/VERIFIED]]`:c);r=k+f.join(S)}return r+="[DIFF_END]",R(r)},K=t=>{if(!t)return null;let o=t.replace("[UI_CONTEXT]","").replace(/\r/g,""),p=o.startsWith("-"),x=o.startsWith("+"),h=p||x?o.substring(1):o,a=h.indexOf("|"),d=a!==-1?R(h.substring(0,a).trim()):"",y=R(a!==-1?h.substring(a+1):h);return{isR:p,isA:x,num:d,content:y}},Y=(t,o)=>{if(!t&&!o)return 1;if(!t||!o)return 0;let p=t.length,x=o.length,h=t,a=o;p<x&&(h=o,a=t);let d=h.length,y=a.length,e=new Int32Array(y+1),s=new Int32Array(y+1);for(let i=0;i<=y;i++)e[i]=i;for(let i=1;i<=d;i++){s[0]=i;let $=h[i-1];for(let b=1;b<=y;b++)$===a[b-1]?s[b]=e[b-1]:s[b]=Math.min(e[b],s[b-1],e[b-1])+1;e.set(s)}let r=e[y],l=Math.max(p,x);return l===0?1:1-r/l},z=t=>{let o=[],p=[];t.forEach((r,l)=>{r.parsed.isR?o.push({index:l,content:r.parsed.content}):r.parsed.isA&&p.push({index:l,content:r.parsed.content})});let x=o.length,h=p.length;if(x===0||h===0)return;let a=Array.from({length:x+1},()=>Array(h+1).fill(0)),d=Array.from({length:x+1},()=>Array(h+1).fill(""));for(let r=1;r<=x;r++)d[r][0]="up";for(let r=1;r<=h;r++)d[0][r]="left";let y=Array.from({length:x},()=>Array(h).fill(0));for(let r=0;r<x;r++)for(let l=0;l<h;l++)y[r][l]=Y(o[r].content.trim(),p[l].content.trim());for(let r=1;r<=x;r++)for(let l=1;l<=h;l++){let i=y[r-1][l-1],$=i>=.2?i:-10,b=a[r-1][l-1]+$,k=a[r-1][l],u=a[r][l-1];b>=k&&b>=u?(a[r][l]=b,d[r][l]="diag"):k>=u?(a[r][l]=k,d[r][l]="up"):(a[r][l]=u,d[r][l]="left")}let e=x,s=h;for(;e>0||s>0;)if(d[e][s]==="diag"){if(y[e-1][s-1]>=.2){let l=o[e-1].index,i=p[s-1].index;t[l].pairContent=t[i].parsed.content,t[i].pairContent=t[l].parsed.content}e--,s--}else d[e][s]==="up"?e--:s--},B=new Map,P=new Map,H=200,W=5,U=(t,o)=>{o.set(t.key,t),t.type==="chunk"&&t.blocks&&t.blocks.forEach(p=>U(p,o))},ht=(t,o)=>{if(!t)return{completed:[],active:[]};let p=`${t.id}-${t.text?.length||0}-${o}-${t.isStreaming}-${t.workedDuration||0}`;if(!t.isStreaming&&B.has(p))return B.get(p);let x=R(et(t.text||"",t.role)),h=`${t.id}-${o}`,a=new Map;if(t.isStreaming){let u=P.get(h);u&&x.startsWith(u.text)&&(a=u.blocksMap)}let d=(u,S,n,f={})=>{let c=a.get(u);if(c&&c.text===n&&c.type===S&&!!c.isActiveBlock==!!f.isActiveBlock&&!!c.isStreaming==!!f.isStreaming&&c.pairContent===f.pairContent)return c;let C=R(n),w={...f};return typeof w.pairContent=="string"&&(w.pairContent=R(w.pairContent)),Array.isArray(w.wrappedLines)&&(w.wrappedLines=w.wrappedLines.map(R)),{key:u,isStreamingMsg:!!t.isStreaming,workedDuration:t.workedDuration,type:S,text:C,msg:S==="full-message"?t:void 0,...w}};if(x.includes("- Content Preview:")){let u="",S=x.match(/File\s+\[(.*?)\]/i);S&&(u=S[1].split(".").pop().toLowerCase());let w=((x.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"").split(`
41
- `).map(E=>E.replace(/\r$/,"")),I=String(w.length).length,L=[],g=null,m=[],F=()=>{if(!m.length)return;let E=m;m=[],L.push(E.length===1?E[0]:{key:`${E[0].key}-chunk`,type:"chunk",blocks:E})},A=o-(I+6);return w.forEach((E,M)=>{let T=M===w.length-1,_=v(E,A).split(`
42
- `),O=d(`${t.id||Date.now()}-write-line-${M}`,"write-line",E,{gutterWidth:I,lineNum:M+1,isFirstLine:M===0,isLastLine:T,extension:u,wrappedLines:_});T&&t.isStreaming?(F(),g=O):(m.push(O),m.length>=W&&F())}),F(),{completed:L,active:g?[g]:[]}}if(x.includes("[DIFF_START]")){let u=x.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),n=(u?u[1].trim():"").split(`
43
- `).map(g=>g.replace(/\r$/,"")),f=n.map(g=>({line:g,parsed:K(g),pairContent:null})),c=[];for(let g=0;g<f.length;g++){let m=f[g];m.parsed&&(m.parsed.isR||m.parsed.isA)?c.push(m):c.length>0&&(z(c),c=[])}c.length>0&&z(c);let C=[],w=null,I=[],L=()=>{if(!I.length)return;let g=I;I=[],C.push(g.length===1?g[0]:{key:`${g[0].key}-chunk`,type:"chunk",blocks:g})};return n.forEach((g,m)=>{let F=m===n.length-1,A=f[m].parsed,E=null;A&&(E=v(A.content,o-17).split(`
44
- `));let M=d(`${t.id||Date.now()}-diff-${m}`,"diff-line",g,{isFirstLine:m===0,isLastLine:F,pairContent:f[m].pairContent,wrappedLines:E});F&&t.isStreaming?(L(),w=M):(I.push(M),I.length>=W&&L())}),L(),{completed:C,active:w?[w]:[]}}if(t.role==="system"||t.isLogo||t.isHelpRecord||t.isTerminalRecord||t.isHomeWarning||t.isImageStats||t.isAskRecord||t.isAboutRecord||t.isUpdateNotification||t.role==="user")return{completed:[d(`${t.id||Date.now()}-full`,"full-message",x)],active:[]};if(!x&&!t.isStreaming){let u={completed:[],active:[]};return B.set(p,u),u}let y=[],e=null,s=[],r=null,l=()=>{if(!s.length)return;let u=s;s=[],r=null,y.push(u.length===1?u[0]:{key:`${t.id||"x"}-chunk-${u[0].key}`,type:"chunk",blocks:u})},i=(u,S=!1)=>{if(r!==null&&r!==u.type&&l(),s.push(u),r=u.type,s.length>=W){if(t.isStreaming&&S)return;l()}},$=Math.max(20,(o||80)-6),b=Math.max(20,(o||80)-8);if(t.role==="think"){y.push(d(`${t.id}-header`,"think-header",""));let u=x.split(`
45
- `),S=[];u.forEach(n=>{v(n,b).split(`
46
- `).forEach(c=>S.push(c))}),S.forEach((n,f)=>{let c=f===S.length-1;i(d(`${t.id}-${f}`,"think-line",n,{}),c)}),t.isStreaming||(l(),y.push({key:`${t.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let u=x.split(`
47
- `),S=!1,n=[],f=!1,c="",C=0,w=0,I=[];u.forEach(L=>{let g=L.trim();g.startsWith("```")?(f=!f,I.push(L)):f||g.startsWith("|")?I.push(L):v(L,$).split(`
48
- `).forEach(F=>I.push(F))}),f=!1,I.forEach((L,g)=>{let m=g===I.length-1,F=L.trim().startsWith("|"),A=L.trim().startsWith("```");if(f)A?(f=!1,i(d(`${t.id}-code-close-${w}`,"code-fence-close","",{}),m)):(C++,i(d(`${t.id}-code-line-${g}`,"code-line",L,{lineNum:C,lang:c}),m));else if(A)f=!0,w=g,C=0,c=L.trim().replace(/^```/,"").trim(),i(d(`${t.id}-code-open-${g}`,"code-fence-open",c,{}),m);else if(F){if(S||(S=!0,n=[]),n.push(L),n.length===2){let E=n[0],M=E.split("|");M[0]!==void 0&&M[0].trim()===""&&M.shift(),M.length>0&&M[M.length-1].trim()===""&&M.pop();let T=M.map(_=>_.trim());i(d(`${t.id}-table-hdr-${g}`,"table-header",E,{colHeaders:T,colCount:T.length}),m)}else if(n.length>2){let E=L.split("|");E[0]!==void 0&&E[0].trim()===""&&E.shift(),E.length>0&&E[E.length-1].trim()===""&&E.pop();let M=E.map(N=>N.trim()),T=n[0].split("|");T[0]!==void 0&&T[0].trim()===""&&T.shift(),T.length>0&&T[T.length-1].trim()===""&&T.pop();let _=T.map(N=>N.trim()),O=Math.max(1,_.length);i(d(`${t.id}-table-row-${g}`,"table-row",L,{cells:M,colHeaders:_,colCount:O,rowIndex:n.length-3}),m)}m&&!t.isStreaming&&(l(),i(d(`${t.id}-table-end-${g}`,"table-close","",{}),!0))}else S&&(i(d(`${t.id}-table-end-${g}`,"table-close","",{}),m),S=!1,n=[]),i(d(`${t.id}-${g}`,"agent-line",L,{}),m)}),!t.isStreaming&&t.workedDuration&&(l(),y.push(d(`${t.id}-worked-duration`,"worked-duration","")))}t.isStreaming&&s.length>0?e=s.length===1?s[0]:{key:`${t.id||"x"}-chunk-active-${s[0].key}`,type:"chunk",blocks:s}:l();let k={completed:y,active:e?[e]:[]};if(t.isStreaming){let u=new Map;if(y.forEach(S=>U(S,u)),e&&U(e,u),P.set(h,{text:x,blocksMap:u}),P.size>H){let S=P.keys().next().value;P.delete(S)}}else{if(B.set(p,k),B.size>H){let u=B.keys().next().value;B.delete(u)}P.delete(h)}return k},q={},Z=/(\r?\n){2}(?=\[?(?:tool:functions|tool\.functions|agent:generalist|agent\.generalist|\s*turn\s*:))/gi,D=(t,o)=>{let p=!1,x=!1,h=0;for(;h<o;){if(t.startsWith("```",h)){x=!x,h+=3;continue}!x&&t[h]==="`"&&(h===0||t[h-1]!=="\\")&&(p=!p),h++}return x||p},J=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[TOOL RESULT\]:?\s*|^\s*(SUCCESS|ERROR):.*(\r?\n)?|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,Q=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,tt=/\b(write_file|update_file|read_folder|view_file|exec_command|web_search|web_scrape|search_keyword|write_pdf|write_docx|generate_image)\b/gi,j=!1,et=(t,o="agent")=>{if(!t)return t;let p=o===!0||o==="think",x=o===!1||o==="agent",h=t.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");if(p)return h.replace(/^<(think|thought|thoughts|thinking)>/gi,"").replace(/<\/(think|thought|thoughts|thinking)>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let a=h;x&&(a=a.replace(/<\/?(?:think|thought|thoughts|thinking)>/gi,(e,s,r)=>D(r,s)?e:""),a=a.replace(Z,(e,s,r,l)=>!j&&D(l,r)?e:""),a&&a.includes("[tool:")&&(a=a.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[tool:[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(e,s,r)=>r&&r.includes("[tool:")?r.trim():e),j&&(a=a.replace(/```(?:tool|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(e,s)=>s.includes("[tool:")?s.trim():e))));let d="tool:functions.",y="agent:generalist.";if(x&&(a.toLowerCase().includes(d)||a.toLowerCase().includes(y)))for(;;){let e=a.toLowerCase(),s=e.indexOf(d),r=e.indexOf(y),l=d,i=s;if((s===-1||r!==-1&&r<s)&&(l=y,i=r),i===-1)break;if(!j&&D(a,i)){let c=i+l.length,C=e.indexOf(d,c),w=e.indexOf(y,c);if(C===-1&&w===-1)break;let I=-1,L=0;for(;;){let g=e.indexOf(d,L),m=e.indexOf(y,L),F=-1,A=d;if(g===-1&&m===-1)break;if(g===-1||m!==-1&&m<g?(F=m,A=y):F=g,!D(a,F)){I=F,l=A;break}L=F+A.length}if(I===-1)break;i=I}let $=i,b=!1,k=i-1;for(;k>=0&&/\s/.test(a[k]);)k--;k>=0&&a[k]==="["&&($=k,b=!0);let u=0,S=!1,n=null,f=i;for(;f<a.length;){let c=a[f];if(!n&&(c==="'"||c==='"'||c==="`")?n=c:n&&c===n&&a[f-1]!=="\\"&&(n=null),n||(c==="("?(u++,S=!0):c===")"&&u--),S&&u===0&&!n){let C=f;if(b){let w=f+1;for(;w<a.length&&/\s/.test(a[w]);)w++;w<a.length&&a[w]==="]"&&(C=w)}a=a.substring(0,$)+a.substring(C+1);break}if(f++,f===a.length)return S&&u>0&&(a=a.substring(0,$)),a}}return a=a.replace(J,""),a=a.replace(Q,e=>{let s=e.toLowerCase();return s.includes("leftrightarrow")?"\u2194":s.includes("rightarrow")?"\u2192":s.includes("leftarrow")?"\u2190":s.includes("uparrow")?"\u2191":s.includes("downarrow")?"\u2193":e}),a=a.replace(tt,e=>q[e.toLowerCase()]||e),a.trim()},ut=()=>{B.clear(),P.clear()};export{R as a,v as b,rt as c,st as d,ot as e,lt as f,at as g,ct as h,ft as i,K as j,z as k,ht as l,j as m,et as n,ut as o};
@@ -1,15 +0,0 @@
1
- import{a as P}from"./chunk-FDNLMLIM.js";import{a as I}from"./chunk-Y5JU726N.js";import r from"fs";import g from"path";var z=a=>{if(!a)return null;let i=a.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!i)return null;let e=i[1];if((i[2]||"").trim().length===0)return null;let n="",c=e.match(/^name:\s*(.+)$/m);return c&&(n=c[1].trim().replace(/^["']|["']$/g,"")),n?{name:n}:null},A=a=>{let i=[];if(!a||!r.existsSync(a))return i;let e=(f,n=0)=>{if(!(n>5))try{let c=r.readdirSync(f,{withFileTypes:!0});for(let s of c){let o=g.join(f,s.name),l=s.name.toLowerCase();s.isFile()?l==="skill.md"&&i.push(o):s.isDirectory()&&(n===0?(l==="skills"||l===".skills"||l==="skill"||l===".skill")&&e(o,n+1):e(o,n+1))}}catch{}};return e(a,0),i},X=a=>a.replace(/^(\s*---\r?\n)([\s\S]*?)(\r?\n---)/,(i,e,f,n)=>{let c=f.split(`
2
- `),s=[],o=!1;for(let l of c){if(/^\s*description\s*:/i.test(l)){o=!0;continue}if(o){if(/^\s+/.test(l))continue;o=!1}s.push(l)}return`${e}${s.join(`
3
- `)}${n}`}),T=(a,i)=>{if(!i)return null;let e=g.join(a,i);if(r.existsSync(e))try{if(r.statSync(e).isFile())return e}catch{}if(!i.toLowerCase().endsWith(".md")){let s=g.join(a,`${i}.md`);if(r.existsSync(s))try{if(r.statSync(s).isFile())return s}catch{}}let f=i.replace(/\\/g,"/").split("/").filter(Boolean),n=a,c=!0;for(let s=0;s<f.length;s++){let o=f[s].toLowerCase(),l=s===f.length-1;try{if(!r.existsSync(n)||!r.statSync(n).isDirectory()){c=!1;break}let S=r.readdirSync(n).find(b=>{let F=b.toLowerCase();return!!(F===o||l&&!o.endsWith(".md")&&F===`${o}.md`)});if(!S){c=!1;break}let w=g.join(n,S);if(l){if(r.statSync(w).isFile())return w;c=!1}else n=w}catch{c=!1;break}}if(f.length===1){let s=f[0],o=["references","reference","scripts","script","examples","example","resources","resource"];for(let l of o){let h=g.join(a,l);if(r.existsSync(h)){let S=T(h,s);if(S)return S}}}return null},K=async(a,i={})=>{let{path:e,StartLine:f,EndLine:n,start_line:c,end_line:s,startLine:o,endLine:l}=I(a),h=parseInt(f||c||o),S=parseInt(n||s||l),w=!isNaN(h),b=!isNaN(S),F=h||1,v=S||(h?h+800:800);if(!e)return'ERROR: Missing "path" argument for ReadFile.';if(e.trim().toLowerCase().startsWith("#skill")){let m=e.trim().replace(/\\/g,"/").replace(/^#skills?\/?/i,"").split("/").filter(Boolean),N="project",u="",d="";if(m[0]?.toLowerCase()==="global"||m[0]?.toLowerCase()==="project"?(N=m[0].toLowerCase(),u=m[1],d=m.slice(2).join("/")):(u=m[0],d=m.slice(1).join("/")),!u)return`ERROR: Missing skill name in path [${e}].`;let R=N==="global"?P:process.cwd(),k=A(R),L=null;for(let t of k)try{let p=r.readFileSync(t,"utf8"),$=z(p),x=g.basename(g.dirname(t)).toLowerCase();if($?.name&&$.name.toLowerCase()===u.toLowerCase()||x===u.toLowerCase()||t.toLowerCase()===g.join(R,"skill.md").toLowerCase()&&u.toLowerCase()==="skill"){L=t;break}}catch{}if(!L)return`No '${u}' exist in given scope.`;let C=g.dirname(L),E=L,M=!0;if(d){let t=T(C,d);if(!t)return`No such file or reference '${d}' exist for skill '${u}'. It could be standard file path?`;E=t,M=!1}try{let t=r.readFileSync(E,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1)),t=t.replace(/\r\n/g,`
4
- `).replace(/\r/g,`
5
- `),M&&(t=X(t));let p=t.split(`
6
- `),$=p.length,x=w?Math.max(0,F-1):0,j=b?Math.min($,v):$,W=p.slice(x,j),O=e.replace(/\\/g,"/").toLowerCase(),U=`${O.includes("#skill/global/fluxflow")||O.includes("#skills/global/fluxflow")?"DOCs":"Skill"}: [${e.replace(/\\/g,"/")}]`,_=W.map(B=>B.trimEnd()).join(`
7
- `);return`${U}
8
-
9
- ${_}`}catch(t){let p=t instanceof Error?t.message:String(t);return`ERROR: Failed to read skill file [${e}]: ${p}`}}try{let y=g.resolve(process.cwd(),e);if(!r.existsSync(y))return`ERROR: File [${e}] does not exist.`;if(r.statSync(y).isDirectory())return`ERROR: Path [${e}] is a directory. Use list_files instead.`;let m=g.extname(e).toLowerCase();if([".mp4",".mkv",".avi",".mov",".webm",".flv",".wmv",".mpeg",".mpg"].includes(m))return`ERROR: Unable to read. Type ${m.slice(1).toUpperCase()} not supported`;let u={".pdf":"application/pdf",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};if(u[m]){if(!(i.isMultiModal!==!1))return`ERROR: Multimodality is not supported for the current model. Unable to load [${e}].`;let x=r.readFileSync(y).toString("base64"),j=u[m];return{text:`[BINARY FILE]: ${e} (${j}) - Loaded as multimodal part.`,binaryPart:{inlineData:{data:x,mimeType:j}}}}let d=r.readFileSync(y,"utf8");d.startsWith("\uFEFF")&&(d=d.slice(1)),d=d.replace(/\r\n/g,`
10
- `).replace(/\r/g,`
11
- `);let R=d.split(`
12
- `),k=R.length;!w&&!b&&k>800&&(F=1,v=50);let L=Math.max(0,F-1),C=Math.min(k,v),E=R.slice(L,C),M=`File: [${e}] (Showing lines ${L+1}-${C} of ${k}).`,t=E.map((p,$)=>`${String(L+$+1).padStart(4)}: ${p.trimEnd()}`).join(`
13
- `);return`${M}
14
-
15
- ${t}`}catch(y){let D=y instanceof Error?y.message:String(y);return`ERROR: Failed to read file [${e}]: ${D}`}};export{K as a};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-UYHPCXNG.js";import"./chunk-FDNLMLIM.js";import"./chunk-Y5JU726N.js";export{a as view_file};