@easbot/local-model-sdk 0.2.49 → 0.3.2
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/dist/index.cjs +26 -29
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.mjs +26 -29
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
'use strict';var sr=require('os'),si=require('path'),z=require('fs'),jn=require('fs/promises'),Ya=require('zod'),url=require('url'),events=require('events'),gn=require('stream'),string_decoder=require('string_decoder'),utils=require('@easbot/utils'),ai$1=require('ai');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var sr__namespace=/*#__PURE__*/_interopNamespace(sr);var si__namespace=/*#__PURE__*/_interopNamespace(si);var z__namespace=/*#__PURE__*/_interopNamespace(z);var jn__default=/*#__PURE__*/_interopDefault(jn);var Ya__default=/*#__PURE__*/_interopDefault(Ya);var gn__default=/*#__PURE__*/_interopDefault(gn);var Jn=Object.defineProperty;var ir=i=>{throw TypeError(i)};var Yn=(i,e,t)=>e in i?Jn(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var c=(i,e,t)=>Yn(i,typeof e!="symbol"?e+"":e,t),xs=(i,e,t)=>e.has(i)||ir("Cannot "+t);var n=(i,e,t)=>(xs(i,e,"read from private field"),t?t.call(i):e.get(i)),b=(i,e,t)=>e.has(i)?ir("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),g=(i,e,t,s)=>(xs(i,e,"write to private field"),e.set(i,t),t),y=(i,e,t)=>(xs(i,e,"access private method"),t);var Vi=(i,e,t,s)=>({set _(r){g(i,e,r);},get _(){return n(i,e,s)}});var me=(f=>(f.MODEL_NOT_FOUND="MODEL_NOT_FOUND",f.MODEL_LOAD_ERROR="MODEL_LOAD_ERROR",f.MODEL_NOT_INITIALIZED="MODEL_NOT_INITIALIZED",f.GENERATION_ERROR="GENERATION_ERROR",f.EMBEDDING_ERROR="EMBEDDING_ERROR",f.INVALID_INPUT="INVALID_INPUT",f.UNSUPPORTED_FEATURE="UNSUPPORTED_FEATURE",f.CACHE_ERROR="CACHE_ERROR",f.PROCESSING_ERROR="PROCESSING_ERROR",f.ABORTED="ABORTED",f.OUT_OF_MEMORY="OUT_OF_MEMORY",f.UNKNOWN_ERROR="UNKNOWN_ERROR",f))(me||{});function Hi(i,e,t){let s;return e?s="error":i?s="stop":s="other",{unified:s,raw:t}}var xe={"qwen3-0.6b":{modelId:"qwen3-0.6b",huggingFaceId:"onnx-community/Qwen3-0.6B-ONNX",contextLength:32768,device:"cpu",dtype:"q4f16",defaultSettings:{temperature:0,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"qwen3.5-0.8b":{modelId:"qwen3.5-0.8b",huggingFaceId:"onnx-community/Qwen3.5-0.8B-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"gemma-3-1b-it":{modelId:"gemma-3-1b-it",huggingFaceId:"onnx-community/gemma-3-1b-it-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}}},bt={"bge-small-zh-v1.5":{modelId:"bge-small-zh-v1.5",huggingFaceId:"Xenova/bge-small-zh-v1.5",dimensions:512,maxEmbeddingsPerCall:32},"bge-base-zh-v1.5":{modelId:"bge-base-zh-v1.5",huggingFaceId:"Xenova/bge-base-zh-v1.5",dimensions:768,maxEmbeddingsPerCall:32,dtype:"q4"},"bge-large-zh-v1.5":{modelId:"bge-large-zh-v1.5",huggingFaceId:"Xenova/bge-large-zh-v1.5",dimensions:1024,maxEmbeddingsPerCall:32,dtype:"q4"},"all-MiniLM-L6-v2":{modelId:"all-MiniLM-L6-v2",huggingFaceId:"sentence-transformers/all-MiniLM-L6-v2",dimensions:384,maxEmbeddingsPerCall:32,dtype:"q4"}};var T=class i extends Error{constructor(t,s,r){super(t);c(this,"code",s);c(this,"cause",r);this.name="LocalModelError",Error.captureStackTrace&&Error.captureStackTrace(this,i);}},re=class{static modelLoadError(e){return new T(`\u6A21\u578B\u52A0\u8F7D\u5931\u8D25: ${e.message}`,"MODEL_LOAD_ERROR",e)}static generationError(e){return new T(`\u751F\u6210\u5931\u8D25: ${e.message}`,"GENERATION_ERROR",e)}static embeddingError(e){return new T(`\u5D4C\u5165\u5931\u8D25: ${e.message}`,"EMBEDDING_ERROR",e)}static validationError(e){return new T(e,"INVALID_INPUT")}static abortError(){return new T("\u64CD\u4F5C\u5DF2\u4E2D\u6B62","ABORTED")}static unsupportedFeature(e){return new T(`\u4E0D\u652F\u6301\u7684\u529F\u80FD: ${e}`,"UNSUPPORTED_FEATURE")}};var Zn=si__namespace.join(sr__namespace.homedir(),".cache","easbot","models"),Bt=class{constructor(e){c(this,"cacheDir");this.cacheDir=e.cacheDir||Zn;}getCachePath(e){return si__namespace.join(this.cacheDir,e)}isCached(e){try{let t=this.getCachePath(e);return z__namespace.existsSync(t)&&z__namespace.statSync(t).isDirectory()}catch{return false}}async clear(e){try{if(e){let t=this.getCachePath(e);z__namespace.existsSync(t)&&await this.removeDirectory(t);}else z__namespace.existsSync(this.cacheDir)&&await this.removeDirectory(this.cacheDir);}catch(t){throw new T(`\u6E05\u7406\u7F13\u5B58\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getCacheSize(e){try{let t=e?this.getCachePath(e):this.cacheDir;return z__namespace.existsSync(t)?await this.getDirectorySize(t):0}catch(t){throw new T(`\u83B7\u53D6\u7F13\u5B58\u5927\u5C0F\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getDirectorySize(e){let t=0,s=z__namespace.readdirSync(e);for(let r of s){let o=si__namespace.join(e,r),a=z__namespace.statSync(o);a.isDirectory()?t+=await this.getDirectorySize(o):t+=a.size;}return t}async removeDirectory(e){if(!z__namespace.existsSync(e))return;let t=z__namespace.readdirSync(e);for(let s of t){let r=si__namespace.join(e,s);z__namespace.statSync(r).isDirectory()?await this.removeDirectory(r):z__namespace.unlinkSync(r);}z__namespace.rmdirSync(e);}ensureCacheDir(){try{z__namespace.existsSync(this.cacheDir)||z__namespace.mkdirSync(this.cacheDir,{recursive:!0});}catch(e){throw new T(`\u521B\u5EFA\u7F13\u5B58\u76EE\u5F55\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`,"CACHE_ERROR",e instanceof Error?e:void 0)}}};var Yr=(i,e,t)=>{let s=i instanceof RegExp?rr(i,t):i,r=e instanceof RegExp?rr(e,t):e,o=s!==null&&r!=null&&Xn(s,r,t);return o&&{start:o[0],end:o[1],pre:t.slice(0,o[0]),body:t.slice(o[0]+s.length,o[1]),post:t.slice(o[1]+r.length)}},rr=(i,e)=>{let t=e.match(i);return t?t[0]:null},Xn=(i,e,t)=>{let s,r,o,a,h,l=t.indexOf(i),d=t.indexOf(e,l+1),p=l;if(l>=0&&d>0){if(i===e)return [l,d];for(s=[],o=t.length;p>=0&&!h;){if(p===l)s.push(p),l=t.indexOf(i,p+1);else if(s.length===1){let u=s.pop();u!==void 0&&(h=[u,d]);}else r=s.pop(),r!==void 0&&r<o&&(o=r,a=d),d=t.indexOf(e,p+1);p=l<d&&l>=0?l:d;}s.length&&a!==void 0&&(h=[o,a]);}return h},Zr="\0SLASH"+Math.random()+"\0",Xr="\0OPEN"+Math.random()+"\0",Hs="\0CLOSE"+Math.random()+"\0",Qr="\0COMMA"+Math.random()+"\0",en="\0PERIOD"+Math.random()+"\0",Qn=new RegExp(Zr,"g"),eo=new RegExp(Xr,"g"),to=new RegExp(Hs,"g"),io=new RegExp(Qr,"g"),so=new RegExp(en,"g"),ro=/\\\\/g,no=/\\{/g,oo=/\\}/g,ao=/\\,/g,lo=/\\./g,ho=1e5;function ks(i){return isNaN(i)?i.charCodeAt(0):parseInt(i,10)}function co(i){return i.replace(ro,Zr).replace(no,Xr).replace(oo,Hs).replace(ao,Qr).replace(lo,en)}function uo(i){return i.replace(Qn,"\\").replace(eo,"{").replace(to,"}").replace(io,",").replace(so,".")}function tn(i){if(!i)return [""];let e=[],t=Yr("{","}",i);if(!t)return i.split(",");let{pre:s,body:r,post:o}=t,a=s.split(",");a[a.length-1]+="{"+r+"}";let h=tn(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),e.push.apply(e,a),e}function po(i,e={}){if(!i)return [];let{max:t=ho}=e;return i.slice(0,2)==="{}"&&(i="\\{\\}"+i.slice(2)),ci(co(i),t,true).map(uo)}function fo(i){return "{"+i+"}"}function go(i){return /^-?0\d/.test(i)}function mo(i,e){return i<=e}function yo(i,e){return i>=e}function ci(i,e,t){let s=[],r=Yr("{","}",i);if(!r)return [i];let o=r.pre,a=r.post.length?ci(r.post,e,false):[""];if(/\$$/.test(r.pre))for(let h=0;h<a.length&&h<e;h++){let l=o+"{"+r.body+"}"+a[h];s.push(l);}else {let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),d=h||l,p=r.body.indexOf(",")>=0;if(!d&&!p)return r.post.match(/,(?!,).*\}/)?(i=r.pre+"{"+r.body+Hs+r.post,ci(i,e,true)):[i];let u;if(d)u=r.body.split(/\.\./);else if(u=tn(r.body),u.length===1&&u[0]!==void 0&&(u=ci(u[0],e,false).map(fo),u.length===1))return a.map(m=>r.pre+u[0]+m);let f;if(d&&u[0]!==void 0&&u[1]!==void 0){let m=ks(u[0]),w=ks(u[1]),S=Math.max(u[0].length,u[1].length),x=u.length===3&&u[2]!==void 0?Math.abs(ks(u[2])):1,v=mo;w<m&&(x*=-1,v=yo);let M=u.some(go);f=[];for(let C=m;v(C,w);C+=x){let P;if(l)P=String.fromCharCode(C),P==="\\"&&(P="");else if(P=String(C),M){let D=S-P.length;if(D>0){let Te=new Array(D+1).join("0");C<0?P="-"+Te+P.slice(1):P=Te+P;}}f.push(P);}}else {f=[];for(let m=0;m<u.length;m++)f.push.apply(f,ci(u[m],e,false));}for(let m=0;m<f.length;m++)for(let w=0;w<a.length&&s.length<e;w++){let S=o+f[m]+a[w];(!t||d||S)&&s.push(S);}}return s}var cs=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")},wo={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",true],"[:alpha:]":["\\p{L}\\p{Nl}",true],"[:ascii:]":["\\x00-\\x7f",false],"[:blank:]":["\\p{Zs}\\t",true],"[:cntrl:]":["\\p{Cc}",true],"[:digit:]":["\\p{Nd}",true],"[:graph:]":["\\p{Z}\\p{C}",true,true],"[:lower:]":["\\p{Ll}",true],"[:print:]":["\\p{C}",true],"[:punct:]":["\\p{P}",true],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",true],"[:upper:]":["\\p{Lu}",true],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",true],"[:xdigit:]":["A-Fa-f0-9",false]},ri=i=>i.replace(/[[\]\\-]/g,"\\$&"),bo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),nr=i=>i.join(""),So=(i,e)=>{let t=e;if(i.charAt(t)!=="[")throw new Error("not in a brace expression");let s=[],r=[],o=t+1,a=false,h=false,l=false,d=false,p=t,u="";e:for(;o<i.length;){let w=i.charAt(o);if((w==="!"||w==="^")&&o===t+1){d=true,o++;continue}if(w==="]"&&a&&!l){p=o+1;break}if(a=true,w==="\\"&&!l){l=true,o++;continue}if(w==="["&&!l){for(let[S,[x,v,M]]of Object.entries(wo))if(i.startsWith(S,o)){if(u)return ["$.",false,i.length-t,true];o+=S.length,M?r.push(x):s.push(x),h=h||v;continue e}}if(l=false,u){w>u?s.push(ri(u)+"-"+ri(w)):w===u&&s.push(ri(w)),u="",o++;continue}if(i.startsWith("-]",o+1)){s.push(ri(w+"-")),o+=2;continue}if(i.startsWith("-",o+1)){u=w,o+=2;continue}s.push(ri(w)),o++;}if(p<o)return ["",false,0,false];if(!s.length&&!r.length)return ["$.",false,i.length-t,true];if(r.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!d){let w=s[0].length===2?s[0].slice(-1):s[0];return [bo(w),false,p-t,false]}let f="["+(d?"^":"")+nr(s)+"]",m="["+(d?"":"^")+nr(r)+"]";return [s.length&&r.length?"("+f+"|"+m+")":s.length?f:m,h,p-t,true]},Wt=(i,{windowsPathsNoEscape:e=false,magicalBraces:t=true}={})=>t?e?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?i.replace(/\[([^\/\\{}])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),vo=new Set(["!","?","+","*","@"]),or=i=>vo.has(i),Eo="(?!(?:^|/)\\.\\.?(?:$|/))",Ki="(?!\\.)",To=new Set(["[","."]),xo=new Set(["..","."]),ko=new Set("().*{}+?[]^$\\!"),Mo=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ks="[^/]",ar=Ks+"*?",lr=Ks+"+?",q,X,Ye,I,j,ct,Tt,dt,Ge,xt,yi,At,rn,yt,te,is,As,nn,sn=(te=class{constructor(e,t,s={}){b(this,At);c(this,"type");b(this,q);b(this,X);b(this,Ye,false);b(this,I,[]);b(this,j);b(this,ct);b(this,Tt);b(this,dt,false);b(this,Ge);b(this,xt);b(this,yi,false);this.type=e,e&&g(this,X,true),g(this,j,t),g(this,q,n(this,j)?n(n(this,j),q):this),g(this,Ge,n(this,q)===this?s:n(n(this,q),Ge)),g(this,Tt,n(this,q)===this?[]:n(n(this,q),Tt)),e==="!"&&!n(n(this,q),dt)&&n(this,Tt).push(this),g(this,ct,n(this,j)?n(n(this,j),I).length:0);}get hasMagic(){if(n(this,X)!==void 0)return n(this,X);for(let e of n(this,I))if(typeof e!="string"&&(e.type||e.hasMagic))return g(this,X,true);return n(this,X)}toString(){return n(this,xt)!==void 0?n(this,xt):this.type?g(this,xt,this.type+"("+n(this,I).map(e=>String(e)).join("|")+")"):g(this,xt,n(this,I).map(e=>String(e)).join(""))}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof te&&n(t,j)===this))throw new Error("invalid part: "+t);n(this,I).push(t);}}toJSON(){let e=this.type===null?n(this,I).slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...n(this,I).map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===n(this,q)||n(n(this,q),dt)&&n(this,j)?.type==="!")&&e.push({}),e}isStart(){if(n(this,q)===this)return true;if(!n(this,j)?.isStart())return false;if(n(this,ct)===0)return true;let e=n(this,j);for(let t=0;t<n(this,ct);t++){let s=n(e,I)[t];if(!(s instanceof te&&s.type==="!"))return false}return true}isEnd(){if(n(this,q)===this||n(this,j)?.type==="!")return true;if(!n(this,j)?.isEnd())return false;if(!this.type)return n(this,j)?.isEnd();let e=n(this,j)?n(n(this,j),I).length:0;return n(this,ct)===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this));}clone(e){let t=new te(this.type,e);for(let s of n(this,I))t.copyIn(s);return t}static fromGlob(e,t={}){var r;let s=new te(null,void 0,t);return y(r=te,yt,is).call(r,e,s,0,t),s}toMMPattern(){if(this!==n(this,q))return n(this,q).toMMPattern();let e=this.toString(),[t,s,r,o]=this.toRegExpSource();if(!(r||n(this,X)||n(this,Ge).nocase&&!n(this,Ge).nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return s;let a=(n(this,Ge).nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return n(this,Ge)}toRegExpSource(e){let t=e??!!n(this,Ge).dot;if(n(this,q)===this&&y(this,At,rn).call(this),!this.type){let l=this.isStart()&&this.isEnd()&&!n(this,I).some(f=>typeof f!="string"),d=n(this,I).map(f=>{var v;let[m,w,S,x]=typeof f=="string"?y(v=te,yt,nn).call(v,f,n(this,X),l):f.toRegExpSource(e);return g(this,X,n(this,X)||S),g(this,Ye,n(this,Ye)||x),m}).join(""),p="";if(this.isStart()&&typeof n(this,I)[0]=="string"&&!(n(this,I).length===1&&xo.has(n(this,I)[0]))){let f=To,m=t&&f.has(d.charAt(0))||d.startsWith("\\.")&&f.has(d.charAt(2))||d.startsWith("\\.\\.")&&f.has(d.charAt(4)),w=!t&&!e&&f.has(d.charAt(0));p=m?Eo:w?Ki:"";}let u="";return this.isEnd()&&n(n(this,q),dt)&&n(this,j)?.type==="!"&&(u="(?:$|\\/)"),[p+d+u,Wt(d),g(this,X,!!n(this,X)),n(this,Ye)]}let s=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",o=y(this,At,As).call(this,t);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return g(this,I,[l]),this.type=null,g(this,X,void 0),[l,Wt(this.toString()),false,false]}let a=!s||e||t||!Ki?"":y(this,At,As).call(this,true);a===o&&(a=""),a&&(o=`(?:${o})(?:${a})*?`);let h="";if(this.type==="!"&&n(this,yi))h=(this.isStart()&&!t?Ki:"")+lr;else {let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Ki:"")+ar+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;h=r+o+l;}return [h,Wt(o),g(this,X,!!n(this,X)),n(this,Ye)]}},q=new WeakMap,X=new WeakMap,Ye=new WeakMap,I=new WeakMap,j=new WeakMap,ct=new WeakMap,Tt=new WeakMap,dt=new WeakMap,Ge=new WeakMap,xt=new WeakMap,yi=new WeakMap,At=new WeakSet,rn=function(){if(this!==n(this,q))throw new Error("should only call on root");if(n(this,dt))return this;this.toString(),g(this,dt,true);let e;for(;e=n(this,Tt).pop();){if(e.type!=="!")continue;let t=e,s=n(t,j);for(;s;){for(let r=n(t,ct)+1;!s.type&&r<n(s,I).length;r++)for(let o of n(e,I)){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n(s,I)[r]);}t=s,s=n(t,j);}}return this},yt=new WeakSet,is=function(e,t,s,r){var m,w;let o=false,a=false,h=-1,l=false;if(t.type===null){let S=s,x="";for(;S<e.length;){let v=e.charAt(S++);if(o||v==="\\"){o=!o,x+=v;continue}if(a){S===h+1?(v==="^"||v==="!")&&(l=true):v==="]"&&!(S===h+2&&l)&&(a=false),x+=v;continue}else if(v==="["){a=true,h=S,l=false,x+=v;continue}if(!r.noext&&or(v)&&e.charAt(S)==="("){t.push(x),x="";let M=new te(v,t);S=y(m=te,yt,is).call(m,e,M,S,r),t.push(M);continue}x+=v;}return t.push(x),S}let d=s+1,p=new te(null,t),u=[],f="";for(;d<e.length;){let S=e.charAt(d++);if(o||S==="\\"){o=!o,f+=S;continue}if(a){d===h+1?(S==="^"||S==="!")&&(l=true):S==="]"&&!(d===h+2&&l)&&(a=false),f+=S;continue}else if(S==="["){a=true,h=d,l=false,f+=S;continue}if(or(S)&&e.charAt(d)==="("){p.push(f),f="";let x=new te(S,p);p.push(x),d=y(w=te,yt,is).call(w,e,x,d,r);continue}if(S==="|"){p.push(f),f="",u.push(p),p=new te(null,t);continue}if(S===")")return f===""&&n(t,I).length===0&&g(t,yi,true),p.push(f),f="",t.push(...u,p),d;f+=S;}return t.type=null,g(t,X,void 0),g(t,I,[e.substring(s-1)]),d},As=function(e){return n(this,I).map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[s,r,o,a]=t.toRegExpSource(e);return g(this,Ye,n(this,Ye)||a),s}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")},nn=function(e,t,s=false){let r=false,o="",a=false,h=false;for(let l=0;l<e.length;l++){let d=e.charAt(l);if(r){r=false,o+=(ko.has(d)?"\\":"")+d;continue}if(d==="*"){if(h)continue;h=true,o+=s&&/^[*]+$/.test(e)?lr:ar,t=true;continue}else h=false;if(d==="\\"){l===e.length-1?o+="\\\\":r=true;continue}if(d==="["){let[p,u,f,m]=So(e,l);if(f){o+=p,a=a||u,l+=f-1,t=t||m;continue}}if(d==="?"){o+=Ks,t=true;continue}o+=Mo(d);}return [o,Wt(e),!!t,a]},b(te,yt),te),on=(i,{windowsPathsNoEscape:e=false,magicalBraces:t=false}={})=>t?e?i.replace(/[?*()[\]{}]/g,"[$&]"):i.replace(/[?*()[\]\\{}]/g,"\\$&"):e?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&"),ce=(i,e,t={})=>(cs(e),!t.nocomment&&e.charAt(0)==="#"?false:new wt(e,t).match(i)),Ro=/^\*+([^+@!?\*\[\(]*)$/,Lo=i=>e=>!e.startsWith(".")&&e.endsWith(i),Co=i=>e=>e.endsWith(i),Oo=i=>(i=i.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(i)),Po=i=>(i=i.toLowerCase(),e=>e.toLowerCase().endsWith(i)),Do=/^\*+\.\*+$/,Ao=i=>!i.startsWith(".")&&i.includes("."),Io=i=>i!=="."&&i!==".."&&i.includes("."),No=/^\.\*+$/,_o=i=>i!=="."&&i!==".."&&i.startsWith("."),Fo=/^\*+$/,Uo=i=>i.length!==0&&!i.startsWith("."),$o=i=>i.length!==0&&i!=="."&&i!=="..",Bo=/^\?+([^+@!?\*\[\(]*)?$/,zo=([i,e=""])=>{let t=an([i]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},jo=([i,e=""])=>{let t=ln([i]);return e?(e=e.toLowerCase(),s=>t(s)&&s.toLowerCase().endsWith(e)):t},Wo=([i,e=""])=>{let t=ln([i]);return e?s=>t(s)&&s.endsWith(e):t},Go=([i,e=""])=>{let t=an([i]);return e?s=>t(s)&&s.endsWith(e):t},an=([i])=>{let e=i.length;return t=>t.length===e&&!t.startsWith(".")},ln=([i])=>{let e=i.length;return t=>t.length===e&&t!=="."&&t!==".."},hn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",hr={win32:{sep:"\\"},posix:{sep:"/"}},qo=hn==="win32"?hr.win32.sep:hr.posix.sep;ce.sep=qo;var he=Symbol("globstar **");ce.GLOBSTAR=he;var Vo="[^/]",Ho=Vo+"*?",Ko="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Jo="(?:(?!(?:\\/|^)\\.).)*?",Yo=(i,e={})=>t=>ce(t,i,e);ce.filter=Yo;var ke=(i,e={})=>Object.assign({},i,e),Zo=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return ce;let e=ce;return Object.assign((t,s,r={})=>e(t,s,ke(i,r)),{Minimatch:class extends e.Minimatch{constructor(t,s={}){super(t,ke(i,s));}static defaults(t){return e.defaults(ke(i,t)).Minimatch}},AST:class extends e.AST{constructor(t,s,r={}){super(t,s,ke(i,r));}static fromGlob(t,s={}){return e.AST.fromGlob(t,ke(i,s))}},unescape:(t,s={})=>e.unescape(t,ke(i,s)),escape:(t,s={})=>e.escape(t,ke(i,s)),filter:(t,s={})=>e.filter(t,ke(i,s)),defaults:t=>e.defaults(ke(i,t)),makeRe:(t,s={})=>e.makeRe(t,ke(i,s)),braceExpand:(t,s={})=>e.braceExpand(t,ke(i,s)),match:(t,s,r={})=>e.match(t,s,ke(i,r)),sep:e.sep,GLOBSTAR:he})};ce.defaults=Zo;var cn=(i,e={})=>(cs(i),e.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:po(i,{max:e.braceExpandMax}));ce.braceExpand=cn;var Xo=(i,e={})=>new wt(i,e).makeRe();ce.makeRe=Xo;var Qo=(i,e,t={})=>{let s=new wt(e,t);return i=i.filter(r=>s.match(r)),s.options.nonull&&!i.length&&i.push(e),i};ce.match=Qo;var cr=/[?*]|[+@!]\(.*?\)|\[|\]/,ea=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),wt=class{constructor(i,e={}){c(this,"options");c(this,"set");c(this,"pattern");c(this,"windowsPathsNoEscape");c(this,"nonegate");c(this,"negate");c(this,"comment");c(this,"empty");c(this,"preserveMultipleSlashes");c(this,"partial");c(this,"globSet");c(this,"globParts");c(this,"nocase");c(this,"isWindows");c(this,"platform");c(this,"windowsNoMagicRoot");c(this,"regexp");cs(i),e=e||{},this.options=e,this.pattern=i,this.platform=e.platform||hn,this.isWindows=this.platform==="win32";let t="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[t]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!e.nonegate,this.comment=false,this.empty=false,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make();}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return true;for(let i of this.set)for(let e of i)if(typeof e!="string")return true;return false}debug(...i){}make(){let i=this.pattern,e=this.options;if(!e.nocomment&&i.charAt(0)==="#"){this.comment=true;return}if(!i){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let t=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(t),this.debug(this.pattern,this.globParts);let s=this.globParts.map((r,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=r[0]===""&&r[1]===""&&(r[2]==="?"||!cr.test(r[2]))&&!cr.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(h)return [...r.slice(0,4),...r.slice(4).map(d=>this.parse(d))];if(l)return [r[0],...r.slice(1).map(d=>this.parse(d))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,s),this.set=s.filter(r=>r.indexOf(false)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?");}this.debug(this.pattern,this.set);}preprocess(i){if(this.options.noglobstar)for(let t=0;t<i.length;t++)for(let s=0;s<i[t].length;s++)i[t][s]==="**"&&(i[t][s]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(i=this.firstPhasePreProcess(i),i=this.secondPhasePreProcess(i)):e>=1?i=this.levelOneOptimize(i):i=this.adjascentGlobstarOptimize(i),i}adjascentGlobstarOptimize(i){return i.map(e=>{let t=-1;for(;(t=e.indexOf("**",t+1))!==-1;){let s=t;for(;e[s+1]==="**";)s++;s!==t&&e.splice(t,s-t);}return e})}levelOneOptimize(i){return i.map(e=>(e=e.reduce((t,s)=>{let r=t[t.length-1];return s==="**"&&r==="**"?t:s===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(t.pop(),t):(t.push(s),t)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(i){Array.isArray(i)||(i=this.slashSplit(i));let e=false;do{if(e=false,!this.preserveMultipleSlashes){for(let s=1;s<i.length-1;s++){let r=i[s];s===1&&r===""&&i[0]===""||(r==="."||r==="")&&(e=true,i.splice(s,1),s--);}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=true,i.pop());}let t=0;for(;(t=i.indexOf("..",t+1))!==-1;){let s=i[t-1];s&&s!=="."&&s!==".."&&s!=="**"&&(e=true,i.splice(t-1,2),t-=2);}}while(e);return i.length===0?[""]:i}firstPhasePreProcess(i){let e=false;do{e=false;for(let t of i){let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let o=s;for(;t[o+1]==="**";)o++;o>s&&t.splice(s+1,o-s);let a=t[s+1],h=t[s+2],l=t[s+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;e=true,t.splice(s,1);let d=t.slice(0);d[s]="**",i.push(d),s--;}if(!this.preserveMultipleSlashes){for(let o=1;o<t.length-1;o++){let a=t[o];o===1&&a===""&&t[0]===""||(a==="."||a==="")&&(e=true,t.splice(o,1),o--);}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=true,t.pop());}let r=0;for(;(r=t.indexOf("..",r+1))!==-1;){let o=t[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=true;let a=r===1&&t[r+1]==="**"?["."]:[];t.splice(r-1,2,...a),t.length===0&&t.push(""),r-=2;}}}}while(e);return i}secondPhasePreProcess(i){for(let e=0;e<i.length-1;e++)for(let t=e+1;t<i.length;t++){let s=this.partsMatch(i[e],i[t],!this.preserveMultipleSlashes);if(s){i[e]=[],i[t]=s;break}}return i.filter(e=>e.length)}partsMatch(i,e,t=false){let s=0,r=0,o=[],a="";for(;s<i.length&&r<e.length;)if(i[s]===e[r])o.push(a==="b"?e[r]:i[s]),s++,r++;else if(t&&i[s]==="**"&&e[r]===i[s+1])o.push(i[s]),s++;else if(t&&e[r]==="**"&&i[s]===e[r+1])o.push(e[r]),r++;else if(i[s]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(a==="b")return false;a="a",o.push(i[s]),s++,r++;}else if(e[r]==="*"&&i[s]&&(this.options.dot||!i[s].startsWith("."))&&i[s]!=="**"){if(a==="a")return false;a="b",o.push(e[r]),s++,r++;}else return false;return i.length===e.length&&o}parseNegate(){if(this.nonegate)return;let i=this.pattern,e=false,t=0;for(let s=0;s<i.length&&i.charAt(s)==="!";s++)e=!e,t++;t&&(this.pattern=i.slice(t)),this.negate=e;}matchOne(i,e,t=false){let s=this.options;if(this.isWindows){let w=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),S=!w&&i[0]===""&&i[1]===""&&i[2]==="?"&&/^[a-z]:$/i.test(i[3]),x=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!x&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),M=S?3:w?0:void 0,C=v?3:x?0:void 0;if(typeof M=="number"&&typeof C=="number"){let[P,D]=[i[M],e[C]];P.toLowerCase()===D.toLowerCase()&&(e[C]=P,C>M?e=e.slice(C):M>C&&(i=i.slice(M)));}}let{optimizationLevel:r=1}=this.options;r>=2&&(i=this.levelTwoFileOptimize(i)),this.debug("matchOne",this,{file:i,pattern:e}),this.debug("matchOne",i.length,e.length);for(var o=0,a=0,h=i.length,l=e.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var d=e[a],p=i[o];if(this.debug(e,d,p),d===false)return false;if(d===he){this.debug("GLOBSTAR",[e,d,p]);var u=o,f=a+1;if(f===l){for(this.debug("** at the end");o<h;o++)if(i[o]==="."||i[o]===".."||!s.dot&&i[o].charAt(0)===".")return false;return true}for(;u<h;){var m=i[u];if(this.debug(`
|
|
2
|
-
|
|
3
|
-
>>> no match, partial?`,i,u,e,f),u===h))}let w;if(typeof d=="string"?(w=p===d,this.debug("string match",d,p,w)):(w=d.test(p),this.debug("pattern match",d,p,w)),!w)return false}if(o===h&&a===l)return true;if(o===h)return t;if(a===l)return o===h-1&&i[o]==="";throw new Error("wtf?")}braceExpand(){return cn(this.pattern,this.options)}parse(i){cs(i);let e=this.options;if(i==="**")return he;if(i==="")return "";let t,s=null;(t=i.match(Fo))?s=e.dot?$o:Uo:(t=i.match(Ro))?s=(e.nocase?e.dot?Po:Oo:e.dot?Co:Lo)(t[1]):(t=i.match(Bo))?s=(e.nocase?e.dot?jo:zo:e.dot?Wo:Go)(t):(t=i.match(Do))?s=e.dot?Io:Ao:(t=i.match(No))&&(s=_o);let r=sn.fromGlob(i,this.options).toMMPattern();return s&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:s}),r}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let i=this.set;if(!i.length)return this.regexp=false,this.regexp;let e=this.options,t=e.noglobstar?Ho:e.dot?Ko:Jo,s=new Set(e.nocase?["i"]:[]),r=i.map(h=>{let l=h.map(p=>{if(p instanceof RegExp)for(let u of p.flags.split(""))s.add(u);return typeof p=="string"?ea(p):p===he?he:p._src});l.forEach((p,u)=>{let f=l[u+1],m=l[u-1];p!==he||m===he||(m===void 0?f!==void 0&&f!==he?l[u+1]="(?:\\/|"+t+"\\/)?"+f:l[u]=t:f===void 0?l[u-1]=m+"(?:\\/|\\/"+t+")?":f!==he&&(l[u-1]=m+"(?:\\/|\\/"+t+"\\/)"+f,l[u+1]=he));});let d=l.filter(p=>p!==he);if(this.partial&&d.length>=1){let p=[];for(let u=1;u<=d.length;u++)p.push(d.slice(0,u).join("/"));return "(?:"+p.join("|")+")"}return d.join("/")}).join("|"),[o,a]=i.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+a+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...s].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(i){return this.preserveMultipleSlashes?i.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(i)?["",...i.split(/\/+/)]:i.split(/\/+/)}match(i,e=this.partial){if(this.debug("match",i,this.pattern),this.comment)return false;if(this.empty)return i==="";if(i==="/"&&e)return true;let t=this.options;this.isWindows&&(i=i.split("\\").join("/"));let s=this.slashSplit(i);this.debug(this.pattern,"split",s);let r=this.set;this.debug(this.pattern,"set",r);let o=s[s.length-1];if(!o)for(let a=s.length-2;!o&&a>=0;a--)o=s[a];for(let a=0;a<r.length;a++){let h=r[a],l=s;if(t.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,e))return t.flipNegate?true:!this.negate}return t.flipNegate?false:this.negate}static defaults(i){return ce.defaults(i).Minimatch}};ce.AST=sn;ce.Minimatch=wt;ce.escape=on;ce.unescape=Wt;var ia=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,dn=new Set,Is=typeof process=="object"&&process?process:{},un=(i,e,t,s)=>{typeof Is.emitWarning=="function"?Is.emitWarning(i,e,t,s):console.error(`[${t}] ${e}: ${i}`);},ds=globalThis.AbortController,dr=globalThis.AbortSignal;if(typeof ds>"u"){dr=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(t,s){this._onabort.push(s);}},ds=class{constructor(){c(this,"signal",new dr);e();}abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let s of this.signal._onabort)s(t);this.signal.onabort?.(t);}}};let i=Is.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{i&&(i=false,un("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var sa=i=>!dn.has(i),ot=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),pn=i=>ot(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?ss:null:null,ss=class extends Array{constructor(i){super(i),this.fill(0);}},He,Gt,ra=(He=class{constructor(e,t){c(this,"heap");c(this,"length");if(!n(He,Gt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=pn(e);if(!t)return [];g(He,Gt,true);let s=new He(e,t);return g(He,Gt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Gt=new WeakMap,b(He,Gt,false),He),Mr,Rr,Re,we,Ae,kt,Ie,qt,Vt,Ne,V,_e,W,N,L,oe,be,se,Q,Fe,ee,Ue,$e,Se,ve,Be,ut,ae,Ht,E,Ns,Mt,Ze,wi,Ee,fn,Rt,Kt,bi,at,lt,_s,rs,ns,A,Fs,di,ht,Us,Jt,fs=(Jt=class{constructor(e){b(this,E);b(this,Re);b(this,we);b(this,Ae);b(this,kt);b(this,Ie);b(this,qt);b(this,Vt);b(this,Ne);c(this,"ttl");c(this,"ttlResolution");c(this,"ttlAutopurge");c(this,"updateAgeOnGet");c(this,"updateAgeOnHas");c(this,"allowStale");c(this,"noDisposeOnSet");c(this,"noUpdateTTL");c(this,"maxEntrySize");c(this,"sizeCalculation");c(this,"noDeleteOnFetchRejection");c(this,"noDeleteOnStaleGet");c(this,"allowStaleOnFetchAbort");c(this,"allowStaleOnFetchRejection");c(this,"ignoreFetchAbort");b(this,V);b(this,_e);b(this,W);b(this,N);b(this,L);b(this,oe);b(this,be);b(this,se);b(this,Q);b(this,Fe);b(this,ee);b(this,Ue);b(this,$e);b(this,Se);b(this,ve);b(this,Be);b(this,ut);b(this,ae);b(this,Ht);b(this,Mt,()=>{});b(this,Ze,()=>{});b(this,wi,()=>{});b(this,Ee,()=>false);b(this,Rt,e=>{});b(this,Kt,(e,t,s)=>{});b(this,bi,(e,t,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,Mr,"LRUCache");let{max:t=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:l,dispose:d,onInsert:p,disposeAfter:u,noDisposeOnSet:f,noUpdateTTL:m,maxSize:w=0,maxEntrySize:S=0,sizeCalculation:x,fetchMethod:v,memoMethod:M,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:P,allowStaleOnFetchRejection:D,allowStaleOnFetchAbort:Te,ignoreFetchAbort:O,perf:_}=e;if(_!==void 0&&typeof _?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,Ne,_??ia),t!==0&&!ot(t))throw new TypeError("max option must be a nonnegative integer");let $=t?pn(t):Array;if(!$)throw new Error("invalid max value: "+t);if(g(this,Re,t),g(this,we,w),this.maxEntrySize=S||n(this,we),this.sizeCalculation=x,this.sizeCalculation){if(!n(this,we)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,Vt,M),v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,qt,v),g(this,ut,!!v),g(this,W,new Map),g(this,N,new Array(t).fill(void 0)),g(this,L,new Array(t).fill(void 0)),g(this,oe,new $(t)),g(this,be,new $(t)),g(this,se,0),g(this,Q,0),g(this,Fe,ra.create(t)),g(this,V,0),g(this,_e,0),typeof d=="function"&&g(this,Ae,d),typeof p=="function"&&g(this,kt,p),typeof u=="function"?(g(this,Ie,u),g(this,ee,[])):(g(this,Ie,void 0),g(this,ee,void 0)),g(this,Be,!!n(this,Ae)),g(this,Ht,!!n(this,kt)),g(this,ae,!!n(this,Ie)),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!D,this.allowStaleOnFetchAbort=!!Te,this.ignoreFetchAbort=!!O,this.maxEntrySize!==0){if(n(this,we)!==0&&!ot(n(this,we)))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");y(this,E,fn).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!P,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=ot(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");y(this,E,Ns).call(this);}if(n(this,Re)===0&&this.ttl===0&&n(this,we)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!n(this,Re)&&!n(this,we)){let de="LRU_CACHE_UNBOUNDED";sa(de)&&(dn.add(de),un("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",de,Jt));}}get perf(){return n(this,Ne)}static unsafeExposeInternals(e){return {starts:n(e,$e),ttls:n(e,Se),autopurgeTimers:n(e,ve),sizes:n(e,Ue),keyMap:n(e,W),keyList:n(e,N),valList:n(e,L),next:n(e,oe),prev:n(e,be),get head(){return n(e,se)},get tail(){return n(e,Q)},free:n(e,Fe),isBackgroundFetch:t=>{var s;return y(s=e,E,A).call(s,t)},backgroundFetch:(t,s,r,o)=>{var a;return y(a=e,E,ns).call(a,t,s,r,o)},moveToTail:t=>{var s;return y(s=e,E,di).call(s,t)},indexes:t=>{var s;return y(s=e,E,at).call(s,t)},rindexes:t=>{var s;return y(s=e,E,lt).call(s,t)},isStale:t=>{var s;return n(s=e,Ee).call(s,t)}}}get max(){return n(this,Re)}get maxSize(){return n(this,we)}get calculatedSize(){return n(this,_e)}get size(){return n(this,V)}get fetchMethod(){return n(this,qt)}get memoMethod(){return n(this,Vt)}get dispose(){return n(this,Ae)}get onInsert(){return n(this,kt)}get disposeAfter(){return n(this,Ie)}getRemainingTTL(e){return n(this,W).has(e)?1/0:0}*entries(){for(let e of y(this,E,at).call(this))n(this,L)[e]!==void 0&&n(this,N)[e]!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield [n(this,N)[e],n(this,L)[e]]);}*rentries(){for(let e of y(this,E,lt).call(this))n(this,L)[e]!==void 0&&n(this,N)[e]!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield [n(this,N)[e],n(this,L)[e]]);}*keys(){for(let e of y(this,E,at).call(this)){let t=n(this,N)[e];t!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield t);}}*rkeys(){for(let e of y(this,E,lt).call(this)){let t=n(this,N)[e];t!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield t);}}*values(){for(let e of y(this,E,at).call(this))n(this,L)[e]!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield n(this,L)[e]);}*rvalues(){for(let e of y(this,E,lt).call(this))n(this,L)[e]!==void 0&&!y(this,E,A).call(this,n(this,L)[e])&&(yield n(this,L)[e]);}[(Rr=Symbol.iterator,Mr=Symbol.toStringTag,Rr)](){return this.entries()}find(e,t={}){for(let s of y(this,E,at).call(this)){let r=n(this,L)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,n(this,N)[s],this))return this.get(n(this,N)[s],t)}}forEach(e,t=this){for(let s of y(this,E,at).call(this)){let r=n(this,L)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,n(this,N)[s],this);}}rforEach(e,t=this){for(let s of y(this,E,lt).call(this)){let r=n(this,L)[s],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,n(this,N)[s],this);}}purgeStale(){let e=false;for(let t of y(this,E,lt).call(this,{allowStale:true}))n(this,Ee).call(this,t)&&(y(this,E,ht).call(this,n(this,N)[t],"expire"),e=true);return e}info(e){let t=n(this,W).get(e);if(t===void 0)return;let s=n(this,L)[t],r=y(this,E,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(n(this,Se)&&n(this,$e)){let a=n(this,Se)[t],h=n(this,$e)[t];if(a&&h){let l=a-(n(this,Ne).now()-h);o.ttl=l,o.start=Date.now();}}return n(this,Ue)&&(o.size=n(this,Ue)[t]),o}dump(){let e=[];for(let t of y(this,E,at).call(this,{allowStale:true})){let s=n(this,N)[t],r=n(this,L)[t],o=y(this,E,A).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(n(this,Se)&&n(this,$e)){a.ttl=n(this,Se)[t];let h=n(this,Ne).now()-n(this,$e)[t];a.start=Math.floor(Date.now()-h);}n(this,Ue)&&(a.size=n(this,Ue)[t]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[t,s]of e){if(s.start){let r=Date.now()-s.start;s.start=n(this,Ne).now()-r;}this.set(t,s.value,s);}}set(e,t,s={}){var f,m,w,S;if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:l}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,p=n(this,bi).call(this,e,t,s.size||0,h);if(this.maxEntrySize&&p>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),y(this,E,ht).call(this,e,"set"),this;let u=n(this,V)===0?void 0:n(this,W).get(e);if(u===void 0)u=n(this,V)===0?n(this,Q):n(this,Fe).length!==0?n(this,Fe).pop():n(this,V)===n(this,Re)?y(this,E,rs).call(this,false):n(this,V),n(this,N)[u]=e,n(this,L)[u]=t,n(this,W).set(e,u),n(this,oe)[n(this,Q)]=u,n(this,be)[u]=n(this,Q),g(this,Q,u),Vi(this,V)._++,n(this,Kt).call(this,u,p,l),l&&(l.set="add"),d=false,n(this,Ht)&&((f=n(this,kt))==null||f.call(this,t,e,"add"));else {y(this,E,di).call(this,u);let x=n(this,L)[u];if(t!==x){if(n(this,ut)&&y(this,E,A).call(this,x)){x.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:v}=x;v!==void 0&&!a&&(n(this,Be)&&((m=n(this,Ae))==null||m.call(this,v,e,"set")),n(this,ae)&&n(this,ee)?.push([v,e,"set"]));}else a||(n(this,Be)&&((w=n(this,Ae))==null||w.call(this,x,e,"set")),n(this,ae)&&n(this,ee)?.push([x,e,"set"]));if(n(this,Rt).call(this,u),n(this,Kt).call(this,u,p,l),n(this,L)[u]=t,l){l.set="replace";let v=x&&y(this,E,A).call(this,x)?x.__staleWhileFetching:x;v!==void 0&&(l.oldValue=v);}}else l&&(l.set="update");n(this,Ht)&&this.onInsert?.(t,e,t===x?"update":"replace");}if(r!==0&&!n(this,Se)&&y(this,E,Ns).call(this),n(this,Se)&&(d||n(this,wi).call(this,u,r,o),l&&n(this,Ze).call(this,l,u)),!a&&n(this,ae)&&n(this,ee)){let x=n(this,ee),v;for(;v=x?.shift();)(S=n(this,Ie))==null||S.call(this,...v);}return this}pop(){var e;try{for(;n(this,V);){let t=n(this,L)[n(this,se)];if(y(this,E,rs).call(this,!0),y(this,E,A).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(n(this,ae)&&n(this,ee)){let t=n(this,ee),s;for(;s=t?.shift();)(e=n(this,Ie))==null||e.call(this,...s);}}}has(e,t={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=t,o=n(this,W).get(e);if(o!==void 0){let a=n(this,L)[o];if(y(this,E,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(n(this,Ee).call(this,o))r&&(r.has="stale",n(this,Ze).call(this,r,o));else return s&&n(this,Mt).call(this,o),r&&(r.has="hit",n(this,Ze).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,t={}){let{allowStale:s=this.allowStale}=t,r=n(this,W).get(e);if(r===void 0||!s&&n(this,Ee).call(this,r))return;let o=n(this,L)[r];return y(this,E,A).call(this,o)?o.__staleWhileFetching:o}async fetch(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:l=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:w=this.allowStaleOnFetchAbort,context:S,forceRefresh:x=false,status:v,signal:M}=t;if(!n(this,ut))return v&&(v.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:v});let C={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:l,sizeCalculation:d,noUpdateTTL:p,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:w,ignoreFetchAbort:m,status:v,signal:M},P=n(this,W).get(e);if(P===void 0){v&&(v.fetch="miss");let D=y(this,E,ns).call(this,e,P,C,S);return D.__returned=D}else {let D=n(this,L)[P];if(y(this,E,A).call(this,D)){let $=s&&D.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",$&&(v.returnedStale=true)),$?D.__staleWhileFetching:D.__returned=D}let Te=n(this,Ee).call(this,P);if(!x&&!Te)return v&&(v.fetch="hit"),y(this,E,di).call(this,P),r&&n(this,Mt).call(this,P),v&&n(this,Ze).call(this,v,P),D;let O=y(this,E,ns).call(this,e,P,C,S),_=O.__staleWhileFetching!==void 0&&s;return v&&(v.fetch=Te?"stale":"refresh",_&&Te&&(v.returnedStale=true)),_?O.__staleWhileFetching:O.__returned=O}}async forceFetch(e,t={}){let s=await this.fetch(e,t);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,t={}){let s=n(this,Vt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=t,h=this.get(e,a);if(!o&&h!==void 0)return h;let l=s(e,h,{options:a,context:r});return this.set(e,l,a),l}get(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=t,h=n(this,W).get(e);if(h!==void 0){let l=n(this,L)[h],d=y(this,E,A).call(this,l);return a&&n(this,Ze).call(this,a,h),n(this,Ee).call(this,h)?(a&&(a.get="stale"),d?(a&&s&&l.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?l.__staleWhileFetching:void 0):(o||y(this,E,ht).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?l:void 0)):(a&&(a.get="hit"),d?l.__staleWhileFetching:(y(this,E,di).call(this,h),r&&n(this,Mt).call(this,h),l))}else a&&(a.get="miss");}delete(e){return y(this,E,ht).call(this,e,"delete")}clear(){return y(this,E,Us).call(this,"delete")}},Re=new WeakMap,we=new WeakMap,Ae=new WeakMap,kt=new WeakMap,Ie=new WeakMap,qt=new WeakMap,Vt=new WeakMap,Ne=new WeakMap,V=new WeakMap,_e=new WeakMap,W=new WeakMap,N=new WeakMap,L=new WeakMap,oe=new WeakMap,be=new WeakMap,se=new WeakMap,Q=new WeakMap,Fe=new WeakMap,ee=new WeakMap,Ue=new WeakMap,$e=new WeakMap,Se=new WeakMap,ve=new WeakMap,Be=new WeakMap,ut=new WeakMap,ae=new WeakMap,Ht=new WeakMap,E=new WeakSet,Ns=function(){let e=new ss(n(this,Re)),t=new ss(n(this,Re));g(this,Se,e),g(this,$e,t);let s=this.ttlAutopurge?new Array(n(this,Re)):void 0;g(this,ve,s),g(this,wi,(a,h,l=n(this,Ne).now())=>{if(t[a]=h!==0?l:0,e[a]=h,s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h!==0&&s){let d=setTimeout(()=>{n(this,Ee).call(this,a)&&y(this,E,ht).call(this,n(this,N)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}),g(this,Mt,a=>{t[a]=e[a]!==0?n(this,Ne).now():0;}),g(this,Ze,(a,h)=>{if(e[h]){let l=e[h],d=t[h];if(!l||!d)return;a.ttl=l,a.start=d,a.now=r||o();let p=a.now-d;a.remainingTTL=l-p;}});let r=0,o=()=>{let a=n(this,Ne).now();if(this.ttlResolution>0){r=a;let h=setTimeout(()=>r=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=n(this,W).get(a);if(h===void 0)return 0;let l=e[h],d=t[h];if(!l||!d)return 1/0;let p=(r||o())-d;return l-p},g(this,Ee,a=>{let h=t[a],l=e[a];return !!l&&!!h&&(r||o())-h>l});},Mt=new WeakMap,Ze=new WeakMap,wi=new WeakMap,Ee=new WeakMap,fn=function(){let e=new ss(n(this,Re));g(this,_e,0),g(this,Ue,e),g(this,Rt,t=>{g(this,_e,n(this,_e)-e[t]),e[t]=0;}),g(this,bi,(t,s,r,o)=>{if(y(this,E,A).call(this,s))return 0;if(!ot(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,t),!ot(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),g(this,Kt,(t,s,r)=>{if(e[t]=s,n(this,we)){let o=n(this,we)-e[t];for(;n(this,_e)>o;)y(this,E,rs).call(this,true);}g(this,_e,n(this,_e)+e[t]),r&&(r.entrySize=s,r.totalCalculatedSize=n(this,_e));});},Rt=new WeakMap,Kt=new WeakMap,bi=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(n(this,V))for(let t=n(this,Q);!(!y(this,E,_s).call(this,t)||((e||!n(this,Ee).call(this,t))&&(yield t),t===n(this,se)));)t=n(this,be)[t];},lt=function*({allowStale:e=this.allowStale}={}){if(n(this,V))for(let t=n(this,se);!(!y(this,E,_s).call(this,t)||((e||!n(this,Ee).call(this,t))&&(yield t),t===n(this,Q)));)t=n(this,oe)[t];},_s=function(e){return e!==void 0&&n(this,W).get(n(this,N)[e])===e},rs=function(e){var o;let t=n(this,se),s=n(this,N)[t],r=n(this,L)[t];return n(this,ut)&&y(this,E,A).call(this,r)?r.__abortController.abort(new Error("evicted")):(n(this,Be)||n(this,ae))&&(n(this,Be)&&((o=n(this,Ae))==null||o.call(this,r,s,"evict")),n(this,ae)&&n(this,ee)?.push([r,s,"evict"])),n(this,Rt).call(this,t),n(this,ve)?.[t]&&(clearTimeout(n(this,ve)[t]),n(this,ve)[t]=void 0),e&&(n(this,N)[t]=void 0,n(this,L)[t]=void 0,n(this,Fe).push(t)),n(this,V)===1?(g(this,se,g(this,Q,0)),n(this,Fe).length=0):g(this,se,n(this,oe)[t]),n(this,W).delete(s),Vi(this,V)._--,t},ns=function(e,t,s,r){let o=t===void 0?void 0:n(this,L)[t];if(y(this,E,A).call(this,o))return o;let a=new ds,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let l={signal:a.signal,options:s,context:r},d=(S,x=false)=>{let{aborted:v}=a.signal,M=s.ignoreFetchAbort&&S!==void 0,C=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&S!==void 0);if(s.status&&(v&&!x?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),v&&!M&&!x)return u(a.signal.reason,C);let P=m,D=n(this,L)[t];return (D===m||M&&x&&D===void 0)&&(S===void 0?P.__staleWhileFetching!==void 0?n(this,L)[t]=P.__staleWhileFetching:y(this,E,ht).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,S,l.options))),S},p=S=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=S),u(S,false)),u=(S,x)=>{let{aborted:v}=a.signal,M=v&&s.allowStaleOnFetchAbort,C=M||s.allowStaleOnFetchRejection,P=C||s.noDeleteOnFetchRejection,D=m;if(n(this,L)[t]===m&&(!P||!x&&D.__staleWhileFetching===void 0?y(this,E,ht).call(this,e,"fetch"):M||(n(this,L)[t]=D.__staleWhileFetching)),C)return s.status&&D.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),D.__staleWhileFetching;if(D.__returned===D)throw S},f=(S,x)=>{var M;let v=(M=n(this,qt))==null?void 0:M.call(this,e,o,l);v&&v instanceof Promise&&v.then(C=>S(C===void 0?void 0:C),x),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(S(void 0),s.allowStaleOnFetchAbort&&(S=C=>d(C,true)));});};s.status&&(s.status.fetchDispatched=true);let m=new Promise(f).then(d,p),w=Object.assign(m,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,w,{...l.options,status:void 0}),t=n(this,W).get(e)):n(this,L)[t]=w,w},A=function(e){if(!n(this,ut))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof ds},Fs=function(e,t){n(this,be)[t]=e,n(this,oe)[e]=t;},di=function(e){e!==n(this,Q)&&(e===n(this,se)?g(this,se,n(this,oe)[e]):y(this,E,Fs).call(this,n(this,be)[e],n(this,oe)[e]),y(this,E,Fs).call(this,n(this,Q),e),g(this,Q,e));},ht=function(e,t){var r,o;let s=false;if(n(this,V)!==0){let a=n(this,W).get(e);if(a!==void 0)if(n(this,ve)?.[a]&&(clearTimeout(n(this,ve)?.[a]),n(this,ve)[a]=void 0),s=true,n(this,V)===1)y(this,E,Us).call(this,t);else {n(this,Rt).call(this,a);let h=n(this,L)[a];if(y(this,E,A).call(this,h)?h.__abortController.abort(new Error("deleted")):(n(this,Be)||n(this,ae))&&(n(this,Be)&&((r=n(this,Ae))==null||r.call(this,h,e,t)),n(this,ae)&&n(this,ee)?.push([h,e,t])),n(this,W).delete(e),n(this,N)[a]=void 0,n(this,L)[a]=void 0,a===n(this,Q))g(this,Q,n(this,be)[a]);else if(a===n(this,se))g(this,se,n(this,oe)[a]);else {let l=n(this,be)[a];n(this,oe)[l]=n(this,oe)[a];let d=n(this,oe)[a];n(this,be)[d]=n(this,be)[a];}Vi(this,V)._--,n(this,Fe).push(a);}}if(n(this,ae)&&n(this,ee)?.length){let a=n(this,ee),h;for(;h=a?.shift();)(o=n(this,Ie))==null||o.call(this,...h);}return s},Us=function(e){var t,s;for(let r of y(this,E,lt).call(this,{allowStale:true})){let o=n(this,L)[r];if(y(this,E,A).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=n(this,N)[r];n(this,Be)&&((t=n(this,Ae))==null||t.call(this,o,a,e)),n(this,ae)&&n(this,ee)?.push([o,a,e]);}}if(n(this,W).clear(),n(this,L).fill(void 0),n(this,N).fill(void 0),n(this,Se)&&n(this,$e)){n(this,Se).fill(0),n(this,$e).fill(0);for(let r of n(this,ve)??[])r!==void 0&&clearTimeout(r);n(this,ve)?.fill(void 0);}if(n(this,Ue)&&n(this,Ue).fill(0),g(this,se,0),g(this,Q,0),n(this,Fe).length=0,g(this,_e,0),g(this,V,0),n(this,ae)&&n(this,ee)){let r=n(this,ee),o;for(;o=r?.shift();)(s=n(this,Ie))==null||s.call(this,...o);}},Jt),ur=typeof process=="object"&&process?process:{stdout:null,stderr:null},wa=i=>!!i&&typeof i=="object"&&(i instanceof us||i instanceof gn__default.default||ba(i)||Sa(i)),ba=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.pipe=="function"&&i.pipe!==gn__default.default.Writable.prototype.pipe,Sa=i=>!!i&&typeof i=="object"&&i instanceof events.EventEmitter&&typeof i.write=="function"&&typeof i.end=="function",Ke=Symbol("EOF"),Je=Symbol("maybeEmitEnd"),nt=Symbol("emittedEnd"),Ji=Symbol("emittingEnd"),ni=Symbol("emittedError"),Yi=Symbol("closed"),pr=Symbol("read"),Zi=Symbol("flush"),fr=Symbol("flushChunk"),Pe=Symbol("encoding"),zt=Symbol("decoder"),J=Symbol("flowing"),oi=Symbol("paused"),jt=Symbol("resume"),Y=Symbol("buffer"),ne=Symbol("pipes"),Z=Symbol("bufferLength"),Ms=Symbol("bufferPush"),Xi=Symbol("bufferShift"),ie=Symbol("objectMode"),B=Symbol("destroyed"),Rs=Symbol("error"),Ls=Symbol("emitData"),gr=Symbol("emitEnd"),Cs=Symbol("emitEnd2"),je=Symbol("async"),Os=Symbol("abort"),Qi=Symbol("aborted"),ai=Symbol("signal"),St=Symbol("dataListeners"),ye=Symbol("discarded"),li=i=>Promise.resolve().then(i),va=i=>i(),Ea=i=>i==="end"||i==="finish"||i==="prefinish",Ta=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,xa=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),mn=class{constructor(i,e,t){c(this,"src");c(this,"dest");c(this,"opts");c(this,"ondrain");this.src=i,this.dest=e,this.opts=t,this.ondrain=()=>i[jt](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(i){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},ka=class extends mn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(i,e,t){super(i,e,t),this.proxyErrors=s=>this.dest.emit("error",s),i.on("error",this.proxyErrors);}},Ma=i=>!!i.objectMode,Ra=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",Lr,Cr,Or,Pr,Dr,Ar,Ir,Nr,_r,Fr,Ur,$r,Br,zr,jr,Wr,Gr,qr,Vr,us=class extends events.EventEmitter{constructor(...e){let t=e[0]||{};super();c(this,Vr,false);c(this,qr,false);c(this,Gr,[]);c(this,Wr,[]);c(this,jr);c(this,zr);c(this,Br);c(this,$r);c(this,Ur,false);c(this,Fr,false);c(this,_r,false);c(this,Nr,false);c(this,Ir,null);c(this,Ar,0);c(this,Dr,false);c(this,Pr);c(this,Or,false);c(this,Cr,0);c(this,Lr,false);c(this,"writable",true);c(this,"readable",true);if(t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Ma(t)?(this[ie]=true,this[Pe]=null):Ra(t)?(this[Pe]=t.encoding,this[ie]=false):(this[ie]=false,this[Pe]=null),this[je]=!!t.async,this[zt]=this[Pe]?new string_decoder.StringDecoder(this[Pe]):null,t&&t.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[Y]}),t&&t.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[ne]});let{signal:s}=t;s&&(this[ai]=s,s.aborted?this[Os]():s.addEventListener("abort",()=>this[Os]()));}get bufferLength(){return this[Z]}get encoding(){return this[Pe]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[ie]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[je]}set async(e){this[je]=this[je]||!!e;}[(Vr=J,qr=oi,Gr=ne,Wr=Y,jr=ie,zr=Pe,Br=je,$r=zt,Ur=Ke,Fr=nt,_r=Ji,Nr=Yi,Ir=ni,Ar=Z,Dr=B,Pr=ai,Or=Qi,Cr=St,Lr=ye,Os)](){this[Qi]=true,this.emit("abort",this[ai]?.reason),this.destroy(this[ai]?.reason);}get aborted(){return this[Qi]}set aborted(e){}write(e,t,s){if(this[Qi])return false;if(this[Ke])throw new Error("write after end");if(this[B])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof t=="function"&&(s=t,t="utf8"),t||(t="utf8");let r=this[je]?li:va;if(!this[ie]&&!Buffer.isBuffer(e)){if(xa(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Ta(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[ie]?(this[J]&&this[Z]!==0&&this[Zi](true),this[J]?this.emit("data",e):this[Ms](e),this[Z]!==0&&this.emit("readable"),s&&r(s),this[J]):e.length?(typeof e=="string"&&!(t===this[Pe]&&!this[zt]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Pe]&&(e=this[zt].write(e)),this[J]&&this[Z]!==0&&this[Zi](true),this[J]?this.emit("data",e):this[Ms](e),this[Z]!==0&&this.emit("readable"),s&&r(s),this[J]):(this[Z]!==0&&this.emit("readable"),s&&r(s),this[J])}read(e){if(this[B])return null;if(this[ye]=false,this[Z]===0||e===0||e&&e>this[Z])return this[Je](),null;this[ie]&&(e=null),this[Y].length>1&&!this[ie]&&(this[Y]=[this[Pe]?this[Y].join(""):Buffer.concat(this[Y],this[Z])]);let t=this[pr](e||null,this[Y][0]);return this[Je](),t}[pr](e,t){if(this[ie])this[Xi]();else {let s=t;e===s.length||e===null?this[Xi]():typeof s=="string"?(this[Y][0]=s.slice(e),t=s.slice(0,e),this[Z]-=e):(this[Y][0]=s.subarray(e),t=s.subarray(0,e),this[Z]-=e);}return this.emit("data",t),!this[Y].length&&!this[Ke]&&this.emit("drain"),t}end(e,t,s){return typeof e=="function"&&(s=e,e=void 0),typeof t=="function"&&(s=t,t="utf8"),e!==void 0&&this.write(e,t),s&&this.once("end",s),this[Ke]=true,this.writable=false,(this[J]||!this[oi])&&this[Je](),this}[jt](){this[B]||(!this[St]&&!this[ne].length&&(this[ye]=true),this[oi]=false,this[J]=true,this.emit("resume"),this[Y].length?this[Zi]():this[Ke]?this[Je]():this.emit("drain"));}resume(){return this[jt]()}pause(){this[J]=false,this[oi]=true,this[ye]=false;}get destroyed(){return this[B]}get flowing(){return this[J]}get paused(){return this[oi]}[Ms](e){this[ie]?this[Z]+=1:this[Z]+=e.length,this[Y].push(e);}[Xi](){return this[ie]?this[Z]-=1:this[Z]-=this[Y][0].length,this[Y].shift()}[Zi](e=false){do;while(this[fr](this[Xi]())&&this[Y].length);!e&&!this[Y].length&&!this[Ke]&&this.emit("drain");}[fr](e){return this.emit("data",e),this[J]}pipe(e,t){if(this[B])return e;this[ye]=false;let s=this[nt];return t=t||{},e===ur.stdout||e===ur.stderr?t.end=false:t.end=t.end!==false,t.proxyErrors=!!t.proxyErrors,s?t.end&&e.end():(this[ne].push(t.proxyErrors?new ka(this,e,t):new mn(this,e,t)),this[je]?li(()=>this[jt]()):this[jt]()),e}unpipe(e){let t=this[ne].find(s=>s.dest===e);t&&(this[ne].length===1?(this[J]&&this[St]===0&&(this[J]=false),this[ne]=[]):this[ne].splice(this[ne].indexOf(t),1),t.unpipe());}addListener(e,t){return this.on(e,t)}on(e,t){let s=super.on(e,t);if(e==="data")this[ye]=false,this[St]++,!this[ne].length&&!this[J]&&this[jt]();else if(e==="readable"&&this[Z]!==0)super.emit("readable");else if(Ea(e)&&this[nt])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ni]){let r=t;this[je]?li(()=>r.call(this,this[ni])):r.call(this,this[ni]);}return s}removeListener(e,t){return this.off(e,t)}off(e,t){let s=super.off(e,t);return e==="data"&&(this[St]=this.listeners("data").length,this[St]===0&&!this[ye]&&!this[ne].length&&(this[J]=false)),s}removeAllListeners(e){let t=super.removeAllListeners(e);return (e==="data"||e===void 0)&&(this[St]=0,!this[ye]&&!this[ne].length&&(this[J]=false)),t}get emittedEnd(){return this[nt]}[Je](){!this[Ji]&&!this[nt]&&!this[B]&&this[Y].length===0&&this[Ke]&&(this[Ji]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Yi]&&this.emit("close"),this[Ji]=false);}emit(e,...t){let s=t[0];if(e!=="error"&&e!=="close"&&e!==B&&this[B])return false;if(e==="data")return !this[ie]&&!s?false:this[je]?(li(()=>this[Ls](s)),true):this[Ls](s);if(e==="end")return this[gr]();if(e==="close"){if(this[Yi]=true,!this[nt]&&!this[B])return false;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(e==="error"){this[ni]=s,super.emit(Rs,s);let o=!this[ai]||this.listeners("error").length?super.emit("error",s):false;return this[Je](),o}else if(e==="resume"){let o=super.emit("resume");return this[Je](),o}else if(e==="finish"||e==="prefinish"){let o=super.emit(e);return this.removeAllListeners(e),o}let r=super.emit(e,...t);return this[Je](),r}[Ls](e){for(let s of this[ne])s.dest.write(e)===false&&this.pause();let t=this[ye]?false:super.emit("data",e);return this[Je](),t}[gr](){return this[nt]?false:(this[nt]=true,this.readable=false,this[je]?(li(()=>this[Cs]()),true):this[Cs]())}[Cs](){if(this[zt]){let t=this[zt].end();if(t){for(let s of this[ne])s.dest.write(t);this[ye]||super.emit("data",t);}}for(let t of this[ne])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[ie]||(e.dataLength=0);let t=this.promise();return this.on("data",s=>{e.push(s),this[ie]||(e.dataLength+=s.length);}),await t,e}async concat(){if(this[ie])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Pe]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(B,()=>t(new Error("stream destroyed"))),this.on("error",s=>t(s)),this.on("end",()=>e());})}[Symbol.asyncIterator](){this[ye]=false;let e=false,t=async()=>(this.pause(),e=true,{value:void 0,done:true});return {next:()=>{if(e)return t();let s=this.read();if(s!==null)return Promise.resolve({done:false,value:s});if(this[Ke])return t();let r,o,a=p=>{this.off("data",h),this.off("end",l),this.off(B,d),t(),o(p);},h=p=>{this.off("error",a),this.off("end",l),this.off(B,d),this.pause(),r({value:p,done:!!this[Ke]});},l=()=>{this.off("error",a),this.off("data",h),this.off(B,d),t(),r({done:true,value:void 0});},d=()=>a(new Error("stream destroyed"));return new Promise((p,u)=>{o=u,r=p,this.once(B,d),this.once("error",a),this.once("end",l),this.once("data",h);})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ye]=false;let e=false,t=()=>(this.pause(),this.off(Rs,t),this.off(B,t),this.off("end",t),e=true,{done:true,value:void 0}),s=()=>{if(e)return t();let r=this.read();return r===null?t():{done:false,value:r}};return this.once("end",t),this.once(Rs,t),this.once(B,t),{next:s,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[B])return e?this.emit("error",e):this.emit(B),this;this[B]=true,this[ye]=true,this[Y].length=0,this[Z]=0;let t=this;return typeof t.close=="function"&&!this[Yi]&&t.close(),e?this.emit("error",e):this.emit(B),this}static get isStream(){return wa}},La=z.realpathSync.native,ui={lstatSync:z.lstatSync,readdir:z.readdir,readdirSync:z.readdirSync,readlinkSync:z.readlinkSync,realpathSync:La,promises:{lstat:jn.lstat,readdir:jn.readdir,readlink:jn.readlink,realpath:jn.realpath}},yn=i=>!i||i===ui||i===z__namespace?ui:{...ui,...i,promises:{...ui.promises,...i.promises||{}}},wn=/^\\\\\?\\([a-z]:)\\?$/i,Ca=i=>i.replace(/\//g,"\\").replace(wn,"$1\\"),Oa=/[\\\/]/,Le=0,bn=1,Sn=2,We=4,vn=6,En=8,vt=10,Tn=12,Me=15,hi=~Me,Ps=16,mr=32,pi=64,De=128,es=256,os=512,yr=pi|De|os,Pa=1023,Ds=i=>i.isFile()?En:i.isDirectory()?We:i.isSymbolicLink()?vt:i.isCharacterDevice()?Sn:i.isBlockDevice()?vn:i.isSocket()?Tn:i.isFIFO()?bn:Le,wr=new fs({max:2**12}),fi=i=>{let e=wr.get(i);if(e)return e;let t=i.normalize("NFKD");return wr.set(i,t),t},br=new fs({max:2**12}),ts=i=>{let e=br.get(i);if(e)return e;let t=fi(i.toLowerCase());return br.set(i,t),t},Sr=class extends fs{constructor(){super({max:256});}},Da=class extends fs{constructor(i=16*1024){super({maxSize:i,sizeCalculation:e=>e.length+1});}},xn=Symbol("PathScurry setAsCwd"),le,Si,vi,Ei,Ti,xi,ki,Mi,Ri,Li,Ci,Oi,Pi,Di,Ai,Ii,Ni,_i,Fi,pt,Lt,qe,Xe,Qe,et,R,Ct,tt,Ve,k,Bs,as,gi,zs,js,mi,ls,Ws,Gs,hs,kn,Mn,Rn,qs,Yt,Zt,Ln,Ot,Hr,pe=(Hr=class{constructor(i,e=Le,t,s,r,o,a){b(this,k);c(this,"name");c(this,"root");c(this,"roots");c(this,"parent");c(this,"nocase");c(this,"isCWD",false);b(this,le);b(this,Si);b(this,vi);b(this,Ei);b(this,Ti);b(this,xi);b(this,ki);b(this,Mi);b(this,Ri);b(this,Li);b(this,Ci);b(this,Oi);b(this,Pi);b(this,Di);b(this,Ai);b(this,Ii);b(this,Ni);b(this,_i);b(this,Fi);b(this,pt);b(this,Lt);b(this,qe);b(this,Xe);b(this,Qe);b(this,et);b(this,R);b(this,Ct);b(this,tt);b(this,Ve);b(this,Yt,[]);b(this,Zt,false);b(this,Ot);this.name=i,g(this,pt,r?ts(i):fi(i)),g(this,R,e&Pa),this.nocase=r,this.roots=s,this.root=t||this,g(this,Ct,o),g(this,qe,a.fullpath),g(this,Qe,a.relative),g(this,et,a.relativePosix),this.parent=a.parent,this.parent?g(this,le,n(this.parent,le)):g(this,le,yn(a.fs));}get dev(){return n(this,Si)}get mode(){return n(this,vi)}get nlink(){return n(this,Ei)}get uid(){return n(this,Ti)}get gid(){return n(this,xi)}get rdev(){return n(this,ki)}get blksize(){return n(this,Mi)}get ino(){return n(this,Ri)}get size(){return n(this,Li)}get blocks(){return n(this,Ci)}get atimeMs(){return n(this,Oi)}get mtimeMs(){return n(this,Pi)}get ctimeMs(){return n(this,Di)}get birthtimeMs(){return n(this,Ai)}get atime(){return n(this,Ii)}get mtime(){return n(this,Ni)}get ctime(){return n(this,_i)}get birthtime(){return n(this,Fi)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return n(this,Lt)!==void 0?n(this,Lt):this.parent?g(this,Lt,this.parent.depth()+1):g(this,Lt,0)}childrenCache(){return n(this,Ct)}resolve(i){var s;if(!i)return this;let e=this.getRootString(i),t=i.substring(e.length).split(this.splitSep);return e?y(s=this.getRoot(e),k,Bs).call(s,t):y(this,k,Bs).call(this,t)}children(){let i=n(this,Ct).get(this);if(i)return i;let e=Object.assign([],{provisional:0});return n(this,Ct).set(this,e),g(this,R,n(this,R)&~Ps),e}child(i,e){if(i===""||i===".")return this;if(i==="..")return this.parent||this;let t=this.children(),s=this.nocase?ts(i):fi(i);for(let h of t)if(n(h,pt)===s)return h;let r=this.parent?this.sep:"",o=n(this,qe)?n(this,qe)+r+i:void 0,a=this.newChild(i,Le,{...e,parent:this,fullpath:o});return this.canReaddir()||g(a,R,n(a,R)|De),t.push(a),a}relative(){if(this.isCWD)return "";if(n(this,Qe)!==void 0)return n(this,Qe);let i=this.name,e=this.parent;if(!e)return g(this,Qe,this.name);let t=e.relative();return t+(!t||!e.parent?"":this.sep)+i}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(n(this,et)!==void 0)return n(this,et);let i=this.name,e=this.parent;if(!e)return g(this,et,this.fullpathPosix());let t=e.relativePosix();return t+(!t||!e.parent?"":"/")+i}fullpath(){if(n(this,qe)!==void 0)return n(this,qe);let i=this.name,e=this.parent;if(!e)return g(this,qe,this.name);let t=e.fullpath()+(e.parent?this.sep:"")+i;return g(this,qe,t)}fullpathPosix(){if(n(this,Xe)!==void 0)return n(this,Xe);if(this.sep==="/")return g(this,Xe,this.fullpath());if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(s)?g(this,Xe,`//?/${s}`):g(this,Xe,s)}let i=this.parent,e=i.fullpathPosix(),t=e+(!e||!i.parent?"":"/")+this.name;return g(this,Xe,t)}isUnknown(){return (n(this,R)&Me)===Le}isType(i){return this[`is${i}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return (n(this,R)&Me)===En}isDirectory(){return (n(this,R)&Me)===We}isCharacterDevice(){return (n(this,R)&Me)===Sn}isBlockDevice(){return (n(this,R)&Me)===vn}isFIFO(){return (n(this,R)&Me)===bn}isSocket(){return (n(this,R)&Me)===Tn}isSymbolicLink(){return (n(this,R)&vt)===vt}lstatCached(){return n(this,R)&mr?this:void 0}readlinkCached(){return n(this,tt)}realpathCached(){return n(this,Ve)}readdirCached(){let i=this.children();return i.slice(0,i.provisional)}canReadlink(){if(n(this,tt))return true;if(!this.parent)return false;let i=n(this,R)&Me;return !(i!==Le&&i!==vt||n(this,R)&es||n(this,R)&De)}calledReaddir(){return !!(n(this,R)&Ps)}isENOENT(){return !!(n(this,R)&De)}isNamed(i){return this.nocase?n(this,pt)===ts(i):n(this,pt)===fi(i)}async readlink(){let i=n(this,tt);if(i)return i;if(this.canReadlink()&&this.parent)try{let e=await n(this,le).promises.readlink(this.fullpath()),t=(await this.parent.realpath())?.resolve(e);if(t)return g(this,tt,t)}catch(e){y(this,k,Gs).call(this,e.code);return}}readlinkSync(){let i=n(this,tt);if(i)return i;if(this.canReadlink()&&this.parent)try{let e=n(this,le).readlinkSync(this.fullpath()),t=this.parent.realpathSync()?.resolve(e);if(t)return g(this,tt,t)}catch(e){y(this,k,Gs).call(this,e.code);return}}async lstat(){if((n(this,R)&De)===0)try{return y(this,k,qs).call(this,await n(this,le).promises.lstat(this.fullpath())),this}catch(i){y(this,k,Ws).call(this,i.code);}}lstatSync(){if((n(this,R)&De)===0)try{return y(this,k,qs).call(this,n(this,le).lstatSync(this.fullpath())),this}catch(i){y(this,k,Ws).call(this,i.code);}}readdirCB(i,e=false){if(!this.canReaddir()){e?i(null,[]):queueMicrotask(()=>i(null,[]));return}let t=this.children();if(this.calledReaddir()){let r=t.slice(0,t.provisional);e?i(null,r):queueMicrotask(()=>i(null,r));return}if(n(this,Yt).push(i),n(this,Zt))return;g(this,Zt,true);let s=this.fullpath();n(this,le).readdir(s,{withFileTypes:true},(r,o)=>{if(r)y(this,k,ls).call(this,r.code),t.provisional=0;else {for(let a of o)y(this,k,hs).call(this,a,t);y(this,k,as).call(this,t);}y(this,k,Ln).call(this,t.slice(0,t.provisional));});}async readdir(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let e=this.fullpath();if(n(this,Ot))await n(this,Ot);else {let t=()=>{};g(this,Ot,new Promise(s=>t=s));try{for(let s of await n(this,le).promises.readdir(e,{withFileTypes:!0}))y(this,k,hs).call(this,s,i);y(this,k,as).call(this,i);}catch(s){y(this,k,ls).call(this,s.code),i.provisional=0;}g(this,Ot,void 0),t();}return i.slice(0,i.provisional)}readdirSync(){if(!this.canReaddir())return [];let i=this.children();if(this.calledReaddir())return i.slice(0,i.provisional);let e=this.fullpath();try{for(let t of n(this,le).readdirSync(e,{withFileTypes:!0}))y(this,k,hs).call(this,t,i);y(this,k,as).call(this,i);}catch(t){y(this,k,ls).call(this,t.code),i.provisional=0;}return i.slice(0,i.provisional)}canReaddir(){if(n(this,R)&yr)return false;let i=Me&n(this,R);return i===Le||i===We||i===vt}shouldWalk(i,e){return (n(this,R)&We)===We&&!(n(this,R)&yr)&&!i.has(this)&&(!e||e(this))}async realpath(){if(n(this,Ve))return n(this,Ve);if(!((os|es|De)&n(this,R)))try{let i=await n(this,le).promises.realpath(this.fullpath());return g(this,Ve,this.resolve(i))}catch{y(this,k,js).call(this);}}realpathSync(){if(n(this,Ve))return n(this,Ve);if(!((os|es|De)&n(this,R)))try{let i=n(this,le).realpathSync(this.fullpath());return g(this,Ve,this.resolve(i))}catch{y(this,k,js).call(this);}}[xn](i){if(i===this)return;i.isCWD=false,this.isCWD=true;let e=new Set([]),t=[],s=this;for(;s&&s.parent;)e.add(s),g(s,Qe,t.join(this.sep)),g(s,et,t.join("/")),s=s.parent,t.push("..");for(s=i;s&&s.parent&&!e.has(s);)g(s,Qe,void 0),g(s,et,void 0),s=s.parent;}},le=new WeakMap,Si=new WeakMap,vi=new WeakMap,Ei=new WeakMap,Ti=new WeakMap,xi=new WeakMap,ki=new WeakMap,Mi=new WeakMap,Ri=new WeakMap,Li=new WeakMap,Ci=new WeakMap,Oi=new WeakMap,Pi=new WeakMap,Di=new WeakMap,Ai=new WeakMap,Ii=new WeakMap,Ni=new WeakMap,_i=new WeakMap,Fi=new WeakMap,pt=new WeakMap,Lt=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Qe=new WeakMap,et=new WeakMap,R=new WeakMap,Ct=new WeakMap,tt=new WeakMap,Ve=new WeakMap,k=new WeakSet,Bs=function(i){let e=this;for(let t of i)e=e.child(t);return e},as=function(i){var e;g(this,R,n(this,R)|Ps);for(let t=i.provisional;t<i.length;t++){let s=i[t];s&&y(e=s,k,gi).call(e);}},gi=function(){n(this,R)&De||(g(this,R,(n(this,R)|De)&hi),y(this,k,zs).call(this));},zs=function(){var e;let i=this.children();i.provisional=0;for(let t of i)y(e=t,k,gi).call(e);},js=function(){g(this,R,n(this,R)|os),y(this,k,mi).call(this);},mi=function(){if(n(this,R)&pi)return;let i=n(this,R);(i&Me)===We&&(i&=hi),g(this,R,i|pi),y(this,k,zs).call(this);},ls=function(i=""){i==="ENOTDIR"||i==="EPERM"?y(this,k,mi).call(this):i==="ENOENT"?y(this,k,gi).call(this):this.children().provisional=0;},Ws=function(i=""){var e;i==="ENOTDIR"?y(e=this.parent,k,mi).call(e):i==="ENOENT"&&y(this,k,gi).call(this);},Gs=function(i=""){var t;let e=n(this,R);e|=es,i==="ENOENT"&&(e|=De),(i==="EINVAL"||i==="UNKNOWN")&&(e&=hi),g(this,R,e),i==="ENOTDIR"&&this.parent&&y(t=this.parent,k,mi).call(t);},hs=function(i,e){return y(this,k,Mn).call(this,i,e)||y(this,k,kn).call(this,i,e)},kn=function(i,e){let t=Ds(i),s=this.newChild(i.name,t,{parent:this}),r=n(s,R)&Me;return r!==We&&r!==vt&&r!==Le&&g(s,R,n(s,R)|pi),e.unshift(s),e.provisional++,s},Mn=function(i,e){for(let t=e.provisional;t<e.length;t++){let s=e[t];if((this.nocase?ts(i.name):fi(i.name))===n(s,pt))return y(this,k,Rn).call(this,i,s,t,e)}},Rn=function(i,e,t,s){let r=e.name;return g(e,R,n(e,R)&hi|Ds(i)),r!==i.name&&(e.name=i.name),t!==s.provisional&&(t===s.length-1?s.pop():s.splice(t,1),s.unshift(e)),s.provisional++,e},qs=function(i){let{atime:e,atimeMs:t,birthtime:s,birthtimeMs:r,blksize:o,blocks:a,ctime:h,ctimeMs:l,dev:d,gid:p,ino:u,mode:f,mtime:m,mtimeMs:w,nlink:S,rdev:x,size:v,uid:M}=i;g(this,Ii,e),g(this,Oi,t),g(this,Fi,s),g(this,Ai,r),g(this,Mi,o),g(this,Ci,a),g(this,_i,h),g(this,Di,l),g(this,Si,d),g(this,xi,p),g(this,Ri,u),g(this,vi,f),g(this,Ni,m),g(this,Pi,w),g(this,Ei,S),g(this,ki,x),g(this,Li,v),g(this,Ti,M);let C=Ds(i);g(this,R,n(this,R)&hi|C|mr),C!==Le&&C!==We&&C!==vt&&g(this,R,n(this,R)|pi);},Yt=new WeakMap,Zt=new WeakMap,Ln=function(i){g(this,Zt,false);let e=n(this,Yt).slice();n(this,Yt).length=0,e.forEach(t=>t(null,i));},Ot=new WeakMap,Hr),Cn=class On extends pe{constructor(t,s=Le,r,o,a,h,l){super(t,s,r,o,a,h,l);c(this,"sep","\\");c(this,"splitSep",Oa);}newChild(t,s=Le,r={}){return new On(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(t){return si.win32.parse(t).root}getRoot(t){if(t=Ca(t.toUpperCase()),t===this.root.name)return this.root;for(let[s,r]of Object.entries(this.roots))if(this.sameRoot(t,s))return this.roots[t]=r;return this.roots[t]=new Ys(t,this).root}sameRoot(t,s=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(wn,"$1\\"),t===s}},Pn=class Dn extends pe{constructor(t,s=Le,r,o,a,h,l){super(t,s,r,o,a,h,l);c(this,"splitSep","/");c(this,"sep","/");}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,s=Le,r={}){return new Dn(t,s,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Xt,Qt,Ui,$i,Kr,An=(Kr=class{constructor(i=process.cwd(),e,t,{nocase:s,childrenCacheSize:r=16*1024,fs:o=ui}={}){c(this,"root");c(this,"rootPath");c(this,"roots");c(this,"cwd");b(this,Xt);b(this,Qt);b(this,Ui);c(this,"nocase");b(this,$i);g(this,$i,yn(o)),(i instanceof URL||i.startsWith("file://"))&&(i=url.fileURLToPath(i));let a=e.resolve(i);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),g(this,Xt,new Sr),g(this,Qt,new Sr),g(this,Ui,new Da(r));let h=a.substring(this.rootPath.length).split(t);if(h.length===1&&!h[0]&&h.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(n(this,$i)),this.roots[this.rootPath]=this.root;let l=this.root,d=h.length-1,p=e.sep,u=this.rootPath,f=false;for(let m of h){let w=d--;l=l.child(m,{relative:new Array(w).fill("..").join(p),relativePosix:new Array(w).fill("..").join("/"),fullpath:u+=(f?"":p)+m}),f=true;}this.cwd=l;}depth(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.depth()}childrenCache(){return n(this,Ui)}resolve(...i){let e="";for(let r=i.length-1;r>=0;r--){let o=i[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let t=n(this,Xt).get(e);if(t!==void 0)return t;let s=this.cwd.resolve(e).fullpath();return n(this,Xt).set(e,s),s}resolvePosix(...i){let e="";for(let r=i.length-1;r>=0;r--){let o=i[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let t=n(this,Qt).get(e);if(t!==void 0)return t;let s=this.cwd.resolve(e).fullpathPosix();return n(this,Qt).set(e,s),s}relative(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relative()}relativePosix(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.relativePosix()}basename(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.name}dirname(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),(i.parent||i).fullpath()}async readdir(i=this.cwd,e={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t}=e;if(i.canReaddir()){let s=await i.readdir();return t?s:s.map(r=>r.name)}else return []}readdirSync(i=this.cwd,e={withFileTypes:true}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true}=e;return i.canReaddir()?t?i.readdirSync():i.readdirSync().map(s=>s.name):[]}async lstat(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstat()}lstatSync(i=this.cwd){return typeof i=="string"&&(i=this.cwd.resolve(i)),i.lstatSync()}async readlink(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i.withFileTypes,i=this.cwd);let t=await i.readlink();return e?t:t?.fullpath()}readlinkSync(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i.withFileTypes,i=this.cwd);let t=i.readlinkSync();return e?t:t?.fullpath()}async realpath(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i.withFileTypes,i=this.cwd);let t=await i.realpath();return e?t:t?.fullpath()}realpathSync(i=this.cwd,{withFileTypes:e}={withFileTypes:false}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i.withFileTypes,i=this.cwd);let t=i.realpathSync();return e?t:t?.fullpath()}async walk(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=[];(!r||r(i))&&a.push(t?i:i.fullpath());let h=new Set,l=(p,u)=>{h.add(p),p.readdirCB((f,m)=>{if(f)return u(f);let w=m.length;if(!w)return u();let S=()=>{--w===0&&u();};for(let x of m)(!r||r(x))&&a.push(t?x:x.fullpath()),s&&x.isSymbolicLink()?x.realpath().then(v=>v?.isUnknown()?v.lstat():v).then(v=>v?.shouldWalk(h,o)?l(v,S):S()):x.shouldWalk(h,o)?l(x,S):S();},true);},d=i;return new Promise((p,u)=>{l(d,f=>{if(f)return u(f);p(a);});})}walkSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=[];(!r||r(i))&&a.push(t?i:i.fullpath());let h=new Set([i]);for(let l of h){let d=l.readdirSync();for(let p of d){(!r||r(p))&&a.push(t?p:p.fullpath());let u=p;if(p.isSymbolicLink()){if(!(s&&(u=p.realpathSync())))continue;u.isUnknown()&&u.lstatSync();}u.shouldWalk(h,o)&&h.add(u);}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(i=this.cwd,e={}){return typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd),this.stream(i,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e;(!r||r(i))&&(yield t?i:i.fullpath());let a=new Set([i]);for(let h of a){let l=h.readdirSync();for(let d of l){(!r||r(d))&&(yield t?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(s&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync();}p.shouldWalk(a,o)&&a.add(p);}}}stream(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=new us({objectMode:true});(!r||r(i))&&a.write(t?i:i.fullpath());let h=new Set,l=[i],d=0,p=()=>{let u=false;for(;!u;){let f=l.shift();if(!f){d===0&&a.end();return}d++,h.add(f);let m=(S,x,v=false)=>{if(S)return a.emit("error",S);if(s&&!v){let M=[];for(let C of x)C.isSymbolicLink()&&M.push(C.realpath().then(P=>P?.isUnknown()?P.lstat():P));if(M.length){Promise.all(M).then(()=>m(null,x,true));return}}for(let M of x)M&&(!r||r(M))&&(a.write(t?M:M.fullpath())||(u=true));d--;for(let M of x){let C=M.realpathCached()||M;C.shouldWalk(h,o)&&l.push(C);}u&&!a.flowing?a.once("drain",p):w||p();},w=true;f.readdirCB(m,true),w=false;}};return p(),a}streamSync(i=this.cwd,e={}){typeof i=="string"?i=this.cwd.resolve(i):i instanceof pe||(e=i,i=this.cwd);let{withFileTypes:t=true,follow:s=false,filter:r,walkFilter:o}=e,a=new us({objectMode:true}),h=new Set;(!r||r(i))&&a.write(t?i:i.fullpath());let l=[i],d=0,p=()=>{let u=false;for(;!u;){let f=l.shift();if(!f){d===0&&a.end();return}d++,h.add(f);let m=f.readdirSync();for(let w of m)(!r||r(w))&&(a.write(t?w:w.fullpath())||(u=true));d--;for(let w of m){let S=w;if(w.isSymbolicLink()){if(!(s&&(S=w.realpathSync())))continue;S.isUnknown()&&S.lstatSync();}S.shouldWalk(h,o)&&l.push(S);}}u&&!a.flowing&&a.once("drain",p);};return p(),a}chdir(i=this.cwd){let e=this.cwd;this.cwd=typeof i=="string"?this.cwd.resolve(i):i,this.cwd[xn](e);}},Xt=new WeakMap,Qt=new WeakMap,Ui=new WeakMap,$i=new WeakMap,Kr),Ys=class extends An{constructor(e=process.cwd(),t={}){let{nocase:s=true}=t;super(e,si.win32,"\\",{...t,nocase:s});c(this,"sep","\\");this.nocase=s;for(let r=this.cwd;r;r=r.parent)r.nocase=this.nocase;}parseRootPath(e){return si.win32.parse(e).root.toUpperCase()}newRoot(e){return new Cn(this.rootPath,We,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Zs=class extends An{constructor(e=process.cwd(),t={}){let{nocase:s=false}=t;super(e,si.posix,"/",{...t,nocase:s});c(this,"sep","/");this.nocase=s;}parseRootPath(e){return "/"}newRoot(e){return new Pn(this.rootPath,We,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},In=class extends Zs{constructor(i=process.cwd(),e={}){let{nocase:t=true}=e;super(i,{...e,nocase:t});}};process.platform==="win32"?Cn:Pn;var Aa=process.platform==="win32"?Ys:process.platform==="darwin"?In:Zs,Ia=i=>i.length>=1,Na=i=>i.length>=1,_a=Symbol.for("nodejs.util.inspect.custom"),H,fe,K,Pt,ze,Bi,ft,gt,mt,ei,ti,Nn=(ti=class{constructor(e,t,s,r){b(this,H);b(this,fe);b(this,K);c(this,"length");b(this,Pt);b(this,ze);b(this,Bi);b(this,ft);b(this,gt);b(this,mt);b(this,ei,true);if(!Ia(e))throw new TypeError("empty pattern list");if(!Na(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,s<0||s>=this.length)throw new TypeError("index out of range");if(g(this,H,e),g(this,fe,t),g(this,K,s),g(this,Pt,r),n(this,K)===0){if(this.isUNC()){let[o,a,h,l,...d]=n(this,H),[p,u,f,m,...w]=n(this,fe);d[0]===""&&(d.shift(),w.shift());let S=[o,a,h,l,""].join("/"),x=[p,u,f,m,""].join("/");g(this,H,[S,...d]),g(this,fe,[x,...w]),this.length=n(this,H).length;}else if(this.isDrive()||this.isAbsolute()){let[o,...a]=n(this,H),[h,...l]=n(this,fe);a[0]===""&&(a.shift(),l.shift());let d=o+"/",p=h+"/";g(this,H,[d,...a]),g(this,fe,[p,...l]),this.length=n(this,H).length;}}}[_a](){return "Pattern <"+n(this,fe).slice(n(this,K)).join("/")+">"}pattern(){return n(this,H)[n(this,K)]}isString(){return typeof n(this,H)[n(this,K)]=="string"}isGlobstar(){return n(this,H)[n(this,K)]===he}isRegExp(){return n(this,H)[n(this,K)]instanceof RegExp}globString(){return g(this,Bi,n(this,Bi)||(n(this,K)===0?this.isAbsolute()?n(this,fe)[0]+n(this,fe).slice(1).join("/"):n(this,fe).join("/"):n(this,fe).slice(n(this,K)).join("/")))}hasMore(){return this.length>n(this,K)+1}rest(){return n(this,ze)!==void 0?n(this,ze):this.hasMore()?(g(this,ze,new ti(n(this,H),n(this,fe),n(this,K)+1,n(this,Pt))),g(n(this,ze),mt,n(this,mt)),g(n(this,ze),gt,n(this,gt)),g(n(this,ze),ft,n(this,ft)),n(this,ze)):g(this,ze,null)}isUNC(){let e=n(this,H);return n(this,gt)!==void 0?n(this,gt):g(this,gt,n(this,Pt)==="win32"&&n(this,K)===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3])}isDrive(){let e=n(this,H);return n(this,ft)!==void 0?n(this,ft):g(this,ft,n(this,Pt)==="win32"&&n(this,K)===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]))}isAbsolute(){let e=n(this,H);return n(this,mt)!==void 0?n(this,mt):g(this,mt,e[0]===""&&e.length>1||this.isDrive()||this.isUNC())}root(){let e=n(this,H)[0];return typeof e=="string"&&this.isAbsolute()&&n(this,K)===0?e:""}checkFollowGlobstar(){return !(n(this,K)===0||!this.isGlobstar()||!n(this,ei))}markFollowGlobstar(){return n(this,K)===0||!this.isGlobstar()||!n(this,ei)?false:(g(this,ei,false),true)}},H=new WeakMap,fe=new WeakMap,K=new WeakMap,Pt=new WeakMap,ze=new WeakMap,Bi=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,ei=new WeakMap,ti),Fa=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",vr=class{constructor(i,{nobrace:e,nocase:t,noext:s,noglobstar:r,platform:o=Fa}){c(this,"relative");c(this,"relativeChildren");c(this,"absolute");c(this,"absoluteChildren");c(this,"platform");c(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:true,nobrace:e,nocase:t,noext:s,noglobstar:r,optimizationLevel:2,platform:o,nocomment:true,nonegate:true};for(let a of i)this.add(a);}add(i){let e=new wt(i,this.mmopts);for(let t=0;t<e.set.length;t++){let s=e.set[t],r=e.globParts[t];if(!s||!r)throw new Error("invalid pattern object");for(;s[0]==="."&&r[0]===".";)s.shift(),r.shift();let o=new Nn(s,r,0,this.platform),a=new wt(o.globString(),this.mmopts),h=r[r.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),h&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a));}}ignored(i){let e=i.fullpath(),t=`${e}/`,s=i.relative()||".",r=`${s}/`;for(let o of this.relative)if(o.match(s)||o.match(r))return true;for(let o of this.absolute)if(o.match(e)||o.match(t))return true;return false}childrenIgnored(i){let e=i.fullpath()+"/",t=(i.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(t))return true;for(let s of this.absoluteChildren)if(s.match(e))return true;return false}},Ua=class _n{constructor(e=new Map){c(this,"store");this.store=e;}copy(){return new _n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let s=e.fullpath(),r=this.store.get(s);r?r.add(t.globString()):this.store.set(s,new Set([t.globString()]));}},$a=class{constructor(){c(this,"store",new Map);}add(i,e,t){let s=(e?2:0)|(t?1:0),r=this.store.get(i);this.store.set(i,r===void 0?s:s&r);}entries(){return [...this.store.entries()].map(([i,e])=>[i,!!(e&2),!!(e&1)])}},Ba=class{constructor(){c(this,"store",new Map);}add(i,e){if(!i.canReaddir())return;let t=this.store.get(i);t?t.find(s=>s.globString()===e.globString())||t.push(e):this.store.set(i,[e]);}get(i){let e=this.store.get(i);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(i=>[i,this.store.get(i)])}keys(){return [...this.store.keys()].filter(i=>i.canReaddir())}},Er=class Fn{constructor(e,t){c(this,"hasWalkedCache");c(this,"matches",new $a);c(this,"subwalks",new Ba);c(this,"patterns");c(this,"follow");c(this,"dot");c(this,"opts");this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new Ua;}processPatterns(e,t){this.patterns=t;let s=t.map(r=>[e,r]);for(let[r,o]of s){this.hasWalkedCache.storeWalked(r,o);let a=o.root(),h=o.isAbsolute()&&this.opts.absolute!==false;if(a){r=r.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let u=o.rest();if(u)o=u;else {this.matches.add(r,true,false);continue}}if(r.isENOENT())continue;let l,d,p=false;for(;typeof(l=o.pattern())=="string"&&(d=o.rest());)r=r.resolve(l),o=d,p=true;if(l=o.pattern(),d=o.rest(),p){if(this.hasWalkedCache.hasWalked(r,o))continue;this.hasWalkedCache.storeWalked(r,o);}if(typeof l=="string"){let u=l===".."||l===""||l===".";this.matches.add(r.resolve(l),h,u);continue}else if(l===he){(!r.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(r,o);let u=d?.pattern(),f=d?.rest();if(!d||(u===""||u===".")&&!f)this.matches.add(r,h,u===""||u===".");else if(u===".."){let m=r.parent||r;f?this.hasWalkedCache.hasWalked(m,f)||this.subwalks.add(m,f):this.matches.add(m,h,true);}}else l instanceof RegExp&&this.subwalks.add(r,o);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Fn(this.opts,this.hasWalkedCache)}filterEntries(e,t){let s=this.subwalks.get(e),r=this.child();for(let o of t)for(let a of s){let h=a.isAbsolute(),l=a.pattern(),d=a.rest();l===he?r.testGlobstar(o,a,d,h):l instanceof RegExp?r.testRegExp(o,l,d,h):r.testString(o,l,d,h);}return r}testGlobstar(e,t,s,r){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,r,false),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(s&&t.checkFollowGlobstar()?this.subwalks.add(e,s):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),s){let o=s.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(e,o,s.rest(),r);else if(o===".."){let a=e.parent||e;this.subwalks.add(a,s);}else o instanceof RegExp&&this.testRegExp(e,o,s.rest(),r);}}testRegExp(e,t,s,r){t.test(e.name)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,false));}testString(e,t,s,r){e.isNamed(t)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,false));}},za=(i,e)=>typeof i=="string"?new vr([i],e):Array.isArray(i)?new vr(i,e):i,ii,it,Dt,Ce,Et,Vs,Jr,Un=(Jr=class{constructor(i,e,t){b(this,Ce);c(this,"path");c(this,"patterns");c(this,"opts");c(this,"seen",new Set);c(this,"paused",false);c(this,"aborted",false);b(this,ii,[]);b(this,it);b(this,Dt);c(this,"signal");c(this,"maxDepth");c(this,"includeChildMatches");if(this.patterns=i,this.path=e,this.opts=t,g(this,Dt,!t.posix&&t.platform==="win32"?"\\":"/"),this.includeChildMatches=t.includeChildMatches!==false,(t.ignore||!this.includeChildMatches)&&(g(this,it,za(t.ignore??[],t)),!this.includeChildMatches&&typeof n(this,it).add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=t.maxDepth||1/0,t.signal&&(this.signal=t.signal,this.signal.addEventListener("abort",()=>{n(this,ii).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let i;for(;!this.paused&&(i=n(this,ii).shift());)i();}onResume(i){this.signal?.aborted||(this.paused?n(this,ii).push(i):i());}async matchCheck(i,e){if(e&&this.opts.nodir)return;let t;if(this.opts.realpath){if(t=i.realpathCached()||await i.realpath(),!t)return;i=t;}let s=i.isUnknown()||this.opts.stat?await i.lstat():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=await s.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat();}return this.matchCheckTest(s,e)}matchCheckTest(i,e){return i&&(this.maxDepth===1/0||i.depth()<=this.maxDepth)&&(!e||i.canReaddir())&&(!this.opts.nodir||!i.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!i.isSymbolicLink()||!i.realpathCached()?.isDirectory())&&!y(this,Ce,Et).call(this,i)?i:void 0}matchCheckSync(i,e){if(e&&this.opts.nodir)return;let t;if(this.opts.realpath){if(t=i.realpathCached()||i.realpathSync(),!t)return;i=t;}let s=i.isUnknown()||this.opts.stat?i.lstatSync():i;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=s.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync();}return this.matchCheckTest(s,e)}matchFinish(i,e){if(y(this,Ce,Et).call(this,i))return;if(!this.includeChildMatches&&n(this,it)?.add){let r=`${i.relativePosix()}/**`;n(this,it).add(r);}let t=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(i);let s=this.opts.mark&&i.isDirectory()?n(this,Dt):"";if(this.opts.withFileTypes)this.matchEmit(i);else if(t){let r=this.opts.posix?i.fullpathPosix():i.fullpath();this.matchEmit(r+s);}else {let r=this.opts.posix?i.relativePosix():i.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+n(this,Dt))?"."+n(this,Dt):"";this.matchEmit(r?o+r+s:"."+s);}}async match(i,e,t){let s=await this.matchCheck(i,t);s&&this.matchFinish(s,e);}matchSync(i,e,t){let s=this.matchCheckSync(i,t);s&&this.matchFinish(s,e);}walkCB(i,e,t){this.signal?.aborted&&t(),this.walkCB2(i,e,new Er(this.opts),t);}walkCB2(i,e,t,s){if(y(this,Ce,Vs).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(i,e,t,s));return}t.processPatterns(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Ce,Et).call(this,a)||(r++,this.match(a,h,l).then(()=>o()));for(let a of t.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,t,o):a.readdirCB((l,d)=>this.walkCB3(a,d,t,o),true);}o();}walkCB3(i,e,t,s){t=t.filterEntries(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Ce,Et).call(this,a)||(r++,this.match(a,h,l).then(()=>o()));for(let[a,h]of t.subwalks.entries())r++,this.walkCB2(a,h,t.child(),o);o();}walkCBSync(i,e,t){this.signal?.aborted&&t(),this.walkCB2Sync(i,e,new Er(this.opts),t);}walkCB2Sync(i,e,t,s){if(y(this,Ce,Vs).call(this,i))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(i,e,t,s));return}t.processPatterns(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Ce,Et).call(this,a)||this.matchSync(a,h,l);for(let a of t.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirSync();this.walkCB3Sync(a,h,t,o);}o();}walkCB3Sync(i,e,t,s){t=t.filterEntries(i,e);let r=1,o=()=>{--r===0&&s();};for(let[a,h,l]of t.matches.entries())y(this,Ce,Et).call(this,a)||this.matchSync(a,h,l);for(let[a,h]of t.subwalks.entries())r++,this.walkCB2Sync(a,h,t.child(),o);o();}},ii=new WeakMap,it=new WeakMap,Dt=new WeakMap,Ce=new WeakSet,Et=function(i){return this.seen.has(i)||!!n(this,it)?.ignored?.(i)},Vs=function(i){return !!n(this,it)?.childrenIgnored?.(i)},Jr),Tr=class extends Un{constructor(e,t,s){super(e,t,s);c(this,"matches",new Set);}matchEmit(e){this.matches.add(e);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches);});}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},xr=class extends Un{constructor(e,t,s){super(e,t,s);c(this,"results");this.results=new us({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(e){this.results.write(e),this.results.flowing||this.pause();}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end());}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},ja=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",It=class{constructor(i,e){c(this,"absolute");c(this,"cwd");c(this,"root");c(this,"dot");c(this,"dotRelative");c(this,"follow");c(this,"ignore");c(this,"magicalBraces");c(this,"mark");c(this,"matchBase");c(this,"maxDepth");c(this,"nobrace");c(this,"nocase");c(this,"nodir");c(this,"noext");c(this,"noglobstar");c(this,"pattern");c(this,"platform");c(this,"realpath");c(this,"scurry");c(this,"stat");c(this,"signal");c(this,"windowsPathsNoEscape");c(this,"withFileTypes");c(this,"includeChildMatches");c(this,"opts");c(this,"patterns");if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=url.fileURLToPath(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==false,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof i=="string"&&(i=[i]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===false,this.windowsPathsNoEscape&&(i=i.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");i=i.map(h=>h.includes("/")?h:`./**/${h}`);}if(this.pattern=i,this.platform=e.platform||ja,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let h=e.platform==="win32"?Ys:e.platform==="darwin"?In:e.platform?Zs:Aa;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs});}this.nocase=this.scurry.nocase;let t=this.platform==="darwin"||this.platform==="win32",s={braceExpandMax:1e4,...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:t,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(h=>new wt(h,s)),[o,a]=r.reduce((h,l)=>(h[0].push(...l.set),h[1].push(...l.globParts),h),[[],[]]);this.patterns=o.map((h,l)=>{let d=a[l];if(!d)throw new Error("invalid pattern object");return new Nn(h,d,0,this.platform)});}async walk(){return [...await new Tr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return [...new Tr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new xr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new xr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},Wa=(i,e={})=>{Array.isArray(i)||(i=[i]);for(let t of i)if(new wt(t,e).hasMagic())return true;return false};function gs(i,e={}){return new It(i,e).streamSync()}function $n(i,e={}){return new It(i,e).stream()}function Bn(i,e={}){return new It(i,e).walkSync()}async function kr(i,e={}){return new It(i,e).walk()}function ms(i,e={}){return new It(i,e).iterateSync()}function zn(i,e={}){return new It(i,e).iterate()}var Ga=gs,qa=Object.assign($n,{sync:gs}),Va=ms,Ha=Object.assign(zn,{sync:ms}),Ka=Object.assign(Bn,{stream:gs,iterate:ms}),ps=Object.assign(kr,{glob:kr,globSync:Bn,sync:Ka,globStream:$n,stream:qa,globStreamSync:gs,streamSync:Ga,globIterate:zn,iterate:Ha,globIterateSync:ms,iterateSync:Va,Glob:It,hasMagic:Wa,escape:on,unescape:Wt});ps.glob=ps;var Oe;(Te=>{Te.Level=Ya__default.default.enum(["DEBUG","INFO","WARN","ERROR"]).meta({ref:"LogLevel",description:"Log level"});let e={DEBUG:0,INFO:1,WARN:2,ERROR:3},t="INFO";function s(O){return e[O]>=e[t]}function r(){return t}Te.getLevel=r;let o=new Map;Te.Default=D({service:"default"});let h="";function l(){return h}Te.file=l;let d,p,u=false,f=false,m=O=>{try{f&&process.stderr.write(O);}catch{}},w=false,S=false;async function x(O){if(u)return;if(O.level&&(t=O.level),O.print&&(f=O.print??false),O.print){u=true;return}let _=O.logDir||si__namespace.default.join(process.env.EASBOT_LOG_PATH??process.cwd(),"logs");O.logFile?h=si__namespace.default.join(_,O.logFile??"local-model-sdk.log"):h=si__namespace.default.join(_,"local-model-sdk.log");try{await jn__default.default.mkdir(_,{recursive:!0}),d=await jn__default.default.open(h,"a"),p=z.createWriteStream("",{fd:d.fd,autoClose:!1}),m=$=>{if(!(w||S||!p||p.destroyed))try{if(!p.writable)return;p.write($,de=>{if(de&&!w){let F=de;if(F.code==="EPIPE"||F.code==="EIO"){S=!0,p?.destroy();return}w=!0,setTimeout(()=>{w=!1;},1e3);}});}catch(de){let F=de;if(F.code==="EPIPE"||F.code==="EIO"){S=!0,p?.destroy();return}w||(w=!0,setTimeout(()=>{w=!1;},1e3));}},u=!0;}catch{m=$=>{try{process.stderr.write($);}catch{}},u=true;}}Te.init=x;async function v(){u&&(p&&!p.destroyed&&(await new Promise((O,_)=>{p.end($=>{$?_($):O();});}).catch(()=>{}),p=void 0),d&&(await d.close().catch(()=>{}),d=void 0),m=O=>{try{process.stderr.write(O);}catch{}},u=false);}Te.close=v;function C(O,_=0){let $=O.message;return O.cause instanceof Error&&_<10?$+" Caused by: "+C(O.cause,_+1):$}let P=Date.now();function D(O){O=O||{};let _=O.service;if(_&&typeof _=="string"){let F=o.get(_);if(F)return F}function $(F,ue){let Es=Object.entries({...O,...ue}).filter(([tr,rt])=>rt!=null).map(([tr,rt])=>{let Ts=`${tr}=`;return rt instanceof Error?Ts+C(rt):typeof rt=="object"?Ts+JSON.stringify(rt):Ts+rt}).join(" "),$t=new Date,Kn=$t.getTime()-P;return P=$t.getTime(),[utils.formatLogTime($t),"+"+Kn+"ms",Es,F].filter(Boolean).join(" ")+`
|
|
4
|
-
`}let de={debug(F,ue){s("DEBUG")&&m("DEBUG "+$(F,ue));},info(F,ue){s("INFO")&&m("INFO "+$(F,ue));},error(F,ue){s("ERROR")&&m("ERROR "+$(F,ue));},warn(F,ue){s("WARN")&&m("WARN "+$(F,ue));},tag(F,ue){return O&&(O[F]=ue),de},clone(){return Te.create({...O})},time(F,ue){let Es=Date.now();de.info(F,{status:"started",...ue});function $t(){de.info(F,{status:"completed",duration:Date.now()-Es,...ue});}return {stop:$t,[Symbol.dispose](){$t();}}}};return _&&typeof _=="string"&&o.set(_,de),de}Te.create=D;})(Oe||(Oe={}));var Nt=null;async function Xa(){if(!Nt){Nt=(await import('@huggingface/transformers')).env;let e=si__namespace.join(sr__namespace.homedir(),".cache","easbot","models");process.env.HF_HOME||(process.env.HF_HOME=e),Nt.allowLocalModels=true,Nt.allowRemoteModels=true,Nt.useBrowserCache=false,Nt.useFSCache=true;}return Nt}var Xs=null;async function Wn(){return Xs||(Xs=(await import('@huggingface/transformers')).pipeline),Xs}var U=Oe.create({service:"transformers-engine"});var ws=class{constructor(e){c(this,"pipeline",null);c(this,"tokenizer",null);c(this,"isInitialized",false);c(this,"config");c(this,"modelCache");this.config=e,this.modelCache=new Bt({cacheDir:e.cacheDir});}async configureEnvironment(){let e=await Xa();this.modelCache.ensureCacheDir(),process.env.HF_HOME||(process.env.HF_HOME=this.config.cacheDir),e.cacheDir=this.config.cacheDir,e.allowLocalModels=true,e.allowRemoteModels=true,e.useBrowserCache=false,e.useFSCache=true,e.backends?.onnx&&(e.backends.onnx.logLevel="error"),this.config.verbose&&U.debug("\u73AF\u5883\u914D\u7F6E\u5B8C\u6210",{cacheDir:this.config.cacheDir,hfHome:process.env.HF_HOME,modelId:this.config.modelId,modelType:this.config.modelType});}async initialize(){if(this.isInitialized){this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7\u91CD\u590D\u52A0\u8F7D");return}await this.configureEnvironment();try{this.config.verbose&&U.debug("\u5F00\u59CB\u521D\u59CB\u5316\u6A21\u578B");let e,t,s;if(this.config.modelType==="language"){let a=xe[this.config.modelId];if(!a)throw new T(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=a.huggingFaceId,t=a.dtype,s=a.device;}else {let a=bt[this.config.modelId];if(!a)throw new T(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=a.huggingFaceId,t=a.dtype;}this.config.verbose&&(U.debug("\u52A0\u8F7D\u6A21\u578B",{huggingFaceId:e,dtype:t||"auto"}),this.modelCache.isCached(e)?U.debug("\u4F7F\u7528\u7F13\u5B58\u7684\u6A21\u578B"):U.debug("\u9996\u6B21\u4E0B\u8F7D\u6A21\u578B\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u4E9B\u65F6\u95F4"));let r={cache_dir:this.config.cacheDir,local_files_only:!0};if(t&&(r.dtype=t),s&&(r.device=s),this.modelCache.isCached(e))this.config.verbose&&U.debug("\u4F7F\u7528\u672C\u5730\u7F13\u5B58\u6A21\u578B");else throw this.config.verbose&&U.warn("\u672C\u5730\u7F13\u5B58\u4E0D\u5B58\u5728",{huggingFaceId:e,cacheDir:this.config.cacheDir}),new T(`\u6A21\u578B ${e} \u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u3002\u8BF7\u5148\u4E0B\u8F7D\u6A21\u578B\u5230: ${this.config.cacheDir}`,"MODEL_NOT_FOUND");if(this.config.modelType==="language"){let a=this.config.pipelineType||"text-generation";this.config.verbose&&U.debug("\u52A0\u8F7D\u8BED\u8A00\u6A21\u578B pipeline",{pipelineType:a,huggingFaceId:e});let h=await Wn();this.pipeline=await h(a,e,r);}else {let a=await Wn();this.pipeline=await a("feature-extraction",e,r);}this.tokenizer=this.pipeline.tokenizer,this.isInitialized=!0,this.config.verbose&&U.debug("\u6A21\u578B\u521D\u59CB\u5316\u6210\u529F",{modelId:this.config.modelId});}catch(e){throw this.config.verbose&&U.error("\u6A21\u578B\u521D\u59CB\u5316\u5931\u8D25",{error:e}),re.modelLoadError(e instanceof Error?e:new Error(String(e)))}}extractAssistantResponse(e,t){let s=`<|im_start|>assistant
|
|
5
|
-
`,r=e.lastIndexOf(s);if(r!==-1){let p=e.slice(r+s.length);return p=p.replace(/<\|im_end\|>$/g,""),p.trim()}let o=`
|
|
1
|
+
'use strict';var H=require('os'),A=require('path'),b=require('fs'),utils=require('@easbot/utils'),ai=require('ai');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var H__namespace=/*#__PURE__*/_interopNamespace(H);var A__namespace=/*#__PURE__*/_interopNamespace(A);var b__namespace=/*#__PURE__*/_interopNamespace(b);var ee=Object.defineProperty;var te=(f,e,t)=>e in f?ee(f,e,{enumerable:true,configurable:true,writable:true,value:t}):f[e]=t;var c=(f,e,t)=>te(f,typeof e!="symbol"?e+"":e,t);var M=(d=>(d.MODEL_NOT_FOUND="MODEL_NOT_FOUND",d.MODEL_LOAD_ERROR="MODEL_LOAD_ERROR",d.MODEL_NOT_INITIALIZED="MODEL_NOT_INITIALIZED",d.GENERATION_ERROR="GENERATION_ERROR",d.EMBEDDING_ERROR="EMBEDDING_ERROR",d.INVALID_INPUT="INVALID_INPUT",d.UNSUPPORTED_FEATURE="UNSUPPORTED_FEATURE",d.CACHE_ERROR="CACHE_ERROR",d.PROCESSING_ERROR="PROCESSING_ERROR",d.ABORTED="ABORTED",d.OUT_OF_MEMORY="OUT_OF_MEMORY",d.UNKNOWN_ERROR="UNKNOWN_ERROR",d))(M||{});function B(f,e,t){let n;return e?n="error":f?n="stop":n="other",{unified:n,raw:t}}var L={"qwen3-0.6b":{modelId:"qwen3-0.6b",huggingFaceId:"onnx-community/Qwen3-0.6B-ONNX",contextLength:32768,device:"cpu",dtype:"q4f16",defaultSettings:{temperature:0,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"qwen3.5-0.8b":{modelId:"qwen3.5-0.8b",huggingFaceId:"onnx-community/Qwen3.5-0.8B-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}},"gemma-3-1b-it":{modelId:"gemma-3-1b-it",huggingFaceId:"onnx-community/gemma-3-1b-it-ONNX",contextLength:32768,dtype:"q4",defaultSettings:{temperature:.7,topP:.9,topK:40,maxTokens:32e3,repetitionPenalty:1.1,stopSequences:[]}}},P={"bge-small-zh-v1.5":{modelId:"bge-small-zh-v1.5",huggingFaceId:"Xenova/bge-small-zh-v1.5",dimensions:512,maxEmbeddingsPerCall:32},"bge-base-zh-v1.5":{modelId:"bge-base-zh-v1.5",huggingFaceId:"Xenova/bge-base-zh-v1.5",dimensions:768,maxEmbeddingsPerCall:32,dtype:"q4"},"bge-large-zh-v1.5":{modelId:"bge-large-zh-v1.5",huggingFaceId:"Xenova/bge-large-zh-v1.5",dimensions:1024,maxEmbeddingsPerCall:32,dtype:"q4"},"all-MiniLM-L6-v2":{modelId:"all-MiniLM-L6-v2",huggingFaceId:"sentence-transformers/all-MiniLM-L6-v2",dimensions:384,maxEmbeddingsPerCall:32,dtype:"q4"}};var s=class f extends Error{constructor(t,n,r){super(t);c(this,"code",n);c(this,"cause",r);this.name="LocalModelError",Error.captureStackTrace&&Error.captureStackTrace(this,f);}},T=class{static modelLoadError(e){return new s(`\u6A21\u578B\u52A0\u8F7D\u5931\u8D25: ${e.message}`,"MODEL_LOAD_ERROR",e)}static generationError(e){return new s(`\u751F\u6210\u5931\u8D25: ${e.message}`,"GENERATION_ERROR",e)}static embeddingError(e){return new s(`\u5D4C\u5165\u5931\u8D25: ${e.message}`,"EMBEDDING_ERROR",e)}static validationError(e){return new s(e,"INVALID_INPUT")}static abortError(){return new s("\u64CD\u4F5C\u5DF2\u4E2D\u6B62","ABORTED")}static unsupportedFeature(e){return new s(`\u4E0D\u652F\u6301\u7684\u529F\u80FD: ${e}`,"UNSUPPORTED_FEATURE")}};var ne=A__namespace.join(H__namespace.homedir(),".cache","easbot","models"),D=class{constructor(e){c(this,"cacheDir");this.cacheDir=e.cacheDir||ne;}getCachePath(e){return A__namespace.join(this.cacheDir,e)}isCached(e){try{let t=this.getCachePath(e);return b__namespace.existsSync(t)&&b__namespace.statSync(t).isDirectory()}catch{return false}}async clear(e){try{if(e){let t=this.getCachePath(e);b__namespace.existsSync(t)&&await this.removeDirectory(t);}else b__namespace.existsSync(this.cacheDir)&&await this.removeDirectory(this.cacheDir);}catch(t){throw new s(`\u6E05\u7406\u7F13\u5B58\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getCacheSize(e){try{let t=e?this.getCachePath(e):this.cacheDir;return b__namespace.existsSync(t)?await this.getDirectorySize(t):0}catch(t){throw new s(`\u83B7\u53D6\u7F13\u5B58\u5927\u5C0F\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`,"CACHE_ERROR",t instanceof Error?t:void 0)}}async getDirectorySize(e){let t=0,n=b__namespace.readdirSync(e);for(let r of n){let o=A__namespace.join(e,r),a=b__namespace.statSync(o);a.isDirectory()?t+=await this.getDirectorySize(o):t+=a.size;}return t}async removeDirectory(e){if(!b__namespace.existsSync(e))return;let t=b__namespace.readdirSync(e);for(let n of t){let r=A__namespace.join(e,n);b__namespace.statSync(r).isDirectory()?await this.removeDirectory(r):b__namespace.unlinkSync(r);}b__namespace.rmdirSync(e);}ensureCacheDir(){try{b__namespace.existsSync(this.cacheDir)||b__namespace.mkdirSync(this.cacheDir,{recursive:!0});}catch(e){throw new s(`\u521B\u5EFA\u7F13\u5B58\u76EE\u5F55\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`,"CACHE_ERROR",e instanceof Error?e:void 0)}}};var I=null;async function re(){if(!I){I=(await import('@huggingface/transformers')).env;let e=A__namespace.join(H__namespace.homedir(),".cache","easbot","models");process.env.HF_HOME||(process.env.HF_HOME=e),I.allowLocalModels=true,I.allowRemoteModels=true,I.useBrowserCache=false,I.useFSCache=true;}return I}var j=null;async function J(){return j||(j=(await import('@huggingface/transformers')).pipeline),j}var y=utils.Log.create({service:"transformers-engine"});var V=class{constructor(e){c(this,"pipeline",null);c(this,"tokenizer",null);c(this,"isInitialized",false);c(this,"config");c(this,"modelCache");this.config=e,this.modelCache=new D({cacheDir:e.cacheDir});}async configureEnvironment(){let e=await re();this.modelCache.ensureCacheDir(),process.env.HF_HOME||(process.env.HF_HOME=this.config.cacheDir),e.cacheDir=this.config.cacheDir,e.allowLocalModels=true,e.allowRemoteModels=true,e.useBrowserCache=false,e.useFSCache=true,e.backends?.onnx&&(e.backends.onnx.logLevel="error"),this.config.verbose&&y.debug("\u73AF\u5883\u914D\u7F6E\u5B8C\u6210",{cacheDir:this.config.cacheDir,hfHome:process.env.HF_HOME,modelId:this.config.modelId,modelType:this.config.modelType});}async initialize(){if(this.isInitialized){this.config.verbose&&y.debug("\u6A21\u578B\u5DF2\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7\u91CD\u590D\u52A0\u8F7D");return}await this.configureEnvironment();try{this.config.verbose&&y.debug("\u5F00\u59CB\u521D\u59CB\u5316\u6A21\u578B");let e,t,n;if(this.config.modelType==="language"){let a=L[this.config.modelId];if(!a)throw new s(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=a.huggingFaceId,t=a.dtype,n=a.device;}else {let a=P[this.config.modelId];if(!a)throw new s(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${this.config.modelId}`,"MODEL_NOT_FOUND");e=a.huggingFaceId,t=a.dtype;}this.config.verbose&&(y.debug("\u52A0\u8F7D\u6A21\u578B",{huggingFaceId:e,dtype:t||"auto"}),this.modelCache.isCached(e)?y.debug("\u4F7F\u7528\u7F13\u5B58\u7684\u6A21\u578B"):y.debug("\u9996\u6B21\u4E0B\u8F7D\u6A21\u578B\uFF0C\u53EF\u80FD\u9700\u8981\u4E00\u4E9B\u65F6\u95F4"));let r={cache_dir:this.config.cacheDir,local_files_only:!0};if(t&&(r.dtype=t),n&&(r.device=n),this.modelCache.isCached(e))this.config.verbose&&y.debug("\u4F7F\u7528\u672C\u5730\u7F13\u5B58\u6A21\u578B");else throw this.config.verbose&&y.warn("\u672C\u5730\u7F13\u5B58\u4E0D\u5B58\u5728",{huggingFaceId:e,cacheDir:this.config.cacheDir}),new s(`\u6A21\u578B ${e} \u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u3002\u8BF7\u5148\u4E0B\u8F7D\u6A21\u578B\u5230: ${this.config.cacheDir}`,"MODEL_NOT_FOUND");if(this.config.modelType==="language"){let a=this.config.pipelineType||"text-generation";this.config.verbose&&y.debug("\u52A0\u8F7D\u8BED\u8A00\u6A21\u578B pipeline",{pipelineType:a,huggingFaceId:e});let g=await J();this.pipeline=await g(a,e,r);}else {let a=await J();this.pipeline=await a("feature-extraction",e,r);}this.tokenizer=this.pipeline.tokenizer,this.isInitialized=!0,this.config.verbose&&y.debug("\u6A21\u578B\u521D\u59CB\u5316\u6210\u529F",{modelId:this.config.modelId});}catch(e){throw this.config.verbose&&y.error("\u6A21\u578B\u521D\u59CB\u5316\u5931\u8D25",{error:e}),T.modelLoadError(e instanceof Error?e:new Error(String(e)))}}extractAssistantResponse(e,t){let n=`<|im_start|>assistant
|
|
2
|
+
`,r=e.lastIndexOf(n);if(r!==-1){let u=e.slice(r+n.length);return u=u.replace(/<\|im_end\|>$/g,""),u.trim()}let o=`
|
|
6
3
|
assistant
|
|
7
|
-
`,a=e.lastIndexOf(o);if(a!==-1)return e.slice(a+o.length).trim();let
|
|
8
|
-
`,l=e.lastIndexOf(h);return l!==-1?e.slice(l+h.length).trim():(e.startsWith(t)?e.slice(t.length):e).trim()}async generate(e,t){let r=xe[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]},o={temperature:t.temperature??r.temperature,topP:t.topP??r.topP,topK:t.topK??r.topK,maxTokens:t.maxTokens??r.maxTokens,repetitionPenalty:t.repetitionPenalty??r.repetitionPenalty,stopSequences:t.stopSequences??r.stopSequences,abortSignal:t.abortSignal};if(this.config.modelType!=="language")throw new T("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw re.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u751F\u6210\u6587\u672C");let a=await this.countTokens([e]),h=await this.pipeline(e,{max_new_tokens:o.maxTokens,temperature:o.temperature,top_p:o.topP,top_k:o.topK,repetition_penalty:o.repetitionPenalty,do_sample:o.temperature>0});if(t.abortSignal?.aborted)throw re.abortError();let l=h[0]?.generated_text||"",d=this.extractAssistantResponse(l,e),p=await this.countTokens([d]);return this.config.verbose&&U.debug("\u751F\u6210\u5B8C\u6210",{completionTokens:p}),{content:d,finishReason:Hi(!0,!1),usage:{promptTokens:a,completionTokens:p,totalTokens:a+p}}}catch(a){throw this.config.verbose&&U.error("\u751F\u6210\u5931\u8D25",{error:a}),a instanceof T&&a.code==="ABORTED"?a:re.generationError(a instanceof Error?a:new Error(String(a)))}}async generateStream(e,t,s){let o=xe[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]};if(!this.isInitialized)throw new T("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="language")throw new T("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw re.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u6D41\u5F0F\u751F\u6210\u6587\u672C\uFF08\u6A21\u62DF\u6D41\u5F0F\u8F93\u51FA\uFF09");let{TextStreamer:a}=await import('@huggingface/transformers'),h=await this.pipeline(e,{max_new_tokens:t.maxTokens??o.maxTokens,temperature:t.temperature??o.temperature,top_p:t.topP??o.topP,top_k:t.topK??o.topK,repetition_penalty:t.repetitionPenalty??o.repetitionPenalty,do_sample:(t.temperature??o.temperature)>0});if(t.abortSignal?.aborted)throw re.abortError();let l=h[0]?.generated_text||"",d=this.extractAssistantResponse(l,e),p=d.split(/(\s+)/);for(let m of p){if(t.abortSignal?.aborted)throw re.abortError();m.length>0&&s({type:"text-delta",delta:m});}s({type:"text-end"});let u=await this.countTokens([e]),f=await this.countTokens([d]);s({type:"finish",finishReason:Hi(!0,!1),usage:{promptTokens:u,completionTokens:f,totalTokens:u+f}}),this.config.verbose&&U.debug("\u6D41\u5F0F\u751F\u6210\u5B8C\u6210",{promptTokens:u,completionTokens:f,totalTokens:u+f});}catch(a){throw this.config.verbose&&U.error("\u6D41\u5F0F\u751F\u6210\u5931\u8D25",{error:a}),a instanceof T&&a.code==="ABORTED"?a:(s({type:"finish",finishReason:Hi(false,true,"generation_error"),usage:{promptTokens:0,completionTokens:0,totalTokens:0}}),re.generationError(a instanceof Error?a:new Error(String(a))))}}async embed(e,t){if(!this.isInitialized)throw new T("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="embedding")throw new T("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u5D4C\u5165\u63A8\u7406","UNSUPPORTED_FEATURE");if(t?.aborted)throw re.abortError();try{this.config.verbose&&U.debug("\u5F00\u59CB\u63A8\u7406",{textCount:e.length});let s=await this.pipeline(e,{pooling:"mean",normalize:!0});if(t?.aborted)throw re.abortError();let r=[];if(s.dims&&s.dims.length===2){let[o,a]=s.dims,h=Array.from(s.data);for(let l=0;l<o;l++){let d=l*a,p=d+a;r.push(h.slice(d,p));}}else r.push(Array.from(s.data));return this.config.verbose&&U.debug("\u63A8\u7406\u5B8C\u6210",{embeddingCount:r.length}),r}catch(s){throw this.config.verbose&&U.error("\u63A8\u7406\u5931\u8D25",{error:s}),s instanceof T&&s.code==="ABORTED"?s:re.embeddingError(s instanceof Error?s:new Error(String(s)))}}async countTokens(e){if(!this.isInitialized)throw new T("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");try{let t=0;for(let s of e){let r=await this.tokenizer(s);t+=r.input_ids.data.length;}return t}catch(t){return this.config.verbose&&U.error("\u8BA1\u7B97 token \u5931\u8D25",{error:t}),e.reduce((s,r)=>s+Math.ceil(r.length/4),0)}}async dispose(){this.config.verbose&&U.debug("\u5378\u8F7D\u6A21\u578B"),this.pipeline=null,this.tokenizer=null,this.isInitialized=false,this.config.verbose&&U.debug("\u6A21\u578B\u5DF2\u5378\u8F7D");}isReady(){return this.isInitialized}};var ge=class{static validateTexts(e){if(!Array.isArray(e))throw new T("\u8F93\u5165\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new T("\u8F93\u5165\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let s=e[t];if(typeof s!="string")throw new T(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`,"INVALID_INPUT");if(s.trim().length===0)throw new T(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}static validateMessages(e){if(!Array.isArray(e))throw new T("\u6D88\u606F\u5FC5\u987B\u662F\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new T("\u6D88\u606F\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let s=e[t];if(!s||typeof s!="object")throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!s.role)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 role \u5B57\u6BB5`,"INVALID_INPUT");if(!["system","user","assistant"].includes(s.role))throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 role "${s.role}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 system\u3001user\u3001assistant`,"UNSUPPORTED_FEATURE");if(!s.content)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 content \u5B57\u6BB5`,"INVALID_INPUT");if(typeof s.content=="string"){if(s.content.trim().length===0)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}else if(Array.isArray(s.content)){if(s.content.length===0)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u6570\u7EC4\u4E3A\u7A7A`,"INVALID_INPUT");for(let r=0;r<s.content.length;r++){let o=s.content[r];if(!o||typeof o!="object")throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!o.type)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11 type \u5B57\u6BB5`,"INVALID_INPUT");if(o.type!=="text"&&o.type!=="reasoning")throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7C7B\u578B "${o.type}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 text \u548C reasoning`,"UNSUPPORTED_FEATURE");if(!("text"in o)||typeof o.text!="string")throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11\u6709\u6548\u7684 text \u5B57\u6BB5`,"INVALID_INPUT");if(o.text.trim().length===0)throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7684 text \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}else throw new T(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216\u6570\u7EC4`,"INVALID_INPUT")}}static validateGenerateOptions(e){if(e.temperature!==void 0&&(typeof e.temperature!="number"||e.temperature<0||e.temperature>2))throw new T("temperature \u5FC5\u987B\u662F 0 \u5230 2 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topP!==void 0&&(typeof e.topP!="number"||e.topP<0||e.topP>1))throw new T("topP \u5FC5\u987B\u662F 0 \u5230 1 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topK!==void 0&&(typeof e.topK!="number"||e.topK<1||!Number.isInteger(e.topK)))throw new T("topK \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.maxTokens!==void 0&&(typeof e.maxTokens!="number"||e.maxTokens<1||!Number.isInteger(e.maxTokens)))throw new T("maxTokens \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.repetitionPenalty!==void 0&&(typeof e.repetitionPenalty!="number"||e.repetitionPenalty<0))throw new T("repetitionPenalty \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6570\u5B57","INVALID_INPUT")}};var bs=class{static createReadableStream(e,t){return new ReadableStream({async start(s){if(t?.aborted){s.error(new T("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let r=false,o=()=>{r=true,s.error(new T("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};t?.addEventListener("abort",o);try{if(await e(a=>{if(!r)try{s.enqueue(a),a.isFinished&&(s.close(),t?.removeEventListener("abort",o));}catch(h){s.error(h),t?.removeEventListener("abort",o);}}),!r)try{s.enqueue({textDelta:"",isFinished:!0,finishReason:"stop"}),s.close();}catch{}}catch(a){r||s.error(a instanceof T?a:new T(`\u751F\u6210\u5931\u8D25: ${a instanceof Error?a.message:String(a)}`,"GENERATION_ERROR",a instanceof Error?a:void 0));}finally{t?.removeEventListener("abort",o);}},cancel(){}})}static async*streamToAsyncIterator(e){let t=e.getReader();try{for(;;){let{done:s,value:r}=await t.read();if(s)break;yield r;}}finally{t.releaseLock();}}};function Qa(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var _t=class{constructor(e,t,s){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=s,this.modelConfig=xe[t],!this.modelConfig)throw new T(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND")}async generate(e){return this.doGenerate(e)}async stream(e){return this.doStream(e)}convertToQwenFormat(e){let t=[];for(let s of e){let r="";switch(typeof s.content=="string"?r=s.content:Array.isArray(s.content)&&(r=s.content.filter(o=>o.type==="text").map(o=>"text"in o?o.text:"").join(`
|
|
9
|
-
`)),
|
|
4
|
+
`,a=e.lastIndexOf(o);if(a!==-1)return e.slice(a+o.length).trim();let g=`assistant
|
|
5
|
+
`,i=e.lastIndexOf(g);return i!==-1?e.slice(i+g.length).trim():(e.startsWith(t)?e.slice(t.length):e).trim()}async generate(e,t){let r=L[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]},o={temperature:t.temperature??r.temperature,topP:t.topP??r.topP,topK:t.topK??r.topK,maxTokens:t.maxTokens??r.maxTokens,repetitionPenalty:t.repetitionPenalty??r.repetitionPenalty,stopSequences:t.stopSequences??r.stopSequences,abortSignal:t.abortSignal};if(this.config.modelType!=="language")throw new s("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw T.abortError();try{this.config.verbose&&y.debug("\u5F00\u59CB\u751F\u6210\u6587\u672C");let a=await this.countTokens([e]),g=await this.pipeline(e,{max_new_tokens:o.maxTokens,temperature:o.temperature,top_p:o.topP,top_k:o.topK,repetition_penalty:o.repetitionPenalty,do_sample:o.temperature>0});if(t.abortSignal?.aborted)throw T.abortError();let i=g[0]?.generated_text||"",m=this.extractAssistantResponse(i,e),u=await this.countTokens([m]);return this.config.verbose&&y.debug("\u751F\u6210\u5B8C\u6210",{completionTokens:u}),{content:m,finishReason:B(!0,!1),usage:{promptTokens:a,completionTokens:u,totalTokens:a+u}}}catch(a){throw this.config.verbose&&y.error("\u751F\u6210\u5931\u8D25",{error:a}),a instanceof s&&a.code==="ABORTED"?a:T.generationError(a instanceof Error?a:new Error(String(a)))}}async generateStream(e,t,n){let o=L[this.config.modelId]?.defaultSettings||{temperature:.7,topP:.9,topK:40,maxTokens:2048,repetitionPenalty:1.1,stopSequences:[]};if(!this.isInitialized)throw new s("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="language")throw new s("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u6587\u672C\u751F\u6210","UNSUPPORTED_FEATURE");if(t.abortSignal?.aborted)throw T.abortError();try{this.config.verbose&&y.debug("\u5F00\u59CB\u6D41\u5F0F\u751F\u6210\u6587\u672C\uFF08\u6A21\u62DF\u6D41\u5F0F\u8F93\u51FA\uFF09");let{TextStreamer:a}=await import('@huggingface/transformers'),g=await this.pipeline(e,{max_new_tokens:t.maxTokens??o.maxTokens,temperature:t.temperature??o.temperature,top_p:t.topP??o.topP,top_k:t.topK??o.topK,repetition_penalty:t.repetitionPenalty??o.repetitionPenalty,do_sample:(t.temperature??o.temperature)>0});if(t.abortSignal?.aborted)throw T.abortError();let i=g[0]?.generated_text||"",m=this.extractAssistantResponse(i,e),u=m.split(/(\s+)/);for(let l of u){if(t.abortSignal?.aborted)throw T.abortError();l.length>0&&n({type:"text-delta",delta:l});}n({type:"text-end"});let p=await this.countTokens([e]),d=await this.countTokens([m]);n({type:"finish",finishReason:B(!0,!1),usage:{promptTokens:p,completionTokens:d,totalTokens:p+d}}),this.config.verbose&&y.debug("\u6D41\u5F0F\u751F\u6210\u5B8C\u6210",{promptTokens:p,completionTokens:d,totalTokens:p+d});}catch(a){throw this.config.verbose&&y.error("\u6D41\u5F0F\u751F\u6210\u5931\u8D25",{error:a}),a instanceof s&&a.code==="ABORTED"?a:(n({type:"finish",finishReason:B(false,true,"generation_error"),usage:{promptTokens:0,completionTokens:0,totalTokens:0}}),T.generationError(a instanceof Error?a:new Error(String(a))))}}async embed(e,t){if(!this.isInitialized)throw new s("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");if(this.config.modelType!=="embedding")throw new s("\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u5D4C\u5165\u63A8\u7406","UNSUPPORTED_FEATURE");if(t?.aborted)throw T.abortError();try{this.config.verbose&&y.debug("\u5F00\u59CB\u63A8\u7406",{textCount:e.length});let n=await this.pipeline(e,{pooling:"mean",normalize:!0});if(t?.aborted)throw T.abortError();let r=[];if(n.dims&&n.dims.length===2){let[o,a]=n.dims,g=Array.from(n.data);for(let i=0;i<o;i++){let m=i*a,u=m+a;r.push(g.slice(m,u));}}else r.push(Array.from(n.data));return this.config.verbose&&y.debug("\u63A8\u7406\u5B8C\u6210",{embeddingCount:r.length}),r}catch(n){throw this.config.verbose&&y.error("\u63A8\u7406\u5931\u8D25",{error:n}),n instanceof s&&n.code==="ABORTED"?n:T.embeddingError(n instanceof Error?n:new Error(String(n)))}}async countTokens(e){if(!this.isInitialized)throw new s("\u6A21\u578B\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u8C03\u7528 initialize() \u65B9\u6CD5","MODEL_NOT_INITIALIZED");try{let t=0;for(let n of e){let r=await this.tokenizer(n);t+=r.input_ids.data.length;}return t}catch(t){return this.config.verbose&&y.error("\u8BA1\u7B97 token \u5931\u8D25",{error:t}),e.reduce((n,r)=>n+Math.ceil(r.length/4),0)}}async dispose(){this.config.verbose&&y.debug("\u5378\u8F7D\u6A21\u578B"),this.pipeline=null,this.tokenizer=null,this.isInitialized=false,this.config.verbose&&y.debug("\u6A21\u578B\u5DF2\u5378\u8F7D");}isReady(){return this.isInitialized}};var E=class{static validateTexts(e){if(!Array.isArray(e))throw new s("\u8F93\u5165\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new s("\u8F93\u5165\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let n=e[t];if(typeof n!="string")throw new s(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`,"INVALID_INPUT");if(n.trim().length===0)throw new s(`\u8F93\u5165\u6570\u7EC4\u7D22\u5F15 ${t} \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}static validateMessages(e){if(!Array.isArray(e))throw new s("\u6D88\u606F\u5FC5\u987B\u662F\u6570\u7EC4","INVALID_INPUT");if(e.length===0)throw new s("\u6D88\u606F\u6570\u7EC4\u4E0D\u80FD\u4E3A\u7A7A","INVALID_INPUT");for(let t=0;t<e.length;t++){let n=e[t];if(!n||typeof n!="object")throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!n.role)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 role \u5B57\u6BB5`,"INVALID_INPUT");if(!["system","user","assistant"].includes(n.role))throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 role "${n.role}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 system\u3001user\u3001assistant`,"UNSUPPORTED_FEATURE");if(!n.content)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7F3A\u5C11 content \u5B57\u6BB5`,"INVALID_INPUT");if(typeof n.content=="string"){if(n.content.trim().length===0)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}else if(Array.isArray(n.content)){if(n.content.length===0)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u6570\u7EC4\u4E3A\u7A7A`,"INVALID_INPUT");for(let r=0;r<n.content.length;r++){let o=n.content[r];if(!o||typeof o!="object")throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u4E0D\u662F\u6709\u6548\u5BF9\u8C61`,"INVALID_INPUT");if(!o.type)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11 type \u5B57\u6BB5`,"INVALID_INPUT");if(o.type!=="text"&&o.type!=="reasoning")throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7C7B\u578B "${o.type}" \u4E0D\u652F\u6301\uFF0C\u53EA\u652F\u6301 text \u548C reasoning`,"UNSUPPORTED_FEATURE");if(!("text"in o)||typeof o.text!="string")throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7F3A\u5C11\u6709\u6548\u7684 text \u5B57\u6BB5`,"INVALID_INPUT");if(o.text.trim().length===0)throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content part ${r} \u7684 text \u662F\u7A7A\u5B57\u7B26\u4E32`,"INVALID_INPUT")}}else throw new s(`\u6D88\u606F\u7D22\u5F15 ${t} \u7684 content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216\u6570\u7EC4`,"INVALID_INPUT")}}static validateGenerateOptions(e){if(e.temperature!==void 0&&(typeof e.temperature!="number"||e.temperature<0||e.temperature>2))throw new s("temperature \u5FC5\u987B\u662F 0 \u5230 2 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topP!==void 0&&(typeof e.topP!="number"||e.topP<0||e.topP>1))throw new s("topP \u5FC5\u987B\u662F 0 \u5230 1 \u4E4B\u95F4\u7684\u6570\u5B57","INVALID_INPUT");if(e.topK!==void 0&&(typeof e.topK!="number"||e.topK<1||!Number.isInteger(e.topK)))throw new s("topK \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.maxTokens!==void 0&&(typeof e.maxTokens!="number"||e.maxTokens<1||!Number.isInteger(e.maxTokens)))throw new s("maxTokens \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570","INVALID_INPUT");if(e.repetitionPenalty!==void 0&&(typeof e.repetitionPenalty!="number"||e.repetitionPenalty<0))throw new s("repetitionPenalty \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6570\u5B57","INVALID_INPUT")}};var G=class{static createReadableStream(e,t){return new ReadableStream({async start(n){if(t?.aborted){n.error(new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let r=false,o=()=>{r=true,n.error(new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};t?.addEventListener("abort",o);try{if(await e(a=>{if(!r)try{n.enqueue(a),a.isFinished&&(n.close(),t?.removeEventListener("abort",o));}catch(g){n.error(g),t?.removeEventListener("abort",o);}}),!r)try{n.enqueue({textDelta:"",isFinished:!0,finishReason:"stop"}),n.close();}catch{}}catch(a){r||n.error(a instanceof s?a:new s(`\u751F\u6210\u5931\u8D25: ${a instanceof Error?a.message:String(a)}`,"GENERATION_ERROR",a instanceof Error?a:void 0));}finally{t?.removeEventListener("abort",o);}},cancel(){}})}static async*streamToAsyncIterator(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;yield r;}}finally{t.releaseLock();}}};function ae(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var v=class{constructor(e,t,n){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=n,this.modelConfig=L[t],!this.modelConfig)throw new s(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND")}async generate(e){return this.doGenerate(e)}async stream(e){return this.doStream(e)}convertToQwenFormat(e){let t=[];for(let n of e){let r="";switch(typeof n.content=="string"?r=n.content:Array.isArray(n.content)&&(r=n.content.filter(o=>o.type==="text").map(o=>"text"in o?o.text:"").join(`
|
|
6
|
+
`)),n.role){case "system":t.push(`<|im_start|>system
|
|
10
7
|
${r}<|im_end|>`);break;case "user":t.push(`<|im_start|>user
|
|
11
8
|
${r}<|im_end|>`);break;case "assistant":t.push(`<|im_start|>assistant
|
|
12
|
-
${r}<|im_end|>`);break;default:throw new
|
|
9
|
+
${r}<|im_end|>`);break;default:throw new s(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${n.role}`,"UNSUPPORTED_FEATURE")}}return t.push(`<|im_start|>assistant
|
|
13
10
|
`),t.join(`
|
|
14
|
-
`)}async doGenerate(e){
|
|
15
|
-
`),
|
|
11
|
+
`)}async doGenerate(e){E.validateMessages(e.prompt);let t=this.convertToQwenFormat(e.prompt),n={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxOutputTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};E.validateGenerateOptions(n),this.engine.isReady()||await this.engine.initialize();let r=await this.engine.generate(t,n);return {content:[{type:"text",text:r.content||""}],finishReason:r.finishReason,usage:{inputTokens:r.usage.promptTokens,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:r.usage.completionTokens,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:(r.usage.promptTokens||0)+(r.usage.completionTokens||0)},warnings:[],rawCall:{rawPrompt:t,rawSettings:n}}}async doStream(e){E.validateMessages(e.prompt);let t=this.convertToQwenFormat(e.prompt),n={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};E.validateGenerateOptions(n),this.engine.isReady()||await this.engine.initialize();let r=G.createReadableStream(async g=>{await this.engine.generateStream(t,n,i=>{if(i.type==="text-delta"){let m=i.delta||"";g({textDelta:m,isFinished:false});}else i.type==="finish"&&g({textDelta:"",isFinished:true,finishReason:i.finishReason});});},e.abortSignal),o=null;return {stream:r.pipeThrough(new TransformStream({transform(g,i){g.isFinished?(o&&(i.enqueue({type:"text-end",id:o}),o=null),i.enqueue({type:"finish",finishReason:g.finishReason||"stop",usage:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}})):g.textDelta&&(o||(o=ae(),i.enqueue({type:"text-start",id:o})),i.enqueue({type:"text-delta",id:o,delta:g.textDelta}));}})),rawCall:{rawPrompt:t,rawSettings:n}}}};var _=class f{static buildEnhancedPrompt(e,t){let n=[];n.push(f.buildSystemPrompt(t));for(let r of e){let o=f.formatMessage(r);o&&n.push(o);}return n.push(`<|im_start|>assistant
|
|
12
|
+
`),n.join(`
|
|
16
13
|
`)}static buildSystemPrompt(e){return e&&e.length>0?`<|im_start|>system
|
|
17
14
|
Environment: ipython
|
|
18
15
|
|
|
19
16
|
You have access to the following functions:
|
|
20
17
|
|
|
21
|
-
${
|
|
18
|
+
${f.formatToolsDefinition(e)}
|
|
22
19
|
|
|
23
20
|
FUNCTION CALLING INSTRUCTIONS:
|
|
24
21
|
|
|
@@ -104,26 +101,26 @@ CRITICAL OUTPUT RULES:
|
|
|
104
101
|
2. If you use <think> tags, ALWAYS use them as a COMPLETE PAIR: <think>content</think>
|
|
105
102
|
3. Your response must be clean, natural text without any formatting markers
|
|
106
103
|
4. Do NOT include any part of the conversation format in your output
|
|
107
|
-
<|im_end|>`}static formatToolsDefinition(e){return e.map(t=>{let
|
|
104
|
+
<|im_end|>`}static formatToolsDefinition(e){return e.map(t=>{let n=t.inputSchema;return JSON.stringify({name:t.name,description:t.description||"No description",parameters:n},null,2)}).join(`
|
|
108
105
|
|
|
109
|
-
`)}static formatMessage(e){let t="";if(typeof e.content=="string")t=e.content;else if(Array.isArray(e.content)){let
|
|
106
|
+
`)}static formatMessage(e){let t="";if(typeof e.content=="string")t=e.content;else if(Array.isArray(e.content)){let n=[];for(let r of e.content)if(r.type==="text")n.push("text"in r?r.text:"");else if(r.type==="tool-call"){let o={name:r.toolName,parameters:r.args||{}};n.push(JSON.stringify(o));}else if(r.type==="tool-result"){let o=r.result;n.push(typeof o=="string"?o:JSON.stringify(o));}t=n.join(`
|
|
110
107
|
`);}switch(e.role){case "system":return null;case "user":return `<|im_start|>user
|
|
111
108
|
${t}<|im_end|>`;case "assistant":return `<|im_start|>assistant
|
|
112
109
|
${t}<|im_end|>`;case "tool":return `<|im_start|>tool
|
|
113
|
-
${t}<|im_end|>`;default:{let
|
|
114
|
-
`),o=[];for(let a of r){let
|
|
115
|
-
`).trim(),{toolCalls:t,remainingText:
|
|
116
|
-
`),a=[];for(let
|
|
117
|
-
`);
|
|
118
|
-
`})),a.length=0;}r.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),r.textStarted=!1);let
|
|
119
|
-
`),r}static finishToolParsing(e,t){let
|
|
110
|
+
${t}<|im_end|>`;default:{let n=e.role;throw new s(`\u4E0D\u652F\u6301\u7684\u6D88\u606F\u89D2\u8272: ${n}`,"UNSUPPORTED_FEATURE")}}}};var O=class{static processThinkTags(e,t){let n={...e};for(;n.contentBuffer.length>0;)if(n.isInThinkTag){let r=n.contentBuffer.indexOf("</think>");if(r===-1){n.contentBuffer.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:n.contentBuffer}),n.contentBuffer="";break}if(r>0){let o=n.contentBuffer.substring(0,r);o.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:o});}t.enqueue({type:"reasoning-end",id:"reasoning-0"}),n.reasoningStarted=false,n.isInThinkTag=false,n.contentBuffer=n.contentBuffer.substring(r+8);}else {let r=n.contentBuffer.indexOf("<think>");if(r===-1){n.contentBuffer.length>0&&(n.textStarted||(n.textStarted=true,t.enqueue({type:"text-start",id:"txt-0"})),t.enqueue({type:"text-delta",id:"txt-0",delta:n.contentBuffer})),n.contentBuffer="";break}if(r>0){let o=n.contentBuffer.substring(0,r);n.textStarted||(n.textStarted=true,t.enqueue({type:"text-start",id:"txt-0"})),o.length>0&&t.enqueue({type:"text-delta",id:"txt-0",delta:o}),t.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=false;}n.isInThinkTag=true,n.contentBuffer=n.contentBuffer.substring(r+7),n.reasoningStarted||(n.reasoningStarted=true,t.enqueue({type:"reasoning-start",id:"reasoning-0"}));}return n}static finishThinkParsing(e,t){let n={...e};return n.contentBuffer.length>0?n.isInThinkTag?(n.contentBuffer.length>0&&t.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:n.contentBuffer}),n.reasoningStarted&&(t.enqueue({type:"reasoning-end",id:"reasoning-0"}),n.reasoningStarted=false)):(n.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),n.textStarted=true),n.contentBuffer.length>0&&t.enqueue({type:"text-delta",id:"txt-0",delta:n.contentBuffer}),t.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=false):(n.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=false),n.reasoningStarted&&!n.isInThinkTag&&(t.enqueue({type:"reasoning-end",id:"reasoning-0"}),n.reasoningStarted=false)),n}static removeThinkTags(e){return e.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}};function ie(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var C=class f{static extractToolCalls(e){let t=[],n=e,r=e.split(`
|
|
111
|
+
`),o=[];for(let a of r){let g=a.trim();if(!g){o.push(a);continue}try{let i=JSON.parse(g);if(i.name&&typeof i.name=="string"&&i.parameters&&typeof i.parameters=="object"){t.push({name:i.name,parameters:JSON.stringify(i.parameters)});continue}}catch{}o.push(a);}return n=o.join(`
|
|
112
|
+
`).trim(),{toolCalls:t,remainingText:n}}static processToolCalls(e,t,n){let r={...e},o=r.contentBuffer.split(`
|
|
113
|
+
`),a=[];for(let g=0;g<o.length;g++){let i=o[g];if(!i)continue;let m=i.trim();if(!m){a.push(i);continue}let u=false;try{let p=JSON.parse(m);if(p.name&&typeof p.name=="string"&&p.parameters&&typeof p.parameters=="object"){if(n&&n.length>0&&!n.some(w=>w.name===p.name)){a.push(i);continue}if(u=!0,a.length>0){let h=a.join(`
|
|
114
|
+
`);h.trim()&&(r.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),r.textStarted=!0),t.enqueue({type:"text-delta",id:"txt-0",delta:h+`
|
|
115
|
+
`})),a.length=0;}r.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),r.textStarted=!1);let d=ie(),l=JSON.stringify(p.parameters);t.enqueue({type:"tool-input-start",id:d,toolName:p.name}),t.enqueue({type:"tool-input-delta",id:d,delta:l}),t.enqueue({type:"tool-input-end",id:d}),t.enqueue({type:"tool-call",toolCallId:d,toolName:p.name,input:l}),r.completedToolCalls.push({id:d,name:p.name,parameters:l});}}catch{}u||a.push(i);}return r.contentBuffer=a.join(`
|
|
116
|
+
`),r}static finishToolParsing(e,t){let n={...e};return n.contentBuffer.trim().length>0?(n.textStarted||(t.enqueue({type:"text-start",id:"txt-0"}),n.textStarted=true),t.enqueue({type:"text-delta",id:"txt-0",delta:n.contentBuffer}),t.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=false):n.textStarted&&(t.enqueue({type:"text-end",id:"txt-0"}),n.textStarted=false),n}static removeToolCalls(e){let{remainingText:t}=f.extractToolCalls(e);return t}};function X(){return `${Date.now()}-${Math.random().toString(36).substring(2,9)}`}var U=class{constructor(e,t,n){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"defaultObjectGenerationMode","json");c(this,"supportedUrls",{});c(this,"supportsToolCalling","experimental");c(this,"supportsThinking","experimental");c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=n,this.modelConfig=L[t],!this.modelConfig)throw new s(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND")}async generate(e){return this.doGenerate(e)}async stream(e){return this.doStream(e)}async doGenerate(e){E.validateMessages(e.prompt);let t=e.tools?.filter(d=>"inputSchema"in d),n=_.buildEnhancedPrompt(e.prompt,t),r={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};E.validateGenerateOptions(r),this.engine.isReady()||await this.engine.initialize();let o=await this.engine.generate(n,r),a=O.removeThinkTags(o.content||""),{toolCalls:g,remainingText:i}=C.extractToolCalls(a),m=[];i.trim().length>0&&m.push({type:"text",text:i});for(let d of g)m.push({type:"tool-call",toolCallId:X(),toolName:d.name,input:d.parameters});let u=g.length>0?"tool-calls":o.finishReason,p=[];return {content:m,finishReason:u,usage:{inputTokens:{total:o.usage.promptTokens,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:o.usage.completionTokens,text:void 0,reasoning:void 0}},warnings:p,rawCall:{rawPrompt:n,rawSettings:r}}}async doStream(e){let t=X();E.validateMessages(e.prompt);let n=e.tools?.filter(l=>"inputSchema"in l),r=_.buildEnhancedPrompt(e.prompt,n),o={temperature:e.temperature??this.modelConfig.defaultSettings.temperature,topP:e.topP??this.modelConfig.defaultSettings.topP,topK:e.topK??this.modelConfig.defaultSettings.topK,maxTokens:e.maxTokens??this.modelConfig.defaultSettings.maxTokens,repetitionPenalty:this.modelConfig.defaultSettings.repetitionPenalty,stopSequences:this.modelConfig.defaultSettings.stopSequences,abortSignal:e.abortSignal};E.validateGenerateOptions(o),this.engine.isReady()||await this.engine.initialize();let a=null,g=null,i=l=>{a&&a.enqueue(l),g&&g.enqueue(l);},m=async()=>{try{let l={isInThinkTag:!1,reasoningStarted:!1,textStarted:!1,contentBuffer:""},h={contentBuffer:"",textStarted:!1,completedToolCalls:[]};i({type:"response-metadata",id:t,modelId:this.modelId,timestamp:new Date}),await this.engine.generateStream(r,o,w=>{if(w.type==="text-delta"){let x=w.delta||"";if(x.length===0)return;l.contentBuffer+=x;let R=O.processThinkTags(l,{enqueue:i});l.isInThinkTag=R.isInThinkTag,l.reasoningStarted=R.reasoningStarted,l.textStarted=R.textStarted,h.contentBuffer+=R.contentBuffer,l.contentBuffer="";let N=C.processToolCalls(h,{enqueue:i},n);h.contentBuffer=N.contentBuffer,h.textStarted=N.textStarted,h.completedToolCalls=N.completedToolCalls;}else if(w.type==="text-end"){let x=O.finishThinkParsing(l,{enqueue:i});l.textStarted=x.textStarted,l.reasoningStarted=x.reasoningStarted;let R=C.finishToolParsing(h,{enqueue:i});h.textStarted=R.textStarted;}else if(w.type==="finish"){let x=O.finishThinkParsing(l,{enqueue:i});l.textStarted=x.textStarted,l.reasoningStarted=x.reasoningStarted;let R=C.finishToolParsing(h,{enqueue:i});h.textStarted=R.textStarted;let N=h.completedToolCalls.length>0;i({type:"finish",finishReason:N?"tool-calls":w.finishReason,usage:w.usage?{inputTokens:{total:w.usage.promptTokens||0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:w.usage.completionTokens||0,text:void 0,reasoning:void 0}}:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}});}catch(l){i({type:"error",error:l instanceof Error?l.message:String(l)}),i({type:"finish",finishReason:"error",usage:{inputTokens:{total:0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:0,text:void 0,reasoning:void 0}}});}finally{a&&a.close(),g&&g.close();}},u=new ReadableStream({start(l){a=l;}}),p=new ReadableStream({start(l){g=l;}});m();async function*d(l){let h=l.getReader();try{for(;;){let{done:w,value:x}=await h.read();if(w)break;yield x;}}finally{h.releaseLock();}}return {stream:u,fullStream:d(p),request:{body:r},response:{headers:{}}}}};var z=class{constructor(e){c(this,"config");this.config=e;}createBatches(e){let t=[],n=this.config.batchSize;for(let r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}async processBatches(e,t,n){if(n?.aborted)throw new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let r=this.createBatches(e),o=[];for(let a=0;a<r.length;a++){if(n?.aborted)throw new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");let g=r[a];if(g){try{let i=await t(g);o.push(...i);}catch(i){throw i instanceof s&&i.code==="ABORTED"?i:new s(`\u6279\u6B21 ${a+1}/${r.length} \u5904\u7406\u5931\u8D25: ${i instanceof Error?i.message:String(i)}`,"PROCESSING_ERROR",i instanceof Error?i:void 0)}a<r.length-1&&this.config.delayBetweenBatches&&this.config.delayBetweenBatches>0&&await this.delay(this.config.delayBetweenBatches,n);}}return o}async delay(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));return}let o=setTimeout(()=>{t?.removeEventListener("abort",a),n();},e),a=()=>{clearTimeout(o),r(new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED"));};t?.addEventListener("abort",a);})}};var $=class{constructor(e,t,n){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"maxEmbeddingsPerCall");c(this,"supportsParallelCalls",false);c(this,"engine");c(this,"modelConfig");if(this.provider=e,this.modelId=t,this.engine=n,this.modelConfig=P[t],!this.modelConfig)throw new s(`\u4E0D\u652F\u6301\u7684\u6A21\u578B ID: ${t}`,"MODEL_NOT_FOUND");this.maxEmbeddingsPerCall=this.modelConfig.maxEmbeddingsPerCall;}async doEmbed(e){let{values:t,abortSignal:n}=e;if(E.validateTexts(t),n?.aborted)throw new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");this.engine.isReady()||await this.engine.initialize();let o=await new z({batchSize:this.maxEmbeddingsPerCall,delayBetweenBatches:0}).processBatches(t,async g=>{if(n?.aborted)throw new s("\u64CD\u4F5C\u5DF2\u53D6\u6D88","ABORTED");return await this.engine.embed(g,n)},n),a=await this.engine.countTokens(t);return {embeddings:o,usage:{tokens:a},warnings:[]}}};var q=class{constructor(e,t,n,r={}){c(this,"specificationVersion","v3");c(this,"provider","local");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",utils.Log.create({service:"local-model-sdk",module:"reranking-model"}));this.modelId=e,this.languageModel=new v("local",e,n),this.options={llm:this.languageModel,totalScore:r.totalScore??1,useEnhancedPrompt:true,promptLanguage:r.promptLanguage??"en"},this.log.debug("LocalRerankingModel created",{modelId:e,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(e){let{query:t,documents:n,topN:r}=e,o;Array.isArray(n)?o=n:n.type==="text"?o=n.values.map((i,m)=>({content:i,id:`doc_${m+1}`})):o=n.values;let a=r??o.length;if(o.length===0)return {ranking:[],warnings:[]};try{let i=this.buildRerankPrompt(t,o),u=(await this.languageModel.doGenerate({prompt:[{role:"user",content:[{type:"text",text:i}]}],maxOutputTokens:2048,temperature:0,topP:1,topK:1})).content.find(d=>d.type==="text")?.text||"",p=this.parseRerankResult(u,o,a);return {ranking:p.results.map(d=>({index:d.index,relevanceScore:d.score,document:d.document})),warnings:p.warnings.map(d=>({type:"other",message:d})),response:{timestamp:new Date,modelId:this.modelId}}}catch(i){return this.log.error("Reranking failed",{error:i.message}),{ranking:o.map((u,p)=>({index:p,relevanceScore:this.options.totalScore*(1-p/o.length),document:u})),warnings:[{type:"other",message:`Reranking failed, using original order: ${i.message}`}],response:{timestamp:new Date,modelId:this.modelId}}}}buildRerankPrompt(e,t){let n=t.map((r,o)=>{let a=r.id||`doc_${o+1}`,g=r.content.slice(0,300);return `${o+1}. [ID: ${a}] ${g}`}).join(`
|
|
120
117
|
|
|
121
118
|
`);if(this.options.useEnhancedPrompt)if(this.options.promptLanguage==="en"){let r=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
|
|
122
119
|
|
|
123
120
|
User query: ${e}
|
|
124
121
|
|
|
125
122
|
Documents to rank:
|
|
126
|
-
${
|
|
123
|
+
${n}
|
|
127
124
|
|
|
128
125
|
Please rank the documents according to the following requirements:
|
|
129
126
|
1. Carefully analyze the user's query intent and key information needs
|
|
@@ -140,7 +137,7 @@ Please only output the ranked document numbers separated by commas, do not inclu
|
|
|
140
137
|
\u7528\u6237\u67E5\u8BE2\uFF1A${e}
|
|
141
138
|
|
|
142
139
|
\u5F85\u6392\u5E8F\u6587\u6863\uFF1A
|
|
143
|
-
${
|
|
140
|
+
${n}
|
|
144
141
|
|
|
145
142
|
\u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
|
|
146
143
|
1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
|
|
@@ -154,16 +151,16 @@ ${s}
|
|
|
154
151
|
|
|
155
152
|
\u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}else return `\u6839\u636E\u67E5\u8BE2 "${e}" \u5BF9\u4EE5\u4E0B\u7ED3\u679C\u76F8\u5173\u6027\u8FDB\u884C\u6392\u5E8F\uFF0C\u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF08\u7528\u9017\u53F7\u5206\u9694\uFF09\uFF1A
|
|
156
153
|
|
|
157
|
-
${
|
|
154
|
+
${n}
|
|
158
155
|
|
|
159
|
-
\u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,
|
|
156
|
+
\u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,n){let r=[];try{let a=e.replaceAll(/<thinking>[\s\S]*?<\/thinking>/gi,"").replaceAll(/<think>[\s\S]*?<\/think>/gi,"").replaceAll(/<answer>[\s\S]*?<\/answer>/gi,"").trim().match(/\d+/g)?.map(l=>parseInt(l,10)-1).filter(l=>l>=0&&l<t.length)||[],g=[],i=new Set;for(let l of a)i.has(l)||(i.add(l),g.push(l));let m=[],u=new Set;for(let l of g)if(l!==void 0&&l>=0&&l<t.length&&!u.has(l)){u.add(l);let h=t[l];h&&m.push({index:l,score:this.options.totalScore*(1-m.length/g.length),document:h});}let p=new Set(g);for(let l=0;l<t.length;l++)if(!p.has(l)){let h=this.options.totalScore*.1*(1-l/t.length);m.push({index:l,score:h,document:t[l]});}let d=n?m.slice(0,n):m;return this.log.debug("Parsed rerank results",{extractedNumbers:a,uniqueIndices:g,resultCount:d.length,topK:n}),{results:d,warnings:r}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:e}),{results:t.map((g,i)=>({index:i,score:this.options.totalScore*(1-i/t.length),document:g})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};var F=class{constructor(e,t,n={}){c(this,"specificationVersion","v3");c(this,"provider");c(this,"modelId");c(this,"languageModel");c(this,"options");c(this,"log",utils.Log.create({service:"local-model-sdk",module:"llm-reranking-model"}));this.modelId=e,this.languageModel=t,this.provider=t.provider||"external",this.options={llm:t,totalScore:n.totalScore??1,useEnhancedPrompt:n.useEnhancedPrompt??false,promptLanguage:n.promptLanguage??"en",modelOptions:n.modelOptions??{temperature:.1,maxTokens:3e4}},this.log.debug("LLMRerankingModel created",{modelId:e,provider:this.provider,totalScore:this.options.totalScore,useEnhancedPrompt:this.options.useEnhancedPrompt,promptLanguage:this.options.promptLanguage});}async doRerank(e){let{query:t,documents:n,topN:r,abortSignal:o}=e,a;Array.isArray(n)?a=n:n.type==="text"?a=n.values.map((m,u)=>({content:m,id:`doc_${u+1}`})):a=n.values;let g=r??a.length;if(a.length===0)return {ranking:[],warnings:[]};try{let m=this.buildRerankPrompt(t,a),u="",p=null;for(let l=0;l<2;l++)try{if(u=await(await ai.streamText({model:this.languageModel,prompt:m,maxOutputTokens:this.options.modelOptions.maxTokens,temperature:this.options.modelOptions.temperature,abortSignal:o})).text,this.log.debug("LLM raw output",{textContent:u,textLength:u?.length,attempt:l}),u&&u.trim().length>0)break;p=new Error("LLM returned empty response");}catch(h){p=h,this.log.warn(`LLM attempt ${l+1} failed: ${p.message}`);}if(!u||u.trim().length===0)throw this.log.warn("LLM returned empty response, using fallback"),p||new Error("LLM returned empty response");let d=this.parseRerankResult(u,a,g);return {ranking:d.results.map(l=>({index:l.index,relevanceScore:l.score,document:l.document})),warnings:d.warnings.map(l=>({type:"other",message:l})),response:{timestamp:new Date,modelId:this.modelId}}}catch(m){return this.log.error("Reranking failed",{error:m.message}),{ranking:a.map((p,d)=>({index:d,relevanceScore:this.options.totalScore*(1-d/a.length),document:p})),warnings:[{type:"other",message:`Reranking failed, using original order: ${m.message}`}],response:{timestamp:new Date,modelId:this.modelId}}}}extractTextContent(e){if(typeof e=="string")return e;if(e.text!==void 0)return e.text;if(e.content&&Array.isArray(e.content)){let t=e.content.find(n=>n.type==="text");if(t?.text)return t.text}return String(e)}buildRerankPrompt(e,t){let n=t.map((r,o)=>{let a=r.id||`doc_${o+1}`,g=r.content.slice(0,300);return `${o+1}. [ID: ${a}] ${g}`}).join(`
|
|
160
157
|
|
|
161
158
|
`);if(this.options.useEnhancedPrompt)if(this.options.promptLanguage==="en"){let r=this.options.totalScore===1?"1.0":`${this.options.totalScore}`;return `You are a professional information retrieval reranking expert. Please rank the following documents according to the query.
|
|
162
159
|
|
|
163
160
|
User query: ${e}
|
|
164
161
|
|
|
165
162
|
Documents to rank:
|
|
166
|
-
${
|
|
163
|
+
${n}
|
|
167
164
|
|
|
168
165
|
Please rank the documents according to the following requirements:
|
|
169
166
|
1. Carefully analyze the user's query intent and key information needs
|
|
@@ -180,7 +177,7 @@ Please only output the ranked document numbers separated by commas, do not inclu
|
|
|
180
177
|
\u7528\u6237\u67E5\u8BE2\uFF1A${e}
|
|
181
178
|
|
|
182
179
|
\u5F85\u6392\u5E8F\u6587\u6863\uFF1A
|
|
183
|
-
${
|
|
180
|
+
${n}
|
|
184
181
|
|
|
185
182
|
\u8BF7\u6309\u7167\u4EE5\u4E0B\u8981\u6C42\u8FDB\u884C\u6392\u5E8F\uFF1A
|
|
186
183
|
1. \u4ED4\u7EC6\u5206\u6790\u7528\u6237\u67E5\u8BE2\u7684\u610F\u56FE\u548C\u5173\u952E\u4FE1\u606F\u9700\u6C42
|
|
@@ -194,6 +191,6 @@ ${s}
|
|
|
194
191
|
|
|
195
192
|
\u8BF7\u53EA\u8F93\u51FA\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF0C\u4E0D\u8981\u5305\u542B\u5176\u4ED6\u89E3\u91CA\u3002`}else return `\u6839\u636E\u67E5\u8BE2 "${e}" \u5BF9\u4EE5\u4E0B\u7ED3\u679C\u76F8\u5173\u6027\u8FDB\u884C\u6392\u5E8F\uFF0C\u8FD4\u56DE\u6392\u5E8F\u540E\u7684\u7F16\u53F7\uFF08\u7528\u9017\u53F7\u5206\u9694\uFF09\uFF1A
|
|
196
193
|
|
|
197
|
-
${
|
|
194
|
+
${n}
|
|
198
195
|
|
|
199
|
-
\u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,
|
|
196
|
+
\u8F93\u51FA\u683C\u5F0F\uFF1A1,2,3,4,5\uFF08\u6700\u76F8\u5173\u7684\u6392\u5728\u524D\u9762\uFF09`}parseRerankResult(e,t,n){let r=[];try{let o=e.match(/\d+/g)?.map(d=>parseInt(d,10)-1).filter(d=>d>=0&&d<t.length)||[],a=[],g=new Set;for(let d of o)g.has(d)||(g.add(d),a.push(d));let i=[],m=new Set;for(let d of a)if(d!==void 0&&d>=0&&d<t.length&&!m.has(d)){m.add(d);let l=t[d];l&&i.push({index:d,score:this.options.totalScore*(1-i.length/a.length),document:l});}let u=new Set(a);for(let d=0;d<t.length;d++)if(!u.has(d)){let l=this.options.totalScore*.1*(1-d/t.length);i.push({index:d,score:l,document:t[d]});}let p=n?i.slice(0,n):i;return this.log.debug("Parsed rerank results",{extractedNumbers:o,uniqueIndices:a,resultCount:p.length,topK:n}),{results:p,warnings:r}}catch(o){return this.log.error("Failed to parse rerank result",{error:o.message,text:e}),{results:t.map((g,i)=>({index:i,score:this.options.totalScore*(1-i/t.length),document:g})),warnings:[`Failed to parse rerank result: ${o.message}`]}}}};var k=utils.Log.create({service:"local-model-provider"}),ce={cacheDir:A__namespace.default.join(process.env.EASBOT_CACHE_PATH??`${A__namespace.default.join(H__namespace.homedir(),".cache","easbot")}`,"models"),verbose:false,autoUnloadTimeout:300*1e3,maxCachedModels:3,memoryWarningThreshold:1.5*1024*1024*1024,useEnhancedModel:true},K=class{constructor(e){c(this,"config");c(this,"modelCache");c(this,"engines",new Map);c(this,"modelInfo",new Map);this.config={...ce,...e},this.modelCache=new D({cacheDir:this.config.cacheDir});}languageModel(e,t){if(!L[e])throw new s(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${e}`,"MODEL_NOT_FOUND");let n=this.getOrCreateEngine(e,"language");return t?.useEnhancedModel??this.config.useEnhancedModel?(this.config.verbose&&k.debug("\u521B\u5EFA\u589E\u5F3A\u8BED\u8A00\u6A21\u578B",{modelId:e}),new U("local",e,n)):(this.config.verbose&&k.debug("\u521B\u5EFA\u57FA\u7840\u8BED\u8A00\u6A21\u578B",{modelId:e}),new v("local",e,n))}embeddingModel(e){if(!P[e])throw new s(`\u4E0D\u652F\u6301\u7684 Embedding Model ID: ${e}`,"MODEL_NOT_FOUND");let t=this.getOrCreateEngine(e,"embedding");return new $("local",e,t)}chat(e,t){return this.languageModel(e,t)}rerankingModel(e,t){if(this.config.verbose&&k.debug("\u521B\u5EFA\u91CD\u6392\u5E8F\u6A21\u578B",{modelId:e,hasExternalLlm:!!t?.llm}),t?.llm)return new F(e,t.llm,t);if(!L[e])throw new s(`\u4E0D\u652F\u6301\u7684 Language Model ID: ${e}`,"MODEL_NOT_FOUND");let n=this.getOrCreateEngine(e,"language");return new q(e,this.config,n,t)}getOrCreateEngine(e,t){let n=`${t}:${e}`;if(this.engines.has(n)){let o=this.modelInfo.get(n);return o&&(o.lastUsed=Date.now(),o.useCount++),this.config.verbose&&k.debug("\u590D\u7528\u5DF2\u52A0\u8F7D\u7684\u6A21\u578B",{engineKey:n}),this.engines.get(n)}this.engines.size>=this.config.maxCachedModels&&this.evictLeastRecentlyUsed(),this.config.verbose&&k.debug("\u521B\u5EFA\u65B0\u5F15\u64CE",{engineKey:n});let r=new V({modelId:e,modelType:t,cacheDir:this.config.cacheDir,verbose:this.config.verbose});return this.engines.set(n,r),this.modelInfo.set(n,{modelId:e,modelType:t,isLoaded:false,lastUsed:Date.now(),useCount:1}),r}evictLeastRecentlyUsed(){let e=null,t=Number.POSITIVE_INFINITY;for(let[n,r]of this.modelInfo.entries())r.lastUsed<t&&(t=r.lastUsed,e=n);if(e){this.config.verbose&&k.debug("\u6DD8\u6C70\u6A21\u578B",{engineKey:e});let n=this.engines.get(e);n&&n.dispose().catch(r=>{k.error("\u5378\u8F7D\u6A21\u578B\u5931\u8D25",{error:r});}),this.engines.delete(e),this.modelInfo.delete(e);}}getLoadedModels(){return Array.from(this.modelInfo.values())}async dispose(){this.config.verbose&&k.debug("\u5378\u8F7D\u6240\u6709\u6A21\u578B");let e=Array.from(this.engines.values()).map(t=>t.dispose());await Promise.all(e),this.engines.clear(),this.modelInfo.clear(),this.config.verbose&&k.debug("\u6240\u6709\u6A21\u578B\u5DF2\u5378\u8F7D");}};function ue(f){let e=new K(f);return Object.assign((n,r)=>e.languageModel(n,r),{languageModel:(n,r)=>e.languageModel(n,r),chat:(n,r)=>e.chat(n,r),embeddingModel:n=>e.embeddingModel(n),rerankingModel:(n,r)=>e.rerankingModel(n,r)})}var me="0.1.0",pe="@easbot/local-model-sdk",fe="Complete local model SDK for EASBot - Transformers.js + ONNX implementation";exports.ErrorCode=M;exports.ErrorHandler=T;exports.LLMRerankingModel=F;exports.LocalEmbeddingModel=$;exports.LocalEnhancedLanguageModel=U;exports.LocalLanguageModel=v;exports.LocalModelError=s;exports.LocalModelProvider=K;exports.LocalRerankingModel=q;exports.SDK_DESCRIPTION=fe;exports.SDK_NAME=pe;exports.SUPPORTED_EMBEDDING_MODELS=P;exports.SUPPORTED_LANGUAGE_MODELS=L;exports.VERSION=me;exports.createLocal=ue;
|