@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.
Files changed (405) hide show
  1. package/dist/chunk-BIJ2JH4U.mjs +1 -0
  2. package/dist/chunk-OYMVHUDZ.mjs +1 -0
  3. package/dist/funcs.d.mts +16 -5
  4. package/dist/funcs.d.ts +16 -5
  5. package/dist/funcs.js +1 -1
  6. package/dist/funcs.mjs +1 -1
  7. package/dist/index.d.mts +839 -563
  8. package/dist/index.d.ts +839 -563
  9. package/dist/index.js +1 -1
  10. package/dist/index.mjs +1 -1
  11. package/dist/test/util.d.mts +1 -1
  12. package/dist/test/util.d.ts +1 -1
  13. package/dist/test/util.js +1 -1
  14. package/dist/test/util.mjs +1 -1
  15. package/docs/api/@isdk/namespaces/ClientTools/README.md +11 -0
  16. package/docs/api/@isdk/namespaces/ClientTools/functions/get.md +27 -0
  17. package/docs/api/@isdk/namespaces/EventStates/variables/ABORT.md +1 -1
  18. package/docs/api/@isdk/namespaces/EventStates/variables/CONTINUE.md +1 -1
  19. package/docs/api/@isdk/namespaces/EventStates/variables/DONE.md +1 -1
  20. package/docs/api/@isdk/namespaces/EventStates/variables/STOPPED.md +1 -1
  21. package/docs/api/classes/BinarySemaphore.md +148 -67
  22. package/docs/api/classes/CancelableAbility.md +95 -43
  23. package/docs/api/classes/ClientToolTransport.md +31 -16
  24. package/docs/api/classes/ClientTools.md +868 -158
  25. package/docs/api/classes/CmdArgLexer.md +82 -0
  26. package/docs/api/classes/CmdArgParser.md +56 -0
  27. package/docs/api/classes/ConfigFile.md +6 -6
  28. package/docs/api/classes/EnvPromptTemplate.md +224 -52
  29. package/docs/api/classes/EventClient.md +902 -192
  30. package/docs/api/classes/EventEmitter.md +62 -12
  31. package/docs/api/classes/EventServer.md +895 -182
  32. package/docs/api/classes/EventToolFunc.md +801 -123
  33. package/docs/api/classes/FStringPromptTemplate.md +224 -52
  34. package/docs/api/classes/FewShotPromptTemplate.md +231 -59
  35. package/docs/api/classes/GolangPromptTemplate.md +224 -52
  36. package/docs/api/classes/HttpClientToolTransport.md +33 -19
  37. package/docs/api/classes/HttpServerToolTransport.md +15 -15
  38. package/docs/api/classes/IntSet.md +21 -21
  39. package/docs/api/classes/MailboxClientTransport.md +398 -0
  40. package/docs/api/classes/MailboxServerTransport.md +433 -0
  41. package/docs/api/classes/PromptExampleSelector.md +11 -11
  42. package/docs/api/classes/PromptTemplate.md +199 -51
  43. package/docs/api/classes/ReadableStreamError.md +2 -2
  44. package/docs/api/classes/ResClientTools.md +875 -165
  45. package/docs/api/classes/ResServerTools.md +869 -156
  46. package/docs/api/classes/RpcMethodsClientTool.md +870 -160
  47. package/docs/api/classes/RpcMethodsServerTool.md +865 -152
  48. package/docs/api/classes/SSEChannel.md +23 -23
  49. package/docs/api/classes/Semaphore.md +148 -76
  50. package/docs/api/classes/ServerToolTransport.md +14 -13
  51. package/docs/api/classes/ServerTools.md +854 -138
  52. package/docs/api/classes/SignalGate.md +12 -12
  53. package/docs/api/classes/SseClientPubSubTransport.md +4 -4
  54. package/docs/api/classes/SseServerPubSubTransport.md +13 -13
  55. package/docs/api/classes/TaskAbortController.md +33 -11
  56. package/docs/api/classes/ToolFunc.md +725 -119
  57. package/docs/api/classes/ToolTransport.md +7 -7
  58. package/docs/api/classes/YamlTypeBaseObject.md +2 -2
  59. package/docs/api/enumerations/AsyncFeatureBits.md +4 -4
  60. package/docs/api/enumerations/AsyncFeatures.md +4 -4
  61. package/docs/api/enumerations/CmdArgTokenType.md +129 -0
  62. package/docs/api/enumerations/HashAlgorithm.md +38 -12
  63. package/docs/api/functions/AIArgProcessor.md +8 -17
  64. package/docs/api/functions/AIStream.md +1 -1
  65. package/docs/api/functions/ChoiceArgProcessor.md +13 -15
  66. package/docs/api/functions/DefaultDateFormat.md +1 -1
  67. package/docs/api/functions/ObjectArgsToArgsInfo.md +11 -9
  68. package/docs/api/functions/RateLimit.md +33 -6
  69. package/docs/api/functions/TemplateArgProcessor.md +13 -15
  70. package/docs/api/functions/assignDirs.md +1 -1
  71. package/docs/api/functions/beforeShutdown.md +3 -3
  72. package/docs/api/functions/calcPerplexity.md +3 -3
  73. package/docs/api/functions/calcPerplexitySimple.md +3 -3
  74. package/docs/api/functions/cmdArgEvaluate.md +28 -0
  75. package/docs/api/functions/cmdArgsToMergedObject.md +34 -0
  76. package/docs/api/functions/completeSentences.md +1 -1
  77. package/docs/api/functions/concatText.md +1 -1
  78. package/docs/api/functions/countLLMTokens.md +1 -1
  79. package/docs/api/functions/countRegexMatches.md +1 -1
  80. package/docs/api/functions/createCallbacksTransformer.md +23 -19
  81. package/docs/api/functions/createEmptyReadableStream.md +1 -1
  82. package/docs/api/functions/createEndWithRepetitionDetector.md +4 -4
  83. package/docs/api/functions/createEventStreamTransformer.md +1 -1
  84. package/docs/api/functions/createHfValueFunc.md +1 -1
  85. package/docs/api/functions/createLRUCache.md +1 -1
  86. package/docs/api/functions/createYamlObjectTag.md +1 -1
  87. package/docs/api/functions/dateToText.md +1 -1
  88. package/docs/api/functions/decodeCharset.md +1 -1
  89. package/docs/api/functions/defaultsWithConcat.md +1 -1
  90. package/docs/api/functions/detectCharset.md +1 -1
  91. package/docs/api/functions/encodeLLMTokens.md +1 -1
  92. package/docs/api/functions/ensureQuoted.md +3 -1
  93. package/docs/api/functions/evaluateExpression.md +40 -0
  94. package/docs/api/functions/eventable.md +1 -1
  95. package/docs/api/functions/expandConfig.md +1 -1
  96. package/docs/api/functions/expandEnv.md +1 -1
  97. package/docs/api/functions/expandObjEnv.md +1 -1
  98. package/docs/api/functions/expandPath.md +1 -1
  99. package/docs/api/functions/expandPathInObject.md +1 -1
  100. package/docs/api/functions/expandPaths.md +1 -1
  101. package/docs/api/functions/extNameLevel.md +1 -1
  102. package/docs/api/functions/extractCodeBlock.md +51 -0
  103. package/docs/api/functions/fileIsExists.md +3 -3
  104. package/docs/api/functions/filterValidFnScope.md +3 -3
  105. package/docs/api/functions/findIndexNonEmptyFrom.md +1 -1
  106. package/docs/api/functions/findPort.md +13 -5
  107. package/docs/api/functions/formatTextWithSpace.md +1 -1
  108. package/docs/api/functions/funcGetMeta.md +1 -1
  109. package/docs/api/functions/funcWithMeta.md +4 -4
  110. package/docs/api/functions/genUrlParamsStr.md +1 -1
  111. package/docs/api/functions/getAllEnumKeys.md +1 -1
  112. package/docs/api/functions/getConfigFileNames.md +1 -1
  113. package/docs/api/functions/getConfigs.md +1 -1
  114. package/docs/api/functions/getEnvVairables.md +1 -1
  115. package/docs/api/functions/getFileMetaInfo.md +1 -1
  116. package/docs/api/functions/getHashAlgoBySize.md +1 -1
  117. package/docs/api/functions/getKeysPath.md +1 -1
  118. package/docs/api/functions/getLLMTokenizer.md +1 -1
  119. package/docs/api/functions/getMultiLevelExtname.md +1 -1
  120. package/docs/api/functions/getPackageDir.md +1 -1
  121. package/docs/api/functions/getRealFilepath.md +1 -1
  122. package/docs/api/functions/getResponseErrorReadableStream.md +2 -2
  123. package/docs/api/functions/getXDGConfigs.md +1 -1
  124. package/docs/api/functions/hasDirectoryIn.md +3 -3
  125. package/docs/api/functions/hash.md +25 -4
  126. package/docs/api/functions/hashFile.md +1 -1
  127. package/docs/api/functions/hashObject.md +23 -1
  128. package/docs/api/functions/hashStream.md +25 -4
  129. package/docs/api/functions/initShutdown.md +1 -1
  130. package/docs/api/functions/isIdentifier.md +30 -0
  131. package/docs/api/functions/isLangUsingSpaces.md +1 -1
  132. package/docs/api/functions/isListItemString.md +3 -3
  133. package/docs/api/functions/isModelNameMatched.md +3 -3
  134. package/docs/api/functions/isPathIdentifier.md +23 -0
  135. package/docs/api/functions/isPunctuationChar.md +1 -1
  136. package/docs/api/functions/isQuoted.md +4 -1
  137. package/docs/api/functions/isRegExp.md +20 -1
  138. package/docs/api/functions/isSameString.md +1 -1
  139. package/docs/api/functions/isSectionString.md +3 -3
  140. package/docs/api/functions/isSentenceEnding.md +1 -1
  141. package/docs/api/functions/isSepLineString.md +3 -3
  142. package/docs/api/functions/isStrWrapped.md +3 -1
  143. package/docs/api/functions/isSubdirectory.md +1 -1
  144. package/docs/api/functions/isTitleString.md +3 -3
  145. package/docs/api/functions/isValidFilename.md +1 -1
  146. package/docs/api/functions/isValidFilepath.md +1 -1
  147. package/docs/api/functions/isWebStream.md +1 -1
  148. package/docs/api/functions/joinSplitWords.md +1 -1
  149. package/docs/api/functions/jsonFilterToWhere.md +1 -1
  150. package/docs/api/functions/jsonToMarkdownStr.md +1 -1
  151. package/docs/api/functions/loadAIConfig.md +1 -1
  152. package/docs/api/functions/loadConfig.md +1 -1
  153. package/docs/api/functions/loadConfigFile.md +1 -1
  154. package/docs/api/functions/loadFileFromPaths.md +1 -1
  155. package/docs/api/functions/loadTextFromPaths.md +1 -1
  156. package/docs/api/functions/lrucache.md +1 -1
  157. package/docs/api/functions/matchUrlProtocol.md +3 -3
  158. package/docs/api/functions/memoize.md +1 -1
  159. package/docs/api/functions/mergeArray.md +1 -1
  160. package/docs/api/functions/messagesToText.md +1 -1
  161. package/docs/api/functions/normalizePath.md +1 -1
  162. package/docs/api/functions/paramsSizeToScaleStr.md +1 -1
  163. package/docs/api/functions/parseCommand.md +21 -4
  164. package/docs/api/functions/parseJsJson.md +1 -1
  165. package/docs/api/functions/parseJsJsonSimpleSync.md +1 -1
  166. package/docs/api/functions/parseObjectArguments.md +17 -33
  167. package/docs/api/functions/parseYaml.md +1 -1
  168. package/docs/api/functions/prependNewlineIfMultiline.md +39 -0
  169. package/docs/api/functions/pruneSubdirectories.md +1 -1
  170. package/docs/api/functions/pruneSubdirectoriesInPlace.md +1 -1
  171. package/docs/api/functions/quoteStr.md +4 -1
  172. package/docs/api/functions/readFilenamesRecursiveSync.md +1 -1
  173. package/docs/api/functions/readTextFileChunks.md +1 -1
  174. package/docs/api/functions/readTextFileChunksEx.md +1 -1
  175. package/docs/api/functions/readableFromAsyncIterable.md +1 -1
  176. package/docs/api/functions/registerCoreTools.md +1 -1
  177. package/docs/api/functions/registerYamlTag.md +2 -2
  178. package/docs/api/functions/removeMarkdownBold.md +1 -1
  179. package/docs/api/functions/removeMarkdownBoldAndItalic.md +1 -1
  180. package/docs/api/functions/removeMarkdownItalic.md +1 -1
  181. package/docs/api/functions/replaceWithPlaceholder.md +3 -18
  182. package/docs/api/functions/restoreFromPlacehoders.md +2 -20
  183. package/docs/api/functions/sanitizeFilename.md +1 -1
  184. package/docs/api/functions/sanitizeFilepath.md +1 -1
  185. package/docs/api/functions/saveConfigFile.md +1 -1
  186. package/docs/api/functions/scaleStrToParamsSize.md +1 -1
  187. package/docs/api/functions/shutdown.md +2 -2
  188. package/docs/api/functions/simplifyObjectArguments.md +4 -1
  189. package/docs/api/functions/simplifyResult.md +34 -0
  190. package/docs/api/functions/sleep.md +1 -1
  191. package/docs/api/functions/sortedValues.md +1 -1
  192. package/docs/api/functions/splitChunks.md +1 -1
  193. package/docs/api/functions/splitParagraph.md +1 -1
  194. package/docs/api/functions/splitSentence.md +1 -1
  195. package/docs/api/functions/splitWords.md +1 -1
  196. package/docs/api/functions/stringifyYaml.md +1 -1
  197. package/docs/api/functions/stripConsoleColor.md +1 -1
  198. package/docs/api/functions/textToDate.md +1 -1
  199. package/docs/api/functions/textify.md +43 -0
  200. package/docs/api/functions/toDateTime.md +3 -3
  201. package/docs/api/functions/toRegExp.md +1 -1
  202. package/docs/api/functions/trimStartOfStreamHelper.md +1 -1
  203. package/docs/api/functions/truncTo.md +1 -1
  204. package/docs/api/functions/truncateByToken.md +1 -1
  205. package/docs/api/functions/truncateToTokenLimit.md +1 -1
  206. package/docs/api/functions/truncateToTokenLimitEx.md +1 -1
  207. package/docs/api/functions/uuid.md +1 -1
  208. package/docs/api/functions/wrapEventEmitter.md +1 -1
  209. package/docs/api/functions/wrapFlagValue.md +29 -0
  210. package/docs/api/functions/xxhash.md +27 -6
  211. package/docs/api/functions/xxhash32.md +22 -4
  212. package/docs/api/functions/xxhash64.md +22 -4
  213. package/docs/api/functions/xxhashAsStr.md +27 -6
  214. package/docs/api/functions/yieldExec.md +1 -1
  215. package/docs/api/globals.md +51 -18
  216. package/docs/api/interfaces/AIChatAssistantMessageParam.md +14 -14
  217. package/docs/api/interfaces/AIChatContentPartBase.md +26 -0
  218. package/docs/api/interfaces/AIChatContentPartImage.md +15 -3
  219. package/docs/api/interfaces/AIChatContentPartText.md +15 -3
  220. package/docs/api/interfaces/AIChatMessageParamBase.md +9 -9
  221. package/docs/api/interfaces/AIChatMessageToolCall.md +12 -8
  222. package/docs/api/interfaces/AIChatSystemMessageParam.md +10 -10
  223. package/docs/api/interfaces/AIChatToolChoiceFuncObject.md +3 -3
  224. package/docs/api/interfaces/AIChatToolChoiceObject.md +2 -2
  225. package/docs/api/interfaces/AIChatToolDefinition.md +45 -0
  226. package/docs/api/interfaces/AIChatToolFunc.md +5 -5
  227. package/docs/api/interfaces/AIChatToolFuncParam.md +3 -3
  228. package/docs/api/interfaces/AIChatToolMessageParam.md +13 -13
  229. package/docs/api/interfaces/AIChatToolParam.md +2 -2
  230. package/docs/api/interfaces/AIChatToolTypeObject.md +2 -2
  231. package/docs/api/interfaces/AIChatUserMessageParam.md +14 -14
  232. package/docs/api/interfaces/AIResult.md +7 -7
  233. package/docs/api/interfaces/AIStreamParser.md +2 -2
  234. package/docs/api/interfaces/AIStreamParserOptions.md +2 -2
  235. package/docs/api/interfaces/BaseFunc.md +15 -15
  236. package/docs/api/interfaces/BaseFuncItem.md +16 -16
  237. package/docs/api/interfaces/BinarySemaphoreAcquireOptions.md +9 -2
  238. package/docs/api/interfaces/BinarySemaphoreOptions.md +22 -5
  239. package/docs/api/interfaces/BinarySemaphoreReleaseOptions.md +7 -5
  240. package/docs/api/interfaces/CancelableAbilityOptions.md +4 -4
  241. package/docs/api/interfaces/ClientFuncItem.md +70 -19
  242. package/docs/api/interfaces/CmdArgAIChoiceConfig.md +97 -0
  243. package/docs/api/interfaces/CmdArgArgsInfo.md +31 -0
  244. package/docs/api/interfaces/CmdArgContext.md +103 -0
  245. package/docs/api/interfaces/CmdArgFlagMetadata.md +21 -0
  246. package/docs/api/interfaces/CmdArgMapResult.md +41 -0
  247. package/docs/api/interfaces/CmdArgParseResult.md +51 -0
  248. package/docs/api/interfaces/CmdArgParsedCommand.md +41 -0
  249. package/docs/api/interfaces/CmdArgParserOptions.md +225 -0
  250. package/docs/api/interfaces/CmdArgProcessorResultOptions.md +22 -0
  251. package/docs/api/interfaces/CmdArgSimplifyOptions.md +101 -0
  252. package/docs/api/interfaces/CmdArgToken.md +51 -0
  253. package/docs/api/interfaces/EventClientFuncParams.md +5 -5
  254. package/docs/api/interfaces/EventServerFuncParams.md +21 -7
  255. package/docs/api/interfaces/FewShotPromptTemplateOptions.md +18 -6
  256. package/docs/api/interfaces/FuncItem.md +19 -15
  257. package/docs/api/interfaces/FuncParam.md +5 -5
  258. package/docs/api/interfaces/FuncParams.md +1 -1
  259. package/docs/api/interfaces/Funcs.md +1 -1
  260. package/docs/api/interfaces/HashAlgoParams.md +36 -5
  261. package/docs/api/interfaces/IClientToolTransport.md +24 -10
  262. package/docs/api/interfaces/IFileMetaInfo.md +8 -8
  263. package/docs/api/interfaces/IPubSubClientTransport.md +4 -4
  264. package/docs/api/interfaces/IPubSubServerTransport.md +14 -14
  265. package/docs/api/interfaces/IReadTextFileChunksOptions.md +11 -11
  266. package/docs/api/interfaces/IServerToolTransport.md +8 -8
  267. package/docs/api/interfaces/IToolTransport.md +5 -5
  268. package/docs/api/interfaces/ITruncateToTokenLimitOptions.md +10 -10
  269. package/docs/api/interfaces/JsonFilter.md +1 -1
  270. package/docs/api/interfaces/MailboxClientOptions.md +74 -0
  271. package/docs/api/interfaces/MailboxServerOptions.md +69 -0
  272. package/docs/api/interfaces/ProbabilityItem.md +4 -4
  273. package/docs/api/interfaces/PromptExampleSelectorOptions.md +3 -3
  274. package/docs/api/interfaces/PromptTemplateOptions.md +8 -0
  275. package/docs/api/interfaces/PubSubClientStream.md +11 -11
  276. package/docs/api/interfaces/PubSubServerSession.md +8 -8
  277. package/docs/api/interfaces/RegisterOptions.md +298 -0
  278. package/docs/api/interfaces/RemoteFuncItem.md +63 -20
  279. package/docs/api/interfaces/ReplacePlacehoderOptions.md +5 -5
  280. package/docs/api/interfaces/ResClientFuncParams.md +3 -3
  281. package/docs/api/interfaces/ResServerFuncParams.md +20 -6
  282. package/docs/api/interfaces/RpcMethodsClientFuncParams.md +2 -2
  283. package/docs/api/interfaces/RpcMethodsServerFuncParams.md +18 -4
  284. package/docs/api/interfaces/SanitizeFilenameOptions.md +3 -3
  285. package/docs/api/interfaces/SectionStringOptions.md +3 -3
  286. package/docs/api/interfaces/SemaphoreOptions.md +30 -7
  287. package/docs/api/interfaces/SemaphoreTaskItem.md +18 -5
  288. package/docs/api/interfaces/ServerFuncItem.md +71 -20
  289. package/docs/api/interfaces/ServerFuncParams.md +14 -4
  290. package/docs/api/interfaces/SplitSentenceOptions.md +5 -5
  291. package/docs/api/interfaces/StreamCallbacksAndOptions.md +80 -7
  292. package/docs/api/interfaces/TaskAbortControllers.md +2 -2
  293. package/docs/api/interfaces/TaskPromise.md +6 -6
  294. package/docs/api/interfaces/TextifyInlineOptions.md +51 -0
  295. package/docs/api/interfaces/TextifyOptions.md +108 -0
  296. package/docs/api/interfaces/ToolFuncContext.md +73 -0
  297. package/docs/api/interfaces/ToolFuncPackage.md +4 -4
  298. package/docs/api/interfaces/ToolFuncRegistryIsolateOptions.md +41 -0
  299. package/docs/api/interfaces/UnregisterOptions.md +56 -0
  300. package/docs/api/type-aliases/AIChatContentPart.md +2 -2
  301. package/docs/api/type-aliases/AIChatMessageParam.md +1 -1
  302. package/docs/api/type-aliases/AIChatRole.md +2 -2
  303. package/docs/api/type-aliases/AIChatTemplateCaps.md +239 -0
  304. package/docs/api/type-aliases/AIChatToolChoiceParam.md +1 -1
  305. package/docs/api/type-aliases/AIMessageType.md +1 -1
  306. package/docs/api/type-aliases/AIModelNameRule.md +1 -1
  307. package/docs/api/type-aliases/AIModelNameRuleFn.md +1 -1
  308. package/docs/api/type-aliases/AIModelNameRules.md +1 -1
  309. package/docs/api/type-aliases/AITextGenerationFinishReason.md +1 -1
  310. package/docs/api/type-aliases/ActionName.md +1 -1
  311. package/docs/api/type-aliases/ArgProcessor.md +24 -0
  312. package/docs/api/type-aliases/ArrayMergeWay.md +1 -1
  313. package/docs/api/type-aliases/AsyncTaskId.md +1 -1
  314. package/docs/api/type-aliases/BeforeShutdownListener.md +1 -1
  315. package/docs/api/type-aliases/CmdArgFlagValue.md +14 -0
  316. package/docs/api/type-aliases/CmdArgFlagsRecord.md +13 -0
  317. package/docs/api/type-aliases/EventErrorListenerFn.md +1 -1
  318. package/docs/api/type-aliases/EventListenerFn.md +1 -1
  319. package/docs/api/type-aliases/FuncParamType.md +1 -1
  320. package/docs/api/type-aliases/PromptExamples.md +1 -1
  321. package/docs/api/type-aliases/PubSubClientId.md +1 -1
  322. package/docs/api/type-aliases/PubSubCtx.md +6 -6
  323. package/docs/api/type-aliases/RpcMethodHandler.md +1 -1
  324. package/docs/api/type-aliases/SSEClient.md +5 -5
  325. package/docs/api/type-aliases/SemaphoreIsReadyFuncType.md +4 -1
  326. package/docs/api/type-aliases/SimplifiedResultType.md +14 -0
  327. package/docs/api/type-aliases/StreamCloseStatus.md +16 -0
  328. package/docs/api/type-aliases/TFunc.md +1 -1
  329. package/docs/api/type-aliases/TextifyInlineStyleMode.md +16 -0
  330. package/docs/api/type-aliases/TextifyStringQuoting.md +16 -0
  331. package/docs/api/type-aliases/UUIDVersions.md +3 -1
  332. package/docs/api/variables/AIChatRoles.md +2 -2
  333. package/docs/api/variables/AIMessageTypes.md +1 -1
  334. package/docs/api/variables/AITextGenerationFinishReasons.md +1 -1
  335. package/docs/api/variables/ActionNames.md +1 -1
  336. package/docs/api/variables/ArrayMergeWay.md +1 -1
  337. package/docs/api/variables/ArrayMergeWaySymbol.md +1 -1
  338. package/docs/api/variables/CMD_ARG_FLAG_SYMBOL.md +21 -0
  339. package/docs/api/variables/CMD_ARG_PROCESSOR_RESULT.md +22 -0
  340. package/docs/api/variables/CMD_ARG_UNRESOLVED_SYMBOL.md +16 -0
  341. package/docs/api/variables/ClientEventPrefix.md +2 -2
  342. package/docs/api/variables/ClientToolFuncSchema.md +27 -17
  343. package/docs/api/variables/DEFAULT_CONFIG_NAME.md +1 -1
  344. package/docs/api/variables/DefaultAsyncSemaphoreCapacity.md +4 -1
  345. package/docs/api/variables/EventBusName.md +2 -2
  346. package/docs/api/variables/EventName.md +2 -2
  347. package/docs/api/variables/FilenameReservedRegex.md +1 -1
  348. package/docs/api/variables/FuncMetaSymbol.md +2 -2
  349. package/docs/api/variables/IDENTIFIER_REGEX.md +14 -0
  350. package/docs/api/variables/LLM_TOKENIZER_NAMES.md +1 -1
  351. package/docs/api/variables/LLM_TOKENIZER_NAMES_MAP.md +1 -1
  352. package/docs/api/variables/PASSING_SCORE.md +1 -1
  353. package/docs/api/variables/PATH_IDENTIFIER_REGEX.md +13 -0
  354. package/docs/api/variables/RESERVED_WORDS.md +13 -0
  355. package/docs/api/variables/RStreamErrCode.md +1 -1
  356. package/docs/api/variables/RemoteToolFuncSchema.md +36 -4
  357. package/docs/api/variables/ResponseRStreamErrCode.md +1 -1
  358. package/docs/api/variables/RpcMethodsClientToolSchema.md +2 -2
  359. package/docs/api/variables/RpcMethodsServerToolSchema.md +2 -2
  360. package/docs/api/variables/SHUTDOWN_SIGNALS.md +1 -1
  361. package/docs/api/variables/SSEChannelAlreadyClosedErrCode.md +1 -1
  362. package/docs/api/variables/SecondaryCache.md +1 -1
  363. package/docs/api/variables/ServerToolFuncSchema.md +27 -17
  364. package/docs/api/variables/StrangeHumanName.md +1 -1
  365. package/docs/api/variables/ToolAsyncCancelableBit.md +1 -1
  366. package/docs/api/variables/ToolAsyncMultiTaskBit.md +1 -1
  367. package/docs/api/variables/ToolAsyncPriorityBit.md +1 -1
  368. package/docs/api/variables/ToolFuncSchema.md +13 -13
  369. package/docs/api/variables/WindowsReservedNameRegex.md +1 -1
  370. package/docs/api/variables/backendEventable.md +23 -3
  371. package/docs/api/variables/base32768.md +2 -2
  372. package/docs/api/variables/event.md +1 -1
  373. package/docs/api/variables/eventClient.md +1 -1
  374. package/docs/api/variables/eventServer.md +1 -1
  375. package/docs/api/variables/lrucache.md +1 -1
  376. package/docs/api/variables/makeToolFuncCancelable.md +23 -3
  377. package/docs/api/variables/wait.md +1 -1
  378. package/docs/transport.dev.md +206 -0
  379. package/package.json +12 -10
  380. package/dist/chunk-4FKBOPZI.mjs +0 -1
  381. package/dist/chunk-TGTHY57V.mjs +0 -1
  382. package/dist/find-port-qS1CZ9c-.d.mts +0 -3
  383. package/dist/find-port-qS1CZ9c-.d.ts +0 -3
  384. package/dist/index-BLW3R7VS.d.mts +0 -1826
  385. package/dist/index-BLW3R7VS.d.ts +0 -1826
  386. package/docs/api/@isdk/namespaces/uuidv5/README.md +0 -12
  387. package/docs/api/@isdk/namespaces/uuidv5/variables/DNS.md +0 -11
  388. package/docs/api/@isdk/namespaces/uuidv5/variables/URL.md +0 -11
  389. package/docs/api/functions/nanoid.md +0 -45
  390. package/docs/api/functions/parseObjectArgInfo.md +0 -33
  391. package/docs/api/functions/parseObjectArgumentInfos.md +0 -29
  392. package/docs/api/functions/parseObjectArgumentsAsArgInfos.md +0 -46
  393. package/docs/api/functions/uuidParse.md +0 -21
  394. package/docs/api/functions/uuidStringify.md +0 -25
  395. package/docs/api/functions/uuidValidate.md +0 -21
  396. package/docs/api/functions/uuidVersion.md +0 -21
  397. package/docs/api/functions/uuidv1.md +0 -61
  398. package/docs/api/functions/uuidv4.md +0 -61
  399. package/docs/api/functions/uuidv5.md +0 -69
  400. package/docs/api/functions/uuidv6.md +0 -61
  401. package/docs/api/functions/uuidv7.md +0 -61
  402. package/docs/api/interfaces/AIChoiceConfig.md +0 -65
  403. package/docs/api/interfaces/BinarySemaphoreReleaserFunc.md +0 -37
  404. package/docs/api/interfaces/ParseObjectArgumentOptions.md +0 -89
  405. package/docs/api/variables/uuidNIL.md +0 -11
