@isdk/ai-tool 0.2.0 → 0.2.1

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 (248) hide show
  1. package/dist/chunk-TOUPOZHH.mjs +1 -0
  2. package/dist/funcs.d.mts +1 -1
  3. package/dist/funcs.d.ts +1 -1
  4. package/dist/funcs.js +1 -1
  5. package/dist/funcs.mjs +1 -1
  6. package/dist/{index-nP9lSU6E.d.mts → index-DUEs7T8M.d.mts} +2 -2
  7. package/dist/{index-nP9lSU6E.d.ts → index-DUEs7T8M.d.ts} +2 -2
  8. package/dist/index.d.mts +3 -3
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +1 -1
  11. package/dist/index.mjs +1 -1
  12. package/docs/README.md +5 -3
  13. package/docs/_media/CONTRIBUTING.md +18 -0
  14. package/docs/_media/LICENSE-MIT +22 -0
  15. package/docs/classes/AbortError.md +108 -129
  16. package/docs/classes/AlreadyExistsError.md +105 -126
  17. package/docs/classes/BaseError.md +112 -125
  18. package/docs/classes/CancelableAbility.md +136 -188
  19. package/docs/classes/ClientTools.md +1005 -1107
  20. package/docs/classes/CommonError.md +115 -136
  21. package/docs/classes/ConfigFile.md +150 -163
  22. package/docs/classes/EventClient.md +1128 -1282
  23. package/docs/classes/EventServer.md +1165 -1303
  24. package/docs/classes/EventToolFunc.md +958 -1028
  25. package/docs/classes/FStringPromptTemplate.md +352 -438
  26. package/docs/classes/FewShotPromptTemplate.md +364 -464
  27. package/docs/classes/GolangPromptTemplate.md +352 -438
  28. package/docs/classes/HFEnvironment.md +53 -79
  29. package/docs/classes/HFInterpreter.md +20 -377
  30. package/docs/classes/HFTemplate.md +21 -33
  31. package/docs/classes/HfPromptTemplate.md +352 -438
  32. package/docs/classes/IntSet.md +67 -100
  33. package/docs/classes/NotFoundError.md +105 -126
  34. package/docs/classes/NotImplementationError.md +105 -126
  35. package/docs/classes/PromptExampleSelector.md +58 -70
  36. package/docs/classes/PromptTemplate.md +338 -422
  37. package/docs/classes/ReadableStreamError.md +108 -129
  38. package/docs/classes/ResClientTools.md +916 -1026
  39. package/docs/classes/ResServerTools.md +919 -1026
  40. package/docs/classes/SSEChannel.md +93 -112
  41. package/docs/classes/Semaphore.md +44 -140
  42. package/docs/classes/ServerTools.md +981 -1072
  43. package/docs/classes/TaskAbortController.md +46 -66
  44. package/docs/classes/ToolFunc.md +840 -910
  45. package/docs/enumerations/AsyncFeatureBits.md +37 -0
  46. package/docs/enumerations/AsyncFeatures.md +37 -0
  47. package/docs/enumerations/ErrorCode.md +217 -0
  48. package/docs/enumerations/XXHashAlgorithm.md +27 -0
  49. package/docs/functions/AIArgProcessor.md +27 -0
  50. package/docs/functions/AIStream.md +50 -0
  51. package/docs/functions/ChoiceArgProcessor.md +27 -0
  52. package/docs/functions/RateLimit.md +33 -0
  53. package/docs/functions/TemplateArgProcessor.md +27 -0
  54. package/docs/functions/backendEventable.md +23 -0
  55. package/docs/functions/canonicalize.md +21 -0
  56. package/docs/functions/countRegexMatches.md +33 -0
  57. package/docs/functions/createAbilityInjector.md +87 -0
  58. package/docs/functions/createCallbacksTransformer.md +49 -0
  59. package/docs/functions/createEmptyReadableStream.md +23 -0
  60. package/docs/functions/createEndWithRepetitionDetector.md +29 -0
  61. package/docs/functions/createError.md +35 -0
  62. package/docs/functions/createEventStreamTransformer.md +33 -0
  63. package/docs/functions/createHfValueFunc.md +29 -0
  64. package/docs/functions/createLRUCache.md +23 -0
  65. package/docs/functions/dateToText.md +23 -0
  66. package/docs/functions/expandEnv.md +40 -0
  67. package/docs/functions/expandObjEnv.md +54 -0
  68. package/docs/functions/extNameLevel.md +43 -0
  69. package/docs/functions/fileIsExists.md +34 -0
  70. package/docs/functions/filenameReservedRegex.md +22 -0
  71. package/docs/functions/filterValidFnScope.md +21 -0
  72. package/docs/functions/findPort.md +23 -0
  73. package/docs/functions/formatISO.md +71 -0
  74. package/docs/functions/getAllEnumKeys.md +31 -0
  75. package/docs/functions/getConfigFileNames.md +23 -0
  76. package/docs/functions/getConfigs.md +23 -0
  77. package/docs/functions/getKeysPath.md +38 -0
  78. package/docs/functions/getMultiLevelExtname.md +31 -0
  79. package/docs/functions/getPackageDir.md +39 -0
  80. package/docs/functions/getRealFilepath.md +34 -0
  81. package/docs/functions/getResponseErrorReadableStream.md +21 -0
  82. package/docs/functions/hfParse.md +24 -0
  83. package/docs/functions/hfTokenize.md +25 -0
  84. package/docs/functions/interpolateEnv.md +25 -0
  85. package/docs/functions/interpolateFString.md +27 -0
  86. package/docs/functions/interpolateGolangTemplate.md +31 -0
  87. package/docs/functions/isModelNameMatched.md +45 -0
  88. package/docs/functions/isValidFilename.md +38 -0
  89. package/docs/functions/isValidFilepath.md +27 -0
  90. package/docs/functions/isWebStream.md +21 -0
  91. package/docs/functions/jsonFilterToWhere.md +45 -0
  92. package/docs/functions/jsonToMarkdownStr.md +31 -0
  93. package/docs/functions/loadFileFromPaths.md +54 -0
  94. package/docs/functions/loadTextFromPaths.md +29 -0
  95. package/docs/functions/lrucache.md +29 -0
  96. package/docs/functions/makeToolFuncCancelable.md +23 -0
  97. package/docs/functions/matchUrlProtocol.md +48 -0
  98. package/docs/functions/memoize.md +27 -0
  99. package/docs/functions/messagesToText.md +21 -0
  100. package/docs/functions/paramsSizeToScaleStr.md +32 -0
  101. package/docs/functions/parseCommand.md +33 -0
  102. package/docs/functions/parseDateFormat.md +360 -0
  103. package/docs/functions/parseFString.md +26 -0
  104. package/docs/functions/parseISO.md +72 -0
  105. package/docs/functions/parseJsJson.md +38 -0
  106. package/docs/functions/parseObjectArgInfo.md +27 -0
  107. package/docs/functions/parseObjectArgumentInfos.md +25 -0
  108. package/docs/functions/parseObjectArguments.md +68 -0
  109. package/docs/functions/parseObjectArgumentsAsArgInfos.md +42 -0
  110. package/docs/functions/parseYaml.md +21 -0
  111. package/docs/functions/quoteStr.md +21 -0
  112. package/docs/functions/reControlCharsRegex.md +21 -0
  113. package/docs/functions/readFilenamesRecursiveSync.md +47 -0
  114. package/docs/functions/readableFromAsyncIterable.md +28 -0
  115. package/docs/functions/registerCoreTools.md +17 -0
  116. package/docs/functions/registerYamlTag.md +21 -0
  117. package/docs/functions/sanitizeFilename.md +37 -0
  118. package/docs/functions/sanitizeFilepath.md +31 -0
  119. package/docs/functions/saveConfigFile.md +25 -0
  120. package/docs/functions/scaleStrToParamsSize.md +27 -0
  121. package/docs/functions/simplifyObjectArguments.md +21 -0
  122. package/docs/functions/sortedValues.md +25 -0
  123. package/docs/functions/splitSentence.md +37 -0
  124. package/docs/functions/stringifyYaml.md +49 -0
  125. package/docs/functions/textToDate.md +23 -0
  126. package/docs/functions/throwError.md +37 -0
  127. package/docs/functions/toDate.md +76 -0
  128. package/docs/functions/toDateTime.md +21 -0
  129. package/docs/functions/trimStartOfStreamHelper.md +41 -0
  130. package/docs/functions/truncTo.md +47 -0
  131. package/docs/functions/uuid.md +23 -0
  132. package/docs/functions/uuidParse.md +21 -0
  133. package/docs/functions/uuidStringify.md +23 -0
  134. package/docs/functions/uuidValidate.md +21 -0
  135. package/docs/functions/uuidVersion.md +21 -0
  136. package/docs/functions/uuidv1.md +47 -0
  137. package/docs/functions/uuidv4.md +47 -0
  138. package/docs/functions/uuidv5.md +51 -0
  139. package/docs/functions/wait.md +21 -0
  140. package/docs/functions/xxhash.md +25 -0
  141. package/docs/functions/xxhash32.md +23 -0
  142. package/docs/functions/xxhash64.md +23 -0
  143. package/docs/functions/xxhashAsStr.md +25 -0
  144. package/docs/globals.md +236 -0
  145. package/docs/interfaces/AIChatAssistantMessageParam.md +29 -38
  146. package/docs/interfaces/AIChatContentPartImage.md +11 -16
  147. package/docs/interfaces/AIChatContentPartText.md +9 -12
  148. package/docs/interfaces/AIChatMessageParamBase.md +12 -19
  149. package/docs/interfaces/AIChatMessageToolCall.md +18 -21
  150. package/docs/interfaces/AIChatSystemMessageParam.md +16 -22
  151. package/docs/interfaces/AIChatToolMessageParam.md +19 -26
  152. package/docs/interfaces/AIChatUserMessageParam.md +32 -42
  153. package/docs/interfaces/AIChoiceConfig.md +31 -39
  154. package/docs/interfaces/AIResult.md +26 -33
  155. package/docs/interfaces/AIStreamParser.md +24 -18
  156. package/docs/interfaces/AIStreamParserOptions.md +8 -10
  157. package/docs/interfaces/BaseFunc.md +55 -75
  158. package/docs/interfaces/BaseFuncItem.md +43 -61
  159. package/docs/interfaces/CancelableAbilityOptions.md +43 -54
  160. package/docs/interfaces/ClientFuncItem.md +66 -83
  161. package/docs/interfaces/DotenvExpandOptions.md +15 -19
  162. package/docs/interfaces/DotenvExpandOutput.md +11 -14
  163. package/docs/interfaces/DotenvParseInput.md +6 -2
  164. package/docs/interfaces/DotenvParseOutput.md +6 -2
  165. package/docs/interfaces/DotenvPopulateInput.md +6 -2
  166. package/docs/interfaces/EventClientFuncParams.md +22 -33
  167. package/docs/interfaces/EventServerFuncParams.md +27 -35
  168. package/docs/interfaces/FewShotPromptTemplateOptions.md +58 -74
  169. package/docs/interfaces/FuncItem.md +53 -70
  170. package/docs/interfaces/FuncParam.md +29 -36
  171. package/docs/interfaces/FuncParams.md +6 -2
  172. package/docs/interfaces/Funcs.md +6 -2
  173. package/docs/interfaces/JsonFilter.md +6 -2
  174. package/docs/interfaces/ParseObjectArgumentOptions.md +23 -29
  175. package/docs/interfaces/PromptExampleSelectorOptions.md +13 -16
  176. package/docs/interfaces/PromptTemplateOptions.md +31 -40
  177. package/docs/interfaces/RemoteFuncItem.md +64 -82
  178. package/docs/interfaces/ResClientFuncParams.md +14 -19
  179. package/docs/interfaces/ResServerFuncParams.md +28 -36
  180. package/docs/interfaces/SanitizeFilenameOptions.md +11 -14
  181. package/docs/interfaces/ServerFuncItem.md +70 -88
  182. package/docs/interfaces/ServerFuncParams.md +15 -20
  183. package/docs/interfaces/StreamCallbacksAndOptions.md +36 -65
  184. package/docs/interfaces/TaskAbortControllers.md +6 -2
  185. package/docs/interfaces/TaskPromise.md +48 -61
  186. package/docs/interfaces/ToolFuncPackage.md +18 -32
  187. package/docs/type-aliases/AIChatContentPart.md +13 -0
  188. package/docs/type-aliases/AIChatMessageParam.md +13 -0
  189. package/docs/type-aliases/AIChatRole.md +13 -0
  190. package/docs/type-aliases/AIMessageType.md +13 -0
  191. package/docs/type-aliases/AIModelNameRule.md +13 -0
  192. package/docs/type-aliases/AIModelNameRuleFn.md +21 -0
  193. package/docs/type-aliases/AIModelNameRules.md +13 -0
  194. package/docs/type-aliases/AITextGenerationFinishReason.md +13 -0
  195. package/docs/type-aliases/ActionName.md +13 -0
  196. package/docs/type-aliases/AsyncTaskId.md +13 -0
  197. package/docs/type-aliases/EventErrorListenerFn.md +27 -0
  198. package/docs/type-aliases/EventListenerFn.md +25 -0
  199. package/docs/type-aliases/FStringPromptTemplateNode.md +16 -0
  200. package/docs/type-aliases/FuncParamType.md +13 -0
  201. package/docs/type-aliases/PromptExamples.md +17 -0
  202. package/docs/type-aliases/PromptTemplateType.md +13 -0
  203. package/docs/type-aliases/PromptType.md +13 -0
  204. package/docs/type-aliases/TFunc.md +23 -0
  205. package/docs/variables/AIChatRoles.md +13 -0
  206. package/docs/variables/AIMessageTypes.md +13 -0
  207. package/docs/variables/AITextGenerationFinishReasons.md +13 -0
  208. package/docs/variables/AbortErrorCode.md +13 -0
  209. package/docs/variables/ActionNames.md +13 -0
  210. package/docs/variables/AlreadyExistsErrorCode.md +13 -0
  211. package/docs/variables/ClientToolFuncSchema.md +87 -0
  212. package/docs/variables/DefaultAsyncSemaphoreCapacity.md +13 -0
  213. package/docs/variables/EventBusName.md +13 -0
  214. package/docs/variables/EventName.md +13 -0
  215. package/docs/variables/FilenameReservedRegex.md +16 -0
  216. package/docs/variables/HFBuiltins.md +92 -0
  217. package/docs/variables/InternalErrorCode.md +13 -0
  218. package/docs/variables/NotFoundErrorCode.md +13 -0
  219. package/docs/variables/NotImplementedErrorCode.md +13 -0
  220. package/docs/variables/PASSING_SCORE.md +13 -0
  221. package/docs/variables/PromptTemplateTypes.md +13 -0
  222. package/docs/variables/PromptTypes.md +16 -0
  223. package/docs/variables/RStreamErrCode.md +13 -0
  224. package/docs/variables/RemoteToolFuncSchema.md +87 -0
  225. package/docs/variables/ResponseRStreamErrCode.md +13 -0
  226. package/docs/variables/SSEChannelAlreadyClosedErrCode.md +13 -0
  227. package/docs/variables/ServerToolFuncSchema.md +87 -0
  228. package/docs/variables/ToolAsyncCancelableBit.md +13 -0
  229. package/docs/variables/ToolAsyncMultiTaskBit.md +13 -0
  230. package/docs/variables/ToolAsyncPriorityBit.md +13 -0
  231. package/docs/variables/ToolFuncSchema.md +125 -0
  232. package/docs/variables/WindowsReservedNameRegex.md +15 -0
  233. package/docs/variables/base32768.md +13 -0
  234. package/docs/variables/defaultTemplateFormat.md +13 -0
  235. package/docs/variables/event.md +13 -0
  236. package/docs/variables/eventClient.md +13 -0
  237. package/docs/variables/eventServer.md +13 -0
  238. package/docs/variables/lrucache.md +13 -0
  239. package/docs/variables/mimeType.md +13 -0
  240. package/docs/variables/uuidNIL.md +13 -0
  241. package/package.json +26 -27
  242. package/dist/chunk-W2LO3HZT.mjs +0 -1
  243. package/docs/.nojekyll +0 -1
  244. package/docs/enums/AsyncFeatureBits.md +0 -41
  245. package/docs/enums/AsyncFeatures.md +0 -41
  246. package/docs/enums/ErrorCode.md +0 -239
  247. package/docs/enums/XXHashAlgorithm.md +0 -30
  248. package/docs/modules.md +0 -4062
