@isdk/ai-tool 0.0.2

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 (87) hide show
  1. package/README.cn.md +261 -0
  2. package/README.md +3 -0
  3. package/dist/chunk-EZFPVSGF.mjs +22 -0
  4. package/dist/chunk-PKECBABP.mjs +5085 -0
  5. package/dist/funcs.d.mts +6 -0
  6. package/dist/funcs.d.ts +6 -0
  7. package/dist/funcs.js +5016 -0
  8. package/dist/funcs.mjs +37 -0
  9. package/dist/index-D4KjfAKl.d.mts +606 -0
  10. package/dist/index-D4KjfAKl.d.ts +606 -0
  11. package/dist/index.d.mts +1097 -0
  12. package/dist/index.d.ts +1097 -0
  13. package/dist/index.js +5239 -0
  14. package/dist/index.mjs +399 -0
  15. package/dist/test/util.d.mts +7 -0
  16. package/dist/test/util.d.ts +7 -0
  17. package/dist/test/util.js +98 -0
  18. package/dist/test/util.mjs +61 -0
  19. package/docs/.nojekyll +1 -0
  20. package/docs/README.md +5 -0
  21. package/docs/classes/AbortError.md +359 -0
  22. package/docs/classes/AlreadyExistsError.md +339 -0
  23. package/docs/classes/BaseError.md +346 -0
  24. package/docs/classes/ClientTools.md +2705 -0
  25. package/docs/classes/CommonError.md +368 -0
  26. package/docs/classes/ConfigFile.md +346 -0
  27. package/docs/classes/EventClient.md +3183 -0
  28. package/docs/classes/EventServer.md +3138 -0
  29. package/docs/classes/EventToolFunc.md +2498 -0
  30. package/docs/classes/FStringPromptTemplate.md +1236 -0
  31. package/docs/classes/FewShotPromptTemplate.md +1286 -0
  32. package/docs/classes/GolangPromptTemplate.md +1236 -0
  33. package/docs/classes/HFEnvironment.md +212 -0
  34. package/docs/classes/HFInterpreter.md +386 -0
  35. package/docs/classes/HFTemplate.md +79 -0
  36. package/docs/classes/HfPromptTemplate.md +1236 -0
  37. package/docs/classes/NotFoundError.md +339 -0
  38. package/docs/classes/NotImplementationError.md +339 -0
  39. package/docs/classes/PromptExampleSelector.md +207 -0
  40. package/docs/classes/PromptTemplate.md +1163 -0
  41. package/docs/classes/ReadableStreamError.md +359 -0
  42. package/docs/classes/ResClientTools.md +2859 -0
  43. package/docs/classes/ResServerTools.md +2783 -0
  44. package/docs/classes/SSEChannel.md +289 -0
  45. package/docs/classes/ServerTools.md +2633 -0
  46. package/docs/classes/ToolFunc.md +2124 -0
  47. package/docs/enums/ErrorCode.md +217 -0
  48. package/docs/enums/XXHashAlgorithm.md +30 -0
  49. package/docs/interfaces/AIChatAssistantMessageParam.md +84 -0
  50. package/docs/interfaces/AIChatContentPartImage.md +36 -0
  51. package/docs/interfaces/AIChatContentPartText.md +30 -0
  52. package/docs/interfaces/AIChatMessageParamBase.md +35 -0
  53. package/docs/interfaces/AIChatMessageToolCall.md +48 -0
  54. package/docs/interfaces/AIChatSystemMessageParam.md +51 -0
  55. package/docs/interfaces/AIChatToolMessageParam.md +62 -0
  56. package/docs/interfaces/AIChatUserMessageParam.md +95 -0
  57. package/docs/interfaces/AIResult.md +65 -0
  58. package/docs/interfaces/AIStreamCallbacksAndOptions.md +158 -0
  59. package/docs/interfaces/AIStreamParser.md +33 -0
  60. package/docs/interfaces/AIStreamParserOptions.md +23 -0
  61. package/docs/interfaces/BaseFunc.md +145 -0
  62. package/docs/interfaces/BaseFuncItem.md +99 -0
  63. package/docs/interfaces/ClientFuncItem.md +181 -0
  64. package/docs/interfaces/DotenvExpandOptions.md +51 -0
  65. package/docs/interfaces/DotenvExpandOutput.md +30 -0
  66. package/docs/interfaces/DotenvParseInput.md +7 -0
  67. package/docs/interfaces/DotenvParseOutput.md +7 -0
  68. package/docs/interfaces/DotenvPopulateInput.md +7 -0
  69. package/docs/interfaces/EventClientFuncParams.md +66 -0
  70. package/docs/interfaces/EventServerFuncParams.md +79 -0
  71. package/docs/interfaces/FewShotPromptTemplateOptions.md +179 -0
  72. package/docs/interfaces/FuncItem.md +130 -0
  73. package/docs/interfaces/FuncParam.md +67 -0
  74. package/docs/interfaces/FuncParams.md +7 -0
  75. package/docs/interfaces/Funcs.md +7 -0
  76. package/docs/interfaces/IOptions.md +30 -0
  77. package/docs/interfaces/JsonFilter.md +7 -0
  78. package/docs/interfaces/PromptExampleSelectorOptions.md +39 -0
  79. package/docs/interfaces/PromptTemplateOptions.md +84 -0
  80. package/docs/interfaces/RemoteFuncItem.md +167 -0
  81. package/docs/interfaces/ResClientFuncParams.md +34 -0
  82. package/docs/interfaces/ResServerFuncParams.md +79 -0
  83. package/docs/interfaces/SanitizeFilenameOptions.md +30 -0
  84. package/docs/interfaces/ServerFuncItem.md +192 -0
  85. package/docs/interfaces/ServerFuncParams.md +44 -0
  86. package/docs/modules.md +2707 -0
  87. package/package.json +112 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,399 @@
