fluxflow-cli 5.2.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/chunks/{ai-W4ZXBMB4.js → ai-BINPY3GV.js} +1 -1
  2. package/dist/chunks/{app-THKSHPL7.js → app-DRT7CX3P.js} +180 -180
  3. package/dist/chunks/{auto_completion-CJNBFI3A.js → auto_completion-I2GVIND6.js} +1 -1
  4. package/dist/chunks/{chunk-3BRTFYTA.js → chunk-25EUCCH5.js} +1 -1
  5. package/dist/chunks/chunk-75OCC24T.js +2 -0
  6. package/dist/chunks/{chunk-WEDUYGPN.js → chunk-7CCULUZN.js} +1 -1
  7. package/dist/chunks/{chunk-HGDSONY3.js → chunk-BM4FWHBO.js} +8 -8
  8. package/dist/chunks/{chunk-UIL6OCU4.js → chunk-BNKY5QOA.js} +2 -2
  9. package/dist/chunks/chunk-KIPZOUEA.js +44 -0
  10. package/dist/chunks/{chunk-GM5VNNTU.js → chunk-RINQH4H4.js} +1 -1
  11. package/dist/chunks/{chunk-KZCVQBDK.js → chunk-UMS5SEYB.js} +1 -1
  12. package/dist/chunks/{chunk-FOELTIXU.js → chunk-VDO5TP6E.js} +1 -1
  13. package/dist/chunks/{chunk-DVXSU3Z4.js → chunk-XAPXZ6KO.js} +1 -1
  14. package/dist/chunks/{chunk-7UF7ZHP7.js → chunk-XRTIQISS.js} +1 -1
  15. package/dist/chunks/{click-ES2QYPC4.js → click-3BB6KDIJ.js} +2 -2
  16. package/dist/chunks/{computer_action-KUJCPYPN.js → computer_action-6RHVNLZG.js} +1 -1
  17. package/dist/chunks/custom_openai-ODYQEMOR.js +3 -0
  18. package/dist/chunks/{drag-U3DNSM33.js → drag-ZGNVQGXW.js} +1 -1
  19. package/dist/chunks/{exec_command-6V5SM6WI.js → exec_command-SQB5LU5X.js} +1 -1
  20. package/dist/chunks/{generate_image-OOU2MEIQ.js → generate_image-7UBJ3ODS.js} +1 -1
  21. package/dist/chunks/{invoke-DPVPIREI.js → invoke-IXWW3N4C.js} +2 -2
  22. package/dist/chunks/{invokeSync-Z2OWSYC7.js → invokeSync-EUHHQZ2H.js} +2 -2
  23. package/dist/chunks/{key_press-5T4RCRQQ.js → key_press-LO75QEJK.js} +1 -1
  24. package/dist/chunks/{keyboard_typing-Y2OBDZDW.js → keyboard_typing-DJ3HHTO7.js} +1 -1
  25. package/dist/chunks/{mistral-QQGMQJ2O.js → mistral-H23J6UYA.js} +1 -1
  26. package/dist/chunks/model_config-IVWGOIBK.js +1 -0
  27. package/dist/chunks/{nvidia-6VK5M5FB.js → nvidia-BUWXTYGV.js} +1 -1
  28. package/dist/chunks/{ollama-YTQ5HFES.js → ollama-53BJCQQX.js} +1 -1
  29. package/dist/chunks/{recapture_screen-CQ3Z5FOL.js → recapture_screen-LONV6G4U.js} +1 -1
  30. package/dist/chunks/{screen_grid-I6BDQFDD.js → screen_grid-LK6IVH4B.js} +1 -1
  31. package/dist/chunks/{scroll-SFUGXJQR.js → scroll-XBXSN2EF.js} +1 -1
  32. package/dist/chunks/{search_keyword-HR6JNLS2.js → search_keyword-IRLPX555.js} +1 -1
  33. package/dist/chunks/{secrets-DQHR2CI2.js → secrets-LHP6ATGQ.js} +1 -1
  34. package/dist/chunks/{secrets_v2-7RG5NKVT.js → secrets_v2-4ZICSEV6.js} +1 -1
  35. package/dist/chunks/{settings-XJ2SOAWE.js → settings-IZC7UDNU.js} +1 -1
  36. package/dist/chunks/{update_file-BN6X5WNO.js → update_file-CH6YILXO.js} +1 -1
  37. package/dist/chunks/{usage-BCL4OUAK.js → usage-G7HRNQNU.js} +1 -1
  38. package/dist/chunks/{usageServer-FIH6WL3V.js → usageServer-SHBKSO4I.js} +13 -5
  39. package/dist/chunks/{write_file-Q4K4LZFU.js → write_file-WX4O436W.js} +1 -1
  40. package/dist/cli.js +5 -5
  41. package/dist/package.json +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunks/chunk-I5LTKU2O.js +0 -1
  44. package/dist/chunks/chunk-KSP6QOQX.js +0 -44
  45. package/dist/chunks/custom_openai-ETCGLBV4.js +0 -3
  46. package/dist/chunks/model_config-J4YX2PNQ.js +0 -1