@@ -1,57 +1,33 @@
1
- [@isdk/ai-tool](../README.md) / [Exports](../modules.md) / SSEChannel
1
+ [**@isdk/ai-tool**](../README.md) **Docs**
2
+
3
+ ***
4
+
5
+ [@isdk/ai-tool](../globals.md) / SSEChannel
2
6
 
3
7
  # Class: SSEChannel
4
8
 
5
9
  A class for creating Server-Sent Events (SSE) channels.
6
10
 
7
- **`Example`**
11
+ ## Example
8
12
 
9
13
  ```ts
10
14
  const sseChannel = new SSEChannel({ pingInterval: 5000 })
11
15
  sseChannel.publish('Hello, world!', 'greeting')
12
16
  ```
13
17
 
14
- ## Table of contents
15
-
16
- ### Constructors
17
-
18
- - [constructor](SSEChannel.md#constructor)
19
-
20
- ### Properties
21
-
22
- - [\_active](SSEChannel.md#_active)
23
- - [clients](SSEChannel.md#clients)
24
- - [messages](SSEChannel.md#messages)
25
- - [nextID](SSEChannel.md#nextid)
26
- - [options](SSEChannel.md#options)
27
- - [pingTimer](SSEChannel.md#pingtimer)
28
-
29
- ### Accessors
30
-
31
- - [active](SSEChannel.md#active)
32
-
33
- ### Methods
34
-
35
- - [clearClients](SSEChannel.md#clearclients)
36
- - [getSubscriberCount](SSEChannel.md#getsubscribercount)
37
- - [listClients](SSEChannel.md#listclients)
38
- - [publish](SSEChannel.md#publish)
39
- - [subscribe](SSEChannel.md#subscribe)
40
- - [unsubscribe](SSEChannel.md#unsubscribe)
41
-
42
18
  ## Constructors
43
19
 
44
- ### constructor
20
+ ### new SSEChannel()
45
21
 
46
- **new SSEChannel**(`options?`): [`SSEChannel`](SSEChannel.md)
22
+ > **new SSEChannel**(`options`?): [`SSEChannel`](SSEChannel.md)
47
23
 
48
24
  Creates a new SSE channel.
49
25
 
50
26
  #### Parameters
51
27
 
52
- | Name | Type | Description |
53
- | :------ | :------ | :------ |
54
- | `options?` | `Record`\<`string`, `any`\> | The options for the SSE channel. |
28
+ **options?**: `Record`\<`string`, `any`\>
29
+
30
+ The options for the SSE channel.
55
31
 
56
32
  #### Returns
57
33
 
@@ -59,103 +35,93 @@ Creates a new SSE channel.
59
35
 
60
36
  #### Defined in
61
37
 
62
- [packages/ai-tool/src/utils/event/sse-channel.ts:65](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L65)
38
+ [packages/ai-tool/src/utils/event/sse-channel.ts:65](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L65)
63
39
 
64
40
  ## Properties
65
41
 
66
42
  ### \_active
67
43
 
68
- **\_active**: `boolean`
44
+ > **\_active**: `boolean`
69
45
 
70
46
  #### Defined in
71
47
 
72
- [packages/ai-tool/src/utils/event/sse-channel.ts:26](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L26)
48
+ [packages/ai-tool/src/utils/event/sse-channel.ts:26](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L26)
73
49
 
74
- ___
50
+ ***
75
51
 
76
52
  ### clients
77
53
 
78
- **clients**: `Set`\<`Client`\>
54
+ > **clients**: `Set`\<`Client`\>
79
55
 
80
56
  #### Defined in
81
57
 
82
- [packages/ai-tool/src/utils/event/sse-channel.ts:27](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L27)
58
+ [packages/ai-tool/src/utils/event/sse-channel.ts:27](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L27)
83
59
 
84
- ___
60
+ ***
85
61
 
86
62
  ### messages
87
63
 
88
- **messages**: `Record`\<`string`, `any`\>[]
64
+ > **messages**: `Record`\<`string`, `any`\>[]
89
65
 
90
66
  #### Defined in
91
67
 
92
- [packages/ai-tool/src/utils/event/sse-channel.ts:28](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L28)
68
+ [packages/ai-tool/src/utils/event/sse-channel.ts:28](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L28)
93
69
 
94
- ___
70
+ ***
95
71
 
96
72
  ### nextID
97
73
 
98
- **nextID**: `number`
74
+ > **nextID**: `number`
99
75
 
100
76
  #### Defined in
101
77
 
102
- [packages/ai-tool/src/utils/event/sse-channel.ts:29](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L29)
78
+ [packages/ai-tool/src/utils/event/sse-channel.ts:29](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L29)
103
79
 
104
- ___
80
+ ***
105
81
 
106
82
  ### options
107
83
 
108
- **options**: `Record`\<`string`, `any`\>
84
+ > **options**: `Record`\<`string`, `any`\>
109
85
 
110
86
  #### Defined in
111
87
 
112
- [packages/ai-tool/src/utils/event/sse-channel.ts:30](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L30)
88
+ [packages/ai-tool/src/utils/event/sse-channel.ts:30](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L30)
113
89
 
114
- ___
90
+ ***
115
91
 
116
- ### pingTimer
92
+ ### pingTimer?
117
93
 
118
- `Optional` **pingTimer**: `Timeout`
94
+ > `optional` **pingTimer**: `Timeout`
119
95
 
120
96
  #### Defined in
121
97
 
122
- [packages/ai-tool/src/utils/event/sse-channel.ts:31](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L31)
98
+ [packages/ai-tool/src/utils/event/sse-channel.ts:31](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L31)
123
99
 
124
100
  ## Accessors
125
101
 
126
102
  ### active
127
103
 
128
- `get` **active**(): `boolean`
129
-
130
- #### Returns
131
-
132
- `boolean`
133
-
134
- #### Defined in
104
+ > `get` **active**(): `boolean`
135
105
 
136
- [packages/ai-tool/src/utils/event/sse-channel.ts:33](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L33)
137
-
138
- • `set` **active**(`v`): `void`
106
+ > `set` **active**(`v`): `void`
139
107
 
140
108
  #### Parameters
141
109
 
142
- | Name | Type |
143
- | :------ | :------ |
144
- | `v` | `boolean` |
110
+ **v**: `boolean`
145
111
 
146
112
  #### Returns
147
113
 
148
- `void`
114
+ `boolean`
149
115
 
150
116
  #### Defined in
151
117
 
152
- [packages/ai-tool/src/utils/event/sse-channel.ts:37](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L37)
118
+ [packages/ai-tool/src/utils/event/sse-channel.ts:33](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L33)
153
119
 
154
120
  ## Methods
155
121
 
156
- ### clearClients
122
+ ### clearClients()
157
123
 
158
- **clearClients**(): `void`
124
+ > **clearClients**(): `void`
159
125
 
160
126
  #### Returns
161
127
 
@@ -163,13 +129,13 @@ ___
163
129
 
164
130
  #### Defined in
165
131
 
166
- [packages/ai-tool/src/utils/event/sse-channel.ts:195](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L195)
132
+ [packages/ai-tool/src/utils/event/sse-channel.ts:195](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L195)
167
133
 
168
- ___
134
+ ***
169
135
 
170
- ### getSubscriberCount
136
+ ### getSubscriberCount()
171
137
 
172
- **getSubscriberCount**(): `number`
138
+ > **getSubscriberCount**(): `number`
173
139
 
174
140
  Gets the number of clients subscribed to the SSE channel.
175
141
 
@@ -181,13 +147,13 @@ Gets the number of clients subscribed to the SSE channel.
181
147
 
182
148
  #### Defined in
183
149
 
184
- [packages/ai-tool/src/utils/event/sse-channel.ts:220](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L220)
150
+ [packages/ai-tool/src/utils/event/sse-channel.ts:220](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L220)
185
151
 
186
- ___
152
+ ***
187
153
 
188
- ### listClients
154
+ ### listClients()
189
155
 
190
- **listClients**(): `Record`\<`string`, `number`\>
156
+ > **listClients**(): `Record`\<`string`, `number`\>
191
157
 
192
158
  Lists the clients connected to the SSE channel grouped by IP address.
193
159
 
@@ -199,22 +165,25 @@ Lists the clients connected to the SSE channel grouped by IP address.
199
165
 
200
166
  #### Defined in
201
167
 
202
- [packages/ai-tool/src/utils/event/sse-channel.ts:204](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L204)
168
+ [packages/ai-tool/src/utils/event/sse-channel.ts:204](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L204)
203
169
 
204
- ___
170
+ ***
205
171
 
206
- ### publish
172
+ ### publish()
207
173
 
208
- **publish**(`data?`, `eventName?`): `undefined` \| `number`
174
+ > **publish**(`data`?, `eventName`?): `undefined` \| `number`
209
175
 
210
176
  Publishes a message to the SSE channel.
211
177
 
212
178
  #### Parameters
213
179
 
214
- | Name | Type | Description |
215
- | :------ | :------ | :------ |
216
- | `data?` | `string` \| `Record`\<`string`, `any`\> | The data to send. It can be a string or an object. |
217
- | `eventName?` | `string` | The name of the event. |
180
+ **data?**: `string` \| `Record`\<`string`, `any`\>
181
+
182
+ The data to send. It can be a string or an object.
183
+
184
+ • **eventName?**: `string`
185
+
186
+ The name of the event.
218
187
 
219
188
  #### Returns
220
189
 
@@ -222,63 +191,75 @@ Publishes a message to the SSE channel.
222
191
 
223
192
  - Returns the ID of the message.
224
193
 
225
- **`Throws`**
194
+ #### Throws
226
195
 
227
196
  Will throw an error if the channel is closed.
228
197
 
229
198
  #### Defined in
230
199
 
231
- [packages/ai-tool/src/utils/event/sse-channel.ts:93](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L93)
200
+ [packages/ai-tool/src/utils/event/sse-channel.ts:93](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L93)
232
201
 
233
- ___
202
+ ***
234
203
 
235
- ### subscribe
204
+ ### subscribe()
236
205
 
237
- **subscribe**(`req`, `res`, `events?`): `Object`
206
+ > **subscribe**(`req`, `res`, `events`?): `object`
238
207
 
239
208
  Subscribes a client to the SSE channel.
240
209
 
241
210
  #### Parameters
242
211
 
243
- | Name | Type | Description |
244
- | :------ | :------ | :------ |
245
- | `req` | `IncomingMessage` | The request object. |
246
- | `res` | `ServerResponse`\<`IncomingMessage`\> | The response object. |
247
- | `events?` | `Events` | The events to subscribe to. |
212
+ **req**: `IncomingMessage`
213
+
214
+ The request object.
215
+
216
+ **res**: `ServerResponse`\<`IncomingMessage`\>
217
+
218
+ The response object.
219
+
220
+ • **events?**: `Events`
221
+
222
+ The events to subscribe to.
248
223
 
249
224
  #### Returns
250
225
 
251
- `Object`
226
+ `object`
252
227
 
253
228
  - Returns the client object.
254
229
 
255
- | Name | Type |
256
- | :------ | :------ |
257
- | `events` | `undefined` \| `Events` |
258
- | `req` | `IncomingMessage` |
259
- | `res` | `ServerResponse`\<`IncomingMessage`\> |
230
+ ##### events
231
+
232
+ > **events**: `undefined` \| `Events`
233
+
234
+ ##### req
260
235
 
261
- **`Throws`**
236
+ > **req**: `IncomingMessage`
237
+
238
+ ##### res
239
+
240
+ > **res**: `ServerResponse`\<`IncomingMessage`\>
241
+
242
+ #### Throws
262
243
 
263
244
  Will throw an error if the channel is closed.
264
245
 
265
246
  #### Defined in
266
247
 
267
- [packages/ai-tool/src/utils/event/sse-channel.ts:143](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L143)
248
+ [packages/ai-tool/src/utils/event/sse-channel.ts:143](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L143)
268
249
 
269
- ___
250
+ ***
270
251
 
271
- ### unsubscribe
252
+ ### unsubscribe()
272
253
 
273
- **unsubscribe**(`c`): `void`
254
+ > **unsubscribe**(`c`): `void`
274
255
 
275
256
  Unsubscribes a client from the SSE channel.
276
257
 
277
258
  #### Parameters
278
259
 
279
- | Name | Type | Description |
280
- | :------ | :------ | :------ |
281
- | `c` | `Client` | The client to unsubscribe. |
260
+ **c**: `Client`
261
+
262
+ The client to unsubscribe.
282
263
 
283
264
  #### Returns
284
265
 
@@ -286,4 +267,4 @@ Unsubscribes a client from the SSE channel.
286
267
 
287
268
  #### Defined in
288
269
 
289
- [packages/ai-tool/src/utils/event/sse-channel.ts:190](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/event/sse-channel.ts#L190)
270
+ [packages/ai-tool/src/utils/event/sse-channel.ts:190](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/event/sse-channel.ts#L190)
@@ -1,4 +1,8 @@
1
- [@isdk/ai-tool](../README.md) / [Exports](../modules.md) / Semaphore
1
+ [**@isdk/ai-tool**](../README.md) **Docs**
2
+
3
+ ***
4
+
5
+ [@isdk/ai-tool](../globals.md) / Semaphore
2
6
 
3
7
  # Class: Semaphore
4
8
 
@@ -30,49 +34,29 @@ async function fetchData(x) {
30
34
  const data = await Promise.all(array.map(fetchData));
31
35
  ```
32
36
 
33
- ## Table of contents
34
-
35
- ### Constructors
37
+ ## Constructors
36
38
 
37
- - [constructor](Semaphore.md#constructor)
39
+ ### new Semaphore()
38
40
 
39
- ### Properties
41
+ > **new Semaphore**(`maxConcurrency`, `__namedParameters`): [`Semaphore`](Semaphore.md)
40
42
 
41
- - [free](Semaphore.md#free)
42
- - [maxConcurrency](Semaphore.md#maxconcurrency)
43
- - [pauseFn](Semaphore.md#pausefn)
44
- - [paused](Semaphore.md#paused)
45
- - [releaseEmitter](Semaphore.md#releaseemitter)
46
- - [resumeFn](Semaphore.md#resumefn)
47
- - [useDefaultTokens](Semaphore.md#usedefaulttokens)
48
- - [waiting](Semaphore.md#waiting)
43
+ Creates a semaphore object. The first argument is the maximum concurrently number and the second argument is optional.
49
44
 
50
- ### Methods
45
+ #### Parameters
51
46
 
52
- - [acquire](Semaphore.md#acquire)
53
- - [drain](Semaphore.md#drain)
54
- - [pendingCount](Semaphore.md#pendingcount)
55
- - [release](Semaphore.md#release)
56
- - [tryAcquire](Semaphore.md#tryacquire)
47
+ **maxConcurrency**: `number`
57
48
 
58
- ## Constructors
49
+ The maximum number of callers allowed to acquire the semaphore concurrently.
59
50
 
60
- ### constructor
51
+ **\_\_namedParameters** = `{}`
61
52
 
62
- **new Semaphore**(`maxConcurrency`, `«destructured»?`): [`Semaphore`](Semaphore.md)
53
+ **\_\_namedParameters.capacity?**: `number` = `DefaultAsyncSemaphoreCapacity`
63
54
 
64
- Creates a semaphore object. The first argument is the maximum concurrently number and the second argument is optional.
55
+ **\_\_namedParameters.initFn?** = `defaultInit`
65
56
 
66
- #### Parameters
57
+ **\_\_namedParameters.pauseFn?**
67
58
 
68
- | Name | Type | Default value | Description |
69
- | :------ | :------ | :------ | :------ |
70
- | `maxConcurrency` | `number` | `undefined` | The maximum number of callers allowed to acquire the semaphore concurrently. |
71
- | `«destructured»` | `Object` | `{}` | - |
72
- | › `capacity?` | `number` | `DefaultAsyncSemaphoreCapacity` | - |
73
- | › `initFn?` | () => `any` | `defaultInit` | - |
74
- | › `pauseFn?` | () => `void` | `undefined` | - |
75
- | › `resumeFn?` | () => `void` | `undefined` | - |
59
+ **\_\_namedParameters.resumeFn?**
76
60
 
77
61
  #### Returns
78
62
 
@@ -80,117 +64,39 @@ Creates a semaphore object. The first argument is the maximum concurrently numbe
80
64
 
81
65
  #### Defined in
82
66
 
83
- [packages/ai-tool/src/utils/async-semaphore.ts:207](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L207)
67
+ [packages/ai-tool/src/utils/async-semaphore.ts:207](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L207)
84
68
 
85
69
  ## Properties
86
70
 
87
- ### free
88
-
89
- • `Private` **free**: `Deque`
90
-
91
- #### Defined in
92
-
93
- [packages/ai-tool/src/utils/async-semaphore.ts:153](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L153)
94
-
95
- ___
96
-
97
71
  ### maxConcurrency
98
72
 
99
- `Readonly` **maxConcurrency**: `number`
100
-
101
- #### Defined in
102
-
103
- [packages/ai-tool/src/utils/async-semaphore.ts:151](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L151)
104
-
105
- ___
106
-
107
- ### pauseFn
108
-
109
- • `Private` `Optional` **pauseFn**: () => `void`
110
-
111
- #### Type declaration
112
-
113
- ▸ (): `void`
114
-
115
- ##### Returns
116
-
117
- `void`
118
-
119
- #### Defined in
120
-
121
- [packages/ai-tool/src/utils/async-semaphore.ts:156](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L156)
122
-
123
- ___
124
-
125
- ### paused
126
-
127
- • `Private` **paused**: `boolean`
128
-
129
- #### Defined in
130
-
131
- [packages/ai-tool/src/utils/async-semaphore.ts:158](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L158)
132
-
133
- ___
134
-
135
- ### releaseEmitter
136
-
137
- • `Private` **releaseEmitter**: `EventEmitter`
138
-
139
- #### Defined in
140
-
141
- [packages/ai-tool/src/utils/async-semaphore.ts:154](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L154)
142
-
143
- ___
144
-
145
- ### resumeFn
146
-
147
- • `Private` `Optional` **resumeFn**: () => `void`
148
-
149
- #### Type declaration
150
-
151
- ▸ (): `void`
152
-
153
- ##### Returns
154
-
155
- `void`
156
-
157
- #### Defined in
158
-
159
- [packages/ai-tool/src/utils/async-semaphore.ts:157](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L157)
160
-
161
- ___
162
-
163
- ### useDefaultTokens
164
-
165
- • `Private` **useDefaultTokens**: `boolean`
73
+ > `readonly` **maxConcurrency**: `number`
166
74
 
167
75
  #### Defined in
168
76
 
169
- [packages/ai-tool/src/utils/async-semaphore.ts:155](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L155)
77
+ [packages/ai-tool/src/utils/async-semaphore.ts:151](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L151)
170
78
 
171
- ___
79
+ ***
172
80
 
173
81
  ### waiting
174
82
 
175
- `Readonly` **waiting**: `Deque`
83
+ > `readonly` **waiting**: `Deque`
176
84
 
177
85
  #### Defined in
178
86
 
179
- [packages/ai-tool/src/utils/async-semaphore.ts:152](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L152)
87
+ [packages/ai-tool/src/utils/async-semaphore.ts:152](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L152)
180
88
 
181
89
  ## Methods
182
90
 
183
- ### acquire
91
+ ### acquire()
184
92
 
185
- **acquire**(`signal?`): `Promise`\<`any`\>
93
+ > **acquire**(`signal`?): `Promise`\<`any`\>
186
94
 
187
95
  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.
188
96
 
189
97
  #### Parameters
190
98
 
191
- | Name | Type |
192
- | :------ | :------ |
193
- | `signal?` | `AbortSignal` |
99
+ **signal?**: `AbortSignal`
194
100
 
195
101
  #### Returns
196
102
 
@@ -198,13 +104,13 @@ Acquire a token from the semaphore, thus decrement the number of available execu
198
104
 
199
105
  #### Defined in
200
106
 
201
- [packages/ai-tool/src/utils/async-semaphore.ts:265](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L265)
107
+ [packages/ai-tool/src/utils/async-semaphore.ts:265](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L265)
202
108
 
203
- ___
109
+ ***
204
110
 
205
- ### drain
111
+ ### drain()
206
112
 
207
- **drain**(): `Promise`\<`any`[]\>
113
+ > **drain**(): `Promise`\<`any`[]\>
208
114
 
209
115
  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.
210
116
 
@@ -214,13 +120,13 @@ Drains the semaphore and returns all the initialized tokens in an array. Drainin
214
120
 
215
121
  #### Defined in
216
122
 
217
- [packages/ai-tool/src/utils/async-semaphore.ts:301](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L301)
123
+ [packages/ai-tool/src/utils/async-semaphore.ts:301](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L301)
218
124
 
219
- ___
125
+ ***
220
126
 
221
- ### pendingCount
127
+ ### pendingCount()
222
128
 
223
- **pendingCount**(): `number`
129
+ > **pendingCount**(): `number`
224
130
 
225
131
  Returns the number of callers waiting on the semaphore, i.e. the number of pending promises.
226
132
 
@@ -232,21 +138,19 @@ The number of waiters in the waiting list.
232
138
 
233
139
  #### Defined in
234
140
 
235
- [packages/ai-tool/src/utils/async-semaphore.ts:314](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L314)
141
+ [packages/ai-tool/src/utils/async-semaphore.ts:314](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L314)
236
142
 
237
- ___
143
+ ***
238
144
 
239
- ### release
145
+ ### release()
240
146
 
241
- **release**(`token?`): `void`
147
+ > **release**(`token`?): `void`
242
148
 
243
149
  Release the semaphore, thus increment the number of free execution slots. If initFn is used then the token returned by acquire() should be given as an argument when calling this function.
244
150
 
245
151
  #### Parameters
246
152
 
247
- | Name | Type |
248
- | :------ | :------ |
249
- | `token?` | `any` |
153
+ **token?**: `any`
250
154
 
251
155
  #### Returns
252
156
 
@@ -254,13 +158,13 @@ Release the semaphore, thus increment the number of free execution slots. If ini
254
158
 
255
159
  #### Defined in
256
160
 
257
- [packages/ai-tool/src/utils/async-semaphore.ts:294](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L294)
161
+ [packages/ai-tool/src/utils/async-semaphore.ts:294](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L294)
258
162
 
259
- ___
163
+ ***
260
164
 
261
- ### tryAcquire
165
+ ### tryAcquire()
262
166
 
263
- **tryAcquire**(): `any`
167
+ > **tryAcquire**(): `any`
264
168
 
265
169
  Attempt to acquire a token from the semaphore, if one is available immediately. Otherwise, return undefined.
266
170
 
@@ -270,4 +174,4 @@ Attempt to acquire a token from the semaphore, if one is available immediately.
270
174
 
271
175
  #### Defined in
272
176
 
273
- [packages/ai-tool/src/utils/async-semaphore.ts:258](https://github.com/isdk/ai-tool.js/blob/c5e620338f3b80d6ef09148577c5087098896d8b/src/utils/async-semaphore.ts#L258)
177
+ [packages/ai-tool/src/utils/async-semaphore.ts:258](https://github.com/isdk/ai-tool.js/blob/5f9f0083c734722103ff5468e424b48c212a55f0/src/utils/async-semaphore.ts#L258)