fluxflow-cli 4.32.1 → 4.33.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.
@@ -38,4 +38,4 @@ ${n}
38
38
  `),$=[];h.forEach(n=>{v(n,F).split(`
39
39
  `).forEach(f=>$.push(f))}),$.forEach((n,a)=>{let f=a===$.length-1;u(x(`${t.id}-${a}`,"think-line",n,{}),f)}),t.isStreaming||(o(),C.push({key:`${t.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let h=p.split(`
40
40
  `),$=!1,n=[],a=!1,f="",S=0,k=0,I=[];h.forEach(E=>{let m=E.trim();m.startsWith("```")?(a=!a,I.push(E)):a||m.startsWith("|")?I.push(E):v(E,g).split(`
41
- `).forEach(M=>I.push(M))}),a=!1,I.forEach((E,m)=>{let w=m===I.length-1,M=E.trim().startsWith("|"),T=E.trim().startsWith("```");if(a)T?(a=!1,u(x(`${t.id}-code-close-${k}`,"code-fence-close","",{}),w)):(S++,u(x(`${t.id}-code-line-${m}`,"code-line",E,{lineNum:S,lang:f}),w));else if(T)a=!0,k=m,S=0,f=E.trim().replace(/^```/,"").trim(),u(x(`${t.id}-code-open-${m}`,"code-fence-open",f,{}),w);else if(M){if($||($=!0,n=[]),n.push(E),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 A=y.map(_=>_.trim());u(x(`${t.id}-table-hdr-${m}`,"table-header",b,{colHeaders:A,colCount:A.length}),w)}else if(n.length>2){let b=E.split("|");b[0]!==void 0&&b[0].trim()===""&&b.shift(),b.length>0&&b[b.length-1].trim()===""&&b.pop();let y=b.map(P=>P.trim()),A=n[0].split("|");A[0]!==void 0&&A[0].trim()===""&&A.shift(),A.length>0&&A[A.length-1].trim()===""&&A.pop();let _=A.map(P=>P.trim()),N=Math.max(1,_.length);u(x(`${t.id}-table-row-${m}`,"table-row",E,{cells:y,colHeaders:_,colCount:N,rowIndex:n.length-3}),w)}w&&!t.isStreaming&&(o(),u(x(`${t.id}-table-end-${m}`,"table-close","",{}),!0))}else $&&(u(x(`${t.id}-table-end-${m}`,"table-close","",{}),w),$=!1,n=[]),u(x(`${t.id}-${m}`,"agent-line",E,{}),w)}),!t.isStreaming&&t.workedDuration&&(o(),C.push(x(`${t.id}-worked-duration`,"worked-duration","")))}t.isStreaming&&i.length>0?e=i.length===1?i[0]:{key:`${t.id||"x"}-chunk-active-${i[0].key}`,type:"chunk",blocks:i}:o();let L={completed:C,active:e?[e]:[]};if(t.isStreaming){let h=new Map;if(C.forEach($=>U($,h)),e&&U(e,h),O.set(c,{text:p,blocksMap:h}),O.size>H){let $=O.keys().next().value;O.delete($)}}else{if(B.set(d,L),B.size>H){let h=B.keys().next().value;B.delete(h)}O.delete(c)}return L},Z={},J=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,D=(t,r)=>{let d=!1,p=!1,c=0;for(;c<r;){if(t.startsWith("```",c)){p=!p,c+=3;continue}!p&&t[c]==="`"&&(c===0||t[c-1]!=="\\")&&(d=!d),c++}return p||d},Q=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[(?:TOOL|ACTION) RESULTS?\]:?\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|ACTION).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,tt=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,et=/\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,nt=(t,r="agent")=>{if(!t)return t;let d=r===!0||r==="think",p=r===!1||r==="agent",c=t.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");if(d)return c.replace(/^<(think|thought|thoughts|thinking)>/gi,"").replace(/<\/(think|thought|thoughts|thinking)>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let l=c;p&&(l=l.replace(/<\/?(?:think|thought|thoughts|thinking)>/gi,(e,i,s)=>D(s,i)?e:""),l=l.replace(J,(e,i,s,o)=>!j&&D(o,s)?e:""),l&&(l.includes("[tool:")||l.includes("[action:"))&&(l=l.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(e,i,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():e),j&&(l=l.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(e,i)=>i.includes("[tool:")||i.includes("[action:")?i.trim():e))));let x="tool:",C="action:";if(p&&(l.toLowerCase().includes(x)||l.toLowerCase().includes(C)))for(;;){let e=l.toLowerCase(),i=e.indexOf(x),s=e.indexOf(C),o=x,u=i;if((i===-1||s!==-1&&s<i)&&(o=C,u=s),u===-1)break;if(!j&&D(l,u)){let f=-1,S=0;for(;;){let k=e.indexOf(x,S),I=e.indexOf(C,S),E=-1,m=x;if(k===-1&&I===-1)break;if(k===-1||I!==-1&&I<k?(E=I,m=C):E=k,!D(l,E)){f=E,o=m;break}S=E+m.length}if(f===-1)break;u=f}let g=u,F=!1,L=u-1;for(;L>=0&&/\s/.test(l[L]);)L--;L>=0&&l[L]==="["&&(g=L,F=!0);let h=0,$=!1,n=null,a=u;for(;a<l.length;){let f=l[a];if(!n&&(f==="'"||f==='"'||f==="`")?n=f:n&&f===n&&l[a-1]!=="\\"&&(n=null),n||(f==="("?(h++,$=!0):f===")"&&h--),$&&h===0&&!n){let S=a;if(F){let k=a+1;for(;k<l.length&&/\s/.test(l[k]);)k++;k<l.length&&l[k]==="]"&&(S=k)}l=l.substring(0,g)+l.substring(S+1);break}if(a++,a===l.length)return $&&h>0&&(l=l.substring(0,g)),l}}return l=l.replace(Q,""),l=l.replace(tt,e=>{let i=e.toLowerCase();return i.includes("leftrightarrow")?"\u2194":i.includes("rightarrow")?"\u2192":i.includes("leftarrow")?"\u2190":i.includes("uparrow")?"\u2191":i.includes("downarrow")?"\u2193":e}),l=l.replace(et,e=>Z[e.toLowerCase()]||e),l.trim()},pt=()=>{B.clear(),O.clear()};export{R as a,v as b,ot as c,lt as d,ct as e,at as f,ft as g,ut as h,ht as i,Y as j,X as k,dt as l,j as m,nt as n,pt as o};
41
+ `).forEach(M=>I.push(M))}),a=!1,I.forEach((E,m)=>{let w=m===I.length-1,M=E.trim().startsWith("|"),T=E.trim().startsWith("```");if(a)T?(a=!1,u(x(`${t.id}-code-close-${k}`,"code-fence-close","",{}),w)):(S++,u(x(`${t.id}-code-line-${m}`,"code-line",E,{lineNum:S,lang:f}),w));else if(T)a=!0,k=m,S=0,f=E.trim().replace(/^```/,"").trim(),u(x(`${t.id}-code-open-${m}`,"code-fence-open",f,{}),w);else if(M){if($||($=!0,n=[]),n.push(E),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 A=y.map(_=>_.trim());u(x(`${t.id}-table-hdr-${m}`,"table-header",b,{colHeaders:A,colCount:A.length}),w)}else if(n.length>2){let b=E.split("|");b[0]!==void 0&&b[0].trim()===""&&b.shift(),b.length>0&&b[b.length-1].trim()===""&&b.pop();let y=b.map(P=>P.trim()),A=n[0].split("|");A[0]!==void 0&&A[0].trim()===""&&A.shift(),A.length>0&&A[A.length-1].trim()===""&&A.pop();let _=A.map(P=>P.trim()),N=Math.max(1,_.length);u(x(`${t.id}-table-row-${m}`,"table-row",E,{cells:y,colHeaders:_,colCount:N,rowIndex:n.length-3}),w)}w&&!t.isStreaming&&(o(),u(x(`${t.id}-table-end-${m}`,"table-close","",{}),!0))}else $&&(u(x(`${t.id}-table-end-${m}`,"table-close","",{}),w),$=!1,n=[]),u(x(`${t.id}-${m}`,"agent-line",E,{}),w)}),!t.isStreaming&&t.workedDuration&&(o(),C.push(x(`${t.id}-worked-duration`,"worked-duration","")))}t.isStreaming&&i.length>0?e=i.length===1?i[0]:{key:`${t.id||"x"}-chunk-active-${i[0].key}`,type:"chunk",blocks:i}:o();let L={completed:C,active:e?[e]:[]};if(t.isStreaming){let h=new Map;if(C.forEach($=>U($,h)),e&&U(e,h),O.set(c,{text:p,blocksMap:h}),O.size>H){let $=O.keys().next().value;O.delete($)}}else{if(B.set(d,L),B.size>H){let h=B.keys().next().value;B.delete(h)}O.delete(c)}return L},Z={},J=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,D=(t,r)=>{let d=!1,p=!1,c=0;for(;c<r;){if(t.startsWith("```",c)){p=!p,c+=3;continue}!p&&t[c]==="`"&&(c===0||t[c-1]!=="\\")&&(d=!d),c++}return p||d},Q=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[(?:TOOL|ACTION) RESULTS?\]:?\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|ACTION).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,tt=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,et=/\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,nt=(t,r="agent")=>{if(!t)return t;let d=r===!0||r==="think",p=r===!1||r==="agent",c=t.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");if(d)return c.replace(/^<(think|thought|thoughts|thinking)>/gi,"").replace(/<\/(think|thought|thoughts|thinking)>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let l=c;p&&(l=l.replace(/<\/?(?:think|thought|thoughts|thinking)>/gi,(e,i,s)=>D(s,i)?e:""),l=l.replace(J,(e,i,s,o)=>!j&&D(o,s)?e:""),l&&(l.includes("[tool:")||l.includes("[action:"))&&(l=l.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(e,i,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():e),j&&(l=l.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(e,i)=>i.includes("[tool:")||i.includes("[action:")?i.trim():e))));let x="tool:",C="action:";if(p&&(l.toLowerCase().includes(x)||l.toLowerCase().includes(C)))for(;;){let e=l.toLowerCase(),i=e.indexOf(x),s=e.indexOf(C),o=x,u=i;if((i===-1||s!==-1&&s<i)&&(o=C,u=s),u===-1)break;if(!j&&D(l,u)){let f=-1,S=0;for(;;){let k=e.indexOf(x,S),I=e.indexOf(C,S),E=-1,m=x;if(k===-1&&I===-1)break;if(k===-1||I!==-1&&I<k?(E=I,m=C):E=k,!D(l,E)){f=E,o=m;break}S=E+m.length}if(f===-1)break;u=f}let g=u,F=!1,L=u-1;for(;L>=0&&/\s/.test(l[L]);)L--;L>=0&&l[L]==="["&&(g=L,F=!0);let h=0,$=!1,n=null,a=u;for(;a<l.length;){let f=l[a];if(!n&&(f==="'"||f==='"'||f==="`")?n=f:n&&f===n&&l[a-1]!=="\\"&&(n=null),n||(f==="("?(h++,$=!0):f===")"&&h--),$&&h===0&&!n){let S=a;if(F){let k=a+1;for(;k<l.length&&/\s/.test(l[k]);)k++;k<l.length&&l[k]==="]"&&(S=k)}l=l.substring(0,g)+l.substring(S+1);break}if(a++,a===l.length)return $&&h>0&&(l=l.substring(0,g)),l}}return l=l.replace(Q,""),l=l.replace(tt,e=>{let i=e.toLowerCase();return i.includes("leftrightarrow")?"\u2194":i.includes("rightarrow")?"\u2192":i.includes("leftarrow")?"\u2190":i.includes("uparrow")?"\u2191":i.includes("downarrow")?"\u2193":e}),l=l.replace(et,e=>Z[e.toLowerCase()]||e),l.trim()},pt=()=>{B.clear(),O.clear()};export{R as a,v as b,ot as c,lt as d,ct as e,at as f,ft as g,ut as h,ht as i,Y as j,X as k,dt as l,nt as m,pt as n};
@@ -0,0 +1,33 @@
1
+ import{a as b,b as C}from"./chunk-U2NRX2PX.js";import{a as S}from"./chunk-Y5JU726N.js";import{spawn as A}from"child_process";var P=null;try{let f=await import("node-pty");P=f.default||f}catch{}var I=!!P,y=f=>typeof f!="string"?f:f.replace(/(?:\u001b][\s\S]*?(?:\u0007|\u001b\\))|(?:[\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=a=>{for(let e=0;e<a.length;e++){let t=a[e];if(t===`
2
+ `)for(n++,o=0;n>=p.length;)p.push([]);else if(t==="\r")o=0;else{for(;n>=p.length;)p.push([]);let s=p[n];for(;o>s.length;)s.push(" ");s[o]=t,o++}}};for(;(h=w.exec(f))!==null;){d(f.substring(g,h.index));let a=h[1],e=h[2],t=a?a.split(";").map(Number):[];if(e==="A"){let s=t[0]||1;n=Math.max(0,n-s)}else if(e==="B"){let s=t[0]||1;for(n=n+s;n>=p.length;)p.push([])}else if(e==="C"){let s=t[0]||1;o=o+s}else if(e==="D"){let s=t[0]||1;o=Math.max(0,o-s)}else if(e==="G"){let s=(t[0]||1)-1;o=Math.max(0,s)}else if(e==="H"||e==="f"){let s=(t[0]||1)-1,r=(t[1]||1)-1;for(n=Math.max(0,s),o=Math.max(0,r);n>=p.length;)p.push([])}else if(e==="K"){let s=t[0]||0;if(n<p.length){let r=p[n];if(s===0)r.length=o;else if(s===1)for(let c=0;c<o&&c<r.length;c++)r[c]=" ";else s===2&&(r.length=0)}}else if(e==="J"){let s=t[0]||0;(s===2||s===3)&&(p.length=0,p.push([]),n=0,o=0)}g=w.lastIndex}d(f.substring(g));let O=p.map(a=>a.join(""));for(;O.length>0&&O[O.length-1]==="";)O.pop();return O.join(`
3
+ `)},x=null,k=!1,_=f=>{try{x&&(k&&typeof x.write=="function"?x.write(f):x.stdin&&x.stdin.writable&&x.stdin.write(f))}catch{}},W=()=>{if(x){try{k&&typeof x.destroy=="function"?x.destroy():typeof x.kill=="function"&&(process.platform==="win32"?A("taskkill",["/pid",x.pid,"/f","/t"]):x.kill("SIGKILL"))}catch{}x=null,k=!1}},T=(f,p=!1)=>{if(process.platform!=="win32"||process.env.ADJUST_WINDOWS_COMMAND!=="true")return f;let n=[],o="",w=null,g=!1;for(let e=0;e<f.length;e++){let t=f[e];if(g){o+=t,g=!1;continue}if(t==="\\"){if(!w&&f[e+1]===" "){o+=" ",e++;continue}o+=t,g=!0;continue}w?(t===w&&(w=null),o+=t):t==='"'||t==="'"?(w=t,o+=t):t===";"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push(p?";":"&")):t==="&"&&!o.includes("://")?f[e+1]==="&"?(o.length>0&&(n.push(o),o=""),n.push("&&"),e++):o.endsWith("2>")&&f[e+1]==="1"?(n.push("2>&1"),o="",e++):(o.length>0&&(n.push(o),o=""),n.push("&")):t==="|"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push("|")):(t===">"||t==="<")&&(e===0||/\s|['"]/.test(f[e-1]||""))?(o.length>0&&(n.push(o),o=""),t===">"&&f[e+1]===">"?(n.push(">>"),e++):n.push(t)):/\s/.test(t)?o.length>0&&(n.push(o),o=""):o+=t}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 t=n[e];if(t==="mkdir"&&p&&b()){let s=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;c!=="-p"&&c!=="--parents"&&c!=="-v"&&c!=="--verbose"&&s.push(c),r++}if(s.length>0){let c=s.map(i=>{let u=i.replace(/^['"]|['"]$/g,""),l=i;return h(u)&&(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(t==="rm"&&p&&b()){let s=[],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:s.push(l),i++}let u=["Remove-Item"];if(r&&u.push("-Recurse"),c&&u.push("-Force"),s.length>0){let l=s.map(m=>{let R=m.replace(/^['"]|['"]$/g,""),$=m;return h(R)&&($=m.replace(/\//g,"\\")),$});u.push("-Path",l.join(","))}d.push(...u),e=i-1;continue}if(t==="cp"&&p&&b()){let s=[],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:s.push(l),i++}let u=["Copy-Item"];if(r&&u.push("-Recurse"),c&&u.push("-Force"),s.length>0){let l=s.map(m=>{let R=m.replace(/^['"]|['"]$/g,""),$=m;return h(R)&&($=m.replace(/\//g,"\\")),$});if(l.length>1){let m=l.pop();u.push("-Path",l.join(","),"-Destination",m)}else u.push("-Path",l[0])}d.push(...u),e=i-1;continue}if(t==="touch"&&p&&b()){let s=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;s.push(c),r++}if(s.length>0){let i=`(${s.map(u=>{let l=u.replace(/^['"]|['"]$/g,""),m=u;return h(l)&&(m=u.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(t==="|"&&n[e+1]==="tee"){n[e+2]==="-a"?(d.push(">>"),e+=2):(d.push(">"),e+=1);continue}if(t==="|"&&n[e+1]==="cat"&&n[e+2]===">"){d.push(">"),e+=2;continue}if(t==="|"){let s=n[e+1];if(s){let r=s.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(t)}let O=!1,a=d.map(e=>{if(e==="echo")return O=!0,e;[">",">>","<","&","&&","|","||",";"].includes(e)&&(O=!1);let s=/^['"]|['"]$/.test(e),r=e;O&&s&&(r=e.replace(/^['"]|['"]$/g,""));let c=/^['"]|['"]$/.test(r),i=r.replace(/^['"]|['"]$/g,"");h(i)&&(r=r.replace(/\//g,"\\"));let u=r.replace(/^['"]|['"]$/g,"");return u.includes(" ")&&!c&&(r=`"${u}"`),r});if(p){let e="",t=0;for(let s=0;s<a.length;s++){let r=a[s];r==="&&"?(e+="; if ($?) {",t++):r===";"?(e+=" }".repeat(t)+";",t=0):(e&&!e.endsWith(" ")&&!e.endsWith("{")&&(e+=" "),e+=r)}return e+=" }".repeat(t),e}return a.join(" ")},M=async(f,p={})=>{let{command:n}=S(f),{onChunk:o}=p;if(!n)return'ERROR: Missing "command" argument for Run.';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=a=>{let e=a==="pwsh"||a==="powershell",t=T(n,e),s;w?a==="pwsh"?s="pwsh.exe":a==="powershell"?s="powershell.exe":s="cmd.exe":s=process.env.SHELL||"bash";let r=w?e?["-NoProfile","-Command",t]:["/c",t]:["-c",t];if(g.networkAccess===!1&&!w){let c=s,i=[...r];if(process.platform==="linux")s="unshare",r=["-n","-r",c,...i];else if(process.platform==="darwin"){let u=`(version 1)
4
+ (allow default)
5
+ (deny network-outbound)
6
+ (allow network-outbound (remote ip "localhost:*"))
7
+ (allow network-outbound (remote ip "127.0.0.1:*"))
8
+ `;s="sandbox-exec",r=["-p",u,c,...i]}}if(P)try{let c=P.spawn(s,r,{name:"xterm-256color",cols:p.cols||120,rows:p.rows||30,cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...h}});x=c,k=!0;let i="",u=!1;return c.onData(l=>{if(!u){i+=l,o&&o(l);let m=y(i);/(?:Network:\s+use\s+--host\s+to|Network:\s+Type\s+--host\s+to|Local:\s+http:\/\/localhost:\d+|ready in \d+\s*ms|Compiled successfully|Development server is running|Listening on:)/i.test(m)&&(u=!0,setTimeout(()=>d(`Dev server started successfully in background.
9
+
10
+ ${m}`),500))}}),c.onExit(({exitCode:l})=>{if(u)return;x=null;let m=E(i||""),R=y(m).replace(/\n{3,}/g,`
11
+
12
+ `)||"Command executed with no output.";d(l!==0?`ERROR: Command [${n}] failed with exit code [${l}].
13
+
14
+ ${R}`:`Command [${n}] completed.
15
+
16
+ ${R}`)}),!0}catch(c){return w&&(a==="pwsh"||a==="powershell")&&c.code==="ENOENT"?!1:(v(d,t,n,h,o,a,g),!0)}else return v(d,t,n,h,o,a,g),!0};if(w){let a=C();O(a)||(a==="pwsh"&&!O("powershell")||a==="powershell")&&O("cmd")}else O("bash")})},v=(f,p,n,o,w,g="powershell",h={})=>{let d=process.platform==="win32",O=g==="pwsh"||g==="powershell",a;d?g==="pwsh"?a="pwsh.exe":g==="powershell"?a="powershell.exe":a="cmd.exe":a=process.env.SHELL||"bash";let e=d?O?["-NoProfile","-Command",p]:["/c",p]:["-c",p];if(h.networkAccess===!1&&!d){let i=a,u=[...e];if(process.platform==="linux")a="unshare",e=["-n","-r",i,...u];else if(process.platform==="darwin"){let l=`(version 1)
17
+ (allow default)
18
+ (deny network-outbound)
19
+ (allow network-outbound (remote ip "localhost:*"))
20
+ (allow network-outbound (remote ip "127.0.0.1:*"))
21
+ `;a="sandbox-exec",e=["-p",l,i,...u]}}let t=d?A(a,e,{cwd:process.cwd(),env:{...process.env,...o}}):A(a,e,{cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...o}});x=t,k=!1,t.stdin&&t.stdin.on("error",()=>{x=null});let s="",r="",c=!1;t.stdout.on("data",i=>{if(!c){let u=i.toString();s+=u,w&&w(u);let l=y(s);/(?:Network:\s+use\s+--host\s+to|Network:\s+Type\s+--host\s+to|Local:\s+http:\/\/localhost:\d+|ready in \d+\s*ms|Compiled successfully|Development server is running|Listening on:)/i.test(l)&&(c=!0,setTimeout(()=>f(`Dev server started successfully in background.
22
+
23
+ ${l}`),500))}}),t.stderr.on("data",i=>{if(!c){let u=i.toString();r+=u,w&&w(u)}}),t.on("close",i=>{if(c)return;x=null;let u=[],l=E(s),m=E(r);l&&u.push(`STDOUT:
24
+ ${l}`),m&&u.push(`STDERR:
25
+ ${m}`),i!==0&&u.push(`EXIT CODE: ${i}`);let R=u.join(`
26
+
27
+ `)||"Command executed with no output.",$=y(R).replace(/\n{3,}/g,`
28
+
29
+ `);f(i!==0?`ERROR: Command [${n}] failed with exit code [${i}].
30
+
31
+ ${$}`:`Command [${n}] completed.
32
+
33
+ ${$}`)}),t.on("error",i=>{if(d&&i.code==="ENOENT"){if(g==="pwsh"){let l=T(n,!0);return v(f,l,n,o,w,"powershell",h)}else if(g==="powershell"){let l=T(n,!1);return v(f,l,n,o,w,"cmd",h)}}x=null;let u=i instanceof Error?i.message:String(i);f(`ERROR: Failed to start command [${n}]: ${u}`)})};export{I as a,y as b,E as c,x as d,k as e,_ as f,W as g,T as h,M as i};
@@ -0,0 +1,4 @@
1
+ import{exec as P}from"child_process";import y from"util";var h=y.promisify(P);async function C(){let s=new Map,m=process.platform==="win32";try{if(m){let{stdout:i}=await h("netstat -ano",{maxBuffer:10485760,windowsHide:!0}),u=i.split(`
2
+ `);for(let l of u){let n=l.trim().split(/\s+/);if(n.length>=5&&n[0].toUpperCase()==="TCP"&&n[3].toUpperCase()==="LISTENING"){let c=n[1],r=parseInt(n[4],10);if(!isNaN(r)){let a=c.lastIndexOf(":");if(a!==-1){let d=c.slice(a+1);d&&!s.has(r)&&s.set(r,`http://localhost:${d}`)}}}}}else try{let{stdout:i}=await h("lsof -iTCP -sTCP:LISTEN -P -n",{maxBuffer:10485760}),u=i.split(`
3
+ `).slice(1);for(let l of u){let n=l.trim().split(/\s+/);if(n.length>=9){let c=parseInt(n[1],10),r=n[8],a=r.lastIndexOf(":");if(a!==-1&&!isNaN(c)&&!s.has(c)){let d=r.slice(a+1);s.set(c,`http://localhost:${d}`)}}}}catch{}}catch{}return s}async function T(s=process.pid){let m=process.platform==="win32",i=[],u=C();if(m)try{let e='powershell -NoProfile -Command "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine | ConvertTo-Json -Compress"',{stdout:f}=await h(e,{maxBuffer:10485760,windowsHide:!0});if(f&&f.trim()){let t=JSON.parse(f.trim());i=(Array.isArray(t)?t:[t]).map(p=>({pid:Number(p.ProcessId),ppid:Number(p.ParentProcessId),name:p.Name||"Unknown",cmd:p.CommandLine||p.Name||""}))}}catch{return[{pid:s,ppid:0,name:"node.exe",cmd:process.title||"node",isRoot:!0}]}else try{let{stdout:e}=await h("ps -axo pid,ppid,comm,args",{maxBuffer:10485760});i=e.trim().split(`
4
+ `).slice(1).map(t=>{let o=t.trim().split(/\s+/),p=Number(o[0]),I=Number(o[1]),N=o[2]||"Unknown",g=o.slice(3).join(" ")||N;return{pid:p,ppid:I,name:N,cmd:g}}).filter(t=>!isNaN(t.pid))}catch{return[{pid:s,ppid:0,name:"node",cmd:process.title||"node",isRoot:!0}]}let l=await u,n=new Map,c=new Map;for(let e of i)n.set(e.pid,e),c.has(e.ppid)||c.set(e.ppid,[]),c.get(e.ppid).push(e.pid);let r=[],a=n.get(s)||{pid:s,ppid:0,name:m?"node.exe":"node",cmd:process.title||"node"};a.isRoot=!0,l.has(s)&&(a.url=l.get(s)),r.push(a);let d=[s],w=new Set([s]),x=new Set(["conhost.exe","cmd.exe","powershell.exe","pwsh.exe","wmic.exe"]);for(;d.length>0;){let e=d.shift(),f=c.get(e)||[];for(let t of f)if(!w.has(t)){w.add(t);let o=n.get(t);if(o){o.isRoot=!1,l.has(t)&&(o.url=l.get(t));let p=(o.name||"").toLowerCase();(o.url||!x.has(p))&&r.push(o),d.push(t)}}}return r}async function $(s){if(!s||isNaN(s))return{success:!1,message:`Invalid PID: ${s}`};let m=process.platform==="win32";try{return m?await h(`taskkill /pid ${s} /f /t`,{windowsHide:!0}):process.kill(s,"SIGKILL"),{success:!0,message:`Process ${s} terminated successfully.`}}catch(i){return{success:!1,message:`Failed to terminate process ${s}: ${i.message}`}}}export{T as a,$ as b};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-QXN5B2BR.js";import"./chunk-U2NRX2PX.js";import"./chunk-Y5JU726N.js";export{d as activeChildProcess,h as adjustWindowsCommand,c as cleanTerminalOutput,i as exec_command,e as isActiveCommandPty,a as isPtyAvailable,b as stripAnsi,g as terminateActiveCommand,f as writeToActiveCommand};
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-PB7NN3GI.js";import"./chunk-U2NRX2PX.js";import"./chunk-Y5JU726N.js";export{d as activeChildProcess,h as adjustWindowsCommand,c as cleanTerminalOutput,i as exec_command,e as isActiveCommandPty,a as isPtyAvailable,b as stripAnsi,g as terminateActiveCommand,f as writeToActiveCommand};
@@ -6,7 +6,7 @@ import{d as $}from"./chunk-DSVLWYIT.js";import R from"fs-extra";import y from"pa
6
6
  `).trim());let r=[];for(let s of i){if(!s)continue;let c=s.split(`
7
7
  `).map(e=>e.trimEnd()),a=c[0]||"";if(!/\bERROR\b/i.test(s))continue;let T=a.match(/\[(.*?)\]/),d=T?T[1]:null,L="ERROR";/CRITICAL\s+ERROR/i.test(a)&&(L="CRITICAL ERROR");let E="";if(T){let e=a.indexOf("]:");e!==-1?E=a.substring(e+2).trim():E=a.replace(o,"").replace(/\[.*?\]/,"").replace(/^:\s*/,"").trim()}else E=a.replace(o,"").replace(/^:\s*/,"").trim();if(c.length>1){let e=c.slice(1).join(`
8
8
  `).trim();e&&(E=E?`${E}
9
- ${e}`:e)}if(E){let e=/\bjanitor\b/i.test(s)?"Memory":u;r.push({timestamp:d||(p?new Date(p).toLocaleString():"Unknown Time"),level:L,source:e,message:E})}}return r},A=async(l=process.cwd())=>{let u=`fluxflow-error-${Date.now()}.txt`,p=y.join(l,u),n=async e=>{if(!await R.pathExists(e))return[];let h=await R.readdir(e),f=[];for(let g of h){let x=y.join(e,g),w=await R.stat(x);if(w.isDirectory()){let C=await n(x);f=f.concat(C)}else(g.endsWith(".log")||g.endsWith(".txt"))&&f.push({path:x,mtime:w.mtimeMs})}return f},i=await n($),t=[];for(let e of i)try{let h=await R.readFile(e.path,"utf8");if(h.trim()){let f=e.path.replace(/\\/g,"/").toLowerCase(),g="FluxFlow";f.includes("/janitor")||f.includes("janitor")?g="Memory":f.includes("/usage")||f.includes("usage")?g="Usage":!f.includes("/agent")&&!f.includes("agent")&&(g="Other");let x=j(h,g,e.mtime);t=t.concat(x)}}catch{}let o=[],O=new Set;for(let e of t){let h=`${e.source}::${e.timestamp}::${e.message.trim()}`;O.has(h)||(O.add(h),o.push(e))}let m=o.filter(e=>e.source==="FluxFlow"),r=o.filter(e=>e.source==="Memory"),s=o.filter(e=>e.source==="Usage"),c=o.filter(e=>!["FluxFlow","Memory","Usage"].includes(e.source)),a=(e,h,f)=>{let g=["================================================================================",`${e} (${h.length})`,"================================================================================"].join(`
9
+ ${e}`:e)}if(E){let e=/\bjanitor\b/i.test(s)?"Memory":u;r.push({timestamp:d||(p?new Date(p).toLocaleString():"Unknown Time"),level:L,source:e,message:E})}}return r},A=async(l=process.cwd())=>{let u=`fluxflow-error-${Date.now()}.txt`,p=y.join(l,u),n=async e=>{if(!await R.pathExists(e))return[];let h=await R.readdir(e),f=[];for(let g of h){if(g==="chats")continue;let x=y.join(e,g),w=await R.stat(x);if(w.isDirectory()){let C=await n(x);f=f.concat(C)}else(g.endsWith(".log")||g.endsWith(".txt"))&&f.push({path:x,mtime:w.mtimeMs})}return f},i=await n($),t=[];for(let e of i)try{let h=await R.readFile(e.path,"utf8");if(h.trim()){let f=e.path.replace(/\\/g,"/").toLowerCase(),g="FluxFlow";f.includes("/janitor")||f.includes("janitor")?g="Memory":f.includes("/usage")||f.includes("usage")?g="Usage":!f.includes("/agent")&&!f.includes("agent")&&(g="Other");let x=j(h,g,e.mtime);t=t.concat(x)}}catch{}let o=[],O=new Set;for(let e of t){let h=`${e.source}::${e.timestamp}::${e.message.trim()}`;O.has(h)||(O.add(h),o.push(e))}let m=o.filter(e=>e.source==="FluxFlow"),r=o.filter(e=>e.source==="Memory"),s=o.filter(e=>e.source==="Usage"),c=o.filter(e=>!["FluxFlow","Memory","Usage"].includes(e.source)),a=(e,h,f)=>{let g=["================================================================================",`${e} (${h.length})`,"================================================================================"].join(`
10
10
  `);if(h.length===0)return`${g}
11
11
  No ${f} error entries found.`;let x=h.map((w,C)=>{let F=`[${f} #${C+1}] ${w.timestamp} (${w.level})`,U=w.message.split(`
12
12
  `).map(I=>` ${I}`).join(`
@@ -0,0 +1,2 @@
1
+ import{a as A}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-JS5ZIGFR.js";import"./chunk-DSVLWYIT.js";var B=async function*(C,v,E,w,x,j,N,O,S=1){let a=v,m=null;if(typeof a=="string"){let t={};if(a.includes("::")){let e=a.indexOf("::"),n=a.slice(0,e).trim();n&&(t.only=[n]),a=a.slice(e+2).trim()}let d=["flex","standard","priority"],o={fp16:"fp16",f16:"fp16",fp8:"fp8",f8:"fp8",int8:"int8",in8:"int8",int4:"int4",in4:"int4"},s=["throughput","latency","price","ttft"];if(a.includes(":")){let e=a.split(":");for(;e.length>1;){let n=e[e.length-1].toLowerCase().trim();if(d.includes(n))t.service_tier=n,t.allow_fallbacks=!1,e.pop();else if(o[n])t.quantizations=[o[n]],t.allow_fallbacks=!1,e.pop();else if(s.includes(n))t.sort=n,t.allow_fallbacks=!1,e.pop();else break}a=e.join(":").trim()}Object.keys(t).length>0&&(m=t)}let _=[];w&&_.push({role:"system",content:w});for(let t of E){let d=t.role==="user"?"user":"assistant",o=[];if(Array.isArray(t.parts)){for(let s of t.parts)if(s.text)o.push({type:"text",text:s.text});else if(s.inlineData&&N){let e=s.inlineData.mimeType,n=s.inlineData.data;e.startsWith("image/")&&o.push({type:"image_url",image_url:{url:`data:${e};base64,${n}`}})}}else{let s=t.text||"";s&&o.push({type:"text",text:s})}_.push({role:d,content:o.length===1&&o[0].type==="text"?o[0].text:o})}let T=b("Infron",a,x),D=T!==null?T:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],y={model:a,messages:_,stream:!0,stream_options:{include_usage:!0},temperature:S,tools:[],tool_choice:"none"};m&&(y.provider=m),D&&(y.reasoning={effort:D});let M=process.env.INFRON_URL||"https://llm.onerouter.pro/v1/chat/completions",I={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},F=C||process.env.INFRON_API_KEY||"";I.Authorization=`Bearer ${F}`;let f=await A(M,{method:"POST",headers:I,body:JSON.stringify(y),signal:O});if(!f.ok){let t=await f.json().catch(()=>({}));throw new Error(`Infron Error (${f.status}): ${t.error?.message||t.message||f.statusText}`)}let R=f.body.getReader(),L=new TextDecoder,k="",i=[],p=null,u=Date.now(),l=!1;for(;;){let{done:t,value:d}=await R.read();if(t){l&&(i.length>0||p)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:p});break}k+=L.decode(d,{stream:!0});let o=k.split(`
2
+ `);k=o.pop();for(let s of o){let e=s.trim();if(!e||!e.startsWith("data: "))continue;let n=!1;if(e==="data: [DONE]")n=!0;else try{let g=JSON.parse(e.substring(6)),c=g.choices?.[0]?.delta,r=g.usage;if(r&&(p={totalTokenCount:r.total_tokens||(r.prompt_tokens||0)+(r.completion_tokens||0),promptTokenCount:r.prompt_tokens||0,candidatesTokenCount:r.completion_tokens||0,cachedContentTokenCount:r.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:r.completion_tokens_details?.reasoning_tokens||r.reasoning_tokens||0},l=!0),c){let h=c.reasoning_content||c.reasoning||null;!h&&Array.isArray(c.reasoning_details)&&c.reasoning_details.length>0&&(h=c.reasoning_details.map(P=>P.text||"").filter(Boolean).join("")),h&&(i.push({text:h,thought:!0}),l=!0),c.content&&(i.push({text:c.content}),l=!0)}}catch{}if((n||Date.now()-u>=150)&&l&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],u=Date.now(),l=!1),n)break}Date.now()-u>=150&&l&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],u=Date.now(),l=!1)}};export{B as getInfronStream};
@@ -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-IV4VGXUD.js"),l=b(w),c=l.task||l.instruction||l.prompt,E=l.model||null,C=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:C||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=[],A={...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-T3E6XBW3.js"),l=b(w),c=l.task||l.instruction||l.prompt,E=l.model||null,C=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:C||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=[],A={...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: [action: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((M,_)=>M+_.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,A,E,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]")||n.startsWith("[Action 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-IV4VGXUD.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)}),`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-T3E6XBW3.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)}),`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-IV4VGXUD.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-IV4VGXUD.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-T3E6XBW3.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-T3E6XBW3.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};
@@ -0,0 +1,2 @@
1
+ import{a as E,b as R}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-JS5ZIGFR.js";import"./chunk-DSVLWYIT.js";var B=async function*(C,O,S,$,m,A,M,F,I=1,N=null){let y=[];$&&y.push({role:"system",content:[{type:"text",text:$}]});for(let e of S){let t=e.role==="user"?"user":"assistant",s=[];if(Array.isArray(e.parts)){for(let n of e.parts)if(n.text)s.push({type:"text",text:n.text});else if(n.inlineData&&M){let l=n.inlineData.mimeType,c=n.inlineData.data;l.startsWith("image/")?s.push({type:"image_url",image_url:{url:`data:${l};base64,${c}`}}):s.push({type:"file",file:{filename:n.filename||"file",file_data:`data:${l};base64,${c}`}})}}else{let n=e.text||"";n&&s.push({type:"text",text:n})}y.push({role:t,content:s.length===1&&s[0].type==="text"?s[0].text:s})}let j={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},r=O,u=null,h=null;if(typeof r=="string"&&r.includes("::")){let e=r.indexOf("::"),t=r.slice(0,e).trim();t&&(u={only:[t],allow_fallbacks:!1}),r=r.slice(e+2).trim()}if(r.includes(":")){let e=r.split(":");if(e.length>1){let t=e[e.length-1].toLowerCase().trim();(t==="flex"||t==="priority")&&(h=t,e.pop())}r=e.join(":").trim()}let v=`${C.slice(-5)}${N||""}${m}${r}${h||""}${u?JSON.stringify(u):""}`,P=await R(v),g={model:r,messages:y,stream:!0,temperature:I,cache_control:{type:"ephemeral"},tools:[],tool_choice:"none",session_id:P};h&&(g.service_tier=h),u&&(g.provider=u);let x=b("OpenRouter",O,m),k=x!==null?x:j[m];k&&k!=="none"&&(x!==null||m!=="Fast")&&(g.reasoning_effort=k);let d=await E("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"Content-Type":"application/json","HTTP-Referer":"https://fluxflow-cli.onrender.com/","X-Title":"FluxFlow CLI","X-OpenRouter-Title":"FluxFlow CLI","X-Cache":"true","X-OpenRouter-Cache":"true"},body:JSON.stringify(g),signal:F});if(!d.ok){let e=await d.json().catch(()=>({})),t=e.error?.metadata?.raw||e.error?.message||(typeof e.error=="string"?e.error:"")||d.statusText||"Unknown error";throw new Error(`OpenRouter Error (${d.status}): ${t}`)}let J=d.body.getReader(),W=new TextDecoder,T="",i=[],_=null,D=Date.now(),p=!1;for(;;){let{done:e,value:t}=await J.read();if(e){p&&(i.length>0||_)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:_});break}T+=W.decode(t,{stream:!0});let s=T.split(`
2
+ `);T=s.pop();for(let n of s){let l=n.trim();if(!l||!l.startsWith("data: "))continue;let c=!1;if(l==="data: [DONE]")c=!0;else try{let o=JSON.parse(l.substring(6));if(o.error){let w=o.error.metadata?.raw||o.error.message||JSON.stringify(o.error);throw new Error(`OpenRouter Stream Error: ${w}`)}let f=o.choices?.[0]?.delta,a=o.usage;if(o.choices?.[0]?.finish_reason&&(c=!0),a&&(_={totalTokenCount:a.total_tokens||(a.prompt_tokens||0)+(a.completion_tokens||0),promptTokenCount:a.prompt_tokens||0,candidatesTokenCount:a.completion_tokens||0,cachedContentTokenCount:a.prompt_tokens_details?.cached_tokens||a.prompt_tokens_details?.cache_read_input_tokens||a.cache_read_input_tokens||0,thoughtsTokenCount:a.completion_tokens_details?.reasoning_tokens||0},p=!0),f){let w=f.reasoning||(f.reasoning_details?f.reasoning_details.map(X=>X.text).join(""):null);w&&(i.push({text:w,thought:!0}),p=!0),f.content&&(i.push({text:f.content}),p=!0)}}catch(o){if(o.message&&o.message.startsWith("OpenRouter Stream Error:"))throw o}if((c||Date.now()-D>=150)&&p&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:_},i=[],D=Date.now(),p=!1),c)break}}};export{B as getOpenRouterStream};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-UEV335RW.js";export{a as getProcessTree,b as killProcess};
@@ -1,4 +1,4 @@
1
- import{g as h,h as m,i as R}from"./chunk-53AFLLUU.js";import{a as F}from"./chunk-FQBBOFNP.js";import{a as $}from"./chunk-Y5JU726N.js";import{a as g}from"./chunk-KZTDLEUL.js";import"./chunk-63V6P5DU.js";import"./chunk-L3W2X74K.js";import"./chunk-DSVLWYIT.js";import c from"fs";import P from"path";var j=async(w,y={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:E,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 M=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":E,i=P.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=y.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-4MDSKJGX.js";import{a as F}from"./chunk-FQBBOFNP.js";import{a as $}from"./chunk-Y5JU726N.js";import{a as g}from"./chunk-KZTDLEUL.js";import"./chunk-63V6P5DU.js";import"./chunk-L3W2X74K.js";import"./chunk-DSVLWYIT.js";import c from"fs";import P from"path";var j=async(w,y={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:E,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 M=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":E,i=P.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=y.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:M}),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(`
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import{a as b}from"./chunks/chunk-DSVLWYIT.js";import{spawn as we}from"child_process";import{fileURLToPath as re}from"url";import he from"os";import j from"path";import T from"fs";import R from"dotenv";try{let t=j.join(b,"AGENTS.md"),f=j.join(b,"FLUXFLOW.md");T.existsSync(b)||T.mkdirSync(b,{recursive:!0}),T.existsSync(t)||T.writeFileSync(t,"","utf8"),T.existsSync(f)||T.writeFileSync(f,"","utf8")}catch{}R.config({path:"./.env",override:!0,quiet:!0});R.config({path:`${b}/.env`,override:!0,quiet:!0});R.config({path:`${b}/.env.agents`,override:!0,quiet:!0});R.config({path:`${b}/.env.fluxflow`,override:!0,quiet:!0});R.config({path:"./.env.agents",override:!0,quiet:!0});R.config({path:"./.env.fluxflow",override:!0,quiet:!0});process.env.NO_INS=!1;var ve=he.totalmem(),ne=ve/(1024*1024),ye=.5,Se=Math.floor(ne*ye),ie=process.argv.slice(2),se=ie.indexOf("--allocation"),u=se!==-1?parseInt(ie[se+1],10):NaN,be=process.env.EXPERIMENTAL_MEMORY_MANAGER==="true"||process.env.EXPERIMENTAL_MEMORY_MANAGER==="1"||process.env.EXPERIMENTAL_MEMORY_MANAGER===!0||process.env.EXPERIMENTAL_MEMORY_MANAGER===1||!1,Ce=!isNaN(u)||be||!1;!isNaN(u)&&u<64&&(console.error(`
2
+ import{a as $}from"./chunks/chunk-DSVLWYIT.js";import{spawn as he}from"child_process";import{fileURLToPath as ie}from"url";import ve from"os";import Q from"path";import R from"fs";import T from"dotenv";try{let t=Q.join($,"AGENTS.md"),g=Q.join($,"FLUXFLOW.md");R.existsSync($)||R.mkdirSync($,{recursive:!0}),R.existsSync(t)||R.writeFileSync(t,"","utf8"),R.existsSync(g)||R.writeFileSync(g,"","utf8")}catch{}T.config({path:"./.env",override:!0,quiet:!0});T.config({path:`${$}/.env`,override:!0,quiet:!0});T.config({path:`${$}/.env.agents`,override:!0,quiet:!0});T.config({path:`${$}/.env.fluxflow`,override:!0,quiet:!0});T.config({path:"./.env.agents",override:!0,quiet:!0});T.config({path:"./.env.fluxflow",override:!0,quiet:!0});process.env.NO_INS=!1;var ye=ve.totalmem(),ae=ye/(1024*1024),Se=.5,be=Math.floor(ae*Se),le=process.argv.slice(2),ne=le.indexOf("--allocation"),u=ne!==-1?parseInt(le[ne+1],10):NaN,$e=process.env.EXPERIMENTAL_MEMORY_MANAGER==="true"||process.env.EXPERIMENTAL_MEMORY_MANAGER==="1"||process.env.EXPERIMENTAL_MEMORY_MANAGER===!0||process.env.EXPERIMENTAL_MEMORY_MANAGER===1||!1,Ce=!isNaN(u)||$e||!1;!isNaN(u)&&u<64&&(console.error(`
3
3
  [ERROR] Allocation value '${u} MB' is too low. Minimum: 64 MB, Recommended: 4096 MB.
4
- `),process.exit(1));var L=Math.floor(ne*.75),$e=!isNaN(u)&&u>0?Math.min(u,L):Math.max(1536,Math.min(32768,Se)),Ae=re(import.meta.url).endsWith(".js");if(Ae&&!process.execArgv.some(t=>t.includes("max-old-space-size"))&&Ce)Number.isNaN(u)||(console.log(`
5
- [MEMORY] Starting with: '${u>L?L:u} MB' Allocation${u>L?" (Max allowed: '"+L+" MB')":""}. Please Wait...`),await new Promise(f=>setTimeout(f,5e3))),we(process.execPath,[`--max-old-space-size=${$e}`,"--expose-gc","--max-semi-space-size=1",re(import.meta.url),...process.argv.slice(2)],{stdio:"inherit"}).on("exit",f=>process.exit(f||0));else{let t=process.argv.slice(2),f=t.includes("--help")&&t[t.indexOf("--help")+1]==="commands",K=t.includes("--help")&&!f,Q=t.includes("--version")||t.includes("-v"),Z=t[0]==="--update",ee=t[0]==="--export";if(t[0]==="--usage"||t.includes("--usage")||t[0]==="--budget"||t.includes("--budget")){let{openUsageDashboard:o}=await import("./chunks/usageServer-SQHTSGOH.js"),{url:m}=await o();console.log(`
4
+ `),process.exit(1));var L=Math.floor(ae*.75),Ae=!isNaN(u)&&u>0?Math.min(u,L):Math.max(1536,Math.min(32768,be)),ke=ie(import.meta.url).endsWith(".js");if(ke&&!process.execArgv.some(t=>t.includes("max-old-space-size"))&&Ce)Number.isNaN(u)||(console.log(`
5
+ [MEMORY] Starting with: '${u>L?L:u} MB' Allocation${u>L?" (Max allowed: '"+L+" MB')":""}. Please Wait...`),await new Promise(g=>setTimeout(g,5e3))),he(process.execPath,[`--max-old-space-size=${Ae}`,"--expose-gc","--max-semi-space-size=1",ie(import.meta.url),...process.argv.slice(2)],{stdio:"inherit"}).on("exit",g=>process.exit(g||0));else{let t=process.argv.slice(2),g=t.includes("--help")&&t[t.indexOf("--help")+1]==="commands",Z=t.includes("--help")&&!g,ee=t.includes("--version")||t.includes("-v"),te=t[0]==="--update",oe=t[0]==="--export";if(t[0]==="--usage"||t.includes("--usage")||t[0]==="--budget"||t.includes("--budget")){let{openUsageDashboard:o}=await import("./chunks/usageServer-SQHTSGOH.js"),{url:m}=await o();console.log(`
6
6
  \u2726 FluxFlow Token Usage & Analytics Dashboard
7
7
  \u2800\u2800\u2514\u2500 Serving at: ${m}
8
8
  \u2800\u2800\u2514\u2500 Opened in default browser. Press Ctrl+C to stop.
9
- `),await new Promise(()=>{})}if(Q||K||f||Z||ee){let o=await import("fs"),m=await import("path"),{fileURLToPath:r}=await import("url"),d=m.join(m.dirname(r(import.meta.url)),"../package.json"),n=JSON.parse(o.readFileSync(d,"utf8")).version;if(ee){let C=(t[1]||"").toLowerCase();if(C==="error"||C==="logs")try{let{exportErrorLogs:g}=await import("./chunks/export-KS6YAXR6.js"),l=await g();console.log(`[EXPORT LOGS] Exported ${l.entryCount} error log entries (FluxFlow: ${l.fluxflowCount}, Memory: ${l.memoryCount}, Usage: ${l.usageCount}) to "${l.exportFile}"`),process.exit(0)}catch(g){console.error(`[EXPORT ERROR] Failed to export error logs: ${g.message}`),process.exit(1)}else console.error(`[EXPORT ERROR] Invalid export target "${t[1]||""}". --export only supports 'error'.
10
- Usage: fluxflow --export error`),process.exit(1)}if(Q&&(console.log(`v${n}`),process.exit(0)),K&&(console.log(`FluxFlow CLI Arguments:
9
+ `),await new Promise(()=>{})}if(ee||Z||g||te||oe){let o=await import("fs"),m=await import("path"),{fileURLToPath:r}=await import("url"),d=m.join(m.dirname(r(import.meta.url)),"../package.json"),n=JSON.parse(o.readFileSync(d,"utf8")).version;if(oe){let C=(t[1]||"").toLowerCase();if(C==="error"||C==="logs")try{let{exportErrorLogs:f}=await import("./chunks/export-QFE76VEG.js"),l=await f();console.log(`[EXPORT LOGS] Exported ${l.entryCount} error log entries (FluxFlow: ${l.fluxflowCount}, Memory: ${l.memoryCount}, Usage: ${l.usageCount}) to "${l.exportFile}"`),process.exit(0)}catch(f){console.error(`[EXPORT ERROR] Failed to export error logs: ${f.message}`),process.exit(1)}else console.error(`[EXPORT ERROR] Invalid export target "${t[1]||""}". --export only supports 'error'.
10
+ Usage: fluxflow --export error`),process.exit(1)}if(ee&&(console.log(`v${n}`),process.exit(0)),Z&&(console.log(`FluxFlow CLI Arguments:
11
11
  --mode <flux|flow|icu|omni> Set startup mode (Agent / Chat / Computer Use / Sentient being)
12
12
  --model <model_name> Set startup AI model
13
13
  --key <key@provider> Set API key and provider
@@ -33,8 +33,9 @@ Usage: fluxflow --export error`),process.exit(1)}if(Q&&(console.log(`v${n}`),pro
33
33
  --export error Export system error logs to fluxflow-error-<timestamp>.txt
34
34
  --update check Check for new updates
35
35
  --update check latest Show the latest version available on npm
36
- --update [latest] Update the app to the latest version (latest is default)`),process.exit(0)),f&&(console.log(`FluxFlow Chat /Commands:
36
+ --update [latest] Update the app to the latest version (latest is default)`),process.exit(0)),g&&(console.log(`FluxFlow Chat /Commands:
37
37
  /quit Exit and shutdown Flux
38
+ /kill [pid] Kill a process by PID or list active processes
38
39
  /help Show help menu
39
40
  /clear Clear terminal screen
40
41
  /resume Load previous session
@@ -66,30 +67,30 @@ Usage: fluxflow --export error`),process.exit(1)}if(Q&&(console.log(`v${n}`),pro
66
67
  /docs View documentation
67
68
  /fluxflow init Create FluxFlow.md template
68
69
  /update check Check for new version
69
- /update latest Install latest release`),process.exit(0)),Z){let C=t[1]||"latest";if(C==="check"){let g=t[2]==="latest";try{let v=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;v||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(g?`Latest version: v${v}`:v!==n?`A new version of FluxFlow is available: v${v} (current: v${n}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${n}).`)}catch(l){console.error("Error checking for updates:",l.message),process.exit(1)}process.exit(0)}else if(C==="latest"){console.log("Checking latest version and settings...");try{let c=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;c||(console.error("Error: Could not retrieve latest version."),process.exit(1)),c===n&&(console.log(`FluxFlow is already up to date (v${n}).`),process.exit(0));let v=async()=>{let s=(await import("react")).default,{useState:N}=s,{render:_,Box:y,Text:S}=await import("ink"),B=(await import("ink-select-input")).default,E=(await import("ink-text-input")).default;return new Promise(W=>{let M=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],H=({label:k,isSelected:F})=>s.createElement(y,{width:"100%"},s.createElement(S,{bold:F},"\u2514\u2500 ",F?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",k)),O,X=()=>{let[k,F]=N("select"),[z,J]=N(""),P=e=>{e.value==="custom"?F("custom"):D({manager:e.value})},U=e=>{D({manager:"custom",customCommand:e})};return k==="custom"?s.createElement(y,{flexDirection:"column",marginY:1},s.createElement(y,{marginBottom:1},s.createElement(S,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),s.createElement(y,{flexDirection:"row"},s.createElement(S,{color:"cyan",bold:!0}," \u276F "),s.createElement(E,{value:z,onChange:J,onSubmit:U})),s.createElement(y,{marginTop:1},s.createElement(S,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):s.createElement(y,{flexDirection:"column",marginY:1},s.createElement(y,{marginBottom:1},s.createElement(S,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),s.createElement(B,{items:M,onSelect:P,itemComponent:H,indicatorComponent:()=>null}))},D=k=>{O&&O(),W(k)},{unmount:V}=_(s.createElement(X,null));O=V})},i,$="",A;try{let{loadSettings:s}=await import("./chunks/settings-Q5OBKUO6.js");A=await s(),i=A?.systemSettings?.updateManager||A?.updateManager}catch{}if(!i){let s=await v();i=s.manager,$=s.customCommand}let p="";i==="pnpm"?p=`pnpm add -g fluxflow-cli@${c}`:i==="bun"?p=`bun add -g fluxflow-cli@${c}`:i==="yarn"?p=`yarn global add fluxflow-cli@${c}`:i==="custom"?p=$||A?.customUpdateCommand||`npm install -g fluxflow-cli@${c}`:p=`npm install -g fluxflow-cli@${c}`,console.log(`Updating FluxFlow to v${c} using ${i}...`),console.log(`Running: ${p}`);let{execSync:w}=await import("child_process");w(p,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${c}.\x1B[0m`)}catch(g){console.error("\x1B[31m\u274C Update failed:\x1B[0m",g.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:ae}=await import("react"),{render:le}=await import("ink"),{default:ce}=await import("./chunks/app-WVWO7GHJ.js");process.env.NODE_NO_WARNINGS="1";let pe=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],me=console.log,de=console.warn,ue=console.error,G=o=>{let m=o.map(String).join(" ");return pe.some(r=>m.includes(r))};console.log=(...o)=>!G(o)&&me(...o),console.warn=(...o)=>!G(o)&&de(...o),console.error=(...o)=>!G(o)&&ue(...o);let Y=t.findIndex(o=>o==="--cwd"||o==="--path");if(Y!==-1&&Y+1<t.length){let o=t[Y+1],m=await import("path"),r=await import("fs-extra"),d=m.default.resolve(o);try{r.default.existsSync(d)&&r.default.statSync(d).isDirectory()?process.chdir(d):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(x){console.error(`[ERROR] Failed to change directory to "${o}": ${x.message}`),process.exit(0)}}let I=t.includes("--commit_8f4a2b9c"),q=t.findIndex(o=>o==="-p"||o==="--prompt");if(q!==-1||I){let o=t.includes("--new")||t.includes("-n"),r=(q!==-1?t.slice(q+1).filter(e=>e!=="-n"&&e!=="--new"):[])[0];if(I)try{let{execSync:e}=await import("child_process"),a=e("git diff --cached",{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();a||process.exit(0),r=`Git Staged Diff:
70
+ /update latest Install latest release`),process.exit(0)),te){let C=t[1]||"latest";if(C==="check"){let f=t[2]==="latest";try{let y=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;y||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(f?`Latest version: v${y}`:y!==n?`A new version of FluxFlow is available: v${y} (current: v${n}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${n}).`)}catch(l){console.error("Error checking for updates:",l.message),process.exit(1)}process.exit(0)}else if(C==="latest"){console.log("Checking latest version and settings...");try{let c=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;c||(console.error("Error: Could not retrieve latest version."),process.exit(1)),c===n&&(console.log(`FluxFlow is already up to date (v${n}).`),process.exit(0));let y=async()=>{let s=(await import("react")).default,{useState:N}=s,{render:U,Box:S,Text:b}=await import("ink"),_=(await import("ink-select-input")).default,P=(await import("ink-text-input")).default;return new Promise(Y=>{let F=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],q=({label:E,isSelected:M})=>s.createElement(S,{width:"100%"},s.createElement(b,{bold:M},"\u2514\u2500 ",M?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",E)),O,W=()=>{let[E,M]=N("select"),[X,V]=N(""),z=h=>{h.value==="custom"?M("custom"):D({manager:h.value})},J=h=>{D({manager:"custom",customCommand:h})};return E==="custom"?s.createElement(S,{flexDirection:"column",marginY:1},s.createElement(S,{marginBottom:1},s.createElement(b,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),s.createElement(S,{flexDirection:"row"},s.createElement(b,{color:"cyan",bold:!0}," \u276F "),s.createElement(P,{value:X,onChange:V,onSubmit:J})),s.createElement(S,{marginTop:1},s.createElement(b,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):s.createElement(S,{flexDirection:"column",marginY:1},s.createElement(S,{marginBottom:1},s.createElement(b,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),s.createElement(_,{items:F,onSelect:z,itemComponent:q,indicatorComponent:()=>null}))},D=E=>{O&&O(),Y(E)},{unmount:H}=U(s.createElement(W,null));O=H})},i,A="",k;try{let{loadSettings:s}=await import("./chunks/settings-Q5OBKUO6.js");k=await s(),i=k?.systemSettings?.updateManager||k?.updateManager}catch{}if(!i){let s=await y();i=s.manager,A=s.customCommand}let p="";i==="pnpm"?p=`pnpm add -g fluxflow-cli@${c}`:i==="bun"?p=`bun add -g fluxflow-cli@${c}`:i==="yarn"?p=`yarn global add fluxflow-cli@${c}`:i==="custom"?p=A||k?.customUpdateCommand||`npm install -g fluxflow-cli@${c}`:p=`npm install -g fluxflow-cli@${c}`,console.log(`Updating FluxFlow to v${c} using ${i}...`),console.log(`Running: ${p}`);let{execSync:w}=await import("child_process");w(p,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${c}.\x1B[0m`)}catch(f){console.error("\x1B[31m\u274C Update failed:\x1B[0m",f.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:ce}=await import("react"),{render:pe}=await import("ink"),{default:me}=await import("./chunks/app-OUE6OIEW.js");process.env.NODE_NO_WARNINGS="1";let de=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],ue=console.log,ge=console.warn,fe=console.error,B=o=>{let m=o.map(String).join(" ");return de.some(r=>m.includes(r))};console.log=(...o)=>!B(o)&&ue(...o),console.warn=(...o)=>!B(o)&&ge(...o),console.error=(...o)=>!B(o)&&fe(...o);let j=t.findIndex(o=>o==="--cwd"||o==="--path");if(j!==-1&&j+1<t.length){let o=t[j+1],m=await import("path"),r=await import("fs-extra"),d=m.default.resolve(o);try{r.default.existsSync(d)&&r.default.statSync(d).isDirectory()?process.chdir(d):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(x){console.error(`[ERROR] Failed to change directory to "${o}": ${x.message}`),process.exit(0)}}let I=t.includes("--commit_8f4a2b9c"),G=t.findIndex(o=>o==="-p"||o==="--prompt");if(G!==-1||I){let o=t.includes("--new")||t.includes("-n"),r=(G!==-1?t.slice(G+1).filter(e=>e!=="-n"&&e!=="--new"):[])[0];if(I)try{let{execSync:e}=await import("child_process"),a=e("git diff --cached",{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();a||process.exit(0),r=`Git Staged Diff:
70
71
  ${a}
71
72
  ---
72
73
 
73
- Write as conventional, title + bullet description style commit message. No markdown, emojis, fluff`}catch{process.exit(0)}let d=t.findIndex(e=>e==="-r"||e==="--run"),x=null,n=null;if(d!==-1&&d+1<t.length){x=t[d+1];try{let{execSync:e}=await import("child_process");n=e(x,{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch(e){n=(e.stdout?e.stdout.toString().trim():"")||(e.stderr?e.stderr.toString().trim():"")||e.message}}if(n){let{stripAnsi:e}=await import("./chunks/exec_command-AB4DNQYP.js");n=e(n).trim(),r?r=`Stdin Context (${x}):
74
+ Write as conventional, title + bullet description style commit message. No markdown, emojis, fluff`}catch{process.exit(0)}let d=t.findIndex(e=>e==="-r"||e==="--run"),x=null,n=null;if(d!==-1&&d+1<t.length){x=t[d+1];try{let{execSync:e}=await import("child_process");n=e(x,{encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch(e){n=(e.stdout?e.stdout.toString().trim():"")||(e.stderr?e.stderr.toString().trim():"")||e.message}}if(n){let{stripAnsi:e}=await import("./chunks/exec_command-THZ4FE42.js");n=e(n).trim(),r?r=`Stdin Context (${x}):
74
75
  ${n}
75
76
  ---
76
77
 
77
- ${r}`:r=n}if(!I&&!process.stdin.isTTY){let e=[];for await(let h of process.stdin)e.push(h);let a=Buffer.concat(e).toString("utf8").trim();if(a){let{stripAnsi:h}=await import("./chunks/exec_command-AB4DNQYP.js");a=h(a).trim(),r?r=`Stdin Context:
78
+ ${r}`:r=n}if(!I&&!process.stdin.isTTY){let e=[];for await(let v of process.stdin)e.push(v);let a=Buffer.concat(e).toString("utf8").trim();if(a){let{stripAnsi:v}=await import("./chunks/exec_command-THZ4FE42.js");a=v(a).trim(),r?r=`Stdin Context:
78
79
  ${a}
79
80
  ---
80
81
 
81
- ${r}`:r=a}}r||(console.error("[ERROR] -p/--prompt requires a prompt string (or piped stdin input)."),process.exit(1));let{loadSettings:C}=await import("./chunks/settings-Q5OBKUO6.js"),{getProviderAPIKey:g}=await import("./chunks/secrets-UNXNDOLK.js"),{getDefaultModel:l}=await import("./chunks/model_config-EN3OYDPU.js"),{generateSimpleContent:c}=await import("./chunks/ai-IV4VGXUD.js"),{checkQuotaDetailed:v}=await import("./chunks/usage-OUCURLG4.js"),i=await C(),$=t.filter(e=>e!=="-p"&&e!=="--prompt"&&e!==r&&e!=="-n"&&e!=="--new"),A=I||$.includes("--raw")||t.includes("--raw"),p=e=>{for(let a of e){let h=$.indexOf(a);if(h!==-1&&h+1<$.length)return $[h+1]}return null},w=p(["--provider"])||i.aiProvider||"Google",s=p(["--model"])||i.activeModel||l(w,i.apiTier)||l(w,"paid"),N=p(["--key"])||await g(w);!N&&!(w==="c_openai"&&i.systemSettings?.customOpenAIBaseUrl)&&(console.error(`[ERROR] No API key resolved for provider "${w}".`),process.exit(1));let _=await v("agent",{aiProvider:w});_.allowed||(console.error(`[ERROR] ${_.reason||"Budget Exhausted"} - adjust with /budget set.`),process.exit(1));let{name:y="",nickname:S="",instructions:B=""}=i?.profileData??{},E={aiProvider:w,apiKey:N,model:s,mode:"flow",thinkingLevel:p(["--thinking"])||"Fast",systemSettings:i.systemSettings||{}},W=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",M=new Date,H=M.getFullYear(),O=M.toLocaleString("en-US",{month:"short"}).toUpperCase(),X=String(M.getDate()).padStart(2,"0"),D=M.toLocaleTimeString([],{hour:"2-digit",hour12:!0}),V=`${H}-${O}-${X}, ${D}`,k=`Identity: FluxFlow. Sassy, CLI Assistant
82
+ ${r}`:r=a}}r||(console.error("[ERROR] -p/--prompt requires a prompt string (or piped stdin input)."),process.exit(1));let{loadSettings:C}=await import("./chunks/settings-Q5OBKUO6.js"),{getProviderAPIKey:f}=await import("./chunks/secrets-UNXNDOLK.js"),{getDefaultModel:l}=await import("./chunks/model_config-EN3OYDPU.js"),{generateSimpleContent:c}=await import("./chunks/ai-T3E6XBW3.js"),{checkQuotaDetailed:y}=await import("./chunks/usage-OUCURLG4.js"),i=await C(),A=t.filter(e=>e!=="-p"&&e!=="--prompt"&&e!==r&&e!=="-n"&&e!=="--new"),k=I||A.includes("--raw")||t.includes("--raw"),p=e=>{for(let a of e){let v=A.indexOf(a);if(v!==-1&&v+1<A.length)return A[v+1]}return null},w=p(["--provider"])||i.aiProvider||"Google",s=p(["--model"])||i.activeModel||l(w,i.apiTier)||l(w,"paid"),N=p(["--key"])||await f(w);!N&&!(w==="c_openai"&&i.systemSettings?.customOpenAIBaseUrl)&&(console.error(`[ERROR] No API key resolved for provider "${w}".`),process.exit(1));let U=await y("agent",{aiProvider:w});U.allowed||(console.error(`[ERROR] ${U.reason||"Budget Exhausted"} - adjust with /budget set.`),process.exit(1));let{name:S="",nickname:b="",instructions:_=""}=i?.profileData??{},P={aiProvider:w,apiKey:N,model:s,mode:"flow",thinkingLevel:p(["--thinking"])||"Fast",systemSettings:i.systemSettings||{}},Y=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",F=new Date,q=F.getFullYear(),O=F.toLocaleString("en-US",{month:"short"}).toUpperCase(),W=String(F.getDate()).padStart(2,"0"),D=F.toLocaleTimeString([],{hour:"2-digit",hour12:!0}),H=`${q}-${O}-${W}, ${D}`,E=(P.model||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),M=Q.basename(E).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,e=>e.toUpperCase().trim()),X=`Identity: FluxFlow. Sassy, CLI Assistant
82
83
  Use NO markdown, only plain text
83
84
  Additional Context:
84
- - OS: ${W}
85
- - Model: ${j.basename(E.model.replace("/free","").trim()).replace(":free","").replace("-free","").replace("/free","").replace("_free","").replace("free_","").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,e=>e.toUpperCase().trim())}
86
- - Approx time: ${V}
85
+ - OS: ${Y}
86
+ - Model: ${M}
87
+ - Approx time: ${H}
87
88
  - Non interactive CLI, support piped inputs
88
- - 'fluxflow' TUI has full agentic tools & capabilities${S.trim().length>0?`
89
- User Nickname: ${S.trim()}`:""}${B.trim().length>0?`
90
- User Preferences: ${B.trim()}`:""}`.trim(),{getPromptSessionHistory:F,savePromptSessionHistory:z,clearPromptSessionHistory:J}=await import("./chunks/sessionDaemon-GHQTAGDG.js"),P=[];o&&!I?await J():o||(P=await F());let U=[];if(Array.isArray(P)&&P.length>0)for(let e of P)e.text&&U.push({role:e.role==="model"?"model":"user",parts:[{text:e.text}]});U.push({role:"user",parts:[{text:r}]});try{if(!A){let h="\x1B[36m",fe="\x1B[35m",oe="\x1B[0m",ge=j.basename(E.model.replace("/free","").trim()).replace(":free","").replace("-free","").replace("/free","").replaceAll("-"," ").replace(/\b\w/g,xe=>xe.toUpperCase().trim());process.stdout.write(`Responding with ${h}${ge}${oe} from ${fe}${E.aiProvider}${oe}:
91
- `)}let{text:e}=await c(E,s,U,k,E.thinkingLevel),a=(e||"").trim();process.stdout.write(a+`
92
- ${A?"":`
89
+ - 'fluxflow' TUI has full agentic tools & capabilities${b.trim().length>0?`
90
+ User Nickname: ${b.trim()}`:""}${_.trim().length>0?`
91
+ User Preferences: ${_.trim()}`:""}`.trim(),{getPromptSessionHistory:V,savePromptSessionHistory:z,clearPromptSessionHistory:J}=await import("./chunks/sessionDaemon-GHQTAGDG.js"),h=[];o&&!I?await J():o||(h=await V());let K=[];if(Array.isArray(h)&&h.length>0)for(let e of h)e.text&&K.push({role:e.role==="model"?"model":"user",parts:[{text:e.text}]});K.push({role:"user",parts:[{text:r}]});try{if(!k){let v="\x1B[36m",xe="\x1B[35m",re="\x1B[0m",we=M;process.stdout.write(`Responding with ${v}${we}${re} from ${xe}${P.aiProvider}${re}:
92
+ `)}let{text:e}=await c(P,s,K,X,P.thinkingLevel),a=(e||"").trim();process.stdout.write(a+`
93
+ ${k?"":`
93
94
  `}`),a&&await z(r,a)}catch(e){console.error(`[ERROR] Prompt request failed: ${e.message.trim()}
94
95
 
95
- `),process.exit(1)}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 te=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",te),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{te(),process.exit(0)})}),t.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:m}=await import("./chunks/paths-2EXHWUSL.js"),r=await import("path"),d=await import("fs-extra"),x=r.default.join(m,"playground");try{d.default.ensureDirSync(x),process.chdir(x)}catch{}}le(ae.createElement(ce,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
96
+ `),process.exit(1)}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 se=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",se),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{se(),process.exit(0)})}),t.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:m}=await import("./chunks/paths-2EXHWUSL.js"),r=await import("path"),d=await import("fs-extra"),x=r.default.join(m,"playground");try{d.default.ensureDirSync(x),process.chdir(x)}catch{}}pe(ce.createElement(me,{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.32.1",
4
- "date": "2026-10-08",
3
+ "version": "4.33.0",
4
+ "date": "2026-10-11",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & advance 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.32.1",
4
- "date": "2026-10-08",
3
+ "version": "4.33.0",
4
+ "date": "2026-10-11",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & advance computer use.",
6
6
  "keywords": [
7
7
  "ai",