@isdk/ai-tool 0.2.3 → 0.3.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 (267) hide show
  1. package/dist/chunk-JHHFTTVE.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-DUEs7T8M.d.mts → index-BC3GQn6-.d.mts} +7 -0
  7. package/dist/{index-DUEs7T8M.d.ts → index-BC3GQn6-.d.ts} +7 -0
  8. package/dist/index.d.mts +411 -10
  9. package/dist/index.d.ts +411 -10
  10. package/dist/index.js +1 -1
  11. package/dist/index.mjs +1 -1
  12. package/dist/test/util.mjs +1 -1
  13. package/docs/classes/AbortError.md +45 -15
  14. package/docs/classes/AlreadyExistsError.md +45 -15
  15. package/docs/classes/BaseError.md +42 -16
  16. package/docs/classes/CancelableAbility.md +20 -20
  17. package/docs/classes/ClientTools.md +93 -93
  18. package/docs/classes/CommonError.md +45 -15
  19. package/docs/classes/EventClient.md +115 -115
  20. package/docs/classes/EventServer.md +117 -117
  21. package/docs/classes/EventToolFunc.md +85 -85
  22. package/docs/classes/FStringPromptTemplate.md +18 -18
  23. package/docs/classes/FewShotPromptTemplate.md +22 -22
  24. package/docs/classes/GolangPromptTemplate.md +18 -18
  25. package/docs/classes/HFEnvironment.md +9 -9
  26. package/docs/classes/HFInterpreter.md +4 -4
  27. package/docs/classes/HFTemplate.md +4 -4
  28. package/docs/classes/HfPromptTemplate.md +18 -18
  29. package/docs/classes/IntSet.md +11 -11
  30. package/docs/classes/NotFoundError.md +45 -15
  31. package/docs/classes/NotImplementationError.md +45 -15
  32. package/docs/classes/PromptExampleSelector.md +8 -8
  33. package/docs/classes/PromptTemplate.md +17 -17
  34. package/docs/classes/ReadableStreamError.md +45 -15
  35. package/docs/classes/ResClientTools.md +100 -100
  36. package/docs/classes/ResServerTools.md +101 -101
  37. package/docs/classes/SSEChannel.md +14 -14
  38. package/docs/classes/Semaphore.md +8 -8
  39. package/docs/classes/ServerTools.md +89 -89
  40. package/docs/classes/TaskAbortController.md +8 -8
  41. package/docs/classes/ToolFunc.md +82 -82
  42. package/docs/classes/YamlTypeBaseObject.md +29 -0
  43. package/docs/enumerations/AsyncFeatureBits.md +3 -3
  44. package/docs/enumerations/AsyncFeatures.md +3 -3
  45. package/docs/enumerations/ErrorCode.md +21 -21
  46. package/docs/enumerations/HashAlgorithm.md +117 -0
  47. package/docs/functions/AIArgProcessor.md +1 -1
  48. package/docs/functions/AIStream.md +1 -1
  49. package/docs/functions/ChoiceArgProcessor.md +1 -1
  50. package/docs/functions/RateLimit.md +1 -1
  51. package/docs/functions/TemplateArgProcessor.md +1 -1
  52. package/docs/functions/backendEventable.md +1 -1
  53. package/docs/functions/completeSentences.md +23 -0
  54. package/docs/functions/concatText.md +23 -0
  55. package/docs/functions/countLLMTokens.md +23 -0
  56. package/docs/functions/countRegexMatches.md +1 -1
  57. package/docs/functions/createCallbacksTransformer.md +1 -1
  58. package/docs/functions/createEmptyReadableStream.md +1 -1
  59. package/docs/functions/createEndWithRepetitionDetector.md +1 -1
  60. package/docs/functions/createError.md +1 -1
  61. package/docs/functions/createEventStreamTransformer.md +1 -1
  62. package/docs/functions/createHfValueFunc.md +1 -1
  63. package/docs/functions/createLRUCache.md +1 -1
  64. package/docs/functions/createYamlObjectTag.md +23 -0
  65. package/docs/functions/dateToText.md +1 -1
  66. package/docs/functions/decodeCharset.md +23 -0
  67. package/docs/functions/detectCharset.md +23 -0
  68. package/docs/functions/encodeLLMTokens.md +23 -0
  69. package/docs/functions/expandEnv.md +1 -1
  70. package/docs/functions/expandObjEnv.md +1 -1
  71. package/docs/functions/extNameLevel.md +1 -1
  72. package/docs/functions/fileIsExists.md +1 -1
  73. package/docs/functions/filenameReservedRegex.md +1 -1
  74. package/docs/functions/filterValidFnScope.md +1 -1
  75. package/docs/functions/findIndexNonEmptyFrom.md +23 -0
  76. package/docs/functions/findPort.md +1 -1
  77. package/docs/functions/formatTextWithSpace.md +59 -0
  78. package/docs/functions/getAllEnumKeys.md +1 -1
  79. package/docs/functions/getConfigFileNames.md +1 -1
  80. package/docs/functions/getConfigs.md +1 -1
  81. package/docs/functions/getFileMetaInfo.md +21 -0
  82. package/docs/functions/getHashAlgoBySize.md +21 -0
  83. package/docs/functions/getKeysPath.md +1 -1
  84. package/docs/functions/getLLMTokenizer.md +21 -0
  85. package/docs/functions/getMultiLevelExtname.md +1 -1
  86. package/docs/functions/getPackageDir.md +1 -1
  87. package/docs/functions/getRealFilepath.md +1 -1
  88. package/docs/functions/getResponseErrorReadableStream.md +1 -1
  89. package/docs/functions/hasDirectoryIn.md +1 -1
  90. package/docs/functions/hashFile.md +23 -0
  91. package/docs/functions/hashStream.md +23 -0
  92. package/docs/functions/hfParse.md +1 -1
  93. package/docs/functions/hfTokenize.md +1 -1
  94. package/docs/functions/interpolateEnv.md +1 -1
  95. package/docs/functions/interpolateFString.md +1 -1
  96. package/docs/functions/interpolateGolangTemplate.md +1 -1
  97. package/docs/functions/isLangUsingSpaces.md +21 -0
  98. package/docs/functions/isListItemString.md +21 -0
  99. package/docs/functions/isModelNameMatched.md +1 -1
  100. package/docs/functions/isPunctuationChar.md +36 -0
  101. package/docs/functions/isRegExp.md +1 -1
  102. package/docs/functions/isSectionString.md +23 -0
  103. package/docs/functions/isSentenceEnding.md +21 -0
  104. package/docs/functions/isSepLineString.md +21 -0
  105. package/docs/functions/isSubdirectory.md +1 -1
  106. package/docs/functions/isTitleString.md +23 -0
  107. package/docs/functions/isValidFilename.md +1 -1
  108. package/docs/functions/isValidFilepath.md +1 -1
  109. package/docs/functions/isWebStream.md +1 -1
  110. package/docs/functions/jsonFilterToWhere.md +1 -1
  111. package/docs/functions/jsonToMarkdownStr.md +1 -1
  112. package/docs/functions/loadFileFromPaths.md +1 -1
  113. package/docs/functions/loadTextFromPaths.md +1 -1
  114. package/docs/functions/lrucache.md +1 -1
  115. package/docs/functions/makeToolFuncCancelable.md +1 -1
  116. package/docs/functions/matchUrlProtocol.md +1 -1
  117. package/docs/functions/memoize.md +1 -1
  118. package/docs/functions/messagesToText.md +1 -1
  119. package/docs/functions/paramsSizeToScaleStr.md +1 -1
  120. package/docs/functions/parseCommand.md +1 -1
  121. package/docs/functions/parseFString.md +1 -1
  122. package/docs/functions/parseJsJson.md +3 -3
  123. package/docs/functions/parseJsJsonSimpleSync.md +23 -0
  124. package/docs/functions/parseObjectArgInfo.md +1 -1
  125. package/docs/functions/parseObjectArgumentInfos.md +1 -1
  126. package/docs/functions/parseObjectArguments.md +1 -1
  127. package/docs/functions/parseObjectArgumentsAsArgInfos.md +1 -1
  128. package/docs/functions/parseYaml.md +1 -1
  129. package/docs/functions/quoteStr.md +1 -1
  130. package/docs/functions/reControlCharsRegex.md +1 -1
  131. package/docs/functions/readFilenamesRecursiveSync.md +1 -1
  132. package/docs/functions/readTextFileChunks.md +51 -0
  133. package/docs/functions/readTextFileChunksEx.md +23 -0
  134. package/docs/functions/readableFromAsyncIterable.md +1 -1
  135. package/docs/functions/registerCoreTools.md +1 -1
  136. package/docs/functions/registerYamlTag.md +1 -1
  137. package/docs/functions/removeMarkdownBold.md +23 -0
  138. package/docs/functions/removeMarkdownBoldAndItalic.md +23 -0
  139. package/docs/functions/removeMarkdownItalic.md +23 -0
  140. package/docs/functions/replaceWithPlaceholder.md +41 -0
  141. package/docs/functions/restoreFromPlacehoders.md +45 -0
  142. package/docs/functions/sanitizeFilename.md +1 -1
  143. package/docs/functions/sanitizeFilepath.md +1 -1
  144. package/docs/functions/saveConfigFile.md +1 -1
  145. package/docs/functions/scaleStrToParamsSize.md +1 -1
  146. package/docs/functions/simplifyObjectArguments.md +1 -1
  147. package/docs/functions/sortedValues.md +1 -1
  148. package/docs/functions/splitChunks.md +23 -0
  149. package/docs/functions/splitParagraph.md +32 -0
  150. package/docs/functions/splitSentence.md +2 -2
  151. package/docs/functions/stringifyYaml.md +1 -1
  152. package/docs/functions/stripConsoleColor.md +21 -0
  153. package/docs/functions/textToDate.md +1 -1
  154. package/docs/functions/throwError.md +1 -1
  155. package/docs/functions/toDateTime.md +1 -1
  156. package/docs/functions/trimStartOfStreamHelper.md +1 -1
  157. package/docs/functions/truncTo.md +1 -1
  158. package/docs/functions/truncateByToken.md +23 -0
  159. package/docs/functions/truncateToTokenLimit.md +44 -0
  160. package/docs/functions/truncateToTokenLimitEx.md +23 -0
  161. package/docs/functions/uuid.md +1 -1
  162. package/docs/functions/wait.md +1 -1
  163. package/docs/functions/xxhash.md +2 -2
  164. package/docs/functions/xxhash32.md +1 -1
  165. package/docs/functions/xxhash64.md +1 -1
  166. package/docs/functions/xxhashAsStr.md +2 -2
  167. package/docs/globals.md +46 -1
  168. package/docs/interfaces/AIChatAssistantMessageParam.md +48 -6
  169. package/docs/interfaces/AIChatContentPartImage.md +2 -2
  170. package/docs/interfaces/AIChatContentPartText.md +2 -2
  171. package/docs/interfaces/AIChatMessageParamBase.md +31 -1
  172. package/docs/interfaces/AIChatMessageToolCall.md +3 -3
  173. package/docs/interfaces/AIChatSystemMessageParam.md +45 -3
  174. package/docs/interfaces/AIChatToolMessageParam.md +46 -4
  175. package/docs/interfaces/AIChatUserMessageParam.md +49 -7
  176. package/docs/interfaces/AIChoiceConfig.md +7 -7
  177. package/docs/interfaces/AIResult.md +5 -5
  178. package/docs/interfaces/AIStreamParser.md +1 -1
  179. package/docs/interfaces/AIStreamParserOptions.md +1 -1
  180. package/docs/interfaces/BaseFunc.md +9 -9
  181. package/docs/interfaces/BaseFuncItem.md +8 -8
  182. package/docs/interfaces/CancelableAbilityOptions.md +2 -2
  183. package/docs/interfaces/ClientFuncItem.md +11 -11
  184. package/docs/interfaces/DotenvExpandOptions.md +3 -3
  185. package/docs/interfaces/DotenvExpandOutput.md +2 -2
  186. package/docs/interfaces/EventClientFuncParams.md +4 -4
  187. package/docs/interfaces/EventServerFuncParams.md +5 -5
  188. package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
  189. package/docs/interfaces/FuncItem.md +9 -9
  190. package/docs/interfaces/FuncParam.md +6 -6
  191. package/docs/interfaces/HashAlgoParams.md +37 -0
  192. package/docs/interfaces/IFileMetaInfo.md +77 -0
  193. package/docs/interfaces/IReadTextFileChunksOptions.md +157 -0
  194. package/docs/interfaces/ITruncateToTokenLimitOptions.md +111 -0
  195. package/docs/interfaces/ParseObjectArgumentOptions.md +45 -5
  196. package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
  197. package/docs/interfaces/PromptTemplateOptions.md +6 -6
  198. package/docs/interfaces/RemoteFuncItem.md +11 -11
  199. package/docs/interfaces/ReplacePlacehoderOptions.md +47 -0
  200. package/docs/interfaces/ResClientFuncParams.md +2 -2
  201. package/docs/interfaces/ResServerFuncParams.md +5 -5
  202. package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
  203. package/docs/interfaces/SectionStringOptions.md +27 -0
  204. package/docs/interfaces/ServerFuncItem.md +12 -12
  205. package/docs/interfaces/ServerFuncParams.md +2 -2
  206. package/docs/interfaces/SplitSentenceOptions.md +47 -0
  207. package/docs/interfaces/StreamCallbacksAndOptions.md +4 -4
  208. package/docs/interfaces/TaskPromise.md +5 -5
  209. package/docs/interfaces/ToolFuncPackage.md +3 -3
  210. package/docs/type-aliases/AIChatContentPart.md +1 -1
  211. package/docs/type-aliases/AIChatMessageParam.md +1 -1
  212. package/docs/type-aliases/AIChatRole.md +1 -1
  213. package/docs/type-aliases/AIMessageType.md +1 -1
  214. package/docs/type-aliases/AIModelNameRule.md +1 -1
  215. package/docs/type-aliases/AIModelNameRuleFn.md +1 -1
  216. package/docs/type-aliases/AIModelNameRules.md +1 -1
  217. package/docs/type-aliases/AITextGenerationFinishReason.md +1 -1
  218. package/docs/type-aliases/ActionName.md +1 -1
  219. package/docs/type-aliases/AsyncTaskId.md +1 -1
  220. package/docs/type-aliases/EventErrorListenerFn.md +1 -1
  221. package/docs/type-aliases/EventListenerFn.md +1 -1
  222. package/docs/type-aliases/FStringPromptTemplateNode.md +1 -1
  223. package/docs/type-aliases/FuncParamType.md +1 -1
  224. package/docs/type-aliases/PromptExamples.md +1 -1
  225. package/docs/type-aliases/PromptTemplateType.md +1 -1
  226. package/docs/type-aliases/PromptType.md +1 -1
  227. package/docs/type-aliases/TFunc.md +1 -1
  228. package/docs/variables/AIChatRoles.md +1 -1
  229. package/docs/variables/AIMessageTypes.md +1 -1
  230. package/docs/variables/AITextGenerationFinishReasons.md +1 -1
  231. package/docs/variables/AbortErrorCode.md +1 -1
  232. package/docs/variables/ActionNames.md +1 -1
  233. package/docs/variables/AlreadyExistsErrorCode.md +1 -1
  234. package/docs/variables/ClientToolFuncSchema.md +1 -1
  235. package/docs/variables/DefaultAsyncSemaphoreCapacity.md +1 -1
  236. package/docs/variables/EventBusName.md +1 -1
  237. package/docs/variables/EventName.md +1 -1
  238. package/docs/variables/FilenameReservedRegex.md +1 -1
  239. package/docs/variables/HFBuiltins.md +1 -1
  240. package/docs/variables/InternalErrorCode.md +1 -1
  241. package/docs/variables/LLM_TOKENIZER_NAMES.md +83 -0
  242. package/docs/variables/LLM_TOKENIZER_NAMES_MAP.md +13 -0
  243. package/docs/variables/NotFoundErrorCode.md +1 -1
  244. package/docs/variables/NotImplementedErrorCode.md +1 -1
  245. package/docs/variables/PASSING_SCORE.md +1 -1
  246. package/docs/variables/PromptTemplateTypes.md +1 -1
  247. package/docs/variables/PromptTypes.md +1 -1
  248. package/docs/variables/RStreamErrCode.md +1 -1
  249. package/docs/variables/RemoteToolFuncSchema.md +1 -1
  250. package/docs/variables/ResponseRStreamErrCode.md +1 -1
  251. package/docs/variables/SSEChannelAlreadyClosedErrCode.md +1 -1
  252. package/docs/variables/ServerToolFuncSchema.md +1 -1
  253. package/docs/variables/ToolAsyncCancelableBit.md +1 -1
  254. package/docs/variables/ToolAsyncMultiTaskBit.md +1 -1
  255. package/docs/variables/ToolAsyncPriorityBit.md +1 -1
  256. package/docs/variables/ToolFuncSchema.md +1 -1
  257. package/docs/variables/WindowsReservedNameRegex.md +1 -1
  258. package/docs/variables/base32768.md +1 -1
  259. package/docs/variables/defaultTemplateFormat.md +1 -1
  260. package/docs/variables/event.md +1 -1
  261. package/docs/variables/eventClient.md +1 -1
  262. package/docs/variables/eventServer.md +1 -1
  263. package/docs/variables/lrucache.md +1 -1
  264. package/package.json +7 -3
  265. package/dist/chunk-FLVJ4R53.mjs +0 -1
  266. package/docs/enumerations/XXHashAlgorithm.md +0 -27
  267. /package/dist/{chunk-PXQPLL62.mjs → chunk-VIG2GB47.mjs} +0 -0
