fluxflow-cli 4.32.1 → 4.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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};