@isdk/ai-tool 0.7.1 → 0.8.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-4FKBOPZI.mjs +1 -0
- package/dist/{chunk-VIG2GB47.mjs → chunk-TGTHY57V.mjs} +1 -1
- package/dist/funcs.d.mts +1 -2
- package/dist/funcs.d.ts +1 -2
- package/dist/funcs.js +1 -1
- package/dist/funcs.mjs +1 -1
- package/dist/{index-DEUnmyUq.d.mts → index-BLW3R7VS.d.mts} +103 -69
- package/dist/{index-DEUnmyUq.d.ts → index-BLW3R7VS.d.ts} +103 -69
- package/dist/index.d.mts +100 -37
- package/dist/index.d.ts +100 -37
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/test/util.js +1 -1
- package/dist/test/util.mjs +1 -1
- package/docs/api/{namespaces → @isdk/namespaces}/EventStates/README.md +2 -2
- package/docs/api/{namespaces → @isdk/namespaces}/EventStates/variables/ABORT.md +2 -2
- package/docs/api/{namespaces → @isdk/namespaces}/EventStates/variables/CONTINUE.md +2 -2
- package/docs/api/{namespaces → @isdk/namespaces}/EventStates/variables/DONE.md +2 -2
- package/docs/api/{namespaces → @isdk/namespaces}/EventStates/variables/STOPPED.md +2 -2
- package/docs/api/@isdk/namespaces/uuidv5/README.md +12 -0
- package/docs/api/{namespaces → @isdk/namespaces}/uuidv5/variables/DNS.md +2 -2
- package/docs/api/{namespaces → @isdk/namespaces}/uuidv5/variables/URL.md +2 -2
- package/docs/api/_media/pubsub.md +427 -105
- package/docs/api/_media/server_client_tools.md +5 -3
- package/docs/api/_media/toolFunc.md +3 -1
- package/docs/api/classes/AbortError.md +8 -8
- package/docs/api/classes/AlreadyExistsError.md +8 -8
- package/docs/api/classes/BaseError.md +14 -14
- package/docs/api/classes/BinarySemaphore.md +39 -39
- package/docs/api/classes/CancelableAbility.md +43 -39
- package/docs/api/classes/ClientToolTransport.md +22 -22
- package/docs/api/classes/ClientTools.md +178 -154
- package/docs/api/classes/CommonError.md +12 -12
- package/docs/api/classes/ConfigFile.md +6 -6
- package/docs/api/classes/EnvPromptTemplate.md +14 -14
- package/docs/api/classes/EventClient.md +240 -198
- package/docs/api/classes/EventEmitter.md +14 -14
- package/docs/api/classes/EventServer.md +208 -233
- package/docs/api/classes/EventToolFunc.md +144 -116
- package/docs/api/classes/FStringPromptTemplate.md +14 -14
- package/docs/api/classes/FewShotPromptTemplate.md +30 -26
- package/docs/api/classes/GolangPromptTemplate.md +13 -13
- package/docs/api/classes/HttpClientToolTransport.md +23 -23
- package/docs/api/classes/HttpServerToolTransport.md +32 -27
- package/docs/api/classes/IntSet.md +21 -21
- package/docs/api/classes/LRUCache.md +18 -18
- package/docs/api/classes/NotFoundError.md +8 -8
- package/docs/api/classes/NotImplementationError.md +8 -8
- package/docs/api/classes/PromptExampleSelector.md +17 -15
- package/docs/api/classes/PromptTemplate.md +15 -15
- package/docs/api/classes/ReadableStreamError.md +12 -12
- package/docs/api/classes/ResClientTools.md +180 -152
- package/docs/api/classes/ResServerTools.md +163 -139
- package/docs/api/classes/RpcMethodsClientTool.md +174 -146
- package/docs/api/classes/RpcMethodsServerTool.md +157 -133
- package/docs/api/classes/SSEChannel.md +142 -52
- package/docs/api/classes/Semaphore.md +40 -40
- package/docs/api/classes/ServerToolTransport.md +32 -27
- package/docs/api/classes/ServerTools.md +163 -139
- package/docs/api/classes/SignalGate.md +19 -17
- package/docs/api/classes/SseClientPubSubTransport.md +38 -10
- package/docs/api/classes/SseServerPubSubTransport.md +115 -42
- package/docs/api/classes/TaskAbortController.md +13 -13
- package/docs/api/classes/ToolFunc.md +157 -129
- package/docs/api/classes/ToolTransport.md +13 -13
- package/docs/api/classes/YamlTypeBaseObject.md +5 -5
- package/docs/api/enumerations/AsyncFeatureBits.md +4 -4
- package/docs/api/enumerations/AsyncFeatures.md +4 -4
- package/docs/api/enumerations/HashAlgorithm.md +12 -12
- package/docs/api/functions/AIArgProcessor.md +2 -2
- package/docs/api/functions/AIStream.md +8 -4
- package/docs/api/functions/ChoiceArgProcessor.md +2 -2
- package/docs/api/functions/DefaultDateFormat.md +2 -2
- package/docs/api/functions/ObjectArgsToArgsInfo.md +1 -1
- package/docs/api/functions/RateLimit.md +2 -2
- package/docs/api/functions/TemplateArgProcessor.md +2 -2
- package/docs/api/functions/addDate.md +7 -3
- package/docs/api/functions/assignDirs.md +1 -1
- package/docs/api/functions/beforeShutdown.md +1 -1
- package/docs/api/functions/calcPerplexity.md +2 -2
- package/docs/api/functions/calcPerplexitySimple.md +1 -1
- package/docs/api/functions/canonicalize.md +1 -1
- 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/createAbilityInjector.md +16 -8
- package/docs/api/functions/createCallbacksTransformer.md +7 -3
- package/docs/api/functions/createEmptyReadableStream.md +1 -1
- package/docs/api/functions/createEndWithRepetitionDetector.md +2 -2
- package/docs/api/functions/createError.md +1 -1
- package/docs/api/functions/createEventStreamTransformer.md +8 -4
- package/docs/api/functions/createHfValueFunc.md +1 -1
- package/docs/api/functions/createLRUCache.md +2 -2
- package/docs/api/functions/createYamlObjectTag.md +1 -1
- package/docs/api/functions/dateToText.md +1 -1
- package/docs/api/functions/decodeCharset.md +2 -2
- package/docs/api/functions/defaultsWithConcat.md +1 -1
- package/docs/api/functions/detectCharset.md +2 -2
- package/docs/api/functions/encodeLLMTokens.md +1 -1
- package/docs/api/functions/ensureQuoted.md +1 -1
- package/docs/api/functions/eventable.md +6 -8
- package/docs/api/functions/expandConfig.md +2 -2
- package/docs/api/functions/expandObjEnv.md +1 -1
- package/docs/api/functions/expandPath.md +2 -2
- package/docs/api/functions/expandPathInObject.md +2 -2
- package/docs/api/functions/expandPaths.md +2 -2
- package/docs/api/functions/fileIsExists.md +1 -1
- package/docs/api/functions/filterValidFnScope.md +2 -2
- package/docs/api/functions/findIndexNonEmptyFrom.md +1 -1
- package/docs/api/functions/findPort.md +1 -1
- package/docs/api/functions/formatISO.md +1 -1
- package/docs/api/functions/formatTextWithSpace.md +2 -2
- package/docs/api/functions/funcGetMeta.md +1 -1
- package/docs/api/functions/funcWithMeta.md +2 -2
- package/docs/api/functions/genUrlParamsStr.md +8 -2
- package/docs/api/functions/getAllEnumKeys.md +4 -2
- package/docs/api/functions/getConfigFileNames.md +2 -2
- package/docs/api/functions/getConfigs.md +2 -2
- package/docs/api/functions/getFileMetaInfo.md +1 -1
- package/docs/api/functions/getHashAlgoBySize.md +1 -1
- package/docs/api/functions/getKeysPath.md +4 -2
- 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 +2 -2
- package/docs/api/functions/hash.md +1 -1
- package/docs/api/functions/hashFile.md +2 -2
- package/docs/api/functions/hashObject.md +2 -2
- package/docs/api/functions/hashStream.md +1 -1
- package/docs/api/functions/initShutdown.md +1 -1
- package/docs/api/functions/isLangUsingSpaces.md +1 -1
- package/docs/api/functions/isListItemString.md +1 -1
- package/docs/api/functions/isModelNameMatched.md +2 -2
- package/docs/api/functions/isPunctuationChar.md +1 -1
- package/docs/api/functions/isQuoted.md +1 -1
- package/docs/api/functions/isRegExp.md +1 -1
- package/docs/api/functions/isSameString.md +1 -1
- package/docs/api/functions/isSectionString.md +2 -2
- package/docs/api/functions/isSentenceEnding.md +1 -1
- package/docs/api/functions/isSepLineString.md +1 -1
- package/docs/api/functions/isStrWrapped.md +1 -1
- package/docs/api/functions/isSubdirectory.md +1 -1
- package/docs/api/functions/isTitleString.md +2 -2
- package/docs/api/functions/isWebStream.md +1 -1
- package/docs/api/functions/joinSplitWords.md +1 -1
- package/docs/api/functions/jsonFilterToWhere.md +2 -2
- package/docs/api/functions/jsonToMarkdownStr.md +2 -2
- 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 +2 -2
- package/docs/api/functions/loadTextFromPaths.md +3 -3
- package/docs/api/functions/lrucache.md +1 -1
- package/docs/api/functions/matchUrlProtocol.md +1 -1
- package/docs/api/functions/memoize.md +5 -3
- package/docs/api/functions/mergeArray.md +1 -1
- package/docs/api/functions/messagesToText.md +1 -1
- package/docs/api/functions/nanoid.md +45 -0
- package/docs/api/functions/normalizePath.md +1 -1
- package/docs/api/functions/paramsSizeToScaleStr.md +1 -1
- package/docs/api/functions/parseCommand.md +3 -3
- package/docs/api/functions/parseDateFormat.md +7 -3
- package/docs/api/functions/parseISO.md +7 -3
- package/docs/api/functions/parseJsJson.md +2 -2
- package/docs/api/functions/parseJsJsonSimpleSync.md +2 -2
- package/docs/api/functions/parseObjectArgInfo.md +2 -2
- package/docs/api/functions/parseObjectArgumentInfos.md +2 -2
- package/docs/api/functions/parseObjectArguments.md +2 -2
- package/docs/api/functions/parseObjectArgumentsAsArgInfos.md +2 -2
- package/docs/api/functions/parseYaml.md +1 -1
- package/docs/api/functions/pruneSubdirectories.md +1 -1
- package/docs/api/functions/pruneSubdirectoriesInPlace.md +1 -1
- package/docs/api/functions/quoteStr.md +1 -1
- package/docs/api/functions/readFilenamesRecursiveSync.md +2 -2
- package/docs/api/functions/readTextFileChunks.md +2 -2
- package/docs/api/functions/readTextFileChunksEx.md +2 -2
- package/docs/api/functions/readableFromAsyncIterable.md +4 -2
- package/docs/api/functions/registerCoreTools.md +1 -1
- package/docs/api/functions/removeMarkdownBold.md +2 -2
- package/docs/api/functions/removeMarkdownBoldAndItalic.md +2 -2
- package/docs/api/functions/removeMarkdownItalic.md +2 -2
- package/docs/api/functions/replaceWithPlaceholder.md +2 -2
- package/docs/api/functions/restoreFromPlacehoders.md +2 -2
- 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 +1 -1
- package/docs/api/functions/simplifyObjectArguments.md +1 -1
- package/docs/api/functions/sleep.md +1 -1
- package/docs/api/functions/sortedValues.md +4 -2
- package/docs/api/functions/splitChunks.md +2 -2
- package/docs/api/functions/splitParagraph.md +2 -2
- 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/throwError.md +1 -1
- package/docs/api/functions/toDate.md +7 -3
- package/docs/api/functions/toDateTime.md +1 -1
- package/docs/api/functions/trimStartOfStreamHelper.md +3 -3
- package/docs/api/functions/truncTo.md +1 -1
- package/docs/api/functions/truncateByToken.md +2 -2
- package/docs/api/functions/truncateToTokenLimit.md +2 -2
- package/docs/api/functions/truncateToTokenLimitEx.md +2 -2
- package/docs/api/functions/uuid.md +15 -6
- package/docs/api/functions/uuidStringify.md +1 -1
- package/docs/api/functions/uuidv1.md +5 -3
- package/docs/api/functions/uuidv4.md +5 -3
- package/docs/api/functions/uuidv5.md +5 -3
- package/docs/api/functions/uuidv6.md +61 -0
- package/docs/api/functions/uuidv7.md +61 -0
- package/docs/api/functions/wrapEventEmitter.md +1 -1
- package/docs/api/functions/xxhash.md +1 -1
- package/docs/api/functions/xxhash32.md +1 -1
- package/docs/api/functions/xxhash64.md +1 -1
- package/docs/api/functions/xxhashAsStr.md +1 -1
- package/docs/api/functions/yieldExec.md +1 -1
- package/docs/api/globals.md +11 -6
- package/docs/api/interfaces/AIChatAssistantMessageParam.md +12 -12
- package/docs/api/interfaces/AIChatContentPartImage.md +3 -3
- package/docs/api/interfaces/AIChatContentPartText.md +3 -3
- package/docs/api/interfaces/AIChatMessageParamBase.md +7 -7
- package/docs/api/interfaces/AIChatMessageToolCall.md +4 -4
- package/docs/api/interfaces/AIChatSystemMessageParam.md +9 -9
- package/docs/api/interfaces/AIChatToolChoiceFuncObject.md +3 -3
- package/docs/api/interfaces/AIChatToolChoiceObject.md +2 -2
- package/docs/api/interfaces/AIChatToolFunc.md +5 -5
- package/docs/api/interfaces/AIChatToolFuncParam.md +3 -3
- package/docs/api/interfaces/AIChatToolMessageParam.md +10 -10
- package/docs/api/interfaces/AIChatToolParam.md +2 -2
- package/docs/api/interfaces/AIChatToolTypeObject.md +2 -2
- package/docs/api/interfaces/AIChatUserMessageParam.md +13 -13
- package/docs/api/interfaces/AIChoiceConfig.md +8 -8
- package/docs/api/interfaces/AIResult.md +12 -8
- package/docs/api/interfaces/AIStreamParser.md +8 -6
- package/docs/api/interfaces/AIStreamParserOptions.md +2 -2
- package/docs/api/interfaces/BaseFunc.md +17 -17
- package/docs/api/interfaces/BaseFuncItem.md +15 -15
- package/docs/api/interfaces/BinarySemaphoreAcquireOptions.md +2 -2
- package/docs/api/interfaces/BinarySemaphoreOptions.md +5 -5
- package/docs/api/interfaces/BinarySemaphoreReleaseOptions.md +2 -2
- package/docs/api/interfaces/BinarySemaphoreReleaserFunc.md +3 -3
- package/docs/api/interfaces/CancelableAbilityOptions.md +4 -4
- package/docs/api/interfaces/ClientFuncItem.md +21 -25
- package/docs/api/interfaces/EventClientFuncParams.md +5 -5
- package/docs/api/interfaces/EventServerFuncParams.md +14 -6
- package/docs/api/interfaces/FewShotPromptTemplateOptions.md +9 -7
- package/docs/api/interfaces/FuncItem.md +18 -18
- 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 +4 -4
- package/docs/api/interfaces/IClientToolTransport.md +9 -9
- package/docs/api/interfaces/IFileMetaInfo.md +8 -8
- package/docs/api/interfaces/IPubSubClientTransport.md +31 -7
- package/docs/api/interfaces/IPubSubServerTransport.md +92 -47
- package/docs/api/interfaces/IReadTextFileChunksOptions.md +13 -13
- package/docs/api/interfaces/IServerToolTransport.md +19 -14
- package/docs/api/interfaces/IToolTransport.md +6 -6
- package/docs/api/interfaces/ITruncateToTokenLimitOptions.md +11 -11
- package/docs/api/interfaces/JsonFilter.md +1 -1
- package/docs/api/interfaces/ParseObjectArgumentOptions.md +11 -11
- package/docs/api/interfaces/ProbabilityItem.md +4 -4
- package/docs/api/interfaces/PromptExampleSelectorOptions.md +3 -3
- package/docs/api/interfaces/PubSubClientStream.md +26 -14
- package/docs/api/interfaces/PubSubServerSession.md +8 -8
- package/docs/api/interfaces/RemoteFuncItem.md +21 -25
- package/docs/api/interfaces/ReplacePlacehoderOptions.md +5 -5
- package/docs/api/interfaces/ResClientFuncParams.md +3 -3
- package/docs/api/interfaces/ResServerFuncParams.md +6 -6
- package/docs/api/interfaces/RpcMethodsClientFuncParams.md +2 -2
- package/docs/api/interfaces/RpcMethodsServerFuncParams.md +4 -4
- package/docs/api/interfaces/SectionStringOptions.md +3 -3
- package/docs/api/interfaces/SemaphoreOptions.md +7 -7
- package/docs/api/interfaces/SemaphoreTaskItem.md +6 -6
- package/docs/api/interfaces/ServerFuncItem.md +22 -26
- package/docs/api/interfaces/ServerFuncParams.md +3 -3
- package/docs/api/interfaces/SplitSentenceOptions.md +5 -5
- package/docs/api/interfaces/StreamCallbacksAndOptions.md +11 -7
- package/docs/api/interfaces/TaskAbortControllers.md +1 -1
- package/docs/api/interfaces/TaskPromise.md +17 -9
- package/docs/api/interfaces/ToolFuncPackage.md +5 -5
- package/docs/api/type-aliases/AIChatContentPart.md +2 -2
- package/docs/api/type-aliases/AIChatMessageParam.md +2 -2
- package/docs/api/type-aliases/AIChatRole.md +2 -2
- package/docs/api/type-aliases/AIChatToolChoiceParam.md +2 -2
- package/docs/api/type-aliases/AIMessageType.md +2 -2
- package/docs/api/type-aliases/AIModelNameRule.md +2 -2
- package/docs/api/type-aliases/AIModelNameRuleFn.md +2 -2
- package/docs/api/type-aliases/AIModelNameRules.md +2 -2
- package/docs/api/type-aliases/AITextGenerationFinishReason.md +2 -2
- package/docs/api/type-aliases/ActionName.md +2 -2
- package/docs/api/type-aliases/ArrayMergeWay.md +2 -2
- package/docs/api/type-aliases/AsyncTaskId.md +2 -2
- package/docs/api/type-aliases/BeforeShutdownListener.md +2 -2
- package/docs/api/type-aliases/EventErrorListenerFn.md +2 -2
- package/docs/api/type-aliases/EventListenerFn.md +2 -2
- package/docs/api/type-aliases/FuncParamType.md +2 -2
- package/docs/api/type-aliases/PromptExamples.md +5 -3
- package/docs/api/type-aliases/PubSubClientId.md +2 -2
- package/docs/api/type-aliases/PubSubCtx.md +24 -4
- package/docs/api/type-aliases/RpcMethodHandler.md +2 -2
- package/docs/api/type-aliases/SSEClient.md +53 -0
- package/docs/api/type-aliases/SemaphoreIsReadyFuncType.md +2 -2
- package/docs/api/type-aliases/TFunc.md +2 -2
- package/docs/api/type-aliases/UUIDVersions.md +11 -0
- package/docs/api/variables/AIChatRoles.md +1 -1
- 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 +2 -2
- package/docs/api/variables/ArrayMergeWaySymbol.md +2 -2
- package/docs/api/variables/ClientEventPrefix.md +11 -0
- package/docs/api/variables/ClientToolFuncSchema.md +4 -2
- package/docs/api/variables/DEFAULT_CONFIG_NAME.md +1 -1
- package/docs/api/variables/DefaultAsyncSemaphoreCapacity.md +1 -1
- package/docs/api/variables/EventBusName.md +1 -1
- package/docs/api/variables/EventName.md +1 -1
- package/docs/api/variables/FuncMetaSymbol.md +2 -2
- package/docs/api/variables/LLM_TOKENIZER_NAMES.md +4 -4
- package/docs/api/variables/LLM_TOKENIZER_NAMES_MAP.md +1 -1
- package/docs/api/variables/PASSING_SCORE.md +1 -1
- package/docs/api/variables/RStreamErrCode.md +1 -1
- package/docs/api/variables/RemoteToolFuncSchema.md +4 -2
- package/docs/api/variables/ResponseRStreamErrCode.md +1 -1
- package/docs/api/variables/RpcMethodsClientToolSchema.md +4 -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 +4 -2
- 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 +4 -2
- package/docs/api/variables/backendEventable.md +11 -0
- package/docs/api/variables/base32768.md +1 -1
- 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 +11 -0
- package/docs/api/{functions → variables}/wait.md +16 -14
- package/docs/pubsub.md +427 -105
- package/docs/server_client_tools.md +5 -3
- package/docs/toolFunc.md +3 -1
- package/package.json +8 -7
- package/dist/chunk-4XRPAC7C.mjs +0 -1
- package/docs/api/functions/backendEventable.md +0 -29
- package/docs/api/functions/makeToolFuncCancelable.md +0 -29
- package/docs/api/interfaces/PubSubClient.md +0 -27
- package/docs/api/namespaces/uuidv5/README.md +0 -12
|
@@ -3,7 +3,6 @@ import { AdvancePropertyManager } from 'property-manager';
|
|
|
3
3
|
import { AbilityOptions } from 'custom-ability';
|
|
4
4
|
import { CommonError } from '@isdk/common-error';
|
|
5
5
|
import { Cache, ICacheOptions } from 'secondary-cache';
|
|
6
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Represents the data type of a function parameter as a string (e.g., `'string'`, `'number'`).
|
|
@@ -681,9 +680,8 @@ interface RemoteFuncItem extends BaseFuncItem {
|
|
|
681
680
|
*/
|
|
682
681
|
action?: ActionName;
|
|
683
682
|
/**
|
|
684
|
-
*
|
|
683
|
+
* Addtional options to be passed to the underlying `fetch` call in a transport.
|
|
685
684
|
* @type {any}
|
|
686
|
-
* @deprecated Use `transport` instead.
|
|
687
685
|
*/
|
|
688
686
|
fetchOptions?: any;
|
|
689
687
|
}
|
|
@@ -1210,8 +1208,8 @@ declare class ClientTools extends ToolFunc {
|
|
|
1210
1208
|
static action?: ActionName | string;
|
|
1211
1209
|
private static _transport;
|
|
1212
1210
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1211
|
+
* Gets the root URL for API endpoints from the configured transport.
|
|
1212
|
+
* This is used as the base for constructing request URLs.
|
|
1215
1213
|
*/
|
|
1216
1214
|
static get apiRoot(): string;
|
|
1217
1215
|
/**
|
|
@@ -1234,11 +1232,11 @@ declare class ClientTools extends ToolFunc {
|
|
|
1234
1232
|
static loadFromSync(items: Funcs): void;
|
|
1235
1233
|
static fetch(name: string, objParam?: any, ...args: any[]): Promise<any>;
|
|
1236
1234
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1235
|
+
* Gets the root URL for API endpoints from the configured transport.
|
|
1236
|
+
* This is used as the base for constructing request URLs.
|
|
1239
1237
|
*/
|
|
1240
1238
|
get apiRoot(): string;
|
|
1241
|
-
fetch(objParam?: any, act?: ActionName, subName?: any): Promise<any>;
|
|
1239
|
+
fetch(objParam?: any, act?: ActionName, subName?: any, fetchOptions?: any): Promise<any>;
|
|
1242
1240
|
/**
|
|
1243
1241
|
* The core implementation for a client-side tool. When a `ClientTools` instance
|
|
1244
1242
|
* is "run", this `func` method is executed. It delegates the call to the
|
|
@@ -1391,8 +1389,8 @@ interface RpcMethodsClientFuncParams {
|
|
|
1391
1389
|
[name: string]: any;
|
|
1392
1390
|
}
|
|
1393
1391
|
declare class RpcMethodsClientTool extends ClientTools {
|
|
1394
|
-
fetch(options: RpcMethodsClientFuncParams, action: ActionName, subName?: any): Promise<any>;
|
|
1395
|
-
_func(action: ActionName, options: RpcMethodsClientFuncParams): Promise<any>;
|
|
1392
|
+
fetch(options: RpcMethodsClientFuncParams, action: ActionName, subName?: any, fetchOptions?: any): Promise<any>;
|
|
1393
|
+
_func(action: ActionName, options: RpcMethodsClientFuncParams, fetchOptions?: any): Promise<any>;
|
|
1396
1394
|
func(options: RpcMethodsClientFuncParams): Promise<any>;
|
|
1397
1395
|
assignMethods(methods: string[]): void;
|
|
1398
1396
|
}
|
|
@@ -1414,7 +1412,7 @@ interface ResClientTools {
|
|
|
1414
1412
|
list?(options?: ResClientFuncParams): any;
|
|
1415
1413
|
}
|
|
1416
1414
|
declare class ResClientTools extends RpcMethodsClientTool {
|
|
1417
|
-
fetch(options: ResClientFuncParams, action: ActionName): Promise<any>;
|
|
1415
|
+
fetch(options: ResClientFuncParams, action: ActionName, ...args: any[]): Promise<any>;
|
|
1418
1416
|
}
|
|
1419
1417
|
|
|
1420
1418
|
type PubSubCtx<T = any> = {
|
|
@@ -1434,6 +1432,12 @@ type PubSubCtx<T = any> = {
|
|
|
1434
1432
|
* and managing the connection state.
|
|
1435
1433
|
*/
|
|
1436
1434
|
interface PubSubClientStream {
|
|
1435
|
+
/**
|
|
1436
|
+
* A unique identifier for this specific stream instance.
|
|
1437
|
+
* This ID is typically generated by the client transport and sent to the
|
|
1438
|
+
* server to establish a stable session identity.
|
|
1439
|
+
*/
|
|
1440
|
+
clientId: string;
|
|
1437
1441
|
/**
|
|
1438
1442
|
* The protocol being used for this stream (e.g., 'sse', 'ws', 'ipc').
|
|
1439
1443
|
*/
|
|
@@ -1491,12 +1495,12 @@ interface PubSubClientStream {
|
|
|
1491
1495
|
interface IPubSubClientTransport {
|
|
1492
1496
|
/**
|
|
1493
1497
|
* Establishes a connection to a server endpoint.
|
|
1494
|
-
* @param url The URL of the
|
|
1498
|
+
* @param url The full URL of the endpoint, or a path relative to the `apiRoot` that may have been configured on the transport.
|
|
1495
1499
|
* @param params Optional parameters for the connection, which might include
|
|
1496
1500
|
* things like authentication tokens, initial subscription topics, or a client ID.
|
|
1497
1501
|
* @returns A `PubSubClientStream` instance that represents the active connection.
|
|
1498
1502
|
*/
|
|
1499
|
-
connect: (url: string, params?:
|
|
1503
|
+
connect: (url: string, params?: any) => PubSubClientStream | Promise<PubSubClientStream>;
|
|
1500
1504
|
/**
|
|
1501
1505
|
* Optional. Disconnects a given stream.
|
|
1502
1506
|
* While the `close` method exists on the stream itself, placing `disconnect`
|
|
@@ -1505,6 +1509,13 @@ interface IPubSubClientTransport {
|
|
|
1505
1509
|
* @param stream The stream to disconnect.
|
|
1506
1510
|
*/
|
|
1507
1511
|
disconnect?: (stream: PubSubClientStream) => void;
|
|
1512
|
+
/**
|
|
1513
|
+
* Optional. Configures the transport with a base URL.
|
|
1514
|
+
* If implemented, this allows the transport to resolve relative paths
|
|
1515
|
+
* passed to the `connect` method.
|
|
1516
|
+
* @param apiRoot The base URL for the API.
|
|
1517
|
+
*/
|
|
1518
|
+
setApiRoot?: (apiRoot: string) => void;
|
|
1508
1519
|
}
|
|
1509
1520
|
|
|
1510
1521
|
/**
|
|
@@ -1512,21 +1523,6 @@ interface IPubSubClientTransport {
|
|
|
1512
1523
|
* This ID is used for targeted message publishing.
|
|
1513
1524
|
*/
|
|
1514
1525
|
type PubSubClientId = string;
|
|
1515
|
-
/**
|
|
1516
|
-
* Represents a client as seen by the transport layer after a subscription is made.
|
|
1517
|
-
* It contains the client's ID and can hold other transport-specific metadata.
|
|
1518
|
-
*/
|
|
1519
|
-
interface PubSubClient {
|
|
1520
|
-
/**
|
|
1521
|
-
* The unique identifier for this client.
|
|
1522
|
-
* This can be assigned by the client during connection or generated by the server.
|
|
1523
|
-
*/
|
|
1524
|
-
clientId?: PubSubClientId;
|
|
1525
|
-
/**
|
|
1526
|
-
* Allows for storing additional, transport-specific properties about the client.
|
|
1527
|
-
*/
|
|
1528
|
-
[k: string]: any;
|
|
1529
|
-
}
|
|
1530
1526
|
/**
|
|
1531
1527
|
* Represents an active client connection session on the server.
|
|
1532
1528
|
* This object provides a standardized way for the `EventServer` to interact
|
|
@@ -1581,37 +1577,44 @@ interface IPubSubServerTransport {
|
|
|
1581
1577
|
*/
|
|
1582
1578
|
readonly protocol: 'sse' | 'ws' | 'ipc' | string;
|
|
1583
1579
|
/**
|
|
1584
|
-
*
|
|
1585
|
-
* server or framework. This is typically required for protocols like SSE or
|
|
1586
|
-
* WebSockets that need to handle incoming HTTP requests at a specific path.
|
|
1587
|
-
*
|
|
1588
|
-
* @param path The URL path to handle (e.g., '/api/events').
|
|
1589
|
-
* @param options Additional options for mounting, specific to the framework.
|
|
1590
|
-
*/
|
|
1591
|
-
mount?: (path: string, options?: Record<string, any>) => void;
|
|
1592
|
-
/**
|
|
1593
|
-
* Establishes a connection with a client and subscribes it to an event stream.
|
|
1580
|
+
* Connects a client, establishing a persistent communication channel.
|
|
1594
1581
|
*
|
|
1595
1582
|
* This method is designed to be generic. Transport-specific details, such as
|
|
1596
|
-
* HTTP request/response objects
|
|
1597
|
-
*
|
|
1583
|
+
* HTTP request/response objects, are passed inside the `options` parameter.
|
|
1584
|
+
* For protocols like SSE, initial events can be passed to be subscribed to at connection time.
|
|
1598
1585
|
*
|
|
1599
|
-
* @param
|
|
1600
|
-
* @
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
* @param options.headers HTTP headers from the client request.
|
|
1606
|
-
* @returns A `PubSubClient` object representing the newly connected client.
|
|
1607
|
-
*/
|
|
1608
|
-
subscribe: (events?: string[], options?: {
|
|
1609
|
-
req?: any;
|
|
1610
|
-
res?: any;
|
|
1586
|
+
* @param options A container for transport-specific parameters, including optional initial events.
|
|
1587
|
+
* @returns A `PubSubServerSession` object representing the newly connected client session.
|
|
1588
|
+
*/
|
|
1589
|
+
connect: (options?: {
|
|
1590
|
+
req: any;
|
|
1591
|
+
res: any;
|
|
1611
1592
|
clientId?: PubSubClientId;
|
|
1612
|
-
|
|
1593
|
+
events?: string[];
|
|
1613
1594
|
[k: string]: any;
|
|
1614
|
-
}) =>
|
|
1595
|
+
}) => PubSubServerSession;
|
|
1596
|
+
/**
|
|
1597
|
+
* Subscribes a client session to one or more events.
|
|
1598
|
+
*
|
|
1599
|
+
* Note: Not all transports may support subscribing to new events after the
|
|
1600
|
+
* initial connection. For transports like SSE, this might be a no-op or
|
|
1601
|
+
* throw an error.
|
|
1602
|
+
*
|
|
1603
|
+
* @param session The `PubSubServerSession` of the client.
|
|
1604
|
+
* @param events An array of event names to subscribe to.
|
|
1605
|
+
*/
|
|
1606
|
+
subscribe: (session: PubSubServerSession, events: string[]) => void;
|
|
1607
|
+
/**
|
|
1608
|
+
* Unsubscribes a client session from one or more events.
|
|
1609
|
+
*
|
|
1610
|
+
* Note: Not all transports may support unsubscribing from events after the
|
|
1611
|
+
* initial connection. For transports like SSE, this might be a no-op or
|
|
1612
|
+
* throw an error.
|
|
1613
|
+
*
|
|
1614
|
+
* @param session The `PubSubServerSession` of the client.
|
|
1615
|
+
* @param events An array of event names to unsubscribe from.
|
|
1616
|
+
*/
|
|
1617
|
+
unsubscribe: (session: PubSubServerSession, events: string[]) => void;
|
|
1615
1618
|
/**
|
|
1616
1619
|
* Publishes an event from the server to connected clients.
|
|
1617
1620
|
*
|
|
@@ -1648,6 +1651,14 @@ interface IPubSubServerTransport {
|
|
|
1648
1651
|
* @param cb The callback function that receives the session, event name, data, and context.
|
|
1649
1652
|
*/
|
|
1650
1653
|
onMessage?: (cb: (session: PubSubServerSession, event: string, data: any, ctx?: PubSubCtx) => void) => void;
|
|
1654
|
+
/**
|
|
1655
|
+
* Optional. Finds and returns a session based on a request object.
|
|
1656
|
+
* This is used by higher-level tools to find the correct session
|
|
1657
|
+
* for operations like adding a subscription via a generic RPC call.
|
|
1658
|
+
* @param req The request object (e.g., http.IncomingMessage or Electron.IpcMainEvent).
|
|
1659
|
+
* @returns The corresponding session, or undefined if not found.
|
|
1660
|
+
*/
|
|
1661
|
+
getSessionFromReq?: (req: any) => PubSubServerSession | undefined;
|
|
1651
1662
|
}
|
|
1652
1663
|
|
|
1653
1664
|
interface EventClientFuncParams {
|
|
@@ -1664,20 +1675,21 @@ declare class EventClient extends ResClientTools {
|
|
|
1664
1675
|
_streamEvents: string[] | undefined;
|
|
1665
1676
|
_sseListeners: Record<string, (data: any, ctx?: PubSubCtx) => void>;
|
|
1666
1677
|
_forwardEvents: Set<string>;
|
|
1667
|
-
get
|
|
1678
|
+
get clientId(): string | undefined;
|
|
1679
|
+
getEvtSource(): Promise<PubSubClientStream>;
|
|
1668
1680
|
get active(): boolean;
|
|
1669
|
-
|
|
1681
|
+
setActive(v: boolean): Promise<void>;
|
|
1670
1682
|
description: string;
|
|
1671
|
-
initEventStream(events?: string | string[]): PubSubClientStream
|
|
1683
|
+
initEventStream(events?: string | string[]): Promise<PubSubClientStream>;
|
|
1672
1684
|
esListener(evtType: string, data: any, ctx?: PubSubCtx): void;
|
|
1673
|
-
ebListener: (this: Event, ...
|
|
1685
|
+
ebListener: (this: Event, ...args: any[]) => Promise<void>;
|
|
1674
1686
|
/**
|
|
1675
|
-
* subscribe server
|
|
1687
|
+
* subscribe server event
|
|
1676
1688
|
* @param events
|
|
1677
1689
|
*/
|
|
1678
1690
|
subscribe(events: string | string[]): Promise<any>;
|
|
1679
1691
|
/**
|
|
1680
|
-
* unsubscribe server
|
|
1692
|
+
* unsubscribe server event
|
|
1681
1693
|
* @param events
|
|
1682
1694
|
*/
|
|
1683
1695
|
unsubscribe(events: string | string[]): Promise<any>;
|
|
@@ -1747,12 +1759,19 @@ declare class ResServerTools extends RpcMethodsServerTool {
|
|
|
1747
1759
|
castParams(params: RpcMethodsServerFuncParams): RpcMethodsServerFuncParams;
|
|
1748
1760
|
}
|
|
1749
1761
|
|
|
1762
|
+
declare const ClientEventPrefix = "client:";
|
|
1750
1763
|
interface EventServerFuncParams extends ServerFuncParams {
|
|
1751
1764
|
event?: string | string[];
|
|
1752
1765
|
data?: any;
|
|
1753
1766
|
act?: 'sub' | 'pub' | 'unsub';
|
|
1767
|
+
clientId?: string;
|
|
1754
1768
|
}
|
|
1755
1769
|
declare class EventServer extends ResServerTools {
|
|
1770
|
+
/**
|
|
1771
|
+
* Controls whether the client-published events are auto-emitted on server's localBus.
|
|
1772
|
+
* Defaults to false for security. Must be explicitly enabled for 'client:' prefixed events to be emitted.
|
|
1773
|
+
*/
|
|
1774
|
+
static autoInjectToLocalBus: boolean;
|
|
1756
1775
|
private static _boundEbListener?;
|
|
1757
1776
|
static _pubSubTransport: IPubSubServerTransport | undefined;
|
|
1758
1777
|
static setPubSubTransport(t?: IPubSubServerTransport): void;
|
|
@@ -1763,25 +1782,40 @@ declare class EventServer extends ResServerTools {
|
|
|
1763
1782
|
"event-bus": EventToolFunc;
|
|
1764
1783
|
};
|
|
1765
1784
|
get pubSubTransport(): IPubSubServerTransport | undefined;
|
|
1766
|
-
static publish(
|
|
1785
|
+
static publish(event: string, data: any, target?: {
|
|
1767
1786
|
clientId?: string | string[];
|
|
1768
1787
|
}): void | undefined;
|
|
1769
1788
|
static ebListener(eventType: string, ...data: any[]): void;
|
|
1770
|
-
static subscribe(req: IncomingMessage, res: ServerResponse, events?: string[], options?: any): PubSubClient | undefined;
|
|
1771
1789
|
static alreadyForward(event: string): true | undefined;
|
|
1772
|
-
|
|
1773
|
-
subscribeSSE(req: IncomingMessage, res: ServerResponse, events?: string | string[]): any;
|
|
1790
|
+
publishServerEvent(event: string, data: any): any;
|
|
1774
1791
|
forward(events: string | string[]): void;
|
|
1775
1792
|
unforward(events: string | string[]): void;
|
|
1776
|
-
list({ _req, _res, event }: EventServerFuncParams):
|
|
1777
|
-
$sub({ event }: EventServerFuncParams): {
|
|
1793
|
+
list({ _req, _res, event }: EventServerFuncParams): PubSubServerSession;
|
|
1794
|
+
$sub({ event, _req }: EventServerFuncParams): {
|
|
1795
|
+
forward: boolean;
|
|
1796
|
+
subscribed: boolean;
|
|
1778
1797
|
event: string | string[];
|
|
1798
|
+
clientId: any;
|
|
1799
|
+
} | {
|
|
1800
|
+
forward: boolean;
|
|
1801
|
+
event: string | string[];
|
|
1802
|
+
subscribed?: undefined;
|
|
1803
|
+
clientId?: undefined;
|
|
1779
1804
|
};
|
|
1780
|
-
$unsub({ event }: EventServerFuncParams): {
|
|
1805
|
+
$unsub({ event, _req }: EventServerFuncParams): {
|
|
1806
|
+
forward: boolean;
|
|
1807
|
+
subscribed: boolean;
|
|
1808
|
+
event: string | string[];
|
|
1809
|
+
clientId: any;
|
|
1810
|
+
} | {
|
|
1811
|
+
forward: boolean;
|
|
1781
1812
|
event: string | string[];
|
|
1813
|
+
subscribed?: undefined;
|
|
1814
|
+
clientId?: undefined;
|
|
1782
1815
|
};
|
|
1783
|
-
$publish({ event: events, data }: EventServerFuncParams): {
|
|
1816
|
+
$publish({ event: events, data, _req }: EventServerFuncParams): {
|
|
1784
1817
|
event: string[];
|
|
1818
|
+
senderId: any;
|
|
1785
1819
|
};
|
|
1786
1820
|
isStream(params: ServerFuncParams): boolean;
|
|
1787
1821
|
}
|
|
@@ -1789,4 +1823,4 @@ declare const eventServer: EventServer;
|
|
|
1789
1823
|
|
|
1790
1824
|
declare function registerCoreTools(): void;
|
|
1791
1825
|
|
|
1792
|
-
export { funcGetMeta as $, type AsyncTaskId as A, type BinarySemaphoreOptions as B, ClientToolTransport as C, DefaultAsyncSemaphoreCapacity as D, TaskAbortController as E, type Funcs as F, type TaskAbortControllers as G, type TaskPromise as H, type IPubSubServerTransport as I, CancelableAbility as J, makeToolFuncCancelable as K, type FuncParamType as L, type FuncParam as M, type FuncParams as N, type TFunc as O, type
|
|
1826
|
+
export { funcGetMeta as $, type AsyncTaskId as A, type BinarySemaphoreOptions as B, ClientToolTransport as C, DefaultAsyncSemaphoreCapacity as D, TaskAbortController as E, type Funcs as F, type TaskAbortControllers as G, type TaskPromise as H, type IPubSubServerTransport as I, CancelableAbility as J, makeToolFuncCancelable as K, type FuncParamType as L, type FuncParam as M, type FuncParams as N, type TFunc as O, type PubSubServerSession as P, type BaseFuncItem as Q, RemoteToolFuncSchema as R, ServerTools as S, ToolTransport as T, type FuncItem as U, type BaseFunc as V, type ToolFuncPackage as W, ToolFunc as X, ToolFuncSchema as Y, FuncMetaSymbol as Z, funcWithMeta as _, type AIModelNameRules as a, ClientTools as a0, type ClientFuncItem as a1, ClientToolFuncSchema as a2, type ServerFuncParams as a3, type ServerFuncItem as a4, ServerToolFuncSchema as a5, registerCoreTools as a6, EventToolFunc as a7, event as a8, SecondaryCache as a9, _lrucache as aa, createLRUCache as ab, lrucache as ac, type EventClientFuncParams as ad, EventClient as ae, eventClient as af, ClientEventPrefix as ag, type EventServerFuncParams as ah, EventServer as ai, eventServer as aj, type RpcMethodsClientFuncParams as ak, RpcMethodsClientTool as al, RpcMethodsClientToolSchema as am, type RpcMethodsServerFuncParams as an, RpcMethodsServerTool as ao, RpcMethodsServerToolSchema as ap, type ResClientFuncParams as aq, ResClientTools as ar, type ResServerFuncParams as as, ResServerTools as at, type RpcMethodHandler as au, type IClientToolTransport as av, type PubSubCtx as aw, type PubSubClientId as b, type IPubSubClientTransport as c, type PubSubClientStream as d, type IToolTransport as e, type ActionName as f, PASSING_SCORE as g, ActionNames as h, type AIModelNameRuleFn as i, type AIModelNameRule as j, type RemoteFuncItem as k, type SemaphoreIsReadyFuncType as l, type BinarySemaphoreAcquireOptions as m, type BinarySemaphoreReleaseOptions as n, type BinarySemaphoreReleaserFunc as o, type SemaphoreOptions as p, type SemaphoreTaskItem as q, BinarySemaphore as r, Semaphore as s, RateLimit as t, ToolAsyncMultiTaskBit as u, ToolAsyncCancelableBit as v, ToolAsyncPriorityBit as w, AsyncFeatureBits as x, AsyncFeatures as y, type CancelableAbilityOptions as z };
|
|
@@ -3,7 +3,6 @@ import { AdvancePropertyManager } from 'property-manager';
|
|
|
3
3
|
import { AbilityOptions } from 'custom-ability';
|
|
4
4
|
import { CommonError } from '@isdk/common-error';
|
|
5
5
|
import { Cache, ICacheOptions } from 'secondary-cache';
|
|
6
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Represents the data type of a function parameter as a string (e.g., `'string'`, `'number'`).
|
|
@@ -681,9 +680,8 @@ interface RemoteFuncItem extends BaseFuncItem {
|
|
|
681
680
|
*/
|
|
682
681
|
action?: ActionName;
|
|
683
682
|
/**
|
|
684
|
-
*
|
|
683
|
+
* Addtional options to be passed to the underlying `fetch` call in a transport.
|
|
685
684
|
* @type {any}
|
|
686
|
-
* @deprecated Use `transport` instead.
|
|
687
685
|
*/
|
|
688
686
|
fetchOptions?: any;
|
|
689
687
|
}
|
|
@@ -1210,8 +1208,8 @@ declare class ClientTools extends ToolFunc {
|
|
|
1210
1208
|
static action?: ActionName | string;
|
|
1211
1209
|
private static _transport;
|
|
1212
1210
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1211
|
+
* Gets the root URL for API endpoints from the configured transport.
|
|
1212
|
+
* This is used as the base for constructing request URLs.
|
|
1215
1213
|
*/
|
|
1216
1214
|
static get apiRoot(): string;
|
|
1217
1215
|
/**
|
|
@@ -1234,11 +1232,11 @@ declare class ClientTools extends ToolFunc {
|
|
|
1234
1232
|
static loadFromSync(items: Funcs): void;
|
|
1235
1233
|
static fetch(name: string, objParam?: any, ...args: any[]): Promise<any>;
|
|
1236
1234
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1235
|
+
* Gets the root URL for API endpoints from the configured transport.
|
|
1236
|
+
* This is used as the base for constructing request URLs.
|
|
1239
1237
|
*/
|
|
1240
1238
|
get apiRoot(): string;
|
|
1241
|
-
fetch(objParam?: any, act?: ActionName, subName?: any): Promise<any>;
|
|
1239
|
+
fetch(objParam?: any, act?: ActionName, subName?: any, fetchOptions?: any): Promise<any>;
|
|
1242
1240
|
/**
|
|
1243
1241
|
* The core implementation for a client-side tool. When a `ClientTools` instance
|
|
1244
1242
|
* is "run", this `func` method is executed. It delegates the call to the
|
|
@@ -1391,8 +1389,8 @@ interface RpcMethodsClientFuncParams {
|
|
|
1391
1389
|
[name: string]: any;
|
|
1392
1390
|
}
|
|
1393
1391
|
declare class RpcMethodsClientTool extends ClientTools {
|
|
1394
|
-
fetch(options: RpcMethodsClientFuncParams, action: ActionName, subName?: any): Promise<any>;
|
|
1395
|
-
_func(action: ActionName, options: RpcMethodsClientFuncParams): Promise<any>;
|
|
1392
|
+
fetch(options: RpcMethodsClientFuncParams, action: ActionName, subName?: any, fetchOptions?: any): Promise<any>;
|
|
1393
|
+
_func(action: ActionName, options: RpcMethodsClientFuncParams, fetchOptions?: any): Promise<any>;
|
|
1396
1394
|
func(options: RpcMethodsClientFuncParams): Promise<any>;
|
|
1397
1395
|
assignMethods(methods: string[]): void;
|
|
1398
1396
|
}
|
|
@@ -1414,7 +1412,7 @@ interface ResClientTools {
|
|
|
1414
1412
|
list?(options?: ResClientFuncParams): any;
|
|
1415
1413
|
}
|
|
1416
1414
|
declare class ResClientTools extends RpcMethodsClientTool {
|
|
1417
|
-
fetch(options: ResClientFuncParams, action: ActionName): Promise<any>;
|
|
1415
|
+
fetch(options: ResClientFuncParams, action: ActionName, ...args: any[]): Promise<any>;
|
|
1418
1416
|
}
|
|
1419
1417
|
|
|
1420
1418
|
type PubSubCtx<T = any> = {
|
|
@@ -1434,6 +1432,12 @@ type PubSubCtx<T = any> = {
|
|
|
1434
1432
|
* and managing the connection state.
|
|
1435
1433
|
*/
|
|
1436
1434
|
interface PubSubClientStream {
|
|
1435
|
+
/**
|
|
1436
|
+
* A unique identifier for this specific stream instance.
|
|
1437
|
+
* This ID is typically generated by the client transport and sent to the
|
|
1438
|
+
* server to establish a stable session identity.
|
|
1439
|
+
*/
|
|
1440
|
+
clientId: string;
|
|
1437
1441
|
/**
|
|
1438
1442
|
* The protocol being used for this stream (e.g., 'sse', 'ws', 'ipc').
|
|
1439
1443
|
*/
|
|
@@ -1491,12 +1495,12 @@ interface PubSubClientStream {
|
|
|
1491
1495
|
interface IPubSubClientTransport {
|
|
1492
1496
|
/**
|
|
1493
1497
|
* Establishes a connection to a server endpoint.
|
|
1494
|
-
* @param url The URL of the
|
|
1498
|
+
* @param url The full URL of the endpoint, or a path relative to the `apiRoot` that may have been configured on the transport.
|
|
1495
1499
|
* @param params Optional parameters for the connection, which might include
|
|
1496
1500
|
* things like authentication tokens, initial subscription topics, or a client ID.
|
|
1497
1501
|
* @returns A `PubSubClientStream` instance that represents the active connection.
|
|
1498
1502
|
*/
|
|
1499
|
-
connect: (url: string, params?:
|
|
1503
|
+
connect: (url: string, params?: any) => PubSubClientStream | Promise<PubSubClientStream>;
|
|
1500
1504
|
/**
|
|
1501
1505
|
* Optional. Disconnects a given stream.
|
|
1502
1506
|
* While the `close` method exists on the stream itself, placing `disconnect`
|
|
@@ -1505,6 +1509,13 @@ interface IPubSubClientTransport {
|
|
|
1505
1509
|
* @param stream The stream to disconnect.
|
|
1506
1510
|
*/
|
|
1507
1511
|
disconnect?: (stream: PubSubClientStream) => void;
|
|
1512
|
+
/**
|
|
1513
|
+
* Optional. Configures the transport with a base URL.
|
|
1514
|
+
* If implemented, this allows the transport to resolve relative paths
|
|
1515
|
+
* passed to the `connect` method.
|
|
1516
|
+
* @param apiRoot The base URL for the API.
|
|
1517
|
+
*/
|
|
1518
|
+
setApiRoot?: (apiRoot: string) => void;
|
|
1508
1519
|
}
|
|
1509
1520
|
|
|
1510
1521
|
/**
|
|
@@ -1512,21 +1523,6 @@ interface IPubSubClientTransport {
|
|
|
1512
1523
|
* This ID is used for targeted message publishing.
|
|
1513
1524
|
*/
|
|
1514
1525
|
type PubSubClientId = string;
|
|
1515
|
-
/**
|
|
1516
|
-
* Represents a client as seen by the transport layer after a subscription is made.
|
|
1517
|
-
* It contains the client's ID and can hold other transport-specific metadata.
|
|
1518
|
-
*/
|
|
1519
|
-
interface PubSubClient {
|
|
1520
|
-
/**
|
|
1521
|
-
* The unique identifier for this client.
|
|
1522
|
-
* This can be assigned by the client during connection or generated by the server.
|
|
1523
|
-
*/
|
|
1524
|
-
clientId?: PubSubClientId;
|
|
1525
|
-
/**
|
|
1526
|
-
* Allows for storing additional, transport-specific properties about the client.
|
|
1527
|
-
*/
|
|
1528
|
-
[k: string]: any;
|
|
1529
|
-
}
|
|
1530
1526
|
/**
|
|
1531
1527
|
* Represents an active client connection session on the server.
|
|
1532
1528
|
* This object provides a standardized way for the `EventServer` to interact
|
|
@@ -1581,37 +1577,44 @@ interface IPubSubServerTransport {
|
|
|
1581
1577
|
*/
|
|
1582
1578
|
readonly protocol: 'sse' | 'ws' | 'ipc' | string;
|
|
1583
1579
|
/**
|
|
1584
|
-
*
|
|
1585
|
-
* server or framework. This is typically required for protocols like SSE or
|
|
1586
|
-
* WebSockets that need to handle incoming HTTP requests at a specific path.
|
|
1587
|
-
*
|
|
1588
|
-
* @param path The URL path to handle (e.g., '/api/events').
|
|
1589
|
-
* @param options Additional options for mounting, specific to the framework.
|
|
1590
|
-
*/
|
|
1591
|
-
mount?: (path: string, options?: Record<string, any>) => void;
|
|
1592
|
-
/**
|
|
1593
|
-
* Establishes a connection with a client and subscribes it to an event stream.
|
|
1580
|
+
* Connects a client, establishing a persistent communication channel.
|
|
1594
1581
|
*
|
|
1595
1582
|
* This method is designed to be generic. Transport-specific details, such as
|
|
1596
|
-
* HTTP request/response objects
|
|
1597
|
-
*
|
|
1583
|
+
* HTTP request/response objects, are passed inside the `options` parameter.
|
|
1584
|
+
* For protocols like SSE, initial events can be passed to be subscribed to at connection time.
|
|
1598
1585
|
*
|
|
1599
|
-
* @param
|
|
1600
|
-
* @
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
* @param options.headers HTTP headers from the client request.
|
|
1606
|
-
* @returns A `PubSubClient` object representing the newly connected client.
|
|
1607
|
-
*/
|
|
1608
|
-
subscribe: (events?: string[], options?: {
|
|
1609
|
-
req?: any;
|
|
1610
|
-
res?: any;
|
|
1586
|
+
* @param options A container for transport-specific parameters, including optional initial events.
|
|
1587
|
+
* @returns A `PubSubServerSession` object representing the newly connected client session.
|
|
1588
|
+
*/
|
|
1589
|
+
connect: (options?: {
|
|
1590
|
+
req: any;
|
|
1591
|
+
res: any;
|
|
1611
1592
|
clientId?: PubSubClientId;
|
|
1612
|
-
|
|
1593
|
+
events?: string[];
|
|
1613
1594
|
[k: string]: any;
|
|
1614
|
-
}) =>
|
|
1595
|
+
}) => PubSubServerSession;
|
|
1596
|
+
/**
|
|
1597
|
+
* Subscribes a client session to one or more events.
|
|
1598
|
+
*
|
|
1599
|
+
* Note: Not all transports may support subscribing to new events after the
|
|
1600
|
+
* initial connection. For transports like SSE, this might be a no-op or
|
|
1601
|
+
* throw an error.
|
|
1602
|
+
*
|
|
1603
|
+
* @param session The `PubSubServerSession` of the client.
|
|
1604
|
+
* @param events An array of event names to subscribe to.
|
|
1605
|
+
*/
|
|
1606
|
+
subscribe: (session: PubSubServerSession, events: string[]) => void;
|
|
1607
|
+
/**
|
|
1608
|
+
* Unsubscribes a client session from one or more events.
|
|
1609
|
+
*
|
|
1610
|
+
* Note: Not all transports may support unsubscribing from events after the
|
|
1611
|
+
* initial connection. For transports like SSE, this might be a no-op or
|
|
1612
|
+
* throw an error.
|
|
1613
|
+
*
|
|
1614
|
+
* @param session The `PubSubServerSession` of the client.
|
|
1615
|
+
* @param events An array of event names to unsubscribe from.
|
|
1616
|
+
*/
|
|
1617
|
+
unsubscribe: (session: PubSubServerSession, events: string[]) => void;
|
|
1615
1618
|
/**
|
|
1616
1619
|
* Publishes an event from the server to connected clients.
|
|
1617
1620
|
*
|
|
@@ -1648,6 +1651,14 @@ interface IPubSubServerTransport {
|
|
|
1648
1651
|
* @param cb The callback function that receives the session, event name, data, and context.
|
|
1649
1652
|
*/
|
|
1650
1653
|
onMessage?: (cb: (session: PubSubServerSession, event: string, data: any, ctx?: PubSubCtx) => void) => void;
|
|
1654
|
+
/**
|
|
1655
|
+
* Optional. Finds and returns a session based on a request object.
|
|
1656
|
+
* This is used by higher-level tools to find the correct session
|
|
1657
|
+
* for operations like adding a subscription via a generic RPC call.
|
|
1658
|
+
* @param req The request object (e.g., http.IncomingMessage or Electron.IpcMainEvent).
|
|
1659
|
+
* @returns The corresponding session, or undefined if not found.
|
|
1660
|
+
*/
|
|
1661
|
+
getSessionFromReq?: (req: any) => PubSubServerSession | undefined;
|
|
1651
1662
|
}
|
|
1652
1663
|
|
|
1653
1664
|
interface EventClientFuncParams {
|
|
@@ -1664,20 +1675,21 @@ declare class EventClient extends ResClientTools {
|
|
|
1664
1675
|
_streamEvents: string[] | undefined;
|
|
1665
1676
|
_sseListeners: Record<string, (data: any, ctx?: PubSubCtx) => void>;
|
|
1666
1677
|
_forwardEvents: Set<string>;
|
|
1667
|
-
get
|
|
1678
|
+
get clientId(): string | undefined;
|
|
1679
|
+
getEvtSource(): Promise<PubSubClientStream>;
|
|
1668
1680
|
get active(): boolean;
|
|
1669
|
-
|
|
1681
|
+
setActive(v: boolean): Promise<void>;
|
|
1670
1682
|
description: string;
|
|
1671
|
-
initEventStream(events?: string | string[]): PubSubClientStream
|
|
1683
|
+
initEventStream(events?: string | string[]): Promise<PubSubClientStream>;
|
|
1672
1684
|
esListener(evtType: string, data: any, ctx?: PubSubCtx): void;
|
|
1673
|
-
ebListener: (this: Event, ...
|
|
1685
|
+
ebListener: (this: Event, ...args: any[]) => Promise<void>;
|
|
1674
1686
|
/**
|
|
1675
|
-
* subscribe server
|
|
1687
|
+
* subscribe server event
|
|
1676
1688
|
* @param events
|
|
1677
1689
|
*/
|
|
1678
1690
|
subscribe(events: string | string[]): Promise<any>;
|
|
1679
1691
|
/**
|
|
1680
|
-
* unsubscribe server
|
|
1692
|
+
* unsubscribe server event
|
|
1681
1693
|
* @param events
|
|
1682
1694
|
*/
|
|
1683
1695
|
unsubscribe(events: string | string[]): Promise<any>;
|
|
@@ -1747,12 +1759,19 @@ declare class ResServerTools extends RpcMethodsServerTool {
|
|
|
1747
1759
|
castParams(params: RpcMethodsServerFuncParams): RpcMethodsServerFuncParams;
|
|
1748
1760
|
}
|
|
1749
1761
|
|
|
1762
|
+
declare const ClientEventPrefix = "client:";
|
|
1750
1763
|
interface EventServerFuncParams extends ServerFuncParams {
|
|
1751
1764
|
event?: string | string[];
|
|
1752
1765
|
data?: any;
|
|
1753
1766
|
act?: 'sub' | 'pub' | 'unsub';
|
|
1767
|
+
clientId?: string;
|
|
1754
1768
|
}
|
|
1755
1769
|
declare class EventServer extends ResServerTools {
|
|
1770
|
+
/**
|
|
1771
|
+
* Controls whether the client-published events are auto-emitted on server's localBus.
|
|
1772
|
+
* Defaults to false for security. Must be explicitly enabled for 'client:' prefixed events to be emitted.
|
|
1773
|
+
*/
|
|
1774
|
+
static autoInjectToLocalBus: boolean;
|
|
1756
1775
|
private static _boundEbListener?;
|
|
1757
1776
|
static _pubSubTransport: IPubSubServerTransport | undefined;
|
|
1758
1777
|
static setPubSubTransport(t?: IPubSubServerTransport): void;
|
|
@@ -1763,25 +1782,40 @@ declare class EventServer extends ResServerTools {
|
|
|
1763
1782
|
"event-bus": EventToolFunc;
|
|
1764
1783
|
};
|
|
1765
1784
|
get pubSubTransport(): IPubSubServerTransport | undefined;
|
|
1766
|
-
static publish(
|
|
1785
|
+
static publish(event: string, data: any, target?: {
|
|
1767
1786
|
clientId?: string | string[];
|
|
1768
1787
|
}): void | undefined;
|
|
1769
1788
|
static ebListener(eventType: string, ...data: any[]): void;
|
|
1770
|
-
static subscribe(req: IncomingMessage, res: ServerResponse, events?: string[], options?: any): PubSubClient | undefined;
|
|
1771
1789
|
static alreadyForward(event: string): true | undefined;
|
|
1772
|
-
|
|
1773
|
-
subscribeSSE(req: IncomingMessage, res: ServerResponse, events?: string | string[]): any;
|
|
1790
|
+
publishServerEvent(event: string, data: any): any;
|
|
1774
1791
|
forward(events: string | string[]): void;
|
|
1775
1792
|
unforward(events: string | string[]): void;
|
|
1776
|
-
list({ _req, _res, event }: EventServerFuncParams):
|
|
1777
|
-
$sub({ event }: EventServerFuncParams): {
|
|
1793
|
+
list({ _req, _res, event }: EventServerFuncParams): PubSubServerSession;
|
|
1794
|
+
$sub({ event, _req }: EventServerFuncParams): {
|
|
1795
|
+
forward: boolean;
|
|
1796
|
+
subscribed: boolean;
|
|
1778
1797
|
event: string | string[];
|
|
1798
|
+
clientId: any;
|
|
1799
|
+
} | {
|
|
1800
|
+
forward: boolean;
|
|
1801
|
+
event: string | string[];
|
|
1802
|
+
subscribed?: undefined;
|
|
1803
|
+
clientId?: undefined;
|
|
1779
1804
|
};
|
|
1780
|
-
$unsub({ event }: EventServerFuncParams): {
|
|
1805
|
+
$unsub({ event, _req }: EventServerFuncParams): {
|
|
1806
|
+
forward: boolean;
|
|
1807
|
+
subscribed: boolean;
|
|
1808
|
+
event: string | string[];
|
|
1809
|
+
clientId: any;
|
|
1810
|
+
} | {
|
|
1811
|
+
forward: boolean;
|
|
1781
1812
|
event: string | string[];
|
|
1813
|
+
subscribed?: undefined;
|
|
1814
|
+
clientId?: undefined;
|
|
1782
1815
|
};
|
|
1783
|
-
$publish({ event: events, data }: EventServerFuncParams): {
|
|
1816
|
+
$publish({ event: events, data, _req }: EventServerFuncParams): {
|
|
1784
1817
|
event: string[];
|
|
1818
|
+
senderId: any;
|
|
1785
1819
|
};
|
|
1786
1820
|
isStream(params: ServerFuncParams): boolean;
|
|
1787
1821
|
}
|
|
@@ -1789,4 +1823,4 @@ declare const eventServer: EventServer;
|
|
|
1789
1823
|
|
|
1790
1824
|
declare function registerCoreTools(): void;
|
|
1791
1825
|
|
|
1792
|
-
export { funcGetMeta as $, type AsyncTaskId as A, type BinarySemaphoreOptions as B, ClientToolTransport as C, DefaultAsyncSemaphoreCapacity as D, TaskAbortController as E, type Funcs as F, type TaskAbortControllers as G, type TaskPromise as H, type IPubSubServerTransport as I, CancelableAbility as J, makeToolFuncCancelable as K, type FuncParamType as L, type FuncParam as M, type FuncParams as N, type TFunc as O, type
|
|
1826
|
+
export { funcGetMeta as $, type AsyncTaskId as A, type BinarySemaphoreOptions as B, ClientToolTransport as C, DefaultAsyncSemaphoreCapacity as D, TaskAbortController as E, type Funcs as F, type TaskAbortControllers as G, type TaskPromise as H, type IPubSubServerTransport as I, CancelableAbility as J, makeToolFuncCancelable as K, type FuncParamType as L, type FuncParam as M, type FuncParams as N, type TFunc as O, type PubSubServerSession as P, type BaseFuncItem as Q, RemoteToolFuncSchema as R, ServerTools as S, ToolTransport as T, type FuncItem as U, type BaseFunc as V, type ToolFuncPackage as W, ToolFunc as X, ToolFuncSchema as Y, FuncMetaSymbol as Z, funcWithMeta as _, type AIModelNameRules as a, ClientTools as a0, type ClientFuncItem as a1, ClientToolFuncSchema as a2, type ServerFuncParams as a3, type ServerFuncItem as a4, ServerToolFuncSchema as a5, registerCoreTools as a6, EventToolFunc as a7, event as a8, SecondaryCache as a9, _lrucache as aa, createLRUCache as ab, lrucache as ac, type EventClientFuncParams as ad, EventClient as ae, eventClient as af, ClientEventPrefix as ag, type EventServerFuncParams as ah, EventServer as ai, eventServer as aj, type RpcMethodsClientFuncParams as ak, RpcMethodsClientTool as al, RpcMethodsClientToolSchema as am, type RpcMethodsServerFuncParams as an, RpcMethodsServerTool as ao, RpcMethodsServerToolSchema as ap, type ResClientFuncParams as aq, ResClientTools as ar, type ResServerFuncParams as as, ResServerTools as at, type RpcMethodHandler as au, type IClientToolTransport as av, type PubSubCtx as aw, type PubSubClientId as b, type IPubSubClientTransport as c, type PubSubClientStream as d, type IToolTransport as e, type ActionName as f, PASSING_SCORE as g, ActionNames as h, type AIModelNameRuleFn as i, type AIModelNameRule as j, type RemoteFuncItem as k, type SemaphoreIsReadyFuncType as l, type BinarySemaphoreAcquireOptions as m, type BinarySemaphoreReleaseOptions as n, type BinarySemaphoreReleaserFunc as o, type SemaphoreOptions as p, type SemaphoreTaskItem as q, BinarySemaphore as r, Semaphore as s, RateLimit as t, ToolAsyncMultiTaskBit as u, ToolAsyncCancelableBit as v, ToolAsyncPriorityBit as w, AsyncFeatureBits as x, AsyncFeatures as y, type CancelableAbilityOptions as z };
|