package/dist/test/util.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,r=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,o=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,i=(e,r,o,i)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let f of u(r))c.call(e,f)||f===o||t(e,f,{get:()=>r[f],enumerable:!(i=n(r,f))||i.enumerable});return e},f={};function a(e,r){expect(e.length).toBeGreaterThanOrEqual(r.length);for(let t=0;t<r.length;t++)if(e[t]!==r[t])return!1;return!0}((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(f,{compareStr:()=>a,findPort:()=>s,rmFile:()=>m}),module.exports=(e=f,i(t({},"__esModule",{value:!0}),e));var l=((e,n,u)=>(u=null!=e?r(o(e)):{},i(!n&&e&&e.__esModule?u:t(u,"default",{value:e,enumerable:!0}),e)))(require("net"));async function s(e,r=10){return new Promise((t,n)=>{void 0===e?e=0:("string"==typeof e&&(e=parseInt(e)),e>=0||(e=0));const u=l.default.createServer();u.on("error",t=>{"EADDRINUSE"===t.code&&(e++,--r>0)?u.listen(e):n(t)}),u.on("listening",async()=>{const e=u.address().port;u.close(r=>{r?n(r):t(e)})}),u.listen(e)})}var b=require("fs");function m(e){(0,b.existsSync)(e)&&(0,b.rmSync)(e,{recursive:!0}),(0,b.existsSync)(e+".temp")&&(0,b.rmSync)(e+".temp",{recursive:!0})}
1
+ "use strict";var e,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o={};function c(e,r){expect(e.length).toBeGreaterThanOrEqual(r.length);for(let t=0;t<r.length;t++)if(e[t]!==r[t])return!1;return!0}((e,t)=>{for(var u in t)r(e,u,{get:t[u],enumerable:!0})})(o,{compareStr:()=>c,findPort:()=>f.findPort,rmFile:()=>l}),module.exports=(e=o,((e,o,c,f)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let n of u(o))i.call(e,n)||n===c||r(e,n,{get:()=>o[n],enumerable:!(f=t(o,n))||f.enumerable});return e})(r({},"__esModule",{value:!0}),e));var f=require("@isdk/util"),n=require("fs");function l(e){(0,n.existsSync)(e)&&(0,n.rmSync)(e,{recursive:!0}),(0,n.existsSync)(e+".temp")&&(0,n.rmSync)(e+".temp",{recursive:!0})}
@@ -1 +1 @@
1
- import{findPort as r}from"../chunk-TGTHY57V.mjs";function e(r,e){expect(r.length).toBeGreaterThanOrEqual(e.length);for(let t=0;t<e.length;t++)if(r[t]!==e[t])return!1;return!0}import{existsSync as t,rmSync as o}from"fs";function f(r){t(r)&&o(r,{recursive:!0}),t(r+".temp")&&o(r+".temp",{recursive:!0})}export{e as compareStr,r as findPort,f as rmFile};
1
+ import{findPort as r}from"../chunk-BIJ2JH4U.mjs";function e(r,e){expect(r.length).toBeGreaterThanOrEqual(e.length);for(let t=0;t<e.length;t++)if(r[t]!==e[t])return!1;return!0}import{existsSync as t,rmSync as o}from"fs";function f(r){t(r)&&o(r,{recursive:!0}),t(r+".temp")&&o(r+".temp",{recursive:!0})}export{e as compareStr,r as findPort,f as rmFile};
@@ -0,0 +1,11 @@
1
+ [**@isdk/ai-tool**](../../../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/ai-tool](../../../globals.md) / ClientTools
6
+
7
+ # ClientTools
8
+
9
+ ## Functions
10
+
11
+ - [get](functions/get.md)
@@ -0,0 +1,27 @@
1
+ [**@isdk/ai-tool**](../../../../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/ai-tool](../../../../globals.md) / [ClientTools](../README.md) / get
6
+
7
+ # Function: get()
8
+
9
+ > **get**(`name`): [`ClientTools`](../../../../classes/ClientTools.md)
10
+
11
+ Defined in: @isdk/ai-tools/packages/tool-rpc/dist/index-359784IS.d.ts:202
12
+
13
+ Gets a registered `ClientTools` instance by name.
14
+
15
+ ## Parameters
16
+
17
+ ### name
18
+
19
+ `string`
20
+
21
+ The name of the tool function.
22
+
23
+ ## Returns
24
+
25
+ [`ClientTools`](../../../../classes/ClientTools.md)
26
+
27
+ The `ClientTools` instance.
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **ABORT**: `-1`
10
10
 
