@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
package/dist/test/util.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,r=Object.
|
|
1
|
+
"use strict";var e,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o={};function c(e,r){expect(e.length).toBeGreaterThanOrEqual(r.length);for(let t=0;t<r.length;t++)if(e[t]!==r[t])return!1;return!0}((e,t)=>{for(var u in t)r(e,u,{get:t[u],enumerable:!0})})(o,{compareStr:()=>c,findPort:()=>f.findPort,rmFile:()=>l}),module.exports=(e=o,((e,o,c,f)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let n of u(o))i.call(e,n)||n===c||r(e,n,{get:()=>o[n],enumerable:!(f=t(o,n))||f.enumerable});return e})(r({},"__esModule",{value:!0}),e));var f=require("@isdk/util"),n=require("fs");function l(e){(0,n.existsSync)(e)&&(0,n.rmSync)(e,{recursive:!0}),(0,n.existsSync)(e+".temp")&&(0,n.rmSync)(e+".temp",{recursive:!0})}
|
package/dist/test/util.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findPort as r}from"../chunk-
|
|
1
|
+
import{findPort as r}from"../chunk-BIJ2JH4U.mjs";function e(r,e){expect(r.length).toBeGreaterThanOrEqual(e.length);for(let t=0;t<e.length;t++)if(r[t]!==e[t])return!1;return!0}import{existsSync as t,rmSync as o}from"fs";function f(r){t(r)&&o(r,{recursive:!0}),t(r+".temp")&&o(r+".temp",{recursive:!0})}export{e as compareStr,r as findPort,f as rmFile};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@isdk/ai-tool**](../../../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/ai-tool](../../../../globals.md) / [ClientTools](../README.md) / get
|
|
6
|
+
|
|
7
|
+
# Function: get()
|
|
8
|
+
|
|
9
|
+
> **get**(`name`): [`ClientTools`](../../../../classes/ClientTools.md)
|
|
10
|
+
|
|
11
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:202
|
|
12
|
+
|
|
13
|
+
Gets a registered `ClientTools` instance by name.
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### name
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
The name of the tool function.
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
[`ClientTools`](../../../../classes/ClientTools.md)
|
|
26
|
+
|
|
27
|
+
The `ClientTools` instance.
|
|
@@ -6,35 +6,26 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: BinarySemaphore
|
|
8
8
|
|
|
9
|
-
Defined in:
|
|
9
|
+
Defined in: @isdk/util/dist/index.d.ts:746
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
二进制信号量(Binary Semaphore)实现。
|
|
12
|
+
二进制信号量在任何时刻只允许一个调用方获取成功(类似于互斥锁)。
|
|
13
|
+
它提供了获取(acquire)、释放(release)以及管理等待队列的机制,并支持背压控制(通过 pauseFn/resumeFn)。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
示例用法:
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
const semaphore = new
|
|
18
|
+
const semaphore = new BinarySemaphore();
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
capacity: 100 // Prealloc space for 100 tokens
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
async function fetchData(x) {
|
|
28
|
-
await semaphore.acquire()
|
|
20
|
+
async function performTask(data) {
|
|
21
|
+
const release = await semaphore.acquire();
|
|
29
22
|
try {
|
|
30
|
-
console.log(
|
|
31
|
-
//
|
|
23
|
+
console.log('正在处理:', data);
|
|
24
|
+
// 执行异步操作...
|
|
32
25
|
} finally {
|
|
33
|
-
semaphore.release();
|
|
26
|
+
release(); // 或者使用 semaphore.release();
|
|
34
27
|
}
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
const data = await Promise.all(array.map(fetchData));
|
|
38
29
|
```
|
|
39
30
|
|
|
40
31
|
## Extended by
|
|
@@ -45,29 +36,37 @@ const data = await Promise.all(array.map(fetchData));
|
|
|
45
36
|
|
|
46
37
|
### Constructor
|
|
47
38
|
|
|
48
|
-
> **new BinarySemaphore**(`options
|
|
39
|
+
> **new BinarySemaphore**(`options?`): `BinarySemaphore`
|
|
49
40
|
|
|
50
|
-
Defined in:
|
|
41
|
+
Defined in: @isdk/util/dist/index.d.ts:771
|
|
51
42
|
|
|
52
|
-
|
|
43
|
+
创建一个二进制信号量实例。
|
|
53
44
|
|
|
54
45
|
#### Parameters
|
|
55
46
|
|
|
56
|
-
##### options
|
|
47
|
+
##### options?
|
|
48
|
+
|
|
49
|
+
[`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
配置选项。
|
|
59
52
|
|
|
60
53
|
#### Returns
|
|
61
54
|
|
|
62
55
|
`BinarySemaphore`
|
|
63
56
|
|
|
57
|
+
#### Throws
|
|
58
|
+
|
|
59
|
+
如果只提供了 pauseFn 而未提供 resumeFn,或者反之,则抛出错误。
|
|
60
|
+
|
|
64
61
|
## Properties
|
|
65
62
|
|
|
66
63
|
### \_activeCount
|
|
67
64
|
|
|
68
65
|
> `protected` **\_activeCount**: `number`
|
|
69
66
|
|
|
70
|
-
Defined in:
|
|
67
|
+
Defined in: @isdk/util/dist/index.d.ts:764
|
|
68
|
+
|
|
69
|
+
记录当前活跃的(已获取但未释放)操作总数。
|
|
71
70
|
|
|
72
71
|
***
|
|
73
72
|
|
|
@@ -75,7 +74,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:97](ht
|
|
|
75
74
|
|
|
76
75
|
> `protected` **emitter**: [`EventEmitter`](EventEmitter.md)
|
|
77
76
|
|
|
78
|
-
Defined in:
|
|
77
|
+
Defined in: @isdk/util/dist/index.d.ts:752
|
|
78
|
+
|
|
79
|
+
内部事件触发器,用于协调释放和分发逻辑。
|
|
79
80
|
|
|
80
81
|
***
|
|
81
82
|
|
|
@@ -83,7 +84,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:91](ht
|
|
|
83
84
|
|
|
84
85
|
> `protected` **free**: `any`
|
|
85
86
|
|
|
86
|
-
Defined in:
|
|
87
|
+
Defined in: @isdk/util/dist/index.d.ts:750
|
|
88
|
+
|
|
89
|
+
当前空闲的令牌。对于二进制信号量,只能持有一个令牌。
|
|
87
90
|
|
|
88
91
|
***
|
|
89
92
|
|
|
@@ -91,7 +94,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:90](ht
|
|
|
91
94
|
|
|
92
95
|
> `protected` **initTokenFn**: (`token?`) => `void`
|
|
93
96
|
|
|
94
|
-
Defined in:
|
|
97
|
+
Defined in: @isdk/util/dist/index.d.ts:760
|
|
98
|
+
|
|
99
|
+
令牌初始化函数。
|
|
95
100
|
|
|
96
101
|
#### Parameters
|
|
97
102
|
|
|
@@ -109,7 +114,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:95](ht
|
|
|
109
114
|
|
|
110
115
|
> `protected` **paused**: `boolean`
|
|
111
116
|
|
|
112
|
-
Defined in:
|
|
117
|
+
Defined in: @isdk/util/dist/index.d.ts:762
|
|
118
|
+
|
|
119
|
+
记录当前是否处于暂停状态。
|
|
113
120
|
|
|
114
121
|
***
|
|
115
122
|
|
|
@@ -117,7 +124,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:96](ht
|
|
|
117
124
|
|
|
118
125
|
> `protected` `optional` **pauseFn**: () => `void`
|
|
119
126
|
|
|
120
|
-
Defined in:
|
|
127
|
+
Defined in: @isdk/util/dist/index.d.ts:756
|
|
128
|
+
|
|
129
|
+
获取积压时的暂停回调。
|
|
121
130
|
|
|
122
131
|
#### Returns
|
|
123
132
|
|
|
@@ -129,7 +138,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:93](ht
|
|
|
129
138
|
|
|
130
139
|
> `protected` `optional` **resumeFn**: () => `void`
|
|
131
140
|
|
|
132
|
-
Defined in:
|
|
141
|
+
Defined in: @isdk/util/dist/index.d.ts:758
|
|
142
|
+
|
|
143
|
+
恢复处理的回调。
|
|
133
144
|
|
|
134
145
|
#### Returns
|
|
135
146
|
|
|
@@ -141,15 +152,19 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:94](ht
|
|
|
141
152
|
|
|
142
153
|
> `protected` **useDefaultTokens**: `boolean`
|
|
143
154
|
|
|
144
|
-
Defined in:
|
|
155
|
+
Defined in: @isdk/util/dist/index.d.ts:754
|
|
156
|
+
|
|
157
|
+
标记是否使用默认的令牌初始化函数。
|
|
145
158
|
|
|
146
159
|
***
|
|
147
160
|
|
|
148
161
|
### waiting
|
|
149
162
|
|
|
150
|
-
> `readonly` **waiting**: `Deque
|
|
163
|
+
> `readonly` **waiting**: `Deque`\<[`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md) \| `undefined`\>
|
|
164
|
+
|
|
165
|
+
Defined in: @isdk/util/dist/index.d.ts:748
|
|
151
166
|
|
|
152
|
-
|
|
167
|
+
存储等待获取令牌的任务队列。
|
|
153
168
|
|
|
154
169
|
## Accessors
|
|
155
170
|
|
|
@@ -159,19 +174,18 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:89](ht
|
|
|
159
174
|
|
|
160
175
|
> **get** **activeCount**(): `number`
|
|
161
176
|
|
|
162
|
-
Defined in:
|
|
177
|
+
Defined in: @isdk/util/dist/index.d.ts:874
|
|
163
178
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
- Already acquired the semaphore but have not yet released it.
|
|
179
|
+
获取所有活跃操作的总数。
|
|
180
|
+
包含:
|
|
181
|
+
- 正在队列中等待获取信号量的操作(`pendingCount`)。
|
|
182
|
+
- 已经成功获取信号量但尚未释放的操作。
|
|
169
183
|
|
|
170
184
|
##### Returns
|
|
171
185
|
|
|
172
186
|
`number`
|
|
173
187
|
|
|
174
|
-
|
|
188
|
+
活跃操作的总数。
|
|
175
189
|
|
|
176
190
|
***
|
|
177
191
|
|
|
@@ -181,15 +195,15 @@ The total count of active operations, including both waiting and ongoing tasks.
|
|
|
181
195
|
|
|
182
196
|
> **get** **pendingCount**(): `number`
|
|
183
197
|
|
|
184
|
-
Defined in:
|
|
198
|
+
Defined in: @isdk/util/dist/index.d.ts:880
|
|
185
199
|
|
|
186
|
-
|
|
200
|
+
获取当前在等待队列中的调用方数量。
|
|
187
201
|
|
|
188
202
|
##### Returns
|
|
189
203
|
|
|
190
204
|
`number`
|
|
191
205
|
|
|
192
|
-
|
|
206
|
+
等待中的 Promise 数量。
|
|
193
207
|
|
|
194
208
|
## Methods
|
|
195
209
|
|
|
@@ -197,7 +211,11 @@ The number of waiters in the waiting list.
|
|
|
197
211
|
|
|
198
212
|
> **\_dispatchTask**(`task`, `options?`): `void`
|
|
199
213
|
|
|
200
|
-
Defined in:
|
|
214
|
+
Defined in: @isdk/util/dist/index.d.ts:805
|
|
215
|
+
|
|
216
|
+
**`Internal`**
|
|
217
|
+
|
|
218
|
+
将令牌分发给等待的任务。
|
|
201
219
|
|
|
202
220
|
#### Parameters
|
|
203
221
|
|
|
@@ -205,10 +223,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
|
|
|
205
223
|
|
|
206
224
|
[`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)
|
|
207
225
|
|
|
226
|
+
等待中的任务项。
|
|
227
|
+
|
|
208
228
|
##### options?
|
|
209
229
|
|
|
210
230
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
211
231
|
|
|
232
|
+
释放时传递的选项。
|
|
233
|
+
|
|
212
234
|
#### Returns
|
|
213
235
|
|
|
214
236
|
`void`
|
|
@@ -217,9 +239,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
|
|
|
217
239
|
|
|
218
240
|
### \_newReleaser()
|
|
219
241
|
|
|
220
|
-
> **\_newReleaser**(`options?`):
|
|
242
|
+
> **\_newReleaser**(`options?`): `BinarySemaphoreReleaserFunc`
|
|
221
243
|
|
|
222
|
-
Defined in:
|
|
244
|
+
Defined in: @isdk/util/dist/index.d.ts:797
|
|
245
|
+
|
|
246
|
+
**`Internal`**
|
|
247
|
+
|
|
248
|
+
创建一个新的释放函数。
|
|
249
|
+
确保释放逻辑只被执行一次,并携带相关的释放选项。
|
|
223
250
|
|
|
224
251
|
#### Parameters
|
|
225
252
|
|
|
@@ -227,9 +254,13 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
|
|
|
227
254
|
|
|
228
255
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
229
256
|
|
|
257
|
+
释放选项。
|
|
258
|
+
|
|
230
259
|
#### Returns
|
|
231
260
|
|
|
232
|
-
|
|
261
|
+
`BinarySemaphoreReleaserFunc`
|
|
262
|
+
|
|
263
|
+
返回一个可调用的释放函数。
|
|
233
264
|
|
|
234
265
|
***
|
|
235
266
|
|
|
@@ -237,7 +268,10 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
|
|
|
237
268
|
|
|
238
269
|
> **abort**(`reason?`): `void`
|
|
239
270
|
|
|
240
|
-
Defined in:
|
|
271
|
+
Defined in: @isdk/util/dist/index.d.ts:865
|
|
272
|
+
|
|
273
|
+
中止所有正在等待的任务。
|
|
274
|
+
所有在等待队列中的 Promise 将被拒绝并抛出 `AbortError`。
|
|
241
275
|
|
|
242
276
|
#### Parameters
|
|
243
277
|
|
|
@@ -245,6 +279,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
|
|
|
245
279
|
|
|
246
280
|
`any`
|
|
247
281
|
|
|
282
|
+
中止的原因。
|
|
283
|
+
|
|
248
284
|
#### Returns
|
|
249
285
|
|
|
250
286
|
`void`
|
|
@@ -253,11 +289,20 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
|
|
|
253
289
|
|
|
254
290
|
### acquire()
|
|
255
291
|
|
|
256
|
-
> **acquire**(`options?`): `Promise
|
|
292
|
+
> **acquire**(`options?`): `Promise`\<`BinarySemaphoreReleaserFunc`\>
|
|
257
293
|
|
|
258
|
-
Defined in:
|
|
294
|
+
Defined in: @isdk/util/dist/index.d.ts:842
|
|
259
295
|
|
|
260
|
-
|
|
296
|
+
获取信号量。
|
|
297
|
+
如果信号量当前可用,将立即解析。否则,调用方将被加入等待队列,
|
|
298
|
+
直到有令牌被释放。
|
|
299
|
+
|
|
300
|
+
逻辑流程:
|
|
301
|
+
1. 增加活跃计数。
|
|
302
|
+
2. 尝试通过 `tryAcquire` 立即获取令牌。
|
|
303
|
+
3. 如果 `tryAcquire` 返回的是异步结果(通过 `isAsync` 判断),则等待其解析。
|
|
304
|
+
4. 如果最终未获得令牌,则将任务推入 `waiting` 队列,并处理可选的 `AbortSignal`。
|
|
305
|
+
5. 如果此时是队列中的第一个任务且定义了 `pauseFn`,则触发暂停回调。
|
|
261
306
|
|
|
262
307
|
#### Parameters
|
|
263
308
|
|
|
@@ -265,11 +310,13 @@ Acquire a token from the semaphore, thus decrement the number of available execu
|
|
|
265
310
|
|
|
266
311
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
267
312
|
|
|
313
|
+
获取选项,可包含 `signal` 用于取消。
|
|
314
|
+
|
|
268
315
|
#### Returns
|
|
269
316
|
|
|
270
|
-
`Promise
|
|
317
|
+
`Promise`\<`BinarySemaphoreReleaserFunc`\>
|
|
271
318
|
|
|
272
|
-
|
|
319
|
+
解析为释放函数(`BinarySemaphoreReleaserFunc`)的 Promise。
|
|
273
320
|
|
|
274
321
|
***
|
|
275
322
|
|
|
@@ -277,21 +324,27 @@ A promise that resolves to a release function when a token is acquired. If the s
|
|
|
277
324
|
|
|
278
325
|
> **drain**(): `Promise`\<`any`[]\>
|
|
279
326
|
|
|
280
|
-
Defined in:
|
|
327
|
+
Defined in: @isdk/util/dist/index.d.ts:858
|
|
281
328
|
|
|
282
|
-
|
|
329
|
+
等待所有当前活跃的操作完成。
|
|
330
|
+
它通过尝试获取一次信号量来确保之前的操作已经释放。
|
|
331
|
+
在进程终止前使用此方法以确保没有挂起的异步任务。
|
|
283
332
|
|
|
284
333
|
#### Returns
|
|
285
334
|
|
|
286
335
|
`Promise`\<`any`[]\>
|
|
287
336
|
|
|
337
|
+
解析为包含已获取令牌的数组的 Promise。
|
|
338
|
+
|
|
288
339
|
***
|
|
289
340
|
|
|
290
341
|
### init()
|
|
291
342
|
|
|
292
343
|
> **init**(`options`): `void`
|
|
293
344
|
|
|
294
|
-
Defined in:
|
|
345
|
+
Defined in: @isdk/util/dist/index.d.ts:788
|
|
346
|
+
|
|
347
|
+
初始化事件监听。在构造函数中被调用。
|
|
295
348
|
|
|
296
349
|
#### Parameters
|
|
297
350
|
|
|
@@ -299,6 +352,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
|
|
|
299
352
|
|
|
300
353
|
[`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
|
|
301
354
|
|
|
355
|
+
配置选项。
|
|
356
|
+
|
|
302
357
|
#### Returns
|
|
303
358
|
|
|
304
359
|
`void`
|
|
@@ -309,7 +364,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
|
|
|
309
364
|
|
|
310
365
|
> **initFree**(`options?`): `void`
|
|
311
366
|
|
|
312
|
-
Defined in:
|
|
367
|
+
Defined in: @isdk/util/dist/index.d.ts:776
|
|
368
|
+
|
|
369
|
+
初始化空闲令牌。在构造函数中被调用。
|
|
313
370
|
|
|
314
371
|
#### Parameters
|
|
315
372
|
|
|
@@ -317,6 +374,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:173](h
|
|
|
317
374
|
|
|
318
375
|
[`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
|
|
319
376
|
|
|
377
|
+
配置选项。
|
|
378
|
+
|
|
320
379
|
#### Returns
|
|
321
380
|
|
|
322
381
|
`void`
|
|
@@ -327,7 +386,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:173](h
|
|
|
327
386
|
|
|
328
387
|
> **lock**(`options?`): `any`
|
|
329
388
|
|
|
330
|
-
Defined in:
|
|
389
|
+
Defined in: @isdk/util/dist/index.d.ts:812
|
|
390
|
+
|
|
391
|
+
锁定信号量。尝试从空闲池中提取令牌。
|
|
331
392
|
|
|
332
393
|
#### Parameters
|
|
333
394
|
|
|
@@ -335,17 +396,24 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:217](h
|
|
|
335
396
|
|
|
336
397
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
337
398
|
|
|
399
|
+
获取选项。
|
|
400
|
+
|
|
338
401
|
#### Returns
|
|
339
402
|
|
|
340
403
|
`any`
|
|
341
404
|
|
|
405
|
+
如果有可用令牌则返回该令牌,否则返回 undefined。
|
|
406
|
+
|
|
342
407
|
***
|
|
343
408
|
|
|
344
409
|
### onReleased()
|
|
345
410
|
|
|
346
411
|
> **onReleased**(`options?`): `void`
|
|
347
412
|
|
|
348
|
-
Defined in:
|
|
413
|
+
Defined in: @isdk/util/dist/index.d.ts:783
|
|
414
|
+
|
|
415
|
+
当信号量被释放时执行的内部处理逻辑。
|
|
416
|
+
检查等待队列,如果有任务则分发令牌;否则将令牌归还至空闲池,并视情况调用 `resumeFn`。
|
|
349
417
|
|
|
350
418
|
#### Parameters
|
|
351
419
|
|
|
@@ -353,6 +421,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
|
|
|
353
421
|
|
|
354
422
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
355
423
|
|
|
424
|
+
释放选项,可能包含令牌。
|
|
425
|
+
|
|
356
426
|
#### Returns
|
|
357
427
|
|
|
358
428
|
`void`
|
|
@@ -363,9 +433,11 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
|
|
|
363
433
|
|
|
364
434
|
> **release**(`options?`): `void`
|
|
365
435
|
|
|
366
|
-
Defined in:
|
|
436
|
+
Defined in: @isdk/util/dist/index.d.ts:850
|
|
367
437
|
|
|
368
|
-
|
|
438
|
+
释放信号量,增加可用执行槽位。
|
|
439
|
+
如果等待队列中有任务,将触发下一个任务的执行。
|
|
440
|
+
此方法会减少 `activeCount` 并发出 'release' 事件。
|
|
369
441
|
|
|
370
442
|
#### Parameters
|
|
371
443
|
|
|
@@ -373,6 +445,8 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
|
|
|
373
445
|
|
|
374
446
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
375
447
|
|
|
448
|
+
释放选项。
|
|
449
|
+
|
|
376
450
|
#### Returns
|
|
377
451
|
|
|
378
452
|
`void`
|
|
@@ -383,9 +457,10 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
|
|
|
383
457
|
|
|
384
458
|
> **tryAcquire**(`options?`): `any`
|
|
385
459
|
|
|
386
|
-
Defined in:
|
|
460
|
+
Defined in: @isdk/util/dist/index.d.ts:826
|
|
387
461
|
|
|
388
|
-
|
|
462
|
+
尝试立即获取令牌。
|
|
463
|
+
如果信号量当前不可用,则立即返回 `undefined` 而不进入等待队列。
|
|
389
464
|
|
|
390
465
|
#### Parameters
|
|
391
466
|
|
|
@@ -393,11 +468,13 @@ Attempt to acquire a token from the semaphore, if one is available immediately.
|
|
|
393
468
|
|
|
394
469
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
395
470
|
|
|
471
|
+
获取选项。
|
|
472
|
+
|
|
396
473
|
#### Returns
|
|
397
474
|
|
|
398
475
|
`any`
|
|
399
476
|
|
|
400
|
-
|
|
477
|
+
如果获取成功则返回令牌,否则返回 `undefined`。
|
|
401
478
|
|
|
402
479
|
***
|
|
403
480
|
|
|
@@ -405,7 +482,9 @@ Returns a token if the semaphore is not full; otherwise, returns `undefined`.
|
|
|
405
482
|
|
|
406
483
|
> **unlock**(`token?`): `void`
|
|
407
484
|
|
|
408
|
-
Defined in:
|
|
485
|
+
Defined in: @isdk/util/dist/index.d.ts:818
|
|
486
|
+
|
|
487
|
+
解锁信号量。将令牌归还至空闲池。
|
|
409
488
|
|
|
410
489
|
#### Parameters
|
|
411
490
|
|
|
@@ -413,6 +492,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:225](h
|
|
|
413
492
|
|
|
414
493
|
`any`
|
|
415
494
|
|
|
495
|
+
要归还的令牌。如果未提供,则使用初始化函数生成。
|
|
496
|
+
|
|
416
497
|
#### Returns
|
|
417
498
|
|
|
418
499
|
`void`
|