@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
|
@@ -6,45 +6,26 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: Semaphore
|
|
8
8
|
|
|
9
|
-
Defined in:
|
|
9
|
+
Defined in: @isdk/util/dist/index.d.ts:903
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
计数信号量(Semaphore)实现。
|
|
12
|
+
扩展自二进制信号量,允许指定最大并发数(`maxConcurrency`)。
|
|
13
|
+
支持可选的就绪检查(`isReadyFn`)。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
示例用法:
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
const semaphore = new Semaphore(5); //
|
|
19
|
-
|
|
20
|
-
const semaphore = new Semaphore(
|
|
21
|
-
4, // Allow 4 concurrent async calls
|
|
22
|
-
{
|
|
23
|
-
capacity: 100, // Prealloc space for 100 tokens
|
|
24
|
-
isReadyFn: async () => {
|
|
25
|
-
// Check if the system is ready to handle more requests
|
|
26
|
-
return true;
|
|
27
|
-
},
|
|
28
|
-
pauseFn: () => {
|
|
29
|
-
console.log('Pausing the stream');
|
|
30
|
-
},
|
|
31
|
-
resumeFn: () => {
|
|
32
|
-
console.log('Resuming the stream');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
);
|
|
18
|
+
const semaphore = new Semaphore(5); // 允许 5 个并发操作
|
|
36
19
|
|
|
37
|
-
async function fetchData(
|
|
38
|
-
await semaphore.acquire()
|
|
20
|
+
async function fetchData(id) {
|
|
21
|
+
const release = await semaphore.acquire();
|
|
39
22
|
try {
|
|
40
|
-
console.log(semaphore.pendingCount
|
|
41
|
-
// ...
|
|
23
|
+
console.log(`正在获取数据 ${id}, 等待中: ${semaphore.pendingCount}`);
|
|
24
|
+
// ... 异步操作
|
|
42
25
|
} finally {
|
|
43
|
-
|
|
26
|
+
release();
|
|
44
27
|
}
|
|
45
28
|
}
|
|
46
|
-
|
|
47
|
-
const data = await Promise.all(array.map(fetchData));
|
|
48
29
|
```
|
|
49
30
|
|
|
50
31
|
## Extends
|
|
@@ -57,15 +38,15 @@ const data = await Promise.all(array.map(fetchData));
|
|
|
57
38
|
|
|
58
39
|
> **new Semaphore**(`maxConcurrency`, `options?`): `Semaphore`
|
|
59
40
|
|
|
60
|
-
Defined in:
|
|
41
|
+
Defined in: @isdk/util/dist/index.d.ts:917
|
|
61
42
|
|
|
62
|
-
|
|
43
|
+
创建一个计数信号量实例。
|
|
63
44
|
|
|
64
45
|
#### Parameters
|
|
65
46
|
|
|
66
47
|
##### maxConcurrency
|
|
67
48
|
|
|
68
|
-
|
|
49
|
+
最大并发数,或者包含并发设置的配置对象。
|
|
69
50
|
|
|
70
51
|
`number` | [`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
|
|
71
52
|
|
|
@@ -73,10 +54,16 @@ The maximum number of callers allowed to acquire the semaphore concurrently.
|
|
|
73
54
|
|
|
74
55
|
[`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
|
|
75
56
|
|
|
57
|
+
配置选项。
|
|
58
|
+
|
|
76
59
|
#### Returns
|
|
77
60
|
|
|
78
61
|
`Semaphore`
|
|
79
62
|
|
|
63
|
+
#### Throws
|
|
64
|
+
|
|
65
|
+
如果未指定有效并发数则抛出错误。
|
|
66
|
+
|
|
80
67
|
#### Overrides
|
|
81
68
|
|
|
82
69
|
[`BinarySemaphore`](BinarySemaphore.md).[`constructor`](BinarySemaphore.md#constructor)
|
|
@@ -87,7 +74,9 @@ The maximum number of callers allowed to acquire the semaphore concurrently.
|
|
|
87
74
|
|
|
88
75
|
> `protected` **\_activeCount**: `number`
|
|
89
76
|
|
|
90
|
-
Defined in:
|
|
77
|
+
Defined in: @isdk/util/dist/index.d.ts:764
|
|
78
|
+
|
|
79
|
+
记录当前活跃的(已获取但未释放)操作总数。
|
|
91
80
|
|
|
92
81
|
#### Inherited from
|
|
93
82
|
|
|
@@ -99,7 +88,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:97](ht
|
|
|
99
88
|
|
|
100
89
|
> `protected` **emitter**: [`EventEmitter`](EventEmitter.md)
|
|
101
90
|
|
|
102
|
-
Defined in:
|
|
91
|
+
Defined in: @isdk/util/dist/index.d.ts:752
|
|
92
|
+
|
|
93
|
+
内部事件触发器,用于协调释放和分发逻辑。
|
|
103
94
|
|
|
104
95
|
#### Inherited from
|
|
105
96
|
|
|
@@ -111,7 +102,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:91](ht
|
|
|
111
102
|
|
|
112
103
|
> `protected` **free**: `Deque`\<`any`\>
|
|
113
104
|
|
|
114
|
-
Defined in:
|
|
105
|
+
Defined in: @isdk/util/dist/index.d.ts:907
|
|
106
|
+
|
|
107
|
+
存储空闲令牌的队列。
|
|
115
108
|
|
|
116
109
|
#### Overrides
|
|
117
110
|
|
|
@@ -123,7 +116,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:374](h
|
|
|
123
116
|
|
|
124
117
|
> `protected` **initTokenFn**: (`token?`) => `void`
|
|
125
118
|
|
|
126
|
-
Defined in:
|
|
119
|
+
Defined in: @isdk/util/dist/index.d.ts:760
|
|
120
|
+
|
|
121
|
+
令牌初始化函数。
|
|
127
122
|
|
|
128
123
|
#### Parameters
|
|
129
124
|
|
|
@@ -145,7 +140,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:95](ht
|
|
|
145
140
|
|
|
146
141
|
> `readonly` **maxConcurrency**: `number`
|
|
147
142
|
|
|
148
|
-
Defined in:
|
|
143
|
+
Defined in: @isdk/util/dist/index.d.ts:905
|
|
144
|
+
|
|
145
|
+
最大并发限制。
|
|
149
146
|
|
|
150
147
|
***
|
|
151
148
|
|
|
@@ -153,7 +150,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:373](h
|
|
|
153
150
|
|
|
154
151
|
> `protected` **paused**: `boolean`
|
|
155
152
|
|
|
156
|
-
Defined in:
|
|
153
|
+
Defined in: @isdk/util/dist/index.d.ts:762
|
|
154
|
+
|
|
155
|
+
记录当前是否处于暂停状态。
|
|
157
156
|
|
|
158
157
|
#### Inherited from
|
|
159
158
|
|
|
@@ -165,7 +164,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:96](ht
|
|
|
165
164
|
|
|
166
165
|
> `protected` `optional` **pauseFn**: () => `void`
|
|
167
166
|
|
|
168
|
-
Defined in:
|
|
167
|
+
Defined in: @isdk/util/dist/index.d.ts:756
|
|
168
|
+
|
|
169
|
+
获取积压时的暂停回调。
|
|
169
170
|
|
|
170
171
|
#### Returns
|
|
171
172
|
|
|
@@ -181,7 +182,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:93](ht
|
|
|
181
182
|
|
|
182
183
|
> `protected` `optional` **resumeFn**: () => `void`
|
|
183
184
|
|
|
184
|
-
Defined in:
|
|
185
|
+
Defined in: @isdk/util/dist/index.d.ts:758
|
|
186
|
+
|
|
187
|
+
恢复处理的回调。
|
|
185
188
|
|
|
186
189
|
#### Returns
|
|
187
190
|
|
|
@@ -197,7 +200,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:94](ht
|
|
|
197
200
|
|
|
198
201
|
> `protected` **useDefaultTokens**: `boolean`
|
|
199
202
|
|
|
200
|
-
Defined in:
|
|
203
|
+
Defined in: @isdk/util/dist/index.d.ts:754
|
|
204
|
+
|
|
205
|
+
标记是否使用默认的令牌初始化函数。
|
|
201
206
|
|
|
202
207
|
#### Inherited from
|
|
203
208
|
|
|
@@ -207,9 +212,11 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:92](ht
|
|
|
207
212
|
|
|
208
213
|
### waiting
|
|
209
214
|
|
|
210
|
-
> `readonly` **waiting**: `Deque
|
|
215
|
+
> `readonly` **waiting**: `Deque`\<[`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md) \| `undefined`\>
|
|
211
216
|
|
|
212
|
-
Defined in:
|
|
217
|
+
Defined in: @isdk/util/dist/index.d.ts:748
|
|
218
|
+
|
|
219
|
+
存储等待获取令牌的任务队列。
|
|
213
220
|
|
|
214
221
|
#### Inherited from
|
|
215
222
|
|
|
@@ -223,19 +230,18 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:89](ht
|
|
|
223
230
|
|
|
224
231
|
> **get** **activeCount**(): `number`
|
|
225
232
|
|
|
226
|
-
Defined in:
|
|
227
|
-
|
|
228
|
-
Get the total count of all active operations.
|
|
233
|
+
Defined in: @isdk/util/dist/index.d.ts:874
|
|
229
234
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
-
|
|
235
|
+
获取所有活跃操作的总数。
|
|
236
|
+
包含:
|
|
237
|
+
- 正在队列中等待获取信号量的操作(`pendingCount`)。
|
|
238
|
+
- 已经成功获取信号量但尚未释放的操作。
|
|
233
239
|
|
|
234
240
|
##### Returns
|
|
235
241
|
|
|
236
242
|
`number`
|
|
237
243
|
|
|
238
|
-
|
|
244
|
+
活跃操作的总数。
|
|
239
245
|
|
|
240
246
|
#### Inherited from
|
|
241
247
|
|
|
@@ -249,15 +255,15 @@ The total count of active operations, including both waiting and ongoing tasks.
|
|
|
249
255
|
|
|
250
256
|
> **get** **pendingCount**(): `number`
|
|
251
257
|
|
|
252
|
-
Defined in:
|
|
258
|
+
Defined in: @isdk/util/dist/index.d.ts:880
|
|
253
259
|
|
|
254
|
-
|
|
260
|
+
获取当前在等待队列中的调用方数量。
|
|
255
261
|
|
|
256
262
|
##### Returns
|
|
257
263
|
|
|
258
264
|
`number`
|
|
259
265
|
|
|
260
|
-
|
|
266
|
+
等待中的 Promise 数量。
|
|
261
267
|
|
|
262
268
|
#### Inherited from
|
|
263
269
|
|
|
@@ -269,7 +275,11 @@ The number of waiters in the waiting list.
|
|
|
269
275
|
|
|
270
276
|
> **\_dispatchTask**(`task`, `options?`): `void`
|
|
271
277
|
|
|
272
|
-
Defined in:
|
|
278
|
+
Defined in: @isdk/util/dist/index.d.ts:805
|
|
279
|
+
|
|
280
|
+
**`Internal`**
|
|
281
|
+
|
|
282
|
+
将令牌分发给等待的任务。
|
|
273
283
|
|
|
274
284
|
#### Parameters
|
|
275
285
|
|
|
@@ -277,10 +287,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
|
|
|
277
287
|
|
|
278
288
|
[`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)
|
|
279
289
|
|
|
290
|
+
等待中的任务项。
|
|
291
|
+
|
|
280
292
|
##### options?
|
|
281
293
|
|
|
282
294
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
283
295
|
|
|
296
|
+
释放时传递的选项。
|
|
297
|
+
|
|
284
298
|
#### Returns
|
|
285
299
|
|
|
286
300
|
`void`
|
|
@@ -293,9 +307,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
|
|
|
293
307
|
|
|
294
308
|
### \_newReleaser()
|
|
295
309
|
|
|
296
|
-
> **\_newReleaser**(`options?`):
|
|
310
|
+
> **\_newReleaser**(`options?`): `BinarySemaphoreReleaserFunc`
|
|
311
|
+
|
|
312
|
+
Defined in: @isdk/util/dist/index.d.ts:797
|
|
297
313
|
|
|
298
|
-
|
|
314
|
+
**`Internal`**
|
|
315
|
+
|
|
316
|
+
创建一个新的释放函数。
|
|
317
|
+
确保释放逻辑只被执行一次,并携带相关的释放选项。
|
|
299
318
|
|
|
300
319
|
#### Parameters
|
|
301
320
|
|
|
@@ -303,9 +322,13 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
|
|
|
303
322
|
|
|
304
323
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
305
324
|
|
|
325
|
+
释放选项。
|
|
326
|
+
|
|
306
327
|
#### Returns
|
|
307
328
|
|
|
308
|
-
|
|
329
|
+
`BinarySemaphoreReleaserFunc`
|
|
330
|
+
|
|
331
|
+
返回一个可调用的释放函数。
|
|
309
332
|
|
|
310
333
|
#### Inherited from
|
|
311
334
|
|
|
@@ -317,7 +340,10 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
|
|
|
317
340
|
|
|
318
341
|
> **abort**(`reason?`): `void`
|
|
319
342
|
|
|
320
|
-
Defined in:
|
|
343
|
+
Defined in: @isdk/util/dist/index.d.ts:865
|
|
344
|
+
|
|
345
|
+
中止所有正在等待的任务。
|
|
346
|
+
所有在等待队列中的 Promise 将被拒绝并抛出 `AbortError`。
|
|
321
347
|
|
|
322
348
|
#### Parameters
|
|
323
349
|
|
|
@@ -325,6 +351,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
|
|
|
325
351
|
|
|
326
352
|
`any`
|
|
327
353
|
|
|
354
|
+
中止的原因。
|
|
355
|
+
|
|
328
356
|
#### Returns
|
|
329
357
|
|
|
330
358
|
`void`
|
|
@@ -337,11 +365,20 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
|
|
|
337
365
|
|
|
338
366
|
### acquire()
|
|
339
367
|
|
|
340
|
-
> **acquire**(`options?`): `Promise
|
|
368
|
+
> **acquire**(`options?`): `Promise`\<`BinarySemaphoreReleaserFunc`\>
|
|
369
|
+
|
|
370
|
+
Defined in: @isdk/util/dist/index.d.ts:842
|
|
341
371
|
|
|
342
|
-
|
|
372
|
+
获取信号量。
|
|
373
|
+
如果信号量当前可用,将立即解析。否则,调用方将被加入等待队列,
|
|
374
|
+
直到有令牌被释放。
|
|
343
375
|
|
|
344
|
-
|
|
376
|
+
逻辑流程:
|
|
377
|
+
1. 增加活跃计数。
|
|
378
|
+
2. 尝试通过 `tryAcquire` 立即获取令牌。
|
|
379
|
+
3. 如果 `tryAcquire` 返回的是异步结果(通过 `isAsync` 判断),则等待其解析。
|
|
380
|
+
4. 如果最终未获得令牌,则将任务推入 `waiting` 队列,并处理可选的 `AbortSignal`。
|
|
381
|
+
5. 如果此时是队列中的第一个任务且定义了 `pauseFn`,则触发暂停回调。
|
|
345
382
|
|
|
346
383
|
#### Parameters
|
|
347
384
|
|
|
@@ -349,11 +386,13 @@ Acquire a token from the semaphore, thus decrement the number of available execu
|
|
|
349
386
|
|
|
350
387
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
351
388
|
|
|
389
|
+
获取选项,可包含 `signal` 用于取消。
|
|
390
|
+
|
|
352
391
|
#### Returns
|
|
353
392
|
|
|
354
|
-
`Promise
|
|
393
|
+
`Promise`\<`BinarySemaphoreReleaserFunc`\>
|
|
355
394
|
|
|
356
|
-
|
|
395
|
+
解析为释放函数(`BinarySemaphoreReleaserFunc`)的 Promise。
|
|
357
396
|
|
|
358
397
|
#### Inherited from
|
|
359
398
|
|
|
@@ -365,14 +404,17 @@ A promise that resolves to a release function when a token is acquired. If the s
|
|
|
365
404
|
|
|
366
405
|
> **drain**(): `Promise`\<`any`[]\>
|
|
367
406
|
|
|
368
|
-
Defined in:
|
|
407
|
+
Defined in: @isdk/util/dist/index.d.ts:948
|
|
369
408
|
|
|
370
|
-
|
|
409
|
+
消耗掉所有并发槽位,确保当前没有其他操作正在运行。
|
|
410
|
+
常用于在关键操作前清空并发环境。
|
|
371
411
|
|
|
372
412
|
#### Returns
|
|
373
413
|
|
|
374
414
|
`Promise`\<`any`[]\>
|
|
375
415
|
|
|
416
|
+
解析为包含所有令牌数组的 Promise。
|
|
417
|
+
|
|
376
418
|
#### Overrides
|
|
377
419
|
|
|
378
420
|
[`BinarySemaphore`](BinarySemaphore.md).[`drain`](BinarySemaphore.md#drain)
|
|
@@ -383,7 +425,9 @@ Drains the semaphore and returns all the initialized tokens in an array. Drainin
|
|
|
383
425
|
|
|
384
426
|
> **init**(`options`): `void`
|
|
385
427
|
|
|
386
|
-
Defined in:
|
|
428
|
+
Defined in: @isdk/util/dist/index.d.ts:788
|
|
429
|
+
|
|
430
|
+
初始化事件监听。在构造函数中被调用。
|
|
387
431
|
|
|
388
432
|
#### Parameters
|
|
389
433
|
|
|
@@ -391,6 +435,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
|
|
|
391
435
|
|
|
392
436
|
[`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
|
|
393
437
|
|
|
438
|
+
配置选项。
|
|
439
|
+
|
|
394
440
|
#### Returns
|
|
395
441
|
|
|
396
442
|
`void`
|
|
@@ -405,7 +451,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
|
|
|
405
451
|
|
|
406
452
|
> **initFree**(`options`): `void`
|
|
407
453
|
|
|
408
|
-
Defined in:
|
|
454
|
+
Defined in: @isdk/util/dist/index.d.ts:922
|
|
455
|
+
|
|
456
|
+
初始化令牌池,填充至最大并发数。
|
|
409
457
|
|
|
410
458
|
#### Parameters
|
|
411
459
|
|
|
@@ -413,6 +461,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:408](h
|
|
|
413
461
|
|
|
414
462
|
[`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
|
|
415
463
|
|
|
464
|
+
配置选项。
|
|
465
|
+
|
|
416
466
|
#### Returns
|
|
417
467
|
|
|
418
468
|
`void`
|
|
@@ -427,7 +477,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:408](h
|
|
|
427
477
|
|
|
428
478
|
> **lock**(`options?`): `any`
|
|
429
479
|
|
|
430
|
-
Defined in:
|
|
480
|
+
Defined in: @isdk/util/dist/index.d.ts:941
|
|
481
|
+
|
|
482
|
+
从空闲令牌池中取出一个令牌。
|
|
431
483
|
|
|
432
484
|
#### Parameters
|
|
433
485
|
|
|
@@ -435,10 +487,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:435](h
|
|
|
435
487
|
|
|
436
488
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
437
489
|
|
|
490
|
+
获取选项。
|
|
491
|
+
|
|
438
492
|
#### Returns
|
|
439
493
|
|
|
440
494
|
`any`
|
|
441
495
|
|
|
496
|
+
如果池中不为空则返回一个令牌,否则返回 undefined。
|
|
497
|
+
|
|
442
498
|
#### Overrides
|
|
443
499
|
|
|
444
500
|
[`BinarySemaphore`](BinarySemaphore.md).[`lock`](BinarySemaphore.md#lock)
|
|
@@ -449,7 +505,10 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:435](h
|
|
|
449
505
|
|
|
450
506
|
> **onReleased**(`options?`): `void`
|
|
451
507
|
|
|
452
|
-
Defined in:
|
|
508
|
+
Defined in: @isdk/util/dist/index.d.ts:783
|
|
509
|
+
|
|
510
|
+
当信号量被释放时执行的内部处理逻辑。
|
|
511
|
+
检查等待队列,如果有任务则分发令牌;否则将令牌归还至空闲池,并视情况调用 `resumeFn`。
|
|
453
512
|
|
|
454
513
|
#### Parameters
|
|
455
514
|
|
|
@@ -457,6 +516,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
|
|
|
457
516
|
|
|
458
517
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
459
518
|
|
|
519
|
+
释放选项,可能包含令牌。
|
|
520
|
+
|
|
460
521
|
#### Returns
|
|
461
522
|
|
|
462
523
|
`void`
|
|
@@ -471,9 +532,11 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
|
|
|
471
532
|
|
|
472
533
|
> **release**(`options?`): `void`
|
|
473
534
|
|
|
474
|
-
Defined in:
|
|
535
|
+
Defined in: @isdk/util/dist/index.d.ts:850
|
|
475
536
|
|
|
476
|
-
|
|
537
|
+
释放信号量,增加可用执行槽位。
|
|
538
|
+
如果等待队列中有任务,将触发下一个任务的执行。
|
|
539
|
+
此方法会减少 `activeCount` 并发出 'release' 事件。
|
|
477
540
|
|
|
478
541
|
#### Parameters
|
|
479
542
|
|
|
@@ -481,6 +544,8 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
|
|
|
481
544
|
|
|
482
545
|
[`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
|
|
483
546
|
|
|
547
|
+
释放选项。
|
|
548
|
+
|
|
484
549
|
#### Returns
|
|
485
550
|
|
|
486
551
|
`void`
|
|
@@ -495,9 +560,10 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
|
|
|
495
560
|
|
|
496
561
|
> **tryAcquire**(`options?`): `any`
|
|
497
562
|
|
|
498
|
-
Defined in:
|
|
563
|
+
Defined in: @isdk/util/dist/index.d.ts:930
|
|
499
564
|
|
|
500
|
-
|
|
565
|
+
尝试获取令牌,包含就绪状态检查。
|
|
566
|
+
如果定义了 `isReadyFn`,将先调用它。
|
|
501
567
|
|
|
502
568
|
#### Parameters
|
|
503
569
|
|
|
@@ -505,11 +571,13 @@ Attempt to acquire a token from the semaphore, if one is available immediately.
|
|
|
505
571
|
|
|
506
572
|
[`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
|
|
507
573
|
|
|
574
|
+
获取选项。
|
|
575
|
+
|
|
508
576
|
#### Returns
|
|
509
577
|
|
|
510
578
|
`any`
|
|
511
579
|
|
|
512
|
-
|
|
580
|
+
可能返回令牌、Promise(当就绪检查为异步时)或 undefined。
|
|
513
581
|
|
|
514
582
|
#### Overrides
|
|
515
583
|
|
|
@@ -521,7 +589,9 @@ Returns a token if the semaphore is not full; otherwise, returns `undefined`.
|
|
|
521
589
|
|
|
522
590
|
> **unlock**(`token?`): `void`
|
|
523
591
|
|
|
524
|
-
Defined in:
|
|
592
|
+
Defined in: @isdk/util/dist/index.d.ts:935
|
|
593
|
+
|
|
594
|
+
将令牌归还至空闲令牌池。
|
|
525
595
|
|
|
526
596
|
#### Parameters
|
|
527
597
|
|
|
@@ -529,6 +599,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:431](h
|
|
|
529
599
|
|
|
530
600
|
`any`
|
|
531
601
|
|
|
602
|
+
要归还的令牌。
|
|
603
|
+
|
|
532
604
|
#### Returns
|
|
533
605
|
|
|
534
606
|
`void`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Abstract Class: ServerToolTransport
|
|
8
8
|
|
|
9
|
-
Defined in:
|
|
9
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:441
|
|
10
10
|
|
|
11
11
|
An abstract base class for server-side transport implementations.
|
|
12
12
|
It provides the generic tool-mounting logic.
|
|
@@ -18,6 +18,7 @@ It provides the generic tool-mounting logic.
|
|
|
18
18
|
## Extended by
|
|
19
19
|
|
|
20
20
|
- [`HttpServerToolTransport`](HttpServerToolTransport.md)
|
|
21
|
+
- [`MailboxServerTransport`](MailboxServerTransport.md)
|
|
21
22
|
|
|
22
23
|
## Implements
|
|
23
24
|
|
|
@@ -43,7 +44,7 @@ It provides the generic tool-mounting logic.
|
|
|
43
44
|
|
|
44
45
|
> **apiRoot**: `string`
|
|
45
46
|
|
|
46
|
-
Defined in:
|
|
47
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:442
|
|
47
48
|
|
|
48
49
|
The root endpoint for the remote service.
|
|
49
50
|
For HTTP, this is a URL. For IPC, it could be a channel name.
|
|
@@ -62,7 +63,7 @@ For HTTP, this is a URL. For IPC, it could be a channel name.
|
|
|
62
63
|
|
|
63
64
|
> `optional` **options**: `any`
|
|
64
65
|
|
|
65
|
-
Defined in:
|
|
66
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:444
|
|
66
67
|
|
|
67
68
|
Additional options for the transport start or fetch, passed by mount.
|
|
68
69
|
|
|
@@ -80,7 +81,7 @@ Additional options for the transport start or fetch, passed by mount.
|
|
|
80
81
|
|
|
81
82
|
> **Tools**: *typeof* [`ServerTools`](ServerTools.md)
|
|
82
83
|
|
|
83
|
-
Defined in:
|
|
84
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:443
|
|
84
85
|
|
|
85
86
|
#### Implementation of
|
|
86
87
|
|
|
@@ -96,7 +97,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/server.ts:49](https:
|
|
|
96
97
|
|
|
97
98
|
> **\_mount**(`Tools`, `apiPrefix`, `options?`): `void`
|
|
98
99
|
|
|
99
|
-
Defined in:
|
|
100
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:445
|
|
100
101
|
|
|
101
102
|
#### Parameters
|
|
102
103
|
|
|
@@ -126,7 +127,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/server.ts:52](https:
|
|
|
126
127
|
|
|
127
128
|
> `abstract` **\_start**(`options?`): `Promise`\<`any`\>
|
|
128
129
|
|
|
129
|
-
Defined in:
|
|
130
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:449
|
|
130
131
|
|
|
131
132
|
#### Parameters
|
|
132
133
|
|
|
@@ -144,7 +145,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/server.ts:65](https:
|
|
|
144
145
|
|
|
145
146
|
> `abstract` **addDiscoveryHandler**(`path`, `handler`): `void`
|
|
146
147
|
|
|
147
|
-
Defined in:
|
|
148
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:447
|
|
148
149
|
|
|
149
150
|
#### Parameters
|
|
150
151
|
|
|
@@ -166,7 +167,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/server.ts:63](https:
|
|
|
166
167
|
|
|
167
168
|
> `abstract` **addRpcHandler**(`serverTools`, `apiPrefix`, `options?`): `void`
|
|
168
169
|
|
|
169
|
-
Defined in:
|
|
170
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:448
|
|
170
171
|
|
|
171
172
|
#### Parameters
|
|
172
173
|
|
|
@@ -192,7 +193,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/server.ts:64](https:
|
|
|
192
193
|
|
|
193
194
|
> `abstract` `optional` **getRaw**(): `any`
|
|
194
195
|
|
|
195
|
-
Defined in:
|
|
196
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:451
|
|
196
197
|
|
|
197
198
|
Gets the underlying raw server instance.
|
|
198
199
|
|
|
@@ -210,7 +211,7 @@ Gets the underlying raw server instance.
|
|
|
210
211
|
|
|
211
212
|
> **mount**(`Tools`, `apiRoot?`, `options?`): `any`
|
|
212
213
|
|
|
213
|
-
Defined in:
|
|
214
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:140
|
|
214
215
|
|
|
215
216
|
Mounts the ServerTools registry, creating the necessary API routes.
|
|
216
217
|
|
|
@@ -257,7 +258,7 @@ A container for transport-specific options. For example,
|
|
|
257
258
|
|
|
258
259
|
> **setApiRoot**(`apiRoot`): `void`
|
|
259
260
|
|
|
260
|
-
Defined in:
|
|
261
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:139
|
|
261
262
|
|
|
262
263
|
#### Parameters
|
|
263
264
|
|
|
@@ -279,7 +280,7 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/transports/base.ts:38](https://
|
|
|
279
280
|
|
|
280
281
|
> **start**(`options?`): `Promise`\<`any`\>
|
|
281
282
|
|
|
282
|
-
Defined in:
|
|
283
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:446
|
|
283
284
|
|
|
284
285
|
Starts the transport layer, making it listen for incoming connections.
|
|
285
286
|
|
|
@@ -305,7 +306,7 @@ Protocol-specific options (e.g., { port, host }).
|
|
|
305
306
|
|
|
306
307
|
> `abstract` **stop**(`force?`): `Promise`\<`void`\>
|
|
307
308
|
|
|
308
|
-
Defined in:
|
|
309
|
+
Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:450
|
|
309
310
|
|
|
310
311
|
Stops the server instance gracefully.
|
|
311
312
|
|