11
- Defined in: @isdk/ai-tools/node\_modules/.pnpm/events-ex@2.1.0/node\_modules/events-ex/lib/consts.d.ts:11
11
+ Defined in: @isdk/util/node\_modules/.pnpm/events-ex@2.1.1/node\_modules/events-ex/lib/consts.d.ts:11
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **CONTINUE**: `any`
10
10
 
11
- Defined in: @isdk/ai-tools/node\_modules/.pnpm/events-ex@2.1.0/node\_modules/events-ex/lib/consts.d.ts:8
11
+ Defined in: @isdk/util/node\_modules/.pnpm/events-ex@2.1.1/node\_modules/events-ex/lib/consts.d.ts:8
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **DONE**: `1`
10
10
 
11
- Defined in: @isdk/ai-tools/node\_modules/.pnpm/events-ex@2.1.0/node\_modules/events-ex/lib/consts.d.ts:9
11
+ Defined in: @isdk/util/node\_modules/.pnpm/events-ex@2.1.1/node\_modules/events-ex/lib/consts.d.ts:9
@@ -8,4 +8,4 @@
8
8
 
9
9
  > `const` **STOPPED**: `2`
10
10
 
11
- Defined in: @isdk/ai-tools/node\_modules/.pnpm/events-ex@2.1.0/node\_modules/events-ex/lib/consts.d.ts:10
11
+ Defined in: @isdk/util/node\_modules/.pnpm/events-ex@2.1.1/node\_modules/events-ex/lib/consts.d.ts:10
@@ -6,35 +6,26 @@
6
6
 
