@isdk/ai-tool 0.1.1 → 0.1.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 (82) hide show
  1. package/dist/chunk-COXUI4Q3.mjs +1 -0
  2. package/dist/funcs.js +1 -1
  3. package/dist/funcs.mjs +1 -1
  4. package/dist/index.d.mts +29 -28
  5. package/dist/index.d.ts +29 -28
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/test/util.mjs +1 -1
  9. package/docs/classes/AbortError.md +8 -8
  10. package/docs/classes/AlreadyExistsError.md +8 -8
  11. package/docs/classes/BaseError.md +8 -8
  12. package/docs/classes/CancelableAbility.md +20 -20
  13. package/docs/classes/ClientTools.md +74 -74
  14. package/docs/classes/CommonError.md +8 -8
  15. package/docs/classes/ConfigFile.md +19 -19
  16. package/docs/classes/EventClient.md +96 -96
  17. package/docs/classes/EventServer.md +97 -97
  18. package/docs/classes/EventToolFunc.md +65 -65
  19. package/docs/classes/FStringPromptTemplate.md +47 -47
  20. package/docs/classes/FewShotPromptTemplate.md +51 -51
  21. package/docs/classes/GolangPromptTemplate.md +47 -47
  22. package/docs/classes/HFEnvironment.md +9 -9
  23. package/docs/classes/HFInterpreter.md +19 -19
  24. package/docs/classes/HFTemplate.md +4 -4
  25. package/docs/classes/HfPromptTemplate.md +47 -47
  26. package/docs/classes/IntSet.md +12 -12
  27. package/docs/classes/NotFoundError.md +8 -8
  28. package/docs/classes/NotImplementationError.md +8 -8
  29. package/docs/classes/PromptExampleSelector.md +8 -8
  30. package/docs/classes/PromptTemplate.md +46 -46
  31. package/docs/classes/ReadableStreamError.md +8 -8
  32. package/docs/classes/ResClientTools.md +80 -80
  33. package/docs/classes/ResServerTools.md +81 -81
  34. package/docs/classes/SSEChannel.md +15 -15
  35. package/docs/classes/Semaphore.md +14 -14
  36. package/docs/classes/ServerTools.md +70 -70
  37. package/docs/classes/TaskAbortController.md +7 -7
  38. package/docs/classes/ToolFunc.md +62 -62
  39. package/docs/enums/AsyncFeatureBits.md +3 -3
  40. package/docs/enums/AsyncFeatures.md +3 -3
  41. package/docs/enums/ErrorCode.md +21 -21
  42. package/docs/enums/XXHashAlgorithm.md +2 -2
  43. package/docs/interfaces/AIChatAssistantMessageParam.md +6 -6
  44. package/docs/interfaces/AIChatContentPartImage.md +2 -2
  45. package/docs/interfaces/AIChatContentPartText.md +2 -2
  46. package/docs/interfaces/AIChatMessageParamBase.md +1 -1
  47. package/docs/interfaces/AIChatMessageToolCall.md +3 -3
  48. package/docs/interfaces/AIChatSystemMessageParam.md +3 -3
  49. package/docs/interfaces/AIChatToolMessageParam.md +4 -4
  50. package/docs/interfaces/AIChatUserMessageParam.md +7 -7
  51. package/docs/interfaces/AIChoiceConfig.md +7 -7
  52. package/docs/interfaces/AIResult.md +5 -5
  53. package/docs/interfaces/AIStreamParser.md +1 -1
  54. package/docs/interfaces/AIStreamParserOptions.md +1 -1
  55. package/docs/interfaces/BaseFunc.md +9 -9
  56. package/docs/interfaces/BaseFuncItem.md +8 -8
  57. package/docs/interfaces/CancelableAbilityOptions.md +8 -8
  58. package/docs/interfaces/ClientFuncItem.md +11 -11
  59. package/docs/interfaces/DotenvExpandOptions.md +3 -3
  60. package/docs/interfaces/DotenvExpandOutput.md +2 -2
  61. package/docs/interfaces/EventClientFuncParams.md +4 -4
  62. package/docs/interfaces/EventServerFuncParams.md +5 -5
  63. package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
  64. package/docs/interfaces/FuncItem.md +9 -9
  65. package/docs/interfaces/FuncParam.md +6 -6
  66. package/docs/interfaces/ParseObjectArgumentOptions.md +63 -0
  67. package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
  68. package/docs/interfaces/PromptTemplateOptions.md +6 -6
  69. package/docs/interfaces/RemoteFuncItem.md +11 -11
  70. package/docs/interfaces/ResClientFuncParams.md +2 -2
  71. package/docs/interfaces/ResServerFuncParams.md +5 -5
  72. package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
  73. package/docs/interfaces/ServerFuncItem.md +12 -12
  74. package/docs/interfaces/ServerFuncParams.md +2 -2
  75. package/docs/interfaces/StreamCallbacksAndOptions.md +4 -4
  76. package/docs/interfaces/TaskPromise.md +1 -1
  77. package/docs/interfaces/ToolFuncPackage.md +3 -3
  78. package/docs/modules.md +182 -181
  79. package/package.json +12 -10
  80. package/dist/chunk-4LD7IUUG.mjs +0 -1
  81. package/dist/chunk-U5DDQYSF.mjs +0 -1
  82. package/docs/interfaces/IOptions.md +0 -30
