@isdk/ai-tool 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-JHHFTTVE.mjs +1 -0
- package/dist/funcs.d.mts +1 -1
- package/dist/funcs.d.ts +1 -1
- package/dist/funcs.js +1 -1
- package/dist/funcs.mjs +1 -1
- package/dist/{index-DUEs7T8M.d.mts → index-BC3GQn6-.d.mts} +7 -0
- package/dist/{index-DUEs7T8M.d.ts → index-BC3GQn6-.d.ts} +7 -0
- package/dist/index.d.mts +411 -10
- package/dist/index.d.ts +411 -10
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/test/util.mjs +1 -1
- package/docs/classes/AbortError.md +45 -15
- package/docs/classes/AlreadyExistsError.md +45 -15
- package/docs/classes/BaseError.md +42 -16
- package/docs/classes/CancelableAbility.md +20 -20
- package/docs/classes/ClientTools.md +93 -93
- package/docs/classes/CommonError.md +45 -15
- package/docs/classes/EventClient.md +115 -115
- package/docs/classes/EventServer.md +117 -117
- package/docs/classes/EventToolFunc.md +85 -85
- package/docs/classes/FStringPromptTemplate.md +18 -18
- package/docs/classes/FewShotPromptTemplate.md +22 -22
- package/docs/classes/GolangPromptTemplate.md +18 -18
- package/docs/classes/HFEnvironment.md +9 -9
- package/docs/classes/HFInterpreter.md +4 -4
- package/docs/classes/HFTemplate.md +4 -4
- package/docs/classes/HfPromptTemplate.md +18 -18
- package/docs/classes/IntSet.md +11 -11
- package/docs/classes/NotFoundError.md +45 -15
- package/docs/classes/NotImplementationError.md +45 -15
- package/docs/classes/PromptExampleSelector.md +8 -8
- package/docs/classes/PromptTemplate.md +17 -17
- package/docs/classes/ReadableStreamError.md +45 -15
- package/docs/classes/ResClientTools.md +100 -100
- package/docs/classes/ResServerTools.md +101 -101
- package/docs/classes/SSEChannel.md +14 -14
- package/docs/classes/Semaphore.md +8 -8
- package/docs/classes/ServerTools.md +89 -89
- package/docs/classes/TaskAbortController.md +8 -8
- package/docs/classes/ToolFunc.md +82 -82
- package/docs/classes/YamlTypeBaseObject.md +29 -0
- package/docs/enumerations/AsyncFeatureBits.md +3 -3
- package/docs/enumerations/AsyncFeatures.md +3 -3
- package/docs/enumerations/ErrorCode.md +21 -21
- package/docs/enumerations/HashAlgorithm.md +117 -0
- package/docs/functions/AIArgProcessor.md +1 -1
- package/docs/functions/AIStream.md +1 -1
- package/docs/functions/ChoiceArgProcessor.md +1 -1
- package/docs/functions/RateLimit.md +1 -1
- package/docs/functions/TemplateArgProcessor.md +1 -1
- package/docs/functions/backendEventable.md +1 -1
- package/docs/functions/completeSentences.md +23 -0
- package/docs/functions/concatText.md +23 -0
- package/docs/functions/countLLMTokens.md +23 -0
- package/docs/functions/countRegexMatches.md +1 -1
- package/docs/functions/createCallbacksTransformer.md +1 -1
- package/docs/functions/createEmptyReadableStream.md +1 -1
- package/docs/functions/createEndWithRepetitionDetector.md +1 -1
- package/docs/functions/createError.md +1 -1
- package/docs/functions/createEventStreamTransformer.md +1 -1
- package/docs/functions/createHfValueFunc.md +1 -1
- package/docs/functions/createLRUCache.md +1 -1
- package/docs/functions/createYamlObjectTag.md +23 -0
- package/docs/functions/dateToText.md +1 -1
- package/docs/functions/decodeCharset.md +23 -0
- package/docs/functions/detectCharset.md +23 -0
- package/docs/functions/encodeLLMTokens.md +23 -0
- package/docs/functions/expandEnv.md +1 -1
- package/docs/functions/expandObjEnv.md +1 -1
- package/docs/functions/extNameLevel.md +1 -1
- package/docs/functions/fileIsExists.md +1 -1
- package/docs/functions/filenameReservedRegex.md +1 -1
- package/docs/functions/filterValidFnScope.md +1 -1
- package/docs/functions/findIndexNonEmptyFrom.md +23 -0
- package/docs/functions/findPort.md +1 -1
- package/docs/functions/formatTextWithSpace.md +59 -0
- package/docs/functions/getAllEnumKeys.md +1 -1
- package/docs/functions/getConfigFileNames.md +1 -1
- package/docs/functions/getConfigs.md +1 -1
- package/docs/functions/getFileMetaInfo.md +21 -0
- package/docs/functions/getHashAlgoBySize.md +21 -0
- package/docs/functions/getKeysPath.md +1 -1
- package/docs/functions/getLLMTokenizer.md +21 -0
- package/docs/functions/getMultiLevelExtname.md +1 -1
- package/docs/functions/getPackageDir.md +1 -1
- package/docs/functions/getRealFilepath.md +1 -1
- package/docs/functions/getResponseErrorReadableStream.md +1 -1
- package/docs/functions/hasDirectoryIn.md +1 -1
- package/docs/functions/hashFile.md +23 -0
- package/docs/functions/hashStream.md +23 -0
- package/docs/functions/hfParse.md +1 -1
- package/docs/functions/hfTokenize.md +1 -1
- package/docs/functions/interpolateEnv.md +1 -1
- package/docs/functions/interpolateFString.md +1 -1
- package/docs/functions/interpolateGolangTemplate.md +1 -1
- package/docs/functions/isLangUsingSpaces.md +21 -0
- package/docs/functions/isListItemString.md +21 -0
- package/docs/functions/isModelNameMatched.md +1 -1
- package/docs/functions/isPunctuationChar.md +36 -0
- package/docs/functions/isRegExp.md +1 -1
- package/docs/functions/isSectionString.md +23 -0
- package/docs/functions/isSentenceEnding.md +21 -0
- package/docs/functions/isSepLineString.md +21 -0
- package/docs/functions/isSubdirectory.md +1 -1
- package/docs/functions/isTitleString.md +23 -0
- package/docs/functions/isValidFilename.md +1 -1
- package/docs/functions/isValidFilepath.md +1 -1
- package/docs/functions/isWebStream.md +1 -1
- package/docs/functions/jsonFilterToWhere.md +1 -1
- package/docs/functions/jsonToMarkdownStr.md +1 -1
- package/docs/functions/loadFileFromPaths.md +1 -1
- package/docs/functions/loadTextFromPaths.md +1 -1
- package/docs/functions/lrucache.md +1 -1
- package/docs/functions/makeToolFuncCancelable.md +1 -1
- package/docs/functions/matchUrlProtocol.md +1 -1
- package/docs/functions/memoize.md +1 -1
- package/docs/functions/messagesToText.md +1 -1
- package/docs/functions/paramsSizeToScaleStr.md +1 -1
- package/docs/functions/parseCommand.md +1 -1
- package/docs/functions/parseFString.md +1 -1
- package/docs/functions/parseJsJson.md +3 -3
- package/docs/functions/parseJsJsonSimpleSync.md +23 -0
- package/docs/functions/parseObjectArgInfo.md +1 -1
- package/docs/functions/parseObjectArgumentInfos.md +1 -1
- package/docs/functions/parseObjectArguments.md +1 -1
- package/docs/functions/parseObjectArgumentsAsArgInfos.md +1 -1
- package/docs/functions/parseYaml.md +1 -1
- package/docs/functions/quoteStr.md +1 -1
- package/docs/functions/reControlCharsRegex.md +1 -1
- package/docs/functions/readFilenamesRecursiveSync.md +1 -1
- package/docs/functions/readTextFileChunks.md +51 -0
- package/docs/functions/readTextFileChunksEx.md +23 -0
- package/docs/functions/readableFromAsyncIterable.md +1 -1
- package/docs/functions/registerCoreTools.md +1 -1
- package/docs/functions/registerYamlTag.md +1 -1
- package/docs/functions/removeMarkdownBold.md +23 -0
- package/docs/functions/removeMarkdownBoldAndItalic.md +23 -0
- package/docs/functions/removeMarkdownItalic.md +23 -0
- package/docs/functions/replaceWithPlaceholder.md +41 -0
- package/docs/functions/restoreFromPlacehoders.md +45 -0
- package/docs/functions/sanitizeFilename.md +1 -1
- package/docs/functions/sanitizeFilepath.md +1 -1
- package/docs/functions/saveConfigFile.md +1 -1
- package/docs/functions/scaleStrToParamsSize.md +1 -1
- package/docs/functions/simplifyObjectArguments.md +1 -1
- package/docs/functions/sortedValues.md +1 -1
- package/docs/functions/splitChunks.md +23 -0
- package/docs/functions/splitParagraph.md +32 -0
- package/docs/functions/splitSentence.md +2 -2
- package/docs/functions/stringifyYaml.md +1 -1
- package/docs/functions/stripConsoleColor.md +21 -0
- package/docs/functions/textToDate.md +1 -1
- package/docs/functions/throwError.md +1 -1
- package/docs/functions/toDateTime.md +1 -1
- package/docs/functions/trimStartOfStreamHelper.md +1 -1
- package/docs/functions/truncTo.md +1 -1
- package/docs/functions/truncateByToken.md +23 -0
- package/docs/functions/truncateToTokenLimit.md +44 -0
- package/docs/functions/truncateToTokenLimitEx.md +23 -0
- package/docs/functions/uuid.md +1 -1
- package/docs/functions/wait.md +1 -1
- package/docs/functions/xxhash.md +2 -2
- package/docs/functions/xxhash32.md +1 -1
- package/docs/functions/xxhash64.md +1 -1
- package/docs/functions/xxhashAsStr.md +2 -2
- package/docs/globals.md +46 -1
- package/docs/interfaces/AIChatAssistantMessageParam.md +48 -6
- package/docs/interfaces/AIChatContentPartImage.md +2 -2
- package/docs/interfaces/AIChatContentPartText.md +2 -2
- package/docs/interfaces/AIChatMessageParamBase.md +31 -1
- package/docs/interfaces/AIChatMessageToolCall.md +3 -3
- package/docs/interfaces/AIChatSystemMessageParam.md +45 -3
- package/docs/interfaces/AIChatToolMessageParam.md +46 -4
- package/docs/interfaces/AIChatUserMessageParam.md +49 -7
- package/docs/interfaces/AIChoiceConfig.md +7 -7
- package/docs/interfaces/AIResult.md +5 -5
- package/docs/interfaces/AIStreamParser.md +1 -1
- package/docs/interfaces/AIStreamParserOptions.md +1 -1
- package/docs/interfaces/BaseFunc.md +9 -9
- package/docs/interfaces/BaseFuncItem.md +8 -8
- package/docs/interfaces/CancelableAbilityOptions.md +2 -2
- package/docs/interfaces/ClientFuncItem.md +11 -11
- package/docs/interfaces/DotenvExpandOptions.md +3 -3
- package/docs/interfaces/DotenvExpandOutput.md +2 -2
- package/docs/interfaces/EventClientFuncParams.md +4 -4
- package/docs/interfaces/EventServerFuncParams.md +5 -5
- package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
- package/docs/interfaces/FuncItem.md +9 -9
- package/docs/interfaces/FuncParam.md +6 -6
- package/docs/interfaces/HashAlgoParams.md +37 -0
- package/docs/interfaces/IFileMetaInfo.md +77 -0
- package/docs/interfaces/IReadTextFileChunksOptions.md +157 -0
- package/docs/interfaces/ITruncateToTokenLimitOptions.md +111 -0
- package/docs/interfaces/ParseObjectArgumentOptions.md +45 -5
- package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
- package/docs/interfaces/PromptTemplateOptions.md +6 -6
- package/docs/interfaces/RemoteFuncItem.md +11 -11
- package/docs/interfaces/ReplacePlacehoderOptions.md +47 -0
- package/docs/interfaces/ResClientFuncParams.md +2 -2
- package/docs/interfaces/ResServerFuncParams.md +5 -5
- package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
- package/docs/interfaces/SectionStringOptions.md +27 -0
- package/docs/interfaces/ServerFuncItem.md +12 -12
- package/docs/interfaces/ServerFuncParams.md +2 -2
- package/docs/interfaces/SplitSentenceOptions.md +47 -0
- package/docs/interfaces/StreamCallbacksAndOptions.md +4 -4
- package/docs/interfaces/TaskPromise.md +5 -5
- package/docs/interfaces/ToolFuncPackage.md +3 -3
- package/docs/type-aliases/AIChatContentPart.md +1 -1
- package/docs/type-aliases/AIChatMessageParam.md +1 -1
- package/docs/type-aliases/AIChatRole.md +1 -1
- package/docs/type-aliases/AIMessageType.md +1 -1
- package/docs/type-aliases/AIModelNameRule.md +1 -1
- package/docs/type-aliases/AIModelNameRuleFn.md +1 -1
- package/docs/type-aliases/AIModelNameRules.md +1 -1
- package/docs/type-aliases/AITextGenerationFinishReason.md +1 -1
- package/docs/type-aliases/ActionName.md +1 -1
- package/docs/type-aliases/AsyncTaskId.md +1 -1
- package/docs/type-aliases/EventErrorListenerFn.md +1 -1
- package/docs/type-aliases/EventListenerFn.md +1 -1
- package/docs/type-aliases/FStringPromptTemplateNode.md +1 -1
- package/docs/type-aliases/FuncParamType.md +1 -1
- package/docs/type-aliases/PromptExamples.md +1 -1
- package/docs/type-aliases/PromptTemplateType.md +1 -1
- package/docs/type-aliases/PromptType.md +1 -1
- package/docs/type-aliases/TFunc.md +1 -1
- package/docs/variables/AIChatRoles.md +1 -1
- package/docs/variables/AIMessageTypes.md +1 -1
- package/docs/variables/AITextGenerationFinishReasons.md +1 -1
- package/docs/variables/AbortErrorCode.md +1 -1
- package/docs/variables/ActionNames.md +1 -1
- package/docs/variables/AlreadyExistsErrorCode.md +1 -1
- package/docs/variables/ClientToolFuncSchema.md +1 -1
- package/docs/variables/DefaultAsyncSemaphoreCapacity.md +1 -1
- package/docs/variables/EventBusName.md +1 -1
- package/docs/variables/EventName.md +1 -1
- package/docs/variables/FilenameReservedRegex.md +1 -1
- package/docs/variables/HFBuiltins.md +1 -1
- package/docs/variables/InternalErrorCode.md +1 -1
- package/docs/variables/LLM_TOKENIZER_NAMES.md +83 -0
- package/docs/variables/LLM_TOKENIZER_NAMES_MAP.md +13 -0
- package/docs/variables/NotFoundErrorCode.md +1 -1
- package/docs/variables/NotImplementedErrorCode.md +1 -1
- package/docs/variables/PASSING_SCORE.md +1 -1
- package/docs/variables/PromptTemplateTypes.md +1 -1
- package/docs/variables/PromptTypes.md +1 -1
- package/docs/variables/RStreamErrCode.md +1 -1
- package/docs/variables/RemoteToolFuncSchema.md +1 -1
- package/docs/variables/ResponseRStreamErrCode.md +1 -1
- package/docs/variables/SSEChannelAlreadyClosedErrCode.md +1 -1
- package/docs/variables/ServerToolFuncSchema.md +1 -1
- package/docs/variables/ToolAsyncCancelableBit.md +1 -1
- package/docs/variables/ToolAsyncMultiTaskBit.md +1 -1
- package/docs/variables/ToolAsyncPriorityBit.md +1 -1
- package/docs/variables/ToolFuncSchema.md +1 -1
- package/docs/variables/WindowsReservedNameRegex.md +1 -1
- package/docs/variables/base32768.md +1 -1
- package/docs/variables/defaultTemplateFormat.md +1 -1
- package/docs/variables/event.md +1 -1
- package/docs/variables/eventClient.md +1 -1
- package/docs/variables/eventServer.md +1 -1
- package/docs/variables/lrucache.md +1 -1
- package/package.json +7 -3
- package/dist/chunk-FLVJ4R53.mjs +0 -1
- package/docs/enumerations/XXHashAlgorithm.md +0 -27
- /package/dist/{chunk-PXQPLL62.mjs → chunk-VIG2GB47.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EventEmitter as t}from"events-ex";import{AdvancePropertyManager as e}from"property-manager";import{_createFunction as n}from"util-ex";import{AbortError as r,AbortErrorCode as s,AlreadyExistsError as i,AlreadyExistsErrorCode as o,BaseError as a,CommonError as c,createError as u,ErrorCode as f,InternalErrorCode as l,NotFoundErrorCode as h,NotFoundError as w,NotImplementedErrorCode as p,NotImplementationError as d,throwError as m}from"@isdk/common-error";import{createAbilityInjector as y}from"custom-ability";import{toRegExp as g}from"util-ex";var b=.618,v=["get","post","put","delete","patch","list","res"],x={apiRoot:{type:"string",get(){return this._apiRoot??this.constructor.apiRoot},set(t){this._apiRoot=t}},action:{type:"string",assign:(t,e,n,r,s)=>t||"post"},fetchOptions:{type:"object"},allowExportFunc:{type:"boolean"}};import{format as E,parse as $,parseISO as k}from"date-fns";import{formatISO as S,parseISO as O,toDate as j}from"date-fns";var A="MMMM d, y 'at' h:m:s b 'GMT'x";function C(t){let e;try{"string"==typeof t?e=k(t):"number"==typeof t?e=new Date(t):t instanceof Date&&(e=t)}catch(t){console.error(t)}return e}function T(t,e=A){return $(t,e,new Date)}function N(t,e=A){return E(t,e)}var M=["stop","length","content_filter","tool_calls","function_call","abort","error","other",null],I=["human","ai","generic","system","tool"],L=["user","assistant","system","tool","tool_calls"];function R(t){let e="";for(const n of t)if(n.content){e+=n.role.toLowerCase()+":";let t=n.createdAt;if(t){const n=C(t);n&&(e+=" ["+N(n)+"]")}e+=" "+n.content+"\n"}return e}var z=["chat","char","plan"],B=["internal","hf","fill"];import{BaseFactory as _}from"custom-factory";var P="default",F=class t extends _{static from(t,e){return new this(t,e)}static async format(t){return new this(t).format()}static async formatIf(t){if(this.isTemplate(t)){return new this(t).format()}}static isTemplate(e){if(e?.template){const n=e.templateFormat||P,r=t.get(n);return r.isTemplate!==t.isTemplate&&r.isTemplate(e)}}filterData(t){return Array.isArray(this.inputVariables)&&(t=Object.fromEntries(Object.entries(t).filter((([t])=>this.inputVariables.includes(t))))),t}constructor(e,n){"string"==typeof e?(n||(n={}),n.template=e):e&&(e=(n=e).template);const{templateFormat:r}=n||{};if(super(n),this.constructor===t){const e=t.get(r||P);if(e)return Reflect.construct(e,arguments);throw new c(`Prompt template type ${r} not found`,"PromptTemplate",f.InvalidArgument)}}_initialize(t){throw new d("Not implemented","PromptTemplate")}initialize(e){this.constructor!==t&&(Object.assign(this,this.toJSON(e)),e?.ignoreInitialize||this._initialize(e))}_format(t){throw new d("Not implemented","PromptTemplate")}async format(e){const n=this.data;if(e={...n,...e},n)for(const[t,r]of Object.entries(n))e[t]===r&&"function"==typeof r&&(delete e[t],e[t]=await r(e));for(const[n,r]of Object.entries(e))r instanceof t&&(delete e[n],e[n]=await r.format(e));return this._format(e)}partial(t){t={...this.data,...t};const e=this.toJSON();return e.data=t,e.ignoreInitialize=!0,new this.constructor(e)}toJSON(e=this){let n={template:e.template,data:e.data,inputVariables:e.inputVariables,compiledTemplate:e.compiledTemplate};var r;return e.templateFormat&&t.get(e.templateFormat)!==this.constructor&&(n.templateFormat=e.templateFormat),r=n,n=Object.keys(r).reduce(((t,e)=>{const n=r[e];return null!=n&&(t[e]=n),t}),{}),n}};function V(t){return(e=t)&&"function"==typeof e[Symbol.iterator]?async function*(t){const e=t[Symbol.iterator]();let n;try{for(;;){n=!1;const t=e.next();if(n=!0,t.done)return n=!1,await t.value;yield await t.value}}finally{n&&await(e.return?.().value)}}(t):t;var e}var U=!1;(async function(){let t=!1,e=!1;try{for await(const e of function*(){try{yield Promise.reject()}finally{t=!0}}())throw new Error("impossible")}catch{e=!0}return e&&t})().then((t=>{U=t}));var X=class{constructor(t,e){this.initialize(t,e)}initialize(t,e){const n=e?.maxLength;var r;n>0&&(this.maxLength=n),void 0!==e?.threshold&&(!0===e.threshold?this.threshold=.5:!1!==e.threshold&&(this.threshold=e.threshold)),this.examples=(r=t,U?r:V(r))}selectExample(t,e){if(void 0===e||e<=this.threshold)return t}async*selectExamples(t=this.examples){let e=this.maxLength||1/0;for await(const n of t){const t="number"==typeof this.threshold?Math.random():void 0;if(this.selectExample(n,t)){if(--e<0)break;yield n}}}async*[Symbol.asyncIterator](){yield*this.selectExamples()}},q=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",BooleanLiteral:"BooleanLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Set:"Set",If:"If",For:"For",In:"In",Is:"Is",NotIn:"NotIn",Else:"Else",EndIf:"EndIf",ElseIf:"ElseIf",EndFor:"EndFor",And:"And",Or:"Or",Not:"UnaryOperator",Macro:"Macro",EndMacro:"EndMacro"}),J=Object.freeze({set:q.Set,for:q.For,in:q.In,is:q.Is,if:q.If,else:q.Else,endif:q.EndIf,elif:q.ElseIf,endfor:q.EndFor,and:q.And,or:q.Or,not:q.Not,"not in":q.NotIn,macro:q.Macro,endmacro:q.EndMacro,true:q.BooleanLiteral,false:q.BooleanLiteral,True:q.BooleanLiteral,False:q.BooleanLiteral}),D=class{constructor(t,e){this.value=t,this.type=e}};function K(t){return/\w/.test(t)}function W(t){return/[0-9]/.test(t)}var Z=[["{%",q.OpenStatement],["%}",q.CloseStatement],["{{",q.OpenExpression],["}}",q.CloseExpression],["(",q.OpenParen],[")",q.CloseParen],["{",q.OpenCurlyBracket],["}",q.CloseCurlyBracket],["[",q.OpenSquareBracket],["]",q.CloseSquareBracket],[",",q.Comma],[".",q.Dot],[":",q.Colon],["|",q.Pipe],["<=",q.ComparisonBinaryOperator],[">=",q.ComparisonBinaryOperator],["==",q.ComparisonBinaryOperator],["!=",q.ComparisonBinaryOperator],["<",q.ComparisonBinaryOperator],[">",q.ComparisonBinaryOperator],["+",q.AdditiveBinaryOperator],["-",q.AdditiveBinaryOperator],["*",q.MultiplicativeBinaryOperator],["/",q.MultiplicativeBinaryOperator],["%",q.MultiplicativeBinaryOperator],["=",q.Equals]],G=new Map([["n","\n"],["t","\t"],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function Q(t,e={}){const n=[],r=function(t,e={}){return t.endsWith("\n")&&(t=t.slice(0,-1)),t=t.replace(/{#.*?#}/gs,"{##}"),e.lstrip_blocks&&(t=t.replace(/^[ \t]*({[#%])/gm,"$1")),e.trim_blocks&&(t=t.replace(/([#%]})\n/g,"$1")),t.replace(/{##}/g,"").replace(/-%}\s*/g,"%}").replace(/\s*{%-/g,"{%").replace(/-}}\s*/g,"}}").replace(/\s*{{-/g,"{{")}(t,e);let s=0;const i=t=>{let e="";for(;t(r[s]);)if("\\"!==r[s]){if(e+=r[s++],s>=r.length)throw new SyntaxError("Unexpected end of input")}else{if(++s,s>=r.length)throw new SyntaxError("Unexpected end of input");const t=r[s++],n=G.get(t);if(void 0===n)throw new SyntaxError(`Unexpected escaped character: ${t}`);e+=n}return e};t:for(;s<r.length;){const t=n.at(-1)?.type;if(void 0===t||t===q.CloseStatement||t===q.CloseExpression){let t="";for(;s<r.length&&("{"!==r[s]||"%"!==r[s+1]&&"{"!==r[s+1]);)t+=r[s++];if(t.length>0){n.push(new D(t,q.Text));continue}}i((t=>/\s/.test(t)));const e=r[s];if("-"===e||"+"===e){const t=n.at(-1)?.type;if(t===q.Text||void 0===t)throw new SyntaxError(`Unexpected character: ${e}`);switch(t){case q.Identifier:case q.NumericLiteral:case q.BooleanLiteral:case q.StringLiteral:case q.CloseParen:case q.CloseSquareBracket:break;default:{++s;const t=i(W);n.push(new D(`${e}${t}`,t.length>0?q.NumericLiteral:q.UnaryOperator));continue}}}for(const[t,e]of Z){if(r.slice(s,s+t.length)===t){n.push(new D(t,e)),s+=t.length;continue t}}if("'"!==e&&'"'!==e)if(W(e)){const t=i(W);n.push(new D(t,q.NumericLiteral))}else{if(!K(e))throw new SyntaxError(`Unexpected character: ${e}`);{const t=i(K),e=Object.hasOwn(J,t)?J[t]:q.Identifier;e===q.In&&n.at(-1)?.type===q.Not?(n.pop(),n.push(new D("not in",q.NotIn))):n.push(new D(t,e))}}else{++s;const t=i((t=>t!==e));n.push(new D(t,q.StringLiteral)),++s}}return n}var H=class{constructor(){this.type="Statement"}},Y=class extends H{constructor(t){super(),this.body=t,this.type="Program"}},tt=class extends H{constructor(t,e,n){super(),this.test=t,this.body=e,this.alternate=n,this.type="If"}},et=class extends H{constructor(t,e,n,r){super(),this.loopvar=t,this.iterable=e,this.body=n,this.defaultBlock=r,this.type="For"}},nt=class extends H{constructor(t,e){super(),this.assignee=t,this.value=e,this.type="Set"}},rt=class extends H{constructor(t,e,n){super(),this.name=t,this.args=e,this.body=n,this.type="Macro"}},st=class extends H{constructor(){super(...arguments),this.type="Expression"}},it=class extends st{constructor(t,e,n){super(),this.object=t,this.property=e,this.computed=n,this.type="MemberExpression"}},ot=class extends st{constructor(t,e){super(),this.callee=t,this.args=e,this.type="CallExpression"}},at=class extends st{constructor(t){super(),this.value=t,this.type="Identifier"}},ct=class extends st{constructor(t){super(),this.value=t,this.type="Literal"}},ut=class extends ct{constructor(){super(...arguments),this.type="NumericLiteral"}},ft=class extends ct{constructor(){super(...arguments),this.type="StringLiteral"}},lt=class extends ct{constructor(){super(...arguments),this.type="BooleanLiteral"}},ht=class extends ct{constructor(){super(...arguments),this.type="ArrayLiteral"}},wt=class extends ct{constructor(){super(...arguments),this.type="TupleLiteral"}},pt=class extends ct{constructor(){super(...arguments),this.type="ObjectLiteral"}},dt=class extends st{constructor(t,e,n){super(),this.operator=t,this.left=e,this.right=n,this.type="BinaryExpression"}},mt=class extends st{constructor(t,e){super(),this.operand=t,this.filter=e,this.type="FilterExpression"}},yt=class extends st{constructor(t,e){super(),this.iterable=t,this.test=e,this.type="SelectExpression"}},gt=class extends st{constructor(t,e,n){super(),this.operand=t,this.negate=e,this.test=n,this.type="TestExpression"}},bt=class extends st{constructor(t,e){super(),this.operator=t,this.argument=e,this.type="UnaryExpression"}},vt=class extends st{constructor(t=void 0,e=void 0,n=void 0){super(),this.start=t,this.stop=e,this.step=n,this.type="SliceExpression"}},xt=class extends st{constructor(t,e){super(),this.key=t,this.value=e,this.type="KeywordArgumentExpression"}};function Et(t){const e=new Y([]);let n=0;function r(e,r){const s=t[n++];if(!s||s.type!==e)throw new Error(`Parser Error: ${r}. ${s.type} !== ${e}.`);return s}function s(){let e;switch(t[n].type){case q.Text:e=new ft(r(q.Text,"Expected text token").value);break;case q.OpenStatement:e=function(){let e;switch(r(q.OpenStatement,"Expected opening statement token"),t[n].type){case q.Set:++n,e=a(),r(q.CloseStatement,"Expected closing statement token");break;case q.If:++n,e=c(),r(q.OpenStatement,"Expected {% token"),r(q.EndIf,"Expected endif token"),r(q.CloseStatement,"Expected %} token");break;case q.Macro:++n,e=function(){const t=x();if("Identifier"!==t.type)throw new SyntaxError("Expected identifier following macro statement");const e=y();r(q.CloseStatement,"Expected closing statement token");const n=[];for(;i(q.OpenStatement,q.EndMacro);)n.push(s());return new rt(t,e,n)}(),r(q.OpenStatement,"Expected {% token"),r(q.EndMacro,"Expected endmacro token"),r(q.CloseStatement,"Expected %} token");break;case q.For:++n,e=function(){const t=u(!0);if(!(t instanceof at||t instanceof wt))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${t.type} instead`);r(q.In,"Expected `in` keyword following loop variable");const e=f();r(q.CloseStatement,"Expected closing statement token");const a=[];for(;i(q.OpenStatement,q.EndFor)&&i(q.OpenStatement,q.Else);)a.push(s());const c=[];if(o(q.OpenStatement,q.Else))for(++n,++n,r(q.CloseStatement,"Expected closing statement token");i(q.OpenStatement,q.EndFor);)c.push(s());return new et(t,e,a,c)}(),r(q.OpenStatement,"Expected {% token"),r(q.EndFor,"Expected endfor token"),r(q.CloseStatement,"Expected %} token");break;default:throw new SyntaxError(`Unknown statement type: ${t[n].type} ${t[n].value}`)}return e}(),e.isStatement=!0;break;case q.OpenExpression:e=function(){r(q.OpenExpression,"Expected opening expression token");const t=f();return r(q.CloseExpression,"Expected closing expression token"),t}(),e.isStatement=!0;break;default:throw new SyntaxError(`Unexpected token type: ${t[n].type}`)}return e}function i(...e){return n+e.length<=t.length&&e.some(((e,r)=>e!==t[n+r].type))}function o(...e){return n+e.length<=t.length&&e.every(((e,r)=>e===t[n+r].type))}function a(){const t=f();if(o(q.Equals)){++n;const e=a();return new nt(t,e)}return t}function c(){const e=f();r(q.CloseStatement,"Expected closing statement token");const i=[],a=[];for(;t[n]?.type!==q.OpenStatement||t[n+1]?.type!==q.ElseIf&&t[n+1]?.type!==q.Else&&t[n+1]?.type!==q.EndIf;)i.push(s());if(t[n]?.type===q.OpenStatement&&t[n+1]?.type!==q.EndIf)if(++n,o(q.ElseIf))r(q.ElseIf,"Expected elseif token"),a.push(c());else for(r(q.Else,"Expected else token"),r(q.CloseStatement,"Expected closing statement token");t[n]?.type!==q.OpenStatement||t[n+1]?.type!==q.EndIf;)a.push(s());return new tt(e,i,a)}function u(t=!1){const e=t?x:f,r=[e()],s=o(q.Comma);for(;s&&(++n,r.push(e()),o(q.Comma)););return s?new wt(r):r[0]}function f(){return function(){const t=l();if(o(q.If)){++n;const e=l();if(o(q.Else)){++n;const r=l();return new tt(e,[t],[r])}return new yt(t,e)}return t}()}function l(){let e=h();for(;o(q.Or);){const r=t[n];++n;const s=h();e=new dt(r,e,s)}return e}function h(){let e=w();for(;o(q.And);){const r=t[n];++n;const s=w();e=new dt(r,e,s)}return e}function w(){let e;for(;o(q.Not);){const r=t[n];++n;const s=w();e=new bt(r,s)}return e??function(){let e=p();for(;o(q.ComparisonBinaryOperator)||o(q.In)||o(q.NotIn);){const r=t[n];++n;const s=p();e=new dt(r,e,s)}return e}()}function p(){let e=b();for(;o(q.AdditiveBinaryOperator);){const r=t[n];++n;const s=b();e=new dt(r,e,s)}return e}function d(){const e=function(){let e=x();for(;o(q.Dot)||o(q.OpenSquareBracket);){const s=t[n];let i;++n;const o=s.type!==q.Dot;if(o)i=g(),r(q.CloseSquareBracket,"Expected closing square bracket");else if(i=x(),"Identifier"!==i.type)throw new SyntaxError("Expected identifier following dot operator");e=new it(e,i,o)}return e}();return o(q.OpenParen)?m(e):e}function m(t){let e=new ot(t,y());return o(q.OpenParen)&&(e=m(e)),e}function y(){r(q.OpenParen,"Expected opening parenthesis for arguments list");const t=function(){const t=[];for(;!o(q.CloseParen);){let e=f();if(o(q.Equals)){if(++n,!(e instanceof at))throw new SyntaxError("Expected identifier for keyword argument");const t=f();e=new xt(e,t)}t.push(e),o(q.Comma)&&++n}return t}();return r(q.CloseParen,"Expected closing parenthesis for arguments list"),t}function g(){const t=[];let e=!1;for(;!o(q.CloseSquareBracket);)o(q.Colon)?(t.push(void 0),++n,e=!0):(t.push(f()),o(q.Colon)&&(++n,e=!0));if(0===t.length)throw new SyntaxError("Expected at least one argument for member/slice expression");if(e){if(t.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new vt(...t)}return t[0]}function b(){let e=v();for(;o(q.MultiplicativeBinaryOperator);){const r=t[n];++n;const s=v();e=new dt(r,e,s)}return e}function v(){let t=function(){let t=d();for(;o(q.Pipe);){++n;let e=x();if(!(e instanceof at))throw new SyntaxError("Expected identifier for the filter");o(q.OpenParen)&&(e=m(e)),t=new mt(t,e)}return t}();for(;o(q.Is);){++n;const e=o(q.Not);e&&++n;let r=x();if(r instanceof lt&&(r=new at(r.value.toString())),!(r instanceof at))throw new SyntaxError("Expected identifier for the test");t=new gt(t,e,r)}return t}function x(){const e=t[n];switch(e.type){case q.NumericLiteral:return++n,new ut(Number(e.value));case q.StringLiteral:return++n,new ft(e.value);case q.BooleanLiteral:return++n,new lt("true"===e.value.toLowerCase());case q.Identifier:return++n,new at(e.value);case q.OpenParen:{++n;const e=u();if(t[n].type!==q.CloseParen)throw new SyntaxError(`Expected closing parenthesis, got ${t[n].type} instead`);return++n,e}case q.OpenSquareBracket:{++n;const t=[];for(;!o(q.CloseSquareBracket);)t.push(f()),o(q.Comma)&&++n;return++n,new ht(t)}case q.OpenCurlyBracket:{++n;const t=new Map;for(;!o(q.CloseCurlyBracket);){const e=f();r(q.Colon,"Expected colon between key and value in object literal");const s=f();t.set(e,s),o(q.Comma)&&++n}return++n,new pt(t)}default:throw new SyntaxError(`Unexpected token: ${e.type}`)}}for(;n<t.length;)e.body.push(s());return e}function $t(t,e,n=1){void 0===e&&(e=t,t=0);const r=[];for(let s=t;s<e;s+=n)r.push(s);return r}function kt(t,e,n,r=1){const s=Math.sign(r);s>=0?(e=(e??=0)<0?Math.max(t.length+e,0):Math.min(e,t.length),n=(n??=t.length)<0?Math.max(t.length+n,0):Math.min(n,t.length)):(e=(e??=t.length-1)<0?Math.max(t.length+e,-1):Math.min(e,t.length-1),n=(n??=-1)<-1?Math.max(t.length+n,-1):Math.min(n,t.length-1));const i=[];for(let o=e;s*o<s*n;o+=r)i.push(t[o]);return i}function St(t){return t.replace(/\b\w/g,(t=>t.toUpperCase()))}var Ot=class{constructor(t=void 0){this.type="RuntimeValue",this.builtins=new Map,this.value=t}__bool__(){return new Ct(!!this.value)}toString(){return""+this.value}toJSON(){return this.value}},jt=class extends Ot{constructor(){super(...arguments),this.type="NumericValue"}},At=class t extends Ot{constructor(){super(...arguments),this.type="StringValue",this.builtins=new Map([["upper",new Lt((()=>new t(this.value.toUpperCase())))],["lower",new Lt((()=>new t(this.value.toLowerCase())))],["strip",new Lt((()=>new t(this.value.trim())))],["title",new Lt((()=>new t(St(this.value))))],["length",new jt(this.value.length)],["rstrip",new Lt((()=>new t(this.value.trimEnd())))],["lstrip",new Lt((()=>new t(this.value.trimStart())))]])}},Ct=class extends Ot{constructor(){super(...arguments),this.type="BooleanValue"}},Tt=class extends Ot{constructor(t,e){super(t),this.orgValue=e,this.type="ObjectValue",this.builtins=new Map([["get",new Lt((([t,e])=>{if(!(t instanceof At))throw new Error(`Object key must be a string: got ${t.type}`);return this.value.get(t.value)??e??new Rt}))],["items",new Lt((()=>new Mt(Array.from(this.value.entries()).map((([t,e])=>new Mt([new At(t),e]))))))]])}toString(){let t;return t=this.orgValue&&this.orgValue.toString!==Object.prototype.toString?this.orgValue.toString():JSON.stringify(Object.fromEntries(this.value.entries())),t}toJSON(){return this.orgValue?this.orgValue:Object.fromEntries(this.value.entries())}__bool__(){return new Ct(this.value.size>0)}},Nt=class extends Tt{constructor(){super(...arguments),this.type="KeywordArgumentsValue"}},Mt=class extends Ot{constructor(){super(...arguments),this.type="ArrayValue",this.builtins=new Map([["length",new jt(this.value.length)]])}__bool__(){return new Ct(this.value.length>0)}},It=class extends Mt{constructor(){super(...arguments),this.type="TupleValue"}},Lt=class extends Ot{constructor(){super(...arguments),this.type="FunctionValue"}},Rt=class extends Ot{constructor(){super(...arguments),this.type="NullValue"}},zt=class extends Ot{constructor(){super(...arguments),this.type="UndefinedValue"}},Bt=class{constructor(t){this.parent=t,this.variables=new Map([["namespace",new Lt((t=>{if(0===t.length)return new Tt(new Map);if(1!==t.length||!(t[0]instanceof Tt))throw new Error("`namespace` expects either zero arguments or a single object argument");return t[0]}))]]),this.tests=new Map([["boolean",t=>"BooleanValue"===t.type],["callable",t=>t instanceof Lt],["odd",t=>{if("NumericValue"!==t.type)throw new Error(`Cannot apply test "odd" to type: ${t.type}`);return t.value%2!=0}],["even",t=>{if("NumericValue"!==t.type)throw new Error(`Cannot apply test "even" to type: ${t.type}`);return t.value%2==0}],["false",t=>"BooleanValue"===t.type&&!t.value],["true",t=>"BooleanValue"===t.type&&t.value],["string",t=>"StringValue"===t.type],["number",t=>"NumericValue"===t.type],["integer",t=>"NumericValue"===t.type&&Number.isInteger(t.value)],["iterable",t=>t instanceof Mt||t instanceof At],["lower",t=>{const e=t.value;return"StringValue"===t.type&&e===e.toLowerCase()}],["upper",t=>{const e=t.value;return"StringValue"===t.type&&e===e.toUpperCase()}],["none",t=>"NullValue"===t.type],["defined",t=>"UndefinedValue"!==t.type],["undefined",t=>"UndefinedValue"===t.type],["equalto",(t,e)=>t.value===e.value],["eq",(t,e)=>t.value===e.value]])}set(t,e){return this.declareVariable(t,Pt(e))}declareVariable(t,e){if(this.variables.has(t))throw new SyntaxError(`Variable already declared: ${t}`);return this.variables.set(t,e),e}setVariable(t,e){return this.variables.set(t,e),e}resolve(t){if(this.variables.has(t))return this;if(this.parent)return this.parent.resolve(t);throw new Error(`Unknown variable: ${t}`)}lookupVariable(t){try{return this.resolve(t).variables.get(t)??new zt}catch{return new zt}}},_t=class{constructor(t){this.global=t??new Bt}run(t){return this.evaluate(t,this.global)}evaluateBinaryExpression(t,e){const n=this.evaluate(t.left,e);switch(t.operator.value){case"and":return n.__bool__().value?this.evaluate(t.right,e):n;case"or":return n.__bool__().value?n:this.evaluate(t.right,e)}const r=this.evaluate(t.right,e);switch(t.operator.value){case"==":return new Ct(n.value==r.value);case"!=":return new Ct(n.value!=r.value)}if(n instanceof zt||r instanceof zt)throw new Error("Cannot perform operation on undefined values");if(n instanceof Rt||r instanceof Rt)throw new Error("Cannot perform operation on null values");if(n instanceof jt&&r instanceof jt)switch(t.operator.value){case"+":return new jt(n.value+r.value);case"-":return new jt(n.value-r.value);case"*":return new jt(n.value*r.value);case"/":return new jt(n.value/r.value);case"%":return new jt(n.value%r.value);case"<":return new Ct(n.value<r.value);case">":return new Ct(n.value>r.value);case">=":return new Ct(n.value>=r.value);case"<=":return new Ct(n.value<=r.value)}else if(n instanceof Mt&&r instanceof Mt){if("+"===t.operator.value)return new Mt(n.value.concat(r.value))}else if(r instanceof Mt){const e=void 0!==r.value.find((t=>t.value===n.value));switch(t.operator.value){case"in":return new Ct(e);case"not in":return new Ct(!e)}}if((n instanceof At||r instanceof At)&&"+"===t.operator.value)return new At(n.toString()+r.toString());if(n instanceof At&&r instanceof At)switch(t.operator.value){case"in":return new Ct(r.value.includes(n.value));case"not in":return new Ct(!r.value.includes(n.value))}if(n instanceof At&&r instanceof Tt)switch(t.operator.value){case"in":return new Ct(r.value.has(n.value));case"not in":return new Ct(!r.value.has(n.value))}throw new SyntaxError(`Unknown operator "${t.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(t,e){const n=[],r=new Map;for(const s of t)if("KeywordArgumentExpression"===s.type){const t=s;r.set(t.key.value,this.evaluate(t.value,e))}else{if(r.size>0)throw new Error("Positional arguments must come before keyword arguments");n.push(this.evaluate(s,e))}return[n,r]}evaluateFilterExpression(t,e){const n=this.evaluate(t.operand,e);if("Identifier"===t.filter.type){const r=t.filter,s=e.lookupVariable(r.value);if(s instanceof Lt)return s.value([n],e);if(n instanceof Mt)switch(r.value){case"list":return n;case"first":return n.value[0];case"last":return n.value[n.value.length-1];case"length":return new jt(n.value.length);case"reverse":return new Mt(n.value.reverse());case"sort":return new Mt(n.value.sort(((t,e)=>{if(t.type!==e.type)throw new Error(`Cannot compare different types: ${t.type} and ${e.type}`);switch(t.type){case"NumericValue":return t.value-e.value;case"StringValue":return t.value.localeCompare(e.value);default:throw new Error(`Cannot compare type: ${t.type}`)}})));default:throw new Error(`Unknown ArrayValue filter: ${r.value}`)}else if(n instanceof At)switch(r.value){case"length":return new jt(n.value.length);case"upper":return new At(n.value.toUpperCase());case"lower":return new At(n.value.toLowerCase());case"title":return new At(St(n.value));case"capitalize":return new At(n.value.charAt(0).toUpperCase()+n.value.slice(1));case"trim":return new At(n.value.trim());case"trimStart":return new At(n.value.trimStart());case"trimEnd":return new At(n.value.trimEnd());case"indent":return new At(n.value.split("\n").map(((t,e)=>0===e||0===t.length?t:" "+t)).join("\n"));case"string":return n;default:throw new Error(`Unknown StringValue filter: ${r.value}`)}else{if(n instanceof jt){if("abs"===r.value)return new jt(Math.abs(n.value));throw new Error(`Unknown NumericValue filter: ${r.value}`)}if(n instanceof Tt)switch(r.value){case"items":return new Mt(Array.from(n.value.entries()).map((([t,e])=>new Mt([new At(t),e]))));case"length":return new jt(n.value.size);case"string":return new At(n.toString());default:throw new Error(`Unknown ObjectValue filter: ${r.value}`)}}throw new Error(`Cannot apply filter "${r.value}" to type: ${n.type}`)}if("CallExpression"===t.filter.type){const r=t.filter;if("Identifier"!==r.callee.type)throw new Error(`Unknown filter: ${r.callee.type}`);const s=r.callee.value,i=e.lookupVariable(s);if(i instanceof Lt){const[t,s]=this.evaluateArguments(r.args,e);return s.size>0&&t.push(new Nt(s)),i.value([n,...t],e)}if(n instanceof Mt){switch(s){case"selectattr":{if(n.value.some((t=>!(t instanceof Tt))))throw new Error("`selectattr` can only be applied to array of objects");if(r.args.some((t=>"StringLiteral"!==t.type)))throw new Error("arguments of `selectattr` must be strings");const[t,s,i]=r.args.map((t=>this.evaluate(t,e)));let o;if(s){const t=e.tests.get(s.value);if(!t)throw new Error(`Unknown test: ${s.value}`);o=t}else o=(...t)=>t[0].__bool__().value;const a=n.value.filter((e=>{const n=e.value.get(t.value);return!!n&&o(n,i)}));return new Mt(a)}case"map":{const[,t]=this.evaluateArguments(r.args,e);if(t.has("attribute")){const e=t.get("attribute");if(!(e instanceof At))throw new Error("attribute must be a string");const r=t.get("default"),s=n.value.map((t=>{if(!(t instanceof Tt))throw new Error("items in map must be an object");return t.value.get(e.value)??r??new zt}));return new Mt(s)}throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${s}`)}if(n instanceof At){if("indent"===s){const[t,s]=this.evaluateArguments(r.args,e),i=t.at(0)??s.get("width")??new jt(4);if(!(i instanceof jt))throw new Error("width must be a number");const o=t.at(1)??s.get("first")??new Ct(!1),a=t.at(2)??s.get("blank")??new Ct(!1),c=n.value.split("\n"),u=" ".repeat(i.value),f=c.map(((t,e)=>!o.value&&0===e||!a.value&&0===t.length?t:u+t));return new At(f.join("\n"))}throw new Error(`Unknown StringValue filter: ${s}`)}throw new Error(`Cannot apply filter "${s}" to type: ${n.type}`)}throw new Error(`Unknown filter: ${t.filter.type}`)}evaluateTestExpression(t,e){const n=this.evaluate(t.operand,e),r=e.tests.get(t.test.value);if(!r)throw new Error(`Unknown test: ${t.test.value}`);const s=r(n);return new Ct(t.negate?!s:s)}evaluateUnaryExpression(t,e){const n=this.evaluate(t.argument,e);if("not"===t.operator.value)return new Ct(!n.value);throw new SyntaxError(`Unknown operator: ${t.operator.value}`)}evalProgram(t,e){return this.evaluateBlock(t.body,e)}evaluateBlock(t,e){let n="";for(const r of t){const t=this.evaluate(r,e);"NullValue"!==t.type&&"UndefinedValue"!==t.type&&(n+=t)}return new At(n)}evaluateIdentifier(t,e){return e.lookupVariable(t.value)}evaluateCallExpression(t,e){const[n,r]=this.evaluateArguments(t.args,e);r.size>0&&n.push(new Nt(r));const s=this.evaluate(t.callee,e);if("FunctionValue"!==s.type)throw new Error(`Cannot call something that is not a function: got ${s.type}`);return s.value(n,e)}evaluateSliceExpression(t,e,n){if(!(t instanceof Mt||t instanceof At))throw new Error("Slice object must be an array or string");const r=this.evaluate(e.start,n),s=this.evaluate(e.stop,n),i=this.evaluate(e.step,n);if(!(r instanceof jt||r instanceof zt))throw new Error("Slice start must be numeric or undefined");if(!(s instanceof jt||s instanceof zt))throw new Error("Slice stop must be numeric or undefined");if(!(i instanceof jt||i instanceof zt))throw new Error("Slice step must be numeric or undefined");return t instanceof Mt?new Mt(kt(t.value,r.value,s.value,i.value)):new At(kt(Array.from(t.value),r.value,s.value,i.value).join(""))}evaluateMemberExpression(t,e){const n=this.evaluate(t.object,e);let r,s;if(t.computed){if("SliceExpression"===t.property.type)return this.evaluateSliceExpression(n,t.property,e);r=this.evaluate(t.property,e)}else r=new At(t.property.value);if(n instanceof Tt){if(!(r instanceof At))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.value.get(r.value)??n.builtins.get(r.value)}else if(n instanceof Mt||n instanceof At)if(r instanceof jt)s=n.value.at(r.value),n instanceof At&&(s=new At(n.value.at(r.value)));else{if(!(r instanceof At))throw new Error(`Cannot access property with non-string/non-number: got ${r.type}`);s=n.builtins.get(r.value)}else{if(!(r instanceof At))throw new Error(`Cannot access property with non-string: got ${r.type}`);s=n.builtins.get(r.value)}return s instanceof Ot?s:new zt}evaluateSet(t,e){const n=this.evaluate(t.value,e);if("Identifier"===t.assignee.type){const r=t.assignee.value;e.setVariable(r,n)}else{if("MemberExpression"!==t.assignee.type)throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(t.assignee)}`);{const r=t.assignee,s=this.evaluate(r.object,e);if(!(s instanceof Tt))throw new Error("Cannot assign to member of non-object");if("Identifier"!==r.property.type)throw new Error("Cannot assign to member with non-identifier property");s.value.set(r.property.value,n)}}return new Rt}evaluateIf(t,e){const n=this.evaluate(t.test,e);return this.evaluateBlock(n.__bool__().value?t.body:t.alternate,e)}evaluateFor(t,e){const n=new Bt(e);let r,s;if("SelectExpression"===t.iterable.type){const e=t.iterable;s=this.evaluate(e.iterable,n),r=e.test}else s=this.evaluate(t.iterable,n);if(!(s instanceof Mt))throw new Error(`Expected iterable type in for loop: got ${s.type}`);const i=[],o=[];for(let e=0;e<s.value.length;++e){const a=new Bt(n),c=s.value[e];let u;if("Identifier"===t.loopvar.type)u=e=>e.setVariable(t.loopvar.value,c);else{if("TupleLiteral"!==t.loopvar.type)throw new Error(`Invalid loop variable(s): ${t.loopvar.type}`);{const e=t.loopvar;if("ArrayValue"!==c.type)throw new Error(`Cannot unpack non-iterable type: ${c.type}`);const n=c;if(e.value.length!==n.value.length)throw new Error(`Too ${e.value.length>n.value.length?"few":"many"} items to unpack`);u=t=>{for(let r=0;r<e.value.length;++r){if("Identifier"!==e.value[r].type)throw new Error(`Cannot unpack non-identifier type: ${e.value[r].type}`);t.setVariable(e.value[r].value,n.value[r])}}}}if(r){u(a);if(!this.evaluate(r,a).__bool__().value)continue}i.push(c),o.push(u)}let a="",c=!0;for(let e=0;e<i.length;++e){const r=new Map([["index",new jt(e+1)],["index0",new jt(e)],["revindex",new jt(i.length-e)],["revindex0",new jt(i.length-e-1)],["first",new Ct(0===e)],["last",new Ct(e===i.length-1)],["length",new jt(i.length)],["previtem",e>0?i[e-1]:new zt],["nextitem",e<i.length-1?i[e+1]:new zt]]);n.setVariable("loop",new Tt(r)),o[e](n);a+=this.evaluateBlock(t.body,n).value,c=!1}if(c){a+=this.evaluateBlock(t.defaultBlock,n).value}return new At(a)}evaluateMacro(t,e){return e.setVariable(t.name.value,new Lt(((e,n)=>{const r=new Bt(n);let s;e=e.slice(),"KeywordArgumentsValue"===e.at(-1)?.type&&(s=e.pop());for(let n=0;n<t.args.length;++n){const i=t.args[n],o=e[n];if("Identifier"===i.type){const t=i;if(!o)throw new Error(`Missing positional argument: ${t.value}`);r.setVariable(t.value,o)}else{if("KeywordArgumentExpression"!==i.type)throw new Error(`Unknown argument type: ${i.type}`);{const t=i,e=o??s?.value.get(t.key.value)??this.evaluate(t.value,r);r.setVariable(t.key.value,e)}}}return this.evaluateBlock(t.body,r)}))),new Rt}evaluate(t,e){if(void 0===t)return new zt;switch(t.type){case"Program":return this.evalProgram(t,e);case"Set":return this.evaluateSet(t,e);case"If":return this.evaluateIf(t,e);case"For":return this.evaluateFor(t,e);case"Macro":return this.evaluateMacro(t,e);case"NumericLiteral":return new jt(Number(t.value));case"StringLiteral":return new At(t.value);case"BooleanLiteral":return new Ct(t.value);case"ArrayLiteral":return new Mt(t.value.map((t=>this.evaluate(t,e))));case"TupleLiteral":return new It(t.value.map((t=>this.evaluate(t,e))));case"ObjectLiteral":{const n=new Map;for(const[r,s]of t.value){const t=this.evaluate(r,e);if(!(t instanceof At))throw new Error(`Object keys must be strings: got ${t.type}`);n.set(t.value,this.evaluate(s,e))}return new Tt(n,t.value)}case"Identifier":return this.evaluateIdentifier(t,e);case"CallExpression":return this.evaluateCallExpression(t,e);case"MemberExpression":return this.evaluateMemberExpression(t,e);case"UnaryExpression":return this.evaluateUnaryExpression(t,e);case"BinaryExpression":return this.evaluateBinaryExpression(t,e);case"FilterExpression":return this.evaluateFilterExpression(t,e);case"TestExpression":return this.evaluateTestExpression(t,e);default:throw new SyntaxError(`Unknown node type: ${t.type}`)}}};function Pt(t){switch(typeof t){case"number":return new jt(t);case"string":return new At(t);case"boolean":return new Ct(t);case"undefined":return new zt;case"object":return null===t?new Rt:Array.isArray(t)?new Mt(t.map(Pt)):new Tt(new Map(Object.entries(t).map((([t,e])=>[t,Pt(e)]))),t);case"function":return new Lt(((e,n)=>{const r=e.map((t=>Ft(t)));return Pt(t(...r)??null)}));default:throw new Error(`Cannot convert to runtime value: ${t}`)}}function Ft(t){let e=t;if(Array.isArray(t))e=t.map((t=>Ft(t)));else if(t instanceof Map)e={},t.forEach(((t,n)=>{e[n]=Ft(t)}));else switch(t.type){case"NullValue":e=null;break;case"UndefinedValue":e=void 0;break;case"ArrayValue":e=t.value.map((t=>Ft(t)));break;case"KeywordArgumentsValue":case"ObjectValue":e=t.orgValue?t.orgValue:Ft(t.value),"KeywordArgumentsValue"===t.type&&Object.setPrototypeOf(e,{jinja_kargs:!0});break;default:t.type&&(e=t.value)}return e}function Vt(t,e=0){return Math.floor(Math.random()*(t-e+1))+e}var Ut={randomInt:Vt,select:function(t,e){if(Array.isArray(t)||"string"==typeof t)return void 0===e?e=Vt(t.length-1):"string"==typeof e&&(e=parseInt(e)),e<0&&(e=t.length+e),t[e];if(t&&"object"==typeof t){if(void 0===e){const n=Object.keys(t);e=n[Vt(n.length-1)]}return t[e]}},tojson:function(t,e,n){return e&&"object"==typeof e&&(e.depth&&(n=e.depth),e=e.indent),Xt(t,e,n)}};function Xt(t,e,n){let r="";const s=n??0;if(null===t)r="null";else{const n=typeof t;switch(n){case"undefined":r="null";case"number":case"string":case"boolean":return JSON.stringify(t);case"object":{const n=e?" ".repeat(e):"",r="\n"+n.repeat(s),i=r+n;if(Array.isArray(t)){const n=t.map((t=>Xt(t,e,s+1)));return e?`[${i}${n.join(`,${i}`)}${r}]`:`[${n.join(", ")}]`}{const n=Array.from(Object.entries(t)).map((([t,n])=>{const r=`"${t}": ${Xt(n,e,s+1)}`;return e?`${i}${r}`:r}));return e?`{${n.join(",")}${r}}`:`{${n.join(", ")}}`}}default:throw new Error(`Cannot convert to JSON: ${n}`)}}return r}var qt=class extends Bt{constructor(t){super(t),this.parent=t}assign(t){for(const[e,n]of Object.entries(t))this.set(e,n)}clear(){this.variables.clear()}},Jt=class t{static{this.global=new qt}constructor(t,e={}){const n=Q(t,e={lstrip_blocks:!0,trim_blocks:!0,...e});this.parsed=Et(n)}render(e){const n=new Bt(t.global);n.set("false",!1),n.set("true",!0),n.set("raise_exception",(t=>{throw new Error(t)})),n.set("range",$t);for(const[t,r]of Object.entries(e))n.set(t,r);return new _t(n).run(this.parsed).toString()}};function Dt(t,e){let n;switch(t.type){case"Identifier":n=t.value;break;case"MemberExpression":n=Dt(t.object,e);break;case"FilterExpression":n=Dt(t.operand,e);break;case"Set":{e||(e=[]);const r=Dt(t.assignee);r&&e.push(r),n=Dt(t.value,e);break}}return n&&e?.includes(n)&&(n=void 0),n}function Kt(t){let e;if("Program"===t.type)e=t.body.some((t=>Kt(t)));else e=t.isStatement;return e}function Wt(t,e){let n=[];if(Array.isArray(t))n=t.map((t=>Wt(t,e))).filter(Boolean).flat();else switch(t.type){case"Program":n=t.body.map((t=>Wt(t,e))).filter(Boolean).flat();break;case"If":n=[Dt(t.test,e),...Wt(t.body,e),...Wt(t.alternate,e)].filter(Boolean);break;case"BinaryExpression":n=[Dt(t.left,e),Dt(t.right,e)].filter(Boolean);break;case"For":{const r=Dt(t.loopvar);r&&(e||(e=[]),e.push(r)),n=[Dt(t.iterable,e),...Wt(t.body,e)].filter(Boolean);break}case"CallExpression":n=[Dt(t.callee,e),...Wt(t.args,e)].filter(Boolean);break;default:n=[Dt(t,e)].filter(Boolean)}return n}Jt.global.assign(Ut);var Zt=class extends F{static isTemplate(t){let e,n,r=!1;if("object"==typeof t?(n=t.template,e=t.compiledTemplate):n=t,!e&&n)try{e=new Jt(n)}catch(t){}return e&&(r=Kt(e.parsed)),r}getVariables(t=this.compiledTemplate){return Wt(t.parsed,[]).filter(((t,e,n)=>n.indexOf(t)===e))}_initialize(t){const e=t?.template;if("string"!=typeof e)throw new c("Prompt template must be a string","PromptTemplate",f.InvalidArgument);this.compiledTemplate=new Jt(e),this.inputVariables=Array.isArray(t?.inputVariables)?t.inputVariables:this.getVariables()}_format(t){return this.compiledTemplate.render(t)}};function Gt(t){return function(e){return t}}function Qt(t){const e=t.split(""),n=[],r=(t,n)=>{for(let r=n;r<e.length;r+=1)if(t.includes(e[r]))return r;return-1};let s=0;for(;s<e.length;)if("{"===e[s]&&s+1<e.length&&"{"===e[s+1])n.push({type:"literal",text:"{"}),s+=2;else if("}"===e[s]&&s+1<e.length&&"}"===e[s+1])n.push({type:"literal",text:"}"}),s+=2;else if("{"===e[s]){const t=r("}",s);if(t<0)throw new Error("Unclosed '{' in template.");n.push({type:"variable",name:e.slice(s+1,t).join("")}),s=t+1}else{if("}"===e[s])throw new Error("Single '}' in template.");{const t=r("{}",s),i=(t<0?e.slice(s):e.slice(s,t)).join("");n.push({type:"literal",text:i}),s=t<0?e.length:t}}return n}function Ht(t,e){return t.reduce(((t,n)=>{let r;return r="variable"===n.type?n.name in e?t+e[n.name]:t:t+n.text,r}),"")}function Yt(t){const e=new Set;return t.forEach((t=>{"variable"===t.type&&e.add(t.name)})),[...e]}F.register(Zt,{name:"hf",aliases:["huggingface","internal","default"]});var te=class extends F{static isTemplate(t){let e,n,r=!1;if("object"==typeof t?(n=t.template,e=t.compiledTemplate):n=t,!e&&n)try{e=Qt(n)}catch(t){}if(e){r=Yt(e).length>0}return r}getVariables(t=this.compiledTemplate){return Yt(t)}_initialize(t){const e=t?.template;if("string"!=typeof e)throw new c("Prompt template must be a string","PromptTemplate",f.InvalidArgument);this.compiledTemplate=Qt(e),this.inputVariables=Array.isArray(t?.inputVariables)?t.inputVariables:this.getVariables()}_format(t){return Ht(this.compiledTemplate,t)}};function ee(t,e){return"string"==typeof e&&(e=e.split(".").filter((t=>t.length))),e.reduce(((t,e)=>t?.[e]),t)}function ne(t,e,n){let r=function(t,e,n){return t.replace(/{{\s*re_replace\s+\.(.+?)\s+(["'])((?:(?!\2).)*?)\2\s+(["'])((?:(?!\4).)*?)\4\s*}}/g,((t,r,s,i,o,a)=>{if(n)return e[r]=null,t;const c=new RegExp(i,"g");return ee(e,r).replace(c,a)}))}(t,e,n);return r=function(t,e,n){return t.replace(/{{\s*join\s+\.(.+?)\s+(["'])((?:(?!\2).)*?)\2\s*}}/g,((t,r,s,i)=>n?(e[r]=null,t):ee(e,r).join(i)))}(r,e,n),r=function(t,e,n){return t.replace(/{{\s*if\s*(\S+?)\s*}}([^{]*)({{\s*else\s*}}([^{]*))?{{\s*end\s*}}/g,((t,r,s,i,o)=>{if(n)return r.startsWith(".")&&(r=r.substring(1)),e[r]=null,t;let a;if(!r.startsWith("."))throw new Error("Functionality not implemented");{const t=ee(e,r.substring(1));if(null==t)a=o??"";else if("string"==typeof t)a=t.length>0?s:o??"";else if(Array.isArray(t))a=t.length>0?s:o??"";else{if("boolean"!=typeof t)throw new Error(`Unexpected type for variable ${r}: ${typeof t}`);a=t?s:o??""}}return a}))}(r,e,n),r=function(t,e,n){return t.replace(/{{\s*range\s*[.$]([^{}\s]+?)\s*}}([^{]*?){{\.}}([^{]*?){{\s*end\s*}}/g,((t,r,s,i)=>{if(n)return e[r]=null,t;const o=ee(e,r);if(Array.isArray(o)){let t="";for(const e of o)t+=`${s}${e}${i}`;return t}return t}))}(r,e,n),r=function(t,e,n){return t.replace(/{{\s*\.([^{}\s]+?)\s*}}/g,((t,r)=>n?(e[r]=null,t):ee(e,r)||""))}(r,e,n),r=function(t,e,n){return t.replace(/{{\s*index\s*\.(.+?)\s+(.+?)\s*}}/g,((t,r,s)=>{if(n)return e[r]=null,t;const i=ee(e,r);let o;return o=isNaN(s)?i[s.substring(1,s.length-1)]:i[parseInt(s,10)],o||""}))}(r,e,n),r}F.register(te,{name:"fstring",aliases:["python","f-string","langchain"]});var re=class extends F{static isTemplate(t){const e="string"==typeof t?t:t.template;return e?.includes("{{")&&e.includes("}}")}getVariables(t){const e={};return ne(t,e,!0),[...Object.keys(e)]}_initialize(t){const e=t?.template;if("string"!=typeof e)throw new c("Prompt template must be a string","PromptTemplate",f.InvalidArgument);this.inputVariables=Array.isArray(t?.inputVariables)?t.inputVariables:this.getVariables(e)}_format(t){return ne(this.template,t)}};function se(t){return Object.keys(t).sort().map((e=>t[e]))}F.register(re,{name:"golang",aliases:["localai","ollama"]});var ie=class extends F{static from(t){return new this(t)}constructor(t){super(t)}_initialize(t){t&&(t.suffix&&(this.suffix=t.suffix),t.exampleSeparator&&(this.exampleSeparator=t.exampleSeparator),t.prefix&&(this.prefix=t.prefix),t.examplePrompt&&(this.examplePrompt=t.examplePrompt instanceof F?t.examplePrompt:F.from(t.examplePrompt)),t.examples&&(this.examples=t.examples)),this.prefix||(this.prefix=""),this.exampleSeparator||(this.exampleSeparator="\n\n"),this.suffix||(this.suffix="")}async _format(t){const e=[];for await(const t of this.examples)if(this.examplePrompt){const n=await this.examplePrompt.format(t);e.push(n)}else if("string"==typeof t)e.push(t);else if(t){const n=se(t);n.length>0&&e.push(...n)}const n=[this.prefix,...e,this.suffix].join(this.exampleSeparator),r=this.templateFormat;return await F.format({template:n,data:t,templateFormat:r})}toJSON(t=this){const e=super.toJSON(t);return t.suffix&&(e.suffix=t.suffix),t.exampleSeparator&&(e.exampleSeparator=t.exampleSeparator),t.prefix&&(e.prefix=t.prefix),t.examplePrompt&&(e.examplePrompt=t.examplePrompt),t.examples&&(e.examples=t.examples),e}};F.register(ie,{name:"fewshot",aliases:["few_shot"]});var oe=/(\\)?(\$)(?!\()(\{?)([\w.]+)(?::?-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))?(\}?)/gi;function ae(t){return t.replace(/\\\$/g,"$")}function ce(t,e,n){return t.replace(oe,((r,s,i,o,a,c,u)=>"\\"===s?r.slice(1):e[a]?e[a]===n[a]?e[a]:ce(e[a],e,n):n[a]?n[a]===t?n[a]:ce(n[a],e,n):c?c.startsWith("$")?ce(c,e,n):c:""))}function ue(t){let e=process.env;t&&null!=t.processEnv&&(e=t.processEnv);for(const n in t.parsed){let r=t.parsed[n];if(!r)continue;r=Object.prototype.hasOwnProperty.call(e,n)?e[n]===t.parsed[n]?ce(r,e,t.parsed):e[n]:ce(r,e,t.parsed),t.parsed[n]=r?ae(r):r}for(const n in t.parsed)e[n]=t.parsed[n];return t}function fe(t,e={},n){switch(n||(n=new WeakSet),e.processEnv||(e.processEnv={...process.env}),e.parsed||(e.parsed=e.processEnv),typeof t){case"string":t=ce(t,e.processEnv,e.parsed);break;case"object":if(n.has(t)||null===t)return t;if(n.add(t),Array.isArray(t))for(let r=0;r<t.length;r++){const s=t[r];"string"!=typeof s&&"object"!=typeof s||(t[r]=fe(t[r],e,n))}else for(const[r,s]of Object.entries(t))"string"!=typeof s&&"object"!=typeof s||(t[r]=fe(s,e,n))}return t}import{detectTextLanguage as le}from"@isdk/detect-text-language";var he=/(\S.+?[.!?])(?=\s+|$)|(\S.+?)(?=[\n]|$)/g,we=/([A-Z][a-z]{1,2}\.)\s(\w)/g,pe=/(\.[a-zA-Z]\.)\s(\w)/g,de=new RegExp("([A-Z][a-z]{1,2}\\.)@(\\w)","g"),me=new RegExp("(\\.[a-zA-Z]\\.)@(\\w)","g"),ye=/(```)([\s\S]*?)(```)/g,ge=">>>CODE_BLOCK<<<",be=/([*_`]{1,3})(\S.*?\S)\1/,ve=/>>> INLINE_BLOCK (\d+) <<</,xe=1e4;function Ee(t,e,n){const r="$1"+e+"$2";let s=t;for(let t=0;t<n.length;t++)s=s.replace(n[t],r);return s}function $e(t,{best:e=!0,completeSentence:n,isMarkdown:r,ignoreEmptyLine:s}={}){const i=[],o=[];let a,c=0;for(;c++<xe&&(a=ye.exec(t));){const e=a[0];i.push(e),t=t.replace(e,"\n"+ge+(i.length-1)+"\n")}for(c=0;c++<xe&&(a=be.exec(t));){const e=a[0];o.push(e),t=t.replace(e,">>> INLINE_BLOCK "+(o.length-1)+" <<<")}if(r){const e=t.split("\n");for(let t=0;t<e.length;t++){const n=e[t];Ae(n,{isMarkdown:r,nextLine:e[t+1]})&&(i.push(n),e[t]=ge+(i.length-1))}t=e.join("\n")}const u=(t=(t=(t=(t=(t=t.replace(/([。!??])\1+/g,"$1")).replace(/([。!??])([^”’])/g,"$1\n$2")).replace(/(\.{6})([^”’])/g,"$1\n$2")).replace(/(…{2})([^”’])/g,"$1\n$2")).replace(/([。!??][”’])([^,。!??])/g,"$1\n$2")).split("\n");let f=[];for(let t=0;t<u.length;t++){let n=u[t].trimEnd();if(!n){!r&&s||f.push("");continue}if(n.startsWith(ge)){f.push(i[Number(n.slice(16))]);continue}if(r&&Ae(n,{isMarkdown:r,nextLine:u[t+1]})){f.push(n);continue}if(!e){f.push(n);continue}let a=Ee(n,"@",[we,pe]),c=Array.from(a.matchAll(he)),l=[];if(c.length)for(let t=0;t<c.length;t++)l.push(Ee(c[t][0]," ",[de,me]));else l.push(n);f.push(...l.map((t=>Me(o,t))))}return n&&(f=ke(f,{isMarkdown:r,ignoreEmptyLine:s})),f}function ke(t,{isMarkdown:e,ignoreEmptyLine:n}={}){const r=[];let s=0,i="";for(n=!e&&n;s<t.length;){let c=t[s];if(c){let u;if(n){const n=Le(t,s+1);u=je(t[n],{isMarkdown:e,nextLine:-1===n?"":t[n+1]})}else u=je(t[s+1],{isMarkdown:e,nextLine:t[s+2]});o=c,a={isMarkdown:e,nextLine:t[s+1]},Oe(o)||je(o,a)||""===t[s+1]||u?(i&&(c=Se(i,c),i=""),r.push(c)):(i&&(c=Se(i,c)),i=c)}else n||r[r.length-1]&&r.push(c);s++}var o,a;return i&&r.push(i),r}function Se(t,e){const n=t+" "+e,r=le(n,{isoCode:!0});return r&&!Ie(r)?(Ne(t)&&(t+=" "),e=t+e):e=t.endsWith("-")?(t=t.slice(0,-1))+e:n,e}function Oe(t){if(!t)return!1;return/(([.。!!??]\s*['"”’]?)|```)\s*$/.test(t)}function je(t,e){let n=Ae(t,e);return n||(n=Ce(t)),n||(n=Te(t)),n}function Ae(t,e){if(!t)return null;let n=/^\s*第?\s*[壹贰叁肆伍陆柒捌玖拾一二三四五六七八九十百千萬万\d]+\s*([章節节编回部篇卷幕场場辑集段册冊期片題]|片段|段落|篇[章目]|小[节節]|(子)?部分|卷[册冊]|[单單]元|章[节節回]|[.、])[ \t]*(?<title>.*)(?=\n|$)/.exec(t);if(n||(n=/^\s*(Chapter|Book|Article|Part|Paragraph|Subsection|Subpart|Volume|Episode|Issue|Unit|Section|Segment|Act|Scene)\s*\d+.*(?=\n|$)/i.exec(t)),!n&&e?.isMarkdown){n=/^[ \t]{0,3}(#+)\s+(?<title>\S.*)$/.exec(t);const r=/^[ \t]{0,3}([-=]+)(?=\n|$)/;!n&&e.nextLine&&!r.test(t)&&/^[ \t]{0,3}\S/.test(t)&&r.test(e.nextLine)&&(n=/^\s*(?<title>.*)(?=\n|$)/.exec(t))}return n}function Ce(t){return/^\s*([*+-]|\d+[.、])\s*(?<item>.*)(?=\n|$)/.exec(t)}function Te(t){return/^[-=_]{3,}$/.exec(t)}function Ne(t){return/[。!??,、;;::'""“”‘’~~《》<>〈〉【】(){}【】\[\]\(\)…·]$/.test(t)}function Me(t,e){let n,r=0;for(;r++<xe&&(n=ve.exec(e));){const r=Number(n[1]);e=e.replace(n[0],t[r])}return e}function Ie(t){return!["zh","ja","th","lo","ta","ko"].includes(t)}function Le(t,e=0){for(let n=e;n<t.length;n++){const e=t[n];if(null!=e&&""!==e)return n}return-1}function Re(t,e){const n=/(?!\\)([*_])\1(?![ \t]|\1)(.+?)(?<!\\)\1{2}/;let r;for(;(r=n.exec(t))&&(t=t.slice(0,r.index)+r[2]+t.slice(r.index+r[0].length),!e););return t}function ze(t,e){const n=/(?!\\)([*_])(?![ \t]|\1)(.+?)(?<!\\)\1/;let r;for(;(r=n.exec(t))&&(t=t.slice(0,r.index)+r[2]+t.slice(r.index+r[0].length),!e););return t}function Be(t,e){return t=ze(t=Re(t,e),e)}function _e(t,e){const n=[],r=[],s=t.split("\n");for(let t=0;t<s.length;t++){let i=s[t];const o=0===i.trim().length;o||Ae(i,{...e,nextLine:s[t+1]})?(r.length&&n.push([...r]),r.length=0,o||r.push(i)):r.push(i)}return r.length&&n.push([...r]),n}function Pe(t,e=2,n=.5){const r=10**e;return Math.trunc((t+Number.EPSILON+n/r)*r)/r}async function Fe(t){return new Promise((e=>setTimeout(e,t)))}import{createAbilityInjector as Ve}from"custom-ability";var Ue="event",Xe="event-bus";var qe=Ve((function(t){return class{static get emitter(){if(!this._emitter){const t=this.get(Xe)?.emitter;t&&(this._emitter=t,this.prototype._events=t._events)}return this._emitter}get emitter(){return this.constructor._emitter}on(e,n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return r.on(e,n)}once(e,n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return r.once(e,n)}off(e,n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return r.off(e,n)}emit(e,...n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return"error"===e?this.emitError.apply(this,n):r.emit.call(this,e,this.name,...n)}emitError(e,...n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return r.emit.call(this,"error",e,this.name,...n)}async emitAsync(e,...n){const r=t.emitter;if(!r)throw new TypeError("EventBackend required");return r.emitAsync.call(this,e,this.name,...n)}}}),!0);function Je(t,e){return!t||t.some((t=>t instanceof RegExp?t.test(e):t===e))}var De=498,Ke=class{get active(){return this._active}set active(t){t!==this._active&&(t?(this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0),this.options.pingInterval>0&&(this.pingTimer=setInterval((()=>this.publish()),this.options.pingInterval))):(this.clients.size&&this.clearClients(),this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0)),this._active=t)}constructor(t){this.options=Object.assign({},{pingInterval:3e3,maxStreamDuration:3e4,clientRetryInterval:1e3,startId:1,historySize:100,rewind:0,cors:!1},t),this.nextID=this.options.startId,this.clients=new Set,this.messages=[],this.active=!0}publish(t,e){let n,r;this.active||m("Channel closed","SSEChannel",498);let s=e;if(t||e)r=this.nextID++,"object"==typeof t&&(t.event?(s=t.event,void 0!==t.data&&(t=JSON.stringify(t.data))):t=JSON.stringify(t)),t=t?t.split(/[\r\n]+/).map((t=>"data: "+t)).join("\n"):"",n="id: "+r+"\n"+(e?"event: "+e+"\n":"")+(t||"data: ")+"\n\n",this.messages.push({id:r,_eventName:s,output:n});else{if(!this.clients.size)return;n="data: \n\n"}for([...this.clients].filter((t=>!s||Je(t.events,s))).forEach(((t,e)=>{t.res.write(n)}));this.messages.length>this.options.historySize;)this.messages.shift();return r}subscribe(t,e,n){this.active||m("Channel closed","SSEChannel",498);const r={req:t,res:e,events:n},s=this.options.maxStreamDuration;let i="max-age=0, stale-while-revalidate=0, stale-if-error=0, no-transform";s>0&&(i+=", s-maxage="+(Math.floor(s/1e3)-1));const o={"Content-Type":"text/event-stream","Cache-Control":i,Connection:"keep-alive"};this.options.cors&&(o["access-control-allow-origin"]="*"),r.req.socket.setNoDelay(!0),r.res.writeHead(200,o);let a="retry: "+this.options.clientRetryInterval+"\n\n";const c=Number.parseInt(t.headers["last-event-id"],10),u=Number.isNaN(c)?this.options.rewind:this.nextID-1-c;return u&&this.messages.filter((t=>Je(r.events,t.eventName))).slice(0-u).forEach((t=>{a+=t.output})),r.res.write(a),this.clients.add(r),s>0&&setTimeout((()=>{r.res.writableEnded||this.unsubscribe(r)}),s),r.res.on("close",(()=>this.unsubscribe(r))),r}unsubscribe(t){t.res.end(),this.clients.delete(t)}clearClients(){this.clients.forEach((t=>t.res.end())),this.clients.clear()}listClients(){const t={};return this.clients.forEach((e=>{const n=e.req.socket.remoteAddress??"";n in t||(t[n]=0),t[n]++})),t}getSubscriberCount(){return this.clients.size}};function We(t){return t instanceof ReadableStream||t instanceof WritableStream}var Ze=600,Ge=601,Qe=class extends a{constructor(t,e=600){super(t,500)}};function He(t){if(t){const e=t.getReader();return new ReadableStream({async start(t){const{done:n,value:r}=await e.read();if(!n){const e=(new TextDecoder).decode(r);t.error(new Qe(`Response error: ${e}`,601))}}})}return new ReadableStream({start(t){t.error(new Qe("Response error: No response body",601))}})}function Ye(){return new ReadableStream({start(t){t.close()}})}import{createParser as tn}from"eventsource-parser";function en(t){const e=new TextDecoder;let n;return new TransformStream({async start(e){n=tn((n=>{if("data"in n&&"event"===n.type&&"[DONE]"===n.data||"done"===n.event)e.terminate();else if("data"in n){const r=t?t(n.data,{event:n.event}):n.data;r&&e.enqueue(r)}}))},transform(t){n.feed(e.decode(t))}})}function nn(){let t=!0;return e=>(t&&(e=e.trimStart())&&(t=!1),e)}function rn(t,e){if(!t.ok)return He(t.body);let n=t.body||new ReadableStream({start(t){t.close()}});return n instanceof ReadableStream||(n=ReadableStream.from(n)),n.pipeThrough(en(e))}function sn(t){let e=t[Symbol.asyncIterator]();return new ReadableStream({async pull(t){const{done:n,value:r}=await e.next();n?t.close():t.enqueue(r)},async cancel(t){await(e.return?.(t))}})}function on(t){const e=t||{};return new TransformStream({async start(t){const n=t.error;if(t.error=r=>{n.call(t,r),e.onError&&e.onError(r)},e.onStart)try{await e.onStart(t)}catch(e){t.error(e)}},async transform(t,n){try{let r;e.onTransform&&(r=await e.onTransform(t,n)),r||(r=t),n.enqueue(r)}catch(t){n.error(t)}},async flush(t){if(e.onFinal)try{await e.onFinal(t)}catch(e){return t.error(e)}t.terminate()}})}import{v1 as an,v5 as cn,v4 as un}from"uuid";import*as fn from"base32768";import{v1 as ln,v4 as hn,v5 as wn,stringify as pn,parse as dn,validate as mn,version as yn,NIL as gn}from"uuid";var bn={1:an,4:un,5:cn};function vn(t=1,e){const n=bn[t];return e?fn.encode(n(null,[])):n()}import{createMD5 as xn,createRIPEMD160 as En,createSHA1 as $n,createSHA224 as kn,createSHA256 as Sn,createSHA512 as On,createXXHash128 as jn,createXXHash32 as An,createXXHash64 as Cn}from"hash-wasm";import Tn from"xxhashjs";import*as Nn from"base32768";import{canonicalize as Mn}from"json-canonicalize";var In=Nn,{h32:Ln,h64:Rn}=Tn,zn=588213;function Bn(t,e=16){return"object"==typeof t&&(t=Mn(t)),Ln(t.normalize(),zn).toString(e)}function _n(t,e=16){return"object"==typeof t&&(t=Mn(t)),Rn(t.normalize(),zn).toString(e)}var Pn=(t=>(t[t.md5=1]="md5",t[t.sha1=2]="sha1",t[t.ripemd=3]="ripemd",t[t.sha256=8]="sha256",t[t.sha384=9]="sha384",t[t.sha512=10]="sha512",t[t.sha224=11]="sha224",t[t.xxhash=111]="xxhash",t[t.xxhash64=111]="xxhash64",t[t.xxhash32=112]="xxhash32",t[t.xxhash128=113]="xxhash128",t))(Pn||{}),Fn={1:xn,2:$n,8:Sn,10:On,11:kn,3:En,112:An,111:Cn,113:jn};function Vn(t,e=111,n=zn){let r;return t.buffer&&(t=t.buffer),112!==e?(r=Rn(t,n),r=new Uint16Array([r._a00,r._a16,r._a32,r._a48]),r=new Uint8Array(r.buffer)):(r=Ln(t,n),r=new Uint16Array([r._low,r._high]),r=new Uint8Array(r.buffer)),r}function Un(t,e=111,n=zn){return Nn.encode(Vn(t,e,n))}async function Xn(t,{hashAlgo:e=111,seed:n=zn,outputType:r="string"}={}){const s=await Fn[e](n);s.init();const i=t.getReader();for(;;){const{done:t,value:e}=await i.read();if(t)break;s.update(e)}return"string"!==r?s.digest(r):Nn.encode(s.digest("binary"))}import qn from"path";var Jn=/[<>:"/\\|?*\u0000-\u001F]/,Dn=/^(con|prn|aux|nul|com\d|lpt\d)$/i,Kn=/^\.+(\\|\/)|^\.+$/,Wn=/\.+$/,Zn=/[\u0000-\u001F\u0080-\u009F\u200E\u200F\u202A-\u202E\u2066-\u2069]/;function Gn(){return new RegExp(Jn.source,"g")}function Qn(){return new RegExp(Zn.source,"g")}function Hn(t){return t&&!(Jn.test(t)||Qn().test(t)||Kn.test(t)||Wn.test(t))}function Yn(t){const e=t.split(qn.sep);return("/"===t[0]||e[0]&&qn.dirname(e[0])===e[0])&&e.shift(),e.every(Hn)}function tr(t,e={}){const n=e.replacement||"!";if((Jn.test(n)||Zn.test(n))&&m("Replacement string cannot contain reserved filename characters","sanitizeFilename",f.InvalidArgument),n.length>0){const e=/([<>:"/\\|?*\u0000-\u001F]){2,}/;t=t.replace(e,"$1")}if(t=(t=(t=(t=(t=t.normalize("NFD")).replace(Kn,n)).replace(Gn(),n)).replace(Qn(),n)).replace(Wn,""),n.length>0){"."===t[0]||"."!==t[0]||(t=n+t),"."===t[t.length-1]&&(t+=n)}t=Dn.test(t)?t+n:t;const r="number"==typeof e.maxLength?e.maxLength:100;if(t.length>r){const e=t.lastIndexOf(".");if(-1===e)t=t.slice(0,r);else{const n=t.slice(0,e),s=t.slice(e);t=n.slice(0,Math.max(1,r-s.length))+s}}return t}function er(t,e={}){const n=t.split(qn.sep);let r;("/"===t[0]||n[0]&&qn.dirname(n[0])===n[0])&&(r=n.shift());const s=n.map((t=>tr(t,e)));return void 0!==r&&s.unshift(r),s.join(qn.sep)}function nr(t,e=1){let n="";for(;e--;){const e=qn.extname(t);if(!e)break;n=e+n,t=qn.basename(t,e)}return n}function rr(t){return t.split(".").length-1}import{isRegExpStr as sr,toRegExp as ir}from"util-ex";function or(t,e){if("string"!=typeof t)throw new c("modelName must be a string","isModelNameMatched",f.InvalidArgument);switch(typeof e){case"string":if(sr(e)){const n=(e=ir(e)).exec(t);if(n)return n}else if(t.toLowerCase()===e.toLowerCase())return e;break;case"object":if(Array.isArray(e)){for(const n of e)if("string"==typeof n){if(sr(n)){const r=(e=ir(n)).exec(t);if(r)return r}else if(t.toLowerCase()===n.toLowerCase())return n}else if(n instanceof RegExp){const e=n.exec(t);if(e)return e}else if("function"==typeof n){const e=n.call(this,t);if(e)return e}}else if(e instanceof RegExp){const n=e.exec(t);if(n)return n}break;case"function":const n=e.call(this,t);if(n)return n}}function ar(t){return Object.keys(t).filter((t=>Number.isNaN(Number(t))))}import{pick as cr}from"lodash-es";import{newFunction as ur}from"util-ex";import{get as fr,omitBy as lr}from"lodash-es";import{newFunction as hr}from"util-ex";async function wr(t,e,n){return dr(Sr(t,e,n),e,n)}function pr(t){if(t&&!Array.isArray(t)&&"object"==typeof t){const e=Object.entries(t),n=Object.keys(t);1===e.length&&void 0!==t[0]?t=t[0]:n.every((t=>!isNaN(parseInt(t))))?t=n.sort(((t,e)=>parseInt(t)-parseInt(e))).map((e=>t[e])):2===e.length&&"0"===e[0][0]&&e[0][1]===e[1][1]&&(t=t[0])}return t}async function dr(t,e,n){if(t.length){const r=await Promise.all(t.map(((t,r)=>kr(t,r,e,n)))),s=n?.returnArrayOnly;let i;if(r?.length){i=Lr(`{${r.map((t=>t)).join(",")}}`,e)}return i&&!s&&(i=pr(i)),i}}function mr(t,e,n,r){const[s,i]=t;if(!s&&"|"===i[0])return"choice: {"+function(t,e,n){const r=Sr(t,e,{...n,delimiter:":"}),s={},i=r.map((([t,e],n)=>{if(t){const t=e.indexOf(":"),n=e.slice(0,t).trim();if(s[n])throw new Error("Only one "+n+" is allowed");return s[n]=!0,e}{if("|"===e[0]){if(s.items)throw new Error("Only one items is allowed");return s.items=!0,"items:["+function(t,e='"'){return t.map((t=>br(t)?t:e+t+e))}(e.split("|").filter(Boolean))+"]"}const t=parseInt(e.trim());if(!isNaN(t)){if(s.maxPick)throw new Error("Only one maxPick is allowed");return s.maxPick=!0,"maxPick:"+t}if("random"===e||"ai"===e)return s.type=!0,'type:"'+e+'"';if(br(e)){if(s.separator)throw new Error("Only one separator is allowed");return s.separator=!0,"separator:"+e}}}));return i}(i,n,r)+"}"}async function yr([t,e],n,r,s){let i,o;if(r||(r={}),t){const t=e.split(":");i=t[0].trim(),o=t[1].trim()}else o=e,i=n+"";const a={template:o,data:{...lr(r,((t,e)=>!e||"_"===e[0]||"function"==typeof t)),...s?.templateData}};s?.templateFormat&&(a.templateFormat=s.templateFormat);const c=await F.formatIf(a);if(c)return o=br(c)?c:JSON.stringify(c),i+":"+o}async function gr(t,e,n,r){let s=mr(t,0,n,r);return s||(s=await yr(t,e,n,r)),s}function br(t){const e=t[0];return('"'===e||"'"===e)&&t[t.length-1]===e}function vr(t){return'"'+t.replace(/(?<!\\)"(?!\\)/g,'\\"')+'"'}var xr=["true","false","null","undefined","NaN","Infinity"];async function Er(t,e,n){const r=hr("async expression",[],`return ${t};`,Br(e));let s;try{s=await r.call(this)}catch(t){if(n||!(t instanceof ReferenceError))throw t}switch(typeof s){case"number":case"boolean":case"undefined":return s;case"function":return r.toString();default:return JSON.stringify(s)}}async function $r(t,e,n){let r=t;if(!(s=t,function(t,e=['""',"''","{}"]){return e.some((e=>t[0]===e[0]&&t[t.length-1]===e[1]))}(s)||!Number.isNaN(parseFloat(s))||xr.includes(s)||Mr(s)||e&&void 0!==fr(e,t)||Mr(t)))try{r=n?.skipExpression?vr(t):await Er.call(this,t,e,n?.preserveUnresolvedName)}catch(e){r=vr(t)}var s;return r}async function kr(t,e,n,r){const[s,i]=t,o=r?.argProcessor,a=r?.ignoreIndexNamed;if("function"==typeof o){const s=await o(t,e,n,r);if(s)return s}if(s){const t=i.indexOf(":");return i.slice(0,t).trim()+":"+await $r(i.slice(t+1).trim(),n,r)}{const t=i.trim();if(n&&void 0!==fr(n,t)){return(a?"":e+":"+t+",")+'"'+t+'":'+t}return e+":"+await $r(i.trim(),n,r)}}function Sr(t,e,n){const r=n?.delimiter??",",s=n?.assigner??"=";let i=[],o=!1,a="",c="",u=!1,f="";for(let e=0;e<t.length;e++){const n=t[e];if(n!==r||o||f)if("\\"===n)c+=n,e++,c+=t[e];else if("("!==n&&"["!==n||o)if(f&&n===f)f="",c+=n;else if("{"!==n||o)'"'===n||"'"===n?(o&&n===a?o=!1:o||(o=!0,a=n),c+=n):n!==s||o||u||!/^[\p{L}\p{N}_ ]+$/u.test(c)?c+=n:(c+=":",u=!0);else{let r,s=e,i=!1,o="",a=-1;for(;s<t.length&&("}"!==(r=t[s])||i||a>0);)"\\"===r?s++:"{"!==r||i?"}"!==r||i?'"'!==r&&"'"!==r||(i&&n===o?i=!1:i||(i=!0,o=n)):a--:a++,s++;s<t.length&&(c+=t.substring(e,s+1),e=s)}else f="("===n?")":"]",c+=n;else c=c.trim(),c.endsWith(":")&&(c+="undefined"),i.push([u,c]),c="",u=!1}return c&&(c=c.trim(),c.endsWith(":")&&(c+="undefined"),i.push([u,c])),i}async function Or(t,e,n){const r=t.match(/^([^(]+)(?:\((.*)\))?$/);if(!r)throw new Error("Invalid command format");const[,s,i]=r;let o;return i&&(o=await wr(i,e,n)),{command:s.trim(),args:o}}var jr="__PlacEhoLdeR_";function Ar(t,e){let n=e?.startChar?Array.isArray(e.startChar)?e.startChar:[e.startChar]:['"',"'"],r=e?.endChar?Array.isArray(e.endChar)?e.endChar:[e.endChar]:n;if(n.length!==r.length)throw new Error("start and end characters must have the same length");const s=e?.placeholder??jr,i=n.every(((t,e)=>t===r[e])),o=e?.placehoders??[];if(i){n=n.map((t=>"\\"+t));const e=new RegExp(`(?<!\\\\)(${n.join("|")}).*?(?<!\\\\)\\1`);let r;for(;null!==(r=e.exec(t));){const e=`${s}${o.length}`;t=t.replace(r[0],e),o.push(r[0])}}else{n=n.map((t=>"\\"+t)),r=r.map((t=>"\\"+t));for(let e=0;e<n.length;e++){const i=new RegExp(`(?<!\\\\)${n[e]}.*?(?<!\\\\)${r[e]}`);let a;for(;null!==(a=i.exec(t));){const e=`${s}${o.length}`;t=t.replace(a[0],e),o.push(a[0])}}}return[t,o]}function Cr(t,e,n){const r=n?.placeholder??jr;return e.reduce(((t,e,n)=>t.replace(new RegExp(r+n,"g"),e)),t)}var Tr="[a-zA-Z_$][a-zA-Z_\\d$]*",Nr=new RegExp(`^\\s*(\\(\\s*\\)|${Tr}|\\(${`${Tr}\\s*(,\\s*${Tr})*`}\\))\\s*=>`);function Mr(t){return Nr.test(t)}async function Ir(t,e){if(e&&(e=Br(e)),e&&(t=t.trim()).startsWith("{")&&t.endsWith("}")){return await wr(t.slice(1,-1),e,{assigner:":",ignoreIndexNamed:!0})}return Lr(t,e)}function Lr(t,e){if(e&&(e=Br(e)),e){const n=Object.keys(e);if(n.length){const r=Object.values(e);let s=0;for(;s++<100;)try{return ur("expression",n,`return ${t}`)(...r)}catch(t){if(!(t instanceof ReferenceError))throw t;{const e=/(.+)\s+is not defined/.exec(t.message);if(!e)throw t;n.push(e[1]),r.push(void 0)}}}}return ur("expression",[],`return ${t}`)()}var Rr=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/,zr=t=>Rr.test(t);function Br(t){if(t){const e=Object.keys(t),n=e.length,r=e.filter((e=>zr(e)&&null!==t[e]));if(n===r.length)return t;if(r.length)return t=cr(t,r)}}function _r(t){return t?Pr(t,[],""):[]}function Pr(t,e,n="."){return Array.isArray(t)?t.flatMap(((t,n)=>Pr(t,[...e,`[${n}]`]))):(r=t)&&r.constructor===Object?Object.entries(t).flatMap((([t,r])=>Pr(r,[...e,n+t]))):[e.join("")];var r}function Fr(t){if(t<2)throw new c("repetitionThreshold must be greater than 1","createEndWithRepetitionDetector",f.InvalidArgument);const e=new RegExp(`([\\S\\s]+)(\\1{${t-1},})$`);return function(t){return e.exec(t)}}import Vr from"path";import*as Ur from"fs";import Xr from"mime-type/with-db";import qr from"jschardet";function Jr(t){const e=Ur.statSync(t,{throwIfNoEntry:!1});return e?.isFile()}function Dr(t,e,n,r){const s=r?.signal,i=r?.exclude;let o;if(Vr.isAbsolute(t)?o=Jr(t)?t:Kr(Vr.basename(t),[Vr.dirname(t)],{extNames:n,exclude:i,signal:s}):(e||(e=["."]),o=Kr(t,e,{extNames:n,exclude:i,signal:s})),!o)throw new w(t,"loadFileFromPaths");{const t=o;o=Ur.readFileSync(o),r&&(r.filepath=t)}return o}function Kr(t,e,{extNames:n,signal:r,exclude:s=[]}){let i;const o=n?n.map((e=>nr(t,rr(e)))):void 0;"string"==typeof s&&(s=[s]);for(const a of e){if(r?.aborted)throw r.reason;const e=Vr.resolve(a,t);if(o)for(let t=0;t<o.length;t++){const r=e+(o[t]!==n[t]?n[t]:"");if(!s.includes(r)&&Jr(r)){i=r;break}}else if(!s.includes(e)&&Jr(e)){i=e;break}}return i}function Wr(t,e,n,r,s){let i;"string"==typeof r?(i=r,r=void 0):i=r?.encoding;return Zr(Dr(t,e,n,r),i)}function Zr(t,e){void 0===e&&(e=es(t)??"utf8");return new TextDecoder(e).decode(t)}function Gr(t,e){const n=[],r="string"==typeof t?[{dir:t,level:0}]:[...t.map((t=>({dir:t,level:0})))],s=new Set,i=e?.signal,o=e?.isFileMatched,a=e?.level;let c=0;for(;r.length>0;){if(i?.aborted)throw i.reason;const t=r.pop(),e=Qr(t.dir),u=Vr.resolve(e);if(s.has(u))continue;s.add(u);const f=Ur.statSync(e,{throwIfNoEntry:!1});if(f?.isDirectory()){c=t.level+1;const s=Ur.readdirSync(e,{withFileTypes:!0});for(let t=0;t<s.length;t++){let i=s[t],u=Vr.join(e,i.name);if(i.isSymbolicLink()){const t=Vr.dirname(u);u=Ur.readlinkSync(u),u=Vr.resolve(t,u),i=Ur.statSync(u)}i.isDirectory()?(!a||c<a)&&(o&&!o(u,i)||r.push({dir:u,level:c})):!i.isFile()||o&&!o(u,i)||n.includes(u)||n.push(u)}}}return n}function Qr(t){const e=Ur.lstatSync(t,{throwIfNoEntry:!1});return e?.isSymbolicLink()&&(t=Ur.readlinkSync(t)),t}async function Hr(t,e){return Xn(ReadableStream.from(Ur.createReadStream(t)),e)}async function Yr(t){const e=Vr.basename(t);t=Vr.resolve(t);const n=await Ur.promises.stat(t),r=n.mtime,s=n.ctime,i=n.size,o=ts(i),a=await Hr(t,{hashAlgo:o}),c=Xr.lookup(t);return{name:e,mtime:r,ctime:s,size:i,hash:Pn[o]+":"+a,mimeType:c,id:"file://"+t}}function ts(t){let e=111;return t<=2048?e=112:t<=1048576?e=111:t<=10485760?e=113:t>10485760&&(e=10),e}function es(t,e){return qr.detect(t,e).encoding}import{existsSync as ns,mkdirSync as rs,readdirSync as ss,statSync as is,writeFileSync as os}from"fs";import as from"path";import{Config as cs}from"load-config-file";import{parse as us,stringify as fs}from"yaml";import{regexp as ls}from"yaml-types";import{mimeType as hs}from"mime-type/with-db";var ws=[ls];function ps(t){Array.isArray(t)||(t=[t]);for(const e of t){-1===ws.indexOf(e)&&ws.push(e)}}function ds(t){return us(t,{customTags:ws})}function ms(t){return fs(t,{customTags:ws})}function ys(t,e){const n=[],r=e?.after,s=e?.exclude?"string"==typeof e.exclude?[e.exclude]:e.exclude:void 0,i=e?.extensions?"string"==typeof e.extensions?[e.extensions]:e.extensions.map((t=>t.startsWith(".")?t:"."+t)):[".yml",".yaml",".json"];return function(t,e){const n=ss(t,{withFileTypes:!0,recursive:!0});for(const r of n){const n=as.join(t,r.name);r.isFile()&&e(n,r)}}(t,((t,e)=>{if(s?.includes(t))return;const o=as.extname(t),a=is(t);if(i.includes(o)){if(r?.hasOwnProperty(t)&&a.mtimeMs<=r[t])return;n.push(t)}})),n}function gs(t,e){return ys(t,e).map((t=>cs.loadSync(t))).filter((t=>void 0!==t))}function bs(t,e,n=1){"."===t[0]&&n++;const r=nr(t,n);(!r||r.split(".").length<=1)&&(t+=".yaml");const s=hs.lookup(t);if("application/json"===s)e=JSON.stringify(e,null,2);else{if("text/yaml"!==s)throw new Error(`${t} unsupported mime type: ${s}`);e=ms(e)}const i=as.dirname(t);return ns(i)||rs(i,{recursive:!0}),os(t,e,{encoding:"utf8"}),t}function vs(t){t instanceof Date&&(t=t.toISOString());return function(t,e){return t?`'${e}'`:String(e)}("string"==typeof t,t)}function xs(t,e){return t.map((t=>ks(t,e))).join(" AND ")}function Es(t,e){return t.map((t=>ks(t,e))).join(" OR ")}function $s(t,e){const n=[];return Object.keys(e).forEach((r=>{const s=e[r];switch(r){case"$lt":case"<":n.push(`${t} < ${vs(s)}`);break;case"<=":case"$lte":n.push(`${t} <= ${vs(s)}`);break;case"$gt":case">":n.push(`${t} > ${vs(s)}`);break;case"$gte":case">=":n.push(`${t} >= ${vs(s)}`);break;case"$ne":case"!=":n.push(`${t} != ${vs(s)}`);break;case"=":case"$eq":n.push(`${t} = ${vs(s)}`);break;case"$in":n.push(`${t} IN (${s.map((t=>vs(t))).join(", ")})`);break;case"$nin":n.push(`${t} NOT IN (${s.map((t=>vs(t))).join(", ")})`);break;case"$regex":n.push(`${t} REGEXP '${s.source}'`);break;case"$like":n.push(`${t} LIKE '${s}'`);break;case"$nlike":n.push(`${t} NOT LIKE '${s}'`);break;case"$glob":n.push(`${t} GLOB '${s}'`);break;case"$nglob":n.push(`${t} NOT GLOB '${s}'`);break;default:throw new Error(`Unsupported condition operator: ${r}`)}})),n.join(" AND ")}function ks(t,e){const n=[];if("function"!=typeof e&&(e=t=>t),Array.isArray(t))n.push(xs(t,e));else for(const[r,s]of Object.entries(t))if("$and"===r)n.push(`(${xs(t[r],e)})`);else if("$or"===r)n.push(`(${Es(t[r],e)})`);else{const t=typeof s;if(null==s)n.push(`${e(r)} IS NULL`);else if(s instanceof Date)n.push(`${e(r)}='${s.toISOString()}'`);else if("object"!==t||Array.isArray(s))if("string"===t)n.push(`${e(r)}='${s}'`);else{if("number"!==t&&"boolean"!==t)throw new Error(`Unsupported value type for key ${r}`);n.push(`${e(r)}=${s}`)}else n.push($s(e(r),s))}return n.length>1?n.join(" AND "):n[0]}function Ss(t){const e=t.indexOf("://");if(e>0)return t.substring(0,e)}function Os(t,e=0){let n,r=t*10**e;return t>=1e12?(r=Math.round(r/1e12),n="T"):t>=1e9?(r=Math.round(r/1e9),n="B"):t>=1e6?(r=Math.round(r/1e6),n="M"):t>=1e3?(r=Math.round(r/1e3),n="K"):(r=Math.round(r),n=""),r/=10**e,r.toFixed(e)+n}function js(t){const e=t.match(/^\s*[+]?(\d+(?:[.]\d+)?)\s*([TBMK])?\s*$/i);if(!e)throw new c("Invalid formatted parameter size string.","scaleToSize",f.InvalidArgument);const n=parseFloat(e[1]),r=e[2]?.toLowerCase();switch(r){case"t":return 1e12*n;case"b":return 1e9*n;case"m":return 1e6*n;case"k":return 1e3*n;default:return n}}function As(t,e){const n=e?.level||0,r=e?.visiting||new Set,s=e?.objectTag||"*",i=e?.arrayTag||"-";let o=[];const a=" ".repeat(2*n);if(null!=t)switch(typeof t){case"object":r.has(t)?o=["[Circular]"]:(r.add(t),o=Array.isArray(t)?t.map((t=>i+c(t))):Object.entries(t).map((([t,e])=>s+" `"+t+"`:"+c(e))));break;case"string":return t;default:return JSON.stringify(t)}else o=["null"];return o.length?a+o.join("\n"+a):"";function c(t){return(null!=t&&"object"==typeof t?"\n":" ")+As(t,{level:n+1,visiting:r})}}cs.register([".yml",".yaml"],ds),cs.register([".json"],(function(t){return JSON.parse(t)}));var Cs=class t{constructor(t=0){this.bitField=t}static has(t,e){return!!(t&1<<e)}static add(t,e){return t|1<<e}static delete(t,e){return t&~(1<<e)}add(t){return this.bitField|=1<<t,this}delete(t){return this.bitField&=~(1<<t),this}has(e){return t.has(this.bitField,e)}clear(){return this.bitField=0,this}valueOf(){return this.bitField}toString(){return this.bitField.toString()}toJSON(){return this.bitField}};import{EventEmitter as Ts}from"events-ex";var Ns=32;function Ms(t){return e=Math.min(Math.max(16,t),1073741824),e>>>=0,e-=1,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,1+(e|=e>>16);var e}var Is=class{constructor(t){this._capacity=Ms(t),this._length=0,this._front=0,this.arr=[]}push(t){const e=this._length;this.checkCapacity(e+1);const n=this._front+e&this._capacity-1;return this.arr[n]=t,this._length=e+1,n}pop(){const t=this._length;if(0===t)return;const e=this._front+t-1&this._capacity-1,n=this.arr[e];return this.arr[e]=void 0,this._length=t-1,n}shift(){const t=this._length;if(0===t)return;const e=this._front,n=this.arr[e];return this.arr[e]=void 0,this._front=e+1&this._capacity-1,this._length=t-1,n}get length(){return this._length}checkCapacity(t){this._capacity<t&&this.resizeTo(Ms(1.5*this._capacity+16))}resizeTo(t){const e=this._capacity;this._capacity=t;const n=this._front,r=this._length;if(n+r>e){const t=n+r&e-1;!function(t,e,n,r,s){for(let i=0;i<s;++i)n[i+r]=t[i+e],t[i+e]=void 0}(this.arr,0,this.arr,e,t)}}},Ls=class extends Ts{};function Rs(t){return"function"==typeof t}function zs(){return"1"}var Bs=class{constructor(t,{initFn:e=zs,pauseFn:n,resumeFn:r,capacity:s=32}={}){if(Rs(n)!==Rs(r))throw new Error("pauseFn and resumeFn must be both set for pausing");this.maxConcurrency=t,this.free=new Is(t),this.waiting=new Is(s),this.releaseEmitter=new Ls,this.useDefaultTokens=e===zs,this.pauseFn=n,this.resumeFn=r,this.paused=!1,this.releaseEmitter.on("release",(t=>{const e=this.waiting.shift();e?e.resolve(t):(this.resumeFn&&this.paused&&(this.paused=!1,this.resumeFn()),this.free.push(t))}));for(let n=0;n<t;n++)this.free.push(e())}tryAcquire(){return this.free.pop()}acquire(t){let e=this.tryAcquire();return void 0!==e?Promise.resolve(e):new Promise(((e,n)=>{this.pauseFn&&!this.paused&&(this.paused=!0,this.pauseFn());const r=this.waiting.push({resolve:e,reject:n});return t&&t.addEventListener("abort",(()=>{this.waiting[r]=void 0;const e=t.reason instanceof Error?t.reason:new Error(t.reason||"aborted");t.alreadyRejected=!0,n(e)})),r}))}release(t){this.releaseEmitter.emit("release",this.useDefaultTokens?"1":t)}drain(){const t=new Array(this.maxConcurrency);for(let e=0;e<this.maxConcurrency;e++)t[e]=this.acquire();return Promise.all(t)}pendingCount(){return this.waiting.length}};function _s(t,{timeUnit:e=1e3,uniformDistribution:n=!1}={}){const r=new Bs(n?1:t),s=n?e/t:e;return async function(){await r.acquire(),setTimeout((()=>r.release()),s)}}import{createAbilityInjector as Ps}from"custom-ability";import{defineProperty as Fs}from"util-ex";var Vs=class extends AbortController{constructor(t){super(),Fs(this,"parent",t)}abort(t,e){this.signal.aborted||("string"==typeof t&&(t=new r(t)),t&&e&&"object"==typeof t&&Object.assign(t.data,e),super.abort(t))}throwRejected(t){const e=this.signal;if(e.aborted){if(void 0===t&&(t=e.alreadyRejected),t)return!0;throw e.reason instanceof Error?e.reason:new r(e.reason||"aborted")}}},Us=class{get maxTaskConcurrency(){return this._maxTaskConcurrency}get semaphore(){const t=this._maxTaskConcurrency;let e=this.__task_semaphore;return t>0&&!e&&(e=this.__task_semaphore=new Bs(t-1)),e}isAborted(t){const e=this.hasAsyncFeature(Ai);let n=this.__task_aborter;if(n&&e){if(null==t)throw new c("Missing taskId",this.name+".isAborted",f.InvalidArgument);n=n[t]}return!n||n.signal.aborted}getRunningTask(t){const e=this.hasAsyncFeature(Ai);let n=this.__task_aborter;if(n&&e){if(null==t)throw new c("Missing taskId",this.name+".getRunningTask",f.InvalidArgument);n=n[t]}return n?.signal.aborted&&(e?this.__task_aborter[t]=void 0:this.__task_aborter=void 0,n=void 0),n}getRunningTaskCount(){let t;if(this.hasAsyncFeature(Ai)){const e=this.__task_aborter;t=e&&Object.entries(e).filter((([t,n])=>{if(!n?.signal.aborted)return!0;e[t]=void 0})).length}else{const e=this.__task_aborter;t=e?.signal.aborted?0:1}return t}_generateAsyncTaskId(t,e){if(e||(e=this.__task_aborter),null==t&&(t=0,e))for(;e[t];)t++;return t}$generateAsyncTaskId(t,e){const n=this.super,r=this.self||this;return t=n?n.call(r,t):this._generateAsyncTaskId(t,e)}createAborter(t,e,n=!0){const r=this.hasAsyncFeature(Ai);if(!r&&n&&this.getRunningTask())throw new c("The task is running",this.name,f.TooManyRequests);const s=t?.aborter||new Vs(this);if(!(s instanceof Vs)){if(!(s instanceof AbortController))throw new c("aborter should be an AbortController",this.name,f.InvalidArgument);Object.setPrototypeOf(s,new Vs(this))}if(r){null==this.__task_aborter&&(this.__task_aborter={});const t=this.__task_aborter;null==e&&(e=this.generateAsyncTaskId(e,t)),s.id=e,t[e]=s}else this.__task_aborter=s;const i=t?.timeout;return i>0&&(s.timeoutId=setTimeout((()=>{s.timeoutId=void 0,this.abort("timeout",{timeout:i})}),i)),s.signal.addEventListener("abort",(()=>{const t=s.timeoutId;t&&(s.timeoutId=void 0,clearTimeout(t));const e=s.signal;try{this.emit&&this.emit("aborting",e.reason,e.reason?.data)}finally{s.streamController?.error(e.reason)}})),s}$cleanMultiTaskAborter(t,e){const n=this.super,r=this.self||this;n?n.call(r,t,e):r._cleanMultiTaskAborter(t,e)}cleanTaskAborter(t){if(this.hasAsyncFeature(Ai)){const e=this.__task_aborter;this.cleanMultiTaskAborter(t.id,e)}else this.__task_aborter=void 0}_cleanMultiTaskAborter(t,e){"number"==typeof t?e[t]=void 0:delete e[t]}createTaskPromise(t,e,n){const r=this.createAborter(e,n?.taskId,n?.raiseError);void 0===e&&(e={}),"object"==typeof e&&(e.aborter=r);let s=t(e,r).then((t=>{if(t&&t instanceof ReadableStream){const e=()=>{this.cleanTaskAborter(r)},n=on({onStart:t=>{Fs(r,"streamController",t)},onFinal:e,onError:e,onTransform:(t,e)=>(t&&"object"==typeof t&&(t.taskId=r.id),t)});t=t.pipeThrough(n)}else this.cleanTaskAborter(r);return t})).catch((t=>{throw this.cleanTaskAborter(r),t})).finally((()=>{r.timeoutId&&(clearTimeout(r.timeoutId),r.timeoutId=void 0)}));return s.task=r,s}runAsyncCancelableTask(t={},e,n){let r=this.createTaskPromise(e,t,n);const s=this.semaphore;if(s){const t=r,e=t.task;r=s.acquire(e.signal).then((()=>t)).finally((()=>{s.release()})),r.task=e}return r}abort(t,e){let n=this.__task_aborter;if(n){const r=n;if(this.hasAsyncFeature(Ai)){const t=e?.taskId;if(null==t)throw new c("Missing data.taskId",this.name+".abort",f.InvalidArgument);n=n[t],this.cleanMultiTaskAborter(t,r)}else this.__task_aborter=void 0;n&&!n.signal.aborted&&n.abort(t,e)}}};Us.prototype.generateAsyncTaskId=function(t,e){return this._generateAsyncTaskId(t,e)},Us.prototype.cleanMultiTaskAborter=function(t,e){return this._cleanMultiTaskAborter(t,e)};var Xs=Ps(Us,"abort",{afterInjection:function(t,e){let n=t.prototype._asyncFeatures||0;n|=Mi.Cancelable,e&&(e.asyncFeatures&&(n|=e.asyncFeatures),e.maxTaskConcurrency>0&&(t.prototype._maxTaskConcurrency=e.maxTaskConcurrency)),t.prototype._asyncFeatures=n}});function qs(t,e){const n=e.global?e:new RegExp(e.source,`${e.flags}g`);let r,s=0;for(;null!==(r=n.exec(t));)s++;return s}import Js from"memoizee";import{canonicalize as Ds}from"json-canonicalize";function Ks(t,e){var n;void 0!==e?.promise||!function(t){return"function"==typeof t&&"AsyncFunction"===t.constructor.name}(t)&&(!(n=t)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)||(e={promise:!0,...e}),void 0===e?.length&&(e={length:!1,...e});const r=e?.normalizer;return Js(t,{...e,normalizer:t=>{if(r){const e=r(t);if("string"===e)return e;e&&(t=e)}return Un(Ds(t))}})}import Ws from"path";import{packageDirectorySync as Zs}from"pkg-dir";function Gs(t){const e=Zs({cwd:t});if(e)return e;const n=t.split(Ws.sep);let r=n.lastIndexOf("dist");if(r>0)return n.slice(0,r).join(Ws.sep);if(r=n.lastIndexOf("src"),r>0)return n.slice(0,r).join(Ws.sep);throw new Error("can not find package directory")}import Qs from"path";function Hs(t,e){try{const n=Qs.relative(Qs.resolve(t),Qs.resolve(e));return!n.startsWith("..")&&!Qs.isAbsolute(n)}catch{return!1}}function Ys(t,e){return e?.some((e=>Hs(e,t)))}import{isRegExp as ti,isRegExpStr as ei}from"util-ex";function ni(t){return ei(t)||ti(t)}function ri(t){return t.replace(/\x1B[[(?);]{0,2}(;?\d)*./g,"")}import si from"path";import{fileURLToPath as ii}from"url";import{AutoTokenizer as oi}from"@xenova/transformers";var ai=ii(import.meta.url),ci=si.dirname(ai),ui=si.join(Gs(ci),".cache"),fi=new Map,li={"deepseek-ai/DeepSeek-V2-Lite-Chat":"deepseek2","Qwen/Qwen2.5-0.5B":"Qwen2.5","Xenova/gpt-4":"gpt-4 / gpt-3.5-turbo / text-embedding-ada-002","Xenova/text-davinci-003":"text-davinci-003 / text-davinci-002","Xenova/gpt-3":"gpt-3","Xenova/grok-1-tokenizer":"Grok-1","Xenova/claude-tokenizer":"Claude","Xenova/mistral-tokenizer-v3":"Mistral v3","Xenova/mistral-tokenizer-v1":"Mistral v1","Xenova/gemma-tokenizer":"Gemma","Xenova/gemma2-tokenizer":"Gemma2","Xenova/llama3-tokenizer-new":"Llama 3","unsloth/Llama-3.2-1B-Instruct":"Llama 3.2","Xenova/llama-tokenizer":"LLaMA / Llama 2","Xenova/c4ai-command-r-v01-tokenizer":"Cohere Command-R","Xenova/t5-small":"T5","Xenova/bert-base-cased":"bert-base-cased"},hi={deepseek2:"deepseek-ai/DeepSeek-V2-Lite-Chat","qwen2.5":"Qwen/Qwen2.5-0.5B","gpt-4":"Xenova/gpt-4","gpt-3.5-turbo":"Xenova/gpt-4","text-embedding-ada-002":"Xenova/gpt-4","text-davinci-003":"Xenova/text-davinci-003","text-davinci-002":"Xenova/text-davinci-003","gpt-3":"Xenova/gpt-3","grok-1":"Xenova/grok-1-tokenizer",claude:"Xenova/claude-tokenizer",mistral:"Xenova/mistral-tokenizer-v3",mistral3:"Xenova/mistral-tokenizer-v3",mistral1:"Xenova/mistral-tokenizer-v1",gemma:"Xenova/gemma-tokenizer",gemma2:"Xenova/gemma2-tokenizer",llama3:"Xenova/llama3-tokenizer-new",llama2:"Xenova/llama-tokenizer",llama:"Xenova/llama-tokenizer","llama3.2":"unsloth/Llama-3.2-1B-Instruct","cohere-command-r":"Xenova/c4ai-command-r-v01-tokenizer",t5:"Xenova/t5-small","bert-cased":"Xenova/bert-base-cased"};async function wi(t){let e=fi.get(t);return e||(e=oi.from_pretrained(t,{cache_dir:ui}),fi.set(t,e)),e}async function pi(t,e="qwen2.5"){hi[e]&&(e=hi[e]);return(await wi(e)).encode(t)}async function di(t,e="qwen2.5"){return(await pi(t,e)).length}function mi(t,e){const n=e?.capitalize??!0;let r=e?.delimiter??/[_-]/g;r instanceof RegExp&&(r.flags.includes("g")||(r=new RegExp(r.source,r.flags+"g")));let s=(t=t.replace(r," ")).split(" ").map((t=>t.trim())).filter(Boolean);return n&&(s=s.map((t=>t.charAt(0).toUpperCase()+t.slice(1)))),t=s.join(" ")}async function yi(t,e){let n,r=1984,s=!0,i=!1,o=!0,a=di,u=!0;if(e&&(n=e.modelId,e.size>=0&&(r=e.size),void 0!==e.corrected&&(s=e.corrected),void 0!==e.completeSentence&&(i=e.completeSentence),void 0!==e.truncLastSection&&(o=e.truncLastSection),"function"==typeof e.countLLMTokens&&(a=e.countLLMTokens),void 0!==e.bySentence&&(u=e.bySentence)),!u)throw new d("truncateToTokenLimit only implemented by sentence","truncateToTokenLimit");if(r>0){let u=await a(t,n);const f=e?.sentences??$e(t,e);if(u>r)for(u=await a(f.join("\n"),n);u>r&&f.length;){const e=f.pop();if(e){if(u-=await a(e+"\n",n),i||s)t=f.join("\n");else{const n=t.lastIndexOf(e);if(-1===n)throw new c(`Can not find sentence: ${e}`,"truncateContentToTokenLimit");t=t.slice(0,n)}if(u<=1)throw new c(`Can not truncate content to fit within the token limit: ${r}`,"truncateContentToTokenLimit");if(u<=r&&o){const e=f[f.length-1];if(e&&je(e)){if(u-await a(e,n)>9){const n=t.lastIndexOf(e);if(-1===n)throw new c(`Can not find sentence: ${e}`,"truncateContentToTokenLimit");t=t.slice(0,n).trimEnd()}}}}else u--}else t=f.join("\n")}if(!t)throw new c(`Can not truncate content to fit within the token limit: ${r}`,"truncateContentToTokenLimit");return t}async function gi(t,e){let n,r=1984,s=!0,i=di,o=!0;if(e&&(n=e.modelId,e.size>=0&&(r=e.size),void 0!==e.truncLastSection&&(s=e.truncLastSection),"function"==typeof e.countLLMTokens&&(i=e.countLLMTokens),void 0!==e.bySentence&&(o=e.bySentence)),!o)throw new d("truncateToTokenLimit only implemented by sentence","truncateToTokenLimit");if(r>0){const e=(t=t.slice()).join("\n");let o=await i(e,n);if(o>r)for(;o>r&&t.length;){const e=t.pop();if(e){if(o-=await i(e,n),o<=1)throw new c(`Can not truncate content to fit within the token limit: ${r}`,"truncateContentToTokenLimit");if(o<=r&&s){const e=t[t.length-1];if(e&&je(e)){o-await i(e,n)>9&&t.pop()}}}}}if(!t.length)throw new c(`Empty. Can not truncate content to fit within the token limit: ${r}`,"truncateContentToTokenLimit");return t}async function bi(t,e){let n,r=1984,s=di;if(e&&(n=e.modelId,"function"==typeof e.countLLMTokens&&(e.size>=0&&(r=e.size),s=e.countLLMTokens)),r>0){await s(t,n)}}import vi from"fs";async function*xi(t,e){const n=(e={...e,completeSentence:!1,corrected:!1}).size??1984,r=e.modelId,s=e.metaInfo?.size??(await vi.promises.stat(t)).size;let i=Math.trunc(s/2);if(i<=n){let s=Zr(await vi.promises.readFile(t));if(i=await di(s,r),i<=n)yield s;else do{const t=await yi(s,{...e,modelId:r,size:n});yield t,s=s.slice(t.length)}while(s)}else{const s=ReadableStream.from(vi.createReadStream(t)).getReader();let i="";for(;;){const{done:t,value:o}=await s.read();if(t)break;i+=Zr(o);const a=$e(i,e);let c=a.pop();if(c){const t=i.lastIndexOf(c);c=i.slice(t),i=i.slice(0,t)}if(i.length>=n){const t=await yi(i,{...e,modelId:r,size:n,sentences:a});i=i.slice(t.length),yield t}for(;i.length>n;){const t=$e(i,e),s=await yi(i,{...e,modelId:r,size:n,sentences:t});i=i.slice(s.length),yield s}void 0!==c&&(i+=c)}for(;i;){const t=$e(i,e),s=await yi(i,{...e,modelId:r,size:n,sentences:t});i=i.slice(s.length),yield s}}}async function*Ei(t,e){const n=e?.size??1984,r=e?.modelId,s=e?.metaInfo?.size??(await vi.promises.stat(t)).size;let i=Math.trunc(s/2);if(i<=n){let s=Zr(await vi.promises.readFile(t));if(i=await di(s,r),i<=n)yield $e(s,e);else{let t=$e(s,e);do{const s=await gi(t,{...e,modelId:r,size:n});yield s,t=t.slice(s.length)}while(t.length)}}else{const s=ReadableStream.from(vi.createReadStream(t)).getReader();let i="";const o=e?.completeSentence,a=e?.corrected,c=!o&&!a;let u;for(;;){const{done:t,value:o}=await s.read();if(t)break;i+=Zr(o),u=$e(i,e);let a=u.pop();if(i.length>=n){const t=await gi(u,{...e,modelId:r,size:n});i=c?i.slice(t.length):u.join("\n"),u=u.slice(t.length),i=u.join("\n"),yield t}for(;i.length>n;){const t=await gi(u,{...e,modelId:r,size:n});u=u.slice(t.length),i=u.join("\n"),yield t}a&&u.push(a)}if(u)for(;u.length;){const t=await gi(u,{...e,modelId:r,size:n});u=u.slice(t.length),yield t}}}async function $i(t,e){const n=e?.size??1984,r=e?.modelId;let s=$e(t,e);const i=[];if(await di(t,r)<=n)i.push(s);else do{const t=await gi(s,{...e,modelId:r,size:n});i.push(t),s=s.slice(t.length)}while(s.length);return i}import{YAMLMap as ki}from"yaml";var Si=class{constructor(t){t&&Object.assign(this,t)}};function Oi(t,e){const n={tag:t,collection:"map",nodeClass:class extends ki{constructor(){super(...arguments),this.tag=t}toJSON(t,n){n={...n,mapAsMap:!1};const r=super.toJSON(t,n);return new e(r)}},identify:t=>t instanceof e};return n}var ji,Ai=0,Ci=1,Ti=2,Ni=(t=>(t[t.MultiTask=Ai]="MultiTask",t[t.Cancelable=1]="Cancelable",t[t.Priority=2]="Priority",t))(Ni||{}),Mi=((ji=Mi||{})[ji.MultiTask=1<<Ai]="MultiTask",ji[ji.Cancelable=2]="Cancelable",ji[ji.Priority=4]="Priority",ji),Ii=class t extends e{static{this.items={}}static get(t){return this.items[t]}static list(){return this.items}static getByTag(t){let e;for(const n in this.list()){const r=this.get(n);let s=r.tags;if("string"==typeof s){if(s===t){e=r;break}}else if(Array.isArray(s)&&s.indexOf(t)>=0){e=r;break}}return e}static getAllByTag(t){let e=[];for(const n in this.list()){const r=this.get(n);let s=r.tags;"string"==typeof s?s===t&&e.push(r):Array.isArray(s)&&s.indexOf(t)>=0&&e.push(r)}return e}static hasAsyncFeature(t){const e=this.prototype;let n=e.asyncFeatures;return e._asyncFeatures&&(n|=e._asyncFeatures),Cs.has(n,t)}static run(t,e){const n=this.get(t);if(n)return n.run(e);throw new w(`${t} to run`,this.name)}static runSync(t,e){const n=this.get(t);if(n)return n.runSync(e);throw new w(`${t} to run`,this.name)}static getFunc(t){const e=this.get(t);return e?.getFunc()}static runWithPos(t,...e){const n=this.get(t);if(n)return n.runWithPos(...e);throw new w(`${t} to run`,this.name)}static runWithPosSync(t,...e){const n=this.get(t);if(n)return n.runWithPosSync(...e);throw new w(`${t} to run`,this.name)}static getFuncWithPos(t){const e=this.get(t);return e?.getFuncWithPos()}static register(e,n={}){switch(typeof e){case"string":n.name=e;break;case"function":n.func=e;break;case"object":n=e}e=n.name;let r=!!this.get(e);if(r)r=!1;else{if(!(n instanceof t))return r=new this(n),r.register();this.items[e]=n,r=n}return r}static unregister(t){const e=this.items[t];return e&&delete this.items[t],e}constructor(t,e={}){switch(super(),typeof t){case"string":e.name=t;break;case"function":e.func=t;break;case"object":e=t}this.name=t=e.name,e.scope&&(this.scope=e.scope),"function"==typeof e.setup&&e.setup.call(this,e),this.initialize(e)}register(){const e=this.constructor,n=this.depends;if(n){const e=Object.keys(n);for(const r of e){const e=n[r];e instanceof t&&e.register()}}return e.register(this)}unregister(){return this.constructor.unregister(this.name)}arr2ObjParams(t){if(this.params&&(t.length>1||Array.isArray(t[0])||t[0]&&"object"!=typeof t[0])){const e={},n=Object.keys(this.params);let r=Math.min(n.length,t.length);for(let s=0;s<r;s++)e[n[s]]=t[s];t=[e]}return t}obj2ArrParams(t){const e=[];if(t&&this.params&&Array.isArray(this.params)){const n=Object.keys(t);let r=Math.min(n.length,this.params.length);for(let s=0;s<r;s++)e.push(t[n[s]])}return e}runSync(t){const e=this.params&&Array.isArray(this.params);if(Array.isArray(t)){if(e)return this.func(...t);m("the function is not support array params, the params must be object!",this.name)}return e?(t=this.obj2ArrParams(t),console.warn('Warning:Use runWithPos() instead of run() for the "'+this.name+'" is function with position params'),this.func(...t)):this.func(t)}run(t){return this.runSync(t)}runAs(t,e){return this.runAsSync(t,e)}runAsSync(t,e){return this.constructor.runSync(t,e)}getFunc(t){return t?this.constructor.getFunc(t):this.runSync.bind(this)}runWithPosSync(...t){return this.params&&!Array.isArray(this.params)&&(t=this.arr2ObjParams(t)),this.func(...t)}runWithPosAsSync(t,...e){return this.constructor.runWithPosSync(t,...e)}runWithPos(...t){return this.runWithPosSync(...t)}runWithPosAs(t,...e){return this.runWithPosAsSync(t,...e)}getFuncWithPos(t){return t?this.constructor.getFuncWithPos(t):this.runWithPosSync.bind(this)}hasAsyncFeature(t){let e=this.asyncFeatures;return this._asyncFeatures&&(e|=this._asyncFeatures),Cs.has(e,t)}isStream(t){return this.stream}},Li={name:{type:"string"},description:{type:"string"},func:{type:"function",assign(t,e,r,s,i){let o=t;const a=typeof t;return i.isExported?o="function"===a?t.toString():t:t&&("string"!==a&&(t=t.toString()),o=n(t,e.scope)),o}},params:{type:"object"},result:{type:"any"},setup:{type:"function"},depends:{type:"object",exported:!1},tags:{type:["array","string"]},isApi:{type:"boolean"},stream:{type:"boolean"},asyncFeatures:{type:"number"}};Ii.defineProperties(Ii,Li);var Ri=class extends Ii{constructor(){super(...arguments),this._emitter=new t,this.description="Return event bus",this.result="event"}get emitter(){return this._emitter}func(){return this.emitter}},zi=new Ri(Xe);import{Cache as Bi}from"secondary-cache";function _i({key:t,value:e,options:n}={}){return void 0!==t?null===e?this.cache.del(t):void 0!==e?this.cache.set(t,e,n):this.cache.get(t):(n&&this.cache.setDefaultOptions(n),this.cache)}function Pi(t,e){let n=Ii.get(t);return n||(n=new Ii(t,{func:_i,description:"get/set LRU cache or return the LRUCache object",params:{key:{name:"key",type:"string",description:"the key is undefined means change the default cache options"},value:{name:"value",type:"any",description:"the value to store, if value is null means remove the key"},options:{name:"options",type:"object|number",description:"the optional cache options:{capacity,expires,cleanInterval} or expires"}},result:"any"}),n.cache=new Bi(e)),n}var Fi=Pi("lrucache"),Vi=class t extends Ii{static get apiRoot(){return t._apiRoot}static setApiRoot(e){t._apiRoot=e}static async loadFrom(){if(this._apiRoot){const t=await fetch(this._apiRoot,{headers:{"Content-Type":"application/json"}}),e=await t.json();e&&this.loadFromSync(e)}else m("missing apiRoot to load tools","ClientTools")}static loadFromSync(e){for(const n in e){const r=this.get(n),s=e[n];r?r instanceof t?r.assign(s):m(`${n} already registered as ${r.constructor.name}`,"ClientTools"):this.register(s)}}static async fetch(t,e){const n=this.get(t);if(n&&n.fetch)return n.fetch(e)}getUrlParams(t){if(void 0!==t){const e=JSON.stringify(t);if("{}"!==e&&"[]"!==e&&'""'!==e)return"?p="+encodeURIComponent(e)}return""}async fetch(t,e,n){const r={...this.fetchOptions};let s;r.headers&&r.headers["Content-Type"]||(r.headers={"Content-Type":"application/json",...r.headers}),t?.stream&&!r.headers.Connection&&(r.headers.Connection="keep-alive"),e||(e=this.action||"post"),"res"===e&&(e="get"),n?("string"!=typeof n&&(n=JSON.stringify(n)),n=this.name+"/"+n):n=this.name,r.method=e.toUpperCase(),"get"===e||"delete"===e?s=n+this.getUrlParams(t):(r.body=JSON.stringify(t),s=n);const i=await fetch(`${this.apiRoot}/${s}`,r);if(!i.ok){throw await this.errorFrom(i)}return i}async errorFrom(t){let e,n=t.status,r=t.statusText,s=this.name;if(t.body){const n=await t.text();try{const t=JSON.parse(n);t&&(t.error&&(r=t.error),t.name&&(s=t.name),t.data&&(e=t.data,e.name=s,e.what&&(e.msg=r,r=e.what)),t.message&&(r=r+":"+t.message))}catch(t){console.warn("🚀 ~ parse error body to json:",t)}}return u(r,s,n)}async func(t){const e=await this.fetch(t);if(t?.stream)return e;return await e.json()}},Ui={...x};Vi.defineProperties(Vi,Ui);var Xi=class extends Vi{async _func(t,e){const n=await this.fetch(e,t);if(e?.stream)return n;return await n.json()}async func(t){const e=t.action;return e&&delete t.action,this._func(e,t)}assignMethods(t){if(Array.isArray(t))for(const e of t){const t=e.startsWith("$")?e.slice(1):e;this[t]||(this[t]=(t=>this._func.bind(this,t))(e))}}},qi={methods:{type:"array",assign(t,e,n,r,s){s?.isExported||e.assignMethods(t)}}};Xi.defineProperties(Xi,qi);var Ji=class extends Xi{async fetch(t,e){if(t||(t={}),e&&"res"===this.action){if("get"===e||"delete"===e){let n=t.id;return n||m("id is required"),"string"==typeof n&&(n=encodeURIComponent(n)),delete t.id,super.fetch(t,e,n)}"list"===e?e="get":e.startsWith("$")&&(t.act=e,e="post")}return await super.fetch(t,e)}},Di=class extends Ji{constructor(){super(...arguments),this._sseEvents={},this._forwardEvents=new Set,this.name=Ue,this.description="subscribe server sent event",this.ebListener=async function(...t){const e=this.type;this.target.publish&&await this.target.publish({data:t,event:e})}}get evtSource(){let t=this._es;return t&&t.readyState!==EventSource.CLOSED||(t=this.initEventSource(this._esEvents)),t}get active(){return!!this._es&&this._es.readyState!==EventSource.CLOSED}set active(t){t!==this.active&&(t?this.initEventSource(this._esEvents):this._es&&(this._es.close(),this._es=void 0))}initEventSource(t){if("string"==typeof t&&(t=[t]),this._es&&this._es.readyState!==EventSource.CLOSED){if(!this._esEvents||t&&t.every((t=>this._esEvents.includes(t))))return this._es;this._es.close()}const e=t?this.getUrlParams({event:t}):"",n=`${this.apiRoot}/${this.name}${e}`,r=this._es=new EventSource(n);return Object.entries(this._sseEvents).forEach((([t,e])=>{r.addEventListener(t,e)})),this._esEvents=t,r}esListener(t){const e=t.data?JSON.parse(t.data):void 0,n=t.type;if(!this._forwardEvents.has(n)){const t=this.emitter;t&&e&&n&&(Array.isArray(e)?t.emit(n,...e):t.emit(n,e))}}async subscribe(t){const e=await this.sub({event:t});"string"==typeof t&&(t=[t]);const n=this.evtSource;for(const e of t)if(!this._sseEvents[e]){const t=this._sseEvents[e]=this.esListener.bind(this);n.addEventListener(e,t)}return e}async unsubscribe(t){const e=await this.unsub({event:t});"string"==typeof t&&(t=[t]);for(const e of t){const t=this._sseEvents[e];t&&(delete this._sseEvents[e],this.evtSource.removeEventListener(e,t))}return e}forwardEvent(t){"string"==typeof t&&(t=[t]);for(const e of t)this._forwardEvents.has(e)||(this._forwardEvents.add(e),this.on&&this.on(e,this.ebListener))}unforwardEvent(t){"string"==typeof t&&(t=[t]);for(const e of t)this._forwardEvents.has(e)&&(this._forwardEvents.delete(e),this.off&&this.off(e,this.ebListener))}async init(t){if(this.active=!1,this.initEventSource(t),t)return await this.subscribe(t)}},Ki=new Di(Ue);import{getAllNames as Wi}from"util-ex";var Zi=class t extends Ii{static get apiRoot(){return this._apiRoot}static setApiRoot(t){this._apiRoot=t}static toJSON(){const e={};for(const n in this.items){let r=this.items[n];(r instanceof t||r.isApi)&&(r.allowExportFunc||(r=r.toJSON(),delete r.func),e[n]=r)}return e}func({}){}},Gi={...x};Zi.defineProperties(Zi,Gi);var Qi=class extends Zi{constructor(t,e={}){super(t,e),this.params={act:{type:"string"}};const n=this.methods=[];this.initRpcMethods(n)}get SpecialRpcMethodNames(){return this.constructor.SpecialRpcMethodNames}initRpcMethods(t=this.methods){const e=this.SpecialRpcMethodNames;if(Array.isArray(e))for(const n of e)"function"==typeof this[n]&&t.push(n);Wi(Object.getPrototypeOf(this)).filter((t=>t.startsWith("$")&&"function"==typeof this[t])).forEach((e=>{t.push(e);const n=e.slice(1);void 0===this[n]&&(this[n]=this[e])}))}cast(t,e){let n=this.params[t];return n&&("string"!=typeof n&&(n=n.type),"number"===n&&(e=Number(e))),e}getMethodFromParams(t){const e=t?.act;return e}castParams(t){return t}func(t){const e=this.getMethodFromParams(t);if(e&&"function"==typeof this[e])return t=this.castParams(t),this[e](t);throw new w(e,this.name)}};Qi.defineProperties(Qi,{methods:{type:"array"}});var Hi=class extends Qi{constructor(t,e={}){super(t,e),this.action="res",this.params={id:{type:"string"},val:{type:"any"}}}static{this.SpecialRpcMethodNames=v}getMethodFromParams(t){let e=t?._req?.method?.toLowerCase();return"get"===e&&void 0===t.id&&(e="list"),"post"===e&&t.act&&(e=t.act),e}castParams(t){return void 0!==t.id&&(t.id=this.cast("id",t.id)),t}},Yi=zi.runSync(),to=class t extends Hi{constructor(){super(...arguments),this.name=Ue,this.description="subscribe server sent event",this.result="event",this.depends={[Xe]:zi}}static get sse(){return this._sse||(this._sse=new Ke),this._sse}get sse(){return this.constructor.sse}static publish(e,n){return t.sse.publish(e,n)}static{this.ebListener=function(...e){t.sse.publish(e,this.type)}}static subscribe(e,n,r){return t.sse.subscribe(e,n,r)}static alreadyForward(e){const n=Yi.listeners(e);for(const e of n)if(e===t.ebListener)return!0}publishSSE(t,e){return this.constructor.publish(t,e)}subscribeSSE(t,e,n){return"string"==typeof n&&(n=[n]),this.constructor.subscribe(t,e,n)}forward(e){Array.isArray(e)||(e=[e]);for(const n of e)t.alreadyForward(n)||Yi.on(n,t.ebListener)}unforward(e){"string"==typeof e&&(e=[e]);for(const n of e)Yi.off(n,t.ebListener)}list({_req:t,_res:e,event:n}){t&&e&&this.subscribeSSE(t,e,n)}$sub({event:t}){if(t)return this.forward(t),{event:t};m("event is required","sub",f.InvalidArgument)}$unsub({event:t}){if(t)return this.unforward(t),{event:t};m("event is required","unsub",f.InvalidArgument)}$publish({event:t,data:e}){if(t&&e){"string"==typeof t&&(t=[t]);for(const n of t)this.publishSSE(e,n);return{event:t}}m("event or data is required","pub",f.InvalidArgument)}isStream(t){return"list"===this.getMethodFromParams(t)}},eo=new to(Ue);function no(){zi.register(),Fi.register()}export{b as PASSING_SCORE,v as ActionNames,x as RemoteToolFuncSchema,r as AbortError,s as AbortErrorCode,i as AlreadyExistsError,o as AlreadyExistsErrorCode,a as BaseError,c as CommonError,u as createError,f as ErrorCode,l as InternalErrorCode,h as NotFoundErrorCode,w as NotFoundError,p as NotImplementedErrorCode,d as NotImplementationError,m as throwError,$ as parseDateFormat,C as toDateTime,T as textToDate,N as dateToText,S as formatISO,O as parseISO,j as toDate,M as AITextGenerationFinishReasons,I as AIMessageTypes,L as AIChatRoles,R as messagesToText,z as PromptTypes,B as PromptTemplateTypes,P as defaultTemplateFormat,F as PromptTemplate,X as PromptExampleSelector,Q as tokenize,Et as parse,_t as Interpreter,Ut as builtins,qt as EnvironmentEx,Jt as Template,Zt as HfPromptTemplate,Gt as createHfValueFunc,Qt as parseFString,Ht as interpolateFString,te as FStringPromptTemplate,ne as interpolateGolangTemplate,re as GolangPromptTemplate,se as sortedValues,ie as FewShotPromptTemplate,ce as interpolateEnv,ue as expandEnv,fe as expandObjEnv,$e as splitSentence,ke as completeSentences,Se as concatText,Oe as isSentenceEnding,je as isSectionString,Ae as isTitleString,Ce as isListItemString,Te as isSepLineString,Ne as isPunctuationChar,Ie as isLangUsingSpaces,Le as findIndexNonEmptyFrom,Re as removeMarkdownBold,ze as removeMarkdownItalic,Be as removeMarkdownBoldAndItalic,_e as splitParagraph,Pe as truncTo,Fe as wait,Ue as EventName,Xe as EventBusName,qe as backendEventable,De as SSEChannelAlreadyClosedErrCode,Ke as SSEChannel,We as isWebStream,Ze as RStreamErrCode,Ge as ResponseRStreamErrCode,Qe as ReadableStreamError,He as getResponseErrorReadableStream,Ye as createEmptyReadableStream,en as createEventStreamTransformer,nn as trimStartOfStreamHelper,rn as AIStream,sn as readableFromAsyncIterable,on as createCallbacksTransformer,vn as uuid,ln as v1,hn as v4,wn as v5,pn as stringify,dn as parse2,mn as validate,yn as version,gn as NIL,Mn as canonicalize,In as base32768,Bn as xxhash32,_n as xxhash64,Pn as HashAlgorithm,Vn as xxhash,Un as xxhashAsStr,Xn as hashStream,Jn as FilenameReservedRegex,Dn as WindowsReservedNameRegex,Gn as filenameReservedRegex,Qn as reControlCharsRegex,Hn as isValidFilename,Yn as isValidFilepath,tr as sanitizeFilename,er as sanitizeFilepath,nr as getMultiLevelExtname,rr as extNameLevel,or as isModelNameMatched,ar as getAllEnumKeys,wr as parseObjectArguments,pr as simplifyObjectArguments,dr as parseObjectArgumentInfos,mr as ChoiceArgProcessor,yr as TemplateArgProcessor,gr as AIArgProcessor,vr as quoteStr,kr as parseObjectArgInfo,Sr as parseObjectArgumentsAsArgInfos,Or as parseCommand,Ar as replaceWithPlaceholder,Cr as restoreFromPlacehoders,Ir as parseJsJson,Lr as parseJsJsonSimpleSync,Br as filterValidFnScope,_r as getKeysPath,Fr as createEndWithRepetitionDetector,Jr as fileIsExists,Dr as loadFileFromPaths,Wr as loadTextFromPaths,Zr as decodeCharset,Gr as readFilenamesRecursiveSync,Qr as getRealFilepath,Hr as hashFile,Yr as getFileMetaInfo,ts as getHashAlgoBySize,es as detectCharset,cs as ConfigFile,hs as mimeType,ps as registerYamlTag,ds as parseYaml,ms as stringifyYaml,ys as getConfigFileNames,gs as getConfigs,bs as saveConfigFile,ks as jsonFilterToWhere,Ss as matchUrlProtocol,Os as paramsSizeToScaleStr,js as scaleStrToParamsSize,As as jsonToMarkdownStr,Cs as IntSet,Ns as DefaultAsyncSemaphoreCapacity,Bs as Semaphore,_s as RateLimit,Ai as ToolAsyncMultiTaskBit,Ci as ToolAsyncCancelableBit,Ti as ToolAsyncPriorityBit,Ni as AsyncFeatureBits,Mi as AsyncFeatures,Ii as ToolFunc,Li as ToolFuncSchema,Vs as TaskAbortController,Us as CancelableAbility,Xs as makeToolFuncCancelable,qs as countRegexMatches,Ks as memoize,Gs as getPackageDir,Hs as isSubdirectory,Ys as hasDirectoryIn,ni as isRegExp,ri as stripConsoleColor,li as LLM_TOKENIZER_NAMES,hi as LLM_TOKENIZER_NAMES_MAP,wi as getLLMTokenizer,pi as encodeLLMTokens,di as countLLMTokens,mi as formatTextWithSpace,yi as truncateToTokenLimit,gi as truncateToTokenLimitEx,bi as truncateByToken,xi as readTextFileChunks,Ei as readTextFileChunksEx,$i as splitChunks,Si as YamlTypeBaseObject,Oi as createYamlObjectTag,y as createAbilityInjector,g as toRegExp,Vi as ClientTools,Ui as ClientToolFuncSchema,Zi as ServerTools,Gi as ServerToolFuncSchema,Ri as EventToolFunc,zi as event,_i as _lrucache,Pi as createLRUCache,Fi as lrucache,Ji as ResClientTools,Di as EventClient,Ki as eventClient,Hi as ResServerTools,to as EventServer,eo as eventServer,no as registerCoreTools};
|
package/dist/funcs.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-
|
|
1
|
+
export { J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-BC3GQn6-.mjs';
|
|
2
2
|
import 'events-ex';
|
|
3
3
|
import 'property-manager';
|
|
4
4
|
import 'secondary-cache';
|
package/dist/funcs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-
|
|
1
|
+
export { J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-BC3GQn6-.js';
|
|
2
2
|
import 'events-ex';
|
|
3
3
|
import 'property-manager';
|
|
4
4
|
import 'secondary-cache';
|