@juspay/neurolink 9.5.3 → 9.7.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 (423) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +29 -25
  3. package/dist/adapters/video/vertexVideoHandler.js +3 -3
  4. package/dist/agent/directTools.d.ts +5 -5
  5. package/dist/cli/commands/config.d.ts +9 -9
  6. package/dist/cli/commands/serve.d.ts +37 -0
  7. package/dist/cli/commands/serve.js +302 -229
  8. package/dist/cli/commands/setup-anthropic.d.ts +2 -2
  9. package/dist/cli/commands/setup-azure.d.ts +2 -2
  10. package/dist/cli/commands/setup-bedrock.d.ts +2 -2
  11. package/dist/cli/commands/setup-gcp.d.ts +2 -2
  12. package/dist/cli/commands/setup-google-ai.d.ts +2 -2
  13. package/dist/cli/commands/setup-huggingface.d.ts +2 -2
  14. package/dist/cli/commands/setup-mistral.d.ts +2 -2
  15. package/dist/cli/commands/setup-openai.d.ts +2 -2
  16. package/dist/cli/commands/setup.d.ts +2 -2
  17. package/dist/cli/factories/commandFactory.js +16 -2
  18. package/dist/cli/loop/optionsSchema.d.ts +2 -2
  19. package/dist/cli/loop/optionsSchema.js +4 -0
  20. package/dist/cli/loop/session.d.ts +4 -0
  21. package/dist/cli/loop/session.js +49 -4
  22. package/dist/cli/utils/interactiveSetup.d.ts +4 -4
  23. package/dist/config/conversationMemory.d.ts +2 -0
  24. package/dist/config/conversationMemory.js +5 -5
  25. package/dist/constants/contextWindows.d.ts +46 -0
  26. package/dist/constants/contextWindows.js +156 -0
  27. package/dist/context/budgetChecker.d.ts +18 -0
  28. package/dist/context/budgetChecker.js +71 -0
  29. package/dist/context/contextCompactor.d.ts +22 -0
  30. package/dist/context/contextCompactor.js +106 -0
  31. package/dist/context/effectiveHistory.d.ts +52 -0
  32. package/dist/context/effectiveHistory.js +105 -0
  33. package/dist/context/errorDetection.d.ts +14 -0
  34. package/dist/context/errorDetection.js +124 -0
  35. package/dist/context/fileSummarizationService.d.ts +54 -0
  36. package/dist/context/fileSummarizationService.js +255 -0
  37. package/dist/context/fileSummarizer.d.ts +56 -0
  38. package/dist/context/fileSummarizer.js +145 -0
  39. package/dist/context/fileTokenBudget.d.ts +53 -0
  40. package/dist/context/fileTokenBudget.js +127 -0
  41. package/dist/context/prompts/summarizationPrompt.d.ts +17 -0
  42. package/dist/context/prompts/summarizationPrompt.js +110 -0
  43. package/dist/context/stages/fileReadDeduplicator.d.ts +10 -0
  44. package/dist/context/stages/fileReadDeduplicator.js +66 -0
  45. package/dist/context/stages/slidingWindowTruncator.d.ts +11 -0
  46. package/dist/context/stages/slidingWindowTruncator.js +42 -0
  47. package/dist/context/stages/structuredSummarizer.d.ts +10 -0
  48. package/dist/context/stages/structuredSummarizer.js +49 -0
  49. package/dist/context/stages/toolOutputPruner.d.ts +10 -0
  50. package/dist/context/stages/toolOutputPruner.js +52 -0
  51. package/dist/context/summarizationEngine.d.ts +45 -0
  52. package/dist/context/summarizationEngine.js +110 -0
  53. package/dist/context/toolOutputLimits.d.ts +17 -0
  54. package/dist/context/toolOutputLimits.js +84 -0
  55. package/dist/context/toolPairRepair.d.ts +16 -0
  56. package/dist/context/toolPairRepair.js +66 -0
  57. package/dist/core/analytics.js +11 -4
  58. package/dist/core/baseProvider.d.ts +6 -0
  59. package/dist/core/baseProvider.js +83 -14
  60. package/dist/core/conversationMemoryManager.d.ts +14 -11
  61. package/dist/core/conversationMemoryManager.js +36 -68
  62. package/dist/core/dynamicModels.js +3 -2
  63. package/dist/core/modules/GenerationHandler.js +2 -0
  64. package/dist/core/modules/MessageBuilder.d.ts +1 -1
  65. package/dist/core/modules/MessageBuilder.js +2 -0
  66. package/dist/core/modules/TelemetryHandler.d.ts +2 -3
  67. package/dist/core/modules/TelemetryHandler.js +3 -3
  68. package/dist/core/modules/ToolsManager.d.ts +2 -2
  69. package/dist/core/redisConversationMemoryManager.d.ts +19 -14
  70. package/dist/core/redisConversationMemoryManager.js +94 -86
  71. package/dist/factories/providerFactory.d.ts +2 -2
  72. package/dist/files/fileReferenceRegistry.d.ts +276 -0
  73. package/dist/files/fileReferenceRegistry.js +1543 -0
  74. package/dist/files/fileTools.d.ts +423 -0
  75. package/dist/files/fileTools.js +449 -0
  76. package/dist/files/index.d.ts +14 -0
  77. package/dist/files/index.js +13 -0
  78. package/dist/files/streamingReader.d.ts +93 -0
  79. package/dist/files/streamingReader.js +321 -0
  80. package/dist/files/types.d.ts +23 -0
  81. package/dist/files/types.js +23 -0
  82. package/dist/image-gen/imageGenTools.d.ts +2 -2
  83. package/dist/image-gen/types.d.ts +12 -12
  84. package/dist/index.d.ts +4 -0
  85. package/dist/index.js +5 -0
  86. package/dist/lib/adapters/video/vertexVideoHandler.js +3 -3
  87. package/dist/lib/agent/directTools.d.ts +7 -7
  88. package/dist/lib/config/conversationMemory.d.ts +2 -0
  89. package/dist/lib/config/conversationMemory.js +5 -5
  90. package/dist/lib/constants/contextWindows.d.ts +46 -0
  91. package/dist/lib/constants/contextWindows.js +157 -0
  92. package/dist/lib/context/budgetChecker.d.ts +18 -0
  93. package/dist/lib/context/budgetChecker.js +72 -0
  94. package/dist/lib/context/contextCompactor.d.ts +22 -0
  95. package/dist/lib/context/contextCompactor.js +107 -0
  96. package/dist/lib/context/effectiveHistory.d.ts +52 -0
  97. package/dist/lib/context/effectiveHistory.js +106 -0
  98. package/dist/lib/context/errorDetection.d.ts +14 -0
  99. package/dist/lib/context/errorDetection.js +125 -0
  100. package/dist/lib/context/fileSummarizationService.d.ts +54 -0
  101. package/dist/lib/context/fileSummarizationService.js +256 -0
  102. package/dist/lib/context/fileSummarizer.d.ts +56 -0
  103. package/dist/lib/context/fileSummarizer.js +146 -0
  104. package/dist/lib/context/fileTokenBudget.d.ts +53 -0
  105. package/dist/lib/context/fileTokenBudget.js +128 -0
  106. package/dist/lib/context/prompts/summarizationPrompt.d.ts +17 -0
  107. package/dist/lib/context/prompts/summarizationPrompt.js +111 -0
  108. package/dist/lib/context/stages/fileReadDeduplicator.d.ts +10 -0
  109. package/dist/lib/context/stages/fileReadDeduplicator.js +67 -0
  110. package/dist/lib/context/stages/slidingWindowTruncator.d.ts +11 -0
  111. package/dist/lib/context/stages/slidingWindowTruncator.js +43 -0
  112. package/dist/lib/context/stages/structuredSummarizer.d.ts +10 -0
  113. package/dist/lib/context/stages/structuredSummarizer.js +50 -0
  114. package/dist/lib/context/stages/toolOutputPruner.d.ts +10 -0
  115. package/dist/lib/context/stages/toolOutputPruner.js +53 -0
  116. package/dist/lib/context/summarizationEngine.d.ts +45 -0
  117. package/dist/lib/context/summarizationEngine.js +111 -0
  118. package/dist/lib/context/toolOutputLimits.d.ts +17 -0
  119. package/dist/lib/context/toolOutputLimits.js +85 -0
  120. package/dist/lib/context/toolPairRepair.d.ts +16 -0
  121. package/dist/lib/context/toolPairRepair.js +67 -0
  122. package/dist/lib/core/analytics.js +11 -4
  123. package/dist/lib/core/baseProvider.d.ts +6 -0
  124. package/dist/lib/core/baseProvider.js +83 -14
  125. package/dist/lib/core/conversationMemoryManager.d.ts +14 -11
  126. package/dist/lib/core/conversationMemoryManager.js +36 -68
  127. package/dist/lib/core/dynamicModels.js +3 -2
  128. package/dist/lib/core/modules/GenerationHandler.js +2 -0
  129. package/dist/lib/core/modules/MessageBuilder.d.ts +1 -1
  130. package/dist/lib/core/modules/MessageBuilder.js +2 -0
  131. package/dist/lib/core/modules/TelemetryHandler.d.ts +2 -3
  132. package/dist/lib/core/modules/TelemetryHandler.js +3 -3
  133. package/dist/lib/core/modules/ToolsManager.d.ts +2 -2
  134. package/dist/lib/core/redisConversationMemoryManager.d.ts +19 -14
  135. package/dist/lib/core/redisConversationMemoryManager.js +94 -86
  136. package/dist/lib/factories/providerFactory.d.ts +2 -2
  137. package/dist/lib/files/fileReferenceRegistry.d.ts +276 -0
  138. package/dist/lib/files/fileReferenceRegistry.js +1544 -0
  139. package/dist/lib/files/fileTools.d.ts +423 -0
  140. package/dist/lib/files/fileTools.js +450 -0
  141. package/dist/lib/files/index.d.ts +14 -0
  142. package/dist/lib/files/index.js +14 -0
  143. package/dist/lib/files/streamingReader.d.ts +93 -0
  144. package/dist/lib/files/streamingReader.js +322 -0
  145. package/dist/lib/files/types.d.ts +23 -0
  146. package/dist/lib/files/types.js +24 -0
  147. package/dist/lib/image-gen/imageGenTools.d.ts +2 -2
  148. package/dist/lib/image-gen/types.d.ts +12 -12
  149. package/dist/lib/index.d.ts +4 -0
  150. package/dist/lib/index.js +5 -0
  151. package/dist/lib/mcp/httpRetryHandler.js +6 -2
  152. package/dist/lib/memory/mem0Initializer.d.ts +2 -2
  153. package/dist/lib/neurolink.d.ts +66 -2
  154. package/dist/lib/neurolink.js +777 -315
  155. package/dist/lib/processors/archive/ArchiveProcessor.d.ts +327 -0
  156. package/dist/lib/processors/archive/ArchiveProcessor.js +1309 -0
  157. package/dist/lib/processors/archive/index.d.ts +33 -0
  158. package/dist/lib/processors/archive/index.js +43 -0
  159. package/dist/lib/processors/base/BaseFileProcessor.js +2 -1
  160. package/dist/lib/processors/base/types.d.ts +70 -64
  161. package/dist/lib/processors/base/types.js +6 -0
  162. package/dist/lib/processors/cli/fileProcessorCli.d.ts +8 -8
  163. package/dist/lib/processors/cli/fileProcessorCli.js +5 -5
  164. package/dist/lib/processors/config/mimeTypes.js +25 -0
  165. package/dist/lib/processors/config/sizeLimits.d.ts +52 -40
  166. package/dist/lib/processors/config/sizeLimits.js +56 -44
  167. package/dist/lib/processors/document/ExcelProcessor.d.ts +14 -0
  168. package/dist/lib/processors/document/ExcelProcessor.js +72 -1
  169. package/dist/lib/processors/document/PptxProcessor.d.ts +63 -0
  170. package/dist/lib/processors/document/PptxProcessor.js +158 -0
  171. package/dist/lib/processors/document/index.d.ts +1 -0
  172. package/dist/lib/processors/document/index.js +6 -0
  173. package/dist/lib/processors/errors/FileErrorCode.d.ts +2 -2
  174. package/dist/lib/processors/errors/errorHelpers.d.ts +2 -2
  175. package/dist/lib/processors/errors/errorHelpers.js +12 -4
  176. package/dist/lib/processors/errors/errorSerializer.d.ts +4 -4
  177. package/dist/lib/processors/index.d.ts +8 -2
  178. package/dist/lib/processors/index.js +5 -2
  179. package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +8 -8
  180. package/dist/lib/processors/integration/FileProcessorIntegration.js +7 -7
  181. package/dist/lib/processors/media/AudioProcessor.d.ts +328 -0
  182. package/dist/lib/processors/media/AudioProcessor.js +708 -0
  183. package/dist/lib/processors/media/VideoProcessor.d.ts +350 -0
  184. package/dist/lib/processors/media/VideoProcessor.js +992 -0
  185. package/dist/lib/processors/media/index.d.ts +27 -0
  186. package/dist/lib/processors/media/index.js +37 -0
  187. package/dist/lib/processors/registry/ProcessorRegistry.d.ts +19 -5
  188. package/dist/lib/processors/registry/ProcessorRegistry.js +103 -8
  189. package/dist/lib/processors/registry/index.d.ts +1 -1
  190. package/dist/lib/processors/registry/index.js +1 -1
  191. package/dist/lib/processors/registry/types.d.ts +2 -2
  192. package/dist/lib/providers/amazonBedrock.js +2 -1
  193. package/dist/lib/providers/anthropic.js +2 -2
  194. package/dist/lib/providers/anthropicBaseProvider.js +10 -4
  195. package/dist/lib/providers/azureOpenai.js +14 -25
  196. package/dist/lib/providers/googleAiStudio.js +136 -457
  197. package/dist/lib/providers/googleNativeGemini3.d.ts +119 -0
  198. package/dist/lib/providers/googleNativeGemini3.js +264 -0
  199. package/dist/lib/providers/googleVertex.d.ts +15 -1
  200. package/dist/lib/providers/googleVertex.js +341 -775
  201. package/dist/lib/providers/huggingFace.js +20 -5
  202. package/dist/lib/providers/litellm.js +6 -4
  203. package/dist/lib/providers/mistral.js +3 -2
  204. package/dist/lib/providers/openAI.js +2 -2
  205. package/dist/lib/providers/openRouter.js +8 -7
  206. package/dist/lib/providers/openaiCompatible.js +10 -4
  207. package/dist/lib/providers/sagemaker/detection.d.ts +6 -6
  208. package/dist/lib/providers/sagemaker/diagnostics.d.ts +4 -4
  209. package/dist/lib/providers/sagemaker/parsers.d.ts +4 -4
  210. package/dist/lib/rag/chunkers/RecursiveChunker.js +2 -2
  211. package/dist/lib/rag/document/loaders.d.ts +6 -71
  212. package/dist/lib/rag/document/loaders.js +5 -5
  213. package/dist/lib/rag/graphRag/graphRAG.js +26 -9
  214. package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +5 -55
  215. package/dist/lib/rag/metadata/metadataExtractor.js +6 -3
  216. package/dist/lib/rag/pipeline/RAGPipeline.d.ts +8 -126
  217. package/dist/lib/rag/pipeline/RAGPipeline.js +11 -11
  218. package/dist/lib/rag/pipeline/contextAssembly.d.ts +3 -42
  219. package/dist/lib/rag/pipeline/contextAssembly.js +6 -3
  220. package/dist/lib/rag/reranker/RerankerFactory.d.ts +5 -60
  221. package/dist/lib/rag/resilience/CircuitBreaker.d.ts +3 -33
  222. package/dist/lib/rag/resilience/RetryHandler.d.ts +2 -21
  223. package/dist/lib/rag/resilience/RetryHandler.js +6 -2
  224. package/dist/lib/rag/retrieval/hybridSearch.d.ts +3 -41
  225. package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +2 -13
  226. package/dist/lib/rag/retrieval/vectorQueryTool.js +4 -3
  227. package/dist/lib/rag/types.d.ts +3 -3
  228. package/dist/lib/sdk/toolRegistration.d.ts +2 -2
  229. package/dist/lib/server/middleware/cache.d.ts +2 -2
  230. package/dist/lib/server/middleware/rateLimit.d.ts +2 -2
  231. package/dist/lib/server/routes/mcpRoutes.js +277 -249
  232. package/dist/lib/server/routes/memoryRoutes.js +287 -281
  233. package/dist/lib/server/utils/validation.d.ts +10 -10
  234. package/dist/lib/services/server/ai/observability/instrumentation.d.ts +24 -2
  235. package/dist/lib/services/server/ai/observability/instrumentation.js +12 -1
  236. package/dist/lib/session/globalSessionState.d.ts +2 -2
  237. package/dist/lib/telemetry/telemetryService.d.ts +2 -2
  238. package/dist/lib/types/common.d.ts +39 -0
  239. package/dist/lib/types/contextTypes.d.ts +255 -0
  240. package/dist/lib/types/contextTypes.js +0 -2
  241. package/dist/lib/types/conversation.d.ts +62 -0
  242. package/dist/lib/types/conversationMemoryInterface.d.ts +27 -0
  243. package/dist/lib/types/conversationMemoryInterface.js +7 -0
  244. package/dist/lib/types/fileReferenceTypes.d.ts +222 -0
  245. package/dist/lib/types/fileReferenceTypes.js +9 -0
  246. package/dist/lib/types/fileTypes.d.ts +26 -3
  247. package/dist/lib/types/generateTypes.d.ts +50 -1
  248. package/dist/lib/types/index.d.ts +4 -5
  249. package/dist/lib/types/index.js +8 -10
  250. package/dist/lib/types/modelTypes.d.ts +2 -2
  251. package/dist/lib/types/processorTypes.d.ts +597 -0
  252. package/dist/lib/types/processorTypes.js +91 -0
  253. package/dist/lib/types/ragTypes.d.ts +489 -0
  254. package/dist/lib/types/ragTypes.js +8 -0
  255. package/dist/lib/types/sdkTypes.d.ts +17 -18
  256. package/dist/lib/types/streamTypes.d.ts +24 -1
  257. package/dist/lib/utils/async/retry.d.ts +2 -2
  258. package/dist/lib/utils/async/withTimeout.js +3 -1
  259. package/dist/lib/utils/conversationMemory.d.ts +12 -6
  260. package/dist/lib/utils/conversationMemory.js +91 -36
  261. package/dist/lib/utils/errorHandling.d.ts +5 -0
  262. package/dist/lib/utils/errorHandling.js +19 -0
  263. package/dist/lib/utils/fileDetector.d.ts +62 -0
  264. package/dist/lib/utils/fileDetector.js +1014 -14
  265. package/dist/lib/utils/json/safeParse.d.ts +2 -2
  266. package/dist/lib/utils/messageBuilder.js +806 -153
  267. package/dist/lib/utils/modelChoices.d.ts +2 -2
  268. package/dist/lib/utils/multimodalOptionsBuilder.d.ts +2 -1
  269. package/dist/lib/utils/multimodalOptionsBuilder.js +1 -0
  270. package/dist/lib/utils/pricing.d.ts +12 -0
  271. package/dist/lib/utils/pricing.js +134 -0
  272. package/dist/lib/utils/rateLimiter.d.ts +2 -2
  273. package/dist/lib/utils/redis.d.ts +17 -0
  274. package/dist/lib/utils/redis.js +105 -0
  275. package/dist/lib/utils/sanitizers/filename.d.ts +4 -4
  276. package/dist/lib/utils/sanitizers/svg.d.ts +2 -2
  277. package/dist/lib/utils/thinkingConfig.d.ts +6 -6
  278. package/dist/lib/utils/timeout.d.ts +10 -0
  279. package/dist/lib/utils/timeout.js +15 -0
  280. package/dist/lib/utils/tokenEstimation.d.ts +68 -0
  281. package/dist/lib/utils/tokenEstimation.js +113 -0
  282. package/dist/lib/utils/tokenUtils.d.ts +4 -4
  283. package/dist/lib/utils/ttsProcessor.d.ts +2 -2
  284. package/dist/lib/workflow/config.d.ts +150 -150
  285. package/dist/mcp/httpRetryHandler.js +6 -2
  286. package/dist/memory/mem0Initializer.d.ts +2 -2
  287. package/dist/neurolink.d.ts +66 -2
  288. package/dist/neurolink.js +777 -315
  289. package/dist/processors/archive/ArchiveProcessor.d.ts +327 -0
  290. package/dist/processors/archive/ArchiveProcessor.js +1308 -0
  291. package/dist/processors/archive/index.d.ts +33 -0
  292. package/dist/processors/archive/index.js +42 -0
  293. package/dist/processors/base/BaseFileProcessor.js +2 -1
  294. package/dist/processors/base/types.d.ts +70 -64
  295. package/dist/processors/base/types.js +6 -0
  296. package/dist/processors/cli/fileProcessorCli.d.ts +8 -8
  297. package/dist/processors/cli/fileProcessorCli.js +5 -5
  298. package/dist/processors/config/mimeTypes.js +25 -0
  299. package/dist/processors/config/sizeLimits.d.ts +52 -40
  300. package/dist/processors/config/sizeLimits.js +56 -44
  301. package/dist/processors/document/ExcelProcessor.d.ts +14 -0
  302. package/dist/processors/document/ExcelProcessor.js +72 -1
  303. package/dist/processors/document/PptxProcessor.d.ts +63 -0
  304. package/dist/processors/document/PptxProcessor.js +157 -0
  305. package/dist/processors/document/index.d.ts +1 -0
  306. package/dist/processors/document/index.js +6 -0
  307. package/dist/processors/errors/FileErrorCode.d.ts +2 -2
  308. package/dist/processors/errors/errorHelpers.d.ts +2 -2
  309. package/dist/processors/errors/errorHelpers.js +12 -4
  310. package/dist/processors/errors/errorSerializer.d.ts +4 -4
  311. package/dist/processors/index.d.ts +8 -2
  312. package/dist/processors/index.js +5 -2
  313. package/dist/processors/integration/FileProcessorIntegration.d.ts +8 -8
  314. package/dist/processors/integration/FileProcessorIntegration.js +7 -7
  315. package/dist/processors/media/AudioProcessor.d.ts +328 -0
  316. package/dist/processors/media/AudioProcessor.js +707 -0
  317. package/dist/processors/media/VideoProcessor.d.ts +350 -0
  318. package/dist/processors/media/VideoProcessor.js +991 -0
  319. package/dist/processors/media/ffprobe-static.d.ts +4 -0
  320. package/dist/processors/media/index.d.ts +27 -0
  321. package/dist/processors/media/index.js +36 -0
  322. package/dist/processors/registry/ProcessorRegistry.d.ts +19 -5
  323. package/dist/processors/registry/ProcessorRegistry.js +103 -8
  324. package/dist/processors/registry/index.d.ts +1 -1
  325. package/dist/processors/registry/index.js +1 -1
  326. package/dist/processors/registry/types.d.ts +2 -2
  327. package/dist/providers/amazonBedrock.js +2 -1
  328. package/dist/providers/anthropic.js +2 -2
  329. package/dist/providers/anthropicBaseProvider.js +10 -4
  330. package/dist/providers/azureOpenai.js +14 -25
  331. package/dist/providers/googleAiStudio.js +136 -457
  332. package/dist/providers/googleNativeGemini3.d.ts +119 -0
  333. package/dist/providers/googleNativeGemini3.js +263 -0
  334. package/dist/providers/googleVertex.d.ts +15 -1
  335. package/dist/providers/googleVertex.js +341 -775
  336. package/dist/providers/huggingFace.js +20 -5
  337. package/dist/providers/litellm.js +6 -4
  338. package/dist/providers/mistral.js +3 -2
  339. package/dist/providers/openAI.js +2 -2
  340. package/dist/providers/openRouter.js +8 -7
  341. package/dist/providers/openaiCompatible.js +10 -4
  342. package/dist/providers/sagemaker/detection.d.ts +6 -6
  343. package/dist/providers/sagemaker/diagnostics.d.ts +4 -4
  344. package/dist/providers/sagemaker/parsers.d.ts +4 -4
  345. package/dist/rag/chunkers/RecursiveChunker.js +2 -2
  346. package/dist/rag/document/loaders.d.ts +6 -71
  347. package/dist/rag/document/loaders.js +5 -5
  348. package/dist/rag/graphRag/graphRAG.js +26 -9
  349. package/dist/rag/metadata/MetadataExtractorFactory.d.ts +5 -55
  350. package/dist/rag/metadata/metadataExtractor.js +6 -3
  351. package/dist/rag/pipeline/RAGPipeline.d.ts +8 -126
  352. package/dist/rag/pipeline/RAGPipeline.js +11 -11
  353. package/dist/rag/pipeline/contextAssembly.d.ts +3 -42
  354. package/dist/rag/pipeline/contextAssembly.js +6 -3
  355. package/dist/rag/reranker/RerankerFactory.d.ts +5 -60
  356. package/dist/rag/resilience/CircuitBreaker.d.ts +3 -33
  357. package/dist/rag/resilience/RetryHandler.d.ts +2 -21
  358. package/dist/rag/resilience/RetryHandler.js +6 -2
  359. package/dist/rag/retrieval/hybridSearch.d.ts +3 -41
  360. package/dist/rag/retrieval/vectorQueryTool.d.ts +2 -13
  361. package/dist/rag/retrieval/vectorQueryTool.js +4 -3
  362. package/dist/rag/types.d.ts +3 -3
  363. package/dist/sdk/toolRegistration.d.ts +2 -2
  364. package/dist/server/middleware/cache.d.ts +2 -2
  365. package/dist/server/middleware/rateLimit.d.ts +2 -2
  366. package/dist/server/routes/mcpRoutes.js +277 -249
  367. package/dist/server/routes/memoryRoutes.js +287 -281
  368. package/dist/server/utils/validation.d.ts +4 -4
  369. package/dist/services/server/ai/observability/instrumentation.d.ts +24 -2
  370. package/dist/services/server/ai/observability/instrumentation.js +12 -1
  371. package/dist/session/globalSessionState.d.ts +2 -2
  372. package/dist/telemetry/telemetryService.d.ts +2 -2
  373. package/dist/types/common.d.ts +39 -0
  374. package/dist/types/contextTypes.d.ts +255 -0
  375. package/dist/types/contextTypes.js +0 -2
  376. package/dist/types/conversation.d.ts +62 -0
  377. package/dist/types/conversationMemoryInterface.d.ts +27 -0
  378. package/dist/types/conversationMemoryInterface.js +6 -0
  379. package/dist/types/fileReferenceTypes.d.ts +222 -0
  380. package/dist/types/fileReferenceTypes.js +8 -0
  381. package/dist/types/fileTypes.d.ts +26 -3
  382. package/dist/types/generateTypes.d.ts +50 -1
  383. package/dist/types/index.d.ts +4 -5
  384. package/dist/types/index.js +8 -10
  385. package/dist/types/processorTypes.d.ts +597 -0
  386. package/dist/types/processorTypes.js +90 -0
  387. package/dist/types/ragTypes.d.ts +489 -0
  388. package/dist/types/ragTypes.js +7 -0
  389. package/dist/types/sdkTypes.d.ts +17 -18
  390. package/dist/types/streamTypes.d.ts +24 -1
  391. package/dist/utils/async/retry.d.ts +2 -2
  392. package/dist/utils/async/withTimeout.js +3 -1
  393. package/dist/utils/conversationMemory.d.ts +12 -6
  394. package/dist/utils/conversationMemory.js +91 -36
  395. package/dist/utils/errorHandling.d.ts +5 -0
  396. package/dist/utils/errorHandling.js +19 -0
  397. package/dist/utils/fileDetector.d.ts +62 -0
  398. package/dist/utils/fileDetector.js +1014 -14
  399. package/dist/utils/json/safeParse.d.ts +2 -2
  400. package/dist/utils/messageBuilder.js +806 -153
  401. package/dist/utils/modelChoices.d.ts +2 -2
  402. package/dist/utils/multimodalOptionsBuilder.d.ts +2 -1
  403. package/dist/utils/multimodalOptionsBuilder.js +1 -0
  404. package/dist/utils/pricing.d.ts +12 -0
  405. package/dist/utils/pricing.js +133 -0
  406. package/dist/utils/rateLimiter.d.ts +2 -2
  407. package/dist/utils/redis.d.ts +17 -0
  408. package/dist/utils/redis.js +105 -0
  409. package/dist/utils/sanitizers/filename.d.ts +4 -4
  410. package/dist/utils/sanitizers/svg.d.ts +2 -2
  411. package/dist/utils/thinkingConfig.d.ts +6 -6
  412. package/dist/utils/timeout.d.ts +10 -0
  413. package/dist/utils/timeout.js +15 -0
  414. package/dist/utils/tokenEstimation.d.ts +68 -0
  415. package/dist/utils/tokenEstimation.js +112 -0
  416. package/dist/utils/tokenUtils.d.ts +4 -4
  417. package/dist/utils/ttsProcessor.d.ts +2 -2
  418. package/dist/workflow/config.d.ts +104 -104
  419. package/package.json +18 -6
  420. package/dist/lib/utils/conversationMemoryUtils.d.ts +0 -25
  421. package/dist/lib/utils/conversationMemoryUtils.js +0 -138
  422. package/dist/utils/conversationMemoryUtils.d.ts +0 -25
  423. package/dist/utils/conversationMemoryUtils.js +0 -137