7
7
  # Class: BinarySemaphore
8
8
 
9
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:88](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L88)
9
+ Defined in: @isdk/util/dist/index.d.ts:746
10
10
 
11
- A binary semaphore implementation for managing concurrency in asynchronous operations.
12
- Unlike a general semaphore, a binary semaphore allows only one caller to acquire the semaphore at a time.
13
- It provides methods to acquire, release, and manage waiting tasks efficiently.
11
+ 二进制信号量(Binary Semaphore)实现。
12
+ 二进制信号量在任何时刻只允许一个调用方获取成功(类似于互斥锁)。
13
+ 它提供了获取(acquire)、释放(release)以及管理等待队列的机制,并支持背压控制(通过 pauseFn/resumeFn)。
14
14
 
15
- Example usage:
15
+ 示例用法:
16
16
 
17
17
  ```typescript
18
- const semaphore = new Semaphore(5); // Allows 5 concurrent operations.
18
+ const semaphore = new BinarySemaphore();
19
19
 
20
- const semaphore = new Semaphore(
21
- 4, // Allow 4 concurrent async calls
22
- {
23
- capacity: 100 // Prealloc space for 100 tokens
24
- }
25
- );
26
-
27
- async function fetchData(x) {
28
- await semaphore.acquire()
20
+ async function performTask(data) {
21
+ const release = await semaphore.acquire();
29
22
  try {
30
- console.log(semaphore.pendingCount + ' calls to fetch are waiting')
31
- // ... do some async stuff with x
23
+ console.log('正在处理:', data);
24
+ // 执行异步操作...
32
25
  } finally {
33
- semaphore.release();
26
+ release(); // 或者使用 semaphore.release();
34
27
  }
35
28
  }
36
-
37
- const data = await Promise.all(array.map(fetchData));
38
29
  ```