package/dist/index.d.ts CHANGED
@@ -6,8 +6,9 @@ export { e as AIModelNameRule, d as AIModelNameRuleFn, n as AbortError, j as Abo
6
6
  import { BaseFactory } from 'custom-factory';
7
7
  import { Event } from 'events-ex';
8
8
  import * as _base32768 from 'base32768';
9
+ import _memoize, { Options } from 'memoizee';
9
10
  export { NIL as uuidNIL, parse as uuidParse, stringify as uuidStringify, validate as uuidValidate, version as uuidVersion, v1 as uuidv1, v4 as uuidv4, v5 as uuidv5 } from 'uuid';
10
- export * from 'json-canonicalize';
11
+ export { canonicalize } from 'json-canonicalize';
11
12
  export { stringify as stringifyYaml } from 'yaml';
12
13
  export { mimeType } from 'mime-type/with-db';
13
14
  export { Config as ConfigFile } from 'load-config-file';
@@ -1315,16 +1316,21 @@ declare function loadTextFromPaths(filename: string, searchPaths?: string[], ext
1315
1316
  * Optionally filters the results using a file matching callback.
1316
1317
  *
1317
1318
  * @param dir - A single directory path or an array of directory paths to start the search from.
1318
- * @param isFileMatched - An optional callback that determines whether a file should be included in the result.
1319
+ * @param options.isFileMatched - An optional callback that determines whether a file should be included in the result.
1320
+ * @param options.signal - An optional signal to abort the operation.
1319
1321
  * @returns An array of file paths that match the criteria.
1320
1322
  *
1321
1323
  * @example
1322
1324
  * ```typescript
1323
- * const files = readFilenamesRecursiveSync('/path/to/directory', (filepath) => filepath.endsWith('.js'));
1325
+ * const files = readFilenamesRecursiveSync('/path/to/directory', {isFileMatched: (filepath) => filepath.endsWith('.js')});
1324
1326
  * console.log(files); // Outputs an array of JavaScript file paths.
1325
1327
  * ```
1326
1328
  */
1327
- declare function readFilenamesRecursiveSync(dir: string | string[], isFileMatched?: (filepath: string) => boolean, signal?: AbortSignal): string[];
1329
+ declare function readFilenamesRecursiveSync(dir: string | string[], options?: {
1330
+ isFileMatched?: (filepath: string) => boolean;
1331
+ signal?: AbortSignal;
1332
+ level?: number;
1333
+ }): string[];
1328
1334
  /**
1329
1335
  * Resolves the real file path, handling symbolic links.
1330
1336
  *
@@ -1479,7 +1485,7 @@ declare class IntSet {
1479
1485
  declare function countRegexMatches(content: string, regex: RegExp): number;
1480
1486
 
1481
1487
  type ArgInfo = [boolean, string];
1482
- type ArgProcessor = (arg: ArgInfo, ix: number, scope?: Record<string, any>) => string | void | Promise<string | void>;
1488
+ type ArgProcessor = (arg: ArgInfo, ix: number, scope?: Record<string, any>, options?: ParseObjectArgumentOptions) => string | void | Promise<string | void>;
1483
1489
  interface AIChoiceConfig {
1484
1490
  items?: string[];
1485
1491
  maxPick?: number;
@@ -1489,6 +1495,13 @@ interface AIChoiceConfig {
1489
1495
  type?: 'random' | 'ai';
1490
1496
  end?: string;
1491
1497
  }
1498
+ interface ParseObjectArgumentOptions {
1499
+ delimiter?: string;
1500
+ argProcessor?: ArgProcessor;
1501
+ returnArrayOnly?: boolean;
1502
+ templateFormat?: string;
1503
+ templateData?: Record<string, any>;
1504
+ }
1492
1505
  /**
1493
1506
  * Asynchronously parses a string of object arguments into an actual object.
1494
1507
  * @param argsStr The string of arguments to be parsed.
@@ -1528,21 +1541,13 @@ interface AIChoiceConfig {
1528
1541
  * console.log(arrayResult); // Output: [1, 2, 3]
1529
1542
  * ```
1530
1543
  */
1531
- declare function parseObjectArguments(argsStr: string, scope?: Record<string, any>, options?: {
1532
- delimiter?: string;
1533
- argProcessor?: ArgProcessor;
1534
- returnArrayOnly?: boolean;
1535
- }): Promise<any>;
1536
- declare function parseObjectArgumentInfos(args: ArgInfo[], scope?: Record<string, any>, options?: {
1537
- delimiter?: string;
1538
- argProcessor?: ArgProcessor;
1539
- returnArrayOnly?: boolean;
1540
- }): Promise<any>;
1541
- declare function ChoiceArgProcessor(argInfo: ArgInfo, _ix: number, scope?: Record<string, any>): string | undefined;
1542
- declare function TemplateArgProcessor([isNamedArg, arg]: ArgInfo, ix: number, scope?: Record<string, any>): Promise<string | undefined>;
1543
- declare function AIArgProcessor(argInfo: ArgInfo, ix: number, scope?: Record<string, any>): Promise<string | undefined>;
1544
+ declare function parseObjectArguments(argsStr: string, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<any>;
1545
+ declare function parseObjectArgumentInfos(args: ArgInfo[], scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<any>;
1546
+ declare function ChoiceArgProcessor(argInfo: ArgInfo, _ix: number, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): string | undefined;
1547
+ declare function TemplateArgProcessor([isNamedArg, arg]: ArgInfo, ix: number, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<string | undefined>;
1548
+ declare function AIArgProcessor(argInfo: ArgInfo, ix: number, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<string | undefined>;
1544
1549
  declare function quoteStr(str: string): string;
1545
- declare function parseObjectArgInfo(argInfo: ArgInfo, ix: number, scope?: Record<string, any>, argProcessor?: ArgProcessor): Promise<string>;
1550
+ declare function parseObjectArgInfo(argInfo: ArgInfo, ix: number, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<string>;
1546
1551
  /**
1547
1552
  * Parses an object arguments string into an array of ArgInfo.
1548
1553
  *
@@ -1558,16 +1563,12 @@ declare function parseObjectArgInfo(argInfo: ArgInfo, ix: number, scope?: Record
1558
1563
  * @returns An array of parsed argument information, where each item contains a boolean indicating whether the argument is named,
1559
1564
  * and the string representation of the argument.
1560
1565
  */
1561
- declare function parseObjectArgumentsAsArgInfos(argsStr: string, scope?: Record<string, any>, options?: {
1562
- delimiter?: string;
1563
- argProcessor?: ArgProcessor;
1564
- }): ArgInfo[];
1565
- declare function parseCommand(commandStr: string, scope?: Record<string, any>, options?: {
1566
- delimiter?: string;
1567
- argProcessor?: ArgProcessor;
1568
- }): Promise<{
1566
+ declare function parseObjectArgumentsAsArgInfos(argsStr: string, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): ArgInfo[];
1567
+ declare function parseCommand(commandStr: string, scope?: Record<string, any>, options?: ParseObjectArgumentOptions): Promise<{
1569
1568
  command: string;
1570
1569
  args?: Record<string, any>;
1571
1570
  }>;
1572
1571
 
1573
- export { AIArgProcessor, type AIChatAssistantMessageParam, type AIChatContentPart, type AIChatContentPartImage, type AIChatContentPartText, type AIChatMessageParam, type AIChatMessageParamBase, type AIChatMessageToolCall, type AIChatRole, AIChatRoles, type AIChatSystemMessageParam, type AIChatToolMessageParam, type AIChatUserMessageParam, type AIChoiceConfig, type AIMessageType, AIMessageTypes, AIModelNameRules, type AIResult, AIStream, type AIStreamParser, type AIStreamParserOptions, type AITextGenerationFinishReason, AITextGenerationFinishReasons, AsyncFeatures, type AsyncTaskId, BaseError, CancelableAbility, type CancelableAbilityOptions, ChoiceArgProcessor, CommonError, DefaultAsyncSemaphoreCapacity, type DotenvExpandOptions, type DotenvExpandOutput, type DotenvParseInput, type DotenvParseOutput, type DotenvPopulateInput, EventBusName, type EventErrorListenerFn, type EventListenerFn, EventName, FStringPromptTemplate, type FStringPromptTemplateNode, FewShotPromptTemplate, type FewShotPromptTemplateOptions, FilenameReservedRegex, GolangPromptTemplate, builtins as HFBuiltins, EnvironmentEx as HFEnvironment, Interpreter as HFInterpreter, Template as HFTemplate, HfPromptTemplate, IntSet, type JsonFilter, PromptExampleSelector, type PromptExampleSelectorOptions, type PromptExamples, PromptTemplate, type PromptTemplateOptions, type PromptTemplateType, PromptTemplateTypes, type PromptType, PromptTypes, RStreamErrCode, RateLimit, ReadableStreamError, ResponseRStreamErrCode, type SanitizeFilenameOptions, Semaphore, type StreamCallbacksAndOptions, TaskAbortController, type TaskAbortControllers, type TaskPromise, TemplateArgProcessor, ToolFunc, WindowsReservedNameRegex, XXHashAlgorithm, backendEventable, base32768, countRegexMatches, createCallbacksTransformer, createEmptyReadableStream, createEndWithRepetitionDetector, createEventStreamTransformer, createHfValueFunc, dateToText, defaultTemplateFormat, expandEnv, expandObjEnv, extNameLevel, fileIsExists, filenameReservedRegex, filterValidFnScope, getAllEnumKeys, getConfigFileNames, getConfigs, getKeysPath, getMultiLevelExtname, getRealFilepath, getResponseErrorReadableStream, parse as hfParse, tokenize as hfTokenize, interpolateEnv, interpolateFString, interpolateGolangTemplate, isModelNameMatched, isValidFilename, isValidFilepath, isWebStream, jsonFilterToWhere, jsonToMarkdownStr, loadFileFromPaths, loadTextFromPaths, makeToolFuncCancelable, matchUrlProtocol, messagesToText, paramsSizeToScaleStr, parseCommand, parseFString, parseJsJson, parseObjectArgInfo, parseObjectArgumentInfos, parseObjectArguments, parseObjectArgumentsAsArgInfos, parseYaml, quoteStr, reControlCharsRegex, readFilenamesRecursiveSync, readableFromAsyncIterable, registerYamlTag, sanitizeFilename, sanitizeFilepath, saveConfigFile, scaleStrToParamsSize, sortedValues, splitSentence, textToDate, toDateTime, trimStartOfStreamHelper, truncTo, uuid, wait, xxhash, xxhash32, xxhash64, xxhashAsStr };
1572
+ declare function memoize<F extends (...args: any[]) => any>(fn: any, options?: Options<F>): F & _memoize.Memoized<F>;
1573
+
1574
+ export { AIArgProcessor, type AIChatAssistantMessageParam, type AIChatContentPart, type AIChatContentPartImage, type AIChatContentPartText, type AIChatMessageParam, type AIChatMessageParamBase, type AIChatMessageToolCall, type AIChatRole, AIChatRoles, type AIChatSystemMessageParam, type AIChatToolMessageParam, type AIChatUserMessageParam, type AIChoiceConfig, type AIMessageType, AIMessageTypes, AIModelNameRules, type AIResult, AIStream, type AIStreamParser, type AIStreamParserOptions, type AITextGenerationFinishReason, AITextGenerationFinishReasons, AsyncFeatures, type AsyncTaskId, BaseError, CancelableAbility, type CancelableAbilityOptions, ChoiceArgProcessor, CommonError, DefaultAsyncSemaphoreCapacity, type DotenvExpandOptions, type DotenvExpandOutput, type DotenvParseInput, type DotenvParseOutput, type DotenvPopulateInput, EventBusName, type EventErrorListenerFn, type EventListenerFn, EventName, FStringPromptTemplate, type FStringPromptTemplateNode, FewShotPromptTemplate, type FewShotPromptTemplateOptions, FilenameReservedRegex, GolangPromptTemplate, builtins as HFBuiltins, EnvironmentEx as HFEnvironment, Interpreter as HFInterpreter, Template as HFTemplate, HfPromptTemplate, IntSet, type JsonFilter, type ParseObjectArgumentOptions, PromptExampleSelector, type PromptExampleSelectorOptions, type PromptExamples, PromptTemplate, type PromptTemplateOptions, type PromptTemplateType, PromptTemplateTypes, type PromptType, PromptTypes, RStreamErrCode, RateLimit, ReadableStreamError, ResponseRStreamErrCode, type SanitizeFilenameOptions, Semaphore, type StreamCallbacksAndOptions, TaskAbortController, type TaskAbortControllers, type TaskPromise, TemplateArgProcessor, ToolFunc, WindowsReservedNameRegex, XXHashAlgorithm, backendEventable, base32768, countRegexMatches, createCallbacksTransformer, createEmptyReadableStream, createEndWithRepetitionDetector, createEventStreamTransformer, createHfValueFunc, dateToText, defaultTemplateFormat, expandEnv, expandObjEnv, extNameLevel, fileIsExists, filenameReservedRegex, filterValidFnScope, getAllEnumKeys, getConfigFileNames, getConfigs, getKeysPath, getMultiLevelExtname, getRealFilepath, getResponseErrorReadableStream, parse as hfParse, tokenize as hfTokenize, interpolateEnv, interpolateFString, interpolateGolangTemplate, isModelNameMatched, isValidFilename, isValidFilepath, isWebStream, jsonFilterToWhere, jsonToMarkdownStr, loadFileFromPaths, loadTextFromPaths, makeToolFuncCancelable, matchUrlProtocol, memoize, messagesToText, paramsSizeToScaleStr, parseCommand, parseFString, parseJsJson, parseObjectArgInfo, parseObjectArgumentInfos, parseObjectArguments, parseObjectArgumentsAsArgInfos, parseYaml, quoteStr, reControlCharsRegex, readFilenamesRecursiveSync, readableFromAsyncIterable, registerYamlTag, sanitizeFilename, sanitizeFilepath, saveConfigFile, scaleStrToParamsSize, sortedValues, splitSentence, textToDate, toDateTime, trimStartOfStreamHelper, truncTo, uuid, wait, xxhash, xxhash32, xxhash64, xxhashAsStr };