@@ -1,44 +0,0 @@
1
- import{c as X}from"./chunk-YFIWMGCS.js";import K from"os";import{structuredPatch as Z}from"diff";var N=e=>typeof e!="string"?e:e.length>12?(e+"").replace("",""):e,j=(e,i)=>{if(!e)return"";let f=/\x1B\[[0-?]*[ -/]*[@-~]/g,d=e.split(`
2
- `),c=[];if(i<=5)return e;let l=r=>r<32||r>=127&&r<160||r>=768&&r<=879||r>=7616&&r<=7679||r>=8400&&r<=8447||r>=65056&&r<=65071?0:r>=4352&&r<=4447||r>=9001&&r<=9002||r>=11904&&r<=12350||r>=12352&&r<=42191||r>=44032&&r<=55203||r>=63744&&r<=64255||r>=65040&&r<=65049||r>=65072&&r<=65135||r>=65280&&r<=65376||r>=65504&&r<=65510||r>=127744&&r<=128591||r>=128640&&r<=128767||r>=131072&&r<=262141?2:1,m=r=>{let o=r.replace(f,""),n=0;for(let s=0;s<o.length;s++){let p=o.codePointAt(s);p>65535&&s++,n+=l(p)}return n},A=(r,o)=>{let n=0,s=r.length,p=!1;for(let h=0;h<r.length;h++){if(r[h]==="\x1B"&&r[h+1]==="["&&(p=!0),p){(r[h]==="m"||r[h]>="@"&&r[h]<="~"&&r[h]!=="[")&&(p=!1);continue}let w=r.codePointAt(h);w>65535&&h++;let C=l(w);if(n+C>o){s=w>65535?h-1:h;break}if(n+=C,n>=o){s=h+1;break}}return{head:r.substring(0,s),tail:r.substring(s)}};return d.forEach(r=>{if(m(r)<=i){c.push(r);return}let n=r.split(/(\s+)/),s="",p=0,h=r.match(/^(\s*)/),w=h?h[1]:"";n.forEach(C=>{if(C.length===0)return;let I=C;for(;I.length>0;){let T=m(I);if(p+T<=i){s+=I,p+=T;break}s.trim().length>0&&(c.push(s.trimEnd()),s=w.substring(0,Math.min(w.length,8)),p=m(s));let t=Math.max(1,i-p);if(m(I)>t){let{head:a,tail:u}=A(I,t);c.push((s+a).trimEnd()),s=w.substring(0,Math.min(w.length,8)),p=m(s),I=u}else s+=I,p+=m(I),I=""}}),(s.trimEnd().length>0||s===w)&&c.push(s.trimEnd())}),N(c.join(`
3
- `))},ce=e=>{if(!e)return 0;let i=0,f=e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);f&&(i+=f.length*.55);let d=e.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),c=d.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);c&&(i+=c.length);let l=d.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return i+=l.length,Math.max(.1,i)},ae=e=>e?e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[e]:[],fe=e=>{if(!e&&e!==0)return"0.0k";let i=typeof e=="string"?parseFloat(e):e;return i>=1e6?`${(i/1e6).toFixed(1)}m`:i>=1e3?`${(i/1e3).toFixed(1)}k`:i.toString()},ue=(e,i=40)=>{let f=X.replaceAll("\\\\","\\");if(e=e.replace(K.homedir(),"~").replace(f,"FluxFlow").replaceAll("\\","/"),!e||e.length<=i)return N(e);let d=Math.floor((i-3)/2);return N(e.substring(0,d)+"..."+e.substring(e.length-d).replaceAll("\\","/"))},he=e=>{let i=[],f=new Set,d=e.allowMultiple===!0||String(e.allowMultiple).toLowerCase()==="true";Object.keys(e).forEach(r=>{let o=r.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(o){let n=o[2]?parseInt(o[2],10):1;f.add(n)}});let c=Array.from(f).sort((r,o)=>r-o),l=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],m=["newContent","new_content","content_to_add","newBlock","new_block"],A=(r,o,n)=>{let s,p;for(let h of o){let w=r===1?[`${h}1`,h,`${h}_1`]:[`${h}${r}`,`${h}_${r}`];for(let C of w)if(e[C]!==void 0){s=e[C];break}if(s!==void 0)break}for(let h of n){let w=r===1?[`${h}1`,h,`${h}_1`]:[`${h}${r}`,`${h}_${r}`];for(let C of w)if(e[C]!==void 0){p=e[C];break}if(p!==void 0)break}return{r:s,n:p}};for(let r of c){let{r:o,n}=A(r,l,m);if(o!==void 0&&n!==void 0)i.push({replace:o,new:n});else if(o!==void 0||n!==void 0)return{error:`Mismatched replacement pair for index ${r}. Both replacement and new content must be provided.`,allowMultiple:d}}return{patchPairs:i,allowMultiple:d}},Y=e=>{if(!e)return null;let i="",f=0,d=e.length;for(;f<d;){let c=e[f];if(c==="\\"){for(;f<d&&e[f]==="\\";)f++;i+="\\\\*"}else if(c===`
4
- `)i+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",f++;else if(c==="\r")i+="(?:\\r|\\\\*r)?",f++;else if(c===" ")i+="(?:\\t|\\\\*t|\\s*)",f++;else if(c==='"'||c==="'"||c==="`")i.endsWith("\\\\*")||(i+="\\\\*"),i+=c,f++;else if(/[.*+?^${}()|[\]]/.test(c))i+="\\"+c,f++;else if(/\s/.test(c)){for(;f<d&&/\s/.test(e[f])&&e[f]!==`
5
- `&&e[f]!=="\r"&&e[f]!==" ";)f++;i+="\\s*"}else i+=c,f++}if(!i)return null;try{return new RegExp(i,"g")}catch{return null}},de=(e,i,f={})=>{let d=typeof f=="boolean"?f:!!(f&&f.allowMultiple),c=e.replace(/\r\n/g,`
6
- `).replace(/\r/g,`
7
- `),l=t=>t.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
8
- `).replace(/\r/g,`
9
- `),m=t=>t.match(/^\s*/)[0],A=t=>{let a=t.split(`
10
- `).filter(g=>g.trim()!=="");if(a.length===0)return"";let u=m(a[0]);for(let g of a){let x=m(g);x.length<u.length&&(u=x)}return u},r=(t,a,u="")=>{if(!t||a===void 0)return t;let x=/^\t/m.test(a)?" ":" ",L=y=>y.split(`
11
- `).find(M=>M.trim()!=="")??"",E=L(a).match(/^\s*/)[0].length,b=L(t).match(/^\s*/)[0].length,$=E-b,k=(u.match(/^\s*/)||[""])[0].length;return t.split(`
12
- `).map((y,M)=>{if(y.trim()===""&&M!==0)return"";let S=y.match(/^\s*/)[0].length,_=Math.max(0,S+$);return M===0&&(_=Math.max(0,_-k)),x.repeat(_)+y.trimStart()}).join(`
13
- `)},o=[];for(let t=0;t<i.length;t++){let a=i[t],u=(a.replace||"").trim(),g=l(a.new||"");if(u.startsWith("^LINE:")&&u.endsWith("$")){let $=u.slice(6,-1).trim(),k=$.includes("..")?$.split(".."):$.split("-"),F=parseInt(k[0]),y=k[1]!==void 0?parseInt(k[1]):F;if(!isNaN(F)&&!isNaN(y)){let M=c.split(`
14
- `);if(F<1||F>M.length||y<F||y>M.length){o.push({index:t,success:!1,error:`Block ${t+1}: Line range ^LINE:${F}..${y}$ out of bounds (file has ${M.length} lines).`});continue}let _=M.slice(F-1,y).join(`
15
- `),R=0;for(let B=0;B<F-1;B++)R+=M[B].length+1;o.push({index:t,success:!0,startPos:R,firstMatchContent:_,content_to_add:g});continue}}let x=l(a.replace||"");if(x===""&&g===""){o.push({index:t,success:!1,error:`Block ${t+1}: Empty replace and add content.`});continue}let L=x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=null;if(x!==""&&c.includes(x))E=new RegExp(L,"g");else{let $=x.split(`
16
- `).map(k=>k.trim()).filter(k=>k.length>0).map(k=>k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if($.length>0){let k=$.join("\\s*");try{E=new RegExp(k,"g")}catch{E=new RegExp(L,"g")}}else E=new RegExp(L,"g")}let b=[...c.matchAll(E)];if(b.length===0&&x!==""){let $=Y(x);$&&(b=[...c.matchAll($)])}if(b.length===0){o.push({index:t,success:!1,error:`Block ${t+1}: Could not find match.`});continue}if(b.length>1&&!d){o.push({index:t,success:!1,error:`Block ${t+1}: Found ${b.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let $ of b)o.push({index:t,success:!0,startPos:$.index,firstMatchContent:$[0],content_to_add:g})}let n=o.filter(t=>t.success).sort((t,a)=>t.startPos-a.startPos);for(let t=0;t<n.length-1;t++){let a=n[t],u=n[t+1];a.startPos+a.firstMatchContent.length>u.startPos&&(a.success=!1,a.error=`Block ${a.index+1}: Overlaps with another block.`,u.success=!1,u.error=`Block ${u.index+1}: Overlaps with another block.`)}let s=new Map,p=c,h=0,w=0,C=o.filter(t=>t.success).sort((t,a)=>t.startPos-a.startPos);for(let t of C){let a=t.startPos,u=c.substring(0,a).split(`
17
- `).length,g=a+h,x=u+w,L=p.lastIndexOf(`
18
- `,g)+1,E=p.substring(L,g),b=r(t.content_to_add,t.firstMatchContent,E),$=p.split(`
19
- `),k=[];for(let S=Math.max(0,x-4);S<x-1;S++)k.push({num:S+1,text:$[S]});let F=t.firstMatchContent.split(`
20
- `),y=[],M=x+F.length-1;for(let S=M;S<Math.min($.length,M+3);S++)y.push({num:S+1,text:$[S]});s.set(t,{success:!0,index:t.index,oldContent:t.firstMatchContent,newContent:b,originalStartLine:u,finalStartLine:x,contextBefore:k,contextAfter:y}),p=p.substring(0,g)+b+p.substring(g+t.firstMatchContent.length),h+=b.length-t.firstMatchContent.length,w+=b.split(`
21
- `).length-t.firstMatchContent.split(`
22
- `).length}let I=[];for(let t=0;t<i.length;t++){let a=C.filter(u=>u.index===t);if(a.length>0)for(let u of a)s.has(u)&&I.push(s.get(u));else{let u=o.find(g=>g.index===t);I.push({success:!1,error:u?u.error:`Block ${t+1}: Unknown error.`})}}let T=I.filter(t=>!t.success&&t.error&&t.error.includes("Could not find match"));if(T.length===1)T[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if(T.length>1){let t=T[T.length-1];t.error+=`
23
- (Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:p,results:I}},pe=(e,i)=>{if(e===i)return{added:0,removed:0};let f=Z("","",e||"",i||"","","",{context:3});if(!f||!f.hunks||f.hunks.length===0)return{added:0,removed:0};let d=0,c=0;for(let l of f.hunks)for(let m of l.lines)m[0]==="+"?d++:m[0]==="-"&&c++;return{added:d,removed:c}},ge=(e,i,f,d=8,c=!1)=>{if(e===i)return"";let l=(e||"").split(/\r?\n/),m=(i||"").split(/\r?\n/),A=Math.max(l.length,m.length,1),r=Math.max(4,String(A).length),o=h=>String(h).padStart(r," "),n=`[DIFF_START]
24
- `,s="\u2550".repeat(88),p=Z("","",e||"",i||"","","",{context:3});if(!p||!p.hunks||p.hunks.length===0)return"";if(p.hunks.forEach((h,w)=>{let C=0,I=0;for(let g of h.lines)g[0]==="+"?C++:g[0]==="-"&&I++;let T=[];C>0&&T.push(`+${C}`),I>0&&T.push(`-${I}`);let t=`@@ ${T.join(" ")} @@`;n+=`[UI_CONTEXT] ${t}
25
- `;let a=h.oldStart,u=h.newStart;for(let g of h.lines){let x=g[0],L=g.slice(1);x===" "?(n+=`[UI_CONTEXT] ${o(u)} |${L}
26
- `,a++,u++):x==="-"?(n+=`-${o(a)} |${L}
27
- `,a++):x==="+"&&(n+=`+${o(u)} |${L}
28
- `,u++)}}),c){let h=`[DIFF_START]
29
- `,w=n.substring(h.length),C=`[UI_CONTEXT] ${s}
30
- `,T=w.split(C).map(t=>t.split(`
31
- `).filter(u=>u.trim()!=="").length>120?`[[VERIFIED]]
32
- ${t}
33
- [[/VERIFIED]]`:t);n=h+T.join(C)}return n+="[DIFF_END]",N(n)},q=e=>{if(!e)return null;let i=e.replace("[UI_CONTEXT]","").replace(/\r/g,""),f=i.startsWith("-"),d=i.startsWith("+"),c=f||d?i.substring(1):i,l=c.indexOf("|"),m=l!==-1?N(c.substring(0,l).trim()):"",A=N(l!==-1?c.substring(l+1):c);return{isR:f,isA:d,num:m,content:A}},J=(e,i)=>{if(!e&&!i)return 1;if(!e||!i)return 0;let f=e.length,d=i.length,c=e,l=i;f<d&&(c=i,l=e);let m=c.length,A=l.length,r=new Int32Array(A+1),o=new Int32Array(A+1);for(let p=0;p<=A;p++)r[p]=p;for(let p=1;p<=m;p++){o[0]=p;let h=c[p-1];for(let w=1;w<=A;w++)h===l[w-1]?o[w]=r[w-1]:o[w]=Math.min(r[w],o[w-1],r[w-1])+1;r.set(o)}let n=r[A],s=Math.max(f,d);return s===0?1:1-n/s},G=e=>{let i=[],f=[];e.forEach((n,s)=>{n.parsed.isR?i.push({index:s,content:n.parsed.content}):n.parsed.isA&&f.push({index:s,content:n.parsed.content})});let d=i.length,c=f.length;if(d===0||c===0)return;let l=Array.from({length:d+1},()=>Array(c+1).fill(0)),m=Array.from({length:d+1},()=>Array(c+1).fill(""));for(let n=1;n<=d;n++)m[n][0]="up";for(let n=1;n<=c;n++)m[0][n]="left";let A=Array.from({length:d},()=>Array(c).fill(0));for(let n=0;n<d;n++)for(let s=0;s<c;s++)A[n][s]=J(i[n].content.trim(),f[s].content.trim());for(let n=1;n<=d;n++)for(let s=1;s<=c;s++){let p=A[n-1][s-1],h=p>=.2?p:-10,w=l[n-1][s-1]+h,C=l[n-1][s],I=l[n][s-1];w>=C&&w>=I?(l[n][s]=w,m[n][s]="diag"):C>=I?(l[n][s]=C,m[n][s]="up"):(l[n][s]=I,m[n][s]="left")}let r=d,o=c;for(;r>0||o>0;)if(m[r][o]==="diag"){if(A[r-1][o-1]>=.2){let s=i[r-1].index,p=f[o-1].index;e[s].pairContent=e[p].parsed.content,e[p].pairContent=e[s].parsed.content}r--,o--}else m[r][o]==="up"?r--:o--},v=new Map,D=new Map,V=200,U=5,H=(e,i)=>{i.set(e.key,e),e.type==="chunk"&&e.blocks&&e.blocks.forEach(f=>H(f,i))},xe=(e,i)=>{if(!e)return{completed:[],active:[]};let f=`${e.id}-${e.text?.length||0}-${i}-${e.isStreaming}-${e.workedDuration||0}`;if(!e.isStreaming&&v.has(f))return v.get(f);let d=N(re(e.text||"",e.role)),c=`${e.id}-${i}`,l=new Map;if(e.isStreaming){let t=D.get(c);t&&d.startsWith(t.text)&&(l=t.blocksMap)}let m=(t,a,u,g={})=>{let x=l.get(t);if(x&&x.text===u&&x.type===a&&!!x.isActiveBlock==!!g.isActiveBlock&&!!x.isStreaming==!!g.isStreaming&&x.pairContent===g.pairContent)return x;let L=N(u),E={...g};return typeof E.pairContent=="string"&&(E.pairContent=N(E.pairContent)),Array.isArray(E.wrappedLines)&&(E.wrappedLines=E.wrappedLines.map(N)),{key:t,isStreamingMsg:!!e.isStreaming,workedDuration:e.workedDuration,type:a,text:L,msg:a==="full-message"?e:void 0,...E}};if(d.includes("- Content Preview:")){let t="",a=d.match(/File\s+\[(.*?)\]/i);a&&(t=a[1].split(".").pop().toLowerCase());let L=(d.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"";L=L.replace(/\n\s*\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\]\s*$/,"").trimEnd();let E=L.split(`
34
- `).map(S=>S.replace(/\r$/,"")),b=String(E.length).length,$=[],k=null,F=[],y=()=>{if(!F.length)return;let S=F;F=[],$.push(S.length===1?S[0]:{key:`${S[0].key}-chunk`,type:"chunk",blocks:S})},M=i-(b+6);return E.forEach((S,_)=>{let R=_===E.length-1,B=j(S,M).split(`
35
- `),W=m(`${e.id||Date.now()}-write-line-${_}`,"write-line",S,{gutterWidth:b,lineNum:_+1,isFirstLine:_===0,isLastLine:R,extension:t,wrappedLines:B});R&&e.isStreaming?(y(),k=W):(F.push(W),F.length>=U&&y())}),y(),{completed:$,active:k?[k]:[]}}let A=d.indexOf("[DIFF_START]");if(A!==-1&&!O(d,A)&&!d.includes("- Content Preview:")){let t=d.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),u=(t?t[1].trim():"").split(`
36
- `).map(k=>k.replace(/\r$/,"")),g=u.map(k=>({line:k,parsed:q(k),pairContent:null})),x=[];for(let k=0;k<g.length;k++){let F=g[k];F.parsed&&(F.parsed.isR||F.parsed.isA)?x.push(F):x.length>0&&(G(x),x=[])}x.length>0&&G(x);let L=[],E=null,b=[],$=()=>{if(!b.length)return;let k=b;b=[],L.push(k.length===1?k[0]:{key:`${k[0].key}-chunk`,type:"chunk",blocks:k})};return u.forEach((k,F)=>{let y=F===u.length-1,M=g[F].parsed,S=null;M&&(S=j(M.content,i-17).split(`
37
- `));let _=m(`${e.id||Date.now()}-diff-${F}`,"diff-line",k,{isFirstLine:F===0,isLastLine:y,pairContent:g[F].pairContent,wrappedLines:S});y&&e.isStreaming?($(),E=_):(b.push(_),b.length>=U&&$())}),$(),{completed:L,active:E?[E]:[]}}if(e.role==="system"||e.isLogo||e.isHelpRecord||e.isTerminalRecord||e.isHomeWarning||e.isImageStats||e.isAskRecord||e.isAboutRecord||e.isUpdateNotification||e.role==="user"){if(!d&&!e.isLogo&&!e.isHelpRecord&&!e.isTerminalRecord&&!e.isHomeWarning&&!e.isImageStats&&!e.isAskRecord&&!e.isAboutRecord&&!e.isUpdateNotification){let t={completed:[],active:[]};return v.set(f,t),t}return{completed:[m(`${e.id||Date.now()}-full`,"full-message",d)],active:[]}}if(!d&&!e.isStreaming){let t={completed:[],active:[]};return v.set(f,t),t}let o=[],n=null,s=[],p=null,h=()=>{if(!s.length)return;let t=s;s=[],p=null,o.push(t.length===1?t[0]:{key:`${e.id||"x"}-chunk-${t[0].key}`,type:"chunk",blocks:t})},w=(t,a=!1)=>{if(p!==null&&p!==t.type&&h(),s.push(t),p=t.type,s.length>=U){if(e.isStreaming&&a)return;h()}},C=Math.max(20,(i||80)-6),I=Math.max(20,(i||80)-8);if(e.role==="think"){o.push(m(`${e.id}-header`,"think-header","",{duration:e.duration}));let t=d.split(`
38
- `),a=[];t.forEach(u=>{j(u,I).split(`
39
- `).forEach(x=>a.push(x))}),a.forEach((u,g)=>{let x=g===a.length-1;w(m(`${e.id}-${g}`,"think-line",u,{}),x)}),e.isStreaming||(h(),o.push({key:`${e.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let t=d.split(`
40
- `),a=!1,u=[],g=!1,x="",L=0,E=0,b=[];t.forEach($=>{let k=$.trim();k.startsWith("```")?(g=!g,b.push($)):g||k.startsWith("|")?b.push($):j($,C).split(`
41
- `).forEach(y=>b.push(y))}),g=!1,b.forEach(($,k)=>{let F=k===b.length-1,y=$.trim().startsWith("|"),M=$.trim().startsWith("```");if(g)M?(g=!1,w(m(`${e.id}-code-close-${E}`,"code-fence-close","",{}),F)):(L++,w(m(`${e.id}-code-line-${k}`,"code-line",$,{lineNum:L,lang:x}),F));else if(M)g=!0,E=k,L=0,x=$.trim().replace(/^```/,"").trim(),w(m(`${e.id}-code-open-${k}`,"code-fence-open",x,{}),F);else if(y){if(a||(a=!0,u=[]),u.push($),u.length===2){let S=u[0],_=S.split("|");_[0]!==void 0&&_[0].trim()===""&&_.shift(),_.length>0&&_[_.length-1].trim()===""&&_.pop();let R=_.map(B=>B.trim());w(m(`${e.id}-table-hdr-${k}`,"table-header",S,{colHeaders:R,colCount:R.length}),F)}else if(u.length>2){let S=$.split("|");S[0]!==void 0&&S[0].trim()===""&&S.shift(),S.length>0&&S[S.length-1].trim()===""&&S.pop();let _=S.map(z=>z.trim()),R=u[0].split("|");R[0]!==void 0&&R[0].trim()===""&&R.shift(),R.length>0&&R[R.length-1].trim()===""&&R.pop();let B=R.map(z=>z.trim()),W=Math.max(1,B.length);w(m(`${e.id}-table-row-${k}`,"table-row",$,{cells:_,colHeaders:B,colCount:W,rowIndex:u.length-3}),F)}F&&!e.isStreaming&&(h(),w(m(`${e.id}-table-end-${k}`,"table-close","",{}),!0))}else a&&(w(m(`${e.id}-table-end-${k}`,"table-close","",{}),F),a=!1,u=[]),w(m(`${e.id}-${k}`,"agent-line",$,{}),F)}),!e.isStreaming&&e.workedDuration&&(h(),o.push(m(`${e.id}-worked-duration`,"worked-duration","")))}e.isStreaming&&s.length>0?n=s.length===1?s[0]:{key:`${e.id||"x"}-chunk-active-${s[0].key}`,type:"chunk",blocks:s}:h();let T={completed:o,active:n?[n]:[]};if(e.isStreaming){let t=new Map;if(o.forEach(a=>H(a,t)),n&&H(n,t),D.set(c,{text:d,blocksMap:t}),D.size>V){let a=D.keys().next().value;D.delete(a)}}else{if(v.set(f,T),v.size>V){let t=v.keys().next().value;v.delete(t)}D.delete(c)}return T},Q={},ee=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,O=(e,i)=>{let f=!1,d=!1,c=0;for(;c<i;){if(e.startsWith("```",c)){f=!f,c+=3;continue}if(f){c++;continue}if(e[c]===`
42
- `){d=!1,c++;continue}e[c]==="`"&&(c===0||e[c-1]!=="\\")&&(d=!d),c++}if(f)return!0;if(d){let l=e.indexOf(`
43
- `,i),m=l===-1?e.length:l;if(e.substring(i,m).includes("`"))return!0}return!1},te=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[(?:TOOL|ACTION) RESULTS?\]:?\s*|\[\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,ne=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,se=/\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,P=!1,re=(e,i="agent")=>{if(!e)return e;let f=i===!0||i==="think",d=i===!1||i==="agent",c=e.replace(/<\|channel>thought/gi,"<think_fluxflow>").replace(/<channel\|>/gi,"</think_fluxflow>");if(f)return c.replace(/^<think_fluxflow>/gi,"").replace(/<\/think_fluxflow>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let l=c;if(c.trimStart().startsWith("ERROR: [INTERNAL CRITICAL] "))return"";d&&(l=l.replace(/<\/?think_fluxflow>/gi,(o,n,s)=>O(s,n)?o:""),l=l.replace(ee,(o,n,s,p)=>!P&&O(p,s)?o:""),l&&(l.includes("[tool:")||l.includes("[action:"))&&(l=l.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(o,n,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():o),P&&(l=l.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(o,n)=>n.includes("[tool:")||n.includes("[action:")?n.trim():o))));let m="tool:",A="action:";if(d&&(l.toLowerCase().includes(m)||l.toLowerCase().includes(A)))for(;;){let o=l.toLowerCase(),n=o.indexOf(m),s=o.indexOf(A),p=m,h=n;if((n===-1||s!==-1&&s<n)&&(p=A,h=s),h===-1)break;if(!P&&O(l,h)){let g=-1,x=0;for(;;){let L=o.indexOf(m,x),E=o.indexOf(A,x),b=-1,$=m;if(L===-1&&E===-1)break;if(L===-1||E!==-1&&E<L?(b=E,$=A):b=L,!O(l,b)){g=b,p=$;break}x=b+$.length}if(g===-1)break;h=g}let w=h,C=!1,I=h-1;for(;I>=0&&/\s/.test(l[I]);)I--;I>=0&&l[I]==="["&&(w=I,C=!0);let T=0,t=!1,a=null,u=h;for(;u<l.length;){let g=l[u];if(!a&&(g==="'"||g==='"'||g==="`")?a=g:a&&g===a&&l[u-1]!=="\\"&&(a=null),a||(g==="("?(T++,t=!0):g===")"&&T--),t&&T===0&&!a){let x=u;if(C){let L=u+1;for(;L<l.length&&/\s/.test(l[L]);)L++;L<l.length&&l[L]==="]"&&(x=L)}l=l.substring(0,w)+l.substring(x+1);break}if(u++,u===l.length){l=l.substring(0,w);break}}}d&&(l=l.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*\s*\([\s\S]*?\)\s*\]/gi,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*[\s\S]*$/gi,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/^(?:\s*=\s*["'][^"'\n]*["']|\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))(?:\s*,\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))*\s*\)?\]\s*/gm,(o,n,s)=>!P&&O(s,n)?o:""),l=l.replace(/(?:\r?\n|^)\s*=\s*["'][^"'\n]*["'][\s\S]*?\s*\)?\]\s*/g,(o,n,s)=>!P&&O(s,n)?o:`
44
- `));let r=i==="tool_result"||i==="tool"||i==="action"||i==="action_result";return l=l.replace(te,(o,n,s,p)=>{if(/^\[(?:TOOL|ACTION) RESULTS?\]:?\s*/i.test(o)||/^\[\s*(?:TOOL|ACTION).*?$/i.test(o)){if(r||O(p,s))return o}else if(O(p,s))return o;return""}),l=l.replace(ne,o=>{let n=o.toLowerCase();return n.includes("leftrightarrow")?"\u2194":n.includes("rightarrow")?"\u2192":n.includes("leftarrow")?"\u2190":n.includes("uparrow")?"\u2191":n.includes("downarrow")?"\u2193":o}),l=l.replace(se,o=>Q[o.toLowerCase()]||o),l.trim()},me=()=>{v.clear(),D.clear()};export{N as a,j as b,ce as c,ae as d,fe as e,ue as f,he as g,de as h,pe as i,ge as j,q as k,G as l,xe as m,O as n,re as o,me as p};
@@ -1,3 +0,0 @@
1
- import{a as m}from"./chunk-PTFCY2D5.js";import{a as L}from"./chunk-XPIXBWTZ.js";import{n as U}from"./chunk-WEDUYGPN.js";import"./chunk-NTZSL2UT.js";import"./chunk-YFIWMGCS.js";var Q=async function*(_,C,v,E,A,b,$,d,W=1,B=""){let x=[];E&&x.push({role:"system",content:E});for(let t of v){let e=t.role==="user"?"user":"assistant",n=[];if(Array.isArray(t.parts)){for(let o of t.parts)if(o.text)n.push({type:"text",text:o.text});else if(o.inlineData&&$){let c=o.inlineData.mimeType,u=o.inlineData.data;c.startsWith("image/")&&n.push({type:"image_url",image_url:{url:`data:${c};base64,${u}`}})}}else{let o=t.text||"";o&&n.push({type:"text",text:o})}x.push({role:e,content:n.length===1&&n[0].type==="text"?n[0].text:n})}let P=L("c_openai",C,A),y=P!==null?P:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"xhigh"}[A],a={model:C,messages:x,stream:!0,stream_options:{include_usage:!0},temperature:W,tools:[],tool_choice:"none"};y&&y!=="none"&&(a.reasoning_effort=y,a.reasoning={effort:y});let N=(B||process.env.CUSTOM_OPENAI_URL||process.env.C_OPENAI_URL||"").trim();if(!N)throw new Error("Custom OpenAI Base URL is not configured. Please set Base URL in /settings -> Providers.");let f=N.replace(/\/+$/,"");f.endsWith("/chat/completions")||(f.endsWith("/v1")?f=`${f}/chat/completions`:f=`${f}/chat/completions`);let l={"Content-Type":"application/json",Accept:"text/event-stream, application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow"},S=_===U,T=S?"":_&&_!=="LOCAL"?_:process.env.CUSTOM_OPENAI_API_KEY||process.env.C_OPENAI_API_KEY||"";if(!S&&T&&T.trim()!==""){let t=T.trim();l.Authorization=t.startsWith("Bearer ")?t:`Bearer ${t}`,l["api-key"]=t}let s=await m(f,{method:"POST",headers:l,body:JSON.stringify(a),signal:d});if(!s.ok&&(s.status===400||s.status===422)&&(a.reasoning||a.reasoning_effort)){if(console.info(`
2
- `),a.reasoning&&a.reasoning_effort){let t={...a};delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok&&a.reasoning_effort){let t={...a};delete t.reasoning;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok){let t={...a};delete t.reasoning,delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:l,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}}if(!s.ok){let t=await s.json().catch(()=>({})),e=t.error?.metadata?.raw||t.error?.message||(typeof t.error=="string"?t.error:"")||t.message||s.statusText||"Unknown error";throw new Error(`Custom OpenAI Error (${s.status}): ${e}`)}let F=s.body.getReader(),J=new TextDecoder,w="",i=[],p=null,k=Date.now(),g=!1,R=(t,e)=>{if(!t&&!e)return null;if(t){if(typeof t.reasoning_content=="string"&&t.reasoning_content)return t.reasoning_content;if(typeof t.reasoning=="string"&&t.reasoning)return t.reasoning;if(typeof t.thinking=="string"&&t.thinking)return t.thinking;if(typeof t.thought=="string"&&t.thought)return t.thought;if(typeof t.reasoning_text=="string"&&t.reasoning_text)return t.reasoning_text;if(Array.isArray(t.reasoning_details)&&t.reasoning_details.length>0){let n=t.reasoning_details.map(o=>typeof o=="string"?o:o?.text||o?.content||"").filter(Boolean).join("");if(n)return n}}if(e){if(typeof e.reasoning_content=="string"&&e.reasoning_content)return e.reasoning_content;if(typeof e.reasoning=="string"&&e.reasoning)return e.reasoning}return null},K=(t,e)=>{if(t){if(typeof t.content=="string"&&t.content)return t.content;if(typeof t.text=="string"&&t.text)return t.text;if(Array.isArray(t.content))return t.content.map(n=>typeof n=="string"?n:n?.text||"").join("")}return e&&typeof e.text=="string"&&e.text?e.text:""},Y=t=>{let e=t.usage||t.usageMetadata||t.choices?.[0]?.usage||null;if(!e)return null;let n=e.prompt_tokens||e.promptTokenCount||e.input_tokens||0,o=e.completion_tokens||e.candidatesTokenCount||e.output_tokens||0,c=e.total_tokens||e.totalTokenCount||n+o,u=e.prompt_tokens_details?.cached_tokens||e.prompt_tokens_details?.cache_read_input_tokens||e.cachedContentTokenCount||e.cache_read_input_tokens||0,r=e.completion_tokens_details?.reasoning_tokens||e.thoughtsTokenCount||e.reasoning_tokens||0;return{totalTokenCount:c,promptTokenCount:n,candidatesTokenCount:o,cachedContentTokenCount:u,thoughtsTokenCount:r}};for(;;){let{done:t,value:e}=await F.read();if(t){g&&(i.length>0||p)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:p});break}w+=J.decode(e,{stream:!0});let n=w.split(`
3
- `);w=n.pop();for(let o of n){let c=o.trim();if(!c||!c.startsWith("data: "))continue;let u=!1;if(c==="data: [DONE]"||c==="data: [DONE]\r")u=!0;else try{let r=JSON.parse(c.substring(6));if(r.error){let H=r.error.metadata?.raw||r.error.message||(typeof r.error=="string"?r.error:JSON.stringify(r.error));throw new Error(`Custom OpenAI Stream Error: ${H}`)}let h=r.choices?.[0],O=h?.delta;h?.finish_reason&&h.finish_reason!=="null"&&(u=!0);let D=Y(r);D&&(p=D,g=!0);let I=R(O,h);I&&(i.push({text:I,thought:!0}),g=!0);let M=K(O,h);M&&(i.push({text:M}),g=!0)}catch(r){if(r.message&&r.message.startsWith("Custom OpenAI Stream Error:"))throw r}if((u||Date.now()-k>=150)&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],k=Date.now(),g=!1),u)break}Date.now()-k>=150&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],k=Date.now(),g=!1)}};export{Q as getCustomOpenAIStream};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-I5LTKU2O.js";import"./chunk-YFIWMGCS.js";export{a as DEFAULT_MODEL_CONFIG,o as getDefaultModel,q as getFallbackValue,b as getModelConfig,p as getModelPricing,n as getModels,m as hasModelReasoning,l as isModelMultimodal,h as removeModelFromProvider,i as renameModelInProvider,c as saveModelConfigToDisk,d as saveModelToProvider,j as setCustomMultimodal,g as setDefaultModelForProvider,f as setModelMultimodalInProvider,k as setOllamaMultimodal,e as updateModelInfoInProvider};