39
30
 
40
31
  ## Extended by
@@ -45,29 +36,37 @@ const data = await Promise.all(array.map(fetchData));
45
36
 
46
37
  ### Constructor
47
38
 
48
- > **new BinarySemaphore**(`options`): `BinarySemaphore`
39
+ > **new BinarySemaphore**(`options?`): `BinarySemaphore`
49
40
 
50
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:145](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L145)
41
+ Defined in: @isdk/util/dist/index.d.ts:771
51
42
 
52
- Creates a binary semaphore object for managing concurrency in asynchronous operations.
43
+ 创建一个二进制信号量实例。
53
44
 
54
45
  #### Parameters
55
46
 
56
- ##### options
47
+ ##### options?
48
+
49
+ [`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
57
50
 
58
- [`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md) = `{}`
51
+ 配置选项。
59
52
 
60
53
  #### Returns
61
54
 
62
55
  `BinarySemaphore`
63
56
 
57
+ #### Throws
58
+
59
+ 如果只提供了 pauseFn 而未提供 resumeFn,或者反之,则抛出错误。
60
+
64
61
  ## Properties
65
62
 
66
63
  ### \_activeCount
67
64
 
68
65
  > `protected` **\_activeCount**: `number`
69
66
 
70
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:97](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L97)
67
+ Defined in: @isdk/util/dist/index.d.ts:764
68
+
69
+ 记录当前活跃的(已获取但未释放)操作总数。
71
70
 
