@easbot/llm 0.3.28 → 0.3.32
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/README.en.md +723 -23
- package/README.md +750 -22
- package/dist/assets/txt/agent/generate.txt +75 -0
- package/dist/assets/txt/agent/prompt/explore.txt +37 -0
- package/dist/assets/txt/agent/prompt/summary.txt +12 -0
- package/dist/assets/txt/agent/prompt/title.txt +24 -0
- package/dist/assets/txt/model/evaluation/templates/completeness.txt +53 -0
- package/dist/assets/txt/model/evaluation/templates/consistency.txt +52 -0
- package/dist/assets/txt/model/evaluation/templates/content-quality.txt +72 -0
- package/dist/assets/txt/model/evaluation/templates/context-relevancy.txt +45 -0
- package/dist/assets/txt/model/evaluation/templates/correctness.txt +43 -0
- package/dist/assets/txt/model/evaluation/templates/fact-checking.txt +43 -0
- package/dist/assets/txt/model/evaluation/templates/faithfulness.txt +53 -0
- package/dist/assets/txt/model/evaluation/templates/goal-completion.txt +70 -0
- package/dist/assets/txt/model/evaluation/templates/moderation.txt +80 -0
- package/dist/assets/txt/model/evaluation/templates/readability.txt +52 -0
- package/dist/assets/txt/model/evaluation/templates/relevancy.txt +56 -0
- package/dist/assets/txt/model/graph-summary.txt +5 -0
- package/dist/assets/txt/model/knowledge-summary.txt +127 -66
- package/dist/assets/txt/model/memory-summary.txt +136 -65
- package/dist/assets/txt/tool/buildin/edit.txt +10 -0
- package/dist/assets/txt/tool/buildin/glob.txt +42 -0
- package/dist/assets/txt/tool/buildin/grep.txt +42 -0
- package/dist/assets/txt/tool/buildin/read.txt +14 -0
- package/dist/assets/txt/tool/buildin/todo.txt +117 -0
- package/dist/assets/txt/tool/buildin/webfetch.txt +13 -0
- package/dist/assets/txt/tool/buildin/websearch.txt +14 -0
- package/dist/assets/txt/tool/buildin/write.txt +9 -0
- package/dist/chunks/chunk-A6QGPYPS.mjs +10 -0
- package/dist/chunks/chunk-IDJUGUEI.cjs +11 -0
- package/dist/chunks/chunk-JIETUZVR.mjs +2 -0
- package/dist/chunks/chunk-K4ES4MUO.cjs +1 -0
- package/dist/chunks/chunk-KNR62LEG.cjs +1 -0
- package/dist/chunks/chunk-M7AHHCVC.cjs +10 -0
- package/dist/chunks/chunk-NX2YVB72.mjs +1 -0
- package/dist/chunks/chunk-QMTIXJ7U.mjs +1 -0
- package/dist/chunks/chunk-R2HXV27D.mjs +2 -0
- package/dist/chunks/chunk-UJYQQ347.cjs +2 -0
- package/dist/chunks/chunk-XDYRNUT7.cjs +2 -0
- package/dist/chunks/chunk-YUX6P6YF.mjs +11 -0
- package/dist/chunks/{copilot-TJATIV2S.mjs → copilot-7CO2EO6N.mjs} +1 -1
- package/dist/chunks/copilot-PO46XRII.cjs +1 -0
- package/dist/chunks/index.min-DHJMPYRN.mjs +4 -0
- package/dist/chunks/index.min-SKM4353Q.cjs +4 -0
- package/dist/chunks/interfaces-H2WJRP6U.cjs +1 -0
- package/dist/chunks/interfaces-U2BBKCET.mjs +1 -0
- package/dist/chunks/loader-ON5XTSUI.cjs +1 -0
- package/dist/chunks/loader-WKTUO2AN.mjs +1 -0
- package/dist/chunks/localagent-PNWC6EGM.mjs +1 -0
- package/dist/chunks/localagent-QBKNVXRX.cjs +1 -0
- package/dist/chunks/models-snapshot-CNQITMJ7.cjs +2 -0
- package/dist/chunks/models-snapshot-XYP5QXSS.mjs +2 -0
- package/dist/chunks/subagent-K4THD4HO.cjs +1 -0
- package/dist/chunks/subagent-OVNTI7J4.mjs +1 -0
- package/dist/index.cjs +144 -31
- package/dist/index.d.cts +8871 -527
- package/dist/index.d.ts +8871 -527
- package/dist/index.mjs +144 -31
- package/package.json +10 -7
- package/dist/chunks/chunk-3BANRW36.mjs +0 -2
- package/dist/chunks/chunk-KFESJR3T.cjs +0 -1
- package/dist/chunks/chunk-S4DPVKMV.mjs +0 -1
- package/dist/chunks/chunk-UIFIYRZK.cjs +0 -2
- package/dist/chunks/copilot-R22QW5MH.cjs +0 -1
- package/dist/chunks/models-snapshot-3EXCDFMS.mjs +0 -2
- package/dist/chunks/models-snapshot-L4WLMITS.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkK4ES4MUO_cjs=require('./chunk-K4ES4MUO.cjs'),providerUtils=require('@ai-sdk/provider-utils'),utils=require('@easbot/utils'),provider=require('@ai-sdk/provider'),zod=require('zod'),v4=require('zod/v4');function D(n){return n?.providerOptions?.copilot??{}}function oe(n){let r=[];for(let{role:b,content:_,...k}of n){let h=D({...k});switch(b){case "system":{r.push({role:"system",content:_,...h});break}case "user":{let p=_[0];if(_.length===1&&p?.type==="text"){r.push({role:"user",content:p.text,...D(p)});break}r.push({role:"user",content:_.map(i=>{let d=D(i);switch(i.type){case "text":return {type:"text",text:i.text,...d};case "file":if(i.mediaType.startsWith("image/")){let m=i.mediaType==="image/*"?"image/jpeg":i.mediaType;return {type:"image_url",image_url:{url:i.data instanceof URL?i.data.toString():`data:${m};base64,${providerUtils.convertToBase64(i.data)}`},...d}}else throw new provider.UnsupportedFunctionalityError({functionality:`file part media type ${i.mediaType}`});default:throw new provider.UnsupportedFunctionalityError({functionality:`part type ${i.type}`})}}),...h});break}case "assistant":{let p="",i,d,m=[];for(let o of _){let C=D(o),u=o.providerOptions?.copilot?.reasoningOpaque;switch(u&&!d&&(d=u),o.type){case "text":{p+=o.text;break}case "reasoning":{o.text&&(i=o.text);break}case "tool-call":{m.push({id:o.toolCallId,type:"function",function:{name:o.toolName,arguments:JSON.stringify(o.input)},...C});break}}}r.push({role:"assistant",content:p||null,tool_calls:m.length>0?m:void 0,reasoning_text:d?i:void 0,reasoning_opaque:d,...h});break}case "tool":{for(let p of _){if(p.type==="tool-approval-response")continue;let i=p.output,d;switch(i.type){case "text":case "error-text":d=i.value;break;case "execution-denied":d=i.reason??"Tool execution denied.";break;case "content":case "json":case "error-json":d=JSON.stringify(i.value);break;default:{d=String(i.value);break}}let m=D(p);r.push({role:"tool",tool_call_id:p.toolCallId,content:d,...m});}break}default:{let p=b;throw new utils.NameErrors.OperationFailedError({message:`Unsupported role: ${String(p)}`,operation:"chat-convert-unsupported-role"})}}}return r}function V({id:n,model:r,created:b}){return {id:n??void 0,modelId:r??void 0,timestamp:b!=null?new Date(b*1e3):void 0}}function B(n){switch(n){case "stop":return {unified:"stop",raw:n||void 0};case "length":return {unified:"length",raw:n||void 0};case "content_filter":return {unified:"content-filter",raw:n||void 0};case "function_call":case "tool_calls":return {unified:"tool-calls",raw:n||void 0};default:return {unified:"other",raw:n||void 0}}}var U=zod.z.object({user:zod.z.string().optional(),reasoningEffort:zod.z.string().optional(),textVerbosity:zod.z.string().optional(),thinking_budget:zod.z.number().optional()});var We=v4.z.object({error:v4.z.object({message:v4.z.string(),type:v4.z.string().nullish(),param:v4.z.any().nullish(),code:v4.z.union([v4.z.string(),v4.z.number()]).nullish()})}),ie={errorSchema:We,errorToMessage:n=>n.error.message};function ae({tools:n,toolChoice:r}){n=(n?.length??0)>0?n:void 0;let b=[];if(n==null)return {tools:void 0,toolChoice:void 0,toolWarnings:b};let _=[];for(let h of n)h.type==="provider"?b.push({type:"unsupported",feature:h.name||"unknown-tool"}):_.push({type:"function",function:{name:h.name,description:h.description,parameters:h.inputSchema}});if(r==null)return {tools:_,toolChoice:void 0,toolWarnings:b};let k=r.type;switch(k){case "auto":case "none":case "required":return {tools:_,toolChoice:k,toolWarnings:b};case "tool":return {tools:_,toolChoice:{type:"function",function:{name:r.toolName}},toolWarnings:b};default:{let h=k;throw new provider.UnsupportedFunctionalityError({functionality:`tool choice type: ${h}`})}}}var H=class{constructor(r,b){chunkK4ES4MUO_cjs.a(this,"specificationVersion","v3");chunkK4ES4MUO_cjs.a(this,"supportsStructuredOutputs");chunkK4ES4MUO_cjs.a(this,"modelId");chunkK4ES4MUO_cjs.a(this,"config");chunkK4ES4MUO_cjs.a(this,"failedResponseHandler");chunkK4ES4MUO_cjs.a(this,"chunkSchema");this.modelId=r,this.config=b;let _=b.errorStructure??ie;this.chunkSchema=Ge(_.errorSchema),this.failedResponseHandler=providerUtils.createJsonErrorResponseHandler(_),this.supportsStructuredOutputs=b.supportsStructuredOutputs??false;}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0]?.trim()??"openai"}get supportedUrls(){return this.config.supportedUrls?.()??{}}async getArgs({prompt:r,maxOutputTokens:b,temperature:_,topP:k,topK:h,frequencyPenalty:p,presencePenalty:i,providerOptions:d,stopSequences:m,responseFormat:o,seed:C,toolChoice:u,tools:a}){let s=[],c=Object.assign(await providerUtils.parseProviderOptions({provider:"copilot",providerOptions:d,schema:U})??{},await providerUtils.parseProviderOptions({provider:this.providerOptionsName,providerOptions:d,schema:U})??{});h!=null&&s.push({type:"unsupported",feature:"topK"}),o?.type==="json"&&o.schema!=null&&!this.supportsStructuredOutputs&&s.push({type:"unsupported",feature:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});let{tools:g,toolChoice:I,toolWarnings:l}=ae({tools:a,toolChoice:u});return {args:{model:this.modelId,user:c.user,max_tokens:b,temperature:_,top_p:k,frequency_penalty:p,presence_penalty:i,response_format:o?.type==="json"?this.supportsStructuredOutputs===true&&o.schema!=null?{type:"json_schema",json_schema:{schema:o.schema,name:o.name??"response",description:o.description}}:{type:"json_object"}:void 0,stop:m,seed:C,...Object.fromEntries(Object.entries(d?.[this.providerOptionsName]??{}).filter(([t])=>!Object.keys(U.shape).includes(t))),reasoning_effort:c.reasoningEffort,verbosity:c.textVerbosity,messages:oe(r),tools:g,tool_choice:I,thinking_budget:c.thinking_budget},warnings:[...s,...l]}}async doGenerate(r){let{args:b,warnings:_}=await this.getArgs({...r}),k=JSON.stringify(b),{responseHeaders:h,value:p,rawValue:i}=await providerUtils.postJsonToApi({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:providerUtils.combineHeaders(this.config.headers(),r.headers),body:b,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:providerUtils.createJsonResponseHandler(Je),abortSignal:r.abortSignal,fetch:this.config.fetch}),d=p.choices?.[0];if(!d)return {content:[],finishReason:{unified:"error",raw:void 0},usage:{inputTokens:{total:p.usage?.prompt_tokens??void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:p.usage?.completion_tokens??void 0,text:p.usage?.completion_tokens??void 0,reasoning:void 0}},providerMetadata:{},request:{body:k},response:{...V(p),headers:h,body:i},warnings:_};let m=[],o=d.message.content;o!=null&&o.length>0&&m.push({type:"text",text:o,providerMetadata:d.message.reasoning_opaque?{copilot:{reasoningOpaque:d.message.reasoning_opaque}}:void 0});let C=d.message.reasoning_text;if(C!=null&&C.length>0&&m.push({type:"reasoning",text:C,providerMetadata:d.message.reasoning_opaque?{copilot:{reasoningOpaque:d.message.reasoning_opaque}}:void 0}),d.message.tool_calls!=null)for(let s of d.message.tool_calls)m.push({type:"tool-call",toolCallId:s.id??providerUtils.generateId(),toolName:s.function.name,input:s.function.arguments,providerMetadata:d.message.reasoning_opaque?{copilot:{reasoningOpaque:d.message.reasoning_opaque}}:void 0});let u={[this.providerOptionsName]:{},...await this.config.metadataExtractor?.extractMetadata?.({parsedBody:i})},a=p.usage?.completion_tokens_details;if(a?.accepted_prediction_tokens!=null){let s=this.providerOptionsName;u[s]&&(u[s].acceptedPredictionTokens=a?.accepted_prediction_tokens);}if(a?.rejected_prediction_tokens!=null){let s=this.providerOptionsName;u[s]&&(u[s].rejectedPredictionTokens=a?.rejected_prediction_tokens);}return {content:m,finishReason:B(d?.finish_reason),usage:{inputTokens:{total:p.usage?.prompt_tokens??void 0,noCache:void 0,cacheRead:p.usage?.prompt_tokens_details?.cached_tokens??void 0,cacheWrite:void 0},outputTokens:{total:p.usage?.completion_tokens??void 0,text:void 0,reasoning:p.usage?.completion_tokens_details?.reasoning_tokens??void 0},raw:p.usage??void 0},providerMetadata:u,request:{body:k},response:{...V(p),headers:h,body:i},warnings:_}}async doStream(r){let{args:b,warnings:_}=await this.getArgs({...r}),k={...b,stream:true,stream_options:this.config.includeUsage?{include_usage:true}:void 0},h=this.config.metadataExtractor?.createStreamExtractor(),{responseHeaders:p,value:i}=await providerUtils.postJsonToApi({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:providerUtils.combineHeaders(this.config.headers(),r.headers),body:k,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:providerUtils.createEventSourceResponseHandler(this.chunkSchema),abortSignal:r.abortSignal,fetch:this.config.fetch}),d=[],m={unified:"other",raw:void 0},o={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0},C=true,u=this.providerOptionsName,a=false,s=false,c;return {stream:i.pipeThrough(new TransformStream({start(g){g.enqueue({type:"stream-start",warnings:_});},transform(g,I){if(r.includeRawChunks&&I.enqueue({type:"raw",rawValue:g.rawValue}),!g.success){m={unified:"error",raw:void 0},I.enqueue({type:"error",error:g.error});return}let l=g.value;if(h?.processChunk(g.rawValue),"error"in l){m={unified:"error",raw:void 0},I.enqueue({type:"error",error:l.error.message});return}if(C&&(C=false,I.enqueue({type:"response-metadata",...V(l)})),l.usage!=null){let{prompt_tokens:w,completion_tokens:q,total_tokens:T,prompt_tokens_details:v,completion_tokens_details:N}=l.usage;o.promptTokens=w??void 0,o.completionTokens=q??void 0,o.totalTokens=T??void 0,N?.reasoning_tokens!=null&&(o.completionTokensDetails.reasoningTokens=N?.reasoning_tokens),N?.accepted_prediction_tokens!=null&&(o.completionTokensDetails.acceptedPredictionTokens=N?.accepted_prediction_tokens),N?.rejected_prediction_tokens!=null&&(o.completionTokensDetails.rejectedPredictionTokens=N?.rejected_prediction_tokens),v?.cached_tokens!=null&&(o.promptTokensDetails.cachedTokens=v?.cached_tokens);}let t=l.choices[0];if(t?.finish_reason!=null&&(m=B(t.finish_reason)),t?.delta==null)return;let y=t.delta;if(y.reasoning_opaque){if(c!=null)throw new provider.InvalidResponseDataError({data:y,message:"Multiple reasoning_opaque values received in a single response. Only one thinking part per response is supported."});c=y.reasoning_opaque;}let L=y.reasoning_text;if(L&&(a||(I.enqueue({type:"reasoning-start",id:"reasoning-0"}),a=true),I.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:L})),y.content&&(a&&!s&&(I.enqueue({type:"reasoning-end",id:"reasoning-0",providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),a=false),s||(I.enqueue({type:"text-start",id:"txt-0",providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),s=true),I.enqueue({type:"text-delta",id:"txt-0",delta:y.content})),y.tool_calls!=null){a&&(I.enqueue({type:"reasoning-end",id:"reasoning-0",providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),a=false);for(let w of y.tool_calls){let q=w.index;if(d[q]==null){if(w.id==null)throw new provider.InvalidResponseDataError({data:w,message:"Expected 'id' to be a string."});if(w.function?.name==null)throw new provider.InvalidResponseDataError({data:w,message:"Expected 'function.name' to be a string."});I.enqueue({type:"tool-input-start",id:w.id,toolName:w.function.name}),d[q]={id:w.id,type:"function",function:{name:w.function.name,arguments:w.function.arguments??""},hasFinished:false};let v=d[q];v.function?.name!=null&&v.function?.arguments!=null&&(v.function.arguments.length>0&&I.enqueue({type:"tool-input-delta",id:v.id,delta:v.function.arguments}),providerUtils.isParsableJson(v.function.arguments)&&(I.enqueue({type:"tool-input-end",id:v.id}),I.enqueue({type:"tool-call",toolCallId:v.id??providerUtils.generateId(),toolName:v.function.name,input:v.function.arguments,providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),v.hasFinished=true));continue}let T=d[q];T.hasFinished||(w.function?.arguments!=null&&(T.function.arguments+=w.function?.arguments??""),I.enqueue({type:"tool-input-delta",id:T.id,delta:w.function.arguments??""}),T.function?.name!=null&&T.function?.arguments!=null&&providerUtils.isParsableJson(T.function.arguments)&&(I.enqueue({type:"tool-input-end",id:T.id}),I.enqueue({type:"tool-call",toolCallId:T.id??providerUtils.generateId(),toolName:T.function.name,input:T.function.arguments,providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),T.hasFinished=true));}}},flush(g){a&&g.enqueue({type:"reasoning-end",id:"reasoning-0",providerMetadata:c?{copilot:{reasoningOpaque:c}}:void 0}),s&&g.enqueue({type:"text-end",id:"txt-0"});for(let l of d.filter(t=>!t.hasFinished))g.enqueue({type:"tool-input-end",id:l.id}),g.enqueue({type:"tool-call",toolCallId:l.id??providerUtils.generateId(),toolName:l.function.name,input:l.function.arguments});let I={[u]:{},...c?{copilot:{reasoningOpaque:c}}:{},...h?.buildMetadata()};o.completionTokensDetails.acceptedPredictionTokens!=null&&I[u]&&(I[u].acceptedPredictionTokens=o.completionTokensDetails.acceptedPredictionTokens),o.completionTokensDetails.rejectedPredictionTokens!=null&&I[u]&&(I[u].rejectedPredictionTokens=o.completionTokensDetails.rejectedPredictionTokens),g.enqueue({type:"finish",finishReason:m,usage:{inputTokens:{total:o.promptTokens,noCache:o.promptTokens!==void 0&&o.promptTokensDetails.cachedTokens!==void 0?o.promptTokens-o.promptTokensDetails.cachedTokens:void 0,cacheRead:o.promptTokensDetails.cachedTokens,cacheWrite:void 0},outputTokens:{total:o.completionTokens,text:void 0,reasoning:o.completionTokensDetails.reasoningTokens},raw:{prompt_tokens:o.promptTokens??null,completion_tokens:o.completionTokens??null,total_tokens:o.totalTokens??null}},providerMetadata:I});}})),request:{body:k},response:{headers:p}}}},ue=zod.z.object({prompt_tokens:zod.z.number().nullish(),completion_tokens:zod.z.number().nullish(),total_tokens:zod.z.number().nullish(),prompt_tokens_details:zod.z.object({cached_tokens:zod.z.number().nullish()}).nullish(),completion_tokens_details:zod.z.object({reasoning_tokens:zod.z.number().nullish(),accepted_prediction_tokens:zod.z.number().nullish(),rejected_prediction_tokens:zod.z.number().nullish()}).nullish()}).nullish(),Je=zod.z.object({id:zod.z.string().nullish(),created:zod.z.number().nullish(),model:zod.z.string().nullish(),choices:zod.z.array(zod.z.object({message:zod.z.object({role:zod.z.literal("assistant").nullish(),content:zod.z.string().nullish(),reasoning_text:zod.z.string().nullish(),reasoning_opaque:zod.z.string().nullish(),tool_calls:zod.z.array(zod.z.object({id:zod.z.string().nullish(),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})).nullish()}),finish_reason:zod.z.string().nullish()})),usage:ue}),Ge=n=>zod.z.union([zod.z.object({id:zod.z.string().nullish(),created:zod.z.number().nullish(),model:zod.z.string().nullish(),choices:zod.z.array(zod.z.object({delta:zod.z.object({role:zod.z.enum(["assistant"]).nullish(),content:zod.z.string().nullish(),reasoning_text:zod.z.string().nullish(),reasoning_opaque:zod.z.string().nullish(),tool_calls:zod.z.array(zod.z.object({index:zod.z.number(),id:zod.z.string().nullish(),function:zod.z.object({name:zod.z.string().nullish(),arguments:zod.z.string().nullish()})})).nullish()}).nullish(),finish_reason:zod.z.string().nullish()})),usage:ue}),n]);var Ke=zod.z.object({error:zod.z.object({message:zod.z.string(),type:zod.z.string().nullish(),param:zod.z.any().nullish(),code:zod.z.union([zod.z.string(),zod.z.number()]).nullish()})}),Z=providerUtils.createJsonErrorResponseHandler({errorSchema:Ke,errorToMessage:n=>n.error.message});var Xe=zod.z.object({code:zod.z.string().nullish(),containerId:zod.z.string()}),Qe=zod.z.object({outputs:zod.z.array(zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("logs"),logs:zod.z.string()}),zod.z.object({type:zod.z.literal("image"),url:zod.z.string()})])).nullish()}),de=zod.z.object({container:zod.z.union([zod.z.string(),zod.z.object({fileIds:zod.z.array(zod.z.string()).optional()})]).optional()});providerUtils.createProviderToolFactoryWithOutputSchema({id:"openai.code_interpreter",inputSchema:Xe,outputSchema:Qe});var ce=zod.z.object({key:zod.z.string(),type:zod.z.enum(["eq","ne","gt","gte","lt","lte"]),value:zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean()])}),me=zod.z.object({type:zod.z.enum(["and","or"]),filters:zod.z.array(zod.z.union([ce,zod.z.lazy(()=>me)]))}),ge=zod.z.object({vectorStoreIds:zod.z.array(zod.z.string()),maxNumResults:zod.z.number().optional(),ranking:zod.z.object({ranker:zod.z.string().optional(),scoreThreshold:zod.z.number().optional()}).optional(),filters:zod.z.union([ce,me]).optional()}),et=zod.z.object({queries:zod.z.array(zod.z.string()),results:zod.z.array(zod.z.object({attributes:zod.z.record(zod.z.string(),zod.z.unknown()),fileId:zod.z.string(),filename:zod.z.string(),score:zod.z.number(),text:zod.z.string()})).nullable()});providerUtils.createProviderToolFactoryWithOutputSchema({id:"openai.file_search",inputSchema:zod.z.object({}),outputSchema:et});var fe=zod.z.object({background:zod.z.enum(["auto","opaque","transparent"]).optional(),inputFidelity:zod.z.enum(["low","high"]).optional(),inputImageMask:zod.z.object({fileId:zod.z.string().optional(),imageUrl:zod.z.string().optional()}).optional(),model:zod.z.string().optional(),moderation:zod.z.enum(["auto"]).optional(),outputCompression:zod.z.number().int().min(0).max(100).optional(),outputFormat:zod.z.enum(["png","jpeg","webp"]).optional(),partialImages:zod.z.number().int().min(0).max(3).optional(),quality:zod.z.enum(["auto","low","medium","high"]).optional(),size:zod.z.enum(["1024x1024","1024x1536","1536x1024","auto"]).optional()}).strict(),nt=zod.z.object({result:zod.z.string()});providerUtils.createProviderToolFactoryWithOutputSchema({id:"openai.image_generation",inputSchema:zod.z.object({}),outputSchema:nt});var X=zod.z.object({action:zod.z.object({type:zod.z.literal("exec"),command:zod.z.array(zod.z.string()),timeoutMs:zod.z.number().optional(),user:zod.z.string().optional(),workingDirectory:zod.z.string().optional(),env:zod.z.record(zod.z.string(),zod.z.string()).optional()})}),Q=zod.z.object({output:zod.z.string()});providerUtils.createProviderToolFactoryWithOutputSchema({id:"openai.local_shell",inputSchema:X,outputSchema:Q});function be(n,r){return r?r.some(b=>n.startsWith(b)):false}async function Ce({prompt:n,systemMessageMode:r,fileIdPrefixes:b,store:_,hasLocalShellTool:k=false}){let h=[],p=[],i=new Set;for(let{role:d,content:m}of n)switch(d){case "system":{switch(r){case "system":{h.push({role:"system",content:m});break}case "developer":{h.push({role:"developer",content:m});break}case "remove":{p.push({type:"other",message:"system messages are removed for this model"});break}default:{let o=r;throw new utils.NameErrors.OperationFailedError({message:`Unsupported system message mode: ${String(o)}`,operation:"responses-convert-unsupported-system-mode"})}}break}case "user":{h.push({role:"user",content:m.map((o,C)=>{switch(o.type){case "text":return {type:"input_text",text:o.text};case "file":if(o.mediaType.startsWith("image/")){let u=o.mediaType==="image/*"?"image/jpeg":o.mediaType;return {type:"input_image",...o.data instanceof URL?{image_url:o.data.toString()}:typeof o.data=="string"&&be(o.data,b)?{file_id:o.data}:{image_url:`data:${u};base64,${providerUtils.convertToBase64(o.data)}`},detail:o.providerOptions?.openai?.imageDetail}}else {if(o.mediaType==="application/pdf")return o.data instanceof URL?{type:"input_file",file_url:o.data.toString()}:{type:"input_file",...typeof o.data=="string"&&be(o.data,b)?{file_id:o.data}:{filename:o.filename??`part-${C}.pdf`,file_data:`data:application/pdf;base64,${providerUtils.convertToBase64(o.data)}`}};throw new provider.UnsupportedFunctionalityError({functionality:`file part media type ${o.mediaType}`})}default:throw new provider.UnsupportedFunctionalityError({functionality:`part type ${o.type}`})}})});break}case "assistant":{let o={},C={};for(let u of m)switch(u.type){case "text":{h.push({role:"assistant",content:[{type:"output_text",text:u.text}],id:u.providerOptions?.openai?.itemId??void 0});break}case "tool-call":{if(C[u.toolCallId]=u,u.providerExecuted)break;if(k&&u.toolName==="local_shell"){let a=X.parse(u.input);h.push({type:"local_shell_call",call_id:u.toolCallId,id:u.providerOptions?.openai?.itemId??void 0,action:{type:"exec",command:a.action.command,timeout_ms:a.action.timeoutMs,user:a.action.user,working_directory:a.action.workingDirectory,env:a.action.env}});break}h.push({type:"function_call",call_id:u.toolCallId,name:u.toolName,arguments:JSON.stringify(u.input),id:u.providerOptions?.openai?.itemId??void 0});break}case "tool-result":{_?h.push({type:"item_reference",id:u.toolCallId}):p.push({type:"other",message:`Results for OpenAI tool ${u.toolName} are not sent to the API when store is false`});break}case "reasoning":{let a=await providerUtils.parseProviderOptions({provider:"copilot",providerOptions:u.providerOptions,schema:at}),s=a?.itemId;if(s!=null){let c=o[s];if(_)c===void 0&&(h.push({type:"item_reference",id:s}),o[s]={type:"reasoning",id:s,summary:[]});else {let g=[];u.text.length>0?g.push({type:"summary_text",text:u.text}):c!==void 0&&p.push({type:"other",message:`Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(u)}.`}),c===void 0?(o[s]={type:"reasoning",id:s,encrypted_content:a?.reasoningEncryptedContent,summary:g},h.push(o[s])):c.summary.push(...g);}}else p.push({type:"other",message:`Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(u)}.`});break}}break}case "tool":{for(let o of m){if(o.type==="tool-approval-response"){if(i.has(o.approvalId))continue;i.add(o.approvalId),_&&h.push({type:"item_reference",id:o.approvalId}),h.push({type:"mcp_approval_response",approval_request_id:o.approvalId,approve:o.approved});continue}let C=o.output;if(C.type==="execution-denied"&&C.providerOptions?.openai?.approvalId)continue;if(k&&o.toolName==="local_shell"&&C.type==="json"){h.push({type:"local_shell_call_output",call_id:o.toolCallId,output:Q.parse(o.output.value).output});break}let u="";switch(C.type){case "text":case "error-text":u=C.value;break;case "execution-denied":u=C.reason??"Tool execution denied.";break;case "content":case "json":case "error-json":u=JSON.stringify(C.value);break}h.push({type:"function_call_output",call_id:o.toolCallId,output:u});}break}default:{let o=d;throw new utils.NameErrors.OperationFailedError({message:`Unsupported role: ${String(o)}`,operation:"responses-convert-unsupported-role"})}}return {input:h,warnings:p}}var at=zod.z.object({itemId:zod.z.string().nullish(),reasoningEncryptedContent:zod.z.string().nullish()});function ee({finishReason:n,hasFunctionCall:r}){switch(n){case void 0:case null:return {unified:r?"tool-calls":"stop",raw:n||void 0};case "max_output_tokens":return {unified:"length",raw:n};case "content_filter":return {unified:"content-filter",raw:n};default:return {unified:r?"tool-calls":"other",raw:n}}}var ke=zod.z.object({filters:zod.z.object({allowedDomains:zod.z.array(zod.z.string()).optional()}).optional(),searchContextSize:zod.z.enum(["low","medium","high"]).optional(),userLocation:zod.z.object({type:zod.z.literal("approximate"),country:zod.z.string().optional(),city:zod.z.string().optional(),region:zod.z.string().optional(),timezone:zod.z.string().optional()}).optional()});providerUtils.createProviderToolFactory({id:"openai.web_search",inputSchema:zod.z.object({action:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("search"),query:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("open_page"),url:zod.z.string()}),zod.z.object({type:zod.z.literal("find"),url:zod.z.string(),pattern:zod.z.string()})]).nullish()})});var Ie=zod.z.object({searchContextSize:zod.z.enum(["low","medium","high"]).optional(),userLocation:zod.z.object({type:zod.z.literal("approximate"),country:zod.z.string().optional(),city:zod.z.string().optional(),region:zod.z.string().optional(),timezone:zod.z.string().optional()}).optional()});providerUtils.createProviderToolFactory({id:"openai.web_search_preview",inputSchema:zod.z.object({action:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("search"),query:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("open_page"),url:zod.z.string()}),zod.z.object({type:zod.z.literal("find"),url:zod.z.string(),pattern:zod.z.string()})]).nullish()})});function Se({tools:n,toolChoice:r,strictJsonSchema:b}){n=(n?.length??0)>0?n:void 0;let _=[];if(n==null)return {tools:void 0,toolChoice:void 0,toolWarnings:_};let k=[];for(let p of n)switch(p.type){case "function":k.push({type:"function",name:p.name,description:p.description,parameters:p.inputSchema,strict:b});break;case "provider":{switch(p.id){case "openai.file_search":{let i=ge.parse(p.args);k.push({type:"file_search",vector_store_ids:i.vectorStoreIds,max_num_results:i.maxNumResults,ranking_options:i.ranking?{ranker:i.ranking.ranker,score_threshold:i.ranking.scoreThreshold}:void 0,filters:i.filters});break}case "openai.local_shell":{k.push({type:"local_shell"});break}case "openai.web_search_preview":{let i=Ie.parse(p.args);k.push({type:"web_search_preview",search_context_size:i.searchContextSize,user_location:i.userLocation});break}case "openai.web_search":{let i=ke.parse(p.args);k.push({type:"web_search",filters:i.filters!=null?{allowed_domains:i.filters.allowedDomains}:void 0,search_context_size:i.searchContextSize,user_location:i.userLocation});break}case "openai.code_interpreter":{let i=de.parse(p.args);k.push({type:"code_interpreter",container:i.container==null?{type:"auto",file_ids:void 0}:typeof i.container=="string"?i.container:{type:"auto",file_ids:i.container.fileIds}});break}case "openai.image_generation":{let i=fe.parse(p.args);k.push({type:"image_generation",background:i.background,input_fidelity:i.inputFidelity,input_image_mask:i.inputImageMask?{file_id:i.inputImageMask.fileId,image_url:i.inputImageMask.imageUrl}:void 0,model:i.model,moderation:i.moderation,partial_images:i.partialImages,quality:i.quality,output_compression:i.outputCompression,output_format:i.outputFormat,size:i.size});break}}break}default:_.push({type:"unsupported",feature:"unknown-tool"});break}if(r==null)return {tools:k,toolChoice:void 0,toolWarnings:_};let h=r.type;switch(h){case "auto":case "none":case "required":return {tools:k,toolChoice:h,toolWarnings:_};case "tool":return {tools:k,toolChoice:r.toolName==="code_interpreter"||r.toolName==="file_search"||r.toolName==="image_generation"||r.toolName==="web_search_preview"||r.toolName==="web_search"?{type:r.toolName}:{type:"function",name:r.toolName},toolWarnings:_};default:{let p=h;throw new provider.UnsupportedFunctionalityError({functionality:`tool choice type: ${p}`})}}}var Oe=zod.z.object({type:zod.z.literal("web_search_call"),id:zod.z.string(),status:zod.z.string(),action:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("search"),query:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("open_page"),url:zod.z.string()}),zod.z.object({type:zod.z.literal("find"),url:zod.z.string(),pattern:zod.z.string()})]).nullish()}),Me=zod.z.object({type:zod.z.literal("file_search_call"),id:zod.z.string(),queries:zod.z.array(zod.z.string()),results:zod.z.array(zod.z.object({attributes:zod.z.record(zod.z.string(),zod.z.unknown()),file_id:zod.z.string(),filename:zod.z.string(),score:zod.z.number(),text:zod.z.string()})).nullish()}),we=zod.z.object({type:zod.z.literal("code_interpreter_call"),id:zod.z.string(),code:zod.z.string().nullable(),container_id:zod.z.string(),outputs:zod.z.array(zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("logs"),logs:zod.z.string()}),zod.z.object({type:zod.z.literal("image"),url:zod.z.string()})])).nullable()}),Re=zod.z.object({type:zod.z.literal("local_shell_call"),id:zod.z.string(),call_id:zod.z.string(),action:zod.z.object({type:zod.z.literal("exec"),command:zod.z.array(zod.z.string()),timeout_ms:zod.z.number().optional(),user:zod.z.string().optional(),working_directory:zod.z.string().optional(),env:zod.z.record(zod.z.string(),zod.z.string()).optional()})}),Te=zod.z.object({type:zod.z.literal("image_generation_call"),id:zod.z.string(),result:zod.z.string()}),je=20,Ae=zod.z.array(zod.z.object({token:zod.z.string(),logprob:zod.z.number(),top_logprobs:zod.z.array(zod.z.object({token:zod.z.string(),logprob:zod.z.number()}))})),G=class{constructor(r,b){chunkK4ES4MUO_cjs.a(this,"specificationVersion","v3");chunkK4ES4MUO_cjs.a(this,"modelId");chunkK4ES4MUO_cjs.a(this,"config");chunkK4ES4MUO_cjs.a(this,"supportedUrls",{"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]});this.modelId=r,this.config=b;}get provider(){return this.config.provider}async getArgs({maxOutputTokens:r,temperature:b,stopSequences:_,topP:k,topK:h,presencePenalty:p,frequencyPenalty:i,seed:d,prompt:m,providerOptions:o,tools:C,toolChoice:u,responseFormat:a}){let s=[],c=Dt(this.modelId);h!=null&&s.push({type:"unsupported",feature:"topK"}),d!=null&&s.push({type:"unsupported",feature:"seed"}),p!=null&&s.push({type:"unsupported",feature:"presencePenalty"}),i!=null&&s.push({type:"unsupported",feature:"frequencyPenalty"}),_!=null&&s.push({type:"unsupported",feature:"stopSequences"});let g=await providerUtils.parseProviderOptions({provider:"copilot",providerOptions:o,schema:Wt}),{input:I,warnings:l}=await Ce({prompt:m,systemMessageMode:c.systemMessageMode,fileIdPrefixes:this.config.fileIdPrefixes,store:g?.store??true,hasLocalShellTool:w("openai.local_shell")});s.push(...l);let t=g?.strictJsonSchema??false,y=g?.include;function L(z){y=y!=null?[...y,z]:[z];}function w(z){return C?.find(te=>te.type==="provider"&&te.id===z)!=null}let q=typeof g?.logprobs=="number"?g?.logprobs:g?.logprobs===true?je:void 0;q&&L("message.output_text.logprobs");let T=C?.find(z=>z.type==="provider"&&(z.id==="openai.web_search"||z.id==="openai.web_search_preview"))?.name;T&&L("web_search_call.action.sources"),w("openai.code_interpreter")&&L("code_interpreter_call.outputs");let v={model:this.modelId,input:I,temperature:b,top_p:k,max_output_tokens:r,...(a?.type==="json"||g?.textVerbosity)&&{text:{...a?.type==="json"&&{format:a.schema!=null?{type:"json_schema",strict:t,name:a.name??"response",description:a.description,schema:a.schema}:{type:"json_object"}},...g?.textVerbosity&&{verbosity:g.textVerbosity}}},max_tool_calls:g?.maxToolCalls,metadata:g?.metadata,parallel_tool_calls:g?.parallelToolCalls,previous_response_id:g?.previousResponseId,store:g?.store,user:g?.user,instructions:g?.instructions,service_tier:g?.serviceTier,include:y,prompt_cache_key:g?.promptCacheKey,safety_identifier:g?.safetyIdentifier,top_logprobs:q,...c.isReasoningModel&&(g?.reasoningEffort!=null||g?.reasoningSummary!=null)&&{reasoning:{...g?.reasoningEffort!=null&&{effort:g.reasoningEffort},...g?.reasoningSummary!=null&&{summary:g.reasoningSummary}}},...c.requiredAutoTruncation&&{truncation:"auto"}};c.isReasoningModel?(v.temperature!=null&&(v.temperature=void 0,s.push({type:"unsupported",feature:"temperature",details:"temperature is not supported for reasoning models"})),v.top_p!=null&&(v.top_p=void 0,s.push({type:"unsupported",feature:"topP",details:"topP is not supported for reasoning models"}))):(g?.reasoningEffort!=null&&s.push({type:"unsupported",feature:"reasoningEffort",details:"reasoningEffort is not supported for non-reasoning models"}),g?.reasoningSummary!=null&&s.push({type:"unsupported",feature:"reasoningSummary",details:"reasoningSummary is not supported for non-reasoning models"})),g?.serviceTier==="flex"&&!c.supportsFlexProcessing&&(s.push({type:"unsupported",feature:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),delete v.service_tier),g?.serviceTier==="priority"&&!c.supportsPriorityProcessing&&(s.push({type:"unsupported",feature:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),delete v.service_tier);let{tools:N,toolChoice:ze,toolWarnings:Ee}=Se({tools:C,toolChoice:u,strictJsonSchema:t});return {webSearchToolName:T,args:{...v,tools:N,tool_choice:ze},warnings:[...s,...Ee]}}async doGenerate(r){let{args:b,warnings:_,webSearchToolName:k}=await this.getArgs(r),h=this.config.url({path:"/responses",modelId:this.modelId}),{responseHeaders:p,value:i,rawValue:d}=await providerUtils.postJsonToApi({url:h,headers:providerUtils.combineHeaders(this.config.headers(),r.headers),body:b,failedResponseHandler:Z,successfulResponseHandler:providerUtils.createJsonResponseHandler(zod.z.object({id:zod.z.string(),created_at:zod.z.number(),error:zod.z.object({code:zod.z.string(),message:zod.z.string()}).nullish(),model:zod.z.string(),output:zod.z.array(zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("message"),role:zod.z.literal("assistant"),id:zod.z.string(),content:zod.z.array(zod.z.object({type:zod.z.literal("output_text"),text:zod.z.string(),logprobs:Ae.nullish(),annotations:zod.z.array(zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("url_citation"),start_index:zod.z.number(),end_index:zod.z.number(),url:zod.z.string(),title:zod.z.string()}),zod.z.object({type:zod.z.literal("file_citation"),file_id:zod.z.string(),filename:zod.z.string().nullish(),index:zod.z.number().nullish(),start_index:zod.z.number().nullish(),end_index:zod.z.number().nullish(),quote:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("container_file_citation")})]))}))}),Oe,Me,we,Te,Re,zod.z.object({type:zod.z.literal("function_call"),call_id:zod.z.string(),name:zod.z.string(),arguments:zod.z.string(),id:zod.z.string()}),zod.z.object({type:zod.z.literal("computer_call"),id:zod.z.string(),status:zod.z.string().optional()}),zod.z.object({type:zod.z.literal("reasoning"),id:zod.z.string(),encrypted_content:zod.z.string().nullish(),summary:zod.z.array(zod.z.object({type:zod.z.literal("summary_text"),text:zod.z.string()}))})])),service_tier:zod.z.string().nullish(),incomplete_details:zod.z.object({reason:zod.z.string()}).nullish(),usage:Pe})),abortSignal:r.abortSignal,fetch:this.config.fetch});if(i.error)throw new provider.APICallError({message:i.error.message,url:h,requestBodyValues:b,statusCode:400,responseHeaders:p,responseBody:d,isRetryable:false});let m=[],o=[],C=false;for(let a of i.output)switch(a.type){case "reasoning":{a.summary.length===0&&a.summary.push({type:"summary_text",text:""});for(let s of a.summary)m.push({type:"reasoning",text:s.text,providerMetadata:{openai:{itemId:a.id,reasoningEncryptedContent:a.encrypted_content??null}}});break}case "image_generation_call":{m.push({type:"tool-call",toolCallId:a.id,toolName:"image_generation",input:"{}"}),m.push({type:"tool-result",toolCallId:a.id,toolName:"image_generation",result:{result:a.result}});break}case "local_shell_call":{m.push({type:"tool-call",toolCallId:a.call_id,toolName:"local_shell",input:JSON.stringify({action:a.action}),providerMetadata:{openai:{itemId:a.id}}});break}case "message":{for(let s of a.content){r.providerOptions?.openai?.logprobs&&s.logprobs&&o.push(s.logprobs),m.push({type:"text",text:s.text,providerMetadata:{openai:{itemId:a.id}}});for(let c of s.annotations)c.type==="url_citation"?m.push({type:"source",sourceType:"url",id:providerUtils.generateId(),url:c.url,title:c.title}):c.type==="file_citation"&&m.push({type:"source",sourceType:"document",id:this.config.generateId?.()??providerUtils.generateId(),mediaType:"text/plain",title:c.quote??c.filename??"Document",filename:c.filename??c.file_id});}break}case "function_call":{C=true,m.push({type:"tool-call",toolCallId:a.call_id,toolName:a.name,input:a.arguments,providerMetadata:{openai:{itemId:a.id}}});break}case "web_search_call":{m.push({type:"tool-call",toolCallId:a.id,toolName:k??"web_search",input:JSON.stringify({action:a.action}),providerExecuted:true}),m.push({type:"tool-result",toolCallId:a.id,toolName:k??"web_search",result:{status:a.status}});break}case "computer_call":{m.push({type:"tool-call",toolCallId:a.id,toolName:"computer_use",input:"",providerExecuted:true}),m.push({type:"tool-result",toolCallId:a.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:a.status||"completed"}});break}case "file_search_call":{m.push({type:"tool-call",toolCallId:a.id,toolName:"file_search",input:"{}",providerExecuted:true}),m.push({type:"tool-result",toolCallId:a.id,toolName:"file_search",result:{queries:a.queries,results:a.results?.map(s=>({attributes:s.attributes,fileId:s.file_id,filename:s.filename,score:s.score,text:s.text}))??null}});break}case "code_interpreter_call":{m.push({type:"tool-call",toolCallId:a.id,toolName:"code_interpreter",input:JSON.stringify({code:a.code,containerId:a.container_id}),providerExecuted:true}),m.push({type:"tool-result",toolCallId:a.id,toolName:"code_interpreter",result:{outputs:a.outputs}});break}}let u={openai:{responseId:i.id}};return o.length>0&&u.openai&&(u.openai.logprobs=o),typeof i.service_tier=="string"&&u.openai&&(u.openai.serviceTier=i.service_tier),{content:m,finishReason:ee({finishReason:i.incomplete_details?.reason,hasFunctionCall:C}),usage:{inputTokens:{total:i.usage.input_tokens,noCache:i.usage.input_tokens!==void 0&&i.usage.input_tokens_details?.cached_tokens!==void 0?i.usage.input_tokens-(i.usage.input_tokens_details?.cached_tokens??0):void 0,cacheRead:i.usage.input_tokens_details?.cached_tokens??void 0,cacheWrite:void 0},outputTokens:{total:i.usage.output_tokens,text:void 0,reasoning:i.usage.output_tokens_details?.reasoning_tokens??void 0},raw:i.usage},request:{body:b},response:{id:i.id,timestamp:new Date(i.created_at*1e3),modelId:i.model,headers:p,body:d},providerMetadata:u,warnings:_}}async doStream(r){let{args:b,warnings:_,webSearchToolName:k}=await this.getArgs(r),{responseHeaders:h,value:p}=await providerUtils.postJsonToApi({url:this.config.url({path:"/responses",modelId:this.modelId}),headers:providerUtils.combineHeaders(this.config.headers(),r.headers),body:{...b,stream:true},failedResponseHandler:Z,successfulResponseHandler:providerUtils.createEventSourceResponseHandler(Ot),abortSignal:r.abortSignal,fetch:this.config.fetch}),i={unified:"other",raw:void 0},d={inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0}},m=[],o=null,C={},u=false,a={},s=null,c=null,g;return {stream:p.pipeThrough(new TransformStream({start(I){I.enqueue({type:"stream-start",warnings:_});},transform(I,l){if(r.includeRawChunks&&l.enqueue({type:"raw",rawValue:I.rawValue}),!I.success){i={unified:"error",raw:void 0},l.enqueue({type:"error",error:I.error});return}let t=I.value;if(Le(t))t.item.type==="function_call"?(C[t.output_index]={toolName:t.item.name,toolCallId:t.item.call_id},l.enqueue({type:"tool-input-start",id:t.item.call_id,toolName:t.item.name})):t.item.type==="web_search_call"?(C[t.output_index]={toolName:k??"web_search",toolCallId:t.item.id},l.enqueue({type:"tool-input-start",id:t.item.id,toolName:k??"web_search"})):t.item.type==="computer_call"?(C[t.output_index]={toolName:"computer_use",toolCallId:t.item.id},l.enqueue({type:"tool-input-start",id:t.item.id,toolName:"computer_use"})):t.item.type==="code_interpreter_call"?(C[t.output_index]={toolName:"code_interpreter",toolCallId:t.item.id,codeInterpreter:{containerId:t.item.container_id}},l.enqueue({type:"tool-input-start",id:t.item.id,toolName:"code_interpreter"}),l.enqueue({type:"tool-input-delta",id:t.item.id,delta:`{"containerId":"${t.item.container_id}","code":"`})):t.item.type==="file_search_call"?l.enqueue({type:"tool-call",toolCallId:t.item.id,toolName:"file_search",input:"{}",providerExecuted:true}):t.item.type==="image_generation_call"?l.enqueue({type:"tool-call",toolCallId:t.item.id,toolName:"image_generation",input:"{}",providerExecuted:true}):t.item.type==="message"?(c=t.item.id,l.enqueue({type:"text-start",id:t.item.id,providerMetadata:{openai:{itemId:t.item.id}}})):Lt(t)&&(a[t.output_index]={canonicalId:t.item.id,encryptedContent:t.item.encrypted_content,summaryParts:[0]},s=t.output_index,l.enqueue({type:"reasoning-start",id:`${t.item.id}:0`,providerMetadata:{openai:{itemId:t.item.id,reasoningEncryptedContent:t.item.encrypted_content??null}}}));else if(qe(t)){if(t.item.type==="function_call")C[t.output_index]=void 0,u=true,l.enqueue({type:"tool-input-end",id:t.item.call_id}),l.enqueue({type:"tool-call",toolCallId:t.item.call_id,toolName:t.item.name,input:t.item.arguments,providerMetadata:{openai:{itemId:t.item.id}}});else if(t.item.type==="web_search_call")C[t.output_index]=void 0,l.enqueue({type:"tool-input-end",id:t.item.id}),l.enqueue({type:"tool-call",toolCallId:t.item.id,toolName:"web_search",input:JSON.stringify({action:t.item.action}),providerExecuted:true}),l.enqueue({type:"tool-result",toolCallId:t.item.id,toolName:"web_search",result:{status:t.item.status}});else if(t.item.type==="computer_call")C[t.output_index]=void 0,l.enqueue({type:"tool-input-end",id:t.item.id}),l.enqueue({type:"tool-call",toolCallId:t.item.id,toolName:"computer_use",input:"",providerExecuted:true}),l.enqueue({type:"tool-result",toolCallId:t.item.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:t.item.status||"completed"}});else if(t.item.type==="file_search_call")C[t.output_index]=void 0,l.enqueue({type:"tool-result",toolCallId:t.item.id,toolName:"file_search",result:{queries:t.item.queries,results:t.item.results?.map(y=>({attributes:y.attributes,fileId:y.file_id,filename:y.filename,score:y.score,text:y.text}))??null}});else if(t.item.type==="code_interpreter_call")C[t.output_index]=void 0,l.enqueue({type:"tool-result",toolCallId:t.item.id,toolName:"code_interpreter",result:{outputs:t.item.outputs}});else if(t.item.type==="image_generation_call")l.enqueue({type:"tool-result",toolCallId:t.item.id,toolName:"image_generation",result:{result:t.item.result}});else if(t.item.type==="local_shell_call")C[t.output_index]=void 0,l.enqueue({type:"tool-call",toolCallId:t.item.call_id,toolName:"local_shell",input:JSON.stringify({action:{type:"exec",command:t.item.action.command,timeoutMs:t.item.action.timeout_ms,user:t.item.action.user,workingDirectory:t.item.action.working_directory,env:t.item.action.env}}),providerMetadata:{openai:{itemId:t.item.id}}});else if(t.item.type==="message")c&&(l.enqueue({type:"text-end",id:c}),c=null);else if(wt(t)){let y=a[t.output_index];if(y){for(let L of y.summaryParts)l.enqueue({type:"reasoning-end",id:`${y.canonicalId}:${L}`,providerMetadata:{openai:{itemId:y.canonicalId,reasoningEncryptedContent:t.item.encrypted_content??null}}});delete a[t.output_index],s===t.output_index&&(s=null);}}}else if(jt(t)){let y=C[t.output_index];y!=null&&l.enqueue({type:"tool-input-delta",id:y.toolCallId,delta:t.delta});}else if(At(t))l.enqueue({type:"tool-result",toolCallId:t.item_id,toolName:"image_generation",result:{result:t.partial_image_b64}});else if(Pt(t)){let y=C[t.output_index];y!=null&&l.enqueue({type:"tool-input-delta",id:y.toolCallId,delta:JSON.stringify(t.delta).slice(1,-1)});}else if(qt(t)){let y=C[t.output_index];y!=null&&(l.enqueue({type:"tool-input-delta",id:y.toolCallId,delta:'"}'}),l.enqueue({type:"tool-input-end",id:y.toolCallId}),l.enqueue({type:"tool-call",toolCallId:y.toolCallId,toolName:"code_interpreter",input:JSON.stringify({code:t.code,containerId:y.codeInterpreter.containerId})}));}else if(Tt(t))o=t.response.id,l.enqueue({type:"response-metadata",id:t.response.id,timestamp:new Date(t.response.created_at*1e3),modelId:t.response.model});else if(Mt(t))c||(c=t.item_id,l.enqueue({type:"text-start",id:c,providerMetadata:{openai:{itemId:t.item_id}}})),l.enqueue({type:"text-delta",id:c,delta:t.delta}),r.providerOptions?.openai?.logprobs&&t.logprobs&&m.push(t.logprobs);else if(zt(t)){let y=s!==null?a[s]:null;y&&t.summary_index>0&&(y.summaryParts.push(t.summary_index),l.enqueue({type:"reasoning-start",id:`${y.canonicalId}:${t.summary_index}`,providerMetadata:{openai:{itemId:y.canonicalId,reasoningEncryptedContent:y.encryptedContent??null}}}));}else if(Et(t)){let y=s!==null?a[s]:null;y&&l.enqueue({type:"reasoning-delta",id:`${y.canonicalId}:${t.summary_index}`,delta:t.delta,providerMetadata:{openai:{itemId:y.canonicalId}}});}else Rt(t)?(i=ee({finishReason:t.response.incomplete_details?.reason,hasFunctionCall:u}),d={inputTokens:{total:t.response.usage.input_tokens,noCache:t.response.usage.input_tokens!==void 0&&t.response.usage.input_tokens_details?.cached_tokens!==void 0?t.response.usage.input_tokens-(t.response.usage.input_tokens_details?.cached_tokens??0):void 0,cacheRead:t.response.usage.input_tokens_details?.cached_tokens??void 0,cacheWrite:void 0},outputTokens:{total:t.response.usage.output_tokens,text:void 0,reasoning:t.response.usage.output_tokens_details?.reasoning_tokens??void 0},raw:t.response.usage},typeof t.response.service_tier=="string"&&(g=t.response.service_tier)):Nt(t)?t.annotation.type==="url_citation"?l.enqueue({type:"source",sourceType:"url",id:providerUtils.generateId(),url:t.annotation.url,title:t.annotation.title}):t.annotation.type==="file_citation"&&l.enqueue({type:"source",sourceType:"document",id:providerUtils.generateId(),mediaType:"text/plain",title:t.annotation.quote??t.annotation.filename??"Document",filename:t.annotation.filename??t.annotation.file_id}):Ft(t)&&l.enqueue({type:"error",error:t});},flush(I){c&&(I.enqueue({type:"text-end",id:c}),c=null);let l={openai:{responseId:o}};m.length>0&&(l.openai.logprobs=m),g!==void 0&&(l.openai.serviceTier=g),I.enqueue({type:"finish",finishReason:i,usage:d,providerMetadata:l});}})),request:{body:b},response:{headers:h}}}},Pe=zod.z.object({input_tokens:zod.z.number(),input_tokens_details:zod.z.object({cached_tokens:zod.z.number().nullish()}).nullish(),output_tokens:zod.z.number(),output_tokens_details:zod.z.object({reasoning_tokens:zod.z.number().nullish()}).nullish()}),mt=zod.z.object({type:zod.z.literal("response.output_text.delta"),item_id:zod.z.string(),delta:zod.z.string(),logprobs:Ae.nullish()}),gt=zod.z.object({type:zod.z.literal("error"),code:zod.z.string(),message:zod.z.string(),param:zod.z.string().nullish(),sequence_number:zod.z.number()}),ft=zod.z.object({type:zod.z.enum(["response.completed","response.incomplete"]),response:zod.z.object({incomplete_details:zod.z.object({reason:zod.z.string()}).nullish(),usage:Pe,service_tier:zod.z.string().nullish()})}),ht=zod.z.object({type:zod.z.literal("response.created"),response:zod.z.object({id:zod.z.string(),created_at:zod.z.number(),model:zod.z.string(),service_tier:zod.z.string().nullish()})}),yt=zod.z.object({type:zod.z.literal("response.output_item.added"),output_index:zod.z.number(),item:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("message"),id:zod.z.string()}),zod.z.object({type:zod.z.literal("reasoning"),id:zod.z.string(),encrypted_content:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("function_call"),id:zod.z.string(),call_id:zod.z.string(),name:zod.z.string(),arguments:zod.z.string()}),zod.z.object({type:zod.z.literal("web_search_call"),id:zod.z.string(),status:zod.z.string(),action:zod.z.object({type:zod.z.literal("search"),query:zod.z.string().optional()}).nullish()}),zod.z.object({type:zod.z.literal("computer_call"),id:zod.z.string(),status:zod.z.string()}),zod.z.object({type:zod.z.literal("file_search_call"),id:zod.z.string()}),zod.z.object({type:zod.z.literal("image_generation_call"),id:zod.z.string()}),zod.z.object({type:zod.z.literal("code_interpreter_call"),id:zod.z.string(),container_id:zod.z.string(),code:zod.z.string().nullable(),outputs:zod.z.array(zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("logs"),logs:zod.z.string()}),zod.z.object({type:zod.z.literal("image"),url:zod.z.string()})])).nullable(),status:zod.z.string()})])}),_t=zod.z.object({type:zod.z.literal("response.output_item.done"),output_index:zod.z.number(),item:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("message"),id:zod.z.string()}),zod.z.object({type:zod.z.literal("reasoning"),id:zod.z.string(),encrypted_content:zod.z.string().nullish()}),zod.z.object({type:zod.z.literal("function_call"),id:zod.z.string(),call_id:zod.z.string(),name:zod.z.string(),arguments:zod.z.string(),status:zod.z.literal("completed")}),we,Te,Oe,Me,Re,zod.z.object({type:zod.z.literal("computer_call"),id:zod.z.string(),status:zod.z.literal("completed")})])}),bt=zod.z.object({type:zod.z.literal("response.function_call_arguments.delta"),item_id:zod.z.string(),output_index:zod.z.number(),delta:zod.z.string()}),Ct=zod.z.object({type:zod.z.literal("response.image_generation_call.partial_image"),item_id:zod.z.string(),output_index:zod.z.number(),partial_image_b64:zod.z.string()}),kt=zod.z.object({type:zod.z.literal("response.code_interpreter_call_code.delta"),item_id:zod.z.string(),output_index:zod.z.number(),delta:zod.z.string()}),It=zod.z.object({type:zod.z.literal("response.code_interpreter_call_code.done"),item_id:zod.z.string(),output_index:zod.z.number(),code:zod.z.string()}),St=zod.z.object({type:zod.z.literal("response.output_text.annotation.added"),annotation:zod.z.discriminatedUnion("type",[zod.z.object({type:zod.z.literal("url_citation"),url:zod.z.string(),title:zod.z.string()}),zod.z.object({type:zod.z.literal("file_citation"),file_id:zod.z.string(),filename:zod.z.string().nullish(),index:zod.z.number().nullish(),start_index:zod.z.number().nullish(),end_index:zod.z.number().nullish(),quote:zod.z.string().nullish()})])}),xt=zod.z.object({type:zod.z.literal("response.reasoning_summary_part.added"),item_id:zod.z.string(),summary_index:zod.z.number()}),vt=zod.z.object({type:zod.z.literal("response.reasoning_summary_text.delta"),item_id:zod.z.string(),summary_index:zod.z.number(),delta:zod.z.string()}),Ot=zod.z.union([mt,ft,ht,yt,_t,bt,Ct,kt,It,St,xt,vt,gt,zod.z.object({type:zod.z.string()}).loose()]);function Mt(n){return n.type==="response.output_text.delta"}function qe(n){return n.type==="response.output_item.done"}function wt(n){return qe(n)&&n.item.type==="reasoning"}function Rt(n){return n.type==="response.completed"||n.type==="response.incomplete"}function Tt(n){return n.type==="response.created"}function jt(n){return n.type==="response.function_call_arguments.delta"}function At(n){return n.type==="response.image_generation_call.partial_image"}function Pt(n){return n.type==="response.code_interpreter_call_code.delta"}function qt(n){return n.type==="response.code_interpreter_call_code.done"}function Le(n){return n.type==="response.output_item.added"}function Lt(n){return Le(n)&&n.item.type==="reasoning"}function Nt(n){return n.type==="response.output_text.annotation.added"}function zt(n){return n.type==="response.reasoning_summary_part.added"}function Et(n){return n.type==="response.reasoning_summary_text.delta"}function Ft(n){return n.type==="error"}function Dt(n){let r=n.startsWith("o3")||n.startsWith("o4-mini")||n.startsWith("gpt-5")&&!n.startsWith("gpt-5-chat"),b=n.startsWith("gpt-4")||n.startsWith("gpt-5-mini")||n.startsWith("gpt-5")&&!n.startsWith("gpt-5-nano")&&!n.startsWith("gpt-5-chat")||n.startsWith("o3")||n.startsWith("o4-mini"),_={requiredAutoTruncation:false,systemMessageMode:"system",supportsFlexProcessing:r,supportsPriorityProcessing:b};return n.startsWith("gpt-5-chat")?{..._,isReasoningModel:false}:n.startsWith("o")||n.startsWith("gpt-5")||n.startsWith("codex-")||n.startsWith("computer-use")?n.startsWith("o1-mini")||n.startsWith("o1-preview")?{..._,isReasoningModel:true,systemMessageMode:"remove"}:{..._,isReasoningModel:true,systemMessageMode:"developer"}:{..._,isReasoningModel:false}}var Wt=zod.z.object({include:zod.z.array(zod.z.enum(["reasoning.encrypted_content","file_search_call.results","message.output_text.logprobs"])).nullish(),instructions:zod.z.string().nullish(),logprobs:zod.z.union([zod.z.boolean(),zod.z.number().min(1).max(je)]).optional(),maxToolCalls:zod.z.number().nullish(),metadata:zod.z.any().nullish(),parallelToolCalls:zod.z.boolean().nullish(),previousResponseId:zod.z.string().nullish(),promptCacheKey:zod.z.string().nullish(),reasoningEffort:zod.z.string().nullish(),reasoningSummary:zod.z.string().nullish(),safetyIdentifier:zod.z.string().nullish(),serviceTier:zod.z.enum(["auto","flex","priority"]).nullish(),store:zod.z.boolean().nullish(),strictJsonSchema:zod.z.boolean().nullish(),textVerbosity:zod.z.enum(["low","medium","high"]).nullish(),user:zod.z.string().nullish()});var Ht="0.1.0";function Ne(n={}){let r=providerUtils.withoutTrailingSlash(n.baseURL??"https://api.openai.com/v1");if(!r)throw new utils.NameErrors.MissingFieldError({message:"baseURL is required",field:"baseURL"});let b={...n.apiKey&&{Authorization:`Bearer ${n.apiKey}`},...n.headers},_=()=>providerUtils.withUserAgentSuffix(b,`ai-sdk/openai-compatible/${Ht}`),k=d=>new H(d,{provider:`${n.name??"openai-compatible"}.chat`,headers:_,url:({path:m})=>`${r}${m}`,fetch:n.fetch}),h=d=>new G(d,{provider:`${n.name??"openai-compatible"}.responses`,headers:_,url:({path:m})=>`${r}${m}`,fetch:n.fetch}),p=d=>k(d),i=function(d){return k(d)};return i.languageModel=p,i.chat=k,i.responses=h,i}var Jt=Ne();
|
|
2
|
+
exports.a=Ne;exports.b=Jt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkKNR62LEG_cjs=require('./chunk-KNR62LEG.cjs'),chunkK4ES4MUO_cjs=require('./chunk-K4ES4MUO.cjs'),fs=require('fs'),utils=require('@easbot/utils'),e=require('zod'),Y=require('path'),G=require('fs/promises'),remeda=require('remeda'),types=require('@easbot/types');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var e__default=/*#__PURE__*/_interopDefault(e);var Y__default=/*#__PURE__*/_interopDefault(Y);var G__default=/*#__PURE__*/_interopDefault(G);var H=utils.Log.create({service:"llm.config.loader"}),L=utils.createConfigChangeSubscriber({service:"llm.config.loader",onChanged:()=>{import('./loader-ON5XTSUI.cjs').then(({Config:o})=>{o.clearCache();}).catch(o=>{H.error("failed to clear llm config cache on external config change",{error:o instanceof Error?o:new Error(String(o))});});}});var fe=["openai","anthropic","google","deepseek","alibaba","alibaba-coding-plan","alibaba-token-plan-cn","minimax","minimax-cn","minimax-coding-plan","minimax-cn-coding-plan","nvidia","easbot-local","ollama"],S={ollama:{id:"ollama",name:"ollama",npm:"@easbot/ollama-sdk",env:["OLLAMA_API_KEY"],models:{"qwen3.5:0.8b":b("qwen3.5:0.8b"),"qwen3:0.6b":b("qwen3:0.6b"),"gemma3:1b":b("gemma3:1b")}},"easbot-local":{id:"easbot-local",name:"easbot-local",npm:"@easbot/local-model-sdk",env:[],models:{"bge-base-zh-v1.5":b("bge-base-zh-v1.5"),"rerank-proxy":b("rerank-proxy")}}},me={openai:"OpenAI",anthropic:"Anthropic",google:"Google",deepseek:"DeepSeek",alibaba:"Alibaba Cloud","alibaba-coding-plan":"Alibaba Coding Plan","alibaba-token-plan-cn":"Alibaba Token Plan (CN)",minimax:"MiniMax","minimax-cn":"MiniMax (CN)","minimax-coding-plan":"MiniMax Coding Plan","minimax-cn-coding-plan":"MiniMax Coding Plan (CN)",nvidia:"NVIDIA"};function b(o){return {id:o,name:o,release_date:"2026-07-01",attachment:false,reasoning:false,temperature:true,tool_call:false,limit:{context:2e5,output:8192},options:{}}}exports.d=void 0;(g=>{let o=utils.Log.create({service:"llm.models.dev"}),r=false;function n(){return Y__default.default.join(chunkKNR62LEG_cjs.g().cache,"models.json")}g.Model=e__default.default.object({id:e__default.default.string(),name:e__default.default.string(),description:e__default.default.string().optional(),family:e__default.default.string().optional(),release_date:e__default.default.string(),last_updated:e__default.default.string().optional(),attachment:e__default.default.boolean(),reasoning:e__default.default.boolean(),reasoning_options:e__default.default.array(e__default.default.union([e__default.default.object({type:e__default.default.literal("effort"),values:e__default.default.array(e__default.default.string())}).strict(),e__default.default.object({type:e__default.default.literal("toggle")}).strict()])).optional(),temperature:e__default.default.boolean(),tool_call:e__default.default.boolean(),structured_output:e__default.default.boolean().optional(),interleaved:e__default.default.union([e__default.default.literal(true),e__default.default.object({field:e__default.default.enum(["reasoning_content","reasoning_details"])}).strict()]).optional(),knowledge:e__default.default.string().optional(),cost:e__default.default.object({input:e__default.default.number(),output:e__default.default.number(),cache_read:e__default.default.number().optional(),cache_write:e__default.default.number().optional(),context_over_200k:e__default.default.object({input:e__default.default.number(),output:e__default.default.number(),cache_read:e__default.default.number().optional(),cache_write:e__default.default.number().optional()}).optional(),tiers:e__default.default.array(e__default.default.object({input:e__default.default.number(),output:e__default.default.number(),cache_read:e__default.default.number().optional(),tier:e__default.default.object({type:e__default.default.literal("context"),size:e__default.default.number()})})).optional()}).optional(),limit:e__default.default.object({context:e__default.default.number(),input:e__default.default.number().optional(),output:e__default.default.number()}),modalities:e__default.default.object({input:e__default.default.array(e__default.default.enum(["text","audio","image","video","pdf"])),output:e__default.default.array(e__default.default.enum(["text","audio","image","video","pdf"]))}).optional(),experimental:e__default.default.boolean().optional(),status:e__default.default.enum(["alpha","beta","deprecated"]).optional(),open_weights:e__default.default.boolean().optional(),options:e__default.default.record(e__default.default.string(),e__default.default.any()),headers:e__default.default.record(e__default.default.string(),e__default.default.string()).optional(),provider:e__default.default.object({npm:e__default.default.string()}).optional(),variants:e__default.default.record(e__default.default.string(),e__default.default.record(e__default.default.string(),e__default.default.any())).optional()}),g.Provider=e__default.default.object({id:e__default.default.string(),name:e__default.default.string(),npm:e__default.default.string().optional(),env:e__default.default.array(e__default.default.string()),api:e__default.default.string().optional(),doc:e__default.default.string().optional(),models:e__default.default.record(e__default.default.string(),g.Model)});function s(){return chunkKNR62LEG_cjs.a.EASBOT_MODELS_URL||"https://models.dev/api.json"}g.Data=utils.lazy(async()=>{if(chunkKNR62LEG_cjs.a.EASBOT_MODELS_FETCH)try{let c=await utils.Fetch.get(s());if(c.data&&Object.keys(c.data).length>0)return l(c.data);o.warn("models.dev returned empty catalog, falling back to local data");}catch(c){o.warn("failed to fetch models.dev catalog, falling back to local data",{url:s(),error:utils.errorMeta(c)});}let a=chunkKNR62LEG_cjs.a.EASBOT_MODELS_PATH??n(),y=await G__default.default.readFile(a,"utf-8").then(c=>JSON.parse(c)).catch(c=>{c?.code!=="ENOENT"&&o.warn("failed to load models cache file",{filePath:a,error:utils.errorMeta(c)});});if(y)return l(y);let j=await import('./models-snapshot-CNQITMJ7.cjs').then(c=>c.snapshot).catch(()=>{});return l(j||{})});function l(a){return Object.keys(S).length===0?a:remeda.mergeDeep(a,S)}async function O(){return await(0, g.Data)()}g.get=O;async function v(){try{let a=await utils.Fetch.get(s(),{headers:{"User-Agent":`EasBot/${chunkKNR62LEG_cjs.h().getVersion()}`},responseType:"text"});if(a.ok){try{JSON.parse(a.data);}catch(y){o.warn("models.dev returned invalid JSON, keeping existing cache",{error:utils.errorMeta(y),url:s()});return}await G__default.default.writeFile(n(),a.data),g.Data.reset(),o.debug("Models from models.dev refreshed successfully");}}catch(a){o.warn("Failed to refresh models from models.dev, using cached or snapshot data",{error:utils.errorMeta(a),url:s()});}}g.refresh=v;function T(){r||(r=true,chunkKNR62LEG_cjs.a.EASBOT_MODELS_FETCH?(o.debug("ModelsDev refresh scheduled"),v()):o.info("ModelsDev refresh skipped (EASBOT_MODELS_FETCH=false)"));}g.init=T;})(exports.d||(exports.d={}));var Te=e__default.default.object({type:e__default.default.union([e__default.default.literal("oauth"),e__default.default.literal("api")]),label:e__default.default.string()}).meta({ref:"ProviderAuthMethod"}),Z=exports.d.Provider.partial().extend({whitelist:e__default.default.array(e__default.default.string()).optional(),blacklist:e__default.default.array(e__default.default.string()).optional(),models:e__default.default.record(e__default.default.string(),exports.d.Model.partial().extend({variants:e__default.default.record(e__default.default.string(),e__default.default.object({disabled:e__default.default.boolean().optional().describe("Disable this variant for the model")}).catchall(e__default.default.any())).optional().describe("Variant-specific configuration")})).optional(),options:e__default.default.object({apiKey:e__default.default.string().optional(),baseURL:e__default.default.string().optional(),enterpriseUrl:e__default.default.string().optional().describe("GitHub Enterprise URL for copilot authentication"),setCacheKey:e__default.default.boolean().optional().describe("Enable promptCacheKey for this provider (default false)"),timeout:e__default.default.union([e__default.default.number().int().positive().describe("Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."),e__default.default.literal(false).describe("Disable timeout for this provider entirely.")]).optional().describe("Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.")}).catchall(e__default.default.any()).optional()}).strict().meta({ref:"ProviderConfig"}),_=e__default.default.object({provider:e__default.default.record(e__default.default.string(),Z).optional().describe("Custom provider configurations and model overrides"),disabled_providers:e__default.default.array(e__default.default.string()).optional().describe("Disable providers that are loaded automatically"),enabled_providers:e__default.default.array(e__default.default.string()).optional().describe("When set, ONLY these providers will be enabled. All other providers will be ignored"),model:e__default.default.string().optional().describe("Model to use in the format of provider/model, eg anthropic/claude-2"),small_model:e__default.default.string().optional().describe("Small model to use for tasks like title generation in the format of provider/model"),embedding_model:e__default.default.string().optional().describe("Embedding model, defaults to easbot-local/bge-base-zh-v1.5"),graph_model:e__default.default.string().optional().describe("Graph model for entity and relation extraction, defaults to easbot-local/qwen2.5-7b-instruct"),rerank_model:e__default.default.string().optional().describe("Rerank model for search result reranking, defaults to easbot-local/qwen2.5-7b-instruct"),agent:e__default.default.record(e__default.default.string(),types.AgentInfoSchema).optional().describe("Agent configuration overrides (see Agent docs)"),permission:types.PermissionConfigSchema.optional().describe("Project-level permission configuration"),default_agent:e__default.default.string().optional().describe("Default agent name; must reference a primary agent"),username:e__default.default.string().optional().describe("Custom username for telemetry"),experimental:e__default.default.object({openTelemetry:e__default.default.boolean().optional().describe("Enable OpenTelemetry spans for AI SDK calls")}).catchall(e__default.default.unknown()).optional().describe("Experimental feature flags")}).meta({ref:"LLMConfig"});var d=utils.Log.create({service:"llm.config.loader"}),w=null;async function A(o){L.track(o);try{return await utils.ConfigFileParse.loadFile(o,{schema:_})??{}}catch(r){return d.warn("Failed to load JSON file",{file:o,error:utils.errorMeta(r)}),null}}async function te(){let o=chunkKNR62LEG_cjs.g().config,r=utils.Filesystem.join(o,"easbot.json");return d.debug("Loading global config",{filePath:r}),await A(r)??{}}async function re(o){let r=utils.Filesystem.join(o,".easbot","easbot.json");return d.debug("Loading project config",{filePath:r}),await A(r)??{}}async function ne(){let o=process.env.EASBOT_CONFIG;if(!o)return {};d.debug("Loading custom config",{filePath:o});try{if(!fs.existsSync(o))throw new utils.NameErrors.NotFoundError({message:`EASBOT_CONFIG file not found: ${o}`,location:o});let n=await A(o);if(n===null)throw new utils.NameErrors.FileParseError({message:`EASBOT_CONFIG file is empty or invalid JSON: ${o}`,path:o,kind:"json"});return n}catch(r){throw d.error("EASBOT_CONFIG load failed",{filePath:o,error:utils.errorMeta(r)}),r}}function ie(){let o=process.env.EASBOT_CONFIG_CONTENT;if(!o)return {};d.debug("Loading inline config",{length:o.length});try{return utils.ConfigFileParse.parseConfig(o,"<EASBOT_CONFIG_CONTENT>",{schema:_})??{}}catch(r){return d.warn("Failed to parse EASBOT_CONFIG_CONTENT",{error:utils.errorMeta(r)}),{}}}async function ae(){var v=[];try{let o=chunkK4ES4MUO_cjs.g(v,d.time("state"));let r=[];let n=[];let p=await te();Object.keys(p).length>0&&(n.push(p),r.push(utils.Filesystem.join(chunkKNR62LEG_cjs.g().config,"easbot.json")));let f=chunkKNR62LEG_cjs.f().getDirectory();let s=await re(f);Object.keys(s).length>0&&(n.push(s),r.push(utils.Filesystem.join(f,"easbot.json")));let i=await ne();Object.keys(i).length>0&&(n.push(i),process.env.EASBOT_CONFIG&&r.push(process.env.EASBOT_CONFIG));let l=ie();Object.keys(l).length>0&&n.push(l);let O=utils.ConfigFileParse.merge(n,_);w=O;return {config:O,directories:r}}catch(T){var g=T,a=true;}finally{chunkK4ES4MUO_cjs.h(v,g,a);}}var U=le(ae);async function se(){return L.init(),U()}function le(o){let r,n=0,p=()=>{if(r)return r;let f=n,s=0;return r=o().then(i=>f===n?i:(r=void 0,s>=ce?(d.warn("config state generation kept changing; accepting current value",{retries:s,generation:n}),i):(s++,p()))),r};return p.reset=()=>{n++,r=void 0;},p}var ce=3;exports.h=void 0;(s=>{async function o(){if(chunkKNR62LEG_cjs.d())try{return await chunkKNR62LEG_cjs.e().getInfo()}catch(l){d.errorDegradable("IConfigProvider failed, falling back to local loader",{error:utils.errorMeta(l)});}let{config:i}=await se();return i}s.get=o;async function r(i){return (await o()).provider?.[i]}s.provider=r;async function n(){let i=await o();return (i.enabled_providers??[]).filter(l=>!(i.disabled_providers??[]).includes(l))}s.enabledProviders=n;function p(){return w!==null}s.isLoaded=p;function f(){U.reset(),w=null;}s.clearCache=f;})(exports.h||(exports.h={}));
|
|
2
|
+
exports.a=fe;exports.b=S;exports.c=me;exports.e=Te;exports.f=Z;exports.g=_;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-NX2YVB72.mjs';import {a,g,h}from'./chunk-QMTIXJ7U.mjs';import {Log,NamedError,errorMeta,Identifier,NameErrors,Env,PKG,Instance,ACPClientConnection}from'@easbot/utils';import $ from'zod';function M(i,e){let t;if(typeof Buffer<"u")t=Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64");else {let r="";for(let a=0;a<i.length;a+=32768){let o=i.subarray(a,Math.min(a+32768,i.length));r+=String.fromCharCode.apply(null,o);}t=btoa(r);}return `data:${e??"application/octet-stream"};base64,${t}`}function Q(i,e){let t=[];if(i)for(let n of i)switch(n.type){case "text":n.text&&t.push(`<text>
|
|
2
|
+
${n.text}
|
|
3
|
+
</text>`);break;case "image":{let r="";typeof n.image=="string"?r=n.image:n.image instanceof URL?r=n.image.toString():n.image instanceof Uint8Array&&(r=M(n.image,n.mime)),t.push(`<image mime="${n.mime??"image/png"}">
|
|
4
|
+
${r}
|
|
5
|
+
</image>`);break}case "file":{let r="";typeof n.data=="string"?r=n.data:n.data instanceof URL?r=n.data.toString():n.data instanceof Uint8Array&&(r=M(n.data,n.mime)),t.push(`<file mime="${n.mime??"application/octet-stream"}">
|
|
6
|
+
${r}
|
|
7
|
+
</file>`);break}case "command":t.push(n.arguments?`/${n.command} ${n.arguments}`:`/${n.command}`);break}return t.join(`
|
|
8
|
+
`)}var ue=5*1024*1024;function V(i,e){let t=e?.maxInlineSize??ue,n=e?.capabilities,r=[];e?.system&&r.push({type:"text",text:`<system-reminder>
|
|
9
|
+
${e.system}
|
|
10
|
+
</system-reminder>`});for(let s of i??[])switch(s.type){case "text":s.text&&r.push({type:"text",text:s.text});break;case "image":{if(n&&n.image!==true){r.push({type:"text",text:D("image",s.mime??"image/png")});break}let a=Y(s.image,s.mime);a&&r.push(a);break}case "file":{let a=s.mime??"application/octet-stream";if(a.startsWith("audio/")&&n&&n.audio!==true){r.push({type:"text",text:D("audio",a)});break}if(a.startsWith("image/")&&n&&n.image!==true){r.push({type:"text",text:D("image",a)});break}let o=le(s.data,s.mime,t,n);o&&r.push(o);break}case "memory":break;case "command":if(s.command){let a=s.arguments?`/${s.command} ${s.arguments}`:`/${s.command}`;r.push({type:"text",text:a});}break}return r}function D(i,e){return `<unsupported-media kind="${i}" mime="${e}" /> (note: agent did not declare ${i} prompt capability, attachment dropped at protocol layer)`}function Y(i,e,t){let n=e??"image/png";if(i instanceof Uint8Array)return {type:"image",mimeType:n,data:M(i)};let r=i instanceof URL?i.toString():i,s=r.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(s){let a=s[1]??n,o=!!s[2],f=s[3]??"",h=o?f:Buffer.from(decodeURIComponent(f)).toString("base64");return {type:"image",mimeType:a,data:h}}return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("file://")?{type:"image",mimeType:n,data:"",uri:r}:{type:"image",mimeType:n,data:r}}function le(i,e,t,n){let r=e??"application/octet-stream";if(r.startsWith("audio/")){if(n&&n.audio!==true)return null;if(i instanceof Uint8Array)return {type:"audio",mimeType:r,data:M(i)};let o=i instanceof URL?i.toString():i,f=o.match(/^data:[^;,]+(;base64)?,(.*)$/s);return f?.[1]?{type:"audio",mimeType:r,data:f[2]??""}:{type:"resource_link",uri:o,name:"audio",mimeType:r}}if(r.startsWith("image/"))return n&&n.image!==true?null:Y(i,r);if(typeof i=="string"||i instanceof URL){let o=i instanceof URL?i.toString():i,f=o.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);if(f){let h=f[1]??r,b=!!f[2],w=J(h),g=f[3]??"",d=b?Math.floor(g.length*3/4):g.length;if(d>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:h,size:d};let P=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=`urn:easbot:inline:${P}`;if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:S,name:P,mimeType:h};if(w){let x=b?Buffer.from(g,"base64").toString("utf-8"):decodeURIComponent(g);return {type:"resource",resource:{uri:S,text:x,mimeType:h}}}return {type:"resource",resource:{uri:S,blob:b?g:Buffer.from(g).toString("base64"),mimeType:h}}}return o.startsWith("http://")||o.startsWith("https://")||o.startsWith("file://")?{type:"resource_link",uri:o,name:ce(o),mimeType:r}:null}if(i.length>t)return {type:"resource_link",uri:"",name:"large-inline-file",mimeType:r,size:i.length};if(n&&n.embeddedContext!==true)return {type:"resource_link",uri:"",name:"inline-file",mimeType:r,size:i.length};let a=`urn:easbot:inline:${`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}`;return J(r)?{type:"resource",resource:{uri:a,text:Buffer.from(i).toString("utf-8"),mimeType:r}}:{type:"resource",resource:{uri:a,blob:M(i),mimeType:r}}}function J(i){return !!(i.startsWith("text/")||i==="application/json"||i==="application/json5"||i==="application/jsonc"||i==="application/xml"||i==="application/javascript"||i==="application/typescript"||i==="application/yaml"||i==="application/x-yaml"||i==="application/toml")}function ce(i){try{return new URL(i).pathname.split("/").pop()||"file"}catch{return "file"}}var u=Log.create({service:"llm.subagent.acp"}),_=class{constructor(e){a(this,"subscriber",null);a(this,"config");a(this,"sessionId",null);a(this,"_isRunning",false);a(this,"abortExecute",null);this.config=e;}async start(){if(this.subscriber&&this._isRunning){u.debug("ACPAgentHandler.start: already connected, reusing",{name:this.config.name});return}let e=this.config.transport==="websocket"?"websocket":this.config.transport==="http"?"http":"stdio",t=this.config.uri??this.buildUrl(this.config);u.debug("ACPAgentHandler.start",{type:e,url:t,cwd:this.config.cwd??Instance.directory??process.cwd(),name:this.config.name});try{let n=await ACPClientConnection.connect({config:{type:e,url:t,cwd:this.config.cwd??Instance.directory??process.cwd(),timeout:this.config.timeout,env:this.config.env}});this.subscriber=n.subscriber,this.sessionId=n.sessionId,this._isRunning=!0,u.info("ACPAgentHandler started",{name:this.config.name,type:e,url:t});}catch(n){throw u.error("ACPAgentHandler.start failed",{name:this.config.name,error:errorMeta(n)}),n}}async stop(){u.debug("ACPAgentHandler.stop",{sessionId:this.sessionId,name:this.config?.name});let e=this.abortExecute;if(this.abortExecute=null,e)try{e();}catch(r){u.warn("ACPAgentHandler.stop: abort execute failed",{error:errorMeta(r)});}let t=this.subscriber,n=this.sessionId;if(this.subscriber=null,this.sessionId=null,this._isRunning=false,!!t){if(n)try{await ACPClientConnection.releaseSubscription(t,n);}catch(r){u.warn("Error releasing subscription",{error:errorMeta(r)});}try{await t.disconnect(),u.debug("ACPAgentHandler disconnected",{name:this.config?.name});}catch(r){u.warn("Error disconnecting ACP subscriber",{error:errorMeta(r)});}}}async execute(e,t){if(!this.subscriber||!this._isRunning)throw new NameErrors.OperationFailedError({message:"ACP agent not running",operation:"acp-agent-not-running"});u.debug("ACPAgentHandler.execute",{title:e.title,agent:e.agent,partsCount:e.parts?.length??1});let n=this.config?.timeout??1800*1e3,r=this.subscriber.client,s=t?.onMessage,a=await new Promise((o,f)=>{let h="",b,w,g=0,d=false,P=false,S=null,x=null,q=()=>{R("error",new NameErrors.OperationFailedError({message:"ACP agent stopped",operation:"acp-agent-stopped"}));};this.abortExecute=q;let R=(p,C)=>{if(!P){if(P=true,clearTimeout(se),this.abortExecute===q&&(this.abortExecute=null),S){try{S();}catch(v){u.warn("ACPAgentHandler: unsubscribeStatus failed",{error:errorMeta(v)});}S=null;}if(x){try{x();}catch(v){u.warn("ACPAgentHandler: unsubscribeSession failed",{error:errorMeta(v)});}x=null;}if(C){u.error("ACPAgentHandler.execute failed",{reason:p,error:errorMeta(C)}),f(C);return}u.debug("ACPAgentHandler.execute completed",{reason:p,messageCount:g,lastMessageId:b,lastTextLength:h.length}),o({title:e.title,output:h,metadata:{sessionId:this.sessionId??void 0,agent:e.agent,messageId:b,tokens:w,finishReason:p,messageCount:g}});}},W=(p,C)=>{u.debug("ACPAgentHandler: remote session status update",{source:C,to:p,promptSent:d,messageCount:g}),p==="idle"&&d?R("idle"):p==="error"&&d&&R("error",new Error("Remote session status: error"));},se=setTimeout(()=>{u.warn("ACPAgentHandler.execute timeout, forcing resolve",{timeout:n,messageCount:g,promptSent:d}),R("timeout");},n);(async()=>{try{let p=this.sessionId;if(!p)throw new NameErrors.OperationFailedError({message:"No session available. Call start() first.",operation:"acp-no-session"});u.debug("ACPAgentHandler: using existing session",{sessionId:p}),typeof r.onSessionStatus=="function"&&(S=r.onSessionStatus(c=>{W(c,"onSessionStatus");})),x=r.subscribeSessionEvents(p,{onMessage:c=>{if(g++,!c.text||c.text.trim().length===0){u.debug("ACPAgentHandler: skipping onMessage for empty-text message",{messageId:c.metadata.messageId,hasThinking:!!c.thinking,hasTools:(c.tools?.length??0)>0});return}b=c.metadata.messageId,c.metadata.tokens&&(w=c.metadata.tokens),c.metadata.sessionStatus&&W(c.metadata.sessionStatus,"onMessage.metadata"),c.text!==void 0&&(h=c.text),u.debug("ACPAgentHandler: message received",{messageId:b,messageCount:g,textLength:c.text?.length??0}),s&&Promise.resolve().then(()=>s(c)).catch(E=>{u.error("ACPAgentHandler.execute: onMessage callback error",{messageId:c.metadata.messageId,error:errorMeta(E)});});},onError:c=>{if(c.message?.includes("NotFoundError")){u.debug("ACPAgentHandler: ignored NotFoundError",{sessionId:p});return}u.error("ACPAgentHandler: subscription error",{error:errorMeta(c)});},onSessionUpdate:c=>{if(c.type==="session_status_update"){let E=c.properties.status,oe=typeof E=="string"?E:E?.type??"idle";W(oe,"onSessionUpdate");}}},{includeThinking:!1,includeToolDetails:!1,includeToolOutput:!1});let C=V(e.parts,{system:e.system,capabilities:r.getPromptCapabilities?.()??void 0}),v=this.config.agentConfig?.agent,G=this.config.agentConfig?.model,U={};v&&(U.agent=v),G&&(U.model=G),await r.prompt({sessionId:p,prompt:C,...Object.keys(U).length>0?{_meta:U}:{}}),d=!0,u.debug("ACPAgentHandler.execute prompt sent",{title:e.title,sessionId:p});}catch(p){R("error",p instanceof Error?p:new Error(errorMeta(p).message));}})();});return u.debug("ACPAgentHandler.execute completed",{title:e.title,textLength:a.output.length,messageCount:a.metadata.messageCount,finishReason:a.metadata.finishReason}),a}async interrupt(){this.subscriber?.client&&this.sessionId&&(u.debug("ACPAgentHandler.interrupt",{sessionId:this.sessionId}),await ACPClientConnection.interrupt(this.subscriber,this.sessionId));}isRunning(){return this._isRunning}async checkHealth(){if(!this._isRunning||!this.subscriber)return false;try{if(this.sessionId){let t=(await this.subscriber.client.listSessions({cwd:this.config?.cwd??process.cwd()}))?.sessions;return !t||!Array.isArray(t)?!1:t.some(n=>n.sessionId===this.sessionId)}return !0}catch(e){return u.errorDegradable("ACPAgentHandler.checkHealth failed",{error:errorMeta(e)}),false}}buildUrl(e){if(e.uri)return e.uri;let t=e.command??"easbot",n=e.args??["acp","--channel","stdio"];return `${t} ${n.join(" ")}`}};var L=Log.create({service:"llm.subagent.cli"}),ne=2*1024*1024,B=class{constructor(e){a(this,"process",null);a(this,"config");a(this,"_isRunning",false);a(this,"abortController",null);this.config=e;}async start(){this._isRunning=true,L.debug("CLIAgentHandler.start",{command:this.config.command});}async stop(){this.abortController&&this.abortController.abort(),this._isRunning=false;}async execute(e,t){if(!this.config.command)throw new NameErrors.OperationFailedError({message:"CLI command not configured",operation:"cli-not-configured"});L.debug("CLIAgentHandler.execute",{title:e.title,command:this.config.command});let n=this.buildArgs(e),r=this.config.cwd,a={...await Env.all(),...this.config.env},o=this.config.timeout??3e5,f={...process.env,...a};this.abortController=new AbortController,this._isRunning=true;let h=[this.config.command,...n];this.process=PKG.spawn(h,{cwd:r,env:f,stdout:"pipe",stderr:"pipe",stdin:"null",timeout:o,signal:this.abortController.signal,windowsHide:true});let b="",w="",g=false;this.process.stdout?.on("data",d=>{if(b.length>=ne){g=true;return}b+=d.toString("utf-8");}),this.process.stderr?.on("data",d=>{if(w.length>=ne){g=true;return}w+=d.toString("utf-8");});try{let d=await this.process.exited;if(d===0)return {title:e.title,output:b.trim(),metadata:{command:this.config.command,args:n,exitCode:d,truncated:g}};throw L.error("CLI exited with error",{code:d}),new NameErrors.OperationFailedError({message:`CLI exited with code ${d}: ${w.trim().slice(0,500)}`,operation:"cli-exit"})}catch(d){throw L.error("CLI process error",{error:errorMeta(d)}),d}finally{this.process=null,this._isRunning=false;}}async interrupt(){this.abortController&&this.abortController.abort();}isRunning(){return this._isRunning}async checkHealth(){return this._isRunning?this.process!==null||this._isRunning:false}buildArgs(e){let t=[...this.config?.args??[]],n=Q(e.parts)||e.title;return t.push("--prompt",n),t}};var m=Log.create({service:"llm.subagent.registry"}),F=class{constructor(e){a(this,"instances",new Map);a(this,"handlers",new Map);a(this,"config");a(this,"agentCounts",new Map);a(this,"idleCleanupTimer",null);a(this,"worktreeBindings",new Map);this.config=e,this.startIdleCleanup();}startIdleCleanup(){if(this.idleCleanupTimer)return;let e=this.config.idleCheckInterval??300*1e3,t=this.config.idleTimeout??1800*1e3;this.idleCleanupTimer=setInterval(()=>{this.cleanupIdleInstances(t);},e),m.debug("Idle cleanup timer started",{interval:e,timeout:t});}stopIdleCleanup(){this.idleCleanupTimer&&(clearInterval(this.idleCleanupTimer),this.idleCleanupTimer=null,m.debug("Idle cleanup timer stopped"));}async cleanupIdleInstances(e){let t=Date.now(),n=[];for(let[r,s]of this.instances){if(s.config.runMode!=="persistent"||s.status!=="idle"&&s.status!=="error")continue;t-s.lastActiveAt>e&&n.push(r);}if(n.length>0){m.debug("Cleaning up idle instances",{count:n.length,maxIdleTime:e});for(let r of n)try{await this.terminate(r);}catch(s){m.warn("Failed to cleanup idle instance",{id:r,error:errorMeta(s)});}}}async checkInstanceHealth(e){let t=this.handlers.get(e.id);if(!t)return false;try{return "checkHealth"in t&&typeof t.checkHealth=="function"?await t.checkHealth():t.isRunning()}catch{return false}}async spawn(e){let t=Identifier.ascending("subagent"),n=e;if(e.transport==="stdio"&&a$1.EASBOT_ENABLE_WORKTREE){let a=await this.assignWorktreeForInstance(t);a&&(n={...e,cwd:a.worktreePath},m.debug("Agent spawned with worktree",{id:t,name:e.name,worktreePath:a.worktreePath}));}let r={id:t,config:n,status:"starting",createdAt:Date.now(),lastActiveAt:Date.now()},s=this.createHandler(n);this.handlers.set(t,s),this.instances.set(t,r);try{return await s.start(n),r.status="idle",this.agentCounts.set(e.name,(this.agentCounts.get(e.name)??0)+1),m.debug("Agent spawned",{id:t,name:e.name,status:r.status}),r}catch(a){r.status="error",r.error=String(a),this.handlers.delete(t),this.instances.delete(t);let o=this.worktreeBindings.get(t);throw o&&(await this.releaseWorktreeForInstance(o.agentId),this.worktreeBindings.delete(t)),m.error("Failed to spawn agent, cleaned up",{id:t,name:e.name,error:errorMeta(a)}),a}}async assignWorktreeForInstance(e){let t=`subagent-${e}`;try{let{MultiAgentWorktree:n}=await import('@easbot/utils'),r=await n.assign({agentId:t,ephemeral:!0}),s={agentId:t,worktreePath:r.directory};return this.worktreeBindings.set(e,s),s}catch(n){return m.warn("worktree assign failed, spawn will use main checkout",{instanceId:e,error:errorMeta(n)}),null}}async releaseWorktreeForInstance(e){try{let{MultiAgentWorktree:t}=await import('@easbot/utils');await t.release({agentId:e});}catch(t){m.warn("worktree release failed (will be reaped by sweep)",{agentId:e,error:errorMeta(t)});}}createHandler(e){switch(e.transport){case "stdio":case "http":case "websocket":return new _(e);case "cli":return new B(e);default:throw new NameErrors.InvalidArgumentError({message:`Unknown transport type: ${e.transport}`,param:"transport"})}}async acquire(e){let t=await this.findIdleInstance(e.name);if(!t){let r=this.agentCounts.get(e.name)??0,s=e.maxConcurrent??this.config.maxConcurrent;r<s?t=await this.spawn(e):(m.debug("Max concurrent reached, waiting for idle instance",{name:e.name,currentCount:r,maxConcurrent:s}),t=await this.waitForIdleInstance(e.name));}t.status="running",t.lastActiveAt=Date.now();let n=this.handlers.get(t.id);if(!n)throw new NameErrors.NotFoundError({message:`Handler not found for instance: ${t.id}`,location:t.id});return {instance:t,execute:async(r,s)=>{t.status="busy";try{let a=await n.execute(r,s);return t.status="idle",t.lastActiveAt=Date.now(),a}catch(a){throw t.status="error",a}},interrupt:()=>n.interrupt()}}async release(e,t){t==="ephemeral"?await this.terminate(e.id):(e.status="idle",m.debug("Agent released to pool",{id:e.id,name:e.config.name}));}async terminate(e){let t=this.handlers.get(e),n=this.instances.get(e);if(this.handlers.delete(e),t)try{await t.stop();}catch(s){m.warn("Error stopping agent",{id:e,error:errorMeta(s)});}let r=this.worktreeBindings.get(e);if(r&&(await this.releaseWorktreeForInstance(r.agentId),this.worktreeBindings.delete(e)),n){let s=this.agentCounts.get(n.config.name)??0;s>0&&this.agentCounts.set(n.config.name,s-1),n.status="stopped",this.instances.delete(e);}m.debug("Agent terminated",{id:e});}async interrupt(e){let t=this.handlers.get(e);if(t)try{await t.interrupt(),m.debug("Agent interrupted",{id:e});}catch(n){m.warn("Error interrupting agent",{id:e,error:errorMeta(n)});}}async shutdownAll(){this.stopIdleCleanup();let e=Array.from(this.instances.keys());await Promise.all(e.map(t=>this.terminate(t))),m.debug("All agents shut down",{count:e.length});}listWorktreeBindings(){return Array.from(this.worktreeBindings.entries()).map(([e,t])=>({instanceId:e,agentId:t.agentId,worktreePath:t.worktreePath}))}list(){return Array.from(this.instances.values())}get(e){return this.instances.get(e)}async findIdleInstance(e){let t=[];for(let[n,r]of this.instances){if(r.config.name!==e||r.status!=="idle")continue;if(!await this.checkInstanceHealth(r)){m.warn("Found unhealthy idle instance, marking for cleanup",{id:n,name:e,lastActiveAt:r.lastActiveAt}),t.push(n);continue}return r}for(let n of t)try{await this.terminate(n);}catch(r){m.warn("Failed to terminate unhealthy instance",{id:n,error:errorMeta(r)});}}async waitForIdleInstance(e,t=6e4){let n=Date.now();for(;Date.now()-n<t;){let r=await this.findIdleInstance(e);if(r)return r;await new Promise(s=>setTimeout(s,1e3));}throw new NameErrors.TimeoutError({message:`Timeout waiting for idle ${e} agent`,timeoutMs:3e4})}};var k=NamedError.create("SubAgentError",$.object({message:$.string(),code:$.string(),agent:$.string().optional(),transport:$.string().optional()}));function we(i){let e=i;return {source:e.source??e.sessionId??"gateway",title:e.title??"SubAgent task",agent:e.agent??"gateway",parts:e.parts??[],system:e.system,config:e.config}}function re(i){return i?.enabled===true}var y=class y{constructor(e){a(this,"log");a(this,"registry",null);a(this,"registryConfig",null);a(this,"initError",null);this.log=Log.create({service:"llm.agent.sub-agent"}),this.registryConfig=e;}ensureRegistry(){if(!this.registry&&this.registryConfig)try{this.registry=new F(this.registryConfig);}catch(e){throw this.initError=e,new k({message:`Failed to initialize SubAgentRegistry: ${errorMeta(e).message}`,code:"init-failed"},{cause:e})}if(!this.registry)throw new k({message:"SubAgent registry not initialized (config missing or invalid)",code:"registry-uninit"});return this.registry}resolveAgentConfig(e){if(!this.registryConfig||!re(this.registryConfig))throw new k({message:"SubAgent system is disabled",code:"disabled"});let t=this.registryConfig.agents.find(r=>r.name===e.agent);if(!t)throw new k({message:`Unknown agent: ${e.agent}`,code:"unknown-agent",agent:e.agent});let n=t.transport;if(n!=="stdio"&&n!=="http"&&n!=="websocket")throw new k({message:`SubAgent.run only supports ACP transport (stdio/http/websocket); got '${n}' for agent '${e.agent}'. Use SubAgentRegistry directly for CLI/Remote transports.`,code:"unsupported-transport",agent:e.agent,transport:n});return {...t,...e.config??{}}}async run(e,t){var f=[];try{let n=g(f,this.log.time("llm.agent.subagent.run",{level:"DEBUG"}));let r=we(e);let s=this.ensureRegistry();let a=this.resolveAgentConfig(r);this.log.debug("SubAgent.run started",{title:r.title,agent:r.agent,runMode:a.runMode,transport:a.transport,hasOnMessage:!!t?.onMessage});let o=await s.acquire(a);try{return await o.execute(r,t)}catch(g){if(this.log.error("SubAgent.run failed",{title:r.title,agent:r.agent,runMode:a.runMode,error:errorMeta(g)}),a.runMode==="persistent"){this.log.warn("Persistent agent failed, terminating instance",{id:o.instance.id,name:r.agent});try{await s.terminate(o.instance.id);}catch(d){this.log.warn("Failed to terminate persistent agent",{id:o.instance.id,error:errorMeta(d)});}}throw g}finally{if(a.runMode==="ephemeral")try{await s.release(o.instance,"ephemeral");}catch(g){this.log.warn("Failed to release ephemeral agent",{id:o.instance.id,error:errorMeta(g)});}}}catch(h){var b=h,w=true;}finally{h(f,b,w);}}async shutdown(){this.registry&&await this.registry.shutdownAll();}isEnabled(){return re(this.registryConfig)&&this.initError===null}static getDefault(){return y._default}static setDefault(e){return y._default&&y._default.shutdown().catch(()=>{}),y._default=new y(e),y._default}static async run(e){let t=y.getDefault();if(!t)throw new k({message:"SubAgent.run called but no default instance set; call SubAgent.setDefault(config) first",code:"registry-uninit"});return t.run(e)}static clearDefault(){y._default&&(y._default.shutdown().catch(()=>{}),y._default=null);}};a(y,"_default",null);var ie=y;
|
|
11
|
+
export{V as a,k as b,ie as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as createOpenaiCompatible,b as openaiCompatible}from'./chunk-
|
|
1
|
+
export{a as createOpenaiCompatible,b as openaiCompatible}from'./chunk-JIETUZVR.mjs';import'./chunk-QMTIXJ7U.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkUJYQQ347_cjs=require('./chunk-UJYQQ347.cjs');require('./chunk-K4ES4MUO.cjs');Object.defineProperty(exports,"createOpenaiCompatible",{enumerable:true,get:function(){return chunkUJYQQ347_cjs.a}});Object.defineProperty(exports,"openaiCompatible",{enumerable:true,get:function(){return chunkUJYQQ347_cjs.b}});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {c,a,d,b,e,f}from'./chunk-QMTIXJ7U.mjs';import {fileURLToPath}from'url';import {win32,posix}from'path';import*as dn from'fs';import {realpathSync,readlinkSync,readdirSync,readdir as readdir$1,lstatSync}from'fs';import {realpath,readlink,readdir,lstat}from'fs/promises';import {EventEmitter}from'events';import Ar from'stream';import {StringDecoder}from'string_decoder';var ar=(e,t,i)=>{let s=e instanceof RegExp?ms(e,i):e,h=t instanceof RegExp?ms(t,i):t,n=s!==null&&h!=null&&th(s,h,i);return n&&{start:n[0],end:n[1],pre:i.slice(0,n[0]),body:i.slice(n[0]+s.length,n[1]),post:i.slice(n[1]+h.length)}},ms=(e,t)=>{let i=t.match(e);return i?i[0]:null},th=(e,t,i)=>{let s,h,n,o,l,a=i.indexOf(e),u=i.indexOf(t,a+1),g=a;if(a>=0&&u>0){if(e===t)return [a,u];for(s=[],n=i.length;g>=0&&!l;){if(g===a)s.push(g),a=i.indexOf(e,g+1);else if(s.length===1){let f=s.pop();f!==void 0&&(l=[f,u]);}else h=s.pop(),h!==void 0&&h<n&&(n=h,o=u),u=i.indexOf(t,g+1);g=a<u&&a>=0?a:u;}s.length&&o!==void 0&&(l=[n,o]);}return l},cr="\0SLASH"+Math.random()+"\0",ur="\0OPEN"+Math.random()+"\0",us="\0CLOSE"+Math.random()+"\0",pr="\0COMMA"+Math.random()+"\0",fr="\0PERIOD"+Math.random()+"\0",eh=new RegExp(cr,"g"),ih=new RegExp(ur,"g"),sh=new RegExp(us,"g"),rh=new RegExp(pr,"g"),hh=new RegExp(fr,"g"),nh=/\\\\/g,oh=/\\{/g,lh=/\\}/g,ah=/\\,/g,ch=/\\./g,uh=1e5;function Gi(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ph(e){return e.replace(nh,cr).replace(oh,ur).replace(lh,us).replace(ah,pr).replace(ch,fr)}function fh(e){return e.replace(eh,"\\").replace(ih,"{").replace(sh,"}").replace(rh,",").replace(hh,".")}function dr(e){if(!e)return [""];let t=[],i=ar("{","}",e);if(!i)return e.split(",");let{pre:s,body:h,post:n}=i,o=s.split(",");o[o.length-1]+="{"+h+"}";let l=dr(n);return n.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),t.push.apply(t,o),t}function dh(e,t={}){if(!e)return [];let{max:i=uh}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Ue(ph(e),i,true).map(fh)}function gh(e){return "{"+e+"}"}function mh(e){return /^-?0\d/.test(e)}function wh(e,t){return e<=t}function yh(e,t){return e>=t}function Ue(e,t,i){let s=[],h=ar("{","}",e);if(!h)return [e];let n=h.pre,o=h.post.length?Ue(h.post,t,false):[""];if(/\$$/.test(h.pre))for(let l=0;l<o.length&&l<t;l++){let a=n+"{"+h.body+"}"+o[l];s.push(a);}else {let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(h.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(h.body),u=l||a,g=h.body.indexOf(",")>=0;if(!u&&!g)return h.post.match(/,(?!,).*\}/)?(e=h.pre+"{"+h.body+us+h.post,Ue(e,t,true)):[e];let f;if(u)f=h.body.split(/\.\./);else if(f=dr(h.body),f.length===1&&f[0]!==void 0&&(f=Ue(f[0],t,false).map(gh),f.length===1))return o.map(E=>h.pre+f[0]+E);let w;if(u&&f[0]!==void 0&&f[1]!==void 0){let E=Gi(f[0]),v=Gi(f[1]),b=Math.max(f[0].length,f[1].length),x=f.length===3&&f[2]!==void 0?Math.abs(Gi(f[2])):1,S=wh;v<E&&(x*=-1,S=yh);let A=f.some(mh);w=[];for(let T=E;S(T,v);T+=x){let R;if(a)R=String.fromCharCode(T),R==="\\"&&(R="");else if(R=String(T),A){let F=b-R.length;if(F>0){let Bt=new Array(F+1).join("0");T<0?R="-"+Bt+R.slice(1):R=Bt+R;}}w.push(R);}}else {w=[];for(let E=0;E<f.length;E++)w.push.apply(w,Ue(f[E],t,false));}for(let E=0;E<w.length;E++)for(let v=0;v<o.length&&s.length<t;v++){let b=n+w[E]+o[v];(!i||u||b)&&s.push(b);}}return s}var ji=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")},bh={"[: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]},je=e=>e.replace(/[[\]\\-]/g,"\\$&"),Sh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ws=e=>e.join(""),vh=(e,t)=>{let i=t;if(e.charAt(i)!=="[")throw new Error("not in a brace expression");let s=[],h=[],n=i+1,o=false,l=false,a=false,u=false,g=i,f="";t:for(;n<e.length;){let v=e.charAt(n);if((v==="!"||v==="^")&&n===i+1){u=true,n++;continue}if(v==="]"&&o&&!a){g=n+1;break}if(o=true,v==="\\"&&!a){a=true,n++;continue}if(v==="["&&!a){for(let[b,[x,S,A]]of Object.entries(bh))if(e.startsWith(b,n)){if(f)return ["$.",false,e.length-i,true];n+=b.length,A?h.push(x):s.push(x),l=l||S;continue t}}if(a=false,f){v>f?s.push(je(f)+"-"+je(v)):v===f&&s.push(je(v)),f="",n++;continue}if(e.startsWith("-]",n+1)){s.push(je(v+"-")),n+=2;continue}if(e.startsWith("-",n+1)){f=v,n+=2;continue}s.push(je(v)),n++;}if(g<n)return ["",false,0,false];if(!s.length&&!h.length)return ["$.",false,e.length-i,true];if(h.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!u){let v=s[0].length===2?s[0].slice(-1):s[0];return [Sh(v),false,g-i,false]}let w="["+(u?"^":"")+ws(s)+"]",E="["+(u?"":"^")+ws(h)+"]";return [s.length&&h.length?"("+w+"|"+E+")":s.length?w:E,l,g-i,true]},Ee=(e,{windowsPathsNoEscape:t=false,magicalBraces:i=true}={})=>i?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),Eh=new Set(["!","?","+","*","@"]),ys=e=>Eh.has(e),xh="(?!(?:^|/)\\.\\.?(?:$|/))",Si="(?!\\.)",kh=new Set(["[","."]),Ch=new Set(["..","."]),Oh=new Set("().*{}+?[]^$\\!"),Ah=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ps="[^/]",bs=ps+"*?",Ss=ps+"+?",z,I,Lt,W,D,Zt,he,Jt,Tt,ne,Ve,ge,mr,te,Z,Ti,Yi,wr,gr=(Z=class{constructor(t,i,s={}){c(this,ge);a(this,"type");c(this,z);c(this,I);c(this,Lt,false);c(this,W,[]);c(this,D);c(this,Zt);c(this,he);c(this,Jt,false);c(this,Tt);c(this,ne);c(this,Ve,false);this.type=t,t&&d(this,I,true),d(this,D,i),d(this,z,b(this,D)?b(b(this,D),z):this),d(this,Tt,b(this,z)===this?s:b(b(this,z),Tt)),d(this,he,b(this,z)===this?[]:b(b(this,z),he)),t==="!"&&!b(b(this,z),Jt)&&b(this,he).push(this),d(this,Zt,b(this,D)?b(b(this,D),W).length:0);}get hasMagic(){if(b(this,I)!==void 0)return b(this,I);for(let t of b(this,W))if(typeof t!="string"&&(t.type||t.hasMagic))return d(this,I,true);return b(this,I)}toString(){return b(this,ne)!==void 0?b(this,ne):this.type?d(this,ne,this.type+"("+b(this,W).map(t=>String(t)).join("|")+")"):d(this,ne,b(this,W).map(t=>String(t)).join(""))}push(...t){for(let i of t)if(i!==""){if(typeof i!="string"&&!(i instanceof Z&&b(i,D)===this))throw new Error("invalid part: "+i);b(this,W).push(i);}}toJSON(){let t=this.type===null?b(this,W).slice().map(i=>typeof i=="string"?i:i.toJSON()):[this.type,...b(this,W).map(i=>i.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===b(this,z)||b(b(this,z),Jt)&&b(this,D)?.type==="!")&&t.push({}),t}isStart(){if(b(this,z)===this)return true;if(!b(this,D)?.isStart())return false;if(b(this,Zt)===0)return true;let t=b(this,D);for(let i=0;i<b(this,Zt);i++){let s=b(t,W)[i];if(!(s instanceof Z&&s.type==="!"))return false}return true}isEnd(){if(b(this,z)===this||b(this,D)?.type==="!")return true;if(!b(this,D)?.isEnd())return false;if(!this.type)return b(this,D)?.isEnd();let t=b(this,D)?b(b(this,D),W).length:0;return b(this,Zt)===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this));}clone(t){let i=new Z(this.type,t);for(let s of b(this,W))i.copyIn(s);return i}static fromGlob(t,i={}){var h;let s=new Z(null,void 0,i);return e(h=Z,te,Ti).call(h,t,s,0,i),s}toMMPattern(){if(this!==b(this,z))return b(this,z).toMMPattern();let t=this.toString(),[i,s,h,n]=this.toRegExpSource();if(!(h||b(this,I)||b(this,Tt).nocase&&!b(this,Tt).nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let o=(b(this,Tt).nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${i}$`,o),{_src:i,_glob:t})}get options(){return b(this,Tt)}toRegExpSource(t){let i=t??!!b(this,Tt).dot;if(b(this,z)===this&&e(this,ge,mr).call(this),!this.type){let a=this.isStart()&&this.isEnd()&&!b(this,W).some(w=>typeof w!="string"),u=b(this,W).map(w=>{var S;let[E,v,b$1,x]=typeof w=="string"?e(S=Z,te,wr).call(S,w,b(this,I),a):w.toRegExpSource(t);return d(this,I,b(this,I)||b$1),d(this,Lt,b(this,Lt)||x),E}).join(""),g="";if(this.isStart()&&typeof b(this,W)[0]=="string"&&!(b(this,W).length===1&&Ch.has(b(this,W)[0]))){let w=kh,E=i&&w.has(u.charAt(0))||u.startsWith("\\.")&&w.has(u.charAt(2))||u.startsWith("\\.\\.")&&w.has(u.charAt(4)),v=!i&&!t&&w.has(u.charAt(0));g=E?xh:v?Si:"";}let f="";return this.isEnd()&&b(b(this,z),Jt)&&b(this,D)?.type==="!"&&(f="(?:$|\\/)"),[g+u+f,Ee(u),d(this,I,!!b(this,I)),b(this,Lt)]}let s=this.type==="*"||this.type==="+",h=this.type==="!"?"(?:(?!(?:":"(?:",n=e(this,ge,Yi).call(this,i);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let a=this.toString();return d(this,W,[a]),this.type=null,d(this,I,void 0),[a,Ee(this.toString()),false,false]}let o=!s||t||i||!Si?"":e(this,ge,Yi).call(this,true);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let l="";if(this.type==="!"&&b(this,Ve))l=(this.isStart()&&!i?Si:"")+Ss;else {let a=this.type==="!"?"))"+(this.isStart()&&!i&&!t?Si:"")+bs+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=h+n+a;}return [l,Ee(n),d(this,I,!!b(this,I)),b(this,Lt)]}},z=new WeakMap,I=new WeakMap,Lt=new WeakMap,W=new WeakMap,D=new WeakMap,Zt=new WeakMap,he=new WeakMap,Jt=new WeakMap,Tt=new WeakMap,ne=new WeakMap,Ve=new WeakMap,ge=new WeakSet,mr=function(){if(this!==b(this,z))throw new Error("should only call on root");if(b(this,Jt))return this;this.toString(),d(this,Jt,true);let t;for(;t=b(this,he).pop();){if(t.type!=="!")continue;let i=t,s=b(i,D);for(;s;){for(let h=b(i,Zt)+1;!s.type&&h<b(s,W).length;h++)for(let n of b(t,W)){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(b(s,W)[h]);}i=s,s=b(i,D);}}return this},te=new WeakSet,Ti=function(t,i,s,h){var E,v;let n=false,o=false,l=-1,a=false;if(i.type===null){let b=s,x="";for(;b<t.length;){let S=t.charAt(b++);if(n||S==="\\"){n=!n,x+=S;continue}if(o){b===l+1?(S==="^"||S==="!")&&(a=true):S==="]"&&!(b===l+2&&a)&&(o=false),x+=S;continue}else if(S==="["){o=true,l=b,a=false,x+=S;continue}if(!h.noext&&ys(S)&&t.charAt(b)==="("){i.push(x),x="";let A=new Z(S,i);b=e(E=Z,te,Ti).call(E,t,A,b,h),i.push(A);continue}x+=S;}return i.push(x),b}let u=s+1,g=new Z(null,i),f=[],w="";for(;u<t.length;){let b$1=t.charAt(u++);if(n||b$1==="\\"){n=!n,w+=b$1;continue}if(o){u===l+1?(b$1==="^"||b$1==="!")&&(a=true):b$1==="]"&&!(u===l+2&&a)&&(o=false),w+=b$1;continue}else if(b$1==="["){o=true,l=u,a=false,w+=b$1;continue}if(ys(b$1)&&t.charAt(u)==="("){g.push(w),w="";let x=new Z(b$1,g);g.push(x),u=e(v=Z,te,Ti).call(v,t,x,u,h);continue}if(b$1==="|"){g.push(w),w="",f.push(g),g=new Z(null,i);continue}if(b$1===")")return w===""&&b(i,W).length===0&&d(i,Ve,true),g.push(w),w="",i.push(...f,g),u;w+=b$1;}return i.type=null,d(i,I,void 0),d(i,W,[t.substring(s-1)]),u},Yi=function(t){return b(this,W).map(i=>{if(typeof i=="string")throw new Error("string type in extglob ast??");let[s,h,n,o]=i.toRegExpSource(t);return d(this,Lt,b(this,Lt)||o),s}).filter(i=>!(this.isStart()&&this.isEnd())||!!i).join("|")},wr=function(t,i,s=false){let h=false,n="",o=false,l=false;for(let a=0;a<t.length;a++){let u=t.charAt(a);if(h){h=false,n+=(Oh.has(u)?"\\":"")+u;continue}if(u==="*"){if(l)continue;l=true,n+=s&&/^[*]+$/.test(t)?Ss:bs,i=true;continue}else l=false;if(u==="\\"){a===t.length-1?n+="\\\\":h=true;continue}if(u==="["){let[g,f,w,E]=vh(t,a);if(w){n+=g,o=o||f,a+=w-1,i=i||E;continue}}if(u==="?"){n+=ps,i=true;continue}n+=Ah(u);}return [n,Ee(t),!!i,o]},c(Z,te),Z),yr=(e,{windowsPathsNoEscape:t=false,magicalBraces:i=false}={})=>i?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),et=(e,t,i={})=>(ji(t),!i.nocomment&&t.charAt(0)==="#"?false:new ee(t,i).match(e)),Th=/^\*+([^+@!?\*\[\(]*)$/,Rh=e=>t=>!t.startsWith(".")&&t.endsWith(e),Fh=e=>t=>t.endsWith(e),Mh=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Wh=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ph=/^\*+\.\*+$/,Lh=e=>!e.startsWith(".")&&e.includes("."),Dh=e=>e!=="."&&e!==".."&&e.includes("."),jh=/^\.\*+$/,zh=e=>e!=="."&&e!==".."&&e.startsWith("."),_h=/^\*+$/,Nh=e=>e.length!==0&&!e.startsWith("."),$h=e=>e.length!==0&&e!=="."&&e!=="..",Bh=/^\?+([^+@!?\*\[\(]*)?$/,Uh=([e,t=""])=>{let i=br([e]);return t?(t=t.toLowerCase(),s=>i(s)&&s.toLowerCase().endsWith(t)):i},Gh=([e,t=""])=>{let i=Sr([e]);return t?(t=t.toLowerCase(),s=>i(s)&&s.toLowerCase().endsWith(t)):i},Ih=([e,t=""])=>{let i=Sr([e]);return t?s=>i(s)&&s.endsWith(t):i},Hh=([e,t=""])=>{let i=br([e]);return t?s=>i(s)&&s.endsWith(t):i},br=([e])=>{let t=e.length;return i=>i.length===t&&!i.startsWith(".")},Sr=([e])=>{let t=e.length;return i=>i.length===t&&i!=="."&&i!==".."},vr=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",vs={win32:{sep:"\\"},posix:{sep:"/"}},qh=vr==="win32"?vs.win32.sep:vs.posix.sep;et.sep=qh;var tt=Symbol("globstar **");et.GLOBSTAR=tt;var Zh="[^/]",Jh=Zh+"*?",Vh="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Kh="(?:(?!(?:\\/|^)\\.).)*?",Yh=(e,t={})=>i=>et(i,e,t);et.filter=Yh;var ct=(e,t={})=>Object.assign({},e,t),Xh=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return et;let t=et;return Object.assign((i,s,h={})=>t(i,s,ct(e,h)),{Minimatch:class extends t.Minimatch{constructor(i,s={}){super(i,ct(e,s));}static defaults(i){return t.defaults(ct(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,s,h={}){super(i,s,ct(e,h));}static fromGlob(i,s={}){return t.AST.fromGlob(i,ct(e,s))}},unescape:(i,s={})=>t.unescape(i,ct(e,s)),escape:(i,s={})=>t.escape(i,ct(e,s)),filter:(i,s={})=>t.filter(i,ct(e,s)),defaults:i=>t.defaults(ct(e,i)),makeRe:(i,s={})=>t.makeRe(i,ct(e,s)),braceExpand:(i,s={})=>t.braceExpand(i,ct(e,s)),match:(i,s,h={})=>t.match(i,s,ct(e,h)),sep:t.sep,GLOBSTAR:tt})};et.defaults=Xh;var Er=(e,t={})=>(ji(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:dh(e,{max:t.braceExpandMax}));et.braceExpand=Er;var Qh=(e,t={})=>new ee(e,t).makeRe();et.makeRe=Qh;var tn=(e,t,i={})=>{let s=new ee(t,i);return e=e.filter(h=>s.match(h)),s.options.nonull&&!e.length&&e.push(t),e};et.match=tn;var Es=/[?*]|[+@!]\(.*?\)|\[|\]/,en=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ee=class{constructor(e,t={}){a(this,"options");a(this,"set");a(this,"pattern");a(this,"windowsPathsNoEscape");a(this,"nonegate");a(this,"negate");a(this,"comment");a(this,"empty");a(this,"preserveMultipleSlashes");a(this,"partial");a(this,"globSet");a(this,"globParts");a(this,"nocase");a(this,"isWindows");a(this,"platform");a(this,"windowsNoMagicRoot");a(this,"regexp");ji(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||vr,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[i]===false,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=false,this.nonegate=!!t.nonegate,this.comment=false,this.empty=false,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.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 e of this.set)for(let t of e)if(typeof t!="string")return true;return false}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...h)=>console.error(...h)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(h=>this.slashSplit(h));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let s=this.globParts.map((h,n,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=h[0]===""&&h[1]===""&&(h[2]==="?"||!Es.test(h[2]))&&!Es.test(h[3]),a=/^[a-z]:/i.test(h[0]);if(l)return [...h.slice(0,4),...h.slice(4).map(u=>this.parse(u))];if(a)return [h[0],...h.slice(1).map(u=>this.parse(u))]}return h.map(l=>this.parse(l))});if(this.debug(this.pattern,s),this.set=s.filter(h=>h.indexOf(false)===-1),this.isWindows)for(let h=0;h<this.set.length;h++){let n=this.set[h];n[0]===""&&n[1]===""&&this.globParts[h][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?");}this.debug(this.pattern,this.set);}preprocess(e){if(this.options.noglobstar)for(let i=0;i<e.length;i++)for(let s=0;s<e[i].length;s++)e[i][s]==="**"&&(e[i][s]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let i=-1;for(;(i=t.indexOf("**",i+1))!==-1;){let s=i;for(;t[s+1]==="**";)s++;s!==i&&t.splice(i,s-i);}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((i,s)=>{let h=i[i.length-1];return s==="**"&&h==="**"?i:s===".."&&h&&h!==".."&&h!=="."&&h!=="**"?(i.pop(),i):(i.push(s),i)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=false;do{if(t=false,!this.preserveMultipleSlashes){for(let s=1;s<e.length-1;s++){let h=e[s];s===1&&h===""&&e[0]===""||(h==="."||h==="")&&(t=true,e.splice(s,1),s--);}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=true,e.pop());}let i=0;for(;(i=e.indexOf("..",i+1))!==-1;){let s=e[i-1];s&&s!=="."&&s!==".."&&s!=="**"&&(t=true,e.splice(i-1,2),i-=2);}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=false;do{t=false;for(let i of e){let s=-1;for(;(s=i.indexOf("**",s+1))!==-1;){let n=s;for(;i[n+1]==="**";)n++;n>s&&i.splice(s+1,n-s);let o=i[s+1],l=i[s+2],a=i[s+3];if(o!==".."||!l||l==="."||l===".."||!a||a==="."||a==="..")continue;t=true,i.splice(s,1);let u=i.slice(0);u[s]="**",e.push(u),s--;}if(!this.preserveMultipleSlashes){for(let n=1;n<i.length-1;n++){let o=i[n];n===1&&o===""&&i[0]===""||(o==="."||o==="")&&(t=true,i.splice(n,1),n--);}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(t=true,i.pop());}let h=0;for(;(h=i.indexOf("..",h+1))!==-1;){let n=i[h-1];if(n&&n!=="."&&n!==".."&&n!=="**"){t=true;let o=h===1&&i[h+1]==="**"?["."]:[];i.splice(h-1,2,...o),i.length===0&&i.push(""),h-=2;}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let i=t+1;i<e.length;i++){let s=this.partsMatch(e[t],e[i],!this.preserveMultipleSlashes);if(s){e[t]=[],e[i]=s;break}}return e.filter(t=>t.length)}partsMatch(e,t,i=false){let s=0,h=0,n=[],o="";for(;s<e.length&&h<t.length;)if(e[s]===t[h])n.push(o==="b"?t[h]:e[s]),s++,h++;else if(i&&e[s]==="**"&&t[h]===e[s+1])n.push(e[s]),s++;else if(i&&t[h]==="**"&&e[s]===t[h+1])n.push(t[h]),h++;else if(e[s]==="*"&&t[h]&&(this.options.dot||!t[h].startsWith("."))&&t[h]!=="**"){if(o==="b")return false;o="a",n.push(e[s]),s++,h++;}else if(t[h]==="*"&&e[s]&&(this.options.dot||!e[s].startsWith("."))&&e[s]!=="**"){if(o==="a")return false;o="b",n.push(t[h]),s++,h++;}else return false;return e.length===t.length&&n}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=false,i=0;for(let s=0;s<e.length&&e.charAt(s)==="!";s++)t=!t,i++;i&&(this.pattern=e.slice(i)),this.negate=t;}matchOne(e,t,i=false){let s=this.options;if(this.isWindows){let v=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),b=!v&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),x=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),S=!x&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),A=b?3:v?0:void 0,T=S?3:x?0:void 0;if(typeof A=="number"&&typeof T=="number"){let[R,F]=[e[A],t[T]];R.toLowerCase()===F.toLowerCase()&&(t[T]=R,T>A?t=t.slice(T):A>T&&(e=e.slice(A)));}}let{optimizationLevel:h=1}=this.options;h>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var n=0,o=0,l=e.length,a=t.length;n<l&&o<a;n++,o++){this.debug("matchOne loop");var u=t[o],g=e[n];if(this.debug(t,u,g),u===false)return false;if(u===tt){this.debug("GLOBSTAR",[t,u,g]);var f=n,w=o+1;if(w===a){for(this.debug("** at the end");n<l;n++)if(e[n]==="."||e[n]===".."||!s.dot&&e[n].charAt(0)===".")return false;return true}for(;f<l;){var E=e[f];if(this.debug(`
|
|
2
|
+
globstar while`,e,f,t,w,E),this.matchOne(e.slice(f),t.slice(w),i))return this.debug("globstar found match!",f,l,E),true;if(E==="."||E===".."||!s.dot&&E.charAt(0)==="."){this.debug("dot detected!",e,f,t,w);break}this.debug("globstar swallow a segment, and continue"),f++;}return !!(i&&(this.debug(`
|
|
3
|
+
>>> no match, partial?`,e,f,t,w),f===l))}let v;if(typeof u=="string"?(v=g===u,this.debug("string match",u,g,v)):(v=u.test(g),this.debug("pattern match",u,g,v)),!v)return false}if(n===l&&o===a)return true;if(n===l)return i;if(o===a)return n===l-1&&e[n]==="";throw new Error("wtf?")}braceExpand(){return Er(this.pattern,this.options)}parse(e){ji(e);let t=this.options;if(e==="**")return tt;if(e==="")return "";let i,s=null;(i=e.match(_h))?s=t.dot?$h:Nh:(i=e.match(Th))?s=(t.nocase?t.dot?Wh:Mh:t.dot?Fh:Rh)(i[1]):(i=e.match(Bh))?s=(t.nocase?t.dot?Gh:Uh:t.dot?Ih:Hh)(i):(i=e.match(Ph))?s=t.dot?Dh:Lh:(i=e.match(jh))&&(s=zh);let h=gr.fromGlob(e,this.options).toMMPattern();return s&&typeof h=="object"&&Reflect.defineProperty(h,"test",{value:s}),h}makeRe(){if(this.regexp||this.regexp===false)return this.regexp;let e=this.set;if(!e.length)return this.regexp=false,this.regexp;let t=this.options,i=t.noglobstar?Jh:t.dot?Vh:Kh,s=new Set(t.nocase?["i"]:[]),h=e.map(l=>{let a=l.map(g=>{if(g instanceof RegExp)for(let f of g.flags.split(""))s.add(f);return typeof g=="string"?en(g):g===tt?tt:g._src});a.forEach((g,f)=>{let w=a[f+1],E=a[f-1];g!==tt||E===tt||(E===void 0?w!==void 0&&w!==tt?a[f+1]="(?:\\/|"+i+"\\/)?"+w:a[f]=i:w===void 0?a[f-1]=E+"(?:\\/|\\/"+i+")?":w!==tt&&(a[f-1]=E+"(?:\\/|\\/"+i+"\\/)"+w,a[f+1]=tt));});let u=a.filter(g=>g!==tt);if(this.partial&&u.length>=1){let g=[];for(let f=1;f<=u.length;f++)g.push(u.slice(0,f).join("/"));return "(?:"+g.join("|")+")"}return u.join("/")}).join("|"),[n,o]=e.length>1?["(?:",")"]:["",""];h="^"+n+h+o+"$",this.partial&&(h="^(?:\\/|"+n+h.slice(1,-1)+o+")$"),this.negate&&(h="^(?!"+h+").+$");try{this.regexp=new RegExp(h,[...s].join(""));}catch{this.regexp=false;}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return false;if(this.empty)return e==="";if(e==="/"&&t)return true;let i=this.options;this.isWindows&&(e=e.split("\\").join("/"));let s=this.slashSplit(e);this.debug(this.pattern,"split",s);let h=this.set;this.debug(this.pattern,"set",h);let n=s[s.length-1];if(!n)for(let o=s.length-2;!n&&o>=0;o--)n=s[o];for(let o=0;o<h.length;o++){let l=h[o],a=s;if(i.matchBase&&l.length===1&&(a=[n]),this.matchOne(a,l,t))return i.flipNegate?true:!this.negate}return i.flipNegate?false:this.negate}static defaults(e){return et.defaults(e).Minimatch}};et.AST=gr;et.Minimatch=ee;et.escape=yr;et.unescape=Ee;var rn=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,xr=new Set,Xi=typeof process=="object"&&process?process:{},kr=(e,t,i,s)=>{typeof Xi.emitWarning=="function"?Xi.emitWarning(e,t,i,s):console.error(`[${i}] ${t}: ${e}`);},zi=globalThis.AbortController,xs=globalThis.AbortSignal;if(typeof zi>"u"){xs=class{constructor(){a(this,"onabort");a(this,"_onabort",[]);a(this,"reason");a(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},zi=class{constructor(){a(this,"signal",new xs);t();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let e=Xi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=false,kr("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",t));};}var hn=e=>!xr.has(e),Gt=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Cr=e=>Gt(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?Ri:null:null,Ri=class extends Array{constructor(e){super(e),this.fill(0);}},Mt,xe,nn=(Mt=class{constructor(t,i){a(this,"heap");a(this,"length");if(!b(Mt,xe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Cr(t);if(!i)return [];d(Mt,xe,true);let s=new Mt(t,i);return d(Mt,xe,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},xe=new WeakMap,c(Mt,xe,false),Mt),Ns,$s,pt,ht,wt,oe,yt,ke,Ce,bt,_,St,j,P,O,Y,nt,V,H,vt,q,Et,xt,ot,lt,kt,Vt,X,Oe,y,Qi,le,Dt,Ke,at,Or,ae,Ae,Ye,It,Ht,ts,Fi,Mi,M,es,Ge,qt,is,Te,Ni=(Te=class{constructor(t){c(this,y);c(this,pt);c(this,ht);c(this,wt);c(this,oe);c(this,yt);c(this,ke);c(this,Ce);c(this,bt);a(this,"ttl");a(this,"ttlResolution");a(this,"ttlAutopurge");a(this,"updateAgeOnGet");a(this,"updateAgeOnHas");a(this,"allowStale");a(this,"noDisposeOnSet");a(this,"noUpdateTTL");a(this,"maxEntrySize");a(this,"sizeCalculation");a(this,"noDeleteOnFetchRejection");a(this,"noDeleteOnStaleGet");a(this,"allowStaleOnFetchAbort");a(this,"allowStaleOnFetchRejection");a(this,"ignoreFetchAbort");c(this,_);c(this,St);c(this,j);c(this,P);c(this,O);c(this,Y);c(this,nt);c(this,V);c(this,H);c(this,vt);c(this,q);c(this,Et);c(this,xt);c(this,ot);c(this,lt);c(this,kt);c(this,Vt);c(this,X);c(this,Oe);c(this,le,()=>{});c(this,Dt,()=>{});c(this,Ke,()=>{});c(this,at,()=>false);c(this,ae,t=>{});c(this,Ae,(t,i,s)=>{});c(this,Ye,(t,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});a(this,Ns,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:a$1,dispose:u,onInsert:g,disposeAfter:f,noDisposeOnSet:w,noUpdateTTL:E,maxSize:v=0,maxEntrySize:b$1=0,sizeCalculation:x,fetchMethod:S,memoMethod:A,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:Bt,ignoreFetchAbort:we,perf:ye}=t;if(ye!==void 0&&typeof ye?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(d(this,bt,ye??rn),i!==0&&!Gt(i))throw new TypeError("max option must be a nonnegative integer");let be=i?Cr(i):Array;if(!be)throw new Error("invalid max value: "+i);if(d(this,pt,i),d(this,ht,v),this.maxEntrySize=b$1||b(this,ht),this.sizeCalculation=x,this.sizeCalculation){if(!b(this,ht)&&!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(A!==void 0&&typeof A!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,Ce,A),S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,ke,S),d(this,Vt,!!S),d(this,j,new Map),d(this,P,new Array(i).fill(void 0)),d(this,O,new Array(i).fill(void 0)),d(this,Y,new be(i)),d(this,nt,new be(i)),d(this,V,0),d(this,H,0),d(this,vt,nn.create(i)),d(this,_,0),d(this,St,0),typeof u=="function"&&d(this,wt,u),typeof g=="function"&&d(this,oe,g),typeof f=="function"?(d(this,yt,f),d(this,q,[])):(d(this,yt,void 0),d(this,q,void 0)),d(this,kt,!!b(this,wt)),d(this,Oe,!!b(this,oe)),d(this,X,!!b(this,yt)),this.noDisposeOnSet=!!w,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!Bt,this.ignoreFetchAbort=!!we,this.maxEntrySize!==0){if(b(this,ht)!==0&&!Gt(b(this,ht)))throw new TypeError("maxSize must be a positive integer if specified");if(!Gt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");e(this,y,Or).call(this);}if(this.allowStale=!!a$1,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=Gt(h)||h===0?h:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!Gt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");e(this,y,Qi).call(this);}if(b(this,pt)===0&&this.ttl===0&&b(this,ht)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!b(this,pt)&&!b(this,ht)){let Ui="LRU_CACHE_UNBOUNDED";hn(Ui)&&(xr.add(Ui),kr("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ui,Te));}}get perf(){return b(this,bt)}static unsafeExposeInternals(t){return {starts:b(t,xt),ttls:b(t,ot),autopurgeTimers:b(t,lt),sizes:b(t,Et),keyMap:b(t,j),keyList:b(t,P),valList:b(t,O),next:b(t,Y),prev:b(t,nt),get head(){return b(t,V)},get tail(){return b(t,H)},free:b(t,vt),isBackgroundFetch:i=>{var s;return e(s=t,y,M).call(s,i)},backgroundFetch:(i,s,h,n)=>{var o;return e(o=t,y,Mi).call(o,i,s,h,n)},moveToTail:i=>{var s;return e(s=t,y,Ge).call(s,i)},indexes:i=>{var s;return e(s=t,y,It).call(s,i)},rindexes:i=>{var s;return e(s=t,y,Ht).call(s,i)},isStale:i=>{var s;return b(s=t,at).call(s,i)}}}get max(){return b(this,pt)}get maxSize(){return b(this,ht)}get calculatedSize(){return b(this,St)}get size(){return b(this,_)}get fetchMethod(){return b(this,ke)}get memoMethod(){return b(this,Ce)}get dispose(){return b(this,wt)}get onInsert(){return b(this,oe)}get disposeAfter(){return b(this,yt)}getRemainingTTL(t){return b(this,j).has(t)?1/0:0}*entries(){for(let t of e(this,y,It).call(this))b(this,O)[t]!==void 0&&b(this,P)[t]!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield [b(this,P)[t],b(this,O)[t]]);}*rentries(){for(let t of e(this,y,Ht).call(this))b(this,O)[t]!==void 0&&b(this,P)[t]!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield [b(this,P)[t],b(this,O)[t]]);}*keys(){for(let t of e(this,y,It).call(this)){let i=b(this,P)[t];i!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield i);}}*rkeys(){for(let t of e(this,y,Ht).call(this)){let i=b(this,P)[t];i!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield i);}}*values(){for(let t of e(this,y,It).call(this))b(this,O)[t]!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield b(this,O)[t]);}*rvalues(){for(let t of e(this,y,Ht).call(this))b(this,O)[t]!==void 0&&!e(this,y,M).call(this,b(this,O)[t])&&(yield b(this,O)[t]);}[($s=Symbol.iterator,Ns=Symbol.toStringTag,$s)](){return this.entries()}find(t,i={}){for(let s of e(this,y,It).call(this)){let h=b(this,O)[s],n=e(this,y,M).call(this,h)?h.__staleWhileFetching:h;if(n!==void 0&&t(n,b(this,P)[s],this))return this.get(b(this,P)[s],i)}}forEach(t,i=this){for(let s of e(this,y,It).call(this)){let h=b(this,O)[s],n=e(this,y,M).call(this,h)?h.__staleWhileFetching:h;n!==void 0&&t.call(i,n,b(this,P)[s],this);}}rforEach(t,i=this){for(let s of e(this,y,Ht).call(this)){let h=b(this,O)[s],n=e(this,y,M).call(this,h)?h.__staleWhileFetching:h;n!==void 0&&t.call(i,n,b(this,P)[s],this);}}purgeStale(){let t=false;for(let i of e(this,y,Ht).call(this,{allowStale:true}))b(this,at).call(this,i)&&(e(this,y,qt).call(this,b(this,P)[i],"expire"),t=true);return t}info(t){let i=b(this,j).get(t);if(i===void 0)return;let s=b(this,O)[i],h=e(this,y,M).call(this,s)?s.__staleWhileFetching:s;if(h===void 0)return;let n={value:h};if(b(this,ot)&&b(this,xt)){let o=b(this,ot)[i],l=b(this,xt)[i];if(o&&l){let a=o-(b(this,bt).now()-l);n.ttl=a,n.start=Date.now();}}return b(this,Et)&&(n.size=b(this,Et)[i]),n}dump(){let t=[];for(let i of e(this,y,It).call(this,{allowStale:true})){let s=b(this,P)[i],h=b(this,O)[i],n=e(this,y,M).call(this,h)?h.__staleWhileFetching:h;if(n===void 0||s===void 0)continue;let o={value:n};if(b(this,ot)&&b(this,xt)){o.ttl=b(this,ot)[i];let l=b(this,bt).now()-b(this,xt)[i];o.start=Math.floor(Date.now()-l);}b(this,Et)&&(o.size=b(this,Et)[i]),t.unshift([s,o]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let h=Date.now()-s.start;s.start=b(this,bt).now()-h;}this.set(i,s.value,s);}}set(t,i,s={}){var w,E,v,b$1;if(i===void 0)return this.delete(t),this;let{ttl:h=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:a}=s,{noUpdateTTL:u=this.noUpdateTTL}=s,g=b(this,Ye).call(this,t,i,s.size||0,l);if(this.maxEntrySize&&g>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=true),e(this,y,qt).call(this,t,"set"),this;let f$1=b(this,_)===0?void 0:b(this,j).get(t);if(f$1===void 0)f$1=b(this,_)===0?b(this,H):b(this,vt).length!==0?b(this,vt).pop():b(this,_)===b(this,pt)?e(this,y,Fi).call(this,false):b(this,_),b(this,P)[f$1]=t,b(this,O)[f$1]=i,b(this,j).set(t,f$1),b(this,Y)[b(this,H)]=f$1,b(this,nt)[f$1]=b(this,H),d(this,H,f$1),f(this,_)._++,b(this,Ae).call(this,f$1,g,a),a&&(a.set="add"),u=false,b(this,Oe)&&((w=b(this,oe))==null||w.call(this,i,t,"add"));else {e(this,y,Ge).call(this,f$1);let x=b(this,O)[f$1];if(i!==x){if(b(this,Vt)&&e(this,y,M).call(this,x)){x.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:S}=x;S!==void 0&&!o&&(b(this,kt)&&((E=b(this,wt))==null||E.call(this,S,t,"set")),b(this,X)&&b(this,q)?.push([S,t,"set"]));}else o||(b(this,kt)&&((v=b(this,wt))==null||v.call(this,x,t,"set")),b(this,X)&&b(this,q)?.push([x,t,"set"]));if(b(this,ae).call(this,f$1),b(this,Ae).call(this,f$1,g,a),b(this,O)[f$1]=i,a){a.set="replace";let S=x&&e(this,y,M).call(this,x)?x.__staleWhileFetching:x;S!==void 0&&(a.oldValue=S);}}else a&&(a.set="update");b(this,Oe)&&this.onInsert?.(i,t,i===x?"update":"replace");}if(h!==0&&!b(this,ot)&&e(this,y,Qi).call(this),b(this,ot)&&(u||b(this,Ke).call(this,f$1,h,n),a&&b(this,Dt).call(this,a,f$1)),!o&&b(this,X)&&b(this,q)){let x=b(this,q),S;for(;S=x?.shift();)(b$1=b(this,yt))==null||b$1.call(this,...S);}return this}pop(){var t;try{for(;b(this,_);){let i=b(this,O)[b(this,V)];if(e(this,y,Fi).call(this,!0),e(this,y,M).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(b(this,X)&&b(this,q)){let i=b(this,q),s;for(;s=i?.shift();)(t=b(this,yt))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h}=i,n=b(this,j).get(t);if(n!==void 0){let o=b(this,O)[n];if(e(this,y,M).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(b(this,at).call(this,n))h&&(h.has="stale",b(this,Dt).call(this,h,n));else return s&&b(this,le).call(this,n),h&&(h.has="hit",b(this,Dt).call(this,h,n)),true}else h&&(h.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,h=b(this,j).get(t);if(h===void 0||!s&&b(this,at).call(this,h))return;let n=b(this,O)[h];return e(this,y,M).call(this,n)?n.__staleWhileFetching:n}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:a=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:E=this.ignoreFetchAbort,allowStaleOnFetchAbort:v=this.allowStaleOnFetchAbort,context:b$1,forceRefresh:x=false,status:S,signal:A}=i;if(!b(this,Vt))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:n,status:S});let T={allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:l,size:a,sizeCalculation:u,noUpdateTTL:g,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:v,ignoreFetchAbort:E,status:S,signal:A},R=b(this,j).get(t);if(R===void 0){S&&(S.fetch="miss");let F=e(this,y,Mi).call(this,t,R,T,b$1);return F.__returned=F}else {let F=b(this,O)[R];if(e(this,y,M).call(this,F)){let be=s&&F.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",be&&(S.returnedStale=true)),be?F.__staleWhileFetching:F.__returned=F}let Bt=b(this,at).call(this,R);if(!x&&!Bt)return S&&(S.fetch="hit"),e(this,y,Ge).call(this,R),h&&b(this,le).call(this,R),S&&b(this,Dt).call(this,S,R),F;let we=e(this,y,Mi).call(this,t,R,T,b$1),ye=we.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=Bt?"stale":"refresh",ye&&Bt&&(S.returnedStale=true)),ye?we.__staleWhileFetching:we.__returned=we}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=b(this,Ce);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:n,...o}=i,l=this.get(t,o);if(!n&&l!==void 0)return l;let a=s(t,l,{options:o,context:h});return this.set(t,a,o),a}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,l=b(this,j).get(t);if(l!==void 0){let a=b(this,O)[l],u=e(this,y,M).call(this,a);return o&&b(this,Dt).call(this,o,l),b(this,at).call(this,l)?(o&&(o.get="stale"),u?(o&&s&&a.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?a.__staleWhileFetching:void 0):(n||e(this,y,qt).call(this,t,"expire"),o&&s&&(o.returnedStale=true),s?a:void 0)):(o&&(o.get="hit"),u?a.__staleWhileFetching:(e(this,y,Ge).call(this,l),h&&b(this,le).call(this,l),a))}else o&&(o.get="miss");}delete(t){return e(this,y,qt).call(this,t,"delete")}clear(){return e(this,y,is).call(this,"delete")}},pt=new WeakMap,ht=new WeakMap,wt=new WeakMap,oe=new WeakMap,yt=new WeakMap,ke=new WeakMap,Ce=new WeakMap,bt=new WeakMap,_=new WeakMap,St=new WeakMap,j=new WeakMap,P=new WeakMap,O=new WeakMap,Y=new WeakMap,nt=new WeakMap,V=new WeakMap,H=new WeakMap,vt=new WeakMap,q=new WeakMap,Et=new WeakMap,xt=new WeakMap,ot=new WeakMap,lt=new WeakMap,kt=new WeakMap,Vt=new WeakMap,X=new WeakMap,Oe=new WeakMap,y=new WeakSet,Qi=function(){let t=new Ri(b(this,pt)),i=new Ri(b(this,pt));d(this,ot,t),d(this,xt,i);let s=this.ttlAutopurge?new Array(b(this,pt)):void 0;d(this,lt,s),d(this,Ke,(o,l,a=b(this,bt).now())=>{if(i[o]=l!==0?a:0,t[o]=l,s?.[o]&&(clearTimeout(s[o]),s[o]=void 0),l!==0&&s){let u=setTimeout(()=>{b(this,at).call(this,o)&&e(this,y,qt).call(this,b(this,P)[o],"expire");},l+1);u.unref&&u.unref(),s[o]=u;}}),d(this,le,o=>{i[o]=t[o]!==0?b(this,bt).now():0;}),d(this,Dt,(o,l)=>{if(t[l]){let a=t[l],u=i[l];if(!a||!u)return;o.ttl=a,o.start=u,o.now=h||n();let g=o.now-u;o.remainingTTL=a-g;}});let h=0,n=()=>{let o=b(this,bt).now();if(this.ttlResolution>0){h=o;let l=setTimeout(()=>h=0,this.ttlResolution);l.unref&&l.unref();}return o};this.getRemainingTTL=o=>{let l=b(this,j).get(o);if(l===void 0)return 0;let a=t[l],u=i[l];if(!a||!u)return 1/0;let g=(h||n())-u;return a-g},d(this,at,o=>{let l=i[o],a=t[o];return !!a&&!!l&&(h||n())-l>a});},le=new WeakMap,Dt=new WeakMap,Ke=new WeakMap,at=new WeakMap,Or=function(){let t=new Ri(b(this,pt));d(this,St,0),d(this,Et,t),d(this,ae,i=>{d(this,St,b(this,St)-t[i]),t[i]=0;}),d(this,Ye,(i,s,h,n)=>{if(e(this,y,M).call(this,s))return 0;if(!Gt(h))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(h=n(s,i),!Gt(h))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 h}),d(this,Ae,(i,s,h)=>{if(t[i]=s,b(this,ht)){let n=b(this,ht)-t[i];for(;b(this,St)>n;)e(this,y,Fi).call(this,true);}d(this,St,b(this,St)+t[i]),h&&(h.entrySize=s,h.totalCalculatedSize=b(this,St));});},ae=new WeakMap,Ae=new WeakMap,Ye=new WeakMap,It=function*({allowStale:t=this.allowStale}={}){if(b(this,_))for(let i=b(this,H);!(!e(this,y,ts).call(this,i)||((t||!b(this,at).call(this,i))&&(yield i),i===b(this,V)));)i=b(this,nt)[i];},Ht=function*({allowStale:t=this.allowStale}={}){if(b(this,_))for(let i=b(this,V);!(!e(this,y,ts).call(this,i)||((t||!b(this,at).call(this,i))&&(yield i),i===b(this,H)));)i=b(this,Y)[i];},ts=function(t){return t!==void 0&&b(this,j).get(b(this,P)[t])===t},Fi=function(t){var n;let i=b(this,V),s=b(this,P)[i],h=b(this,O)[i];return b(this,Vt)&&e(this,y,M).call(this,h)?h.__abortController.abort(new Error("evicted")):(b(this,kt)||b(this,X))&&(b(this,kt)&&((n=b(this,wt))==null||n.call(this,h,s,"evict")),b(this,X)&&b(this,q)?.push([h,s,"evict"])),b(this,ae).call(this,i),b(this,lt)?.[i]&&(clearTimeout(b(this,lt)[i]),b(this,lt)[i]=void 0),t&&(b(this,P)[i]=void 0,b(this,O)[i]=void 0,b(this,vt).push(i)),b(this,_)===1?(d(this,V,d(this,H,0)),b(this,vt).length=0):d(this,V,b(this,Y)[i]),b(this,j).delete(s),f(this,_)._--,i},Mi=function(t,i,s,h){let n=i===void 0?void 0:b(this,O)[i];if(e(this,y,M).call(this,n))return n;let o=new zi,{signal:l}=s;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let a={signal:o.signal,options:s,context:h},u=(b$1,x=false)=>{let{aborted:S}=o.signal,A=s.ignoreFetchAbort&&b$1!==void 0,T=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&b$1!==void 0);if(s.status&&(S&&!x?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,A&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!A&&!x)return f(o.signal.reason,T);let R=E,F=b(this,O)[i];return (F===E||A&&x&&F===void 0)&&(b$1===void 0?R.__staleWhileFetching!==void 0?b(this,O)[i]=R.__staleWhileFetching:e(this,y,qt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,b$1,a.options))),b$1},g=b=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=b),f(b,false)),f=(b$1,x)=>{let{aborted:S}=o.signal,A=S&&s.allowStaleOnFetchAbort,T=A||s.allowStaleOnFetchRejection,R=T||s.noDeleteOnFetchRejection,F=E;if(b(this,O)[i]===E&&(!R||!x&&F.__staleWhileFetching===void 0?e(this,y,qt).call(this,t,"fetch"):A||(b(this,O)[i]=F.__staleWhileFetching)),T)return s.status&&F.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),F.__staleWhileFetching;if(F.__returned===F)throw b$1},w=(b$1,x)=>{var A;let S=(A=b(this,ke))==null?void 0:A.call(this,t,n,a);S&&S instanceof Promise&&S.then(T=>b$1(T===void 0?void 0:T),x),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(b$1(void 0),s.allowStaleOnFetchAbort&&(b$1=T=>u(T,true)));});};s.status&&(s.status.fetchDispatched=true);let E=new Promise(w).then(u,g),v=Object.assign(E,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(t,v,{...a.options,status:void 0}),i=b(this,j).get(t)):b(this,O)[i]=v,v},M=function(t){if(!b(this,Vt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof zi},es=function(t,i){b(this,nt)[i]=t,b(this,Y)[t]=i;},Ge=function(t){t!==b(this,H)&&(t===b(this,V)?d(this,V,b(this,Y)[t]):e(this,y,es).call(this,b(this,nt)[t],b(this,Y)[t]),e(this,y,es).call(this,b(this,H),t),d(this,H,t));},qt=function(t,i){var h,n;let s=false;if(b(this,_)!==0){let o=b(this,j).get(t);if(o!==void 0)if(b(this,lt)?.[o]&&(clearTimeout(b(this,lt)?.[o]),b(this,lt)[o]=void 0),s=true,b(this,_)===1)e(this,y,is).call(this,i);else {b(this,ae).call(this,o);let l=b(this,O)[o];if(e(this,y,M).call(this,l)?l.__abortController.abort(new Error("deleted")):(b(this,kt)||b(this,X))&&(b(this,kt)&&((h=b(this,wt))==null||h.call(this,l,t,i)),b(this,X)&&b(this,q)?.push([l,t,i])),b(this,j).delete(t),b(this,P)[o]=void 0,b(this,O)[o]=void 0,o===b(this,H))d(this,H,b(this,nt)[o]);else if(o===b(this,V))d(this,V,b(this,Y)[o]);else {let a=b(this,nt)[o];b(this,Y)[a]=b(this,Y)[o];let u=b(this,Y)[o];b(this,nt)[u]=b(this,nt)[o];}f(this,_)._--,b(this,vt).push(o);}}if(b(this,X)&&b(this,q)?.length){let o=b(this,q),l;for(;l=o?.shift();)(n=b(this,yt))==null||n.call(this,...l);}return s},is=function(t){var i,s;for(let h of e(this,y,Ht).call(this,{allowStale:true})){let n=b(this,O)[h];if(e(this,y,M).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=b(this,P)[h];b(this,kt)&&((i=b(this,wt))==null||i.call(this,n,o,t)),b(this,X)&&b(this,q)?.push([n,o,t]);}}if(b(this,j).clear(),b(this,O).fill(void 0),b(this,P).fill(void 0),b(this,ot)&&b(this,xt)){b(this,ot).fill(0),b(this,xt).fill(0);for(let h of b(this,lt)??[])h!==void 0&&clearTimeout(h);b(this,lt)?.fill(void 0);}if(b(this,Et)&&b(this,Et).fill(0),d(this,V,0),d(this,H,0),b(this,vt).length=0,d(this,St,0),d(this,_,0),b(this,X)&&b(this,q)){let h=b(this,q),n;for(;n=h?.shift();)(s=b(this,yt))==null||s.call(this,...n);}},Te),ks=typeof process=="object"&&process?process:{stdout:null,stderr:null},Sn=e=>!!e&&typeof e=="object"&&(e instanceof _i||e instanceof Ar||vn(e)||En(e)),vn=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Ar.Writable.prototype.pipe,En=e=>!!e&&typeof e=="object"&&e instanceof EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Wt=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Ut=Symbol("emittedEnd"),vi=Symbol("emittingEnd"),ze=Symbol("emittedError"),Ei=Symbol("closed"),Cs=Symbol("read"),xi=Symbol("flush"),Os=Symbol("flushChunk"),gt=Symbol("encoding"),Se=Symbol("decoder"),B=Symbol("flowing"),_e=Symbol("paused"),ve=Symbol("resume"),U=Symbol("buffer"),K=Symbol("pipes"),G=Symbol("bufferLength"),Ii=Symbol("bufferPush"),ki=Symbol("bufferShift"),J=Symbol("objectMode"),L=Symbol("destroyed"),Hi=Symbol("error"),qi=Symbol("emitData"),As=Symbol("emitEnd"),Zi=Symbol("emitEnd2"),Ot=Symbol("async"),Ji=Symbol("abort"),Ci=Symbol("aborted"),Ne=Symbol("signal"),ie=Symbol("dataListeners"),rt=Symbol("discarded"),$e=e=>Promise.resolve().then(e),xn=e=>e(),kn=e=>e==="end"||e==="finish"||e==="prefinish",Cn=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,On=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Tr=class{constructor(e,t,i){a(this,"src");a(this,"dest");a(this,"opts");a(this,"ondrain");this.src=e,this.dest=t,this.opts=i,this.ondrain=()=>e[ve](),this.dest.on("drain",this.ondrain);}unpipe(){this.dest.removeListener("drain",this.ondrain);}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end();}},An=class extends Tr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe();}constructor(e,t,i){super(e,t,i),this.proxyErrors=s=>this.dest.emit("error",s),e.on("error",this.proxyErrors);}},Tn=e=>!!e.objectMode,Rn=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Bs,Us,Gs,Is,Hs,qs,Zs,Js,Vs,Ks,Ys,Xs,Qs,tr,er,ir,sr,rr,hr,_i=class extends EventEmitter{constructor(...t){let i=t[0]||{};super();a(this,hr,false);a(this,rr,false);a(this,sr,[]);a(this,ir,[]);a(this,er);a(this,tr);a(this,Qs);a(this,Xs);a(this,Ys,false);a(this,Ks,false);a(this,Vs,false);a(this,Js,false);a(this,Zs,null);a(this,qs,0);a(this,Hs,false);a(this,Is);a(this,Gs,false);a(this,Us,0);a(this,Bs,false);a(this,"writable",true);a(this,"readable",true);if(i.objectMode&&typeof i.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Tn(i)?(this[J]=true,this[gt]=null):Rn(i)?(this[gt]=i.encoding,this[J]=false):(this[J]=false,this[gt]=null),this[Ot]=!!i.async,this[Se]=this[gt]?new StringDecoder(this[gt]):null,i&&i.debugExposeBuffer===true&&Object.defineProperty(this,"buffer",{get:()=>this[U]}),i&&i.debugExposePipes===true&&Object.defineProperty(this,"pipes",{get:()=>this[K]});let{signal:s}=i;s&&(this[Ne]=s,s.aborted?this[Ji]():s.addEventListener("abort",()=>this[Ji]()));}get bufferLength(){return this[G]}get encoding(){return this[gt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[J]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ot]}set async(t){this[Ot]=this[Ot]||!!t;}[(hr=B,rr=_e,sr=K,ir=U,er=J,tr=gt,Qs=Ot,Xs=Se,Ys=Wt,Ks=Ut,Vs=vi,Js=Ei,Zs=ze,qs=G,Hs=L,Is=Ne,Gs=Ci,Us=ie,Bs=rt,Ji)](){this[Ci]=true,this.emit("abort",this[Ne]?.reason),this.destroy(this[Ne]?.reason);}get aborted(){return this[Ci]}set aborted(t){}write(t,i,s){if(this[Ci])return false;if(this[Wt])throw new Error("write after end");if(this[L])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),true;typeof i=="function"&&(s=i,i="utf8"),i||(i="utf8");let h=this[Ot]?$e:xn;if(!this[J]&&!Buffer.isBuffer(t)){if(On(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Cn(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[J]?(this[B]&&this[G]!==0&&this[xi](true),this[B]?this.emit("data",t):this[Ii](t),this[G]!==0&&this.emit("readable"),s&&h(s),this[B]):t.length?(typeof t=="string"&&!(i===this[gt]&&!this[Se]?.lastNeed)&&(t=Buffer.from(t,i)),Buffer.isBuffer(t)&&this[gt]&&(t=this[Se].write(t)),this[B]&&this[G]!==0&&this[xi](true),this[B]?this.emit("data",t):this[Ii](t),this[G]!==0&&this.emit("readable"),s&&h(s),this[B]):(this[G]!==0&&this.emit("readable"),s&&h(s),this[B])}read(t){if(this[L])return null;if(this[rt]=false,this[G]===0||t===0||t&&t>this[G])return this[Pt](),null;this[J]&&(t=null),this[U].length>1&&!this[J]&&(this[U]=[this[gt]?this[U].join(""):Buffer.concat(this[U],this[G])]);let i=this[Cs](t||null,this[U][0]);return this[Pt](),i}[Cs](t,i){if(this[J])this[ki]();else {let s=i;t===s.length||t===null?this[ki]():typeof s=="string"?(this[U][0]=s.slice(t),i=s.slice(0,t),this[G]-=t):(this[U][0]=s.subarray(t),i=s.subarray(0,t),this[G]-=t);}return this.emit("data",i),!this[U].length&&!this[Wt]&&this.emit("drain"),i}end(t,i,s){return typeof t=="function"&&(s=t,t=void 0),typeof i=="function"&&(s=i,i="utf8"),t!==void 0&&this.write(t,i),s&&this.once("end",s),this[Wt]=true,this.writable=false,(this[B]||!this[_e])&&this[Pt](),this}[ve](){this[L]||(!this[ie]&&!this[K].length&&(this[rt]=true),this[_e]=false,this[B]=true,this.emit("resume"),this[U].length?this[xi]():this[Wt]?this[Pt]():this.emit("drain"));}resume(){return this[ve]()}pause(){this[B]=false,this[_e]=true,this[rt]=false;}get destroyed(){return this[L]}get flowing(){return this[B]}get paused(){return this[_e]}[Ii](t){this[J]?this[G]+=1:this[G]+=t.length,this[U].push(t);}[ki](){return this[J]?this[G]-=1:this[G]-=this[U][0].length,this[U].shift()}[xi](t=false){do;while(this[Os](this[ki]())&&this[U].length);!t&&!this[U].length&&!this[Wt]&&this.emit("drain");}[Os](t){return this.emit("data",t),this[B]}pipe(t,i){if(this[L])return t;this[rt]=false;let s=this[Ut];return i=i||{},t===ks.stdout||t===ks.stderr?i.end=false:i.end=i.end!==false,i.proxyErrors=!!i.proxyErrors,s?i.end&&t.end():(this[K].push(i.proxyErrors?new An(this,t,i):new Tr(this,t,i)),this[Ot]?$e(()=>this[ve]()):this[ve]()),t}unpipe(t){let i=this[K].find(s=>s.dest===t);i&&(this[K].length===1?(this[B]&&this[ie]===0&&(this[B]=false),this[K]=[]):this[K].splice(this[K].indexOf(i),1),i.unpipe());}addListener(t,i){return this.on(t,i)}on(t,i){let s=super.on(t,i);if(t==="data")this[rt]=false,this[ie]++,!this[K].length&&!this[B]&&this[ve]();else if(t==="readable"&&this[G]!==0)super.emit("readable");else if(kn(t)&&this[Ut])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ze]){let h=i;this[Ot]?$e(()=>h.call(this,this[ze])):h.call(this,this[ze]);}return s}removeListener(t,i){return this.off(t,i)}off(t,i){let s=super.off(t,i);return t==="data"&&(this[ie]=this.listeners("data").length,this[ie]===0&&!this[rt]&&!this[K].length&&(this[B]=false)),s}removeAllListeners(t){let i=super.removeAllListeners(t);return (t==="data"||t===void 0)&&(this[ie]=0,!this[rt]&&!this[K].length&&(this[B]=false)),i}get emittedEnd(){return this[Ut]}[Pt](){!this[vi]&&!this[Ut]&&!this[L]&&this[U].length===0&&this[Wt]&&(this[vi]=true,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ei]&&this.emit("close"),this[vi]=false);}emit(t,...i){let s=i[0];if(t!=="error"&&t!=="close"&&t!==L&&this[L])return false;if(t==="data")return !this[J]&&!s?false:this[Ot]?($e(()=>this[qi](s)),true):this[qi](s);if(t==="end")return this[As]();if(t==="close"){if(this[Ei]=true,!this[Ut]&&!this[L])return false;let n=super.emit("close");return this.removeAllListeners("close"),n}else if(t==="error"){this[ze]=s,super.emit(Hi,s);let n=!this[Ne]||this.listeners("error").length?super.emit("error",s):false;return this[Pt](),n}else if(t==="resume"){let n=super.emit("resume");return this[Pt](),n}else if(t==="finish"||t==="prefinish"){let n=super.emit(t);return this.removeAllListeners(t),n}let h=super.emit(t,...i);return this[Pt](),h}[qi](t){for(let s of this[K])s.dest.write(t)===false&&this.pause();let i=this[rt]?false:super.emit("data",t);return this[Pt](),i}[As](){return this[Ut]?false:(this[Ut]=true,this.readable=false,this[Ot]?($e(()=>this[Zi]()),true):this[Zi]())}[Zi](){if(this[Se]){let i=this[Se].end();if(i){for(let s of this[K])s.dest.write(i);this[rt]||super.emit("data",i);}}for(let i of this[K])i.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[J]||(t.dataLength=0);let i=this.promise();return this.on("data",s=>{t.push(s),this[J]||(t.dataLength+=s.length);}),await i,t}async concat(){if(this[J])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[gt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,i)=>{this.on(L,()=>i(new Error("stream destroyed"))),this.on("error",s=>i(s)),this.on("end",()=>t());})}[Symbol.asyncIterator](){this[rt]=false;let t=false,i=async()=>(this.pause(),t=true,{value:void 0,done:true});return {next:()=>{if(t)return i();let s=this.read();if(s!==null)return Promise.resolve({done:false,value:s});if(this[Wt])return i();let h,n,o=g=>{this.off("data",l),this.off("end",a),this.off(L,u),i(),n(g);},l=g=>{this.off("error",o),this.off("end",a),this.off(L,u),this.pause(),h({value:g,done:!!this[Wt]});},a=()=>{this.off("error",o),this.off("data",l),this.off(L,u),i(),h({done:true,value:void 0});},u=()=>o(new Error("stream destroyed"));return new Promise((g,f)=>{n=f,h=g,this.once(L,u),this.once("error",o),this.once("end",a),this.once("data",l);})},throw:i,return:i,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[rt]=false;let t=false,i=()=>(this.pause(),this.off(Hi,i),this.off(L,i),this.off("end",i),t=true,{done:true,value:void 0}),s=()=>{if(t)return i();let h=this.read();return h===null?i():{done:false,value:h}};return this.once("end",i),this.once(Hi,i),this.once(L,i),{next:s,throw:i,return:i,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[L])return t?this.emit("error",t):this.emit(L),this;this[L]=true,this[rt]=true,this[U].length=0,this[G]=0;let i=this;return typeof i.close=="function"&&!this[Ei]&&i.close(),t?this.emit("error",t):this.emit(L),this}static get isStream(){return Sn}},Fn=realpathSync.native,Ie={lstatSync:lstatSync,readdir:readdir$1,readdirSync:readdirSync,readlinkSync:readlinkSync,realpathSync:Fn,promises:{lstat:lstat,readdir:readdir,readlink:readlink,realpath:realpath}},Rr=e=>!e||e===Ie||e===dn?Ie:{...Ie,...e,promises:{...Ie.promises,...e.promises||{}}},Fr=/^\\\\\?\\([a-z]:)\\?$/i,Mn=e=>e.replace(/\//g,"\\").replace(Fr,"$1\\"),Wn=/[\\\/]/,ft=0,Mr=1,Wr=2,At=4,Pr=6,Lr=8,se=10,Dr=12,ut=15,Be=~ut,Vi=16,Ts=32,He=64,mt=128,Oi=256,Wi=512,Rs=He|mt|Wi,Pn=1023,Ki=e=>e.isFile()?Lr:e.isDirectory()?At:e.isSymbolicLink()?se:e.isCharacterDevice()?Wr:e.isBlockDevice()?Pr:e.isSocket()?Dr:e.isFIFO()?Mr:ft,Fs=new Ni({max:2**12}),qe=e=>{let t=Fs.get(e);if(t)return t;let i=e.normalize("NFKD");return Fs.set(e,i),i},Ms=new Ni({max:2**12}),Ai=e=>{let t=Ms.get(e);if(t)return t;let i=qe(e.toLowerCase());return Ms.set(e,i),i},Ws=class extends Ni{constructor(){super({max:256});}},Ln=class extends Ni{constructor(e=16*1024){super({maxSize:e,sizeCalculation:t=>t.length+1});}},jr=Symbol("PathScurry setAsCwd"),Q,Xe,Qe,ti,ei,ii,si,ri,hi,ni,oi,li,ai,ci,ui,pi,fi,di,gi,Kt,ce,Rt,jt,zt,_t,C,ue,Nt,Ft,k,rs,Pi,Ze,hs,ns,Je,Li,os,ls,Di,zr,_r,Nr,as,Re,Fe,$r,pe,nr,it=(nr=class{constructor(e,t=ft,i,s,h,n,o){c(this,k);a(this,"name");a(this,"root");a(this,"roots");a(this,"parent");a(this,"nocase");a(this,"isCWD",false);c(this,Q);c(this,Xe);c(this,Qe);c(this,ti);c(this,ei);c(this,ii);c(this,si);c(this,ri);c(this,hi);c(this,ni);c(this,oi);c(this,li);c(this,ai);c(this,ci);c(this,ui);c(this,pi);c(this,fi);c(this,di);c(this,gi);c(this,Kt);c(this,ce);c(this,Rt);c(this,jt);c(this,zt);c(this,_t);c(this,C);c(this,ue);c(this,Nt);c(this,Ft);c(this,Re,[]);c(this,Fe,false);c(this,pe);this.name=e,d(this,Kt,h?Ai(e):qe(e)),d(this,C,t&Pn),this.nocase=h,this.roots=s,this.root=i||this,d(this,ue,n),d(this,Rt,o.fullpath),d(this,zt,o.relative),d(this,_t,o.relativePosix),this.parent=o.parent,this.parent?d(this,Q,b(this.parent,Q)):d(this,Q,Rr(o.fs));}get dev(){return b(this,Xe)}get mode(){return b(this,Qe)}get nlink(){return b(this,ti)}get uid(){return b(this,ei)}get gid(){return b(this,ii)}get rdev(){return b(this,si)}get blksize(){return b(this,ri)}get ino(){return b(this,hi)}get size(){return b(this,ni)}get blocks(){return b(this,oi)}get atimeMs(){return b(this,li)}get mtimeMs(){return b(this,ai)}get ctimeMs(){return b(this,ci)}get birthtimeMs(){return b(this,ui)}get atime(){return b(this,pi)}get mtime(){return b(this,fi)}get ctime(){return b(this,di)}get birthtime(){return b(this,gi)}get parentPath(){return (this.parent||this).fullpath()}get path(){return this.parentPath}depth(){return b(this,ce)!==void 0?b(this,ce):this.parent?d(this,ce,this.parent.depth()+1):d(this,ce,0)}childrenCache(){return b(this,ue)}resolve(e$1){var s;if(!e$1)return this;let t=this.getRootString(e$1),i=e$1.substring(t.length).split(this.splitSep);return t?e(s=this.getRoot(t),k,rs).call(s,i):e(this,k,rs).call(this,i)}children(){let e=b(this,ue).get(this);if(e)return e;let t=Object.assign([],{provisional:0});return b(this,ue).set(this,t),d(this,C,b(this,C)&~Vi),t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let i=this.children(),s=this.nocase?Ai(e):qe(e);for(let l of i)if(b(l,Kt)===s)return l;let h=this.parent?this.sep:"",n=b(this,Rt)?b(this,Rt)+h+e:void 0,o=this.newChild(e,ft,{...t,parent:this,fullpath:n});return this.canReaddir()||d(o,C,b(o,C)|mt),i.push(o),o}relative(){if(this.isCWD)return "";if(b(this,zt)!==void 0)return b(this,zt);let e=this.name,t=this.parent;if(!t)return d(this,zt,this.name);let i=t.relative();return i+(!i||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return "";if(b(this,_t)!==void 0)return b(this,_t);let e=this.name,t=this.parent;if(!t)return d(this,_t,this.fullpathPosix());let i=t.relativePosix();return i+(!i||!t.parent?"":"/")+e}fullpath(){if(b(this,Rt)!==void 0)return b(this,Rt);let e=this.name,t=this.parent;if(!t)return d(this,Rt,this.name);let i=t.fullpath()+(t.parent?this.sep:"")+e;return d(this,Rt,i)}fullpathPosix(){if(b(this,jt)!==void 0)return b(this,jt);if(this.sep==="/")return d(this,jt,this.fullpath());if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return /^[a-z]:\//i.test(s)?d(this,jt,`//?/${s}`):d(this,jt,s)}let e=this.parent,t=e.fullpathPosix(),i=t+(!t||!e.parent?"":"/")+this.name;return d(this,jt,i)}isUnknown(){return (b(this,C)&ut)===ft}isType(e){return this[`is${e}`]()}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 (b(this,C)&ut)===Lr}isDirectory(){return (b(this,C)&ut)===At}isCharacterDevice(){return (b(this,C)&ut)===Wr}isBlockDevice(){return (b(this,C)&ut)===Pr}isFIFO(){return (b(this,C)&ut)===Mr}isSocket(){return (b(this,C)&ut)===Dr}isSymbolicLink(){return (b(this,C)&se)===se}lstatCached(){return b(this,C)&Ts?this:void 0}readlinkCached(){return b(this,Nt)}realpathCached(){return b(this,Ft)}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(b(this,Nt))return true;if(!this.parent)return false;let e=b(this,C)&ut;return !(e!==ft&&e!==se||b(this,C)&Oi||b(this,C)&mt)}calledReaddir(){return !!(b(this,C)&Vi)}isENOENT(){return !!(b(this,C)&mt)}isNamed(e){return this.nocase?b(this,Kt)===Ai(e):b(this,Kt)===qe(e)}async readlink(){let e$1=b(this,Nt);if(e$1)return e$1;if(this.canReadlink()&&this.parent)try{let t=await b(this,Q).promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(t);if(i)return d(this,Nt,i)}catch(t){e(this,k,ls).call(this,t.code);return}}readlinkSync(){let e$1=b(this,Nt);if(e$1)return e$1;if(this.canReadlink()&&this.parent)try{let t=b(this,Q).readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(t);if(i)return d(this,Nt,i)}catch(t){e(this,k,ls).call(this,t.code);return}}async lstat(){if((b(this,C)&mt)===0)try{return e(this,k,as).call(this,await b(this,Q).promises.lstat(this.fullpath())),this}catch(e$1){e(this,k,os).call(this,e$1.code);}}lstatSync(){if((b(this,C)&mt)===0)try{return e(this,k,as).call(this,b(this,Q).lstatSync(this.fullpath())),this}catch(e$1){e(this,k,os).call(this,e$1.code);}}readdirCB(e$1,t=false){if(!this.canReaddir()){t?e$1(null,[]):queueMicrotask(()=>e$1(null,[]));return}let i=this.children();if(this.calledReaddir()){let h=i.slice(0,i.provisional);t?e$1(null,h):queueMicrotask(()=>e$1(null,h));return}if(b(this,Re).push(e$1),b(this,Fe))return;d(this,Fe,true);let s=this.fullpath();b(this,Q).readdir(s,{withFileTypes:true},(h,n)=>{if(h)e(this,k,Li).call(this,h.code),i.provisional=0;else {for(let o of n)e(this,k,Di).call(this,o,i);e(this,k,Pi).call(this,i);}e(this,k,$r).call(this,i.slice(0,i.provisional));});}async readdir(){if(!this.canReaddir())return [];let e$1=this.children();if(this.calledReaddir())return e$1.slice(0,e$1.provisional);let t=this.fullpath();if(b(this,pe))await b(this,pe);else {let i=()=>{};d(this,pe,new Promise(s=>i=s));try{for(let s of await b(this,Q).promises.readdir(t,{withFileTypes:!0}))e(this,k,Di).call(this,s,e$1);e(this,k,Pi).call(this,e$1);}catch(s){e(this,k,Li).call(this,s.code),e$1.provisional=0;}d(this,pe,void 0),i();}return e$1.slice(0,e$1.provisional)}readdirSync(){if(!this.canReaddir())return [];let e$1=this.children();if(this.calledReaddir())return e$1.slice(0,e$1.provisional);let t=this.fullpath();try{for(let i of b(this,Q).readdirSync(t,{withFileTypes:!0}))e(this,k,Di).call(this,i,e$1);e(this,k,Pi).call(this,e$1);}catch(i){e(this,k,Li).call(this,i.code),e$1.provisional=0;}return e$1.slice(0,e$1.provisional)}canReaddir(){if(b(this,C)&Rs)return false;let e=ut&b(this,C);return e===ft||e===At||e===se}shouldWalk(e,t){return (b(this,C)&At)===At&&!(b(this,C)&Rs)&&!e.has(this)&&(!t||t(this))}async realpath(){if(b(this,Ft))return b(this,Ft);if(!((Wi|Oi|mt)&b(this,C)))try{let e=await b(this,Q).promises.realpath(this.fullpath());return d(this,Ft,this.resolve(e))}catch{e(this,k,ns).call(this);}}realpathSync(){if(b(this,Ft))return b(this,Ft);if(!((Wi|Oi|mt)&b(this,C)))try{let e=b(this,Q).realpathSync(this.fullpath());return d(this,Ft,this.resolve(e))}catch{e(this,k,ns).call(this);}}[jr](e){if(e===this)return;e.isCWD=false,this.isCWD=true;let t=new Set([]),i=[],s=this;for(;s&&s.parent;)t.add(s),d(s,zt,i.join(this.sep)),d(s,_t,i.join("/")),s=s.parent,i.push("..");for(s=e;s&&s.parent&&!t.has(s);)d(s,zt,void 0),d(s,_t,void 0),s=s.parent;}},Q=new WeakMap,Xe=new WeakMap,Qe=new WeakMap,ti=new WeakMap,ei=new WeakMap,ii=new WeakMap,si=new WeakMap,ri=new WeakMap,hi=new WeakMap,ni=new WeakMap,oi=new WeakMap,li=new WeakMap,ai=new WeakMap,ci=new WeakMap,ui=new WeakMap,pi=new WeakMap,fi=new WeakMap,di=new WeakMap,gi=new WeakMap,Kt=new WeakMap,ce=new WeakMap,Rt=new WeakMap,jt=new WeakMap,zt=new WeakMap,_t=new WeakMap,C=new WeakMap,ue=new WeakMap,Nt=new WeakMap,Ft=new WeakMap,k=new WeakSet,rs=function(e){let t=this;for(let i of e)t=t.child(i);return t},Pi=function(e$1){var t;d(this,C,b(this,C)|Vi);for(let i=e$1.provisional;i<e$1.length;i++){let s=e$1[i];s&&e(t=s,k,Ze).call(t);}},Ze=function(){b(this,C)&mt||(d(this,C,(b(this,C)|mt)&Be),e(this,k,hs).call(this));},hs=function(){var t;let e$1=this.children();e$1.provisional=0;for(let i of e$1)e(t=i,k,Ze).call(t);},ns=function(){d(this,C,b(this,C)|Wi),e(this,k,Je).call(this);},Je=function(){if(b(this,C)&He)return;let e$1=b(this,C);(e$1&ut)===At&&(e$1&=Be),d(this,C,e$1|He),e(this,k,hs).call(this);},Li=function(e$1=""){e$1==="ENOTDIR"||e$1==="EPERM"?e(this,k,Je).call(this):e$1==="ENOENT"?e(this,k,Ze).call(this):this.children().provisional=0;},os=function(e$1=""){var t;e$1==="ENOTDIR"?e(t=this.parent,k,Je).call(t):e$1==="ENOENT"&&e(this,k,Ze).call(this);},ls=function(e$1=""){var i;let t=b(this,C);t|=Oi,e$1==="ENOENT"&&(t|=mt),(e$1==="EINVAL"||e$1==="UNKNOWN")&&(t&=Be),d(this,C,t),e$1==="ENOTDIR"&&this.parent&&e(i=this.parent,k,Je).call(i);},Di=function(e$1,t){return e(this,k,_r).call(this,e$1,t)||e(this,k,zr).call(this,e$1,t)},zr=function(e,t){let i=Ki(e),s=this.newChild(e.name,i,{parent:this}),h=b(s,C)&ut;return h!==At&&h!==se&&h!==ft&&d(s,C,b(s,C)|He),t.unshift(s),t.provisional++,s},_r=function(e$1,t){for(let i=t.provisional;i<t.length;i++){let s=t[i];if((this.nocase?Ai(e$1.name):qe(e$1.name))===b(s,Kt))return e(this,k,Nr).call(this,e$1,s,i,t)}},Nr=function(e,t,i,s){let h=t.name;return d(t,C,b(t,C)&Be|Ki(e)),h!==e.name&&(t.name=e.name),i!==s.provisional&&(i===s.length-1?s.pop():s.splice(i,1),s.unshift(t)),s.provisional++,t},as=function(e){let{atime:t,atimeMs:i,birthtime:s,birthtimeMs:h,blksize:n,blocks:o,ctime:l,ctimeMs:a,dev:u,gid:g,ino:f,mode:w,mtime:E,mtimeMs:v,nlink:b$1,rdev:x,size:S,uid:A}=e;d(this,pi,t),d(this,li,i),d(this,gi,s),d(this,ui,h),d(this,ri,n),d(this,oi,o),d(this,di,l),d(this,ci,a),d(this,Xe,u),d(this,ii,g),d(this,hi,f),d(this,Qe,w),d(this,fi,E),d(this,ai,v),d(this,ti,b$1),d(this,si,x),d(this,ni,S),d(this,ei,A);let T=Ki(e);d(this,C,b(this,C)&Be|T|Ts),T!==ft&&T!==At&&T!==se&&d(this,C,b(this,C)|He);},Re=new WeakMap,Fe=new WeakMap,$r=function(e){d(this,Fe,false);let t=b(this,Re).slice();b(this,Re).length=0,t.forEach(i=>i(null,e));},pe=new WeakMap,nr),Br=class Ur extends it{constructor(i,s=ft,h,n,o,l,a$1){super(i,s,h,n,o,l,a$1);a(this,"sep","\\");a(this,"splitSep",Wn);}newChild(i,s=ft,h={}){return new Ur(i,s,this.root,this.roots,this.nocase,this.childrenCache(),h)}getRootString(i){return win32.parse(i).root}getRoot(i){if(i=Mn(i.toUpperCase()),i===this.root.name)return this.root;for(let[s,h]of Object.entries(this.roots))if(this.sameRoot(i,s))return this.roots[i]=h;return this.roots[i]=new ds(i,this).root}sameRoot(i,s=this.root.name){return i=i.toUpperCase().replace(/\//g,"\\").replace(Fr,"$1\\"),i===s}},Gr=class Ir extends it{constructor(i,s=ft,h,n,o,l,a$1){super(i,s,h,n,o,l,a$1);a(this,"splitSep","/");a(this,"sep","/");}getRootString(i){return i.startsWith("/")?"/":""}getRoot(i){return this.root}newChild(i,s=ft,h={}){return new Ir(i,s,this.root,this.roots,this.nocase,this.childrenCache(),h)}},Me,We,mi,wi,or,Hr=(or=class{constructor(e=process.cwd(),t,i,{nocase:s,childrenCacheSize:h=16*1024,fs:n=Ie}={}){a(this,"root");a(this,"rootPath");a(this,"roots");a(this,"cwd");c(this,Me);c(this,We);c(this,mi);a(this,"nocase");c(this,wi);d(this,wi,Rr(n)),(e instanceof URL||e.startsWith("file://"))&&(e=fileURLToPath(e));let o=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),d(this,Me,new Ws),d(this,We,new Ws),d(this,mi,new Ln(h));let l=o.substring(this.rootPath.length).split(i);if(l.length===1&&!l[0]&&l.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(b(this,wi)),this.roots[this.rootPath]=this.root;let a$1=this.root,u=l.length-1,g=t.sep,f=this.rootPath,w=false;for(let E of l){let v=u--;a$1=a$1.child(E,{relative:new Array(v).fill("..").join(g),relativePosix:new Array(v).fill("..").join("/"),fullpath:f+=(w?"":g)+E}),w=true;}this.cwd=a$1;}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return b(this,mi)}resolve(...e){let t="";for(let h=e.length-1;h>=0;h--){let n=e[h];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let i=b(this,Me).get(t);if(i!==void 0)return i;let s=this.cwd.resolve(t).fullpath();return b(this,Me).set(t,s),s}resolvePosix(...e){let t="";for(let h=e.length-1;h>=0;h--){let n=e[h];if(!(!n||n===".")&&(t=t?`${n}/${t}`:n,this.isAbsolute(n)))break}let i=b(this,We).get(t);if(i!==void 0)return i;let s=this.cwd.resolve(t).fullpathPosix();return b(this,We).set(t,s),s}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i}=t;if(e.canReaddir()){let s=await e.readdir();return i?s:s.map(h=>h.name)}else return []}readdirSync(e=this.cwd,t={withFileTypes:true}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true}=t;return e.canReaddir()?i?e.readdirSync():e.readdirSync().map(s=>s.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e.withFileTypes,e=this.cwd);let i=await e.readlink();return t?i:i?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e.withFileTypes,e=this.cwd);let i=e.readlinkSync();return t?i:i?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e.withFileTypes,e=this.cwd);let i=await e.realpath();return t?i:i?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:false}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e.withFileTypes,e=this.cwd);let i=e.realpathSync();return t?i:i?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true,follow:s=false,filter:h,walkFilter:n}=t,o=[];(!h||h(e))&&o.push(i?e:e.fullpath());let l=new Set,a=(g,f)=>{l.add(g),g.readdirCB((w,E)=>{if(w)return f(w);let v=E.length;if(!v)return f();let b=()=>{--v===0&&f();};for(let x of E)(!h||h(x))&&o.push(i?x:x.fullpath()),s&&x.isSymbolicLink()?x.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(l,n)?a(S,b):b()):x.shouldWalk(l,n)?a(x,b):b();},true);},u=e;return new Promise((g,f)=>{a(u,w=>{if(w)return f(w);g(o);});})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true,follow:s=false,filter:h,walkFilter:n}=t,o=[];(!h||h(e))&&o.push(i?e:e.fullpath());let l=new Set([e]);for(let a of l){let u=a.readdirSync();for(let g of u){(!h||h(g))&&o.push(i?g:g.fullpath());let f=g;if(g.isSymbolicLink()){if(!(s&&(f=g.realpathSync())))continue;f.isUnknown()&&f.lstatSync();}f.shouldWalk(l,n)&&l.add(f);}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true,follow:s=false,filter:h,walkFilter:n}=t;(!h||h(e))&&(yield i?e:e.fullpath());let o=new Set([e]);for(let l of o){let a=l.readdirSync();for(let u of a){(!h||h(u))&&(yield i?u:u.fullpath());let g=u;if(u.isSymbolicLink()){if(!(s&&(g=u.realpathSync())))continue;g.isUnknown()&&g.lstatSync();}g.shouldWalk(o,n)&&o.add(g);}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true,follow:s=false,filter:h,walkFilter:n}=t,o=new _i({objectMode:true});(!h||h(e))&&o.write(i?e:e.fullpath());let l=new Set,a=[e],u=0,g=()=>{let f=false;for(;!f;){let w=a.shift();if(!w){u===0&&o.end();return}u++,l.add(w);let E=(b,x,S=false)=>{if(b)return o.emit("error",b);if(s&&!S){let A=[];for(let T of x)T.isSymbolicLink()&&A.push(T.realpath().then(R=>R?.isUnknown()?R.lstat():R));if(A.length){Promise.all(A).then(()=>E(null,x,true));return}}for(let A of x)A&&(!h||h(A))&&(o.write(i?A:A.fullpath())||(f=true));u--;for(let A of x){let T=A.realpathCached()||A;T.shouldWalk(l,n)&&a.push(T);}f&&!o.flowing?o.once("drain",g):v||g();},v=true;w.readdirCB(E,true),v=false;}};return g(),o}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof it||(t=e,e=this.cwd);let{withFileTypes:i=true,follow:s=false,filter:h,walkFilter:n}=t,o=new _i({objectMode:true}),l=new Set;(!h||h(e))&&o.write(i?e:e.fullpath());let a=[e],u=0,g=()=>{let f=false;for(;!f;){let w=a.shift();if(!w){u===0&&o.end();return}u++,l.add(w);let E=w.readdirSync();for(let v of E)(!h||h(v))&&(o.write(i?v:v.fullpath())||(f=true));u--;for(let v of E){let b=v;if(v.isSymbolicLink()){if(!(s&&(b=v.realpathSync())))continue;b.isUnknown()&&b.lstatSync();}b.shouldWalk(l,n)&&a.push(b);}}f&&!o.flowing&&o.once("drain",g);};return g(),o}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[jr](t);}},Me=new WeakMap,We=new WeakMap,mi=new WeakMap,wi=new WeakMap,or),ds=class extends Hr{constructor(t=process.cwd(),i={}){let{nocase:s=true}=i;super(t,win32,"\\",{...i,nocase:s});a(this,"sep","\\");this.nocase=s;for(let h=this.cwd;h;h=h.parent)h.nocase=this.nocase;}parseRootPath(t){return win32.parse(t).root.toUpperCase()}newRoot(t){return new Br(this.rootPath,At,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},gs=class extends Hr{constructor(t=process.cwd(),i={}){let{nocase:s=false}=i;super(t,posix,"/",{...i,nocase:s});a(this,"sep","/");this.nocase=s;}parseRootPath(t){return "/"}newRoot(t){return new Gr(this.rootPath,At,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},qr=class extends gs{constructor(e=process.cwd(),t={}){let{nocase:i=true}=t;super(e,{...t,nocase:i});}};process.platform==="win32"?Br:Gr;var Dn=process.platform==="win32"?ds:process.platform==="darwin"?qr:gs,jn=e=>e.length>=1,zn=e=>e.length>=1,_n=Symbol.for("nodejs.util.inspect.custom"),N,st,$,fe,Ct,yi,Yt,Xt,Qt,Pe,Le,Zr=(Le=class{constructor(t,i,s,h){c(this,N);c(this,st);c(this,$);a(this,"length");c(this,fe);c(this,Ct);c(this,yi);c(this,Yt);c(this,Xt);c(this,Qt);c(this,Pe,true);if(!jn(t))throw new TypeError("empty pattern list");if(!zn(i))throw new TypeError("empty glob list");if(i.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(d(this,N,t),d(this,st,i),d(this,$,s),d(this,fe,h),b(this,$)===0){if(this.isUNC()){let[n,o,l,a,...u]=b(this,N),[g,f,w,E,...v]=b(this,st);u[0]===""&&(u.shift(),v.shift());let b$1=[n,o,l,a,""].join("/"),x=[g,f,w,E,""].join("/");d(this,N,[b$1,...u]),d(this,st,[x,...v]),this.length=b(this,N).length;}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=b(this,N),[l,...a]=b(this,st);o[0]===""&&(o.shift(),a.shift());let u=n+"/",g=l+"/";d(this,N,[u,...o]),d(this,st,[g,...a]),this.length=b(this,N).length;}}}[_n](){return "Pattern <"+b(this,st).slice(b(this,$)).join("/")+">"}pattern(){return b(this,N)[b(this,$)]}isString(){return typeof b(this,N)[b(this,$)]=="string"}isGlobstar(){return b(this,N)[b(this,$)]===tt}isRegExp(){return b(this,N)[b(this,$)]instanceof RegExp}globString(){return d(this,yi,b(this,yi)||(b(this,$)===0?this.isAbsolute()?b(this,st)[0]+b(this,st).slice(1).join("/"):b(this,st).join("/"):b(this,st).slice(b(this,$)).join("/")))}hasMore(){return this.length>b(this,$)+1}rest(){return b(this,Ct)!==void 0?b(this,Ct):this.hasMore()?(d(this,Ct,new Le(b(this,N),b(this,st),b(this,$)+1,b(this,fe))),d(b(this,Ct),Qt,b(this,Qt)),d(b(this,Ct),Xt,b(this,Xt)),d(b(this,Ct),Yt,b(this,Yt)),b(this,Ct)):d(this,Ct,null)}isUNC(){let t=b(this,N);return b(this,Xt)!==void 0?b(this,Xt):d(this,Xt,b(this,fe)==="win32"&&b(this,$)===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3])}isDrive(){let t=b(this,N);return b(this,Yt)!==void 0?b(this,Yt):d(this,Yt,b(this,fe)==="win32"&&b(this,$)===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]))}isAbsolute(){let t=b(this,N);return b(this,Qt)!==void 0?b(this,Qt):d(this,Qt,t[0]===""&&t.length>1||this.isDrive()||this.isUNC())}root(){let t=b(this,N)[0];return typeof t=="string"&&this.isAbsolute()&&b(this,$)===0?t:""}checkFollowGlobstar(){return !(b(this,$)===0||!this.isGlobstar()||!b(this,Pe))}markFollowGlobstar(){return b(this,$)===0||!this.isGlobstar()||!b(this,Pe)?false:(d(this,Pe,false),true)}},N=new WeakMap,st=new WeakMap,$=new WeakMap,fe=new WeakMap,Ct=new WeakMap,yi=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Qt=new WeakMap,Pe=new WeakMap,Le),Nn=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ps=class{constructor(e,{nobrace:t,nocase:i,noext:s,noglobstar:h,platform:n=Nn}){a(this,"relative");a(this,"relativeChildren");a(this,"absolute");a(this,"absoluteChildren");a(this,"platform");a(this,"mmopts");this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:true,nobrace:t,nocase:i,noext:s,noglobstar:h,optimizationLevel:2,platform:n,nocomment:true,nonegate:true};for(let o of e)this.add(o);}add(e){let t=new ee(e,this.mmopts);for(let i=0;i<t.set.length;i++){let s=t.set[i],h=t.globParts[i];if(!s||!h)throw new Error("invalid pattern object");for(;s[0]==="."&&h[0]===".";)s.shift(),h.shift();let n=new Zr(s,h,0,this.platform),o=new ee(n.globString(),this.mmopts),l=h[h.length-1]==="**",a=n.isAbsolute();a?this.absolute.push(o):this.relative.push(o),l&&(a?this.absoluteChildren.push(o):this.relativeChildren.push(o));}}ignored(e){let t=e.fullpath(),i=`${t}/`,s=e.relative()||".",h=`${s}/`;for(let n of this.relative)if(n.match(s)||n.match(h))return true;for(let n of this.absolute)if(n.match(t)||n.match(i))return true;return false}childrenIgnored(e){let t=e.fullpath()+"/",i=(e.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(i))return true;for(let s of this.absoluteChildren)if(s.match(t))return true;return false}},$n=class Jr{constructor(t=new Map){a(this,"store");this.store=t;}copy(){return new Jr(new Map(this.store))}hasWalked(t,i){return this.store.get(t.fullpath())?.has(i.globString())}storeWalked(t,i){let s=t.fullpath(),h=this.store.get(s);h?h.add(i.globString()):this.store.set(s,new Set([i.globString()]));}},Bn=class{constructor(){a(this,"store",new Map);}add(e,t,i){let s=(t?2:0)|(i?1:0),h=this.store.get(e);this.store.set(e,h===void 0?s:s&h);}entries(){return [...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},Un=class{constructor(){a(this,"store",new Map);}add(e,t){if(!e.canReaddir())return;let i=this.store.get(e);i?i.find(s=>s.globString()===t.globString())||i.push(t):this.store.set(e,[t]);}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return [...this.store.keys()].filter(e=>e.canReaddir())}},Ls=class Vr{constructor(t,i){a(this,"hasWalkedCache");a(this,"matches",new Bn);a(this,"subwalks",new Un);a(this,"patterns");a(this,"follow");a(this,"dot");a(this,"opts");this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=i?i.copy():new $n;}processPatterns(t,i){this.patterns=i;let s=i.map(h=>[t,h]);for(let[h,n]of s){this.hasWalkedCache.storeWalked(h,n);let o=n.root(),l=n.isAbsolute()&&this.opts.absolute!==false;if(o){h=h.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let f=n.rest();if(f)n=f;else {this.matches.add(h,true,false);continue}}if(h.isENOENT())continue;let a,u,g=false;for(;typeof(a=n.pattern())=="string"&&(u=n.rest());)h=h.resolve(a),n=u,g=true;if(a=n.pattern(),u=n.rest(),g){if(this.hasWalkedCache.hasWalked(h,n))continue;this.hasWalkedCache.storeWalked(h,n);}if(typeof a=="string"){let f=a===".."||a===""||a===".";this.matches.add(h.resolve(a),l,f);continue}else if(a===tt){(!h.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(h,n);let f=u?.pattern(),w=u?.rest();if(!u||(f===""||f===".")&&!w)this.matches.add(h,l,f===""||f===".");else if(f===".."){let E=h.parent||h;w?this.hasWalkedCache.hasWalked(E,w)||this.subwalks.add(E,w):this.matches.add(E,l,true);}}else a instanceof RegExp&&this.subwalks.add(h,n);}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Vr(this.opts,this.hasWalkedCache)}filterEntries(t,i){let s=this.subwalks.get(t),h=this.child();for(let n of i)for(let o of s){let l=o.isAbsolute(),a=o.pattern(),u=o.rest();a===tt?h.testGlobstar(n,o,u,l):a instanceof RegExp?h.testRegExp(n,a,u,l):h.testString(n,a,u,l);}return h}testGlobstar(t,i,s,h){if((this.dot||!t.name.startsWith("."))&&(i.hasMore()||this.matches.add(t,h,false),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,i):t.isSymbolicLink()&&(s&&i.checkFollowGlobstar()?this.subwalks.add(t,s):i.markFollowGlobstar()&&this.subwalks.add(t,i)))),s){let n=s.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(t,n,s.rest(),h);else if(n===".."){let o=t.parent||t;this.subwalks.add(o,s);}else n instanceof RegExp&&this.testRegExp(t,n,s.rest(),h);}}testRegExp(t,i,s,h){i.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,h,false));}testString(t,i,s,h){t.isNamed(i)&&(s?this.subwalks.add(t,s):this.matches.add(t,h,false));}},Gn=(e,t)=>typeof e=="string"?new Ps([e],t):Array.isArray(e)?new Ps(e,t):e,De,$t,de,dt,re,cs,lr,Kr=(lr=class{constructor(e,t,i){c(this,dt);a(this,"path");a(this,"patterns");a(this,"opts");a(this,"seen",new Set);a(this,"paused",false);a(this,"aborted",false);c(this,De,[]);c(this,$t);c(this,de);a(this,"signal");a(this,"maxDepth");a(this,"includeChildMatches");if(this.patterns=e,this.path=t,this.opts=i,d(this,de,!i.posix&&i.platform==="win32"?"\\":"/"),this.includeChildMatches=i.includeChildMatches!==false,(i.ignore||!this.includeChildMatches)&&(d(this,$t,Gn(i.ignore??[],i)),!this.includeChildMatches&&typeof b(this,$t).add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{b(this,De).length=0;}));}pause(){this.paused=true;}resume(){if(this.signal?.aborted)return;this.paused=false;let e;for(;!this.paused&&(e=b(this,De).shift());)e();}onResume(e){this.signal?.aborted||(this.paused?b(this,De).push(e):e());}async matchCheck(e,t){if(t&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=e.realpathCached()||await e.realpath(),!i)return;e=i;}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let h=await s.realpath();h&&(h.isUnknown()||this.opts.stat)&&await h.lstat();}return this.matchCheckTest(s,t)}matchCheckTest(e$1,t){return e$1&&(this.maxDepth===1/0||e$1.depth()<=this.maxDepth)&&(!t||e$1.canReaddir())&&(!this.opts.nodir||!e$1.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e$1.isSymbolicLink()||!e$1.realpathCached()?.isDirectory())&&!e(this,dt,re).call(this,e$1)?e$1:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=e.realpathCached()||e.realpathSync(),!i)return;e=i;}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let h=s.realpathSync();h&&(h?.isUnknown()||this.opts.stat)&&h.lstatSync();}return this.matchCheckTest(s,t)}matchFinish(e$1,t){if(e(this,dt,re).call(this,e$1))return;if(!this.includeChildMatches&&b(this,$t)?.add){let h=`${e$1.relativePosix()}/**`;b(this,$t).add(h);}let i=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e$1);let s=this.opts.mark&&e$1.isDirectory()?b(this,de):"";if(this.opts.withFileTypes)this.matchEmit(e$1);else if(i){let h=this.opts.posix?e$1.fullpathPosix():e$1.fullpath();this.matchEmit(h+s);}else {let h=this.opts.posix?e$1.relativePosix():e$1.relative(),n=this.opts.dotRelative&&!h.startsWith(".."+b(this,de))?"."+b(this,de):"";this.matchEmit(h?n+h+s:"."+s);}}async match(e,t,i){let s=await this.matchCheck(e,i);s&&this.matchFinish(s,t);}matchSync(e,t,i){let s=this.matchCheckSync(e,i);s&&this.matchFinish(s,t);}walkCB(e,t,i){this.signal?.aborted&&i(),this.walkCB2(e,t,new Ls(this.opts),i);}walkCB2(e$1,t,i,s){if(e(this,dt,cs).call(this,e$1))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(e$1,t,i,s));return}i.processPatterns(e$1,t);let h=1,n=()=>{--h===0&&s();};for(let[o,l,a]of i.matches.entries())e(this,dt,re).call(this,o)||(h++,this.match(o,l,a).then(()=>n()));for(let o of i.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;h++;let l=o.readdirCached();o.calledReaddir()?this.walkCB3(o,l,i,n):o.readdirCB((a,u)=>this.walkCB3(o,u,i,n),true);}n();}walkCB3(e$1,t,i,s){i=i.filterEntries(e$1,t);let h=1,n=()=>{--h===0&&s();};for(let[o,l,a]of i.matches.entries())e(this,dt,re).call(this,o)||(h++,this.match(o,l,a).then(()=>n()));for(let[o,l]of i.subwalks.entries())h++,this.walkCB2(o,l,i.child(),n);n();}walkCBSync(e,t,i){this.signal?.aborted&&i(),this.walkCB2Sync(e,t,new Ls(this.opts),i);}walkCB2Sync(e$1,t,i,s){if(e(this,dt,cs).call(this,e$1))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(e$1,t,i,s));return}i.processPatterns(e$1,t);let h=1,n=()=>{--h===0&&s();};for(let[o,l,a]of i.matches.entries())e(this,dt,re).call(this,o)||this.matchSync(o,l,a);for(let o of i.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;h++;let l=o.readdirSync();this.walkCB3Sync(o,l,i,n);}n();}walkCB3Sync(e$1,t,i,s){i=i.filterEntries(e$1,t);let h=1,n=()=>{--h===0&&s();};for(let[o,l,a]of i.matches.entries())e(this,dt,re).call(this,o)||this.matchSync(o,l,a);for(let[o,l]of i.subwalks.entries())h++,this.walkCB2Sync(o,l,i.child(),n);n();}},De=new WeakMap,$t=new WeakMap,de=new WeakMap,dt=new WeakSet,re=function(e){return this.seen.has(e)||!!b(this,$t)?.ignored?.(e)},cs=function(e){return !!b(this,$t)?.childrenIgnored?.(e)},lr),Ds=class extends Kr{constructor(t,i,s){super(t,i,s);a(this,"matches",new Set);}matchEmit(t){this.matches.add(t);}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,i)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?i(this.signal.reason):t(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}},js=class extends Kr{constructor(t,i,s){super(t,i,s);a(this,"results");this.results=new _i({signal:this.signal,objectMode:true}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume());}matchEmit(t){this.results.write(t),this.results.flowing||this.pause();}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end());}):this.walkCB(t,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}},In=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",me=class{constructor(e,t){a(this,"absolute");a(this,"cwd");a(this,"root");a(this,"dot");a(this,"dotRelative");a(this,"follow");a(this,"ignore");a(this,"magicalBraces");a(this,"mark");a(this,"matchBase");a(this,"maxDepth");a(this,"nobrace");a(this,"nocase");a(this,"nodir");a(this,"noext");a(this,"noglobstar");a(this,"pattern");a(this,"platform");a(this,"realpath");a(this,"scurry");a(this,"stat");a(this,"signal");a(this,"windowsPathsNoEscape");a(this,"withFileTypes");a(this,"includeChildMatches");a(this,"opts");a(this,"patterns");if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=fileURLToPath(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==false,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===false,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`);}if(this.pattern=e,this.platform=t.platform||In,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else {let l=t.platform==="win32"?ds:t.platform==="darwin"?qr:t.platform?gs:Dn;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs});}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",s={braceExpandMax:1e4,...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:true,noext:this.noext,nonegate:true,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},h=this.pattern.map(l=>new ee(l,s)),[n,o]=h.reduce((l,a)=>(l[0].push(...a.set),l[1].push(...a.globParts),l),[[],[]]);this.patterns=n.map((l,a)=>{let u=o[a];if(!u)throw new Error("invalid pattern object");return new Zr(l,u,0,this.platform)});}async walk(){return [...await new Ds(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 Ds(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 js(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 js(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()}},Hn=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let i of e)if(new ee(i,t).hasMagic())return true;return false};function $i(e,t={}){return new me(e,t).streamSync()}function Yr(e,t={}){return new me(e,t).stream()}function Xr(e,t={}){return new me(e,t).walkSync()}async function zs(e,t={}){return new me(e,t).walk()}function Bi(e,t={}){return new me(e,t).iterateSync()}function Qr(e,t={}){return new me(e,t).iterate()}var qn=$i,Zn=Object.assign(Yr,{sync:$i}),Jn=Bi,Vn=Object.assign(Qr,{sync:Bi}),Kn=Object.assign(Xr,{stream:$i,iterate:Bi}),_s=Object.assign(zs,{glob:zs,globSync:Xr,sync:Kn,globStream:Yr,stream:Zn,globStreamSync:$i,streamSync:qn,globIterate:Qr,iterate:Vn,globIterateSync:Bi,iterateSync:Jn,Glob:me,hasMagic:Hn,escape:yr,unescape:Ee});_s.glob=_s;
|
|
4
|
+
export{me as Glob,Ps as Ignore,yr as escape,_s as glob,Qr as globIterate,Bi as globIterateSync,Yr as globStream,$i as globStreamSync,Xr as globSync,Hn as hasMagic,Vn as iterate,Jn as iterateSync,Zn as stream,qn as streamSync,Kn as sync,Ee as unescape};
|