fluxflow-cli 4.49.0 → 5.0.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.
- package/ARCHITECTURE.md +7 -16
- package/README.md +1 -4
- package/TOOLS.md +0 -9
- package/UI_FEATURES.md +1 -2
- package/dist/chunks/ai-WBRHU7IH.js +1 -0
- package/dist/chunks/app-ML5GKD3A.js +325 -0
- package/dist/chunks/{auto_completion-33R46AFF.js → auto_completion-UG6IEWD2.js} +1 -1
- package/dist/chunks/{chat-BA72I6O3.js → chat-ISCVWNVN.js} +1 -1
- package/dist/chunks/chunk-24LJKH4G.js +847 -0
- package/dist/chunks/chunk-7SGZ66KT.js +44 -0
- package/dist/chunks/chunk-B4UKMX5E.js +1 -0
- package/dist/chunks/{chunk-Z5D4VQSG.js → chunk-EXT42EJZ.js} +1 -1
- package/dist/chunks/{chunk-IMX3PWYO.js → chunk-GBH7XI5A.js} +1 -1
- package/dist/chunks/{chunk-ZCM4J7JT.js → chunk-J4J3F6BT.js} +1 -1
- package/dist/chunks/chunk-LQM3JK7N.js +1 -0
- package/dist/chunks/{chunk-AIWOSKP3.js → chunk-QESQR5GB.js} +1 -1
- package/dist/chunks/chunk-V36DXF56.js +13 -0
- package/dist/chunks/{chunk-TNA3R7TS.js → chunk-ZNO55RNG.js} +1 -1
- package/dist/chunks/{click-HMFVJIQN.js → click-AWHZCV2E.js} +2 -2
- package/dist/chunks/{computer_action-6AYM3W7D.js → computer_action-MO2JR2XH.js} +1 -1
- package/dist/chunks/{custom_openai-HY6EEQI2.js → custom_openai-K554R7Q5.js} +1 -1
- package/dist/chunks/{drag-H53TOSDP.js → drag-D2GVPIQB.js} +1 -1
- package/dist/chunks/{generate_image-JS7J4FLD.js → generate_image-45UQ6P2B.js} +1 -1
- package/dist/chunks/{invoke-WGWAIYZH.js → invoke-DVZUJJV3.js} +2 -2
- package/dist/chunks/{invokeSync-DCL3EMVV.js → invokeSync-NEZGW27B.js} +2 -2
- package/dist/chunks/{key_press-NF322TXF.js → key_press-AQNKL6UM.js} +1 -1
- package/dist/chunks/{keyboard_typing-OADL5LPA.js → keyboard_typing-QSBPTZJ6.js} +1 -1
- package/dist/chunks/{mistral-YTTOZB2J.js → mistral-ON6RQMK7.js} +1 -1
- package/dist/chunks/{model_config-JTMSQGKH.js → model_config-QRYAVWHF.js} +1 -1
- package/dist/chunks/{nvidia-ON4Q6Q26.js → nvidia-I6DPWP6U.js} +2 -2
- package/dist/chunks/{ollama-NWY2XLYF.js → ollama-6WSZPCI5.js} +1 -1
- package/dist/chunks/{recapture_screen-IXVMQR5C.js → recapture_screen-PPXYK2YY.js} +1 -1
- package/dist/chunks/{screen_grid-DGIDOOQD.js → screen_grid-3RU324CV.js} +1 -1
- package/dist/chunks/{scroll-B3HCFDTS.js → scroll-TSU6MTGU.js} +1 -1
- package/dist/chunks/search_keyword-DZY4MWV7.js +8 -0
- package/dist/chunks/{secrets-NGDMM5RJ.js → secrets-TNMLVMST.js} +1 -1
- package/dist/chunks/{secrets_v2-R5GMXRT3.js → secrets_v2-OBRWR3UT.js} +1 -1
- package/dist/chunks/{settings-JME7GCEU.js → settings-PUFSRWT3.js} +1 -1
- package/dist/chunks/update_file-TGEB5UWK.js +13 -0
- package/dist/chunks/usage-EBE2OVES.js +1 -0
- package/dist/chunks/{usageServer-RJDE5QDZ.js → usageServer-RTK5N5KE.js} +1 -2
- package/dist/chunks/write_file-O6OF7Z2W.js +32 -0
- package/dist/cli.js +27 -24
- package/dist/model_config.json +2 -30
- package/dist/package.json +2 -2
- package/model_config.json +2 -30
- package/package.json +2 -2
- package/dist/chunks/ai-QEMKCYGG.js +0 -1
- package/dist/chunks/app-6TAUOS56.js +0 -333
- package/dist/chunks/chunk-2XQIWDKW.js +0 -1
- package/dist/chunks/chunk-2YDU2B2F.js +0 -13
- package/dist/chunks/chunk-36FKJWXK.js +0 -949
- package/dist/chunks/chunk-AMFNIFF3.js +0 -44
- package/dist/chunks/chunk-HTOLY3HR.js +0 -1
- package/dist/chunks/search_keyword-UXNKLCGC.js +0 -8
- package/dist/chunks/update_file-YXW37NRJ.js +0 -13
- package/dist/chunks/usage-URT2EC23.js +0 -1
- package/dist/chunks/write_file-WMLWKQKI.js +0 -32
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import{c as U}from"./chunk-26BQ45XP.js";import G from"os";import{structuredPatch as V}from"diff";var R=e=>typeof e!="string"?e:e.length>12?(e+"").replace("",""):e,D=(e,o)=>{if(!e)return"";let d=/\x1B\[[0-?]*[ -/]*[@-~]/g,p=e.split(`
|
|
2
|
-
`),c=[];if(o<=5)return e;let i=t=>t<32||t>=127&&t<160||t>=768&&t<=879||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071?0:t>=4352&&t<=4447||t>=9001&&t<=9002||t>=11904&&t<=12350||t>=12352&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=127744&&t<=128591||t>=128640&&t<=128767||t>=131072&&t<=262141?2:1,w=t=>{let r=t.replace(d,""),s=0;for(let l=0;l<r.length;l++){let h=r.codePointAt(l);h>65535&&l++,s+=i(h)}return s},I=(t,r)=>{let s=0,l=t.length,h=!1;for(let x=0;x<t.length;x++){if(t[x]==="\x1B"&&t[x+1]==="["&&(h=!0),h){(t[x]==="m"||t[x]>="@"&&t[x]<="~"&&t[x]!=="[")&&(h=!1);continue}let L=t.codePointAt(x);L>65535&&x++;let E=i(L);if(s+E>r){l=L>65535?x-1:x;break}if(s+=E,s>=r){l=x+1;break}}return{head:t.substring(0,l),tail:t.substring(l)}};return p.forEach(t=>{if(w(t)<=o){c.push(t);return}let s=t.split(/(\s+)/),l="",h=0,x=t.match(/^(\s*)/),L=x?x[1]:"";s.forEach(E=>{if(E.length===0)return;let u=E;for(;u.length>0;){let $=w(u);if(h+$<=o){l+=u,h+=$;break}l.trim().length>0&&(c.push(l.trimEnd()),l=L.substring(0,Math.min(L.length,8)),h=w(l));let n=Math.max(1,o-h);if(w(u)>n){let{head:f,tail:a}=I(u,n);c.push((l+f).trimEnd()),l=L.substring(0,Math.min(L.length,8)),h=w(l),u=a}else l+=u,h+=w(u),u=""}}),(l.trimEnd().length>0||l===L)&&c.push(l.trimEnd())}),R(c.join(`
|
|
3
|
-
`))},oe=e=>{if(!e)return 0;let o=0,d=e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);d&&(o+=d.length*.55);let p=e.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),c=p.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);c&&(o+=c.length);let i=p.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return o+=i.length,Math.max(.1,o)},le=e=>e?e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[e]:[],ce=e=>{if(!e&&e!==0)return"0.0k";let o=typeof e=="string"?parseFloat(e):e;return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:o.toString()},ae=(e,o=40)=>{let d=U.replaceAll("\\\\","\\");if(e=e.replace(G.homedir(),"~").replace(d,"FluxFlow").replaceAll("\\","/"),!e||e.length<=o)return R(e);let p=Math.floor((o-3)/2);return R(e.substring(0,p)+"..."+e.substring(e.length-p).replaceAll("\\","/"))},fe=e=>{let o=[],d=new Set,p=e.allowMultiple===!0||String(e.allowMultiple).toLowerCase()==="true";Object.keys(e).forEach(t=>{let r=t.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(r){let s=r[2]?parseInt(r[2],10):1;d.add(s)}});let c=Array.from(d).sort((t,r)=>t-r),i=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],w=["newContent","new_content","content_to_add","newBlock","new_block"],I=(t,r,s)=>{let l,h;for(let x of r){let L=t===1?[`${x}1`,x,`${x}_1`]:[`${x}${t}`,`${x}_${t}`];for(let E of L)if(e[E]!==void 0){l=e[E];break}if(l!==void 0)break}for(let x of s){let L=t===1?[`${x}1`,x,`${x}_1`]:[`${x}${t}`,`${x}_${t}`];for(let E of L)if(e[E]!==void 0){h=e[E];break}if(h!==void 0)break}return{r:l,n:h}};for(let t of c){let{r,n:s}=I(t,i,w);if(r!==void 0&&s!==void 0)o.push({replace:r,new:s});else if(r!==void 0||s!==void 0)return{error:`Mismatched replacement pair for index ${t}. Both replacement and new content must be provided.`,allowMultiple:p}}return{patchPairs:o,allowMultiple:p}},Z=e=>{if(!e)return null;let o="",d=0,p=e.length;for(;d<p;){let c=e[d];if(c==="\\"){for(;d<p&&e[d]==="\\";)d++;o+="\\\\*"}else if(c===`
|
|
4
|
-
`)o+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",d++;else if(c==="\r")o+="(?:\\r|\\\\*r)?",d++;else if(c===" ")o+="(?:\\t|\\\\*t|\\s*)",d++;else if(c==='"'||c==="'"||c==="`")o.endsWith("\\\\*")||(o+="\\\\*"),o+=c,d++;else if(/[.*+?^${}()|[\]]/.test(c))o+="\\"+c,d++;else if(/\s/.test(c)){for(;d<p&&/\s/.test(e[d])&&e[d]!==`
|
|
5
|
-
`&&e[d]!=="\r"&&e[d]!==" ";)d++;o+="\\s*"}else o+=c,d++}if(!o)return null;try{return new RegExp(o,"g")}catch{return null}},ue=(e,o,d={})=>{let p=typeof d=="boolean"?d:!!(d&&d.allowMultiple),c=e.replace(/\r\n/g,`
|
|
6
|
-
`).replace(/\r/g,`
|
|
7
|
-
`),i=n=>n.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
8
|
-
`).replace(/\r/g,`
|
|
9
|
-
`),w=n=>n.match(/^\s*/)[0],I=n=>{let f=n.split(`
|
|
10
|
-
`).filter(F=>F.trim()!=="");if(f.length===0)return"";let a=w(f[0]);for(let F of f){let g=w(F);g.length<a.length&&(a=g)}return a},t=(n,f,a="")=>{if(!n||f===void 0)return n;let g=/^\t/m.test(f)?" ":" ",C=b=>b.split(`
|
|
11
|
-
`).find(y=>y.trim()!=="")??"",S=C(f).match(/^\s*/)[0].length,m=C(n).match(/^\s*/)[0].length,k=S-m,A=(a.match(/^\s*/)||[""])[0].length;return n.split(`
|
|
12
|
-
`).map((b,y)=>{if(b.trim()===""&&y!==0)return"";let _=b.match(/^\s*/)[0].length,T=Math.max(0,_+k);return y===0&&(T=Math.max(0,T-A)),g.repeat(T)+b.trimStart()}).join(`
|
|
13
|
-
`)},r=[];for(let n=0;n<o.length;n++){let f=o[n],a=(f.replace||"").trim(),F=i(f.new||"");if(a.startsWith("^LINE:")&&a.endsWith("$")){let A=a.slice(6,-1).trim().split(".."),M=parseInt(A[0]),b=A[1]!==void 0?parseInt(A[1]):M;if(!isNaN(M)&&!isNaN(b)){let y=c.split(`
|
|
14
|
-
`);if(M<1||M>y.length||b<M||b>y.length){r.push({index:n,success:!1,error:`Block ${n+1}: Line range ^LINE:${M}..${b}$ out of bounds (file has ${y.length} lines).`});continue}let T=y.slice(M-1,b).join(`
|
|
15
|
-
`),O=0;for(let P=0;P<M-1;P++)O+=y[P].length+1;r.push({index:n,success:!0,startPos:O,firstMatchContent:T,content_to_add:F});continue}}let g=i(f.replace||"");if(g===""&&F===""){r.push({index:n,success:!1,error:`Block ${n+1}: Empty replace and add content.`});continue}let C=g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=null;if(g!==""&&c.includes(g))S=new RegExp(C,"g");else{let k=g.split(`
|
|
16
|
-
`).map(A=>A.trim()).filter(A=>A.length>0).map(A=>A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if(k.length>0){let A=k.join("\\s*");try{S=new RegExp(A,"g")}catch{S=new RegExp(C,"g")}}else S=new RegExp(C,"g")}let m=[...c.matchAll(S)];if(m.length===0&&g!==""){let k=Z(g);k&&(m=[...c.matchAll(k)])}if(m.length===0){r.push({index:n,success:!1,error:`Block ${n+1}: Could not find match.`});continue}if(m.length>1&&!p){r.push({index:n,success:!1,error:`Block ${n+1}: Found ${m.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let k of m)r.push({index:n,success:!0,startPos:k.index,firstMatchContent:k[0],content_to_add:F})}let s=r.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n=0;n<s.length-1;n++){let f=s[n],a=s[n+1];f.startPos+f.firstMatchContent.length>a.startPos&&(f.success=!1,f.error=`Block ${f.index+1}: Overlaps with another block.`,a.success=!1,a.error=`Block ${a.index+1}: Overlaps with another block.`)}let l=new Map,h=c,x=0,L=0,E=r.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n of E){let f=n.startPos,a=c.substring(0,f).split(`
|
|
17
|
-
`).length,F=f+x,g=a+L,C=h.lastIndexOf(`
|
|
18
|
-
`,F)+1,S=h.substring(C,F),m=t(n.content_to_add,n.firstMatchContent,S),k=h.split(`
|
|
19
|
-
`),A=[];for(let _=Math.max(0,g-4);_<g-1;_++)A.push({num:_+1,text:k[_]});let M=n.firstMatchContent.split(`
|
|
20
|
-
`),b=[],y=g+M.length-1;for(let _=y;_<Math.min(k.length,y+3);_++)b.push({num:_+1,text:k[_]});l.set(n,{success:!0,index:n.index,oldContent:n.firstMatchContent,newContent:m,originalStartLine:a,finalStartLine:g,contextBefore:A,contextAfter:b}),h=h.substring(0,F)+m+h.substring(F+n.firstMatchContent.length),x+=m.length-n.firstMatchContent.length,L+=m.split(`
|
|
21
|
-
`).length-n.firstMatchContent.split(`
|
|
22
|
-
`).length}let u=[];for(let n=0;n<o.length;n++){let f=E.filter(a=>a.index===n);if(f.length>0)for(let a of f)l.has(a)&&u.push(l.get(a));else{let a=r.find(F=>F.index===n);u.push({success:!1,error:a?a.error:`Block ${n+1}: Unknown error.`})}}let $=u.filter(n=>!n.success&&n.error&&n.error.includes("Could not find match"));if($.length===1)$[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if($.length>1){let n=$[$.length-1];n.error+=`
|
|
23
|
-
(Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:h,results:u}},he=(e,o,d,p=8,c=!1)=>{if(e===o)return"";let i=(e||"").split(/\r?\n/),w=(o||"").split(/\r?\n/),I=Math.max(i.length,w.length,1),t=Math.max(4,String(I).length),r=x=>String(x).padStart(t," "),s=`[DIFF_START]
|
|
24
|
-
`,l="\u2550".repeat(88),h=V("","",e||"",o||"","","",{context:3});if(!h||!h.hunks||h.hunks.length===0)return"";if(h.hunks.forEach((x,L)=>{let E=0,u=0;for(let F of x.lines)F[0]==="+"?E++:F[0]==="-"&&u++;let $=[];E>0&&$.push(`+${E}`),u>0&&$.push(`-${u}`);let n=`@@ ${$.join(" ")} @@`;s+=`[UI_CONTEXT] ${n}
|
|
25
|
-
`;let f=x.oldStart,a=x.newStart;for(let F of x.lines){let g=F[0],C=F.slice(1);g===" "?(s+=`[UI_CONTEXT] ${r(a)} |${C}
|
|
26
|
-
`,f++,a++):g==="-"?(s+=`-${r(f)} |${C}
|
|
27
|
-
`,f++):g==="+"&&(s+=`+${r(a)} |${C}
|
|
28
|
-
`,a++)}}),c){let x=`[DIFF_START]
|
|
29
|
-
`,L=s.substring(x.length),E=`[UI_CONTEXT] ${l}
|
|
30
|
-
`,$=L.split(E).map(n=>n.split(`
|
|
31
|
-
`).filter(a=>a.trim()!=="").length>120?`[[VERIFIED]]
|
|
32
|
-
${n}
|
|
33
|
-
[[/VERIFIED]]`:n);s=x+$.join(E)}return s+="[DIFF_END]",R(s)},K=e=>{if(!e)return null;let o=e.replace("[UI_CONTEXT]","").replace(/\r/g,""),d=o.startsWith("-"),p=o.startsWith("+"),c=d||p?o.substring(1):o,i=c.indexOf("|"),w=i!==-1?R(c.substring(0,i).trim()):"",I=R(i!==-1?c.substring(i+1):c);return{isR:d,isA:p,num:w,content:I}},Y=(e,o)=>{if(!e&&!o)return 1;if(!e||!o)return 0;let d=e.length,p=o.length,c=e,i=o;d<p&&(c=o,i=e);let w=c.length,I=i.length,t=new Int32Array(I+1),r=new Int32Array(I+1);for(let h=0;h<=I;h++)t[h]=h;for(let h=1;h<=w;h++){r[0]=h;let x=c[h-1];for(let L=1;L<=I;L++)x===i[L-1]?r[L]=t[L-1]:r[L]=Math.min(t[L],r[L-1],t[L-1])+1;t.set(r)}let s=t[I],l=Math.max(d,p);return l===0?1:1-s/l},H=e=>{let o=[],d=[];e.forEach((s,l)=>{s.parsed.isR?o.push({index:l,content:s.parsed.content}):s.parsed.isA&&d.push({index:l,content:s.parsed.content})});let p=o.length,c=d.length;if(p===0||c===0)return;let i=Array.from({length:p+1},()=>Array(c+1).fill(0)),w=Array.from({length:p+1},()=>Array(c+1).fill(""));for(let s=1;s<=p;s++)w[s][0]="up";for(let s=1;s<=c;s++)w[0][s]="left";let I=Array.from({length:p},()=>Array(c).fill(0));for(let s=0;s<p;s++)for(let l=0;l<c;l++)I[s][l]=Y(o[s].content.trim(),d[l].content.trim());for(let s=1;s<=p;s++)for(let l=1;l<=c;l++){let h=I[s-1][l-1],x=h>=.2?h:-10,L=i[s-1][l-1]+x,E=i[s-1][l],u=i[s][l-1];L>=E&&L>=u?(i[s][l]=L,w[s][l]="diag"):E>=u?(i[s][l]=E,w[s][l]="up"):(i[s][l]=u,w[s][l]="left")}let t=p,r=c;for(;t>0||r>0;)if(w[t][r]==="diag"){if(I[t-1][r-1]>=.2){let l=o[t-1].index,h=d[r-1].index;e[l].pairContent=e[h].parsed.content,e[h].pairContent=e[l].parsed.content}t--,r--}else w[t][r]==="up"?t--:r--},B=new Map,W=new Map,X=200,j=5,z=(e,o)=>{o.set(e.key,e),e.type==="chunk"&&e.blocks&&e.blocks.forEach(d=>z(d,o))},de=(e,o)=>{if(!e)return{completed:[],active:[]};let d=`${e.id}-${e.text?.length||0}-${o}-${e.isStreaming}-${e.workedDuration||0}`;if(!e.isStreaming&&B.has(d))return B.get(d);let p=R(ne(e.text||"",e.role)),c=`${e.id}-${o}`,i=new Map;if(e.isStreaming){let u=W.get(c);u&&p.startsWith(u.text)&&(i=u.blocksMap)}let w=(u,$,n,f={})=>{let a=i.get(u);if(a&&a.text===n&&a.type===$&&!!a.isActiveBlock==!!f.isActiveBlock&&!!a.isStreaming==!!f.isStreaming&&a.pairContent===f.pairContent)return a;let F=R(n),g={...f};return typeof g.pairContent=="string"&&(g.pairContent=R(g.pairContent)),Array.isArray(g.wrappedLines)&&(g.wrappedLines=g.wrappedLines.map(R)),{key:u,isStreamingMsg:!!e.isStreaming,workedDuration:e.workedDuration,type:$,text:F,msg:$==="full-message"?e:void 0,...g}};if(p.includes("- Content Preview:")){let u="",$=p.match(/File\s+\[(.*?)\]/i);$&&(u=$[1].split(".").pop().toLowerCase());let g=((p.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"").split(`
|
|
34
|
-
`).map(b=>b.replace(/\r$/,"")),C=String(g.length).length,S=[],m=null,k=[],A=()=>{if(!k.length)return;let b=k;k=[],S.push(b.length===1?b[0]:{key:`${b[0].key}-chunk`,type:"chunk",blocks:b})},M=o-(C+6);return g.forEach((b,y)=>{let _=y===g.length-1,T=D(b,M).split(`
|
|
35
|
-
`),O=w(`${e.id||Date.now()}-write-line-${y}`,"write-line",b,{gutterWidth:C,lineNum:y+1,isFirstLine:y===0,isLastLine:_,extension:u,wrappedLines:T});_&&e.isStreaming?(A(),m=O):(k.push(O),k.length>=j&&A())}),A(),{completed:S,active:m?[m]:[]}}if(p.includes("[DIFF_START]")){let u=p.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),n=(u?u[1].trim():"").split(`
|
|
36
|
-
`).map(m=>m.replace(/\r$/,"")),f=n.map(m=>({line:m,parsed:K(m),pairContent:null})),a=[];for(let m=0;m<f.length;m++){let k=f[m];k.parsed&&(k.parsed.isR||k.parsed.isA)?a.push(k):a.length>0&&(H(a),a=[])}a.length>0&&H(a);let F=[],g=null,C=[],S=()=>{if(!C.length)return;let m=C;C=[],F.push(m.length===1?m[0]:{key:`${m[0].key}-chunk`,type:"chunk",blocks:m})};return n.forEach((m,k)=>{let A=k===n.length-1,M=f[k].parsed,b=null;M&&(b=D(M.content,o-17).split(`
|
|
37
|
-
`));let y=w(`${e.id||Date.now()}-diff-${k}`,"diff-line",m,{isFirstLine:k===0,isLastLine:A,pairContent:f[k].pairContent,wrappedLines:b});A&&e.isStreaming?(S(),g=y):(C.push(y),C.length>=j&&S())}),S(),{completed:F,active:g?[g]:[]}}if(e.role==="system"||e.isLogo||e.isHelpRecord||e.isTerminalRecord||e.isHomeWarning||e.isImageStats||e.isAskRecord||e.isAboutRecord||e.isUpdateNotification||e.role==="user"){if(!p&&!e.isLogo&&!e.isHelpRecord&&!e.isTerminalRecord&&!e.isHomeWarning&&!e.isImageStats&&!e.isAskRecord&&!e.isAboutRecord&&!e.isUpdateNotification){let u={completed:[],active:[]};return B.set(d,u),u}return{completed:[w(`${e.id||Date.now()}-full`,"full-message",p)],active:[]}}if(!p&&!e.isStreaming){let u={completed:[],active:[]};return B.set(d,u),u}let I=[],t=null,r=[],s=null,l=()=>{if(!r.length)return;let u=r;r=[],s=null,I.push(u.length===1?u[0]:{key:`${e.id||"x"}-chunk-${u[0].key}`,type:"chunk",blocks:u})},h=(u,$=!1)=>{if(s!==null&&s!==u.type&&l(),r.push(u),s=u.type,r.length>=j){if(e.isStreaming&&$)return;l()}},x=Math.max(20,(o||80)-6),L=Math.max(20,(o||80)-8);if(e.role==="think"){I.push(w(`${e.id}-header`,"think-header","",{duration:e.duration}));let u=p.split(`
|
|
38
|
-
`),$=[];u.forEach(n=>{D(n,L).split(`
|
|
39
|
-
`).forEach(a=>$.push(a))}),$.forEach((n,f)=>{let a=f===$.length-1;h(w(`${e.id}-${f}`,"think-line",n,{}),a)}),e.isStreaming||(l(),I.push({key:`${e.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let u=p.split(`
|
|
40
|
-
`),$=!1,n=[],f=!1,a="",F=0,g=0,C=[];u.forEach(S=>{let m=S.trim();m.startsWith("```")?(f=!f,C.push(S)):f||m.startsWith("|")?C.push(S):D(S,x).split(`
|
|
41
|
-
`).forEach(A=>C.push(A))}),f=!1,C.forEach((S,m)=>{let k=m===C.length-1,A=S.trim().startsWith("|"),M=S.trim().startsWith("```");if(f)M?(f=!1,h(w(`${e.id}-code-close-${g}`,"code-fence-close","",{}),k)):(F++,h(w(`${e.id}-code-line-${m}`,"code-line",S,{lineNum:F,lang:a}),k));else if(M)f=!0,g=m,F=0,a=S.trim().replace(/^```/,"").trim(),h(w(`${e.id}-code-open-${m}`,"code-fence-open",a,{}),k);else if(A){if($||($=!0,n=[]),n.push(S),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 _=y.map(T=>T.trim());h(w(`${e.id}-table-hdr-${m}`,"table-header",b,{colHeaders:_,colCount:_.length}),k)}else if(n.length>2){let b=S.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()),_=n[0].split("|");_[0]!==void 0&&_[0].trim()===""&&_.shift(),_.length>0&&_[_.length-1].trim()===""&&_.pop();let T=_.map(P=>P.trim()),O=Math.max(1,T.length);h(w(`${e.id}-table-row-${m}`,"table-row",S,{cells:y,colHeaders:T,colCount:O,rowIndex:n.length-3}),k)}k&&!e.isStreaming&&(l(),h(w(`${e.id}-table-end-${m}`,"table-close","",{}),!0))}else $&&(h(w(`${e.id}-table-end-${m}`,"table-close","",{}),k),$=!1,n=[]),h(w(`${e.id}-${m}`,"agent-line",S,{}),k)}),!e.isStreaming&&e.workedDuration&&(l(),I.push(w(`${e.id}-worked-duration`,"worked-duration","")))}e.isStreaming&&r.length>0?t=r.length===1?r[0]:{key:`${e.id||"x"}-chunk-active-${r[0].key}`,type:"chunk",blocks:r}:l();let E={completed:I,active:t?[t]:[]};if(e.isStreaming){let u=new Map;if(I.forEach($=>z($,u)),t&&z(t,u),W.set(c,{text:p,blocksMap:u}),W.size>X){let $=W.keys().next().value;W.delete($)}}else{if(B.set(d,E),B.size>X){let u=B.keys().next().value;B.delete(u)}W.delete(c)}return E},q={},J=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,N=(e,o)=>{let d=!1,p=!1,c=0;for(;c<o;){if(e.startsWith("```",c)){d=!d,c+=3;continue}if(d){c++;continue}if(e[c]===`
|
|
42
|
-
`){p=!1,c++;continue}e[c]==="`"&&(c===0||e[c-1]!=="\\")&&(p=!p),c++}if(d)return!0;if(p){let i=e.indexOf(`
|
|
43
|
-
`,o),w=i===-1?e.length:i;if(e.substring(o,w).includes("`"))return!0}return!1},Q=/\[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,ee=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,te=/\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,v=!1,ne=(e,o="agent")=>{if(!e)return e;let d=o===!0||o==="think",p=o===!1||o==="agent",c=e.replace(/<\|channel>thought/gi,"<think_fluxflow>").replace(/<channel\|>/gi,"</think_fluxflow>");if(d)return c.replace(/^<think_fluxflow>/gi,"").replace(/<\/think_fluxflow>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let i=c;if(c.trimStart().startsWith("ERROR: [INTERNAL CRITICAL] "))return"";p&&(i=i.replace(/<\/?think_fluxflow>/gi,(t,r,s)=>N(s,r)?t:""),i=i.replace(J,(t,r,s,l)=>!v&&N(l,s)?t:""),i&&(i.includes("[tool:")||i.includes("[action:"))&&(i=i.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(t,r,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():t),v&&(i=i.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(t,r)=>r.includes("[tool:")||r.includes("[action:")?r.trim():t))));let w="tool:",I="action:";if(p&&(i.toLowerCase().includes(w)||i.toLowerCase().includes(I)))for(;;){let t=i.toLowerCase(),r=t.indexOf(w),s=t.indexOf(I),l=w,h=r;if((r===-1||s!==-1&&s<r)&&(l=I,h=s),h===-1)break;if(!v&&N(i,h)){let a=-1,F=0;for(;;){let g=t.indexOf(w,F),C=t.indexOf(I,F),S=-1,m=w;if(g===-1&&C===-1)break;if(g===-1||C!==-1&&C<g?(S=C,m=I):S=g,!N(i,S)){a=S,l=m;break}F=S+m.length}if(a===-1)break;h=a}let x=h,L=!1,E=h-1;for(;E>=0&&/\s/.test(i[E]);)E--;E>=0&&i[E]==="["&&(x=E,L=!0);let u=0,$=!1,n=null,f=h;for(;f<i.length;){let a=i[f];if(!n&&(a==="'"||a==='"'||a==="`")?n=a:n&&a===n&&i[f-1]!=="\\"&&(n=null),n||(a==="("?(u++,$=!0):a===")"&&u--),$&&u===0&&!n){let F=f;if(L){let g=f+1;for(;g<i.length&&/\s/.test(i[g]);)g++;g<i.length&&i[g]==="]"&&(F=g)}i=i.substring(0,x)+i.substring(F+1);break}if(f++,f===i.length){i=i.substring(0,x);break}}}return p&&(i=i.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*\s*\([\s\S]*?\)\s*\]/gi,(t,r,s)=>!v&&N(s,r)?t:""),i=i.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*[\s\S]*$/gi,(t,r,s)=>!v&&N(s,r)?t:""),i=i.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,(t,r,s)=>!v&&N(s,r)?t:""),i=i.replace(/(?:\r?\n|^)\s*=\s*["'][^"'\n]*["'][\s\S]*?\s*\)?\]\s*/g,(t,r,s)=>!v&&N(s,r)?t:`
|
|
44
|
-
`)),i=i.replace(Q,""),i=i.replace(ee,t=>{let r=t.toLowerCase();return r.includes("leftrightarrow")?"\u2194":r.includes("rightarrow")?"\u2192":r.includes("leftarrow")?"\u2190":r.includes("uparrow")?"\u2191":r.includes("downarrow")?"\u2193":t}),i=i.replace(te,t=>q[t.toLowerCase()]||t),i.trim()},pe=()=>{B.clear(),W.clear()};export{R as a,D as b,oe as c,le as d,ce as e,ae as f,fe as g,ue as h,he as i,K as j,H as k,de as l,ne as m,pe as n};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p}from"./chunk-26BQ45XP.js";import d from"fs";import _ from"path";import{fileURLToPath as I}from"url";var g={version:0,release:20261004,fallbacks:{janitor_default:"gemini-3.5-flash-lite",janitor_attempts_fallback:"gemma-4-26b-a4b-it",janitor_open_router:"google/gemma-4-26b-a4b-it:free",general_fallback:"gemini-3.5-flash-lite",deepseek_fast_fallback:"deepseek-v4-flash",deepseek_level_1:"deepseek-flash",deepseek_level_2:"deepseek-pro",mistral_janitor_fallback:"",mistral_level_1:"",nvidia_janitor_fallback:"mistralai/mistral-nemotron",nvidia_chat_summarizer_fallback:"nvidia/nemotron-3-super-120b-a12b",google_level_1:"gemini-3-flash-preview",google_level_2:"gemini-3.7-flash",gemma_emergency:"gemma-4-31b-it",gemma_janitor_fallback_google_openrouter:"google/gemma-4-26b-a4b-it:free",gemma_janitor_fallback_google:"gemma-4-26b-a4b-it",inferx_fallback:"",sensenova_fallback:"",crofai_fallback:"",aihubmix_fallback:"",poolside_fallback:"","9router_fallback":"",explabs_fallback:"",tokenharbor_fallback:"",infron_fallback:"",xkiro_fallback:"",c_openai_fallback:""},providers:{}};var C=I(import.meta.url),F=_.dirname(C),y="",O=[_.join(F,"../../model_config.json"),_.join(F,"../model_config.json")];for(let e of O)try{if(d.existsSync(e)){y=e;break}}catch{}var v=_.join(p,"model_config.json"),a=null,k=()=>{if(y)try{let e=d.readFileSync(y,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return t}catch{}return g&&typeof g=="object"?JSON.parse(JSON.stringify(g)):{version:0,release:20260913,fallbacks:{},providers:{}}};if(d.existsSync(v))try{let e=d.readFileSync(v,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object"){let o=k();t.fallbacks={...o.fallbacks||{},...t.fallbacks||{}},t.providers||(t.providers={}),t.release||(t.release=o.release||20260913),a=t}}catch{}a||(a=k());var x=new Set,h=new Set,m=()=>{let e=new Set,t=new Set;if(a.providers)for(let o of Object.keys(a.providers)){let r=a.providers[o];if(r&&r.models){let i=["Free","Paid"];for(let n of i){let s=r.models[n];if(Array.isArray(s)){for(let l of s)if(l&&l.cmd){let f=l.cmd.trim().toLowerCase();l.multimodal===!0&&e.add(f),l.hasReasoning===!0&&t.add(f)}}}}}if(Array.isArray(a.multimodal_models))for(let o of a.multimodal_models)o&&typeof o=="string"&&e.add(o.trim().toLowerCase());x=e,h=t};m();var $=()=>a,u=()=>{try{return d.existsSync(p)||d.mkdirSync(p,{recursive:!0}),d.writeFileSync(v,JSON.stringify(a,null,2),"utf-8"),!0}catch{return!1}},U=(e,t,o=!1,r=null,i=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let n=t.trim();if(!n)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let s=a.providers[e];s.models||(s.models={Free:[],Paid:[]}),Array.isArray(s.models.Free)||(s.models.Free=[]);let l=i?String(i).trim().replace(/\/+$/,""):null,f=s.models.Free.find(c=>(typeof c=="string"?c:c?.cmd)===n);if(f)if(typeof f=="string"){let c=s.models.Free.indexOf(f),b={cmd:n,multimodal:!!o,desc:n};r&&Object.keys(r).length>0&&(b.info=r),l&&(b.baseUrl=l),s.models.Free[c]=b}else f.multimodal=!!o,r&&Object.keys(r).length>0&&(f.info={...f.info||{},...r}),l&&(f.baseUrl=l);else{let c={cmd:n,multimodal:!!o,desc:n};r&&Object.keys(r).length>0&&(c.info=r),l&&(c.baseUrl=l),s.models.Free.push(c)}return m(),u(),{success:!0}},R=(e,t,o={})=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let r=t.trim();if(!r)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let i=a.providers[e];i.models||(i.models={Free:[],Paid:[]}),Array.isArray(i.models.Free)||(i.models.Free=[]);let n=r.toLowerCase(),s=i.models.Free.find(l=>{let f=typeof l=="string"?l:l?.cmd;return f&&f.trim().toLowerCase()===n});if(o===null)s&&typeof s=="object"&&delete s.info;else if(!s)i.models.Free.push({cmd:r,multimodal:!1,desc:r,info:o});else if(typeof s=="string"){let l=i.models.Free.indexOf(s);i.models.Free[l]={cmd:s,multimodal:!1,desc:s,info:o}}else s.info={...s.info||{},...o};return u(),{success:!0}},T=(e,t,o=!0)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let r=t.trim();if(!r)return{success:!1,reason:"Model ID cannot be empty"};let i=a.providers?.[e];if(!i||!i.models||!Array.isArray(i.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let n=i.models.Free.find(s=>(typeof s=="string"?s:s?.cmd)===r);if(!n)return{success:!1,reason:`Model "${r}" not found in ${e} model list`};if(typeof n=="string"){let s=i.models.Free.indexOf(n);i.models.Free[s]={cmd:r,multimodal:!!o,desc:r}}else n.multimodal=!!o;return m(),u(),{success:!0}},J=(e,t,o=!1,r=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let i=t.trim();if(!i)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let n=a.providers[e];n.models||(n.models={Free:[],Paid:[]}),Array.isArray(n.models.Free)||(n.models.Free=[]);let s=n.models.Free.find(l=>(typeof l=="string"?l:l?.cmd)===i);if(s)if(typeof s=="string"){let l=n.models.Free.indexOf(s),f={cmd:i,multimodal:!!o,desc:i};r&&Object.keys(r).length>0&&(f.info=r),n.models.Free[l]=f}else o&&(s.multimodal=!0),r&&Object.keys(r).length>0&&(s.info={...s.info||{},...r});else{let l={cmd:i,multimodal:!!o,desc:i};r&&Object.keys(r).length>0&&(l.info=r),n.models.Free.push(l)}return n.default_free=i,m(),u(),{success:!0}},W=(e,t)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let o=t.trim();if(!o)return{success:!1,reason:"Model ID cannot be empty"};let r=a.providers?.[e];if(!r||!r.models||!Array.isArray(r.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let i=r.models.Free.findIndex(n=>(typeof n=="string"?n:n?.cmd)===o);return i===-1?{success:!1,reason:`Model "${o}" not found in ${e} model list`}:(r.models.Free.splice(i,1),r.default_free===o&&(r.default_free=""),r.default_paid===o&&(r.default_paid=""),m(),u(),{success:!0})},E=(e,t,o)=>{if(!e||!t||!o)return{success:!1,reason:"Invalid provider or model IDs"};let r=t.trim(),i=o.trim();if(!r||!i)return{success:!1,reason:"Model IDs cannot be empty"};let n=a.providers?.[e];if(!n||!n.models||!Array.isArray(n.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let s=n.models.Free.find(l=>(typeof l=="string"?l:l?.cmd)===r);if(!s)return{success:!1,reason:`Model "${r}" not found in ${e} model list`};if(typeof s=="string"){let l=n.models.Free.indexOf(s);n.models.Free[l]={cmd:i,multimodal:!1,desc:i}}else s.cmd=i,(s.desc===r||!s.desc)&&(s.desc=i);return m(),u(),{success:!0}},M=!1,P=e=>{M=!!e},z=P,G=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return!!(M||x.has(t)||t.startsWith("gemini-")||t.startsWith("gemma-"))},K=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return h.has(t)},V=(e,t,o=null)=>{let r=a.providers[e];if(!r)return[];let i=r.models[t==="Free"?"Free":"Paid"]||[];if(e==="c_openai"&&o){let n=String(o).trim().replace(/\/+$/,"");return i.filter(s=>typeof s=="object"&&s?.baseUrl?s.baseUrl.replace(/\/+$/,"")===n:!0)}return i},X=(e,t)=>{let o=a.providers[e];return o?t==="Free"?o.default_free:o.default_paid:""},q=(e,t)=>{if(!e||!t||!a.providers)return null;let o=a.providers[e];if(!o||!o.models)return null;let r=t.trim().toLowerCase(),i=["Free","Paid"];for(let n of i){let s=o.models[n];if(Array.isArray(s)){for(let l of s)if(typeof l=="object"&&l?.cmd&&l.cmd.trim().toLowerCase()===r&&l.info)return{IN:Number(l.info.IN)||0,OUT:Number(l.info.OUT)||0,CR:Number(l.info.CR)||0,CW:Number(l.info.CW)||0}}}return null},B=e=>a?.fallbacks?.[e];export{g as a,$ as b,u as c,U as d,R as e,T as f,J as g,W as h,E as i,P as j,z as k,G as l,K as m,V as n,X as o,q as p,B as q};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as Y}from"./chunk-Y5JU726N.js";import{b as Q}from"./chunk-2XQIWDKW.js";import"./chunk-HTOLY3HR.js";import"./chunk-P5HBJA23.js";import{w as V,x as q,y as J}from"./chunk-26BQ45XP.js";import K from"fs/promises";import E from"path";import j from"fast-glob";import{Minimatch as tt}from"minimatch";async function A(f,o,n=f,p=1){if(p>12)return[];let h=[],s;try{s=await K.readdir(f,{withFileTypes:!0})}catch{return[]}for(let t of s){let a=E.join(f,t.name),y=E.relative(n,a),L=y.split(E.sep).map(w=>w.toLowerCase()),O=t.name.toLowerCase();if(!o.some(w=>{let F=w.toLowerCase();return F.startsWith(".")&&O.endsWith(F)?!0:L.some(M=>M===F||M.startsWith(".pnpm"))}))if(t.isDirectory()){let w=await A(a,o,n,p+1);h=h.concat(w)}else t.isFile()&&h.push({fullPath:a,relativePath:y})}return h}function rt(f,o,n=1/0){if(f===o)return 0;if(f.length===0)return o.length;if(o.length===0)return f.length;if(Math.abs(f.length-o.length)>n)return n+1;let p=Array.from({length:o.length+1},(h,s)=>s);for(let h=1;h<=f.length;h++){let s=[h],t=h;for(let a=1;a<=o.length;a++){let y=f[h-1]===o[a-1]?0:1,L=Math.min(s[a-1]+1,p[a]+1,p[a-1]+y);s.push(L),L<t&&(t=L)}if(p=s,t>n)return n+1}return p[o.length]}function nt(f,o){if(!f||!o)return!1;let n=f.toLowerCase(),p=o.toLowerCase();if(n.includes(p))return!0;let h=n.split(/[^a-z0-9]+/).filter(t=>t.length>0),s=p.split(/[^a-z0-9]+/).filter(t=>t.length>1||p.length===1&&t.length>0);return s.length===0?!1:s.every(t=>{let a=t.length<=2?0:t.length<=5?1:2;for(let y of h)if(y.includes(t)||t.length>=3&&y.length>=3&&Math.abs(y.length-t.length)<=a&&rt(t,y,a)<=a)return!0;return!1})}var gt=async f=>{let{keyword:o,path:n,fuzzy:p,subString:h,regex:s}=Y(f);if(o==null)return'ERROR: Missing "keyword" argument.';let t=String(o);if(n){let e=n.trim().toLowerCase();if(e==="#docs"||e==="#doc"||e==="#documentation"||e.includes("#skill/global/fluxflow")||e.startsWith("#skill"))return"ERROR: Cannot search in reserved VFS '#skill' namespace. Use 'ReadFile' to read specific skills."}let a=e=>e===!0||e==="true"||e===1||e==="1"||e==="yes",y=s===!1||s==="false"||s===0||s==="0"||s==="no",L=s===!0||s==="true"||s===1||s==="1"||s==="yes",O=a(p)||a(h),G=null,w=null;if(y)O||(w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i"));else{try{G=new RegExp(t,"i")}catch(e){if(L)return`ERROR: Invalid regex pattern "${t}": ${e.message}`}w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i")}let F=Array.from(new Set([...V,...q(process.cwd())])),M=150;try{let e=[],P=process.cwd(),u=null;if(n){let i=r=>r.startsWith("!")||!r.startsWith("-")?r:"!"+r.replace(/^-+/,""),g=n.split(";").map(r=>r.trim()).filter(Boolean).map(i).filter(r=>r!=="!"),c=g.some(r=>r.startsWith("!"));if(g.some(r=>j.isDynamicPattern(r)||/[*?{}[\]()|+]/.test(r))){u="glob";let r=n.replace(/\\/g,"/"),l=g.map(m=>m.replace(/\\/g,"/")),z=F.map(m=>m.startsWith(".")?`**/*${m}`:`**/${m}/**`);if(c&&!g.some(m=>!m.startsWith("!"))){let m=await A(P,F,P),R=$=>$.endsWith("/")?$+"**":$,d=l.filter($=>$.startsWith("!")).map($=>R($.slice(1))),v=l.filter($=>!$.startsWith("!")).map(R);e=m.filter($=>{let x=$.relativePath.replace(/\\/g,"/"),_=v.length===0||v.some(b=>{try{return new tt(b).match(x)}catch{return!1}}),Z=d.some(b=>{try{return new tt(b).match(x)}catch{return!1}});return _&&!Z})}else{let m=l.some(d=>/[\(\)\|]|\.\*/.test(d)),R=[];if(!m)try{R=await j(l,{cwd:P,ignore:z,dot:!0,onlyFiles:!0,absolute:!1})}catch{R=[]}if(R.length===0&&(m||j.isDynamicPattern(r))){let d=r.match(/^([^\*\?\(\)\|\[\]\s]+)\//),v=d&&!/[\*\?\(\)\|\[\]]/.test(d[1])?E.resolve(P,d[1]):P,$=await A(v,F,P);try{let x=r.replace(/^\.\//,"");x=x.replace(/\.\*\/(\\.|[^\/])/g,".*$1"),!x.startsWith("^")&&!x.startsWith(".*")&&(x=`.*${x}`);let _=new RegExp(x.endsWith("$")?x:`${x}$`,"i");e=$.filter(Z=>{let b=Z.relativePath.replace(/\\/g,"/");return _.test(b)})}catch{e=[]}}else e=R.map(d=>({fullPath:E.resolve(P,d),relativePath:d}))}}else{let r=[],l=!1,z=!1;for(let k of g){let m=k.replace(/[\/\\]+$/,""),R=E.resolve(P,m);try{let d=await K.stat(R);if(d.isDirectory()){z=!0;let v=await A(R,F,P);r.push(...v)}else if(d.isFile())l=!0,r.push({fullPath:R,relativePath:E.relative(P,R)});else return`ERROR: Path is neither a file nor a directory: ${k}`}catch{return`ERROR: Path not found: ${k}`}}e=r,l&&!z?u="file":u="dir"}}else e=await A(P,F);let et=e.map(async i=>{try{let g=await K.readFile(i.fullPath,"utf-8");if(g.includes("\0"))return[];let c=g.split(/\r?\n/),W=[];for(let l=0;l<c.length;l++)(O?c[l].toLowerCase().includes(t.toLowerCase())||nt(c[l],t):y?w&&w.test(c[l]):G&&G.test(c[l])||w&&w.test(c[l]))&&W.push({line:l+1,content:c[l].trim()});return W.length===0?null:{path:i.relativePath.replace(/\\/g,"/"),matches:W}}catch{return[]}}),st=await Promise.all(et),S=[],D=0;for(let i of st){if(!i||!i.matches)continue;if(D>=M)break;let g=M-D,c=i.matches.slice(0,g);S.push({path:i.path,matches:c}),D+=c.length}typeof global.gc=="function"&&global.gc();let I=null;if(S.length===0){let i=u==="file"?` in '${n}'`:u==="dir"||u==="glob"?` in '${n}'`:". Try to specify files",g=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"";return`${g}${g?" ":""}Found 0 matches of '${t}'${i}${I?` ${I}`:""}`}let B=I?` ${I}`:"",T=`${S.length} file${S.length===1?"":"s"}`,U=`${D} match${D===1?"":"es"}`,N;u==="file"?N=`Found ${U} of '${t}' in '${n}'${B}:`:u==="dir"||u==="glob"?N=`Found ${U} of '${t}' in '${n}' across ${T}${B}:`:N=`Found ${U} of '${t}' across ${T}${B}:`;let X=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"",C=`${X}${X?" ":""}${N}
|
|
2
|
-
|
|
3
|
-
`,H="";try{let i=await Q();i?.systemSettings?.alwaysAskFiles&&(H=i.systemSettings.alwaysAskFiles)}catch{}for(let i of S)if(C+=`${i.path}:
|
|
4
|
-
`,J(i.path,H)){let c=i.matches.map(W=>`Line ${W.line}`).join(", ");C+=` ${c}. Line snapshot not available due to file restriction policy. ReadFile if needed
|
|
5
|
-
|
|
6
|
-
`}else{for(let c of i.matches)C+=` Line ${c.line}: ${c.content}
|
|
7
|
-
`;C+=`
|
|
8
|
-
`}return C.trimEnd()}catch(e){return`ERROR: ${e.message}`}};export{gt as search_keyword};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{g as h,h as m,i as R}from"./chunk-AMFNIFF3.js";import{a as F}from"./chunk-6EYQQ7GQ.js";import{a as $}from"./chunk-Y5JU726N.js";import{b as g}from"./chunk-2XQIWDKW.js";import"./chunk-HTOLY3HR.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.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
|
-
`).replace(/\r/g,`
|
|
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
|
-
${a.map(r=>` \u2022 ${r.error}`).join(`
|
|
5
|
-
`)}`;await F.recordFileChange(i,s),c.writeFileSync(i,u,"utf8");let{systemSettings:C}=await g(),d=R(s,u,l,12,C?.compressToolResults);return a.length>0?`File [${t}] updated with some blocks failed. [${f.length}/${o.length}] blocks applied.
|
|
6
|
-
|
|
7
|
-
Failures:
|
|
8
|
-
${a.map(r=>` \u2022 ${r.error}`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
|
|
11
|
-
${d}`:`File [${t}] updated. [${l.length}/${o.length}] blocks applied.
|
|
12
|
-
|
|
13
|
-
${d}`}catch(e){let s=e instanceof Error?e.message:String(e);return`ERROR: Failed to update file [${t}]: ${s}`}};export{j as update_file};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-2YDU2B2F.js";import"./chunk-2XQIWDKW.js";import"./chunk-HTOLY3HR.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{n as addToUsage,c as calculateTokenCost,t as checkImageQuota,q as checkQuota,p as checkQuotaDetailed,e as forceFlushUsage,w as getAllUsageData,o as getCustomPeriodUsage,j as getDailyUsage,r as getImageQuotaBuckets,s as getImageQuotaLimit,u as getImageQuotaStats,k as getMonthlyUsage,h as getTimedUsage,l as incrementUsage,i as initUsage,d as invalidateCachedBaseUrl,g as purgeTimedUsage,v as recordImageGeneration,f as recordTimedUsage,m as runtimeSession,b as sendUsageFinalize,a as sendUsageHeartbeat};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{a as C}from"./chunk-6EYQQ7GQ.js";import{a as j}from"./chunk-Y5JU726N.js";import{b as w}from"./chunk-2XQIWDKW.js";import"./chunk-HTOLY3HR.js";import"./chunk-P5HBJA23.js";import{c as F}from"./chunk-26BQ45XP.js";import e from"fs";import f from"path";var T=async(k,b={})=>{let{path:i,content:p}=j(k);if(!i)return'ERROR: Missing "path" argument for WriteFile.';if(p===void 0)return'ERROR: Missing "content" argument for WriteFile.';p=p.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
2
|
-
`).replace(/\r/g,`
|
|
3
|
-
`);let n=f.resolve(process.cwd(),i),y=f.dirname(n);try{await C.recordFileChange(n);let{systemSettings:r}=await w(),m=r?.overwriteProtection!==!1,a="";if(e.existsSync(n))try{let o=e.readFileSync(n,"utf8").split(/\r?\n/);if(!m)a="";else if(o.length<=50)a=`Old File contents:
|
|
4
|
-
${o.map((c,l)=>`${l+1} | ${c}`).join(`
|
|
5
|
-
`)}
|
|
6
|
-
|
|
7
|
-
`;else{let c=f.parse(n),l=f.join(F,"OverwriteBackups");e.existsSync(l)||e.mkdirSync(l,{recursive:!0});let O=`${c.name}-old-${Date.now()}${c.ext}.bak`,v=f.join(l,O);e.copyFileSync(n,v),a=`Old File contents:
|
|
8
|
-
- Renamed old file as ${v} and written requested content in ${i}. For reversal use Run
|
|
9
|
-
|
|
10
|
-
`}}catch{a=`[Note: Could not read existing file for reversal reference]
|
|
11
|
-
|
|
12
|
-
`}e.existsSync(y)||e.mkdirSync(y,{recursive:!0});let $=(t=>t.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
13
|
-
`).replace(/\r/g,`
|
|
14
|
-
`))(p),d=$.endsWith(`
|
|
15
|
-
`)?$:$+`
|
|
16
|
-
`,E=d.split(/\r?\n/).length,x=Buffer.byteLength(d,"utf8");e.writeFileSync(n,d,"utf8");let u=e.readFileSync(n,"utf8"),S=Buffer.byteLength(u,"utf8"),s=u.split(/\r?\n/),g=s.length;if(S===0&&x>0)return u=null,`ERROR: CRITICAL FAILURE: Verification failed. File [${i}] is empty on disk!`;let h="";if(g<=690)h=s.join(`
|
|
17
|
-
`);else{let t=s.slice(0,300).join(`
|
|
18
|
-
`),o=s.slice(-300).join(`
|
|
19
|
-
`);h=`${t}
|
|
20
|
-
|
|
21
|
-
... [${g-100} lines truncated] ...
|
|
22
|
-
|
|
23
|
-
${o}`}u=null;let R=`File [${i}] saved.
|
|
24
|
-
- Stats: [${g} lines, ${(S/1024).toFixed(1)} KB]
|
|
25
|
-
${a}- Content Preview:
|
|
26
|
-
|
|
27
|
-
${h}`;if(r?.compressToolResults&&g>6e3){let t=d.split(/\r?\n/),o=t.slice(0,25).join(`
|
|
28
|
-
`)===s.slice(0,25).join(`
|
|
29
|
-
`),c=t.slice(-25).join(`
|
|
30
|
-
`)===s.slice(-25).join(`
|
|
31
|
-
`);o&&c&&(R=`[[SAME]]
|
|
32
|
-
${R}`)}return R}catch(r){let m=r instanceof Error?r.message:String(r);return`ERROR: Failed to write file [${i}]: ${m}`}};export{T as write_file};
|