1
+ import {
2
+ AIChatRoles,
3
+ AIMessageTypes,
4
+ AIStream,
5
+ AITextGenerationFinishReasons,
6
+ AbortError,
7
+ AbortErrorCode,
8
+ ActionNames,
9
+ AlreadyExistsError,
10
+ AlreadyExistsErrorCode,
11
+ BaseError,
12
+ ClientToolFuncSchema,
13
+ ClientTools,
14
+ CommonError,
15
+ ConfigFile,
16
+ EnvironmentEx,
17
+ ErrorCode,
18
+ EventBusName,
19
+ EventClient,
20
+ EventName,
21
+ EventServer,
22
+ EventToolFunc,
23
+ FStringPromptTemplate,
24
+ FewShotPromptTemplate,
25
+ FilenameReservedRegex,
26
+ GolangPromptTemplate,
27
+ HfPromptTemplate,
28
+ InternalErrorCode,
29
+ Interpreter,
30
+ NIL,
31
+ NotFoundError,
32
+ NotFoundErrorCode,
33
+ NotImplementationError,
34
+ NotImplementedErrorCode,
35
+ PASSING_SCORE,
36
+ PromptExampleSelector,
37
+ PromptTemplate,
38
+ PromptTemplateTypes,
39
+ PromptTypes,
40
+ RStreamErrCode,
41
+ ReadableStreamError,
42
+ RemoteToolFuncSchema,
43
+ ResClientTools,
44
+ ResClientToolsSchema,
45
+ ResServerTools,
46
+ ResServerToolsSchema,
47
+ ResponseRStreamErrCode,
48
+ SSEChannel,
49
+ SSEChannelAlreadyClosedErrCode,
50
+ ServerToolFuncSchema,
51
+ ServerTools,
52
+ Template,
53
+ ToolFunc,
54
+ ToolFuncSchema,
55
+ WindowsReservedNameRegex,
56
+ XXHashAlgorithm,
57
+ _lrucache,
58
+ backendEventable,
59
+ base32768,
60
+ builtins,
61
+ createCallbacksTransformer,
62
+ createEmptyReadableStream,
63
+ createEndWithRepetitionDetector,
64
+ createError,
65
+ createEventStreamTransformer,
66
+ createHfValueFunc,
67
+ createLRUCache,
68
+ defaultTemplateFormat,
69
+ event,
70
+ eventClient,
71
+ eventServer,
72
+ expandEnv,
73
+ expandObjEnv,
74
+ extNameLevel,
75
+ filenameReservedRegex,
76
+ getAllEnumKeys,
77
+ getConfigFileNames,
78
+ getConfigs,
79
+ getDefaultSimilarPassingScore,
80
+ getKeysPath,
81
+ getMultiLevelExtname,
82
+ getResponseErrorReadableStream,
83
+ interpolateEnv,
84
+ interpolateFString,
85
+ interpolateGolangTemplate,
86
+ isModelNameMatched,
87
+ isSimilar,
88
+ isValidFilename,
89
+ isValidFilepath,
90
+ jsonFilterToWhere,
91
+ loadFileFromPaths,
92
+ loadTextFromPaths,
93
+ lrucache,
94
+ mergeSegments,
95
+ mimeType,
96
+ parse,
97
+ parse2,
98
+ parseFString,
99
+ parseJsJson,
100
+ parseYaml,
101
+ reControlCharsRegex,
102
+ readableFromAsyncIterable,
103
+ registerCoreTools,
104
+ registerYamlTag,
105
+ sanitizeFilename,
106
+ sanitizeFilepath,
107
+ saveConfigFile,
108
+ segments,
109
+ similarity,
110
+ sortedValues,
111
+ splitSegments,
112
+ splitSentence,
113
+ stringify,
114
+ stringify2,
115
+ throwError,
116
+ tokenize,
117
+ trimStartOfStreamHelper,
118
+ truncTo,
119
+ utils_exports,
120
+ uuid,
121
+ v1,
122
+ v4,
123
+ v5,
124
+ validate,
125
+ version,
126
+ wait,
127
+ xxhash,
128
+ xxhash32,
129
+ xxhash64,
130
+ xxhashAsStr
131
+ } from "./chunk-PKECBABP.mjs";
132
+ import {
133
+ __export,
134
+ __reExport
135
+ } from "./chunk-EZFPVSGF.mjs";
136
+
137
+ // src/index.ts
138
+ var src_exports = {};
139
+ __export(src_exports, {
140
+ AIChatRoles: () => AIChatRoles,
141
+ AIMessageTypes: () => AIMessageTypes,
142
+ AIStream: () => AIStream,
143
+ AITextGenerationFinishReasons: () => AITextGenerationFinishReasons,
144
+ AbortError: () => AbortError,
145
+ AbortErrorCode: () => AbortErrorCode,
146
+ ActionNames: () => ActionNames,
147
+ AlreadyExistsError: () => AlreadyExistsError,
148
+ AlreadyExistsErrorCode: () => AlreadyExistsErrorCode,
149
+ BaseError: () => BaseError,
150
+ ClientToolFuncSchema: () => ClientToolFuncSchema,
151
+ ClientTools: () => ClientTools,
152
+ CommonError: () => CommonError,
153
+ ConfigFile: () => ConfigFile,
154
+ ErrorCode: () => ErrorCode,
155
+ EventBusName: () => EventBusName,
156
+ EventClient: () => EventClient,
157
+ EventName: () => EventName,
158
+ EventServer: () => EventServer,
159
+ EventToolFunc: () => EventToolFunc,
160
+ FStringPromptTemplate: () => FStringPromptTemplate,
161
+ FewShotPromptTemplate: () => FewShotPromptTemplate,
162
+ FilenameReservedRegex: () => FilenameReservedRegex,
163
+ GolangPromptTemplate: () => GolangPromptTemplate,
164
+ HFBuiltins: () => builtins,
165
+ HFEnvironment: () => EnvironmentEx,
166
+ HFInterpreter: () => Interpreter,
167
+ HFTemplate: () => Template,
168
+ HfPromptTemplate: () => HfPromptTemplate,
169
+ InternalErrorCode: () => InternalErrorCode,
170
+ NotFoundError: () => NotFoundError,
171
+ NotFoundErrorCode: () => NotFoundErrorCode,
172
+ NotImplementationError: () => NotImplementationError,
173
+ NotImplementedErrorCode: () => NotImplementedErrorCode,
174
+ PASSING_SCORE: () => PASSING_SCORE,
175
+ PromptExampleSelector: () => PromptExampleSelector,
176
+ PromptTemplate: () => PromptTemplate,
177
+ PromptTemplateTypes: () => PromptTemplateTypes,
178
+ PromptTypes: () => PromptTypes,
179
+ RStreamErrCode: () => RStreamErrCode,
180
+ ReadableStreamError: () => ReadableStreamError,
181
+ RemoteToolFuncSchema: () => RemoteToolFuncSchema,
182
+ ResClientTools: () => ResClientTools,
183
+ ResClientToolsSchema: () => ResClientToolsSchema,
184
+ ResServerTools: () => ResServerTools,
185
+ ResServerToolsSchema: () => ResServerToolsSchema,
186
+ ResponseRStreamErrCode: () => ResponseRStreamErrCode,
187
+ SSEChannel: () => SSEChannel,
188
+ SSEChannelAlreadyClosedErrCode: () => SSEChannelAlreadyClosedErrCode,
189
+ ServerToolFuncSchema: () => ServerToolFuncSchema,
190
+ ServerTools: () => ServerTools,
191
+ ToolFunc: () => ToolFunc,
192
+ ToolFuncSchema: () => ToolFuncSchema,
193
+ WindowsReservedNameRegex: () => WindowsReservedNameRegex,
194
+ XXHashAlgorithm: () => XXHashAlgorithm,
195
+ _lrucache: () => _lrucache,
196
+ backendEventable: () => backendEventable,
197
+ base32768: () => base32768,
198
+ createCallbacksTransformer: () => createCallbacksTransformer,
199
+ createEmptyReadableStream: () => createEmptyReadableStream,
200
+ createEndWithRepetitionDetector: () => createEndWithRepetitionDetector,
201
+ createError: () => createError,
202
+ createEventStreamTransformer: () => createEventStreamTransformer,
203
+ createHfValueFunc: () => createHfValueFunc,
204
+ createLRUCache: () => createLRUCache,
205
+ defaultTemplateFormat: () => defaultTemplateFormat,
206
+ event: () => event,
207
+ eventClient: () => eventClient,
208
+ eventServer: () => eventServer,
209
+ expandEnv: () => expandEnv,
210
+ expandObjEnv: () => expandObjEnv,
211
+ extNameLevel: () => extNameLevel,
212
+ filenameReservedRegex: () => filenameReservedRegex,
213
+ getAllEnumKeys: () => getAllEnumKeys,
214
+ getConfigFileNames: () => getConfigFileNames,
215
+ getConfigs: () => getConfigs,
216
+ getDefaultSimilarPassingScore: () => getDefaultSimilarPassingScore,
217
+ getKeysPath: () => getKeysPath,
218
+ getMultiLevelExtname: () => getMultiLevelExtname,
219
+ getResponseErrorReadableStream: () => getResponseErrorReadableStream,
220
+ hfParse: () => parse,
221
+ hfTokenize: () => tokenize,
222
+ interpolateEnv: () => interpolateEnv,
223
+ interpolateFString: () => interpolateFString,
224
+ interpolateGolangTemplate: () => interpolateGolangTemplate,
225
+ isModelNameMatched: () => isModelNameMatched,
226
+ isSimilar: () => isSimilar,
227
+ isValidFilename: () => isValidFilename,
228
+ isValidFilepath: () => isValidFilepath,
229
+ jsonFilterToWhere: () => jsonFilterToWhere,
230
+ loadFileFromPaths: () => loadFileFromPaths,
231
+ loadTextFromPaths: () => loadTextFromPaths,
232
+ lrucache: () => lrucache,
233
+ mergeSegments: () => mergeSegments,
234
+ mimeType: () => mimeType,
235
+ parseFString: () => parseFString,
236
+ parseJsJson: () => parseJsJson,
237
+ parseYaml: () => parseYaml,
238
+ reControlCharsRegex: () => reControlCharsRegex,
239
+ readableFromAsyncIterable: () => readableFromAsyncIterable,
240
+ registerCoreTools: () => registerCoreTools,
241
+ registerYamlTag: () => registerYamlTag,
242
+ sanitizeFilename: () => sanitizeFilename,
243
+ sanitizeFilepath: () => sanitizeFilepath,
244
+ saveConfigFile: () => saveConfigFile,
245
+ segments: () => segments,
246
+ similarity: () => similarity,
247
+ sortedValues: () => sortedValues,
248
+ splitSegments: () => splitSegments,
249
+ splitSentence: () => splitSentence,
250
+ stringifyYaml: () => stringify2,
251
+ throwError: () => throwError,
252
+ trimStartOfStreamHelper: () => trimStartOfStreamHelper,
253
+ truncTo: () => truncTo,
254
+ uuid: () => uuid,
255
+ uuidNIL: () => NIL,
256
+ uuidParse: () => parse2,
257
+ uuidStringify: () => stringify,
258
+ uuidValidate: () => validate,
259
+ uuidVersion: () => version,
260
+ uuidv1: () => v1,
261
+ uuidv4: () => v4,
262
+ uuidv5: () => v5,
263
+ wait: () => wait,
264
+ xxhash: () => xxhash,
265
+ xxhash32: () => xxhash32,
266
+ xxhash64: () => xxhash64,
267
+ xxhashAsStr: () => xxhashAsStr
268
+ });
269
+ __reExport(src_exports, utils_exports);
270
+ export {
271
+ AIChatRoles,
272
+ AIMessageTypes,
273
+ AIStream,
274
+ AITextGenerationFinishReasons,
275
+ AbortError,
276
+ AbortErrorCode,
277
+ ActionNames,
278
+ AlreadyExistsError,
279
+ AlreadyExistsErrorCode,
280
+ BaseError,
281
+ ClientToolFuncSchema,
282
+ ClientTools,
283
+ CommonError,
284
+ ConfigFile,
285
+ ErrorCode,
286
+ EventBusName,
287
+ EventClient,
288
+ EventName,
289
+ EventServer,
290
+ EventToolFunc,
291
+ FStringPromptTemplate,
292
+ FewShotPromptTemplate,
293
+ FilenameReservedRegex,
294
+ GolangPromptTemplate,
295
+ builtins as HFBuiltins,
296
+ EnvironmentEx as HFEnvironment,
297
+ Interpreter as HFInterpreter,
298
+ Template as HFTemplate,
299
+ HfPromptTemplate,
300
+ InternalErrorCode,
301
+ NotFoundError,
302
+ NotFoundErrorCode,
303
+ NotImplementationError,
304
+ NotImplementedErrorCode,
305
+ PASSING_SCORE,
306
+ PromptExampleSelector,
307
+ PromptTemplate,
308
+ PromptTemplateTypes,
309
+ PromptTypes,
310
+ RStreamErrCode,
311
+ ReadableStreamError,
312
+ RemoteToolFuncSchema,
313
+ ResClientTools,
314
+ ResClientToolsSchema,
315
+ ResServerTools,
316
+ ResServerToolsSchema,
317
+ ResponseRStreamErrCode,
318
+ SSEChannel,
319
+ SSEChannelAlreadyClosedErrCode,
320
+ ServerToolFuncSchema,
321
+ ServerTools,
322
+ ToolFunc,
323
+ ToolFuncSchema,
324
+ WindowsReservedNameRegex,
325
+ XXHashAlgorithm,
326
+ _lrucache,
327
+ backendEventable,
328
+ base32768,
329
+ createCallbacksTransformer,
330
+ createEmptyReadableStream,
331
+ createEndWithRepetitionDetector,
332
+ createError,
333
+ createEventStreamTransformer,
334
+ createHfValueFunc,
335
+ createLRUCache,
336
+ defaultTemplateFormat,
337
+ event,
338
+ eventClient,
339
+ eventServer,
340
+ expandEnv,
341
+ expandObjEnv,
342
+ extNameLevel,
343
+ filenameReservedRegex,
344
+ getAllEnumKeys,
345
+ getConfigFileNames,
346
+ getConfigs,
347
+ getDefaultSimilarPassingScore,
348
+ getKeysPath,
349
+ getMultiLevelExtname,
350
+ getResponseErrorReadableStream,
351
+ parse as hfParse,
352
+ tokenize as hfTokenize,
353
+ interpolateEnv,
354
+ interpolateFString,
355
+ interpolateGolangTemplate,
356
+ isModelNameMatched,
357
+ isSimilar,
358
+ isValidFilename,
359
+ isValidFilepath,
360
+ jsonFilterToWhere,
361
+ loadFileFromPaths,
362
+ loadTextFromPaths,
363
+ lrucache,
364
+ mergeSegments,
365
+ mimeType,
366
+ parseFString,
367
+ parseJsJson,
368
+ parseYaml,
369
+ reControlCharsRegex,
370
+ readableFromAsyncIterable,
371
+ registerCoreTools,
372
+ registerYamlTag,
373
+ sanitizeFilename,
374
+ sanitizeFilepath,
375
+ saveConfigFile,
376
+ segments,
377
+ similarity,
378
+ sortedValues,
379
+ splitSegments,
380
+ splitSentence,
381
+ stringify2 as stringifyYaml,
382
+ throwError,
383
+ trimStartOfStreamHelper,
384
+ truncTo,
385
+ uuid,
386
+ NIL as uuidNIL,
387
+ parse2 as uuidParse,
388
+ stringify as uuidStringify,
389
+ validate as uuidValidate,
390
+ version as uuidVersion,
391
+ v1 as uuidv1,
392
+ v4 as uuidv4,
393
+ v5 as uuidv5,
394
+ wait,
395
+ xxhash,
396
+ xxhash32,
397
+ xxhash64,
398
+ xxhashAsStr
399
+ };
@@ -0,0 +1,7 @@
1
+ declare function compareStr(src: Buffer, dest: Buffer): boolean;
2
+
3
+ declare function findPort(port: any, portRetryCount?: number): Promise<number>;
4
+
5
+ declare function rmFile(filePath: string): void;
6
+
7
+ export { compareStr, findPort, rmFile };
@@ -0,0 +1,7 @@
1
+ declare function compareStr(src: Buffer, dest: Buffer): boolean;
2
+
3
+ declare function findPort(port: any, portRetryCount?: number): Promise<number>;
4
+
5
+ declare function rmFile(filePath: string): void;
6
+
7
+ export { compareStr, findPort, rmFile };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // test/util/index.ts
31
+ var util_exports = {};
32
+ __export(util_exports, {
33
+ compareStr: () => compareStr,
34
+ findPort: () => findPort,
35
+ rmFile: () => rmFile
36
+ });
37
+ module.exports = __toCommonJS(util_exports);
38
+
39
+ // test/util/compare-str.ts
40
+ function compareStr(src, dest) {
41
+ expect(src.length).toBeGreaterThanOrEqual(dest.length);
42
+ for (let i = 0; i < dest.length; i++) {
43
+ if (src[i] !== dest[i]) {
44
+ return false;
45
+ }
46
+ }
47
+ return true;
48
+ }
49
+
50
+ // test/util/find-port.ts
51
+ var import_net = __toESM(require("net"));
52
+ async function findPort(port, portRetryCount = 10) {
53
+ return new Promise((resolve, reject) => {
54
+ if (port === void 0) {
55
+ port = 0;
56
+ } else {
57
+ port = parseInt(port);
58
+ if (!(port >= 0))
59
+ port = 0;
60
+ }
61
+ const server = import_net.default.createServer();
62
+ server.on("error", (err) => {
63
+ if (err.code === "EADDRINUSE") {
64
+ port++;
65
+ portRetryCount--;
66
+ if (portRetryCount > 0) {
67
+ server.listen(port);
68
+ return;
69
+ }
70
+ }
71
+ reject(err);
72
+ });
73
+ server.on("listening", async () => {
74
+ const addr = server.address();
75
+ const result = addr.port;
76
+ server.close();
77
+ resolve(result);
78
+ });
79
+ server.listen(port);
80
+ });
81
+ }
82
+
83
+ // test/util/rm-file.ts
84
+ var import_fs = require("fs");
85
+ function rmFile(filePath) {
86
+ if ((0, import_fs.existsSync)(filePath)) {
87
+ (0, import_fs.rmSync)(filePath, { recursive: true });
88
+ }
89
+ if ((0, import_fs.existsSync)(filePath + ".temp")) {
90
+ (0, import_fs.rmSync)(filePath + ".temp", { recursive: true });
91
+ }
92
+ }
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ compareStr,
96
+ findPort,
97
+ rmFile
98
+ });
@@ -0,0 +1,61 @@
1
+ import "../chunk-EZFPVSGF.mjs";
2
+
3
+ // test/util/compare-str.ts
4
+ function compareStr(src, dest) {
5
+ expect(src.length).toBeGreaterThanOrEqual(dest.length);
6
+ for (let i = 0; i < dest.length; i++) {
7
+ if (src[i] !== dest[i]) {
8
+ return false;
9
+ }
10
+ }
11
+ return true;
12
+ }
13
+
14
+ // test/util/find-port.ts
15
+ import net from "net";
16
+ async function findPort(port, portRetryCount = 10) {
17
+ return new Promise((resolve, reject) => {
18
+ if (port === void 0) {
19
+ port = 0;
20
+ } else {
21
+ port = parseInt(port);
22
+ if (!(port >= 0))
23
+ port = 0;
24
+ }
25
+ const server = net.createServer();
26
+ server.on("error", (err) => {
27
+ if (err.code === "EADDRINUSE") {
28
+ port++;
29
+ portRetryCount--;
30
+ if (portRetryCount > 0) {
31
+ server.listen(port);
32
+ return;
33
+ }
34
+ }
35
+ reject(err);
36
+ });
37
+ server.on("listening", async () => {
38
+ const addr = server.address();
39
+ const result = addr.port;
40
+ server.close();
41
+ resolve(result);
42
+ });
43
+ server.listen(port);
44
+ });
45
+ }
46
+
47
+ // test/util/rm-file.ts
48
+ import { existsSync, rmSync } from "fs";
49
+ function rmFile(filePath) {
50
+ if (existsSync(filePath)) {
51
+ rmSync(filePath, { recursive: true });
52
+ }
53
+ if (existsSync(filePath + ".temp")) {
54
+ rmSync(filePath + ".temp", { recursive: true });
55
+ }
56
+ }
57
+ export {
58
+ compareStr,
59
+ findPort,
60
+ rmFile
61
+ };
package/docs/.nojekyll ADDED
@@ -0,0 +1 @@
1
+ TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
package/docs/README.md ADDED
@@ -0,0 +1,5 @@
1
+ @isdk/ai-tool / [Exports](modules.md)
2
+
3
+ ## @isdk/ai-tool
4
+
5
+ All Tool Function parameters are Obj parameters, not positional arguments.