@juspay/neurolink 9.5.3 → 9.6.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 (356) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +29 -25
  3. package/dist/agent/directTools.d.ts +5 -5
  4. package/dist/cli/commands/config.d.ts +9 -9
  5. package/dist/cli/commands/serve.d.ts +37 -0
  6. package/dist/cli/commands/serve.js +302 -229
  7. package/dist/cli/commands/setup-anthropic.d.ts +2 -2
  8. package/dist/cli/commands/setup-azure.d.ts +2 -2
  9. package/dist/cli/commands/setup-bedrock.d.ts +2 -2
  10. package/dist/cli/commands/setup-gcp.d.ts +2 -2
  11. package/dist/cli/commands/setup-google-ai.d.ts +2 -2
  12. package/dist/cli/commands/setup-huggingface.d.ts +2 -2
  13. package/dist/cli/commands/setup-mistral.d.ts +2 -2
  14. package/dist/cli/commands/setup-openai.d.ts +2 -2
  15. package/dist/cli/commands/setup.d.ts +2 -2
  16. package/dist/cli/factories/commandFactory.js +16 -2
  17. package/dist/cli/loop/optionsSchema.d.ts +2 -2
  18. package/dist/cli/loop/session.d.ts +4 -0
  19. package/dist/cli/loop/session.js +49 -4
  20. package/dist/cli/utils/interactiveSetup.d.ts +4 -4
  21. package/dist/config/conversationMemory.d.ts +2 -0
  22. package/dist/config/conversationMemory.js +5 -5
  23. package/dist/constants/contextWindows.d.ts +46 -0
  24. package/dist/constants/contextWindows.js +156 -0
  25. package/dist/context/budgetChecker.d.ts +18 -0
  26. package/dist/context/budgetChecker.js +71 -0
  27. package/dist/context/contextCompactor.d.ts +22 -0
  28. package/dist/context/contextCompactor.js +106 -0
  29. package/dist/context/effectiveHistory.d.ts +52 -0
  30. package/dist/context/effectiveHistory.js +105 -0
  31. package/dist/context/errorDetection.d.ts +14 -0
  32. package/dist/context/errorDetection.js +124 -0
  33. package/dist/context/fileSummarizationService.d.ts +54 -0
  34. package/dist/context/fileSummarizationService.js +255 -0
  35. package/dist/context/fileSummarizer.d.ts +56 -0
  36. package/dist/context/fileSummarizer.js +145 -0
  37. package/dist/context/fileTokenBudget.d.ts +53 -0
  38. package/dist/context/fileTokenBudget.js +127 -0
  39. package/dist/context/prompts/summarizationPrompt.d.ts +17 -0
  40. package/dist/context/prompts/summarizationPrompt.js +110 -0
  41. package/dist/context/stages/fileReadDeduplicator.d.ts +10 -0
  42. package/dist/context/stages/fileReadDeduplicator.js +66 -0
  43. package/dist/context/stages/slidingWindowTruncator.d.ts +11 -0
  44. package/dist/context/stages/slidingWindowTruncator.js +42 -0
  45. package/dist/context/stages/structuredSummarizer.d.ts +10 -0
  46. package/dist/context/stages/structuredSummarizer.js +49 -0
  47. package/dist/context/stages/toolOutputPruner.d.ts +10 -0
  48. package/dist/context/stages/toolOutputPruner.js +52 -0
  49. package/dist/context/summarizationEngine.d.ts +45 -0
  50. package/dist/context/summarizationEngine.js +110 -0
  51. package/dist/context/toolOutputLimits.d.ts +17 -0
  52. package/dist/context/toolOutputLimits.js +84 -0
  53. package/dist/context/toolPairRepair.d.ts +16 -0
  54. package/dist/context/toolPairRepair.js +66 -0
  55. package/dist/core/conversationMemoryManager.d.ts +5 -15
  56. package/dist/core/conversationMemoryManager.js +15 -75
  57. package/dist/core/modules/MessageBuilder.d.ts +1 -1
  58. package/dist/core/modules/MessageBuilder.js +2 -0
  59. package/dist/core/modules/TelemetryHandler.d.ts +2 -3
  60. package/dist/core/modules/TelemetryHandler.js +3 -3
  61. package/dist/core/modules/ToolsManager.d.ts +2 -2
  62. package/dist/core/redisConversationMemoryManager.d.ts +8 -14
  63. package/dist/core/redisConversationMemoryManager.js +69 -78
  64. package/dist/factories/providerFactory.d.ts +2 -2
  65. package/dist/files/fileReferenceRegistry.d.ts +276 -0
  66. package/dist/files/fileReferenceRegistry.js +1543 -0
  67. package/dist/files/fileTools.d.ts +423 -0
  68. package/dist/files/fileTools.js +449 -0
  69. package/dist/files/index.d.ts +14 -0
  70. package/dist/files/index.js +13 -0
  71. package/dist/files/streamingReader.d.ts +93 -0
  72. package/dist/files/streamingReader.js +321 -0
  73. package/dist/files/types.d.ts +23 -0
  74. package/dist/files/types.js +23 -0
  75. package/dist/image-gen/imageGenTools.d.ts +2 -2
  76. package/dist/image-gen/types.d.ts +12 -12
  77. package/dist/lib/agent/directTools.d.ts +7 -7
  78. package/dist/lib/config/conversationMemory.d.ts +2 -0
  79. package/dist/lib/config/conversationMemory.js +5 -5
  80. package/dist/lib/constants/contextWindows.d.ts +46 -0
  81. package/dist/lib/constants/contextWindows.js +157 -0
  82. package/dist/lib/context/budgetChecker.d.ts +18 -0
  83. package/dist/lib/context/budgetChecker.js +72 -0
  84. package/dist/lib/context/contextCompactor.d.ts +22 -0
  85. package/dist/lib/context/contextCompactor.js +107 -0
  86. package/dist/lib/context/effectiveHistory.d.ts +52 -0
  87. package/dist/lib/context/effectiveHistory.js +106 -0
  88. package/dist/lib/context/errorDetection.d.ts +14 -0
  89. package/dist/lib/context/errorDetection.js +125 -0
  90. package/dist/lib/context/fileSummarizationService.d.ts +54 -0
  91. package/dist/lib/context/fileSummarizationService.js +256 -0
  92. package/dist/lib/context/fileSummarizer.d.ts +56 -0
  93. package/dist/lib/context/fileSummarizer.js +146 -0
  94. package/dist/lib/context/fileTokenBudget.d.ts +53 -0
  95. package/dist/lib/context/fileTokenBudget.js +128 -0
  96. package/dist/lib/context/prompts/summarizationPrompt.d.ts +17 -0
  97. package/dist/lib/context/prompts/summarizationPrompt.js +111 -0
  98. package/dist/lib/context/stages/fileReadDeduplicator.d.ts +10 -0
  99. package/dist/lib/context/stages/fileReadDeduplicator.js +67 -0
  100. package/dist/lib/context/stages/slidingWindowTruncator.d.ts +11 -0
  101. package/dist/lib/context/stages/slidingWindowTruncator.js +43 -0
  102. package/dist/lib/context/stages/structuredSummarizer.d.ts +10 -0
  103. package/dist/lib/context/stages/structuredSummarizer.js +50 -0
  104. package/dist/lib/context/stages/toolOutputPruner.d.ts +10 -0
  105. package/dist/lib/context/stages/toolOutputPruner.js +53 -0
  106. package/dist/lib/context/summarizationEngine.d.ts +45 -0
  107. package/dist/lib/context/summarizationEngine.js +111 -0
  108. package/dist/lib/context/toolOutputLimits.d.ts +17 -0
  109. package/dist/lib/context/toolOutputLimits.js +85 -0
  110. package/dist/lib/context/toolPairRepair.d.ts +16 -0
  111. package/dist/lib/context/toolPairRepair.js +67 -0
  112. package/dist/lib/core/conversationMemoryManager.d.ts +5 -15
  113. package/dist/lib/core/conversationMemoryManager.js +15 -75
  114. package/dist/lib/core/modules/MessageBuilder.d.ts +1 -1
  115. package/dist/lib/core/modules/MessageBuilder.js +2 -0
  116. package/dist/lib/core/modules/TelemetryHandler.d.ts +2 -3
  117. package/dist/lib/core/modules/TelemetryHandler.js +3 -3
  118. package/dist/lib/core/modules/ToolsManager.d.ts +2 -2
  119. package/dist/lib/core/redisConversationMemoryManager.d.ts +8 -14
  120. package/dist/lib/core/redisConversationMemoryManager.js +69 -78
  121. package/dist/lib/factories/providerFactory.d.ts +2 -2
  122. package/dist/lib/files/fileReferenceRegistry.d.ts +276 -0
  123. package/dist/lib/files/fileReferenceRegistry.js +1544 -0
  124. package/dist/lib/files/fileTools.d.ts +423 -0
  125. package/dist/lib/files/fileTools.js +450 -0
  126. package/dist/lib/files/index.d.ts +14 -0
  127. package/dist/lib/files/index.js +14 -0
  128. package/dist/lib/files/streamingReader.d.ts +93 -0
  129. package/dist/lib/files/streamingReader.js +322 -0
  130. package/dist/lib/files/types.d.ts +23 -0
  131. package/dist/lib/files/types.js +24 -0
  132. package/dist/lib/image-gen/imageGenTools.d.ts +2 -2
  133. package/dist/lib/image-gen/types.d.ts +12 -12
  134. package/dist/lib/memory/mem0Initializer.d.ts +2 -2
  135. package/dist/lib/neurolink.d.ts +61 -2
  136. package/dist/lib/neurolink.js +619 -307
  137. package/dist/lib/processors/archive/ArchiveProcessor.d.ts +327 -0
  138. package/dist/lib/processors/archive/ArchiveProcessor.js +1309 -0
  139. package/dist/lib/processors/archive/index.d.ts +33 -0
  140. package/dist/lib/processors/archive/index.js +43 -0
  141. package/dist/lib/processors/base/types.d.ts +70 -64
  142. package/dist/lib/processors/base/types.js +6 -0
  143. package/dist/lib/processors/cli/fileProcessorCli.d.ts +8 -8
  144. package/dist/lib/processors/cli/fileProcessorCli.js +5 -5
  145. package/dist/lib/processors/config/mimeTypes.js +25 -0
  146. package/dist/lib/processors/config/sizeLimits.d.ts +52 -40
  147. package/dist/lib/processors/config/sizeLimits.js +56 -44
  148. package/dist/lib/processors/document/ExcelProcessor.d.ts +14 -0
  149. package/dist/lib/processors/document/ExcelProcessor.js +72 -1
  150. package/dist/lib/processors/document/PptxProcessor.d.ts +63 -0
  151. package/dist/lib/processors/document/PptxProcessor.js +158 -0
  152. package/dist/lib/processors/document/index.d.ts +1 -0
  153. package/dist/lib/processors/document/index.js +6 -0
  154. package/dist/lib/processors/errors/FileErrorCode.d.ts +2 -2
  155. package/dist/lib/processors/errors/errorHelpers.d.ts +2 -2
  156. package/dist/lib/processors/errors/errorSerializer.d.ts +4 -4
  157. package/dist/lib/processors/index.d.ts +8 -2
  158. package/dist/lib/processors/index.js +5 -2
  159. package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +8 -8
  160. package/dist/lib/processors/integration/FileProcessorIntegration.js +7 -7
  161. package/dist/lib/processors/media/AudioProcessor.d.ts +328 -0
  162. package/dist/lib/processors/media/AudioProcessor.js +708 -0
  163. package/dist/lib/processors/media/VideoProcessor.d.ts +350 -0
  164. package/dist/lib/processors/media/VideoProcessor.js +992 -0
  165. package/dist/lib/processors/media/index.d.ts +27 -0
  166. package/dist/lib/processors/media/index.js +37 -0
  167. package/dist/lib/processors/registry/ProcessorRegistry.d.ts +19 -5
  168. package/dist/lib/processors/registry/ProcessorRegistry.js +103 -8
  169. package/dist/lib/processors/registry/index.d.ts +1 -1
  170. package/dist/lib/processors/registry/index.js +1 -1
  171. package/dist/lib/processors/registry/types.d.ts +2 -2
  172. package/dist/lib/providers/googleAiStudio.d.ts +34 -0
  173. package/dist/lib/providers/googleAiStudio.js +267 -397
  174. package/dist/lib/providers/googleVertex.d.ts +55 -1
  175. package/dist/lib/providers/googleVertex.js +452 -719
  176. package/dist/lib/providers/sagemaker/detection.d.ts +6 -6
  177. package/dist/lib/providers/sagemaker/diagnostics.d.ts +4 -4
  178. package/dist/lib/providers/sagemaker/parsers.d.ts +4 -4
  179. package/dist/lib/rag/chunkers/RecursiveChunker.js +2 -2
  180. package/dist/lib/rag/document/loaders.d.ts +6 -71
  181. package/dist/lib/rag/document/loaders.js +5 -5
  182. package/dist/lib/rag/graphRag/graphRAG.js +26 -9
  183. package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +5 -55
  184. package/dist/lib/rag/metadata/metadataExtractor.js +6 -3
  185. package/dist/lib/rag/pipeline/RAGPipeline.d.ts +8 -126
  186. package/dist/lib/rag/pipeline/RAGPipeline.js +11 -11
  187. package/dist/lib/rag/pipeline/contextAssembly.d.ts +3 -42
  188. package/dist/lib/rag/pipeline/contextAssembly.js +6 -3
  189. package/dist/lib/rag/reranker/RerankerFactory.d.ts +5 -60
  190. package/dist/lib/rag/resilience/CircuitBreaker.d.ts +3 -33
  191. package/dist/lib/rag/resilience/RetryHandler.d.ts +2 -21
  192. package/dist/lib/rag/retrieval/hybridSearch.d.ts +3 -41
  193. package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +2 -13
  194. package/dist/lib/rag/retrieval/vectorQueryTool.js +4 -3
  195. package/dist/lib/rag/types.d.ts +3 -3
  196. package/dist/lib/sdk/toolRegistration.d.ts +2 -2
  197. package/dist/lib/server/middleware/cache.d.ts +2 -2
  198. package/dist/lib/server/middleware/rateLimit.d.ts +2 -2
  199. package/dist/lib/server/routes/mcpRoutes.js +277 -249
  200. package/dist/lib/server/routes/memoryRoutes.js +287 -281
  201. package/dist/lib/server/utils/validation.d.ts +10 -10
  202. package/dist/lib/session/globalSessionState.d.ts +2 -2
  203. package/dist/lib/telemetry/telemetryService.d.ts +2 -2
  204. package/dist/lib/types/common.d.ts +39 -0
  205. package/dist/lib/types/contextTypes.d.ts +255 -0
  206. package/dist/lib/types/contextTypes.js +0 -2
  207. package/dist/lib/types/conversation.d.ts +62 -0
  208. package/dist/lib/types/conversationMemoryInterface.d.ts +27 -0
  209. package/dist/lib/types/conversationMemoryInterface.js +7 -0
  210. package/dist/lib/types/fileReferenceTypes.d.ts +222 -0
  211. package/dist/lib/types/fileReferenceTypes.js +9 -0
  212. package/dist/lib/types/fileTypes.d.ts +26 -3
  213. package/dist/lib/types/generateTypes.d.ts +22 -1
  214. package/dist/lib/types/index.d.ts +4 -5
  215. package/dist/lib/types/index.js +8 -10
  216. package/dist/lib/types/modelTypes.d.ts +2 -2
  217. package/dist/lib/types/processorTypes.d.ts +597 -0
  218. package/dist/lib/types/processorTypes.js +91 -0
  219. package/dist/lib/types/ragTypes.d.ts +481 -0
  220. package/dist/lib/types/ragTypes.js +8 -0
  221. package/dist/lib/types/sdkTypes.d.ts +17 -18
  222. package/dist/lib/types/streamTypes.d.ts +11 -1
  223. package/dist/lib/utils/async/retry.d.ts +2 -2
  224. package/dist/lib/utils/async/withTimeout.js +3 -1
  225. package/dist/lib/utils/conversationMemory.d.ts +12 -6
  226. package/dist/lib/utils/conversationMemory.js +76 -36
  227. package/dist/lib/utils/fileDetector.d.ts +62 -0
  228. package/dist/lib/utils/fileDetector.js +1014 -14
  229. package/dist/lib/utils/json/safeParse.d.ts +2 -2
  230. package/dist/lib/utils/messageBuilder.js +806 -153
  231. package/dist/lib/utils/modelChoices.d.ts +2 -2
  232. package/dist/lib/utils/multimodalOptionsBuilder.d.ts +2 -1
  233. package/dist/lib/utils/multimodalOptionsBuilder.js +1 -0
  234. package/dist/lib/utils/rateLimiter.d.ts +2 -2
  235. package/dist/lib/utils/sanitizers/filename.d.ts +4 -4
  236. package/dist/lib/utils/sanitizers/svg.d.ts +2 -2
  237. package/dist/lib/utils/thinkingConfig.d.ts +6 -6
  238. package/dist/lib/utils/tokenEstimation.d.ts +68 -0
  239. package/dist/lib/utils/tokenEstimation.js +113 -0
  240. package/dist/lib/utils/tokenUtils.d.ts +4 -4
  241. package/dist/lib/utils/ttsProcessor.d.ts +2 -2
  242. package/dist/lib/workflow/config.d.ts +150 -150
  243. package/dist/memory/mem0Initializer.d.ts +2 -2
  244. package/dist/neurolink.d.ts +61 -2
  245. package/dist/neurolink.js +619 -307
  246. package/dist/processors/archive/ArchiveProcessor.d.ts +327 -0
  247. package/dist/processors/archive/ArchiveProcessor.js +1308 -0
  248. package/dist/processors/archive/index.d.ts +33 -0
  249. package/dist/processors/archive/index.js +42 -0
  250. package/dist/processors/base/types.d.ts +70 -64
  251. package/dist/processors/base/types.js +6 -0
  252. package/dist/processors/cli/fileProcessorCli.d.ts +8 -8
  253. package/dist/processors/cli/fileProcessorCli.js +5 -5
  254. package/dist/processors/config/mimeTypes.js +25 -0
  255. package/dist/processors/config/sizeLimits.d.ts +52 -40
  256. package/dist/processors/config/sizeLimits.js +56 -44
  257. package/dist/processors/document/ExcelProcessor.d.ts +14 -0
  258. package/dist/processors/document/ExcelProcessor.js +72 -1
  259. package/dist/processors/document/PptxProcessor.d.ts +63 -0
  260. package/dist/processors/document/PptxProcessor.js +157 -0
  261. package/dist/processors/document/index.d.ts +1 -0
  262. package/dist/processors/document/index.js +6 -0
  263. package/dist/processors/errors/FileErrorCode.d.ts +2 -2
  264. package/dist/processors/errors/errorHelpers.d.ts +2 -2
  265. package/dist/processors/errors/errorSerializer.d.ts +4 -4
  266. package/dist/processors/index.d.ts +8 -2
  267. package/dist/processors/index.js +5 -2
  268. package/dist/processors/integration/FileProcessorIntegration.d.ts +8 -8
  269. package/dist/processors/integration/FileProcessorIntegration.js +7 -7
  270. package/dist/processors/media/AudioProcessor.d.ts +328 -0
  271. package/dist/processors/media/AudioProcessor.js +707 -0
  272. package/dist/processors/media/VideoProcessor.d.ts +350 -0
  273. package/dist/processors/media/VideoProcessor.js +991 -0
  274. package/dist/processors/media/ffprobe-static.d.ts +4 -0
  275. package/dist/processors/media/index.d.ts +27 -0
  276. package/dist/processors/media/index.js +36 -0
  277. package/dist/processors/registry/ProcessorRegistry.d.ts +19 -5
  278. package/dist/processors/registry/ProcessorRegistry.js +103 -8
  279. package/dist/processors/registry/index.d.ts +1 -1
  280. package/dist/processors/registry/index.js +1 -1
  281. package/dist/processors/registry/types.d.ts +2 -2
  282. package/dist/providers/googleAiStudio.d.ts +34 -0
  283. package/dist/providers/googleAiStudio.js +267 -397
  284. package/dist/providers/googleVertex.d.ts +55 -1
  285. package/dist/providers/googleVertex.js +452 -719
  286. package/dist/providers/sagemaker/detection.d.ts +6 -6
  287. package/dist/providers/sagemaker/diagnostics.d.ts +4 -4
  288. package/dist/providers/sagemaker/parsers.d.ts +4 -4
  289. package/dist/rag/chunkers/RecursiveChunker.js +2 -2
  290. package/dist/rag/document/loaders.d.ts +6 -71
  291. package/dist/rag/document/loaders.js +5 -5
  292. package/dist/rag/graphRag/graphRAG.js +26 -9
  293. package/dist/rag/metadata/MetadataExtractorFactory.d.ts +5 -55
  294. package/dist/rag/metadata/metadataExtractor.js +6 -3
  295. package/dist/rag/pipeline/RAGPipeline.d.ts +8 -126
  296. package/dist/rag/pipeline/RAGPipeline.js +11 -11
  297. package/dist/rag/pipeline/contextAssembly.d.ts +3 -42
  298. package/dist/rag/pipeline/contextAssembly.js +6 -3
  299. package/dist/rag/reranker/RerankerFactory.d.ts +5 -60
  300. package/dist/rag/resilience/CircuitBreaker.d.ts +3 -33
  301. package/dist/rag/resilience/RetryHandler.d.ts +2 -21
  302. package/dist/rag/retrieval/hybridSearch.d.ts +3 -41
  303. package/dist/rag/retrieval/vectorQueryTool.d.ts +2 -13
  304. package/dist/rag/retrieval/vectorQueryTool.js +4 -3
  305. package/dist/rag/types.d.ts +3 -3
  306. package/dist/sdk/toolRegistration.d.ts +2 -2
  307. package/dist/server/middleware/cache.d.ts +2 -2
  308. package/dist/server/middleware/rateLimit.d.ts +2 -2
  309. package/dist/server/routes/mcpRoutes.js +277 -249
  310. package/dist/server/routes/memoryRoutes.js +287 -281
  311. package/dist/server/utils/validation.d.ts +4 -4
  312. package/dist/session/globalSessionState.d.ts +2 -2
  313. package/dist/telemetry/telemetryService.d.ts +2 -2
  314. package/dist/types/common.d.ts +39 -0
  315. package/dist/types/contextTypes.d.ts +255 -0
  316. package/dist/types/contextTypes.js +0 -2
  317. package/dist/types/conversation.d.ts +62 -0
  318. package/dist/types/conversationMemoryInterface.d.ts +27 -0
  319. package/dist/types/conversationMemoryInterface.js +6 -0
  320. package/dist/types/fileReferenceTypes.d.ts +222 -0
  321. package/dist/types/fileReferenceTypes.js +8 -0
  322. package/dist/types/fileTypes.d.ts +26 -3
  323. package/dist/types/generateTypes.d.ts +22 -1
  324. package/dist/types/index.d.ts +4 -5
  325. package/dist/types/index.js +8 -10
  326. package/dist/types/processorTypes.d.ts +597 -0
  327. package/dist/types/processorTypes.js +90 -0
  328. package/dist/types/ragTypes.d.ts +481 -0
  329. package/dist/types/ragTypes.js +7 -0
  330. package/dist/types/sdkTypes.d.ts +17 -18
  331. package/dist/types/streamTypes.d.ts +11 -1
  332. package/dist/utils/async/retry.d.ts +2 -2
  333. package/dist/utils/async/withTimeout.js +3 -1
  334. package/dist/utils/conversationMemory.d.ts +12 -6
  335. package/dist/utils/conversationMemory.js +76 -36
  336. package/dist/utils/fileDetector.d.ts +62 -0
  337. package/dist/utils/fileDetector.js +1014 -14
  338. package/dist/utils/json/safeParse.d.ts +2 -2
  339. package/dist/utils/messageBuilder.js +806 -153
  340. package/dist/utils/modelChoices.d.ts +2 -2
  341. package/dist/utils/multimodalOptionsBuilder.d.ts +2 -1
  342. package/dist/utils/multimodalOptionsBuilder.js +1 -0
  343. package/dist/utils/rateLimiter.d.ts +2 -2
  344. package/dist/utils/sanitizers/filename.d.ts +4 -4
  345. package/dist/utils/sanitizers/svg.d.ts +2 -2
  346. package/dist/utils/thinkingConfig.d.ts +6 -6
  347. package/dist/utils/tokenEstimation.d.ts +68 -0
  348. package/dist/utils/tokenEstimation.js +112 -0
  349. package/dist/utils/tokenUtils.d.ts +4 -4
  350. package/dist/utils/ttsProcessor.d.ts +2 -2
  351. package/dist/workflow/config.d.ts +104 -104
  352. package/package.json +18 -6
  353. package/dist/lib/utils/conversationMemoryUtils.d.ts +0 -25
  354. package/dist/lib/utils/conversationMemoryUtils.js +0 -138
  355. package/dist/utils/conversationMemoryUtils.d.ts +0 -25
  356. package/dist/utils/conversationMemoryUtils.js +0 -137