@@ -25,133 +25,15 @@
25
25
  * console.log(response.answer, response.sources);
26
26
  * ```
27
27
  */
28
- import type { ChunkingStrategy } from "../types.js";
29
28
  import { MDocument } from "../document/MDocument.js";
30
- import { type VectorStore } from "../retrieval/vectorQueryTool.js";
31
- import { type BM25Index } from "../retrieval/hybridSearch.js";
32
- /**
33
- * Embedding model configuration
34
- */
35
- export interface EmbeddingModelConfig {
36
- provider: string;
37
- modelName: string;
38
- }
39
- /**
40
- * Generation model configuration
41
- */
42
- export interface GenerationModelConfig {
43
- provider: string;
44
- modelName: string;
45
- temperature?: number;
46
- maxTokens?: number;
47
- }
48
- /**
49
- * RAG pipeline configuration
50
- */
51
- export interface RAGPipelineConfig {
52
- /** Pipeline identifier */
53
- id?: string;
54
- /** Vector store instance (defaults to in-memory) */
55
- vectorStore?: VectorStore;
56
- /** BM25 index for hybrid search (defaults to in-memory) */
57
- bm25Index?: BM25Index;
58
- /** Index name for vector store */
59
- indexName?: string;
60
- /** Embedding model configuration */
61
- embeddingModel: EmbeddingModelConfig;
62
- /** Generation model configuration (for RAG responses) */
63
- generationModel?: GenerationModelConfig;
64
- /** Default chunking strategy */
65
- defaultChunkingStrategy?: ChunkingStrategy;
66
- /** Default chunk size */
67
- defaultChunkSize?: number;
68
- /** Default chunk overlap */
69
- defaultChunkOverlap?: number;
70
- /** Enable hybrid search (vector + BM25) */
71
- enableHybridSearch?: boolean;
72
- /** Enable Graph RAG */
73
- enableGraphRAG?: boolean;
74
- /** Graph RAG similarity threshold */
75
- graphThreshold?: number;
76
- /** Default number of results to retrieve */
77
- defaultTopK?: number;
78
- /** Enable reranking */
79
- enableReranking?: boolean;
80
- /** Reranking model configuration */
81
- rerankingModel?: EmbeddingModelConfig;
82
- }
83
- /**
84
- * Ingestion options
85
- */
86
- export interface IngestOptions {
87
- /** Chunking strategy override */
88
- strategy?: ChunkingStrategy;
89
- /** Chunk size override */
90
- chunkSize?: number;
91
- /** Chunk overlap override */
92
- chunkOverlap?: number;
93
- /** Custom metadata to add */
94
- metadata?: Record<string, unknown>;
95
- /** Extract metadata using LLM */
96
- extractMetadata?: boolean;
97
- }
98
- /**
99
- * Query options
100
- */
101
- export interface QueryOptions {
102
- /** Number of chunks to retrieve */
103
- topK?: number;
104
- /** Use hybrid search */
105
- hybrid?: boolean;
106
- /** Use Graph RAG */
107
- graph?: boolean;
108
- /** Enable reranking */
109
- rerank?: boolean;
110
- /** Metadata filter */
111
- filter?: Record<string, unknown>;
112
- /** Include sources in response */
113
- includeSources?: boolean;
114
- /** Generate response (vs just retrieve) */
115
- generate?: boolean;
116
- /** Custom system prompt for generation */
117
- systemPrompt?: string;
118
- /** Temperature for generation */
119
- temperature?: number;
120
- }
121
- /**
122
- * Query response
123
- */
124
- export interface RAGResponse {
125
- /** Generated answer (if generate=true) */
126
- answer?: string;
127
- /** Retrieved context chunks */
128
- context: string;
129
- /** Source documents/chunks */
130
- sources: Array<{
131
- id: string;
132
- text: string;
133
- score: number;
134
- metadata?: Record<string, unknown>;
135
- }>;
136
- /** Query metadata */
137
- metadata: {
138
- queryTime: number;
139
- retrievalMethod: string;
140
- chunksRetrieved: number;
141
- reranked: boolean;
142
- };
143
- }
144
- /**
145
- * Pipeline statistics
146
- */
147
- export interface PipelineStats {
148
- totalDocuments: number;
149
- totalChunks: number;
150
- indexName: string;
151
- embeddingDimension?: number;
152
- hybridSearchEnabled: boolean;
153
- graphRAGEnabled: boolean;
154
- }
29
+ import type { RAGPipelineConfig, IngestOptions, QueryOptions, RAGResponse, PipelineStats } from "../../types/ragTypes.js";
30
+ export type { EmbeddingModelConfig } from "../../types/ragTypes.js";
31
+ export type { GenerationModelConfig } from "../../types/ragTypes.js";
32
+ export type { RAGPipelineConfig } from "../../types/ragTypes.js";
33
+ export type { IngestOptions } from "../../types/ragTypes.js";
34
+ export type { QueryOptions } from "../../types/ragTypes.js";
35
+ export type { RAGResponse } from "../../types/ragTypes.js";
36
+ export type { PipelineStats } from "../../types/ragTypes.js";
155
37
  /**
156
38
  * RAG Pipeline Orchestrator
157
39
  *
@@ -89,7 +89,7 @@ export class RAGPipeline {
89
89
  this.hybridSearch = createHybridSearch({
90
90
  vectorStore: this.vectorStore,
91
91
  bm25Index: this.bm25Index,
92
- indexName: this.config.indexName,
92
+ indexName: this.config.indexName ?? "default",
93
93
  embeddingModel: this.config.embeddingModel,
94
94
  });
95
95
  }
@@ -103,9 +103,9 @@ export class RAGPipeline {
103
103
  */
104
104
  async ingest(sources, options) {
105
105
  await this.ensureInitialized();
106
- const strategy = options?.strategy || this.config.defaultChunkingStrategy;
107
- const chunkSize = options?.chunkSize || this.config.defaultChunkSize;
108
- const chunkOverlap = options?.chunkOverlap || this.config.defaultChunkOverlap;
106
+ const strategy = options?.strategy || this.config.defaultChunkingStrategy || "recursive";
107
+ const chunkSize = options?.chunkSize || this.config.defaultChunkSize || 1000;
108
+ const chunkOverlap = options?.chunkOverlap || this.config.defaultChunkOverlap || 200;
109
109
  let documentsProcessed = 0;
110
110
  let chunksCreated = 0;
111
111
  for (const source of sources) {
@@ -137,13 +137,13 @@ export class RAGPipeline {
137
137
  const embeddings = doc.getEmbeddings();
138
138
  // Store in vector store
139
139
  await this.vectorStore.query({
140
- indexName: this.config.indexName,
140
+ indexName: this.config.indexName ?? "default",
141
141
  queryVector: embeddings[0],
142
142
  topK: 1,
143
143
  }); // Warm up
144
144
  // Upsert into vector store
145
145
  if ("upsert" in this.vectorStore) {
146
- await this.vectorStore.upsert(this.config.indexName, chunks.map((chunk, i) => ({
146
+ await this.vectorStore.upsert(this.config.indexName ?? "default", chunks.map((chunk, i) => ({
147
147
  id: chunk.id,
148
148
  vector: embeddings[i],
149
149
  metadata: { ...chunk.metadata, text: chunk.text },
@@ -197,7 +197,7 @@ export class RAGPipeline {
197
197
  async query(query, options) {
198
198
  await this.ensureInitialized();
199
199
  const startTime = Date.now();
200
- const topK = options?.topK || this.config.defaultTopK;
200
+ const topK = options?.topK || this.config.defaultTopK || 5;
201
201
  const useHybrid = options?.hybrid ?? this.config.enableHybridSearch;
202
202
  const useGraph = options?.graph ?? this.config.enableGraphRAG;
203
203
  const useRerank = options?.rerank ?? this.config.enableReranking;
@@ -233,7 +233,7 @@ export class RAGPipeline {
233
233
  else {
234
234
  // Vector search
235
235
  results = await this.vectorStore.query({
236
- indexName: this.config.indexName,
236
+ indexName: this.config.indexName ?? "default",
237
237
  queryVector: queryEmbedding,
238
238
  topK: topK * 2,
239
239
  filter: options?.filter,
@@ -293,10 +293,10 @@ export class RAGPipeline {
293
293
  return {
294
294
  totalDocuments: this.documents.size,
295
295
  totalChunks: this.allChunks.length,
296
- indexName: this.config.indexName,
296
+ indexName: this.config.indexName ?? "default",
297
297
  embeddingDimension: this.allChunks[0]?.embedding?.length,
298
- hybridSearchEnabled: this.config.enableHybridSearch,
299
- graphRAGEnabled: this.config.enableGraphRAG,
298
+ hybridSearchEnabled: this.config.enableHybridSearch ?? false,
299
+ graphRAGEnabled: this.config.enableGraphRAG ?? false,
300
300
  };
301
301
  }
302
302
  /**
@@ -12,52 +12,13 @@
12
12
  * - Context summarization
13
13
  */
14
14
  import type { Chunk, VectorQueryResult } from "../types.js";
15
+ import type { ContextAssemblyOptions, ContextWindow } from "../../types/ragTypes.js";
15
16
  /**
16
17
  * Citation format options
17
18
  */
18
19
  export type CitationFormat = "inline" | "footnote" | "numbered" | "none";
19
- /**
20
- * Context assembly options
21
- */
22
- export interface ContextAssemblyOptions {
23
- /** Maximum characters in assembled context */
24
- maxChars?: number;
25
- /** Maximum tokens (approximate, 4 chars/token) */
26
- maxTokens?: number;
27
- /** Citation format to use */
28
- citationFormat?: CitationFormat;
29
- /** Separator between chunks */
30
- separator?: string;
31
- /** Include chunk metadata in context */
32
- includeMetadata?: boolean;
33
- /** Deduplicate overlapping content */
34
- deduplicate?: boolean;
35
- /** Similarity threshold for deduplication (0-1) */
36
- dedupeThreshold?: number;
37
- /** Order by relevance score */
38
- orderByRelevance?: boolean;
39
- /** Include section headers */
40
- includeSectionHeaders?: boolean;
41
- /** Header template (use {index}, {source}, {score} placeholders) */
42
- headerTemplate?: string;
43
- }
44
- /**
45
- * Context window representation
46
- */
47
- export interface ContextWindow {
48
- /** Assembled context text */
49
- text: string;
50
- /** Number of chunks included */
51
- chunkCount: number;
52
- /** Total character count */
53
- charCount: number;
54
- /** Estimated token count */
55
- tokenCount: number;
56
- /** Chunks that were truncated/excluded */
57
- truncatedChunks: number;
58
- /** Citation map (id -> citation text) */
59
- citations: Map<string, string>;
60
- }
20
+ export type { ContextAssemblyOptions } from "../../types/ragTypes.js";
21
+ export type { ContextWindow } from "../../types/ragTypes.js";
61
22
  /**
62
23
  * Assemble context from retrieved results
63
24
  *
@@ -307,10 +307,13 @@ export function orderByDocumentStructure(chunks) {
307
307
  const byDocument = new Map();
308
308
  for (const chunk of chunks) {
309
309
  const docId = chunk.metadata.documentId;
310
- if (!byDocument.has(docId)) {
311
- byDocument.set(docId, []);
310
+ const group = byDocument.get(docId);
311
+ if (group) {
312
+ group.push(chunk);
313
+ }
314
+ else {
315
+ byDocument.set(docId, [chunk]);
312
316
  }
313
- byDocument.get(docId).push(chunk);
314
317
  }
315
318
  // Sort each document's chunks by position
316
319
  for (const docChunks of byDocument.values()) {
@@ -6,66 +6,11 @@
6
6
  */
7
7
  import { BaseFactory } from "../../core/infrastructure/index.js";
8
8
  import type { AIProvider } from "../../types/providers.js";
9
- import type { RerankerOptions, RerankResult, VectorQueryResult } from "../types.js";
10
- /**
11
- * Supported reranker types
12
- */
13
- export type RerankerType = "llm" | "cross-encoder" | "cohere" | "simple" | "batch";
14
- /**
15
- * Reranker interface - all rerankers implement this
16
- */
17
- export interface Reranker {
18
- /** Reranker type identifier */
19
- readonly type: RerankerType;
20
- /**
21
- * Rerank results based on query relevance
22
- * @param results - Vector search results to rerank
23
- * @param query - Original search query
24
- * @param options - Reranking options
25
- * @returns Reranked results with scores
26
- */
27
- rerank(results: VectorQueryResult[], query: string, options?: RerankerOptions): Promise<RerankResult[]>;
28
- }
29
- /**
30
- * Reranker configuration
31
- */
32
- export interface RerankerConfig {
33
- /** Reranker type */
34
- type: RerankerType;
35
- /** Model name for LLM-based rerankers */
36
- model?: string;
37
- /** Provider for the model */
38
- provider?: string;
39
- /** Number of results to return after reranking */
40
- topK?: number;
41
- /** Scoring weights */
42
- weights?: {
43
- semantic?: number;
44
- vector?: number;
45
- position?: number;
46
- };
47
- /** API key for external services (e.g., Cohere) */
48
- apiKey?: string;
49
- }
50
- /**
51
- * Reranker metadata for discovery and documentation
52
- */
53
- export interface RerankerMetadata {
54
- /** Human-readable description */
55
- description: string;
56
- /** Default configuration */
57
- defaultConfig: Partial<RerankerConfig>;
58
- /** Supported configuration options */
59
- supportedOptions: string[];
60
- /** Recommended use cases */
61
- useCases: string[];
62
- /** Alternative names for this reranker */
63
- aliases: string[];
64
- /** Whether this reranker requires an AI model */
65
- requiresModel: boolean;
66
- /** Whether this reranker requires external API */
67
- requiresExternalAPI: boolean;
68
- }
9
+ import type { Reranker, RerankerConfig, RerankerMetadata, RerankerType } from "../../types/ragTypes.js";
10
+ export type { RerankerType } from "../../types/ragTypes.js";
11
+ export type { Reranker } from "../../types/ragTypes.js";
12
+ export type { RerankerConfig } from "../../types/ragTypes.js";
13
+ export type { RerankerMetadata } from "../../types/ragTypes.js";
69
14
  /**
70
15
  * Reranker Factory
71
16
  *
@@ -10,39 +10,9 @@ import { TypedEventEmitter } from "../../core/infrastructure/index.js";
10
10
  * Circuit breaker states
11
11
  */
12
12
  export type CircuitState = "closed" | "open" | "half-open";
13
- /**
14
- * Circuit breaker configuration
15
- */
16
- export interface RAGCircuitBreakerConfig {
17
- /** Number of failures before opening circuit (default: 5) */
18
- failureThreshold: number;
19
- /** Time in ms before attempting reset (default: 60000) */
20
- resetTimeout: number;
21
- /** Max calls allowed in half-open state (default: 3) */
22
- halfOpenMaxCalls: number;
23
- /** Operation timeout in ms (default: 30000) */
24
- operationTimeout: number;
25
- /** Minimum calls before calculating failure rate (default: 10) */
26
- minimumCallsBeforeCalculation: number;
27
- /** Time window for statistics in ms (default: 300000 - 5 minutes) */
28
- statisticsWindowSize: number;
29
- }
30
- /**
31
- * Circuit breaker statistics
32
- */
33
- export interface RAGCircuitBreakerStats {
34
- state: CircuitState;
35
- totalCalls: number;
36
- successfulCalls: number;
37
- failedCalls: number;
38
- failureRate: number;
39
- windowCalls: number;
40
- lastStateChange: Date;
41
- nextRetryTime?: Date;
42
- halfOpenCalls: number;
43
- averageLatency: number;
44
- p95Latency: number;
45
- }
13
+ import type { RAGCircuitBreakerConfig, RAGCircuitBreakerStats } from "../../types/ragTypes.js";
14
+ export type { RAGCircuitBreakerConfig } from "../../types/ragTypes.js";
15
+ export type { RAGCircuitBreakerStats } from "../../types/ragTypes.js";
46
16
  /**
47
17
  * Circuit breaker events
48
18
  */
@@ -5,27 +5,8 @@
5
5
  * specifically designed for RAG operations including embeddings,
6
6
  * vector queries, and LLM-based extraction.
7
7
  */
8
- /**
9
- * RAG-specific retry configuration
10
- */
11
- export interface RAGRetryConfig {
12
- /** Maximum number of retry attempts (default: 3) */
13
- maxRetries: number;
14
- /** Initial delay in ms (default: 1000) */
15
- initialDelay: number;
16
- /** Maximum delay in ms (default: 30000) */
17
- maxDelay: number;
18
- /** Backoff multiplier (default: 2) */
19
- backoffMultiplier: number;
20
- /** Whether to add jitter (default: true) */
21
- jitter: boolean;
22
- /** Custom function to determine if error is retryable */
23
- shouldRetry?: (error: Error) => boolean;
24
- /** Retryable error codes */
25
- retryableErrorCodes?: string[];
26
- /** Retryable HTTP status codes */
27
- retryableStatusCodes?: number[];
28
- }
8
+ import type { RAGRetryConfig } from "../../types/ragTypes.js";
9
+ export type { RAGRetryConfig } from "../../types/ragTypes.js";
29
10
  /**
30
11
  * Default retry configuration
31
12
  */
@@ -6,6 +6,7 @@
6
6
  * vector queries, and LLM-based extraction.
7
7
  */
8
8
  import { withRetry, } from "../../core/infrastructure/index.js";
9
+ import { isAbortError } from "../../utils/errorHandling.js";
9
10
  import { logger } from "../../utils/logger.js";
10
11
  import { EmbeddingError, isRetryableRAGError, MetadataExtractionError, RAGError, RAGErrorCodes, VectorQueryError, } from "../errors/RAGError.js";
11
12
  /**
@@ -50,6 +51,10 @@ function sleep(ms) {
50
51
  * Check if an error is retryable based on configuration
51
52
  */
52
53
  export function isRetryable(error, config = DEFAULT_RAG_RETRY_CONFIG) {
54
+ // Never retry abort errors - the operation was intentionally cancelled
55
+ if (isAbortError(error)) {
56
+ return false;
57
+ }
53
58
  // Use custom shouldRetry if provided
54
59
  if (config.shouldRetry) {
55
60
  return config.shouldRetry(error);
@@ -70,8 +75,7 @@ export function isRetryable(error, config = DEFAULT_RAG_RETRY_CONFIG) {
70
75
  // Timeout errors
71
76
  if (errorObj.name === "TimeoutError" ||
72
77
  errorObj.code === "TIMEOUT" ||
73
- errorObj.code === "ETIMEDOUT" ||
74
- errorObj.name === "AbortError") {
78
+ errorObj.code === "ETIMEDOUT") {
75
79
  return true;
76
80
  }
77
81
  // Network errors
@@ -5,29 +5,8 @@
5
5
  * Supports multiple fusion methods: Reciprocal Rank Fusion (RRF) and Linear Combination.
6
6
  */
7
7
  import type { BM25Result, HybridSearchConfig, HybridSearchResult } from "../types.js";
8
- import type { VectorStore } from "./vectorQueryTool.js";
9
- /**
10
- * BM25 Index interface
11
- * Implementations should provide sparse retrieval capabilities
12
- */
13
- export interface BM25Index {
14
- /**
15
- * Search documents using BM25 algorithm
16
- * @param query - Search query string
17
- * @param topK - Number of results to return
18
- * @returns Array of BM25 results
19
- */
20
- search(query: string, topK?: number): Promise<BM25Result[]>;
21
- /**
22
- * Add documents to the index
23
- * @param documents - Documents to index
24
- */
25
- addDocuments(documents: Array<{
26
- id: string;
27
- text: string;
28
- metadata?: Record<string, unknown>;
29
- }>): Promise<void>;
30
- }
8
+ import type { BM25Index, HybridSearchOptions } from "../../types/ragTypes.js";
9
+ export type { BM25Index } from "../../types/ragTypes.js";
31
10
  /**
32
11
  * In-memory BM25 implementation for testing and development
33
12
  */
@@ -67,24 +46,7 @@ export declare function reciprocalRankFusion(rankings: Array<Array<{
67
46
  * @returns Map of document IDs to combined scores
68
47
  */
69
48
  export declare function linearCombination(vectorScores: Map<string, number>, bm25Scores: Map<string, number>, alpha?: number): Map<string, number>;
70
- /**
71
- * Hybrid search configuration for creating a search function
72
- */
73
- export interface HybridSearchOptions {
74
- /** Vector store instance */
75
- vectorStore: VectorStore;
76
- /** BM25 index instance */
77
- bm25Index: BM25Index;
78
- /** Index name for vector store */
79
- indexName: string;
80
- /** Embedding model configuration (optional - uses defaults from ProviderFactory if not specified) */
81
- embeddingModel?: {
82
- provider?: string;
83
- modelName?: string;
84
- };
85
- /** Default search configuration */
86
- defaultConfig?: HybridSearchConfig;
87
- }
49
+ export type { HybridSearchOptions } from "../../types/ragTypes.js";
88
50
  /**
89
51
  * Create a hybrid search function
90
52
  *
@@ -6,19 +6,8 @@
6
6
  */
7
7
  import { z } from "zod";
8
8
  import type { MetadataFilter, RequestContext, VectorQueryResponse, VectorQueryResult, VectorQueryToolConfig } from "../types.js";
9
- /**
10
- * Abstract vector store interface
11
- * Vector stores should implement this interface to work with the query tool
12
- */
13
- export interface VectorStore {
14
- query(params: {
15
- indexName: string;
16
- queryVector: number[];
17
- topK?: number;
18
- filter?: MetadataFilter;
19
- includeVectors?: boolean;
20
- }): Promise<VectorQueryResult[]>;
21
- }
9
+ import type { VectorStore } from "../../types/ragTypes.js";
10
+ export type { VectorStore } from "../../types/ragTypes.js";
22
11
  /**
23
12
  * Creates a vector query tool for semantic search
24
13
  * Follows NeuroLink's factory pattern
@@ -123,10 +123,11 @@ export class InMemoryVectorStore {
123
123
  * Add vectors to an index
124
124
  */
125
125
  async upsert(indexName, items) {
126
- if (!this.vectors.has(indexName)) {
127
- this.vectors.set(indexName, new Map());
126
+ let index = this.vectors.get(indexName);
127
+ if (!index) {
128
+ index = new Map();
129
+ this.vectors.set(indexName, index);
128
130
  }
129
- const index = this.vectors.get(indexName);
130
131
  for (const item of items) {
131
132
  index.set(item.id, {
132
133
  vector: item.vector,
@@ -211,9 +211,9 @@ export type SemanticChunkerConfig = BaseChunkerConfig & {
211
211
  */
212
212
  export type ChunkerConfig = CharacterChunkerConfig | RecursiveChunkerConfig | SentenceChunkerConfig | TokenChunkerConfig | MarkdownChunkerConfig | HTMLChunkerConfig | JSONChunkerConfig | LaTeXChunkerConfig | SemanticChunkerConfig;
213
213
  /**
214
- * Chunker interface - all chunking strategies implement this
214
+ * Chunker type - all chunking strategies implement this
215
215
  */
216
- export interface Chunker {
216
+ export type Chunker = {
217
217
  /** Strategy name for identification */
218
218
  readonly strategy: ChunkingStrategy;
219
219
  /**
@@ -223,7 +223,7 @@ export interface Chunker {
223
223
  * @returns Array of chunks
224
224
  */
225
225
  chunk(text: string, config?: BaseChunkerConfig): Promise<Chunk[]>;
226
- }
226
+ };
227
227
  /**
228
228
  * Chunker metadata for factory registration
229
229
  */
@@ -27,7 +27,7 @@ export type ToolContext = SDKToolContext;
27
27
  * Simple tool interface for SDK users
28
28
  * Extends the core SimpleTool with specific types
29
29
  */
30
- export interface SimpleTool<TArgs = ToolArgs, TResult = JsonValue> extends Omit<CoreSimpleTool<TArgs, TResult>, "execute"> {
30
+ export type SimpleTool<TArgs = ToolArgs, TResult = JsonValue> = Omit<CoreSimpleTool<TArgs, TResult>, "execute"> & {
31
31
  /**
32
32
  * Tool description that helps AI understand when to use it
33
33
  */
@@ -51,7 +51,7 @@ export interface SimpleTool<TArgs = ToolArgs, TResult = JsonValue> extends Omit<
51
51
  documentation?: string;
52
52
  [key: string]: JsonValue | undefined;
53
53
  };
54
- }
54
+ };
55
55
  /**
56
56
  * Creates a MCPServerInfo from a set of tools
57
57
  */
@@ -55,12 +55,12 @@ export type CacheEntry = {
55
55
  /**
56
56
  * Cache store interface
57
57
  */
58
- export interface CacheStore {
58
+ export type CacheStore = {
59
59
  get(key: string): Promise<CacheEntry | undefined>;
60
60
  set(key: string, entry: CacheEntry): Promise<void>;
61
61
  delete(key: string): Promise<void>;
62
62
  clear(): Promise<void>;
63
- }
63
+ };
64
64
  /**
65
65
  * In-memory LRU cache store
66
66
  */
@@ -41,7 +41,7 @@ export type RateLimitEntry = {
41
41
  * Rate limit store interface
42
42
  * Implement this for custom storage (Redis, etc.)
43
43
  */
44
- export interface RateLimitStore {
44
+ export type RateLimitStore = {
45
45
  /**
46
46
  * Get the current entry for a key
47
47
  */
@@ -59,7 +59,7 @@ export interface RateLimitStore {
59
59
  * Reset the counter for a key
60
60
  */
61
61
  reset(key: string): Promise<void>;
62
- }
62
+ };
63
63
  /**
64
64
  * In-memory rate limit store
65
65
  */