72
71
  ***
73
72
 
@@ -75,7 +74,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:97](ht
75
74
 
76
75
  > `protected` **emitter**: [`EventEmitter`](EventEmitter.md)
77
76
 
78
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:91](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L91)
77
+ Defined in: @isdk/util/dist/index.d.ts:752
78
+
79
+ 内部事件触发器,用于协调释放和分发逻辑。
79
80
 
80
81
  ***
81
82
 
@@ -83,7 +84,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:91](ht
83
84
 
84
85
  > `protected` **free**: `any`
85
86
 
86
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:90](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L90)
87
+ Defined in: @isdk/util/dist/index.d.ts:750
88
+
89
+ 当前空闲的令牌。对于二进制信号量,只能持有一个令牌。
87
90
 
88
91
  ***
89
92
 
@@ -91,7 +94,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:90](ht
91
94
 
92
95
  > `protected` **initTokenFn**: (`token?`) => `void`
93
96
 
94
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:95](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L95)
97
+ Defined in: @isdk/util/dist/index.d.ts:760
98
+
99
+ 令牌初始化函数。
95
100
 
96
101
  #### Parameters
97
102
 
@@ -109,7 +114,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:95](ht
109
114
 
110
115
  > `protected` **paused**: `boolean`
111
116
 
112
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:96](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L96)
117
+ Defined in: @isdk/util/dist/index.d.ts:762
118
+
119
+ 记录当前是否处于暂停状态。
113
120
 