@@ -0,0 +1,481 @@
1
+ /**
2
+ * RAG Type Definitions
3
+ *
4
+ * Canonical type file for all RAG (Retrieval-Augmented Generation) interfaces.
5
+ * All exported interfaces from src/lib/rag/ are collected here as type aliases.
6
+ */
7
+ import type { BaseChunkerConfig, BM25Result, Chunk, ChunkingStrategy, DocumentType, ExtractionResult, ExtractParams, HybridSearchConfig, MetadataFilter, RerankResult, RerankerOptions, VectorQueryResult } from "../rag/types.js";
8
+ /**
9
+ * Citation format options
10
+ */
11
+ export type CitationFormat = "inline" | "footnote" | "numbered" | "none";
12
+ /**
13
+ * Chunker type - all chunking strategies implement this
14
+ */
15
+ export type Chunker = {
16
+ /** Strategy name for identification */
17
+ readonly strategy: ChunkingStrategy;
18
+ /**
19
+ * Split text into chunks
20
+ * @param text - The text to chunk
21
+ * @param config - Strategy-specific configuration
22
+ * @returns Array of chunks
23
+ */
24
+ chunk(text: string, config?: BaseChunkerConfig): Promise<Chunk[]>;
25
+ };
26
+ /**
27
+ * Context assembly options
28
+ */
29
+ export type ContextAssemblyOptions = {
30
+ /** Maximum characters in assembled context */
31
+ maxChars?: number;
32
+ /** Maximum tokens (approximate, 4 chars/token) */
33
+ maxTokens?: number;
34
+ /** Citation format to use */
35
+ citationFormat?: CitationFormat;
36
+ /** Separator between chunks */
37
+ separator?: string;
38
+ /** Include chunk metadata in context */
39
+ includeMetadata?: boolean;
40
+ /** Deduplicate overlapping content */
41
+ deduplicate?: boolean;
42
+ /** Similarity threshold for deduplication (0-1) */
43
+ dedupeThreshold?: number;
44
+ /** Order by relevance score */
45
+ orderByRelevance?: boolean;
46
+ /** Include section headers */
47
+ includeSectionHeaders?: boolean;
48
+ /** Header template (use {index}, {source}, {score} placeholders) */
49
+ headerTemplate?: string;
50
+ };
51
+ /**
52
+ * Context window representation
53
+ */
54
+ export type ContextWindow = {
55
+ /** Assembled context text */
56
+ text: string;
57
+ /** Number of chunks included */
58
+ chunkCount: number;
59
+ /** Total character count */
60
+ charCount: number;
61
+ /** Estimated token count */
62
+ tokenCount: number;
63
+ /** Chunks that were truncated/excluded */
64
+ truncatedChunks: number;
65
+ /** Citation map (id -> citation text) */
66
+ citations: Map<string, string>;
67
+ };
68
+ /**
69
+ * Supported metadata extractor types
70
+ */
71
+ export type MetadataExtractorType = "llm" | "title" | "summary" | "keywords" | "questions" | "custom" | "composite";
72
+ /**
73
+ * Metadata Extractor type - all extractors implement this
74
+ */
75
+ export type MetadataExtractor = {
76
+ /** Extractor type identifier */
77
+ readonly type: MetadataExtractorType;
78
+ /**
79
+ * Extract metadata from chunks
80
+ * @param chunks - Array of chunks to extract metadata from
81
+ * @param params - Extraction parameters
82
+ * @returns Array of extraction results
83
+ */
84
+ extract(chunks: Chunk[], params?: ExtractParams): Promise<ExtractionResult[]>;
85
+ };
86
+ /**
87
+ * Metadata extractor configuration
88
+ */
89
+ export type MetadataExtractorConfig = {
90
+ /** Extractor type */
91
+ type: MetadataExtractorType;
92
+ /** Language model provider */
93
+ provider?: string;
94
+ /** Model name for LLM-based extraction */
95
+ modelName?: string;
96
+ /** Custom prompt template */
97
+ promptTemplate?: string;
98
+ /** Maximum tokens for LLM response */
99
+ maxTokens?: number;
100
+ /** Temperature for LLM generation */
101
+ temperature?: number;
102
+ };
103
+ /**
104
+ * Metadata extractor metadata for discovery and documentation
105
+ */
106
+ export type MetadataExtractorMetadata = {
107
+ /** Human-readable description */
108
+ description: string;
109
+ /** Default configuration */
110
+ defaultConfig: Partial<MetadataExtractorConfig>;
111
+ /** Supported configuration options */
112
+ supportedOptions: string[];
113
+ /** Recommended use cases */
114
+ useCases: string[];
115
+ /** Alternative names for this extractor */
116
+ aliases: string[];
117
+ /** Whether this extractor requires an AI model */
118
+ requiresModel: boolean;
119
+ /** Extraction types this extractor can produce */
120
+ extractionTypes: string[];
121
+ };
122
+ /**
123
+ * RAG-specific retry configuration
124
+ */
125
+ export type RAGRetryConfig = {
126
+ /** Maximum number of retry attempts (default: 3) */
127
+ maxRetries: number;
128
+ /** Initial delay in ms (default: 1000) */
129
+ initialDelay: number;
130
+ /** Maximum delay in ms (default: 30000) */
131
+ maxDelay: number;
132
+ /** Backoff multiplier (default: 2) */
133
+ backoffMultiplier: number;
134
+ /** Whether to add jitter (default: true) */
135
+ jitter: boolean;
136
+ /** Custom function to determine if error is retryable */
137
+ shouldRetry?: (error: Error) => boolean;
138
+ /** Retryable error codes */
139
+ retryableErrorCodes?: string[];
140
+ /** Retryable HTTP status codes */
141
+ retryableStatusCodes?: number[];
142
+ };
143
+ /**
144
+ * Circuit breaker configuration
145
+ */
146
+ export type RAGCircuitBreakerConfig = {
147
+ /** Number of failures before opening circuit (default: 5) */
148
+ failureThreshold: number;
149
+ /** Time in ms before attempting reset (default: 60000) */
150
+ resetTimeout: number;
151
+ /** Max calls allowed in half-open state (default: 3) */
152
+ halfOpenMaxCalls: number;
153
+ /** Operation timeout in ms (default: 30000) */
154
+ operationTimeout: number;
155
+ /** Minimum calls before calculating failure rate (default: 10) */
156
+ minimumCallsBeforeCalculation: number;
157
+ /** Time window for statistics in ms (default: 300000 - 5 minutes) */
158
+ statisticsWindowSize: number;
159
+ };
160
+ /**
161
+ * Circuit breaker statistics
162
+ */
163
+ export type RAGCircuitBreakerStats = {
164
+ state: CircuitState;
165
+ totalCalls: number;
166
+ successfulCalls: number;
167
+ failedCalls: number;
168
+ failureRate: number;
169
+ windowCalls: number;
170
+ lastStateChange: Date;
171
+ nextRetryTime?: Date;
172
+ halfOpenCalls: number;
173
+ averageLatency: number;
174
+ p95Latency: number;
175
+ };
176
+ import type { CircuitState } from "../rag/resilience/CircuitBreaker.js";
177
+ /**
178
+ * Embedding model configuration
179
+ */
180
+ export type EmbeddingModelConfig = {
181
+ provider: string;
182
+ modelName: string;
183
+ };
184
+ /**
185
+ * Generation model configuration
186
+ */
187
+ export type GenerationModelConfig = {
188
+ provider: string;
189
+ modelName: string;
190
+ temperature?: number;
191
+ maxTokens?: number;
192
+ };
193
+ /**
194
+ * RAG pipeline configuration
195
+ */
196
+ export type RAGPipelineConfig = {
197
+ /** Pipeline identifier */
198
+ id?: string;
199
+ /** Vector store instance (defaults to in-memory) */
200
+ vectorStore?: VectorStore;
201
+ /** BM25 index for hybrid search (defaults to in-memory) */
202
+ bm25Index?: BM25Index;
203
+ /** Index name for vector store */
204
+ indexName?: string;
205
+ /** Embedding model configuration */
206
+ embeddingModel: EmbeddingModelConfig;
207
+ /** Generation model configuration (for RAG responses) */
208
+ generationModel?: GenerationModelConfig;
209
+ /** Default chunking strategy */
210
+ defaultChunkingStrategy?: ChunkingStrategy;
211
+ /** Default chunk size */
212
+ defaultChunkSize?: number;
213
+ /** Default chunk overlap */
214
+ defaultChunkOverlap?: number;
215
+ /** Enable hybrid search (vector + BM25) */
216
+ enableHybridSearch?: boolean;
217
+ /** Enable Graph RAG */
218
+ enableGraphRAG?: boolean;
219
+ /** Graph RAG similarity threshold */
220
+ graphThreshold?: number;
221
+ /** Default number of results to retrieve */
222
+ defaultTopK?: number;
223
+ /** Enable reranking */
224
+ enableReranking?: boolean;
225
+ /** Reranking model configuration */
226
+ rerankingModel?: EmbeddingModelConfig;
227
+ };
228
+ /**
229
+ * Ingestion options
230
+ */
231
+ export type IngestOptions = {
232
+ /** Chunking strategy override */
233
+ strategy?: ChunkingStrategy;
234
+ /** Chunk size override */
235
+ chunkSize?: number;
236
+ /** Chunk overlap override */
237
+ chunkOverlap?: number;
238
+ /** Custom metadata to add */
239
+ metadata?: Record<string, unknown>;
240
+ /** Extract metadata using LLM */
241
+ extractMetadata?: boolean;
242
+ };
243
+ /**
244
+ * Query options
245
+ */
246
+ export type QueryOptions = {
247
+ /** Number of chunks to retrieve */
248
+ topK?: number;
249
+ /** Use hybrid search */
250
+ hybrid?: boolean;
251
+ /** Use Graph RAG */
252
+ graph?: boolean;
253
+ /** Enable reranking */
254
+ rerank?: boolean;
255
+ /** Metadata filter */
256
+ filter?: Record<string, unknown>;
257
+ /** Include sources in response */
258
+ includeSources?: boolean;
259
+ /** Generate response (vs just retrieve) */
260
+ generate?: boolean;
261
+ /** Custom system prompt for generation */
262
+ systemPrompt?: string;
263
+ /** Temperature for generation */
264
+ temperature?: number;
265
+ };
266
+ /**
267
+ * Query response
268
+ */
269
+ export type RAGResponse = {
270
+ /** Generated answer (if generate=true) */
271
+ answer?: string;
272
+ /** Retrieved context chunks */
273
+ context: string;
274
+ /** Source documents/chunks */
275
+ sources: Array<{
276
+ id: string;
277
+ text: string;
278
+ score: number;
279
+ metadata?: Record<string, unknown>;
280
+ }>;
281
+ /** Query metadata */
282
+ metadata: {
283
+ queryTime: number;
284
+ retrievalMethod: string;
285
+ chunksRetrieved: number;
286
+ reranked: boolean;
287
+ };
288
+ };
289
+ /**
290
+ * Pipeline statistics
291
+ */
292
+ export type PipelineStats = {
293
+ totalDocuments: number;
294
+ totalChunks: number;
295
+ indexName: string;
296
+ embeddingDimension?: number;
297
+ hybridSearchEnabled: boolean;
298
+ graphRAGEnabled: boolean;
299
+ };
300
+ /**
301
+ * Supported reranker types
302
+ */
303
+ export type RerankerType = "llm" | "cross-encoder" | "cohere" | "simple" | "batch";
304
+ /**
305
+ * Reranker type - all rerankers implement this
306
+ */
307
+ export type Reranker = {
308
+ /** Reranker type identifier */
309
+ readonly type: RerankerType;
310
+ /**
311
+ * Rerank results based on query relevance
312
+ * @param results - Vector search results to rerank
313
+ * @param query - Original search query
314
+ * @param options - Reranking options
315
+ * @returns Reranked results with scores
316
+ */
317
+ rerank(results: VectorQueryResult[], query: string, options?: RerankerOptions): Promise<RerankResult[]>;
318
+ };
319
+ /**
320
+ * Reranker configuration
321
+ */
322
+ export type RerankerConfig = {
323
+ /** Reranker type */
324
+ type: RerankerType;
325
+ /** Model name for LLM-based rerankers */
326
+ model?: string;
327
+ /** Provider for the model */
328
+ provider?: string;
329
+ /** Number of results to return after reranking */
330
+ topK?: number;
331
+ /** Scoring weights */
332
+ weights?: {
333
+ semantic?: number;
334
+ vector?: number;
335
+ position?: number;
336
+ };
337
+ /** API key for external services (e.g., Cohere) */
338
+ apiKey?: string;
339
+ };
340
+ /**
341
+ * Reranker metadata for discovery and documentation
342
+ */
343
+ export type RerankerMetadata = {
344
+ /** Human-readable description */
345
+ description: string;
346
+ /** Default configuration */
347
+ defaultConfig: Partial<RerankerConfig>;
348
+ /** Supported configuration options */
349
+ supportedOptions: string[];
350
+ /** Recommended use cases */
351
+ useCases: string[];
352
+ /** Alternative names for this reranker */
353
+ aliases: string[];
354
+ /** Whether this reranker requires an AI model */
355
+ requiresModel: boolean;
356
+ /** Whether this reranker requires external API */
357
+ requiresExternalAPI: boolean;
358
+ };
359
+ /**
360
+ * BM25 Index type
361
+ * Implementations should provide sparse retrieval capabilities
362
+ */
363
+ export type BM25Index = {
364
+ /**
365
+ * Search documents using BM25 algorithm
366
+ * @param query - Search query string
367
+ * @param topK - Number of results to return
368
+ * @returns Array of BM25 results
369
+ */
370
+ search(query: string, topK?: number): Promise<BM25Result[]>;
371
+ /**
372
+ * Add documents to the index
373
+ * @param documents - Documents to index
374
+ */
375
+ addDocuments(documents: Array<{
376
+ id: string;
377
+ text: string;
378
+ metadata?: Record<string, unknown>;
379
+ }>): Promise<void>;
380
+ };
381
+ /**
382
+ * Hybrid search configuration for creating a search function
383
+ */
384
+ export type HybridSearchOptions = {
385
+ /** Vector store instance */
386
+ vectorStore: VectorStore;
387
+ /** BM25 index instance */
388
+ bm25Index: BM25Index;
389
+ /** Index name for vector store */
390
+ indexName: string;
391
+ /** Embedding model configuration (optional - uses defaults from ProviderFactory if not specified) */
392
+ embeddingModel?: {
393
+ provider?: string;
394
+ modelName?: string;
395
+ };
396
+ /** Default search configuration */
397
+ defaultConfig?: HybridSearchConfig;
398
+ };
399
+ /**
400
+ * Abstract vector store type
401
+ * Vector stores should implement this type to work with the query tool
402
+ */
403
+ export type VectorStore = {
404
+ query(params: {
405
+ indexName: string;
406
+ queryVector: number[];
407
+ topK?: number;
408
+ filter?: MetadataFilter;
409
+ includeVectors?: boolean;
410
+ }): Promise<VectorQueryResult[]>;
411
+ };
412
+ /**
413
+ * Document loader options
414
+ */
415
+ export type LoaderOptions = {
416
+ /** Custom metadata to add to document */
417
+ metadata?: Record<string, unknown>;
418
+ /** Encoding for text files */
419
+ encoding?: BufferEncoding;
420
+ /** Document type override */
421
+ type?: DocumentType;
422
+ };
423
+ /**
424
+ * Web loader options
425
+ */
426
+ export type WebLoaderOptions = LoaderOptions & {
427
+ /** Request timeout in milliseconds */
428
+ timeout?: number;
429
+ /** Custom headers for request */
430
+ headers?: Record<string, string>;
431
+ /** Extract only main content (remove navigation, ads, etc.) */
432
+ extractMainContent?: boolean;
433
+ /** Selector for main content (CSS selector) */
434
+ contentSelector?: string;
435
+ /** User agent string */
436
+ userAgent?: string;
437
+ };
438
+ /**
439
+ * PDF loader options
440
+ */
441
+ export type PDFLoaderOptions = LoaderOptions & {
442
+ /** Page range to extract (e.g., "1-5" or "1,3,5") */
443
+ pageRange?: string;
444
+ /** Extract images as base64 */
445
+ extractImages?: boolean;
446
+ /** OCR for scanned documents */
447
+ enableOCR?: boolean;
448
+ /** Preserve layout formatting */
449
+ preserveLayout?: boolean;
450
+ };
451
+ /**
452
+ * CSV loader options
453
+ */
454
+ export type CSVLoaderOptions = LoaderOptions & {
455
+ /** Delimiter character */
456
+ delimiter?: string;
457
+ /** Whether first row is header */
458
+ hasHeader?: boolean;
459
+ /** Column names (if no header) */
460
+ columns?: string[];
461
+ /** Output format */
462
+ outputFormat?: "text" | "json" | "markdown";
463
+ };
464
+ /**
465
+ * Abstract document loader type
466
+ */
467
+ export type DocumentLoader = {
468
+ /**
469
+ * Load document from source
470
+ * @param source - File path, URL, or content
471
+ * @param options - Loader options
472
+ * @returns Promise resolving to MDocument
473
+ */
474
+ load(source: string, options?: LoaderOptions): Promise<import("../rag/document/MDocument.js").MDocument>;
475
+ /**
476
+ * Check if loader can handle the source
477
+ * @param source - File path, URL, or content
478
+ * @returns True if loader can handle the source
479
+ */
480
+ canHandle(source: string): boolean;
481
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * RAG Type Definitions
3
+ *
4
+ * Canonical type file for all RAG (Retrieval-Augmented Generation) interfaces.
5
+ * All exported interfaces from src/lib/rag/ are collected here as type aliases.
6
+ */
7
+ export {};
@@ -5,21 +5,20 @@
5
5
  * when integrating with the NeuroLink SDK. Maximum type exposure for
6
6
  * comprehensive TypeScript support across the NeuroLink ecosystem.
7
7
  */
8
- export type { StreamResult, StreamingProgressData, StreamingMetadata, ProgressCallback, ToolCall as StreamToolCall, // Note: Renamed in main index to avoid conflict with tools.js ToolCall
9
- ToolResult as StreamToolResult, // Note: Renamed in main index to avoid conflict with tools.js ToolResult
10
- ToolCallResults, ToolCalls, StreamOptions, StreamingOptions, EnhancedStreamProvider, StreamTextResult, AISDKUsage, StreamAnalyticsCollector, ResponseMetadata, AudioInputSpec, AudioChunk, PCMEncoding, } from "./streamTypes.js";
11
- export type { TypedEventEmitter, NeuroLinkEvents, StreamEvent, AsyncFunction, SyncFunction, AnyFunction, } from "./common.js";
12
- export type { NeuroLinkConfig, ProviderConfig, PerformanceConfig, CacheConfig, FallbackConfig, RetryConfig, AnalyticsConfig, ToolConfig, BackupInfo, BackupMetadata, ConfigValidationResult, ConfigUpdateOptions, } from "./configTypes.js";
13
- export type { AISDKModel, ProviderError, AIModelProviderConfig, ProviderName, ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, ProviderCapabilities, } from "./providers.js";
14
- export type { GenerateOptions, GenerateResult as GenerateApiResult, // Renamed to avoid conflict with cli.js GenerateResult
15
- UnifiedGenerationOptions, EnhancedProvider, FactoryEnhancedProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, } from "./generateTypes.js";
16
- export type { TokenUsage, AnalyticsData } from "./analytics.js";
17
- export type { TextContent, ImageContent, Content, VisionCapability, ProviderImageFormat, ProcessedImage, MultimodalMessage, ProviderMultimodalPayload, } from "./content.js";
18
- export type { MCPTransportType, MCPServerConnectionStatus, MCPServerCategory, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPToolInfo, MCPExecutableTool, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, } from "./mcpTypes.js";
19
- export type { ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolInfo, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPToolContext, ExternalMCPToolResult, ExternalMCPServerEvents, ExternalMCPManagerConfig, } from "./externalMcp.js";
20
- export type { BaseCommandArgs, GenerateCommandArgs, MCPCommandArgs, ModelsCommandArgs, CommandResult, GenerateResult as CLIGenerateResult, StreamChunk, } from "./cli.js";
21
- export type { Unknown, UnknownRecord, UnknownArray, JsonValue, JsonObject, JsonArray, ErrorInfo, Result, FunctionParameters, } from "./common.js";
22
- export type { EvaluationData, EvaluationContext, EnhancedEvaluationResult, EvaluationRequest, EvaluationCriteria, } from "./evaluation.js";
23
- export type { TaskType, TaskClassification, ClassificationScores, ClassificationStats, ClassificationValidation, } from "./taskClassificationTypes.js";
24
- export type { DomainType, DomainConfig, DomainTemplate, DomainConfigOptions, DomainEvaluationCriteria, DomainValidationRule, } from "./domainTypes.js";
25
- export type { ConversationMemoryConfig, SessionMemory, ChatMessage, MessageContent, MultimodalChatMessage, ConversationMemoryEvents, ConversationMemoryError, SessionIdentifier, SessionMetadata, RedisConversationObject, RedisStorageConfig, StoreConversationTurnOptions, } from "./conversation.js";
8
+ export type { AnyFunction, AsyncFunction, NeuroLinkEvents, StreamEvent, SyncFunction, TypedEventEmitter, } from "./common.js";
9
+ export type { AnalyticsConfig, BackupInfo, BackupMetadata, CacheConfig, ConfigUpdateOptions, ConfigValidationResult, FallbackConfig, NeuroLinkConfig, PerformanceConfig, ProviderConfig, RetryConfig, ToolConfig, } from "./configTypes.js";
10
+ export type { AISDKUsage, AudioChunk, AudioInputSpec, EnhancedStreamProvider, PCMEncoding, ProgressCallback, ResponseMetadata, StreamAnalyticsCollector, StreamingMetadata, StreamingOptions, StreamingProgressData, StreamOptions, StreamResult, StreamTextResult, ToolCall as StreamToolCall, // Note: Renamed in main index to avoid conflict with tools.js ToolCall
11
+ ToolCallResults, ToolCalls, ToolResult as StreamToolResult, } from "./streamTypes.js";
12
+ export type { AnalyticsData, TokenUsage } from "./analytics.js";
13
+ export type { BaseCommandArgs, CommandResult, GenerateCommandArgs, GenerateResult as CLIGenerateResult, MCPCommandArgs, ModelsCommandArgs, StreamChunk, } from "./cli.js";
14
+ export type { ErrorInfo, FunctionParameters, JsonArray, JsonObject, JsonValue, ProcessResult, Result, TestFunction, TestResult, Unknown, UnknownArray, UnknownRecord, } from "./common.js";
15
+ export type { Content, ImageContent, MultimodalMessage, ProcessedImage, ProviderImageFormat, ProviderMultimodalPayload, TextContent, VisionCapability, } from "./content.js";
16
+ export type { ChatMessage, ConversationMemoryConfig, ConversationMemoryError, ConversationMemoryEvents, MessageContent, MultimodalChatMessage, RedisConversationObject, RedisStorageConfig, SessionIdentifier, SessionMemory, SessionMetadata, StoreConversationTurnOptions, } from "./conversation.js";
17
+ export type { DomainConfig, DomainConfigOptions, DomainEvaluationCriteria, DomainTemplate, DomainType, DomainValidationRule, } from "./domainTypes.js";
18
+ export type { EnhancedEvaluationResult, EvaluationContext, EvaluationCriteria, EvaluationData, EvaluationRequest, } from "./evaluation.js";
19
+ export type { ExternalMCPConfigValidation, ExternalMCPManagerConfig, ExternalMCPOperationResult, ExternalMCPServerEvents, ExternalMCPServerHealth, ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolContext, ExternalMCPToolInfo, ExternalMCPToolResult, } from "./externalMcp.js";
20
+ export type { EnhancedGenerateResult, EnhancedProvider, FactoryEnhancedProvider, GenerateOptions, GenerateResult as GenerateApiResult, // Renamed to avoid conflict with cli.js GenerateResult
21
+ TextGenerationOptions, TextGenerationResult, UnifiedGenerationOptions, } from "./generateTypes.js";
22
+ export type { MCPConnectedServer, MCPDiscoveredServer, MCPExecutableTool, MCPServerCategory, MCPServerConnectionStatus, MCPServerMetadata, MCPServerRegistryEntry, MCPServerStatus, MCPToolInfo, MCPToolMetadata, MCPTransportType, } from "./mcpTypes.js";
23
+ export type { AIModelProviderConfig, AISDKModel, ModelCapability, ModelFilter, ModelPricing, ModelResolutionContext, ModelStats, ModelUseCase, ProviderCapabilities, ProviderError, ProviderName, } from "./providers.js";
24
+ export type { ClassificationScores, ClassificationStats, ClassificationValidation, TaskClassification, TaskType, } from "./taskClassificationTypes.js";
@@ -202,7 +202,7 @@ export type StreamOptions = {
202
202
  csvFiles?: Array<Buffer | string>;
203
203
  pdfFiles?: Array<Buffer | string>;
204
204
  videoFiles?: Array<Buffer | string>;
205
- files?: Array<Buffer | string>;
205
+ files?: Array<Buffer | string | import("./fileTypes.js").FileWithMetadata>;
206
206
  content?: Content[];
207
207
  };
208
208
  output?: {
@@ -370,6 +370,16 @@ export type StreamOptions = {
370
370
  * ```
371
371
  */
372
372
  rag?: RAGConfig;
373
+ /**
374
+ * File reference registry for on-demand file processing (internal).
375
+ *
376
+ * When set, files above the "tiny" size tier (>10KB) will be registered
377
+ * as lightweight references instead of being fully loaded into the prompt.
378
+ * The LLM can then access file content on-demand via file tools.
379
+ *
380
+ * @internal Set by NeuroLink SDK — not typically used directly by consumers.
381
+ */
382
+ fileRegistry?: unknown;
373
383
  };
374
384
  /**
375
385
  * Stream function result type - Primary output format for streaming
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * Configuration options for retry operations.
8
8
  */
9
- export interface RetryOptions {
9
+ export type RetryOptions = {
10
10
  /**
11
11
  * Maximum number of retry attempts (not including the initial attempt).
12
12
  * @default 3
@@ -37,7 +37,7 @@ export interface RetryOptions {
37
37
  * Useful for logging or metrics.
38
38
  */
39
39
  onRetry?: (error: Error, attempt: number, delayMs: number) => void;
40
- }
40
+ };
41
41
  /**
42
42
  * Default retry configuration.
43
43
  */
@@ -67,7 +67,9 @@ export async function withTimeout(promise, ms, message) {
67
67
  return await Promise.race([promise, timeoutPromise]);
68
68
  }
69
69
  finally {
70
- clearTimeout(timeoutId);
70
+ if (timeoutId !== undefined) {
71
+ clearTimeout(timeoutId);
72
+ }
71
73
  }
72
74
  }
73
75
  /**
@@ -2,9 +2,9 @@
2
2
  * Conversation Memory Utilities
3
3
  * Handles configuration merging and conversation memory operations
4
4
  */
5
- import type { ConversationMemoryConfig, ChatMessage, SessionMemory } from "../types/conversation.js";
6
5
  import type { ConversationMemoryManager } from "../core/conversationMemoryManager.js";
7
6
  import type { RedisConversationMemoryManager } from "../core/redisConversationMemoryManager.js";
7
+ import type { ChatMessage, ConversationMemoryConfig, SessionMemory } from "../types/conversation.js";
8
8
  import type { TextGenerationOptions, TextGenerationResult } from "../types/generateTypes.js";
9
9
  /**
10
10
  * Apply conversation memory defaults to user configuration
@@ -35,13 +35,14 @@ export declare function buildContextFromPointer(session: SessionMemory): ChatMes
35
35
  */
36
36
  export declare function createSummarizationPrompt(history: ChatMessage[], previousSummary?: string): string;
37
37
  /**
38
- * Calculate token threshold based on model's output token limit
39
- * Uses existing provider token limits as proxy for context window
38
+ * Calculate token threshold based on model's context window and available input tokens
39
+ * Uses context window registry for accurate per-provider, per-model limits
40
40
  * @param provider - AI provider name
41
41
  * @param model - Model name
42
- * @returns Token threshold (80% of model's token limit)
42
+ * @param maxTokens - Optional explicit maxTokens for output reserve calculation
43
+ * @returns Token threshold (80% of available input tokens)
43
44
  */
44
- export declare function calculateTokenThreshold(provider: string, model: string): number;
45
+ export declare function calculateTokenThreshold(provider?: string, model?: string, maxTokens?: number): number;
45
46
  /**
46
47
  * Get effective token threshold for a session
47
48
  * Priority: session override > env var > model-based (80%) > fallback
@@ -61,4 +62,9 @@ export declare function getEffectiveTokenThreshold(provider: string, model: stri
61
62
  * @param logPrefix - Prefix for log messages (e.g., "[ConversationMemory]" or "[RedisConversationMemoryManager]")
62
63
  * @returns Summary text or null if generation fails
63
64
  */
64
- export declare function generateSummary(messages: ChatMessage[], config: ConversationMemoryConfig, logPrefix?: string, previousSummary?: string): Promise<string | null>;
65
+ export declare function generateSummary(messages: ChatMessage[], config: Partial<ConversationMemoryConfig>, logPrefix?: string, previousSummary?: string): Promise<string | null>;
66
+ /**
67
+ * Check if Redis is available for conversation memory.
68
+ * Migrated from the deprecated conversationMemoryUtils.ts.
69
+ */
70
+ export declare function checkRedisAvailability(): Promise<boolean>;