package/dist/index.d.ts CHANGED
@@ -2,15 +2,17 @@ import * as custom_ability from 'custom-ability';
2
2
  import { AbilityOptions } from 'custom-ability';
3
3
  export { createAbilityInjector } from 'custom-ability';
4
4
  export { toRegExp } from 'util-ex';
5
- import { A as AsyncFeatures, T as ToolFunc, a as AIModelNameRules } from './index-DUEs7T8M.js';
6
- export { e as AIModelNameRule, d as AIModelNameRuleFn, c as ActionName, b as ActionNames, k as AsyncFeatureBits, p as BaseFunc, B as BaseFuncItem, C as ClientFuncItem, u as ClientToolFuncSchema, t as ClientTools, J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, o as FuncItem, l as FuncParam, F as FuncParamType, m as FuncParams, q as Funcs, P as PASSING_SCORE, f as RemoteFuncItem, R as RemoteToolFuncSchema, O as ResClientFuncParams, Q as ResClientTools, U as ResServerFuncParams, V as ResServerTools, g as SSEChannel, S as SSEChannelAlreadyClosedErrCode, w as ServerFuncItem, v as ServerFuncParams, y as ServerToolFuncSchema, x as ServerTools, n as TFunc, i as ToolAsyncCancelableBit, h as ToolAsyncMultiTaskBit, j as ToolAsyncPriorityBit, r as ToolFuncPackage, s as ToolFuncSchema, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-DUEs7T8M.js';
5
+ import { A as AsyncFeatures, T as ToolFunc, a as AIModelNameRules } from './index-BC3GQn6-.js';
6
+ export { e as AIModelNameRule, d as AIModelNameRuleFn, c as ActionName, b as ActionNames, k as AsyncFeatureBits, p as BaseFunc, B as BaseFuncItem, C as ClientFuncItem, u as ClientToolFuncSchema, t as ClientTools, J as EventClient, I as EventClientFuncParams, M as EventServer, L as EventServerFuncParams, E as EventToolFunc, o as FuncItem, l as FuncParam, F as FuncParamType, m as FuncParams, q as Funcs, P as PASSING_SCORE, f as RemoteFuncItem, R as RemoteToolFuncSchema, O as ResClientFuncParams, Q as ResClientTools, U as ResServerFuncParams, V as ResServerTools, g as SSEChannel, S as SSEChannelAlreadyClosedErrCode, w as ServerFuncItem, v as ServerFuncParams, y as ServerToolFuncSchema, x as ServerTools, n as TFunc, i as ToolAsyncCancelableBit, h as ToolAsyncMultiTaskBit, j as ToolAsyncPriorityBit, r as ToolFuncPackage, s as ToolFuncSchema, _ as _lrucache, G as createLRUCache, D as event, K as eventClient, N as eventServer, H as lrucache, z as registerCoreTools } from './index-BC3GQn6-.js';
7
7
  import { CommonError, BaseError } from '@isdk/common-error';
8
8
  export { AbortError, AbortErrorCode, AlreadyExistsError, AlreadyExistsErrorCode, BaseError, CommonError, ErrorCode, InternalErrorCode, NotFoundError, NotFoundErrorCode, NotImplementationError, NotImplementedErrorCode, createError, throwError } from '@isdk/common-error';
9
9
  import { BaseFactory } from 'custom-factory';
10
10
  import { Event } from 'events-ex';
11
11
  import * as _base32768 from 'base32768';
12
+ import * as fs from 'fs';
12
13
  import _memoize, { Options } from 'memoizee';
13
14
  export { f as findPort } from './find-port-qS1CZ9c-.js';
15
+ import { PreTrainedTokenizer } from '@xenova/transformers';
14
16
  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';
15
17
  export { canonicalize } from 'json-canonicalize';
16
18
  export { mimeType } from 'mime-type/with-db';
@@ -261,6 +263,9 @@ type AIChatRole = (typeof AIChatRoles[number]) & string;
261
263
  type AIChatMessageParam = AIChatSystemMessageParam | AIChatUserMessageParam | AIChatAssistantMessageParam | AIChatToolMessageParam;
262
264
  interface AIChatMessageParamBase {
263
265
  role: string;
266
+ toRole?: string | string[] | Record<string, Partial<AIChatMessageParam>>;
267
+ replies?: Record<string, Partial<AIChatMessageParam>>;
268
+ private?: boolean;
264
269
  [name: string]: any;
265
270
  }
266
271
  interface AIChatSystemMessageParam extends AIChatMessageParamBase {
@@ -959,6 +964,12 @@ interface DotenvExpandOutput {
959
964
  parsed?: DotenvParseOutput;
960
965
  }
961
966
 
967
+ interface SplitSentenceOptions {
968
+ best?: boolean;
969
+ completeSentence?: boolean;
970
+ isMarkdown?: boolean;
971
+ ignoreEmptyLine?: boolean;
972
+ }
962
973
  /**
963
974
  * Splits a text into sentences.
964
975
  * This function is used to split a text into separate sentences, based on punctuation marks such as '.', '?', or '!' and other rules.
@@ -971,7 +982,49 @@ interface DotenvExpandOutput {
971
982
  * const text = "Hello world! How are you today? I am fine.";
972
983
  * console.log(splitSentence(text)); // returns ['Hello world!', 'How are you today?', 'I am fine.']
973
984
  */
974
- declare function splitSentence(text: string, best?: boolean): string[];
985
+ declare function splitSentence(text: string, { best, completeSentence, isMarkdown, ignoreEmptyLine }?: SplitSentenceOptions): string[];
986
+ declare function completeSentences(sentences: string[], { isMarkdown, ignoreEmptyLine }?: SplitSentenceOptions): string[];
987
+ declare function concatText(left: string, right: string): string;
988
+ declare function isSentenceEnding(text: string): boolean;
989
+ interface SectionStringOptions {
990
+ isMarkdown?: boolean;
991
+ nextLine?: string;
992
+ }
993
+ declare function isSectionString(text: string, options?: SectionStringOptions): RegExpExecArray | null;
994
+ declare function isTitleString(text: string, options?: SectionStringOptions): RegExpExecArray | null;
995
+ declare function isListItemString(text: string): RegExpExecArray | null;
996
+ declare function isSepLineString(text: string): RegExpExecArray | null;
997
+ /**
998
+ * Checks if the given character is a punctuation mark.
999
+ * This function supports both Chinese and English punctuation marks.
1000
+ *
1001
+ * @param char - The character to check.
1002
+ * @returns `true` if the character is a punctuation mark, otherwise `false`.
1003
+ *
1004
+ * @example
1005
+ * ```typescript
1006
+ * isPunctuationChar('。'); // returns true
1007
+ * isPunctuationChar('!'); // returns true
1008
+ * isPunctuationChar('a'); // returns false
1009
+ * ```
1010
+ */
1011
+ declare function isPunctuationChar(char: string): boolean;
1012
+ declare function isLangUsingSpaces(isoCode: string): boolean;
1013
+ declare function findIndexNonEmptyFrom(arr: any[], start?: number): number;
1014
+ declare function removeMarkdownBold(s: string, once?: boolean): string;
1015
+ declare function removeMarkdownItalic(s: string, once?: boolean): string;
1016
+ declare function removeMarkdownBoldAndItalic(s: string, once?: boolean): string;
1017
+
1018
+ /**
1019
+ * Splits the input string into paragraphs based on empty lines and title lines.
1020
+ * Each paragraph is represented as an array of strings, where each string is a line in the paragraph.
1021
+ *
1022
+ * @param value - The input string to be split into paragraphs.
1023
+ * @param options - Optional configuration options for splitting the string.
1024
+ * @param options.isMarkdown - If true, it's markdown format string.
1025
+ * @returns A two-dimensional array where each sub-array represents a paragraph.
1026
+ */
1027
+ declare function splitParagraph(value: string, options?: SplitSentenceOptions): string[][];
975
1028
 
976
1029
  /**
977
1030
  * Truncates(Round) a number to a specified number of decimal places.
@@ -1125,13 +1178,28 @@ declare const base32768: typeof _base32768;
1125
1178
 
1126
1179
  declare function xxhash32(value: string | object, radix?: number): string;
1127
1180
  declare function xxhash64(value: string | object, radix?: number): string;
1128
- declare enum XXHashAlgorithm {
1181
+ declare enum HashAlgorithm {
1182
+ md5 = 1,
1183
+ sha1 = 2,
1184
+ ripemd = 3,
1185
+ sha256 = 8,
1186
+ sha384 = 9,
1187
+ sha512 = 10,
1188
+ sha224 = 11,
1189
+ xxhash = 111,
1129
1190
  xxhash64 = 111,
1130
- xxhash32 = 112
1191
+ xxhash32 = 112,
1192
+ xxhash128 = 113
1131
1193
  }
1132
1194
  type HashValue = string | ArrayBuffer | Buffer;
1133
- declare function xxhash(value: HashValue, hashAlgo?: XXHashAlgorithm, seed?: number): Uint8Array;
1134
- declare function xxhashAsStr(value: string | Uint8Array, hashAlgo?: XXHashAlgorithm, seed?: number): string;
1195
+ declare function xxhash(value: HashValue, hashAlgo?: HashAlgorithm, seed?: number): Uint8Array;
1196
+ declare function xxhashAsStr(value: string | Uint8Array, hashAlgo?: HashAlgorithm, seed?: number): string;
1197
+ interface HashAlgoParams {
1198
+ hashAlgo?: HashAlgorithm;
1199
+ seed?: number;
1200
+ outputType?: 'hex' | 'binary' | 'string';
1201
+ }
1202
+ declare function hashStream(stream: ReadableStream, { hashAlgo, seed, outputType }?: HashAlgoParams): Promise<string | Uint8Array>;
1135
1203
 
1136
1204
  /**
1137
1205
  * Regular expression pattern for reserved characters in a filename.
@@ -1257,7 +1325,8 @@ declare function getAllEnumKeys<T extends object>(enumType: T): Array<keyof type
1257
1325
  * const json = parseJsJson(jsonString);
1258
1326
  * console.log(json); // { name: 'John' }
1259
1327
  */
1260
- declare function parseJsJson(input: string, scope?: Record<string, any>): any;
1328
+ declare function parseJsJson(input: string, scope?: Record<string, any>): Promise<any>;
1329
+ declare function parseJsJsonSimpleSync(input: string, scope?: Record<string, any>): any;
1261
1330
  declare function filterValidFnScope(scope?: Record<string, any>): Record<string, any> | undefined;
1262
1331
 
1263
1332
  /**
@@ -1314,6 +1383,7 @@ declare function loadTextFromPaths(filename: string, searchPaths?: string[], ext
1314
1383
  filepath?: string;
1315
1384
  signal?: AbortSignal;
1316
1385
  } | BufferEncoding, exclude?: string[] | string): string;
1386
+ declare function decodeCharset(result: Buffer, encoding?: BufferEncoding): string;
1317
1387
  /**
1318
1388
  * Recursively reads all filenames in the given directory or directories.
1319
1389
  * Optionally filters the results using a file matching callback.
@@ -1330,7 +1400,7 @@ declare function loadTextFromPaths(filename: string, searchPaths?: string[], ext
1330
1400
  * ```
1331
1401
  */
1332
1402
  declare function readFilenamesRecursiveSync(dir: string | string[], options?: {
1333
- isFileMatched?: (filepath: string) => boolean;
1403
+ isFileMatched?: (filepath: string, file: fs.Dirent | fs.Stats) => boolean;
1334
1404
  signal?: AbortSignal;
1335
1405
  level?: number;
1336
1406
  }): string[];
@@ -1347,6 +1417,19 @@ declare function readFilenamesRecursiveSync(dir: string | string[], options?: {
1347
1417
  * ```
1348
1418
  */
1349
1419
  declare function getRealFilepath(filepath: string): string;
1420
+ declare function hashFile(filepath: string, options?: HashAlgoParams): Promise<string | Uint8Array>;
1421
+ interface IFileMetaInfo {
1422
+ name: string;
1423
+ mtime: Date;
1424
+ ctime: Date;
1425
+ size: number;
1426
+ hash: string;
1427
+ mimeType: string;
1428
+ id: string;
1429
+ }
1430
+ declare function getFileMetaInfo(filepath: string): Promise<IFileMetaInfo>;
1431
+ declare function getHashAlgoBySize(size: number): HashAlgorithm;
1432
+ declare function detectCharset(content: Buffer | string, options?: any): string;
1350
1433
 
1351
1434
  declare function registerYamlTag(tags: any): void;
1352
1435
  declare function parseYaml(content: string): any;
@@ -1501,10 +1584,14 @@ interface AIChoiceConfig {
1501
1584
  }
1502
1585
  interface ParseObjectArgumentOptions {
1503
1586
  delimiter?: string;
1587
+ assigner?: string;
1504
1588
  argProcessor?: ArgProcessor;
1505
1589
  returnArrayOnly?: boolean;
1506
1590
  templateFormat?: string;
1507
1591
  templateData?: Record<string, any>;
1592
+ ignoreIndexNamed?: boolean;
1593
+ preserveUnresolvedName?: boolean;
1594
+ skipExpression?: boolean;
1508
1595
  }
1509
1596
  /**
1510
1597
  * Asynchronously parses a string of object arguments into an actual object.
@@ -1573,6 +1660,45 @@ declare function parseCommand(commandStr: string, scope?: Record<string, any>, o
1573
1660
  command: string;
1574
1661
  args?: Record<string, any>;
1575
1662
  }>;
1663
+ interface ReplacePlacehoderOptions {
1664
+ startChar?: string | string[];
1665
+ endChar?: string | string[];
1666
+ placeholder?: string;
1667
+ placehoders?: string[];
1668
+ }
1669
+ /**
1670
+ * Replaces substrings in the given content with placeholders.
1671
+ *
1672
+ * @param content - The string content to process.
1673
+ * @param options - Optional configuration object with the following properties:
1674
+ * - `startChar` - The starting character(s) of the substrings to replace. Can be a single character or an array of characters. Defaults to `["\"", "'"]`.
1675
+ * - `endChar` - The ending character(s) of the substrings to replace. Can be a single character or an array of characters. Defaults to the value of `startChar`.
1676
+ * - `placeholder` - The prefix for the placeholder names. Defaults to `defaultPlaceholderName`.
1677
+ * - `placehoders` - An array of placeholders to use instead of generating new one.
1678
+ * @returns An array containing:
1679
+ * - `content` - The modified content with placeholders.
1680
+ * - `placehoders` - An array of the original substrings that were replaced.
1681
+ * @throws {Error} If the lengths of `startChar` and `endChar` are not the same.
1682
+ */
1683
+ declare function replaceWithPlaceholder(content: string, options?: ReplacePlacehoderOptions): [string, string[]];
1684
+ /**
1685
+ * Restores the original substrings from placeholders in the given content.
1686
+ *
1687
+ * @param content - The string content containing placeholders to be restored.
1688
+ * @param placehoders - An array of the original substrings that were replaced by placeholders.
1689
+ * @param options - Optional configuration object with the following properties:
1690
+ * - `placeholder` - The prefix for the placeholder names. Defaults to `__PlacEhoLdeR_`.
1691
+ * @returns The modified content with the original substrings restored.
1692
+ *
1693
+ * @example
1694
+ * ```typescript
1695
+ * const contentWithPlaceholders = "Hello __PlacEhoLdeR_0, welcome to __PlacEhoLdeR_1!";
1696
+ * const originalSubstrings = ["World", "the site"];
1697
+ * const restoredContent = restoreFromPlacehoders(contentWithPlaceholders, originalSubstrings);
1698
+ * console.log(restoredContent); // Output: "Hello World, welcome to the site!"
1699
+ * ```
1700
+ */
1701
+ declare function restoreFromPlacehoders(content: string, placehoders: string[], options?: ReplacePlacehoderOptions): string;
1576
1702
 
1577
1703
  declare function memoize<F extends (...args: any[]) => any>(fn: any, options?: Options<F>): F & _memoize.Memoized<F>;
1578
1704
 
@@ -1622,4 +1748,279 @@ declare function hasDirectoryIn(dir: string, dirs?: string[]): boolean | undefin
1622
1748
 
1623
1749
  declare function isRegExp(value: any): boolean;
1624
1750
 
1625
- 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, CancelableAbility, type CancelableAbilityOptions, ChoiceArgProcessor, 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, getPackageDir, getRealFilepath, getResponseErrorReadableStream, hasDirectoryIn, parse as hfParse, tokenize as hfTokenize, interpolateEnv, interpolateFString, interpolateGolangTemplate, isModelNameMatched, isRegExp, isSubdirectory, 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, simplifyObjectArguments, sortedValues, splitSentence, stringifyYaml, textToDate, toDateTime, trimStartOfStreamHelper, truncTo, uuid, wait, xxhash, xxhash32, xxhash64, xxhashAsStr };
1751
+ declare function stripConsoleColor(str: any): any;
1752
+
1753
+ declare const LLM_TOKENIZER_NAMES: {
1754
+ 'deepseek-ai/DeepSeek-V2-Lite-Chat': string;
1755
+ 'Qwen/Qwen2.5-0.5B': string;
1756
+ 'Xenova/gpt-4': string;
1757
+ 'Xenova/text-davinci-003': string;
1758
+ 'Xenova/gpt-3': string;
1759
+ 'Xenova/grok-1-tokenizer': string;
1760
+ 'Xenova/claude-tokenizer': string;
1761
+ 'Xenova/mistral-tokenizer-v3': string;
1762
+ 'Xenova/mistral-tokenizer-v1': string;
1763
+ 'Xenova/gemma-tokenizer': string;
1764
+ 'Xenova/gemma2-tokenizer': string;
1765
+ 'Xenova/llama3-tokenizer-new': string;
1766
+ 'unsloth/Llama-3.2-1B-Instruct': string;
1767
+ 'Xenova/llama-tokenizer': string;
1768
+ 'Xenova/c4ai-command-r-v01-tokenizer': string;
1769
+ 'Xenova/t5-small': string;
1770
+ 'Xenova/bert-base-cased': string;
1771
+ };
1772
+ declare const LLM_TOKENIZER_NAMES_MAP: any;
1773
+ declare function getLLMTokenizer(modelId: string): Promise<PreTrainedTokenizer>;
1774
+ declare function encodeLLMTokens(text: string, modelId?: string): Promise<number[]>;
1775
+ declare function countLLMTokens(text: string, modelId?: string): Promise<number>;
1776
+
1777
+ /**
1778
+ * Formats the input text by replacing delimiters with spaces and optionally capitalizing the first letter of each word.
1779
+ *
1780
+ * @param input - The input string to be formatted.
1781
+ * @param options - Optional configuration for formatting.
1782
+ * @param options.capitalize - Whether to capitalize the first letter of each word. Defaults to `true`.
1783
+ * @param options.delimiter - The delimiter used to split the words. Defaults to `/[_-]/g`.
1784
+ *
1785
+ * @example
1786
+ * // Returns "Hello World"
1787
+ * formatTextWithSpace("hello_world");
1788
+ *
1789
+ * @example
1790
+ * // Returns "This Is A Test"
1791
+ * formatTextWithSpace("this-is-a-test", { delimiter: /-/g });
1792
+ *
1793
+ * @example
1794
+ * // Returns "hello world"
1795
+ * formatTextWithSpace("hello_world", { capitalize: false });
1796
+ *
1797
+ * @example
1798
+ * // Returns "Hello World This Is A Test"
1799
+ * formatTextWithSpace("hello-world_this_is_a_test");
1800
+ */
1801
+ declare function formatTextWithSpace(input: string, options?: {
1802
+ capitalize?: boolean;
1803
+ delimiter?: string | RegExp;
1804
+ }): string;
1805
+
1806
+ interface ITruncateToTokenLimitOptions {
1807
+ bySentence?: boolean;
1808
+ size?: number;
1809
+ modelId?: string;
1810
+ sentences?: string[];
1811
+ best?: boolean;
1812
+ completeSentence?: boolean;
1813
+ corrected?: boolean;
1814
+ truncLastSection?: boolean;
1815
+ countLLMTokens?: (text: string, modelId?: string) => Promise<number>;
1816
+ }
1817
+ /**
1818
+ * Truncates the given content to fit within a specified token limit by removing sentences from the end.
1819
+ * This function is suitable for text content with multiple sentences.
1820
+ * @param content - The original text content to be processed.
1821
+ * @param options - Optional configuration including model ID and size limit.
1822
+ * @returns The truncated text content.
1823
+ *
1824
+ * @example
1825
+ * ```typescript
1826
+ * const text = "This is an example text that will be truncated to fit within the token limit. It contains multiple sentences. Each sentence will be removed until the content fits within the specified token limit. This is the fourth sentence. This is the fifth sentence.";
1827
+ * const truncatedText = await truncateToTokenLimit(text, { modelId: "exampleModel", size: 50 });
1828
+ * console.log(truncatedText); // Output may be the truncated text
1829
+ * ```
1830
+ *
1831
+ * @warning This function is designed for text content with multiple sentences.
1832
+ */
1833
+ declare function truncateToTokenLimit(content: string, options?: ITruncateToTokenLimitOptions): Promise<string>;
1834
+ declare function truncateToTokenLimitEx(sentences: string[], options?: ITruncateToTokenLimitOptions): Promise<string[]>;
1835
+ declare function truncateByToken(content: string, options?: ITruncateToTokenLimitOptions): Promise<void>;
1836
+
1837
+ /**
1838
+ Returns a boolean for whether the two given types are equal.
1839
+
1840
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
1841
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
1842
+
1843
+ Use-cases:
1844
+ - If you want to make a conditional branch based on the result of a comparison of two types.
1845
+
1846
+ @example
1847
+ ```
1848
+ import type {IsEqual} from 'type-fest';
1849
+
1850
+ // This type returns a boolean for whether the given array includes the given item.
1851
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
1852
+ type Includes<Value extends readonly any[], Item> =
1853
+ Value extends readonly [Value[0], ...infer rest]
1854
+ ? IsEqual<Value[0], Item> extends true
1855
+ ? true
1856
+ : Includes<rest, Item>
1857
+ : false;
1858
+ ```
1859
+
1860
+ @category Type Guard
1861
+ @category Utilities
1862
+ */
1863
+ type IsEqual<A, B> =
1864
+ (<G>() => G extends A ? 1 : 2) extends
1865
+ (<G>() => G extends B ? 1 : 2)
1866
+ ? true
1867
+ : false;
1868
+
1869
+ /**
1870
+ Filter out keys from an object.
1871
+
1872
+ Returns `never` if `Exclude` is strictly equal to `Key`.
1873
+ Returns `never` if `Key` extends `Exclude`.
1874
+ Returns `Key` otherwise.
1875
+
1876
+ @example
1877
+ ```
1878
+ type Filtered = Filter<'foo', 'foo'>;
1879
+ //=> never
1880
+ ```
1881
+
1882
+ @example
1883
+ ```
1884
+ type Filtered = Filter<'bar', string>;
1885
+ //=> never
1886
+ ```
1887
+
1888
+ @example
1889
+ ```
1890
+ type Filtered = Filter<'bar', 'foo'>;
1891
+ //=> 'bar'
1892
+ ```
1893
+
1894
+ @see {Except}
1895
+ */
1896
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1897
+
1898
+ type ExceptOptions = {
1899
+ /**
1900
+ Disallow assigning non-specified properties.
1901
+
1902
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1903
+
1904
+ @default false
1905
+ */
1906
+ requireExactProps?: boolean;
1907
+ };
1908
+
1909
+ /**
1910
+ Create a type from an object type without certain keys.
1911
+
1912
+ We recommend setting the `requireExactProps` option to `true`.
1913
+
1914
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
1915
+
1916
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
1917
+
1918
+ @example
1919
+ ```
1920
+ import type {Except} from 'type-fest';
1921
+
1922
+ type Foo = {
1923
+ a: number;
1924
+ b: string;
1925
+ };
1926
+
1927
+ type FooWithoutA = Except<Foo, 'a'>;
1928
+ //=> {b: string}
1929
+
1930
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1931
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1932
+
1933
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1934
+ //=> {a: number} & Partial<Record<"b", never>>
1935
+
1936
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1937
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1938
+ ```
1939
+
1940
+ @category Object
1941
+ */
1942
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
1943
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
1944
+ } & (Options['requireExactProps'] extends true
1945
+ ? Partial<Record<KeysType, never>>
1946
+ : {});
1947
+
1948
+ /**
1949
+ Create a type that requires at least one of the given keys. The remaining keys are kept as is.
1950
+
1951
+ @example
1952
+ ```
1953
+ import type {RequireAtLeastOne} from 'type-fest';
1954
+
1955
+ type Responder = {
1956
+ text?: () => string;
1957
+ json?: () => string;
1958
+ secure?: boolean;
1959
+ };
1960
+
1961
+ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
1962
+ json: () => '{"message": "ok"}',
1963
+ secure: true
1964
+ };
1965
+ ```
1966
+
1967
+ @category Object
1968
+ */
1969
+ type RequireAtLeastOne<
1970
+ ObjectType,
1971
+ KeysType extends keyof ObjectType = keyof ObjectType,
1972
+ > = {
1973
+ // For each `Key` in `KeysType` make a mapped type:
1974
+ [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
1975
+ // 2. Make all other keys in `KeysType` optional
1976
+ Partial<Pick<ObjectType, Exclude<KeysType, Key>>>;
1977
+ }[KeysType] &
1978
+ // 3. Add the remaining keys not in `KeysType`
1979
+ Except<ObjectType, KeysType>;
1980
+
1981
+ interface IReadTextFileChunksOptions extends ITruncateToTokenLimitOptions {
1982
+ size?: number;
1983
+ modelId?: string;
1984
+ metaInfo?: RequireAtLeastOne<Partial<IFileMetaInfo>, 'size'>;
1985
+ }
1986
+ /**
1987
+ * Reads a text file and yields chunks of text that are within a specified token limit.
1988
+ * This function supports both small files that can be read entirely into memory,
1989
+ * and large files that require streaming.
1990
+ *
1991
+ * Note: The specified `size` must not be less than the token count of the longest sentence.
1992
+ * If the `size` is less than the token count of the longest sentence, some sentences may not
1993
+ * fit completely into a single chunk.
1994
+ * Without completeSentence and corrected Only!
1995
+ *
1996
+ * @param filePath - The path to the text file to be read.
1997
+ * @param options - optional Options for reading the file.
1998
+ * @param options.size - optional The maximum token size per chunk. Default is 1984.
1999
+ * @param options.modelId - optional The ID of the model used for token counting.
2000
+ * @param options.metaInfo - optional Metadata about the file, including its size.
2001
+ *
2002
+ * @example
2003
+ * ```typescript
2004
+ * const filePath = 'path/to/file.txt';
2005
+ * const options = {
2006
+ * size: 2048,
2007
+ * modelId: 'gpt-3.5',
2008
+ * metaInfo: { size: 10240 }
2009
+ * };
2010
+ *
2011
+ * for await (const chunk of readTextFileChunks(filePath, options)) {
2012
+ * console.log('Chunk:', chunk);
2013
+ * }
2014
+ * ```
2015
+ */
2016
+ declare function readTextFileChunks(filePath: string, options?: IReadTextFileChunksOptions): AsyncIterable<string>;
2017
+ declare function readTextFileChunksEx(filePath: string, options?: IReadTextFileChunksOptions): AsyncIterable<string[]>;
2018
+ declare function splitChunks(content: string, options?: IReadTextFileChunksOptions): Promise<string[][]>;
2019
+
2020
+ declare class YamlTypeBaseObject {
2021
+ [name: string]: any;
2022
+ constructor(options?: any);
2023
+ }
2024
+ declare function createYamlObjectTag(tag: string, BaseObject: typeof YamlTypeBaseObject): any;
2025
+
2026
+ 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, CancelableAbility, type CancelableAbilityOptions, ChoiceArgProcessor, 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, type HashAlgoParams, HashAlgorithm, HfPromptTemplate, type IFileMetaInfo, type IReadTextFileChunksOptions, type ITruncateToTokenLimitOptions, IntSet, type JsonFilter, LLM_TOKENIZER_NAMES, LLM_TOKENIZER_NAMES_MAP, type ParseObjectArgumentOptions, PromptExampleSelector, type PromptExampleSelectorOptions, type PromptExamples, PromptTemplate, type PromptTemplateOptions, type PromptTemplateType, PromptTemplateTypes, type PromptType, PromptTypes, RStreamErrCode, RateLimit, ReadableStreamError, type ReplacePlacehoderOptions, ResponseRStreamErrCode, type SanitizeFilenameOptions, type SectionStringOptions, Semaphore, type SplitSentenceOptions, type StreamCallbacksAndOptions, TaskAbortController, type TaskAbortControllers, type TaskPromise, TemplateArgProcessor, ToolFunc, WindowsReservedNameRegex, YamlTypeBaseObject, backendEventable, base32768, completeSentences, concatText, countLLMTokens, countRegexMatches, createCallbacksTransformer, createEmptyReadableStream, createEndWithRepetitionDetector, createEventStreamTransformer, createHfValueFunc, createYamlObjectTag, dateToText, decodeCharset, defaultTemplateFormat, detectCharset, encodeLLMTokens, expandEnv, expandObjEnv, extNameLevel, fileIsExists, filenameReservedRegex, filterValidFnScope, findIndexNonEmptyFrom, formatTextWithSpace, getAllEnumKeys, getConfigFileNames, getConfigs, getFileMetaInfo, getHashAlgoBySize, getKeysPath, getLLMTokenizer, getMultiLevelExtname, getPackageDir, getRealFilepath, getResponseErrorReadableStream, hasDirectoryIn, hashFile, hashStream, parse as hfParse, tokenize as hfTokenize, interpolateEnv, interpolateFString, interpolateGolangTemplate, isLangUsingSpaces, isListItemString, isModelNameMatched, isPunctuationChar, isRegExp, isSectionString, isSentenceEnding, isSepLineString, isSubdirectory, isTitleString, isValidFilename, isValidFilepath, isWebStream, jsonFilterToWhere, jsonToMarkdownStr, loadFileFromPaths, loadTextFromPaths, makeToolFuncCancelable, matchUrlProtocol, memoize, messagesToText, paramsSizeToScaleStr, parseCommand, parseFString, parseJsJson, parseJsJsonSimpleSync, parseObjectArgInfo, parseObjectArgumentInfos, parseObjectArguments, parseObjectArgumentsAsArgInfos, parseYaml, quoteStr, reControlCharsRegex, readFilenamesRecursiveSync, readTextFileChunks, readTextFileChunksEx, readableFromAsyncIterable, registerYamlTag, removeMarkdownBold, removeMarkdownBoldAndItalic, removeMarkdownItalic, replaceWithPlaceholder, restoreFromPlacehoders, sanitizeFilename, sanitizeFilepath, saveConfigFile, scaleStrToParamsSize, simplifyObjectArguments, sortedValues, splitChunks, splitParagraph, splitSentence, stringifyYaml, stripConsoleColor, textToDate, toDateTime, trimStartOfStreamHelper, truncTo, truncateByToken, truncateToTokenLimit, truncateToTokenLimitEx, uuid, wait, xxhash, xxhash32, xxhash64, xxhashAsStr };