114
121
  ***
115
122
 
@@ -117,7 +124,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:96](ht
117
124
 
118
125
  > `protected` `optional` **pauseFn**: () => `void`
119
126
 
120
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:93](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L93)
127
+ Defined in: @isdk/util/dist/index.d.ts:756
128
+
129
+ 获取积压时的暂停回调。
121
130
 
122
131
  #### Returns
123
132
 
@@ -129,7 +138,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:93](ht
129
138
 
130
139
  > `protected` `optional` **resumeFn**: () => `void`
131
140
 
132
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:94](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L94)
141
+ Defined in: @isdk/util/dist/index.d.ts:758
142
+
143
+ 恢复处理的回调。
133
144
 
134
145
  #### Returns
135
146
 
@@ -141,15 +152,19 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:94](ht
141
152
 
142
153
  > `protected` **useDefaultTokens**: `boolean`
143
154
 
144
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:92](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L92)
155
+ Defined in: @isdk/util/dist/index.d.ts:754
156
+
157
+ 标记是否使用默认的令牌初始化函数。
145
158
 
146
159
  ***
147
160
 
148
161
  ### waiting
149
162
 
150
- > `readonly` **waiting**: `Deque`\<`undefined` \| [`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)\>
163
+ > `readonly` **waiting**: `Deque`\<[`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md) \| `undefined`\>
164
+
165
+ Defined in: @isdk/util/dist/index.d.ts:748
151
166
 
152
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:89](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L89)
167
+ 存储等待获取令牌的任务队列。
153
168
 
154
169
  ## Accessors
155
170
 
@@ -159,19 +174,18 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:89](ht
159
174
 
160
175
  > **get** **activeCount**(): `number`
161
176
 
162
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:318](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L318)
177
+ Defined in: @isdk/util/dist/index.d.ts:874
163
178
 
164
- Get the total count of all active operations.
165
-
166
- This method returns the number of operations that are either:
167
- - Waiting in the queue to acquire the semaphore (`pendingCount`).
168
- - Already acquired the semaphore but have not yet released it.
179
+ 获取所有活跃操作的总数。
180
+ 包含:
181
+ - 正在队列中等待获取信号量的操作(`pendingCount`)。
182
+ - 已经成功获取信号量但尚未释放的操作。
169
183
 
170
184
  ##### Returns
171
185
 
172
186
  `number`
173
187
 
174
- The total count of active operations, including both waiting and ongoing tasks.
188
+ 活跃操作的总数。
175
189
 
176
190
  ***
177
191
 
@@ -181,15 +195,15 @@ The total count of active operations, including both waiting and ongoing tasks.
181
195
 
182
196
  > **get** **pendingCount**(): `number`
183
197
 
184
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:327](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L327)
198
+ Defined in: @isdk/util/dist/index.d.ts:880
185
199
 
186
- Get the number of callers waiting on the semaphore, i.e. the number of pending promises.
200
+ 获取当前在等待队列中的调用方数量。
187
201
 
188
202
  ##### Returns
189
203
 
190
204
  `number`
191
205
 
192
- The number of waiters in the waiting list.
206
+ 等待中的 Promise 数量。
193
207
 
194
208
  ## Methods
195
209
 
@@ -197,7 +211,11 @@ The number of waiters in the waiting list.
197
211
 
198
212
  > **\_dispatchTask**(`task`, `options?`): `void`
199
213
 
200
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L212)
214
+ Defined in: @isdk/util/dist/index.d.ts:805
215
+
216
+ **`Internal`**
217
+
218
+ 将令牌分发给等待的任务。
201
219
 
202
220
  #### Parameters
203
221
 
@@ -205,10 +223,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
205
223
 
206
224
  [`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)
207
225
 
226
+ 等待中的任务项。
227
+
208
228
  ##### options?
209
229
 
210
230
  [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
211
231
 
232
+ 释放时传递的选项。
233
+
212
234
  #### Returns
213
235
 
214
236
  `void`
@@ -217,9 +239,14 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:212](h
217
239
 
218
240
  ### \_newReleaser()
219
241
 
220
- > **\_newReleaser**(`options?`): [`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)
242
+ > **\_newReleaser**(`options?`): `BinarySemaphoreReleaserFunc`
221
243
 
222
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L199)
244
+ Defined in: @isdk/util/dist/index.d.ts:797
245
+
246
+ **`Internal`**
247
+
248
+ 创建一个新的释放函数。
249
+ 确保释放逻辑只被执行一次,并携带相关的释放选项。
223
250
 
224
251
  #### Parameters
225
252
 
@@ -227,9 +254,13 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
227
254
 
228
255
  [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
229
256
 
257
+ 释放选项。
258
+
230
259
  #### Returns
231
260
 
232
- [`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)
261
+ `BinarySemaphoreReleaserFunc`
262
+
263
+ 返回一个可调用的释放函数。
233
264
 
234
265
  ***
235
266
 
@@ -237,7 +268,10 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:199](h
237
268
 
238
269
  > **abort**(`reason?`): `void`
239
270
 
240
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L301)
271
+ Defined in: @isdk/util/dist/index.d.ts:865
272
+
273
+ 中止所有正在等待的任务。
274
+ 所有在等待队列中的 Promise 将被拒绝并抛出 `AbortError`。
241
275
 
242
276
  #### Parameters
243
277
 
@@ -245,6 +279,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
245
279
 
246
280
  `any`
247
281
 
282
+ 中止的原因。
283
+
248
284
  #### Returns
249
285
 
250
286
  `void`
@@ -253,11 +289,20 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:301](h
253
289
 
254
290
  ### acquire()
255
291
 
256
- > **acquire**(`options?`): `Promise`\<[`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)\>
292
+ > **acquire**(`options?`): `Promise`\<`BinarySemaphoreReleaserFunc`\>
257
293
 
258
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:243](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L243)
294
+ Defined in: @isdk/util/dist/index.d.ts:842
259
295
 
260
- Acquire a token from the semaphore, thus decrement the number of available execution slots. If initFn is not used then the return value of the function can be discarded.
296
+ 获取信号量。
297
+ 如果信号量当前可用,将立即解析。否则,调用方将被加入等待队列,
298
+ 直到有令牌被释放。
299
+
300
+ 逻辑流程:
301
+ 1. 增加活跃计数。
302
+ 2. 尝试通过 `tryAcquire` 立即获取令牌。
303
+ 3. 如果 `tryAcquire` 返回的是异步结果(通过 `isAsync` 判断),则等待其解析。
304
+ 4. 如果最终未获得令牌,则将任务推入 `waiting` 队列,并处理可选的 `AbortSignal`。
305
+ 5. 如果此时是队列中的第一个任务且定义了 `pauseFn`,则触发暂停回调。
261
306
 
262
307
  #### Parameters
