@isdk/ai-tool 0.8.2 → 0.9.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-BIJ2JH4U.mjs +1 -0
- package/dist/chunk-OYMVHUDZ.mjs +1 -0
- package/dist/funcs.d.mts +16 -5
- package/dist/funcs.d.ts +16 -5
- package/dist/funcs.js +1 -1
- package/dist/funcs.mjs +1 -1
- package/dist/index.d.mts +839 -563
- package/dist/index.d.ts +839 -563
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/test/util.d.mts +1 -1
- package/dist/test/util.d.ts +1 -1
- package/dist/test/util.js +1 -1
- package/dist/test/util.mjs +1 -1
- package/docs/api/@isdk/namespaces/ClientTools/README.md +11 -0
- package/docs/api/@isdk/namespaces/ClientTools/functions/get.md +27 -0
- package/docs/api/@isdk/namespaces/EventStates/variables/ABORT.md +1 -1
- package/docs/api/@isdk/namespaces/EventStates/variables/CONTINUE.md +1 -1
- package/docs/api/@isdk/namespaces/EventStates/variables/DONE.md +1 -1
- package/docs/api/@isdk/namespaces/EventStates/variables/STOPPED.md +1 -1
- package/docs/api/classes/BinarySemaphore.md +148 -67
- package/docs/api/classes/CancelableAbility.md +95 -43
- package/docs/api/classes/ClientToolTransport.md +31 -16
- package/docs/api/classes/ClientTools.md +868 -158
- package/docs/api/classes/CmdArgLexer.md +82 -0
- package/docs/api/classes/CmdArgParser.md +56 -0
- package/docs/api/classes/ConfigFile.md +6 -6
- package/docs/api/classes/EnvPromptTemplate.md +224 -52
- package/docs/api/classes/EventClient.md +902 -192
- package/docs/api/classes/EventEmitter.md +62 -12
- package/docs/api/classes/EventServer.md +895 -182
- package/docs/api/classes/EventToolFunc.md +801 -123
- package/docs/api/classes/FStringPromptTemplate.md +224 -52
- package/docs/api/classes/FewShotPromptTemplate.md +231 -59
- package/docs/api/classes/GolangPromptTemplate.md +224 -52
- package/docs/api/classes/HttpClientToolTransport.md +33 -19
- package/docs/api/classes/HttpServerToolTransport.md +15 -15
- package/docs/api/classes/IntSet.md +21 -21
- package/docs/api/classes/MailboxClientTransport.md +398 -0
- package/docs/api/classes/MailboxServerTransport.md +433 -0
- package/docs/api/classes/PromptExampleSelector.md +11 -11
- package/docs/api/classes/PromptTemplate.md +199 -51
- package/docs/api/classes/ReadableStreamError.md +2 -2
- package/docs/api/classes/ResClientTools.md +875 -165
- package/docs/api/classes/ResServerTools.md +869 -156
- package/docs/api/classes/RpcMethodsClientTool.md +870 -160
- package/docs/api/classes/RpcMethodsServerTool.md +865 -152
- package/docs/api/classes/SSEChannel.md +23 -23
- package/docs/api/classes/Semaphore.md +148 -76
- package/docs/api/classes/ServerToolTransport.md +14 -13
- package/docs/api/classes/ServerTools.md +854 -138
- package/docs/api/classes/SignalGate.md +12 -12
- package/docs/api/classes/SseClientPubSubTransport.md +4 -4
- package/docs/api/classes/SseServerPubSubTransport.md +13 -13
- package/docs/api/classes/TaskAbortController.md +33 -11
- package/docs/api/classes/ToolFunc.md +725 -119
- package/docs/api/classes/ToolTransport.md +7 -7
- package/docs/api/classes/YamlTypeBaseObject.md +2 -2
- package/docs/api/enumerations/AsyncFeatureBits.md +4 -4
- package/docs/api/enumerations/AsyncFeatures.md +4 -4
- package/docs/api/enumerations/CmdArgTokenType.md +129 -0
- package/docs/api/enumerations/HashAlgorithm.md +38 -12
- package/docs/api/functions/AIArgProcessor.md +8 -17
- package/docs/api/functions/AIStream.md +1 -1
- package/docs/api/functions/ChoiceArgProcessor.md +13 -15
- package/docs/api/functions/DefaultDateFormat.md +1 -1
- package/docs/api/functions/ObjectArgsToArgsInfo.md +11 -9
- package/docs/api/functions/RateLimit.md +33 -6
- package/docs/api/functions/TemplateArgProcessor.md +13 -15
- package/docs/api/functions/assignDirs.md +1 -1
- package/docs/api/functions/beforeShutdown.md +3 -3
- package/docs/api/functions/calcPerplexity.md +3 -3
- package/docs/api/functions/calcPerplexitySimple.md +3 -3
- package/docs/api/functions/cmdArgEvaluate.md +28 -0
- package/docs/api/functions/cmdArgsToMergedObject.md +34 -0
- package/docs/api/functions/completeSentences.md +1 -1
- package/docs/api/functions/concatText.md +1 -1
- package/docs/api/functions/countLLMTokens.md +1 -1
- package/docs/api/functions/countRegexMatches.md +1 -1
- package/docs/api/functions/createCallbacksTransformer.md +23 -19
- package/docs/api/functions/createEmptyReadableStream.md +1 -1
- package/docs/api/functions/createEndWithRepetitionDetector.md +4 -4
- package/docs/api/functions/createEventStreamTransformer.md +1 -1
- package/docs/api/functions/createHfValueFunc.md +1 -1
- package/docs/api/functions/createLRUCache.md +1 -1
- package/docs/api/functions/createYamlObjectTag.md +1 -1
- package/docs/api/functions/dateToText.md +1 -1
- package/docs/api/functions/decodeCharset.md +1 -1
- package/docs/api/functions/defaultsWithConcat.md +1 -1
- package/docs/api/functions/detectCharset.md +1 -1
- package/docs/api/functions/encodeLLMTokens.md +1 -1
- package/docs/api/functions/ensureQuoted.md +3 -1
- package/docs/api/functions/evaluateExpression.md +40 -0
- package/docs/api/functions/eventable.md +1 -1
- package/docs/api/functions/expandConfig.md +1 -1
- package/docs/api/functions/expandEnv.md +1 -1
- package/docs/api/functions/expandObjEnv.md +1 -1
- package/docs/api/functions/expandPath.md +1 -1
- package/docs/api/functions/expandPathInObject.md +1 -1
- package/docs/api/functions/expandPaths.md +1 -1
- package/docs/api/functions/extNameLevel.md +1 -1
- package/docs/api/functions/extractCodeBlock.md +51 -0
- package/docs/api/functions/fileIsExists.md +3 -3
- package/docs/api/functions/filterValidFnScope.md +3 -3
- package/docs/api/functions/findIndexNonEmptyFrom.md +1 -1
- package/docs/api/functions/findPort.md +13 -5
- package/docs/api/functions/formatTextWithSpace.md +1 -1
- package/docs/api/functions/funcGetMeta.md +1 -1
- package/docs/api/functions/funcWithMeta.md +4 -4
- package/docs/api/functions/genUrlParamsStr.md +1 -1
- package/docs/api/functions/getAllEnumKeys.md +1 -1
- package/docs/api/functions/getConfigFileNames.md +1 -1
- package/docs/api/functions/getConfigs.md +1 -1
- package/docs/api/functions/getEnvVairables.md +1 -1
- package/docs/api/functions/getFileMetaInfo.md +1 -1
- package/docs/api/functions/getHashAlgoBySize.md +1 -1
- package/docs/api/functions/getKeysPath.md +1 -1
- package/docs/api/functions/getLLMTokenizer.md +1 -1
- package/docs/api/functions/getMultiLevelExtname.md +1 -1
- package/docs/api/functions/getPackageDir.md +1 -1
- package/docs/api/functions/getRealFilepath.md +1 -1
- package/docs/api/functions/getResponseErrorReadableStream.md +2 -2
- package/docs/api/functions/getXDGConfigs.md +1 -1
- package/docs/api/functions/hasDirectoryIn.md +3 -3
- package/docs/api/functions/hash.md +25 -4
- package/docs/api/functions/hashFile.md +1 -1
- package/docs/api/functions/hashObject.md +23 -1
- package/docs/api/functions/hashStream.md +25 -4
- package/docs/api/functions/initShutdown.md +1 -1
- package/docs/api/functions/isIdentifier.md +30 -0
- package/docs/api/functions/isLangUsingSpaces.md +1 -1
- package/docs/api/functions/isListItemString.md +3 -3
- package/docs/api/functions/isModelNameMatched.md +3 -3
- package/docs/api/functions/isPathIdentifier.md +23 -0
- package/docs/api/functions/isPunctuationChar.md +1 -1
- package/docs/api/functions/isQuoted.md +4 -1
- package/docs/api/functions/isRegExp.md +20 -1
- package/docs/api/functions/isSameString.md +1 -1
- package/docs/api/functions/isSectionString.md +3 -3
- package/docs/api/functions/isSentenceEnding.md +1 -1
- package/docs/api/functions/isSepLineString.md +3 -3
- package/docs/api/functions/isStrWrapped.md +3 -1
- package/docs/api/functions/isSubdirectory.md +1 -1
- package/docs/api/functions/isTitleString.md +3 -3
- package/docs/api/functions/isValidFilename.md +1 -1
- package/docs/api/functions/isValidFilepath.md +1 -1
- package/docs/api/functions/isWebStream.md +1 -1
- package/docs/api/functions/joinSplitWords.md +1 -1
- package/docs/api/functions/jsonFilterToWhere.md +1 -1
- package/docs/api/functions/jsonToMarkdownStr.md +1 -1
- package/docs/api/functions/loadAIConfig.md +1 -1
- package/docs/api/functions/loadConfig.md +1 -1
- package/docs/api/functions/loadConfigFile.md +1 -1
- package/docs/api/functions/loadFileFromPaths.md +1 -1
- package/docs/api/functions/loadTextFromPaths.md +1 -1
- package/docs/api/functions/lrucache.md +1 -1
- package/docs/api/functions/matchUrlProtocol.md +3 -3
- package/docs/api/functions/memoize.md +1 -1
- package/docs/api/functions/mergeArray.md +1 -1
- package/docs/api/functions/messagesToText.md +1 -1
- package/docs/api/functions/normalizePath.md +1 -1
- package/docs/api/functions/paramsSizeToScaleStr.md +1 -1
- package/docs/api/functions/parseCommand.md +21 -4
- package/docs/api/functions/parseJsJson.md +1 -1
- package/docs/api/functions/parseJsJsonSimpleSync.md +1 -1
- package/docs/api/functions/parseObjectArguments.md +17 -33
- package/docs/api/functions/parseYaml.md +1 -1
- package/docs/api/functions/prependNewlineIfMultiline.md +39 -0
- package/docs/api/functions/pruneSubdirectories.md +1 -1
- package/docs/api/functions/pruneSubdirectoriesInPlace.md +1 -1
- package/docs/api/functions/quoteStr.md +4 -1
- package/docs/api/functions/readFilenamesRecursiveSync.md +1 -1
- package/docs/api/functions/readTextFileChunks.md +1 -1
- package/docs/api/functions/readTextFileChunksEx.md +1 -1
- package/docs/api/functions/readableFromAsyncIterable.md +1 -1
- package/docs/api/functions/registerCoreTools.md +1 -1
- package/docs/api/functions/registerYamlTag.md +2 -2
- package/docs/api/functions/removeMarkdownBold.md +1 -1
- package/docs/api/functions/removeMarkdownBoldAndItalic.md +1 -1
- package/docs/api/functions/removeMarkdownItalic.md +1 -1
- package/docs/api/functions/replaceWithPlaceholder.md +3 -18
- package/docs/api/functions/restoreFromPlacehoders.md +2 -20
- package/docs/api/functions/sanitizeFilename.md +1 -1
- package/docs/api/functions/sanitizeFilepath.md +1 -1
- package/docs/api/functions/saveConfigFile.md +1 -1
- package/docs/api/functions/scaleStrToParamsSize.md +1 -1
- package/docs/api/functions/shutdown.md +2 -2
- package/docs/api/functions/simplifyObjectArguments.md +4 -1
- package/docs/api/functions/simplifyResult.md +34 -0
- package/docs/api/functions/sleep.md +1 -1
- package/docs/api/functions/sortedValues.md +1 -1
- package/docs/api/functions/splitChunks.md +1 -1
- package/docs/api/functions/splitParagraph.md +1 -1
- package/docs/api/functions/splitSentence.md +1 -1
- package/docs/api/functions/splitWords.md +1 -1
- package/docs/api/functions/stringifyYaml.md +1 -1
- package/docs/api/functions/stripConsoleColor.md +1 -1
- package/docs/api/functions/textToDate.md +1 -1
- package/docs/api/functions/textify.md +43 -0
- package/docs/api/functions/toDateTime.md +3 -3
- package/docs/api/functions/toRegExp.md +1 -1
- package/docs/api/functions/trimStartOfStreamHelper.md +1 -1
- package/docs/api/functions/truncTo.md +1 -1
- package/docs/api/functions/truncateByToken.md +1 -1
- package/docs/api/functions/truncateToTokenLimit.md +1 -1
- package/docs/api/functions/truncateToTokenLimitEx.md +1 -1
- package/docs/api/functions/uuid.md +1 -1
- package/docs/api/functions/wrapEventEmitter.md +1 -1
- package/docs/api/functions/wrapFlagValue.md +29 -0
- package/docs/api/functions/xxhash.md +27 -6
- package/docs/api/functions/xxhash32.md +22 -4
- package/docs/api/functions/xxhash64.md +22 -4
- package/docs/api/functions/xxhashAsStr.md +27 -6
- package/docs/api/functions/yieldExec.md +1 -1
- package/docs/api/globals.md +51 -18
- package/docs/api/interfaces/AIChatAssistantMessageParam.md +14 -14
- package/docs/api/interfaces/AIChatContentPartBase.md +26 -0
- package/docs/api/interfaces/AIChatContentPartImage.md +15 -3
- package/docs/api/interfaces/AIChatContentPartText.md +15 -3
- package/docs/api/interfaces/AIChatMessageParamBase.md +9 -9
- package/docs/api/interfaces/AIChatMessageToolCall.md +12 -8
- package/docs/api/interfaces/AIChatSystemMessageParam.md +10 -10
- package/docs/api/interfaces/AIChatToolChoiceFuncObject.md +3 -3
- package/docs/api/interfaces/AIChatToolChoiceObject.md +2 -2
- package/docs/api/interfaces/AIChatToolDefinition.md +45 -0
- package/docs/api/interfaces/AIChatToolFunc.md +5 -5
- package/docs/api/interfaces/AIChatToolFuncParam.md +3 -3
- package/docs/api/interfaces/AIChatToolMessageParam.md +13 -13
- package/docs/api/interfaces/AIChatToolParam.md +2 -2
- package/docs/api/interfaces/AIChatToolTypeObject.md +2 -2
- package/docs/api/interfaces/AIChatUserMessageParam.md +14 -14
- package/docs/api/interfaces/AIResult.md +7 -7
- package/docs/api/interfaces/AIStreamParser.md +2 -2
- package/docs/api/interfaces/AIStreamParserOptions.md +2 -2
- package/docs/api/interfaces/BaseFunc.md +15 -15
- package/docs/api/interfaces/BaseFuncItem.md +16 -16
- package/docs/api/interfaces/BinarySemaphoreAcquireOptions.md +9 -2
- package/docs/api/interfaces/BinarySemaphoreOptions.md +22 -5
- package/docs/api/interfaces/BinarySemaphoreReleaseOptions.md +7 -5
- package/docs/api/interfaces/CancelableAbilityOptions.md +4 -4
- package/docs/api/interfaces/ClientFuncItem.md +70 -19
- package/docs/api/interfaces/CmdArgAIChoiceConfig.md +97 -0
- package/docs/api/interfaces/CmdArgArgsInfo.md +31 -0
- package/docs/api/interfaces/CmdArgContext.md +103 -0
- package/docs/api/interfaces/CmdArgFlagMetadata.md +21 -0
- package/docs/api/interfaces/CmdArgMapResult.md +41 -0
- package/docs/api/interfaces/CmdArgParseResult.md +51 -0
- package/docs/api/interfaces/CmdArgParsedCommand.md +41 -0
- package/docs/api/interfaces/CmdArgParserOptions.md +225 -0
- package/docs/api/interfaces/CmdArgProcessorResultOptions.md +22 -0
- package/docs/api/interfaces/CmdArgSimplifyOptions.md +101 -0
- package/docs/api/interfaces/CmdArgToken.md +51 -0
- package/docs/api/interfaces/EventClientFuncParams.md +5 -5
- package/docs/api/interfaces/EventServerFuncParams.md +21 -7
- package/docs/api/interfaces/FewShotPromptTemplateOptions.md +18 -6
- package/docs/api/interfaces/FuncItem.md +19 -15
- package/docs/api/interfaces/FuncParam.md +5 -5
- package/docs/api/interfaces/FuncParams.md +1 -1
- package/docs/api/interfaces/Funcs.md +1 -1
- package/docs/api/interfaces/HashAlgoParams.md +36 -5
- package/docs/api/interfaces/IClientToolTransport.md +24 -10
- package/docs/api/interfaces/IFileMetaInfo.md +8 -8
- package/docs/api/interfaces/IPubSubClientTransport.md +4 -4
- package/docs/api/interfaces/IPubSubServerTransport.md +14 -14
- package/docs/api/interfaces/IReadTextFileChunksOptions.md +11 -11
- package/docs/api/interfaces/IServerToolTransport.md +8 -8
- package/docs/api/interfaces/IToolTransport.md +5 -5
- package/docs/api/interfaces/ITruncateToTokenLimitOptions.md +10 -10
- package/docs/api/interfaces/JsonFilter.md +1 -1
- package/docs/api/interfaces/MailboxClientOptions.md +74 -0
- package/docs/api/interfaces/MailboxServerOptions.md +69 -0
- package/docs/api/interfaces/ProbabilityItem.md +4 -4
- package/docs/api/interfaces/PromptExampleSelectorOptions.md +3 -3
- package/docs/api/interfaces/PromptTemplateOptions.md +8 -0
- package/docs/api/interfaces/PubSubClientStream.md +11 -11
- package/docs/api/interfaces/PubSubServerSession.md +8 -8
- package/docs/api/interfaces/RegisterOptions.md +298 -0
- package/docs/api/interfaces/RemoteFuncItem.md +63 -20
- package/docs/api/interfaces/ReplacePlacehoderOptions.md +5 -5
- package/docs/api/interfaces/ResClientFuncParams.md +3 -3
- package/docs/api/interfaces/ResServerFuncParams.md +20 -6
- package/docs/api/interfaces/RpcMethodsClientFuncParams.md +2 -2
- package/docs/api/interfaces/RpcMethodsServerFuncParams.md +18 -4
- package/docs/api/interfaces/SanitizeFilenameOptions.md +3 -3
- package/docs/api/interfaces/SectionStringOptions.md +3 -3
- package/docs/api/interfaces/SemaphoreOptions.md +30 -7
- package/docs/api/interfaces/SemaphoreTaskItem.md +18 -5
- package/docs/api/interfaces/ServerFuncItem.md +71 -20
- package/docs/api/interfaces/ServerFuncParams.md +14 -4
- package/docs/api/interfaces/SplitSentenceOptions.md +5 -5
- package/docs/api/interfaces/StreamCallbacksAndOptions.md +80 -7
- package/docs/api/interfaces/TaskAbortControllers.md +2 -2
- package/docs/api/interfaces/TaskPromise.md +6 -6
- package/docs/api/interfaces/TextifyInlineOptions.md +51 -0
- package/docs/api/interfaces/TextifyOptions.md +108 -0
- package/docs/api/interfaces/ToolFuncContext.md +73 -0
- package/docs/api/interfaces/ToolFuncPackage.md +4 -4
- package/docs/api/interfaces/ToolFuncRegistryIsolateOptions.md +41 -0
- package/docs/api/interfaces/UnregisterOptions.md +56 -0
- package/docs/api/type-aliases/AIChatContentPart.md +2 -2
- package/docs/api/type-aliases/AIChatMessageParam.md +1 -1
- package/docs/api/type-aliases/AIChatRole.md +2 -2
- package/docs/api/type-aliases/AIChatTemplateCaps.md +239 -0
- package/docs/api/type-aliases/AIChatToolChoiceParam.md +1 -1
- package/docs/api/type-aliases/AIMessageType.md +1 -1
- package/docs/api/type-aliases/AIModelNameRule.md +1 -1
- package/docs/api/type-aliases/AIModelNameRuleFn.md +1 -1
- package/docs/api/type-aliases/AIModelNameRules.md +1 -1
- package/docs/api/type-aliases/AITextGenerationFinishReason.md +1 -1
- package/docs/api/type-aliases/ActionName.md +1 -1
- package/docs/api/type-aliases/ArgProcessor.md +24 -0
- package/docs/api/type-aliases/ArrayMergeWay.md +1 -1
- package/docs/api/type-aliases/AsyncTaskId.md +1 -1
- package/docs/api/type-aliases/BeforeShutdownListener.md +1 -1
- package/docs/api/type-aliases/CmdArgFlagValue.md +14 -0
- package/docs/api/type-aliases/CmdArgFlagsRecord.md +13 -0
- package/docs/api/type-aliases/EventErrorListenerFn.md +1 -1
- package/docs/api/type-aliases/EventListenerFn.md +1 -1
- package/docs/api/type-aliases/FuncParamType.md +1 -1
- package/docs/api/type-aliases/PromptExamples.md +1 -1
- package/docs/api/type-aliases/PubSubClientId.md +1 -1
- package/docs/api/type-aliases/PubSubCtx.md +6 -6
- package/docs/api/type-aliases/RpcMethodHandler.md +1 -1
- package/docs/api/type-aliases/SSEClient.md +5 -5
- package/docs/api/type-aliases/SemaphoreIsReadyFuncType.md +4 -1
- package/docs/api/type-aliases/SimplifiedResultType.md +14 -0
- package/docs/api/type-aliases/StreamCloseStatus.md +16 -0
- package/docs/api/type-aliases/TFunc.md +1 -1
- package/docs/api/type-aliases/TextifyInlineStyleMode.md +16 -0
- package/docs/api/type-aliases/TextifyStringQuoting.md +16 -0
- package/docs/api/type-aliases/UUIDVersions.md +3 -1
- package/docs/api/variables/AIChatRoles.md +2 -2
- package/docs/api/variables/AIMessageTypes.md +1 -1
- package/docs/api/variables/AITextGenerationFinishReasons.md +1 -1
- package/docs/api/variables/ActionNames.md +1 -1
- package/docs/api/variables/ArrayMergeWay.md +1 -1
- package/docs/api/variables/ArrayMergeWaySymbol.md +1 -1
- package/docs/api/variables/CMD_ARG_FLAG_SYMBOL.md +21 -0
- package/docs/api/variables/CMD_ARG_PROCESSOR_RESULT.md +22 -0
- package/docs/api/variables/CMD_ARG_UNRESOLVED_SYMBOL.md +16 -0
- package/docs/api/variables/ClientEventPrefix.md +2 -2
- package/docs/api/variables/ClientToolFuncSchema.md +27 -17
- package/docs/api/variables/DEFAULT_CONFIG_NAME.md +1 -1
- package/docs/api/variables/DefaultAsyncSemaphoreCapacity.md +4 -1
- package/docs/api/variables/EventBusName.md +2 -2
- package/docs/api/variables/EventName.md +2 -2
- package/docs/api/variables/FilenameReservedRegex.md +1 -1
- package/docs/api/variables/FuncMetaSymbol.md +2 -2
- package/docs/api/variables/IDENTIFIER_REGEX.md +14 -0
- package/docs/api/variables/LLM_TOKENIZER_NAMES.md +1 -1
- package/docs/api/variables/LLM_TOKENIZER_NAMES_MAP.md +1 -1
- package/docs/api/variables/PASSING_SCORE.md +1 -1
- package/docs/api/variables/PATH_IDENTIFIER_REGEX.md +13 -0
- package/docs/api/variables/RESERVED_WORDS.md +13 -0
- package/docs/api/variables/RStreamErrCode.md +1 -1
- package/docs/api/variables/RemoteToolFuncSchema.md +36 -4
- package/docs/api/variables/ResponseRStreamErrCode.md +1 -1
- package/docs/api/variables/RpcMethodsClientToolSchema.md +2 -2
- package/docs/api/variables/RpcMethodsServerToolSchema.md +2 -2
- package/docs/api/variables/SHUTDOWN_SIGNALS.md +1 -1
- package/docs/api/variables/SSEChannelAlreadyClosedErrCode.md +1 -1
- package/docs/api/variables/SecondaryCache.md +1 -1
- package/docs/api/variables/ServerToolFuncSchema.md +27 -17
- package/docs/api/variables/StrangeHumanName.md +1 -1
- package/docs/api/variables/ToolAsyncCancelableBit.md +1 -1
- package/docs/api/variables/ToolAsyncMultiTaskBit.md +1 -1
- package/docs/api/variables/ToolAsyncPriorityBit.md +1 -1
- package/docs/api/variables/ToolFuncSchema.md +13 -13
- package/docs/api/variables/WindowsReservedNameRegex.md +1 -1
- package/docs/api/variables/backendEventable.md +23 -3
- package/docs/api/variables/base32768.md +2 -2
- package/docs/api/variables/event.md +1 -1
- package/docs/api/variables/eventClient.md +1 -1
- package/docs/api/variables/eventServer.md +1 -1
- package/docs/api/variables/lrucache.md +1 -1
- package/docs/api/variables/makeToolFuncCancelable.md +23 -3
- package/docs/api/variables/wait.md +1 -1
- package/docs/transport.dev.md +206 -0
- package/package.json +12 -10
- package/dist/chunk-4FKBOPZI.mjs +0 -1
- package/dist/chunk-TGTHY57V.mjs +0 -1
- package/dist/find-port-qS1CZ9c-.d.mts +0 -3
- package/dist/find-port-qS1CZ9c-.d.ts +0 -3
- package/dist/index-BLW3R7VS.d.mts +0 -1826
- package/dist/index-BLW3R7VS.d.ts +0 -1826
- package/docs/api/@isdk/namespaces/uuidv5/README.md +0 -12
- package/docs/api/@isdk/namespaces/uuidv5/variables/DNS.md +0 -11
- package/docs/api/@isdk/namespaces/uuidv5/variables/URL.md +0 -11
- package/docs/api/functions/nanoid.md +0 -45
- package/docs/api/functions/parseObjectArgInfo.md +0 -33
- package/docs/api/functions/parseObjectArgumentInfos.md +0 -29
- package/docs/api/functions/parseObjectArgumentsAsArgInfos.md +0 -46
- package/docs/api/functions/uuidParse.md +0 -21
- package/docs/api/functions/uuidStringify.md +0 -25
- package/docs/api/functions/uuidValidate.md +0 -21
- package/docs/api/functions/uuidVersion.md +0 -21
- package/docs/api/functions/uuidv1.md +0 -61
- package/docs/api/functions/uuidv4.md +0 -61
- package/docs/api/functions/uuidv5.md +0 -69
- package/docs/api/functions/uuidv6.md +0 -61
- package/docs/api/functions/uuidv7.md +0 -61
- package/docs/api/interfaces/AIChoiceConfig.md +0 -65
- package/docs/api/interfaces/BinarySemaphoreReleaserFunc.md +0 -37
- package/docs/api/interfaces/ParseObjectArgumentOptions.md +0 -89
- package/docs/api/variables/uuidNIL.md +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{findPort as i}from"@isdk/util";export{i as findPort};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{event as e}from"@isdk/tool-event";import{Cache as t}from"secondary-cache";import{ToolFunc as o}from"@isdk/tool-func";import{LRUCache as n}from"secondary-cache";var i=t;function r({key:e,value:t,options:o}={}){return void 0!==e?null===t?this.cache.del(e):void 0!==t?this.cache.set(e,t,o):this.cache.get(e):(o&&this.cache.setDefaultOptions(o),this.cache)}function a(e,n){let i=o.get(e);return i||(i=new o(e,{func:r,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"}),i.cache=new t(n)),i}var c=a("lrucache");export*from"@isdk/tool-event";function s(){e.register(),c.register()}export{i as SecondaryCache,r as _lrucache,a as createLRUCache,c as lrucache,n as LRUCache,s as registerCoreTools};
|
package/dist/funcs.d.mts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@isdk/tool-event';
|
|
2
|
+
import { Cache, ICacheOptions } from 'secondary-cache';
|
|
2
3
|
export { LRUCache } from 'secondary-cache';
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { ToolFunc } from '@isdk/tool-func';
|
|
5
|
+
|
|
6
|
+
declare const SecondaryCache: typeof Cache;
|
|
7
|
+
declare function _lrucache(this: ToolFunc, { key, value, options }?: {
|
|
8
|
+
key?: string;
|
|
9
|
+
value?: any;
|
|
10
|
+
options?: ICacheOptions | number;
|
|
11
|
+
}): Cache;
|
|
12
|
+
declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
|
|
13
|
+
declare const lrucache: ToolFunc;
|
|
14
|
+
|
|
15
|
+
declare function registerCoreTools(): void;
|
|
16
|
+
|
|
17
|
+
export { SecondaryCache, _lrucache, createLRUCache, lrucache, registerCoreTools };
|
package/dist/funcs.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@isdk/tool-event';
|
|
2
|
+
import { Cache, ICacheOptions } from 'secondary-cache';
|
|
2
3
|
export { LRUCache } from 'secondary-cache';
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { ToolFunc } from '@isdk/tool-func';
|
|
5
|
+
|
|
6
|
+
declare const SecondaryCache: typeof Cache;
|
|
7
|
+
declare function _lrucache(this: ToolFunc, { key, value, options }?: {
|
|
8
|
+
key?: string;
|
|
9
|
+
value?: any;
|
|
10
|
+
options?: ICacheOptions | number;
|
|
11
|
+
}): Cache;
|
|
12
|
+
declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
|
|
13
|
+
declare const lrucache: ToolFunc;
|
|
14
|
+
|
|
15
|
+
declare function registerCoreTools(): void;
|
|
16
|
+
|
|
17
|
+
export { SecondaryCache, _lrucache, createLRUCache, lrucache, registerCoreTools };
|
package/dist/funcs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,h=(t,e,n,h)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let a of r(e))o.call(t,a)||a===n||s(t,a,{get:()=>e[a],enumerable:!(h=i(e,a))||h.enumerable});return t},a=(t,i,r)=>(r=null!=t?e(n(t)):{},h(!i&&t&&t.__esModule?r:s(r,"default",{value:t,enumerable:!0}),t)),c={};((t,e)=>{for(var i in e)s(t,i,{get:e[i],enumerable:!0})})(c,{ClientEventPrefix:()=>jt,EventClient:()=>mt,EventServer:()=>St,EventToolFunc:()=>st,LRUCache:()=>nt.LRUCache,SecondaryCache:()=>ot,_lrucache:()=>ht,createLRUCache:()=>at,event:()=>it,eventClient:()=>wt,eventServer:()=>Et,lrucache:()=>ct,registerCoreTools:()=>$t}),module.exports=(t=c,h(s({},"__esModule",{value:!0}),t));var u=(()=>"undefined"==typeof document?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href)(),l=require("events-ex"),f=(require("lodash-es"),require("property-manager")),d=require("util-ex"),p=require("@isdk/common-error"),y=(require("custom-ability"),require("util-ex"),["get","post","put","delete","patch","list","res"]),b={action:{type:"string",assign:(t,e,s,i,r)=>t||"post"},fetchOptions:{type:"object"},allowExportFunc:{type:"boolean"}},v=(require("date-fns"),require("date-fns"),require("@isdk/template-engines"),require("@isdk/template-engines"));function m(t){return Object.keys(t).sort().map(e=>t[e])}var w=class extends v.StringTemplate{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 v.StringTemplate?t.examplePrompt:v.StringTemplate.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 s=await this.examplePrompt.format(t);e.push(s)}else if("string"==typeof t)e.push(t);else if(t){const s=m(t);s.length>0&&e.push(...s)}const s=[this.prefix,...e,this.suffix].join(this.exampleSeparator),i=this.templateFormat;return await v.StringTemplate.format({template:s,data:t,templateFormat:i})}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}};v.StringTemplate.register(w,{name:"fewshot",aliases:["few_shot"]});(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=>{0});require("@isdk/detect-text-language"),new RegExp("([A-Z][a-z]{1,2}\\.)@(\\w)","g"),new RegExp("(\\.[a-zA-Z]\\.)@(\\w)","g");var g=require("custom-ability"),q=(require("events-ex"),"event"),k="event-bus";(0,g.createAbilityInjector)(function(t,e){const s=e?.eventBusName||k;return class{static get emitter(){if(!this._emitter){const t=this.get(s)?.emitter;t&&(this._emitter=t,this.prototype._events=t._events)}return this._emitter}get emitter(){return this.constructor._emitter}on(e,s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return i.on(e,s)}once(e,s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return i.once(e,s)}off(e,s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return i.off(e,s)}emit(e,...s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return"error"===e?this.emitError.apply(this,s):i.emit.call(this,e,this.name,...s)}emitError(e,...s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return i.emit.call(this,"error",e,this.name,...s)}async emitAsync(e,...s){const i=t.emitter;if(!i)throw new TypeError("EventBackend required");return i.emitAsync.call(this,e,this.name,...s)}}},!0),require("nanoid"),require("uuid"),a(require("base32768")),require("uuid");var A=a(require("xxhashjs")),{h32:T,h64:x}=(a(require("base32768")),require("json-canonicalize"),require("hash-wasm"),A.default);require("json-canonicalize"),a(require("base32768")),require("eventsource-parser");require("@isdk/util"),require("util-ex"),require("lodash-es"),require("util-ex"),require("lodash-es"),require("util-ex");var j="[a-zA-Z_$][a-zA-Z_\\d$]*",S=(new RegExp(`^\\s*(\\(\\s*\\)|${j}|\\(${`${j}\\s*(,\\s*${j})*`}\\))\\s*=>`),a(require("mime-type/with-db")),a(require("jschardet")),require("@isdk/util")),E=require("yaml-types");require("mime-type/with-db"),require("@isdk/util");(0,S.registerYamlTag)(E.regexp);var $=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}},C=require("util-ex"),P=require("events-ex");function F(t=0){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 R=class extends Array{constructor(t,e){Array.isArray(t)?(super(...t),this._length=t.length,t=void 0):(super(),this._length=0),this._capacity=F(t),this._front=0,this._disableAutoResize=e}push(t){let e=this._length;this.checkCapacity(e+1);const s=this._front+e&this._capacity-1;return this[s]=t,++e<=this._capacity&&(this._length=e),s}unshift(t){let e=this._length;this.checkCapacity(++e);const s=this._capacity,i=(this._front-1&s-1^s)-s;return this[i]=t,this._front=i,e<=this._capacity&&(this._length=e),i}pop(t){let e=this._length;if(0===e)return;let s=this._front+e-1&this._capacity-1,i=this[s];for(;--e>0&&t&&null==i;)s--,i=this[s];return this[s]=void 0,this._length=e,i}shift(t){let e=this._length;if(0===e)return;let s=this._front,i=this[s];for(;--e>0&&t&&null==i;)s=s+1&this._capacity-1,i=this[s];return this[s]=void 0,this._front=s+1&this._capacity-1,this._length=e,i}get size(){return this._length}get(t){let e;if(t===(0|t)){const s=this._length;t<0&&(t+=s),t>=0&&t<s&&(e=this[this._front+t&this._capacity-1])}return e}peekBack(){const t=this._length;if(0===t)return;return this[this._front+t-1&this._capacity-1]}peekFront(){if(0!==this._length)return this[this._front]}clear(){const t=this._length,e=this._front,s=this._capacity;for(let i=0;i<t;++i)this[e+i&s-1]=void 0;this._length=0,this._front=0}isEmpty(){return 0===this._length}removeAt(t){const e=this._length;if(t<0||t>=e)return;const s=this._front,i=this._capacity-1,r=s+t&i,n=this[r];if(t<e/2)this.copyWithin(s+1&i,s,s+t&i),this[s]=void 0,this._front=s+1&i;else{this.copyWithin(r,r+1&i,s+e&i);this[s+e-1&i]=void 0}return this._length=e-1,n}checkCapacity(t){this._capacity<t&&!this._disableAutoResize&&this.resizeTo(F(1.5*this._capacity+16))}resizeTo(t){const e=this._capacity;this._capacity=t;const s=this._front,i=this._length;if(s+i>e){!function(t,e,s,i,r){for(let n=0;n<r;++n)s[n+i]=t[n+e],t[n+e]=void 0}(this,0,this,e,s+i&e-1)}}},O=require("@isdk/common-error"),_=32;function M(t){return"function"==typeof t}function I(){return"1"}var z,W=class{constructor(t={}){const{initFn:e=I,pauseFn:s,resumeFn:i,capacity:r=_}=t;if(M(s)!==M(i))throw new Error("pauseFn and resumeFn must be both set for pausing");this.waiting=new R(r),this.emitter=new P.EventEmitter,this.useDefaultTokens=e===I,this.pauseFn=s,this.resumeFn=i,this.initTokenFn=e,this.paused=!1,this._activeCount=0,this.initFree(t),this.init(t)}initFree(t){this.free=this.initTokenFn()}onReleased(t){const e=t?.token,s=this.waiting.shift(!0);s?this._dispatchTask(s,t):(this.resumeFn&&this.paused&&(this.paused=!1,this.resumeFn()),this.unlock(e))}init(t){this.emitter.on("release",t=>{this.onReleased(t)})}_newReleaser(t){let e=!1;const s=()=>{e||(e=!0,this.release(t))};return t&&Object.assign(s,t),s}_dispatchTask(t,e){const{resolve:s}=t;s(this._newReleaser(e))}lock(t){let e=this.free;if(e)return this.free=void 0,e}unlock(t){this.free=this.useDefaultTokens?"1":t??this.initTokenFn()}tryAcquire(t){return this.lock(t)}async acquire(t){this._activeCount++;const e=t?.signal,s=t=>{this.pauseFn&&!this.paused&&(this.paused=!0,this.pauseFn());const s=this.waiting.push(t),i=t.reject;return e&&e.addEventListener("abort",()=>{this.waiting[s]=void 0;const t=e.reason instanceof Error?e.reason:new O.AbortError(e.reason||"aborted");e.alreadyRejected=!0,i(t)}),s};let i=this.tryAcquire(t);const r=i&&(0,C.isAsync)(i),n=e=>new Promise((i,r)=>{const n={...t,resolve:i,reject:r,token:e};void 0===e?s(n):this._dispatchTask(n,{...t,token:e})});return r?i.then(t=>n(t)):n(i)}release(t){this._activeCount--,this.emitter.emit("release",t)}drain(){const t=[this.acquire()];return Promise.all(t)}abort(t){let e;for(;e=this.waiting.shift(!0);)e.reject(new O.AbortError(t))}get activeCount(){return this._activeCount}get pendingCount(){return this.waiting.size}},B=class extends W{constructor(t,e){if("number"==typeof t)(e=e||{}).maxConcurrency=t;else{if("number"!=typeof(e=t).maxConcurrency)throw new Error("maxConcurrency must be set");t=e.maxConcurrency}super(e),this.maxConcurrency=e.maxConcurrency,e.isReadyFn&&(this.isReady=e.isReadyFn)}initFree(t){const e=t.maxConcurrency=Math.max(1,t.maxConcurrency);this.free=new R(e);for(let t=0;t<e;t++)this.free.push(this.initTokenFn())}tryAcquire(t){let e=this.isReady;if(e&&(0,C.isAsync)(e)){return e instanceof Promise||(e=e()),e.then(e=>{if(e)return this.lock(t)})}if(!e||e())return this.lock(t)}unlock(t){this.free.push(this.useDefaultTokens?"1":t??this.initTokenFn())}lock(t){return this.free.pop()}drain(){const t=new Array(this.maxConcurrency);for(let e=0;e<this.maxConcurrency;e++)t[e]=this.acquire();return Promise.all(t)}},U=(require("@isdk/common-error"),require("custom-ability")),L=require("util-ex"),N=((z=N||{})[z.MultiTask=1]="MultiTask",z[z.Cancelable=2]="Cancelable",z[z.Priority=4]="Priority",z),Z=class extends AbortController{constructor(t){super(),(0,L.defineProperty)(this,"parent",t)}abort(t,e){this.signal.aborted||("string"==typeof t&&(t=new p.AbortError(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 p.AbortError(e.reason||"aborted")}}},J=class{get maxTaskConcurrency(){return this._maxTaskConcurrency}get semaphore(){return this.getSemaphore()}getSemaphore(t=this._isReadyFn){let e=this._maxTaskConcurrency,s=this.__task_semaphore;return e>0&&!s&&(t&&(t=t.bind(this)),s=this.__task_semaphore=new B(e-1,{isReadyFn:t})),s}static hasAsyncFeature(t){const e=this.prototype;let s=e.asyncFeatures;return e._asyncFeatures&&(s|=e._asyncFeatures),$.has(s,t)}hasAsyncFeature(t){let e=this.asyncFeatures;return this._asyncFeatures&&(e|=this._asyncFeatures),$.has(e,t)}isAborted(t){const e=this.hasAsyncFeature(0);let s=this.__task_aborter;if(s&&e){if(null==t)throw new p.CommonError("Missing taskId",this.name+".isAborted",p.ErrorCode.InvalidArgument);s=s[t]}return!s||s.signal.aborted}getRunningTask(t){const e=this.hasAsyncFeature(0);let s=this.__task_aborter;if(s&&e){if(null==t)throw new p.CommonError("Missing taskId",this.name+".getRunningTask",p.ErrorCode.InvalidArgument);s=s[t]}return s?.signal.aborted&&(e?this.__task_aborter[t]=void 0:this.__task_aborter=void 0,s=void 0),s}getRunningTaskCount(){let t;if(this.hasAsyncFeature(0)){const e=this.__task_aborter;t=e&&Object.entries(e).filter(([t,s])=>{if(!s?.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 s=this.super,i=this.self||this;return t=s?s.call(i,t):this._generateAsyncTaskId(t,e)}createAborter(t,e,s=!0){const i=this.hasAsyncFeature(0);if(!i&&s&&this.getRunningTask())throw new p.CommonError("The task is running",this.name,p.ErrorCode.TooManyRequests);const r=t?.aborter||new Z(this);if(!(r instanceof Z)){if(!(r instanceof AbortController))throw new p.CommonError("aborter should be an AbortController",this.name,p.ErrorCode.InvalidArgument);Object.setPrototypeOf(r,new Z(this))}if(i){null==this.__task_aborter&&(this.__task_aborter={});const t=this.__task_aborter;null==e&&(e=this.generateAsyncTaskId(e,t)),r.id=e,t[e]=r}else this.__task_aborter=r;const n=[...D(t?.signal),...D(t?.signals)];n.length&&function(t,e){if(!e.length)return;const s=[],i=()=>{for(const t of s)try{t()}catch{}s.length=0},r=e.find(t=>t.aborted);if(r){const e=r.reason;try{t.abort(e||"aborted")}catch{}return}for(const i of e){const e=()=>{const e=i.reason;try{t.abort(e||"aborted")}catch(t){console.log(t)}};i.addEventListener("abort",e,{once:!0}),s.push(()=>i.removeEventListener("abort",e))}const n=()=>i();t.signal.addEventListener("abort",n,{once:!0}),s.push(()=>t.signal.removeEventListener("abort",n))}(r,n);const o=t?.timeout;return o>0&&(r.timeoutId=setTimeout(()=>{r.timeoutId=void 0,this.abort("timeout",{timeout:o})},o)),r.signal.addEventListener("abort",()=>{const t=r.timeoutId;t&&(r.timeoutId=void 0,clearTimeout(t));const e=r.signal;try{this.emit&&this.emit("aborting",e.reason,e.reason?.data)}finally{try{r.streamController?.error?.(e.reason)}catch{}}}),r}$cleanMultiTaskAborter(t,e){const s=this.super,i=this.self||this;s?s.call(i,t,e):i._cleanMultiTaskAborter(t,e)}cleanTaskAborter(t){if(this.hasAsyncFeature(0)){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,s){const i=this.createAborter(e,s?.taskId,s?.raiseError);void 0===e&&(e={}),"object"==typeof e&&(e.aborter=i);let r=t(e,i).then(t=>{if(t&&t instanceof ReadableStream){const e=()=>{this.cleanTaskAborter(i)},s=function(t){const e=t||{};return new TransformStream({async start(t){const s=t.error;if(t.error=i=>{s.call(t,i),e.onError&&e.onError(i)},e.onStart)try{await e.onStart(t)}catch(e){t.error(e)}},async transform(t,s){try{let i;e.onTransform&&(i=await e.onTransform(t,s)),i||(i=t),s.enqueue(i)}catch(t){s.error(t)}},async flush(t){if(e.onFinal)try{await e.onFinal(t)}catch(e){return t.error(e)}t.terminate()}})}({onStart:t=>{(0,L.defineProperty)(i,"streamController",t)},onFinal:e,onError:e,onTransform:(t,e)=>(t&&"object"==typeof t&&(t.taskId=i.id),t)});t=t.pipeThrough(s)}else this.cleanTaskAborter(i);return t}).catch(t=>{throw this.cleanTaskAborter(i),t}).finally(()=>{i.timeoutId&&(clearTimeout(i.timeoutId),i.timeoutId=void 0)});return r.task=i,r}runAsyncCancelableTask(t={},e,s){let i=this.createTaskPromise(e,t,s);const r=this.getSemaphore(s?.isReadyFn);if(r){const t=i,e=t.task;i=r.acquire({signal:e.signal}).then(()=>t).finally(()=>{r.release()}),i.task=e}return i}abort(t,e){let s=this.__task_aborter;if(s){const i=s;if(this.hasAsyncFeature(0)){const t=e?.taskId;if(null==t)throw new p.CommonError("Missing data.taskId",this.name+".abort",p.ErrorCode.InvalidArgument);s=s[t],this.cleanMultiTaskAborter(t,i)}else this.__task_aborter=void 0;s&&!s.signal.aborted&&s.abort(t,e)}}};function D(t){return t?Array.isArray(t)?t.filter(Boolean):[t]:[]}J.prototype.generateAsyncTaskId=function(t,e){return this._generateAsyncTaskId(t,e)},J.prototype.cleanMultiTaskAborter=function(t,e){return this._cleanMultiTaskAborter(t,e)};(0,U.createAbilityInjector)(J,"abort",{afterInjection:function(t,e){let s=t.prototype._asyncFeatures||0;s|=N.Cancelable,e&&(e.asyncFeatures&&(s|=e.asyncFeatures),e.maxTaskConcurrency>0&&(t.prototype._maxTaskConcurrency=e.maxTaskConcurrency),e.isReadyFn&&"function"==typeof e.isReadyFn&&(t.prototype._isReadyFn=e.isReadyFn)),t.prototype._asyncFeatures=s}}),a(require("memoizee")),require("json-canonicalize");var G=a(require("path")),H=require("package-directory");require("util-ex");var K=a(require("path")),Q=require("url"),V=(require("@huggingface/transformers"),(0,Q.fileURLToPath)(u)),X=K.default.dirname(V),{exit:Y}=(K.default.join(function(t){const e=(0,H.packageDirectorySync)({cwd:t});if(e)return e;const s=t.split(G.default.sep);let i=s.lastIndexOf("dist");if(i>0)return s.slice(0,i).join(G.default.sep);if(i=s.lastIndexOf("src"),i>0)return s.slice(0,i).join(G.default.sep);throw new Error("can not find package directory")}(X),".cache"),require("yaml"),require("lodash-es"),process),tt=(require("lodash-es"),Symbol("MergeWay"),class t extends f.AdvancePropertyManager{static{this.items={}}static{this.aliases={}}static get(t){let e=this.items[t];return!e&&(t=this.aliases[t])&&(e=this.items[t]),e}static list(){return this.items}static getByTag(t){let e;for(const s in this.list()){const i=this.get(s);let r=i.tags;if("string"==typeof r){if(r===t){e=i;break}}else if(Array.isArray(r)&&r.indexOf(t)>=0){e=i;break}}return e}static getAllByTag(t){let e=[];for(const s in this.list()){const i=this.get(s);let r=i.tags;"string"==typeof r?r===t&&e.push(i):Array.isArray(r)&&r.indexOf(t)>=0&&e.push(i)}return e}static hasAsyncFeature(t){const e=this.prototype;let s=e.asyncFeatures??0;return e._asyncFeatures&&(s|=e._asyncFeatures),$.has(s,t)}static run(t,e){const s=this.get(t);if(s)return s.run(e);throw new p.NotFoundError(`${t} to run`,this.name)}static runSync(t,e){const s=this.get(t);if(s)return s.runSync(e);throw new p.NotFoundError(`${t} to run`,this.name)}static getFunc(t){const e=this.get(t);return e?.getFunc()}static runWithPos(t,...e){const s=this.get(t);if(s)return s.runWithPos(...e);throw new p.NotFoundError(`${t} to run`,this.name)}static runWithPosSync(t,...e){const s=this.get(t);if(s)return s.runWithPosSync(...e);throw new p.NotFoundError(`${t} to run`,this.name)}static getFuncWithPos(t){const e=this.get(t);return e?.getFuncWithPos()}static register(e,s={}){switch(typeof e){case"string":s.name=e;break;case"function":s.func=e;break;case"object":s=e}e=s.name;let i=!!this.get(e);if(i)i=!1;else{if(!(s instanceof t))return i=new this(s),i.register();if(this.items[e]=s,s.alias){const t=s.alias;if("string"==typeof t)this.aliases[t]&&(0,p.throwError)(`Alias ${t} already exists for ${e}`),this.aliases[t]=e;else if(Array.isArray(t))for(const s of t)this.aliases[s]&&(0,p.throwError)(`Alias ${s} already exists for ${e}`),this.aliases[s]=e}i=s}return i}static unregister(t){const e=this.get(t);if(e&&(delete this.items[t],e.alias)){const t=e.alias;if("string"==typeof t)delete this.aliases[t];else if(Array.isArray(t))for(const e of t)delete this.aliases[e]}return 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,s=this.depends;if(s){const e=Object.keys(s);for(const i of e){const e=s[i];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={},s=Object.keys(this.params);let i=Math.min(s.length,t.length);for(let r=0;r<i;r++)e[s[r]]=t[r];t=[e]}return t}obj2ArrParams(t){const e=[];if(t&&this.params&&Array.isArray(this.params)){const s=Object.keys(t);let i=Math.min(s.length,this.params.length);for(let r=0;r<i;r++)e.push(t[s[r]])}return e}runSync(t){const e=this.params&&Array.isArray(this.params);if(Array.isArray(t)){if(e)return this.func(...t);(0,p.throwError)("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??0;return this._asyncFeatures&&(e|=this._asyncFeatures),$.has(e,t)}isStream(t){let e=this.stream;if(e){const s=this.params;s?.stream&&(e=t?.stream)}return e}}),et={name:{type:"string"},description:{type:"string"},title:{type:"string"},func:{type:"function",assign(t,e,s,i,r){let n=t;const o=typeof t;return r.isExported?n="function"===o?t.toString():t:t&&("string"!==o&&(t=t.toString()),n=(0,d._createFunction)(t,e.scope)),n}},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"},alias:{type:["array","string"]}};tt.defineProperties(tt,et);Symbol("meta");var st=class extends tt{constructor(){super(...arguments),this._emitter=new l.EventEmitter,this.description="Return event bus",this.result="event"}get emitter(){return this._emitter}func(){return this.emitter}},it=new st(k),rt=require("secondary-cache"),nt=require("secondary-cache"),ot=rt.Cache;function ht({key:t,value:e,options:s}={}){return void 0!==t?null===e?this.cache.del(t):void 0!==e?this.cache.set(t,e,s):this.cache.get(t):(s&&this.cache.setDefaultOptions(s),this.cache)}function at(t,e){let s=tt.get(t);return s||(s=new tt(t,{func:ht,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"}),s.cache=new rt.Cache(e)),s}var ct=at("lrucache"),ut=require("lodash-es"),lt="A client transport has not been set. Use ClientTools.setTransport() or transport.mount(ClientTools) first.",ft=class t extends tt{static get apiRoot(){return this._transport||(0,p.throwError)(lt,"ClientTools"),this._transport.apiRoot}static setTransport(t){if(t){this._transport=t;const e=this.constructor;t.Tools!==e&&(t.Tools=e)}}static get transport(){return this._transport}static async loadFrom(t){return t||(this._transport||(0,p.throwError)(lt,"ClientTools"),t=await this._transport.loadApis()),t&&this.loadFromSync(t),t}static loadFromSync(e){for(const s in e){const i=this.get(s),r=e[s];i?i instanceof t?i.assign(r):(0,p.throwError)(`${s} already registered as ${i.constructor.name}`,"ClientTools"):this.register(r)}}static async fetch(t,e,...s){const i=this.get(t);if(i&&i.fetch)return i.fetch(e,...s)}get apiRoot(){return this.constructor.apiRoot}async fetch(t,e,s,i){const r=this.constructor;if(r._transport)return i=(0,ut.defaultsDeep)(i,this.fetchOptions),r._transport.fetch(this.name,t,e,s,i);(0,p.throwError)(lt,"ClientTools")}async func(t){return await this.fetch(t)}},dt={...b};ft.defineProperties(ft,dt);var pt=class extends ft{async fetch(t,e,s,i){return t||(t={}),e?.startsWith("$")&&(t.act=e,e="post"),await super.fetch(t,e,s,i)}async _func(t,e,s){return await this.fetch(e,t,null,s)}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))}}},yt={methods:{type:"array",assign(t,e,s,i,r){r?.isExported||e.assignMethods(t)}}};pt.defineProperties(pt,yt);var bt=class extends pt{async fetch(t,e,...s){if(t||(t={}),e&&"res"===this.action){if("get"===e||"delete"===e){let s=t.id;return s||(0,p.throwError)("id is required"),"string"==typeof s&&(s=encodeURIComponent(s)),delete t.id,super.fetch(t,e,s)}"list"===e?e="get":e.startsWith("$")&&(t.act=e,e="post")}return await super.fetch(t,e,...s)}},vt=require("lodash-es"),mt=class extends bt{constructor(){super(...arguments),this._sseListeners={},this._forwardEvents=new Set,this.description="subscribe server event",this.ebListener=async function(...t){const e=t[0];let s=t[1];const i=this.type;("string"!=typeof e||s&&"object"!=typeof s||t.length>2)&&(s=t,e&&e===this.target.name&&(s=t.slice(1))),this.target.publish&&await this.target.publish({data:s,event:i})}}static setPubSubTransport(t){t?.setApiRoot&&this.apiRoot&&t.setApiRoot(this.apiRoot),this._pubSubTransport=t}static get pubSubTransport(){if(!this._pubSubTransport)throw new Error("EventClient pubSubTransport not set");return this._pubSubTransport}get clientId(){return this._stream?.clientId}async getEvtSource(){let t=this._stream;return t&&2!==t.readyState||(t=await this.initEventStream(this._streamEvents)),t}get active(){return!!this._stream&&2!==this._stream.readyState}async setActive(t){t!==this.active&&(t?await this.initEventStream(this._streamEvents):this._stream&&this.close())}async initEventStream(t){const e="string"==typeof t?[t]:t;if(this._stream&&2!==this._stream.readyState){if(!this._streamEvents||e&&e.every(t=>this._streamEvents.includes(t)))return this._stream;this._stream.close()}const s=e?{event:e}:void 0,i=this._stream=await this.constructor.pubSubTransport.connect(this.name,s);return i.clientId&&(this.fetchOptions=(0,vt.defaultsDeep)({clientId:i.clientId},this.fetchOptions)),Object.entries(this._sseListeners).forEach(([t,e])=>{i.on(t,e)}),this._streamEvents=e,i}esListener(t,e,s){if(!this._forwardEvents.has(t)){const s=this.emitter;s&&t&&(Array.isArray(e)?s.emit(t,...e):s.emit(t,e))}}async subscribe(t){this.active||await this.initEventStream(t);const e=await this.sub({event:t});"string"==typeof t&&(t=[t]);const s=await this.getEvtSource();for(const e of t)if(!this._sseListeners[e]){const t=this._sseListeners[e]=(t,s)=>this.esListener(e,t,s);s.on(e,t)}return e}async unsubscribe(t){"string"==typeof t&&(t=[t]);const e=await this.unsub({event:t}),s=await this.getEvtSource();for(const e of t){const t=this._sseListeners[e];t&&(delete this._sseListeners[e],s.off(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.setActive(!1),await this.initEventStream(t),t)return await this.subscribe(t)}close(){const t=this._stream;if(t)return this._stream=void 0,t.close()}},wt=new mt(q),gt=require("util-ex"),qt=class t extends tt{static get apiRoot(){return this._apiRoot}static setApiRoot(t){this._apiRoot=t}static toJSON(){const e={};for(const s in this.items){let i=this.items[s];(i instanceof t||i.isApi)&&(i.allowExportFunc||(i=i.toJSON(),delete i.func),e[s]=i)}return e}run(t,e){return e&&(t._req=e.req,t._res=e.reply),super.run(t)}func(t){}},kt={...b};qt.defineProperties(qt,kt);var At=class extends qt{constructor(t,e={}){super(t,e),this.params={act:{type:"string"}};const s=this.methods=[];this.initRpcMethods(s)}get SpecialRpcMethodNames(){return this.constructor.SpecialRpcMethodNames}initRpcMethods(t=this.methods){const e=this.SpecialRpcMethodNames;if(Array.isArray(e))for(const s of e)"function"==typeof this[s]&&t.push(s);(0,gt.getAllNames)(Object.getPrototypeOf(this)).filter(t=>t.startsWith("$")&&"function"==typeof this[t]).forEach(e=>{t.push(e);const s=e.slice(1);void 0===this[s]&&(this[s]=this[e])})}cast(t,e){let s=this.params[t];return s&&("string"!=typeof s&&(s=s.type),"number"===s&&(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 p.NotFoundError(e,this.name)}};At.defineProperties(At,{methods:{type:"array"}});var Tt=class extends At{constructor(t,e={}){super(t,e),this.action="res",this.params={id:{type:"string"},val:{type:"any"}}}static{this.SpecialRpcMethodNames=y}getMethodFromParams(t){let e=t?._req?.method?.toLowerCase();return"get"===e&&void 0===t.id?e="list":t.act&&(e=t.act),e}castParams(t){return void 0!==t.id&&(t.id=this.cast("id",t.id)),t}},xt=it.runSync(),jt="client:",St=class t extends Tt{constructor(){super(...arguments),this.description="subscribe server event",this.result="event",this.depends={[k]:it}}static{this.autoInjectToLocalBus=!1}static setPubSubTransport(t){this._pubSubTransport=t}static get pubSubTransport(){return this._pubSubTransport||console.warn("EventServer pubSubTransport not set"),this._pubSubTransport}get pubSubTransport(){return this.constructor.pubSubTransport}static publish(t,e,s){return this.pubSubTransport?.publish(t,e,s)}static ebListener(t,...e){this.pubSubTransport?.publish(t,e)}static alreadyForward(t){const e=xt.listeners(t);for(const t of e)if(t===this._boundEbListener)return!0}publishServerEvent(t,e){return this.constructor.publish(t,e)}forward(e){Array.isArray(e)||(e=[e]);const s=this.constructor;s._boundEbListener||(s._boundEbListener=function(...t){return s.ebListener(this.type,...t)});for(const i of e)t.alreadyForward(i)||xt.on(i,s._boundEbListener)}unforward(t){"string"==typeof t&&(t=[t]);const e=this.constructor;if(e._boundEbListener)for(const s of t)xt.off(s,e._boundEbListener)}list({_req:t,_res:e,event:s}){if(this.pubSubTransport)return this.pubSubTransport.connect({req:t,res:e,events:s});(0,p.throwError)("PubSub transport not available","list",p.ErrorCode.NotImplemented)}$sub({event:t,_req:e}){if(this.pubSubTransport||(0,p.throwError)("PubSub transport not available","sub",p.ErrorCode.NotImplemented),t){this.forward(t);const s=e&&this.pubSubTransport.getSessionFromReq?.(e);return s?(this.pubSubTransport.subscribe(s,Array.isArray(t)?t:[t]),{forward:!0,subscribed:!0,event:t,clientId:s.clientId}):(this.pubSubTransport.getSessionFromReq?console.warn("$sub: No session found for request"):e?console.warn(`$sub: The ${this.pubSubTransport.name} Transport does not support dynamic subscription`):console.warn("$sub: missing _req"),{forward:!0,event:t})}(0,p.throwError)("event is required","sub",p.ErrorCode.InvalidArgument)}$unsub({event:t,_req:e}){if(this.pubSubTransport||(0,p.throwError)("PubSub transport not available","unsub",p.ErrorCode.NotImplemented),t){this.unforward(t);const s=e&&this.pubSubTransport.getSessionFromReq?.(e);return s?(this.pubSubTransport.unsubscribe(s,Array.isArray(t)?t:[t]),{forward:!1,subscribed:!1,event:t,clientId:s.clientId}):(this.pubSubTransport.getSessionFromReq?console.warn("$unsub: No session found for request"):e?console.warn(`$unsub: The ${this.pubSubTransport.name} Transport does not support dynamic subscription`):console.warn("$sub: missing _req"),{forward:!1,event:t})}(0,p.throwError)("event is required","unsub",p.ErrorCode.InvalidArgument)}$publish({event:t,data:e,_req:s}){if(t&&e){const i=s&&this.pubSubTransport?.getSessionFromReq?.(s),r=i?.clientId,n=this.constructor;"string"==typeof t&&(t=[t]);for(const s of t)n.autoInjectToLocalBus&&xt.emit(jt+s,e,{event:s,sender:i}),this.publishServerEvent(s,e);return{event:t,senderId:r}}(0,p.throwError)("event or data is required","pub",p.ErrorCode.InvalidArgument)}isStream(t){return"list"===this.getMethodFromParams(t)}},Et=new St(q);function $t(){it.register(),ct.register()}
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a=(e,a,c,i)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let u of n(a))o.call(e,u)||u===c||t(e,u,{get:()=>a[u],enumerable:!(i=r(a,u))||i.enumerable});return e},c={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(c,{LRUCache:()=>l.LRUCache,SecondaryCache:()=>h,_lrucache:()=>d,createLRUCache:()=>p,lrucache:()=>f,registerCoreTools:()=>v}),module.exports=(e=c,a(t({},"__esModule",{value:!0}),e));var i=require("@isdk/tool-event"),u=require("secondary-cache"),s=require("@isdk/tool-func"),l=require("secondary-cache"),h=u.Cache;function d({key:e,value:t,options:r}={}){return void 0!==e?null===t?this.cache.del(e):void 0!==t?this.cache.set(e,t,r):this.cache.get(e):(r&&this.cache.setDefaultOptions(r),this.cache)}function p(e,t){let r=s.ToolFunc.get(e);return r||(r=new s.ToolFunc(e,{func:d,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"}),r.cache=new u.Cache(t)),r}var f=p("lrucache");function v(){i.event.register(),f.register()}((e,t,r)=>{a(e,t,"default"),r&&a(r,t,"default")})(c,require("@isdk/tool-event"),module.exports);
|
package/dist/funcs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{LRUCache as m,SecondaryCache as o,_lrucache as r,createLRUCache as p,lrucache as t,registerCoreTools as c}from"./chunk-OYMVHUDZ.mjs";export{m as LRUCache,o as SecondaryCache,r as _lrucache,p as createLRUCache,t as lrucache,c as registerCoreTools};
|