263
308
 
@@ -265,11 +310,13 @@ Acquire a token from the semaphore, thus decrement the number of available execu
265
310
 
266
311
  [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
267
312
 
313
+ 获取选项,可包含 `signal` 用于取消。
314
+
268
315
  #### Returns
269
316
 
270
- `Promise`\<[`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)\>
317
+ `Promise`\<`BinarySemaphoreReleaserFunc`\>
271
318
 
272
- A promise that resolves to a release function when a token is acquired. If the semaphore is full, the caller will be added to a waiting queue.
319
+ 解析为释放函数(`BinarySemaphoreReleaserFunc`)的 Promise。
273
320
 
274
321
  ***
275
322
 
@@ -277,21 +324,27 @@ A promise that resolves to a release function when a token is acquired. If the s
277
324
 
278
325
  > **drain**(): `Promise`\<`any`[]\>
279
326
 
280
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:296](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L296)
327
+ Defined in: @isdk/util/dist/index.d.ts:858
281
328
 
282
- Drains the semaphore and returns all the initialized tokens in an array. Draining is an ideal way to ensure there are no pending async tasks, for example before a process will terminate.
329
+ 等待所有当前活跃的操作完成。
330
+ 它通过尝试获取一次信号量来确保之前的操作已经释放。
331
+ 在进程终止前使用此方法以确保没有挂起的异步任务。
283
332
 
284
333
  #### Returns
285
334
 
286
335
  `Promise`\<`any`[]\>
287
336
 
337
+ 解析为包含已获取令牌的数组的 Promise。
338
+
288
339
  ***
289
340
 
290
341
  ### init()
291
342
 
292
343
  > **init**(`options`): `void`
293
344
 
294
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L193)
345
+ Defined in: @isdk/util/dist/index.d.ts:788
346
+
347
+ 初始化事件监听。在构造函数中被调用。
295
348
 
296
349
  #### Parameters
297
350
 
@@ -299,6 +352,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
299
352
 
300
353
  [`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
301
354
 
355
+ 配置选项。
356
+
302
357
  #### Returns
303
358
 
304
359
  `void`
@@ -309,7 +364,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:193](h
309
364
 
310
365
  > **initFree**(`options?`): `void`
311
366
 
312
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:173](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L173)
367
+ Defined in: @isdk/util/dist/index.d.ts:776
368
+
369
+ 初始化空闲令牌。在构造函数中被调用。
313
370
 
314
371
  #### Parameters
315
372
 
@@ -317,6 +374,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:173](h
317
374
 
318
375
  [`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
319
376
 
377
+ 配置选项。
378
+
320
379
  #### Returns
321
380
 
322
381
  `void`
@@ -327,7 +386,9 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:173](h
327
386
 
328
387
  > **lock**(`options?`): `any`
329
388
 
330
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:217](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L217)
389
+ Defined in: @isdk/util/dist/index.d.ts:812
390
+
391
+ 锁定信号量。尝试从空闲池中提取令牌。
331
392
 
332
393
  #### Parameters
333
394
 
@@ -335,17 +396,24 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:217](h
335
396
 
336
397
  [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
337
398
 
399
+ 获取选项。
400
+
338
401
  #### Returns
339
402
 
340
403
  `any`
341
404
 
405
+ 如果有可用令牌则返回该令牌,否则返回 undefined。
406
+
342
407
  ***
343
408
 
344
409
  ### onReleased()
345
410
 
346
411
  > **onReleased**(`options?`): `void`
347
412
 
348
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L177)
413
+ Defined in: @isdk/util/dist/index.d.ts:783
414
+
415
+ 当信号量被释放时执行的内部处理逻辑。
416
+ 检查等待队列,如果有任务则分发令牌;否则将令牌归还至空闲池,并视情况调用 `resumeFn`。
349
417
 
350
418
  #### Parameters
351
419
 
@@ -353,6 +421,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
353
421
 
354
422
  [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
355
423
 
424
+ 释放选项,可能包含令牌。
425
+
356
426
  #### Returns
357
427
 
358
428
  `void`
@@ -363,9 +433,11 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:177](h
363
433
 
364
434
  > **release**(`options?`): `void`
365
435
 
366
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:288](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L288)
436
+ Defined in: @isdk/util/dist/index.d.ts:850
367
437
 
368
- Releases the semaphore, incrementing the number of free execution slots. If there are tasks in the waiting queue, the next task will be dispatched.
438
+ 释放信号量,增加可用执行槽位。
439
+ 如果等待队列中有任务,将触发下一个任务的执行。
440
+ 此方法会减少 `activeCount` 并发出 'release' 事件。
369
441
 
370
442
  #### Parameters
371
443
 
@@ -373,6 +445,8 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
373
445
 
374
446
  [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
375
447
 
448
+ 释放选项。
449
+
376
450
  #### Returns
377
451
 
378
452
  `void`
@@ -383,9 +457,10 @@ Releases the semaphore, incrementing the number of free execution slots. If ther
383
457
 
384
458
  > **tryAcquire**(`options?`): `any`
385
459
 
386
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:234](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L234)
460
+ Defined in: @isdk/util/dist/index.d.ts:826
387
461
 
388
- Attempt to acquire a token from the semaphore, if one is available immediately. Otherwise, return undefined.
462
+ 尝试立即获取令牌。
463
+ 如果信号量当前不可用,则立即返回 `undefined` 而不进入等待队列。
389
464
 
390
465
  #### Parameters
391
466
 
@@ -393,11 +468,13 @@ Attempt to acquire a token from the semaphore, if one is available immediately.
393
468
 
394
469
  [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
395
470
 
471
+ 获取选项。
472
+
396
473
  #### Returns
397
474
 
398
475
  `any`
399
476
 
400
- Returns a token if the semaphore is not full; otherwise, returns `undefined`.
477
+ 如果获取成功则返回令牌,否则返回 `undefined`。
401
478
 
402
479
  ***
403
480
 
@@ -405,7 +482,9 @@ Returns a token if the semaphore is not full; otherwise, returns `undefined`.
405
482
 
406
483
  > **unlock**(`token?`): `void`
407
484
 
408
- Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:225](https://github.com/isdk/ai-tool.js/blob/e883e341c67e937e7d3a3e95e8bc56844896f5a3/src/utils/async-semaphore.ts#L225)
485
+ Defined in: @isdk/util/dist/index.d.ts:818
486
+
487
+ 解锁信号量。将令牌归还至空闲池。
409
488
 
410
489
  #### Parameters
411
490
 
@@ -413,6 +492,8 @@ Defined in: [@isdk/ai-tools/packages/ai-tool/src/utils/async-semaphore.ts:225](h
413
492
 
414
493
  `any`
415
494
 
495
+ 要归还的令牌。如果未提供,则使用初始化函数生成。
496
+
416
497
  #### Returns
417
498
 
418
499
  `void`