@juspay/neurolink 9.1.1 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (555) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +106 -37
  3. package/dist/agent/directTools.d.ts +11 -11
  4. package/dist/cli/commands/config.d.ts +6 -6
  5. package/dist/cli/commands/rag.d.ts +19 -0
  6. package/dist/cli/commands/rag.js +756 -0
  7. package/dist/cli/factories/commandFactory.js +146 -83
  8. package/dist/cli/parser.js +4 -1
  9. package/dist/core/baseProvider.d.ts +43 -30
  10. package/dist/core/baseProvider.js +98 -138
  11. package/dist/core/conversationMemoryFactory.d.ts +2 -2
  12. package/dist/core/conversationMemoryFactory.js +2 -2
  13. package/dist/core/conversationMemoryInitializer.d.ts +1 -2
  14. package/dist/core/conversationMemoryInitializer.js +2 -2
  15. package/dist/core/infrastructure/baseError.d.ts +21 -0
  16. package/dist/core/infrastructure/baseError.js +22 -0
  17. package/dist/core/infrastructure/baseFactory.d.ts +21 -0
  18. package/dist/core/infrastructure/baseFactory.js +54 -0
  19. package/dist/core/infrastructure/baseRegistry.d.ts +21 -0
  20. package/dist/core/infrastructure/baseRegistry.js +49 -0
  21. package/dist/core/infrastructure/index.d.ts +5 -0
  22. package/dist/core/infrastructure/index.js +5 -0
  23. package/dist/core/infrastructure/retry.d.ts +7 -0
  24. package/dist/core/infrastructure/retry.js +20 -0
  25. package/dist/core/infrastructure/typedEventEmitter.d.ts +8 -0
  26. package/dist/core/infrastructure/typedEventEmitter.js +23 -0
  27. package/dist/core/redisConversationMemoryManager.d.ts +1 -6
  28. package/dist/core/redisConversationMemoryManager.js +7 -19
  29. package/dist/factories/providerFactory.d.ts +5 -3
  30. package/dist/factories/providerFactory.js +31 -24
  31. package/dist/image-gen/ImageGenService.d.ts +143 -0
  32. package/dist/image-gen/ImageGenService.js +345 -0
  33. package/dist/image-gen/imageGenTools.d.ts +126 -0
  34. package/dist/image-gen/imageGenTools.js +304 -0
  35. package/dist/image-gen/index.d.ts +46 -0
  36. package/dist/image-gen/index.js +48 -0
  37. package/dist/image-gen/types.d.ts +237 -0
  38. package/dist/image-gen/types.js +24 -0
  39. package/dist/index.d.ts +46 -12
  40. package/dist/index.js +88 -36
  41. package/dist/lib/agent/directTools.d.ts +8 -8
  42. package/dist/lib/core/baseProvider.d.ts +43 -30
  43. package/dist/lib/core/baseProvider.js +98 -138
  44. package/dist/lib/core/conversationMemoryFactory.d.ts +2 -2
  45. package/dist/lib/core/conversationMemoryFactory.js +2 -2
  46. package/dist/lib/core/conversationMemoryInitializer.d.ts +1 -2
  47. package/dist/lib/core/conversationMemoryInitializer.js +2 -2
  48. package/dist/lib/core/infrastructure/baseError.d.ts +21 -0
  49. package/dist/lib/core/infrastructure/baseError.js +23 -0
  50. package/dist/lib/core/infrastructure/baseFactory.d.ts +21 -0
  51. package/dist/lib/core/infrastructure/baseFactory.js +55 -0
  52. package/dist/lib/core/infrastructure/baseRegistry.d.ts +21 -0
  53. package/dist/lib/core/infrastructure/baseRegistry.js +50 -0
  54. package/dist/lib/core/infrastructure/index.d.ts +5 -0
  55. package/dist/lib/core/infrastructure/index.js +6 -0
  56. package/dist/lib/core/infrastructure/retry.d.ts +7 -0
  57. package/dist/lib/core/infrastructure/retry.js +21 -0
  58. package/dist/lib/core/infrastructure/typedEventEmitter.d.ts +8 -0
  59. package/dist/lib/core/infrastructure/typedEventEmitter.js +24 -0
  60. package/dist/lib/core/redisConversationMemoryManager.d.ts +1 -6
  61. package/dist/lib/core/redisConversationMemoryManager.js +7 -19
  62. package/dist/lib/factories/providerFactory.d.ts +5 -3
  63. package/dist/lib/factories/providerFactory.js +31 -24
  64. package/dist/lib/image-gen/ImageGenService.d.ts +143 -0
  65. package/dist/lib/image-gen/ImageGenService.js +346 -0
  66. package/dist/lib/image-gen/imageGenTools.d.ts +126 -0
  67. package/dist/lib/image-gen/imageGenTools.js +305 -0
  68. package/dist/lib/image-gen/index.d.ts +46 -0
  69. package/dist/lib/image-gen/index.js +49 -0
  70. package/dist/lib/image-gen/types.d.ts +237 -0
  71. package/dist/lib/image-gen/types.js +25 -0
  72. package/dist/lib/index.d.ts +46 -12
  73. package/dist/lib/index.js +88 -36
  74. package/dist/lib/mcp/index.d.ts +6 -5
  75. package/dist/lib/mcp/index.js +7 -5
  76. package/dist/lib/neurolink.d.ts +11 -13
  77. package/dist/lib/neurolink.js +95 -29
  78. package/dist/lib/processors/base/BaseFileProcessor.d.ts +273 -0
  79. package/dist/lib/processors/base/BaseFileProcessor.js +614 -0
  80. package/dist/lib/processors/base/index.d.ts +14 -0
  81. package/dist/lib/processors/base/index.js +20 -0
  82. package/dist/lib/processors/base/types.d.ts +593 -0
  83. package/dist/lib/processors/base/types.js +77 -0
  84. package/dist/lib/processors/cli/fileProcessorCli.d.ts +163 -0
  85. package/dist/lib/processors/cli/fileProcessorCli.js +389 -0
  86. package/dist/lib/processors/cli/index.d.ts +37 -0
  87. package/dist/lib/processors/cli/index.js +50 -0
  88. package/dist/lib/processors/code/ConfigProcessor.d.ts +171 -0
  89. package/dist/lib/processors/code/ConfigProcessor.js +401 -0
  90. package/dist/lib/processors/code/SourceCodeProcessor.d.ts +174 -0
  91. package/dist/lib/processors/code/SourceCodeProcessor.js +305 -0
  92. package/dist/lib/processors/code/index.d.ts +44 -0
  93. package/dist/lib/processors/code/index.js +61 -0
  94. package/dist/lib/processors/config/fileTypes.d.ts +283 -0
  95. package/dist/lib/processors/config/fileTypes.js +521 -0
  96. package/dist/lib/processors/config/index.d.ts +32 -0
  97. package/dist/lib/processors/config/index.js +93 -0
  98. package/dist/lib/processors/config/languageMap.d.ts +66 -0
  99. package/dist/lib/processors/config/languageMap.js +411 -0
  100. package/dist/lib/processors/config/mimeTypes.d.ts +376 -0
  101. package/dist/lib/processors/config/mimeTypes.js +339 -0
  102. package/dist/lib/processors/config/sizeLimits.d.ts +194 -0
  103. package/dist/lib/processors/config/sizeLimits.js +247 -0
  104. package/dist/lib/processors/data/JsonProcessor.d.ts +122 -0
  105. package/dist/lib/processors/data/JsonProcessor.js +204 -0
  106. package/dist/lib/processors/data/XmlProcessor.d.ts +160 -0
  107. package/dist/lib/processors/data/XmlProcessor.js +284 -0
  108. package/dist/lib/processors/data/YamlProcessor.d.ts +163 -0
  109. package/dist/lib/processors/data/YamlProcessor.js +295 -0
  110. package/dist/lib/processors/data/index.d.ts +49 -0
  111. package/dist/lib/processors/data/index.js +77 -0
  112. package/dist/lib/processors/document/ExcelProcessor.d.ts +238 -0
  113. package/dist/lib/processors/document/ExcelProcessor.js +520 -0
  114. package/dist/lib/processors/document/OpenDocumentProcessor.d.ts +69 -0
  115. package/dist/lib/processors/document/OpenDocumentProcessor.js +211 -0
  116. package/dist/lib/processors/document/RtfProcessor.d.ts +152 -0
  117. package/dist/lib/processors/document/RtfProcessor.js +362 -0
  118. package/dist/lib/processors/document/WordProcessor.d.ts +168 -0
  119. package/dist/lib/processors/document/WordProcessor.js +354 -0
  120. package/dist/lib/processors/document/index.d.ts +54 -0
  121. package/dist/lib/processors/document/index.js +91 -0
  122. package/dist/lib/processors/errors/FileErrorCode.d.ts +98 -0
  123. package/dist/lib/processors/errors/FileErrorCode.js +256 -0
  124. package/dist/lib/processors/errors/errorHelpers.d.ts +151 -0
  125. package/dist/lib/processors/errors/errorHelpers.js +379 -0
  126. package/dist/lib/processors/errors/errorSerializer.d.ts +139 -0
  127. package/dist/lib/processors/errors/errorSerializer.js +508 -0
  128. package/dist/lib/processors/errors/index.d.ts +46 -0
  129. package/dist/lib/processors/errors/index.js +50 -0
  130. package/dist/lib/processors/index.d.ts +76 -0
  131. package/dist/lib/processors/index.js +113 -0
  132. package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +244 -0
  133. package/dist/lib/processors/integration/FileProcessorIntegration.js +273 -0
  134. package/dist/lib/processors/integration/index.d.ts +42 -0
  135. package/dist/lib/processors/integration/index.js +45 -0
  136. package/dist/lib/processors/markup/HtmlProcessor.d.ts +169 -0
  137. package/dist/lib/processors/markup/HtmlProcessor.js +250 -0
  138. package/dist/lib/processors/markup/MarkdownProcessor.d.ts +165 -0
  139. package/dist/lib/processors/markup/MarkdownProcessor.js +245 -0
  140. package/dist/lib/processors/markup/SvgProcessor.d.ts +156 -0
  141. package/dist/lib/processors/markup/SvgProcessor.js +241 -0
  142. package/dist/lib/processors/markup/TextProcessor.d.ts +135 -0
  143. package/dist/lib/processors/markup/TextProcessor.js +189 -0
  144. package/dist/lib/processors/markup/index.d.ts +66 -0
  145. package/dist/lib/processors/markup/index.js +103 -0
  146. package/dist/lib/processors/registry/ProcessorRegistry.d.ts +334 -0
  147. package/dist/lib/processors/registry/ProcessorRegistry.js +609 -0
  148. package/dist/lib/processors/registry/index.d.ts +12 -0
  149. package/dist/lib/processors/registry/index.js +17 -0
  150. package/dist/lib/processors/registry/types.d.ts +53 -0
  151. package/dist/lib/processors/registry/types.js +11 -0
  152. package/dist/lib/providers/amazonBedrock.d.ts +15 -2
  153. package/dist/lib/providers/amazonBedrock.js +65 -8
  154. package/dist/lib/providers/anthropic.d.ts +3 -3
  155. package/dist/lib/providers/anthropic.js +10 -7
  156. package/dist/lib/providers/googleAiStudio.d.ts +5 -5
  157. package/dist/lib/providers/googleAiStudio.js +10 -7
  158. package/dist/lib/providers/googleVertex.d.ts +16 -4
  159. package/dist/lib/providers/googleVertex.js +72 -16
  160. package/dist/lib/providers/litellm.d.ts +3 -3
  161. package/dist/lib/providers/litellm.js +10 -10
  162. package/dist/lib/providers/mistral.d.ts +3 -3
  163. package/dist/lib/providers/mistral.js +7 -6
  164. package/dist/lib/providers/ollama.d.ts +3 -4
  165. package/dist/lib/providers/ollama.js +7 -8
  166. package/dist/lib/providers/openAI.d.ts +14 -2
  167. package/dist/lib/providers/openAI.js +60 -6
  168. package/dist/lib/providers/openRouter.d.ts +2 -2
  169. package/dist/lib/providers/openRouter.js +10 -6
  170. package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
  171. package/dist/lib/rag/ChunkerFactory.d.ts +91 -0
  172. package/dist/lib/rag/ChunkerFactory.js +321 -0
  173. package/dist/lib/rag/ChunkerRegistry.d.ts +91 -0
  174. package/dist/lib/rag/ChunkerRegistry.js +422 -0
  175. package/dist/lib/rag/chunkers/BaseChunker.d.ts +53 -0
  176. package/dist/lib/rag/chunkers/BaseChunker.js +144 -0
  177. package/dist/lib/rag/chunkers/CharacterChunker.d.ts +18 -0
  178. package/dist/lib/rag/chunkers/CharacterChunker.js +29 -0
  179. package/dist/lib/rag/chunkers/HTMLChunker.d.ts +19 -0
  180. package/dist/lib/rag/chunkers/HTMLChunker.js +39 -0
  181. package/dist/lib/rag/chunkers/JSONChunker.d.ts +19 -0
  182. package/dist/lib/rag/chunkers/JSONChunker.js +69 -0
  183. package/dist/lib/rag/chunkers/LaTeXChunker.d.ts +15 -0
  184. package/dist/lib/rag/chunkers/LaTeXChunker.js +64 -0
  185. package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +15 -0
  186. package/dist/lib/rag/chunkers/MarkdownChunker.js +103 -0
  187. package/dist/lib/rag/chunkers/RecursiveChunker.d.ts +27 -0
  188. package/dist/lib/rag/chunkers/RecursiveChunker.js +140 -0
  189. package/dist/lib/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
  190. package/dist/lib/rag/chunkers/SemanticMarkdownChunker.js +139 -0
  191. package/dist/lib/rag/chunkers/SentenceChunker.d.ts +19 -0
  192. package/dist/lib/rag/chunkers/SentenceChunker.js +67 -0
  193. package/dist/lib/rag/chunkers/TokenChunker.d.ts +19 -0
  194. package/dist/lib/rag/chunkers/TokenChunker.js +62 -0
  195. package/dist/lib/rag/chunkers/index.d.ts +15 -0
  196. package/dist/lib/rag/chunkers/index.js +16 -0
  197. package/dist/lib/rag/chunking/characterChunker.d.ts +16 -0
  198. package/dist/lib/rag/chunking/characterChunker.js +143 -0
  199. package/dist/lib/rag/chunking/chunkerRegistry.d.ts +67 -0
  200. package/dist/lib/rag/chunking/chunkerRegistry.js +195 -0
  201. package/dist/lib/rag/chunking/htmlChunker.d.ts +34 -0
  202. package/dist/lib/rag/chunking/htmlChunker.js +248 -0
  203. package/dist/lib/rag/chunking/index.d.ts +15 -0
  204. package/dist/lib/rag/chunking/index.js +18 -0
  205. package/dist/lib/rag/chunking/jsonChunker.d.ts +20 -0
  206. package/dist/lib/rag/chunking/jsonChunker.js +282 -0
  207. package/dist/lib/rag/chunking/latexChunker.d.ts +26 -0
  208. package/dist/lib/rag/chunking/latexChunker.js +252 -0
  209. package/dist/lib/rag/chunking/markdownChunker.d.ts +19 -0
  210. package/dist/lib/rag/chunking/markdownChunker.js +202 -0
  211. package/dist/lib/rag/chunking/recursiveChunker.d.ts +19 -0
  212. package/dist/lib/rag/chunking/recursiveChunker.js +149 -0
  213. package/dist/lib/rag/chunking/semanticChunker.d.ts +41 -0
  214. package/dist/lib/rag/chunking/semanticChunker.js +307 -0
  215. package/dist/lib/rag/chunking/sentenceChunker.d.ts +25 -0
  216. package/dist/lib/rag/chunking/sentenceChunker.js +231 -0
  217. package/dist/lib/rag/chunking/tokenChunker.d.ts +36 -0
  218. package/dist/lib/rag/chunking/tokenChunker.js +184 -0
  219. package/dist/lib/rag/document/MDocument.d.ts +198 -0
  220. package/dist/lib/rag/document/MDocument.js +393 -0
  221. package/dist/lib/rag/document/index.d.ts +5 -0
  222. package/dist/lib/rag/document/index.js +6 -0
  223. package/dist/lib/rag/document/loaders.d.ts +201 -0
  224. package/dist/lib/rag/document/loaders.js +501 -0
  225. package/dist/lib/rag/errors/RAGError.d.ts +244 -0
  226. package/dist/lib/rag/errors/RAGError.js +275 -0
  227. package/dist/lib/rag/errors/index.d.ts +6 -0
  228. package/dist/lib/rag/errors/index.js +7 -0
  229. package/dist/lib/rag/graphRag/graphRAG.d.ts +115 -0
  230. package/dist/lib/rag/graphRag/graphRAG.js +385 -0
  231. package/dist/lib/rag/graphRag/index.d.ts +4 -0
  232. package/dist/lib/rag/graphRag/index.js +5 -0
  233. package/dist/lib/rag/index.d.ts +103 -0
  234. package/dist/lib/rag/index.js +142 -0
  235. package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
  236. package/dist/lib/rag/metadata/MetadataExtractorFactory.js +419 -0
  237. package/dist/lib/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
  238. package/dist/lib/rag/metadata/MetadataExtractorRegistry.js +363 -0
  239. package/dist/lib/rag/metadata/index.d.ts +6 -0
  240. package/dist/lib/rag/metadata/index.js +10 -0
  241. package/dist/lib/rag/metadata/metadataExtractor.d.ts +69 -0
  242. package/dist/lib/rag/metadata/metadataExtractor.js +278 -0
  243. package/dist/lib/rag/pipeline/RAGPipeline.d.ts +235 -0
  244. package/dist/lib/rag/pipeline/RAGPipeline.js +402 -0
  245. package/dist/lib/rag/pipeline/contextAssembly.d.ts +126 -0
  246. package/dist/lib/rag/pipeline/contextAssembly.js +338 -0
  247. package/dist/lib/rag/pipeline/index.d.ts +5 -0
  248. package/dist/lib/rag/pipeline/index.js +6 -0
  249. package/dist/lib/rag/ragIntegration.d.ts +38 -0
  250. package/dist/lib/rag/ragIntegration.js +212 -0
  251. package/dist/lib/rag/reranker/RerankerFactory.d.ts +184 -0
  252. package/dist/lib/rag/reranker/RerankerFactory.js +431 -0
  253. package/dist/lib/rag/reranker/RerankerRegistry.d.ts +119 -0
  254. package/dist/lib/rag/reranker/RerankerRegistry.js +403 -0
  255. package/dist/lib/rag/reranker/index.d.ts +6 -0
  256. package/dist/lib/rag/reranker/index.js +10 -0
  257. package/dist/lib/rag/reranker/reranker.d.ts +71 -0
  258. package/dist/lib/rag/reranker/reranker.js +278 -0
  259. package/dist/lib/rag/resilience/CircuitBreaker.d.ts +215 -0
  260. package/dist/lib/rag/resilience/CircuitBreaker.js +432 -0
  261. package/dist/lib/rag/resilience/RetryHandler.d.ts +115 -0
  262. package/dist/lib/rag/resilience/RetryHandler.js +301 -0
  263. package/dist/lib/rag/resilience/index.d.ts +7 -0
  264. package/dist/lib/rag/resilience/index.js +8 -0
  265. package/dist/lib/rag/retrieval/hybridSearch.d.ts +94 -0
  266. package/dist/lib/rag/retrieval/hybridSearch.js +314 -0
  267. package/dist/lib/rag/retrieval/index.d.ts +5 -0
  268. package/dist/lib/rag/retrieval/index.js +6 -0
  269. package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +93 -0
  270. package/dist/lib/rag/retrieval/vectorQueryTool.js +290 -0
  271. package/dist/lib/rag/types.d.ts +768 -0
  272. package/dist/lib/rag/types.js +9 -0
  273. package/dist/lib/server/index.d.ts +15 -11
  274. package/dist/lib/server/index.js +55 -51
  275. package/dist/lib/server/utils/validation.d.ts +2 -2
  276. package/dist/lib/types/common.d.ts +0 -1
  277. package/dist/lib/types/fileTypes.d.ts +1 -1
  278. package/dist/lib/types/generateTypes.d.ts +42 -8
  279. package/dist/lib/types/generateTypes.js +1 -1
  280. package/dist/lib/types/index.d.ts +25 -24
  281. package/dist/lib/types/index.js +21 -20
  282. package/dist/lib/types/modelTypes.d.ts +16 -16
  283. package/dist/lib/types/pptTypes.d.ts +14 -2
  284. package/dist/lib/types/pptTypes.js +16 -0
  285. package/dist/lib/types/streamTypes.d.ts +28 -8
  286. package/dist/lib/types/streamTypes.js +1 -1
  287. package/dist/lib/utils/async/delay.d.ts +40 -0
  288. package/dist/lib/utils/async/delay.js +43 -0
  289. package/dist/lib/utils/async/index.d.ts +23 -0
  290. package/dist/lib/utils/async/index.js +24 -0
  291. package/dist/lib/utils/async/retry.d.ts +141 -0
  292. package/dist/lib/utils/async/retry.js +172 -0
  293. package/dist/lib/utils/async/withTimeout.d.ts +73 -0
  294. package/dist/lib/utils/async/withTimeout.js +97 -0
  295. package/dist/lib/utils/fileDetector.d.ts +7 -1
  296. package/dist/lib/utils/fileDetector.js +91 -18
  297. package/dist/lib/utils/json/extract.d.ts +103 -0
  298. package/dist/lib/utils/json/extract.js +249 -0
  299. package/dist/lib/utils/json/index.d.ts +36 -0
  300. package/dist/lib/utils/json/index.js +37 -0
  301. package/dist/lib/utils/json/safeParse.d.ts +137 -0
  302. package/dist/lib/utils/json/safeParse.js +191 -0
  303. package/dist/lib/utils/messageBuilder.d.ts +2 -2
  304. package/dist/lib/utils/messageBuilder.js +15 -7
  305. package/dist/lib/utils/modelRouter.d.ts +4 -4
  306. package/dist/lib/utils/modelRouter.js +4 -4
  307. package/dist/lib/utils/sanitizers/filename.d.ts +137 -0
  308. package/dist/lib/utils/sanitizers/filename.js +366 -0
  309. package/dist/lib/utils/sanitizers/html.d.ts +170 -0
  310. package/dist/lib/utils/sanitizers/html.js +326 -0
  311. package/dist/lib/utils/sanitizers/index.d.ts +26 -0
  312. package/dist/lib/utils/sanitizers/index.js +30 -0
  313. package/dist/lib/utils/sanitizers/svg.d.ts +81 -0
  314. package/dist/lib/utils/sanitizers/svg.js +483 -0
  315. package/dist/mcp/index.d.ts +6 -5
  316. package/dist/mcp/index.js +7 -5
  317. package/dist/neurolink.d.ts +11 -13
  318. package/dist/neurolink.js +95 -29
  319. package/dist/processors/base/BaseFileProcessor.d.ts +273 -0
  320. package/dist/processors/base/BaseFileProcessor.js +613 -0
  321. package/dist/processors/base/index.d.ts +14 -0
  322. package/dist/processors/base/index.js +19 -0
  323. package/dist/processors/base/types.d.ts +593 -0
  324. package/dist/processors/base/types.js +76 -0
  325. package/dist/processors/cli/fileProcessorCli.d.ts +163 -0
  326. package/dist/processors/cli/fileProcessorCli.js +388 -0
  327. package/dist/processors/cli/index.d.ts +37 -0
  328. package/dist/processors/cli/index.js +49 -0
  329. package/dist/processors/code/ConfigProcessor.d.ts +171 -0
  330. package/dist/processors/code/ConfigProcessor.js +400 -0
  331. package/dist/processors/code/SourceCodeProcessor.d.ts +174 -0
  332. package/dist/processors/code/SourceCodeProcessor.js +304 -0
  333. package/dist/processors/code/index.d.ts +44 -0
  334. package/dist/processors/code/index.js +60 -0
  335. package/dist/processors/config/fileTypes.d.ts +283 -0
  336. package/dist/processors/config/fileTypes.js +520 -0
  337. package/dist/processors/config/index.d.ts +32 -0
  338. package/dist/processors/config/index.js +92 -0
  339. package/dist/processors/config/languageMap.d.ts +66 -0
  340. package/dist/processors/config/languageMap.js +410 -0
  341. package/dist/processors/config/mimeTypes.d.ts +376 -0
  342. package/dist/processors/config/mimeTypes.js +338 -0
  343. package/dist/processors/config/sizeLimits.d.ts +194 -0
  344. package/dist/processors/config/sizeLimits.js +246 -0
  345. package/dist/processors/data/JsonProcessor.d.ts +122 -0
  346. package/dist/processors/data/JsonProcessor.js +203 -0
  347. package/dist/processors/data/XmlProcessor.d.ts +160 -0
  348. package/dist/processors/data/XmlProcessor.js +283 -0
  349. package/dist/processors/data/YamlProcessor.d.ts +163 -0
  350. package/dist/processors/data/YamlProcessor.js +294 -0
  351. package/dist/processors/data/index.d.ts +49 -0
  352. package/dist/processors/data/index.js +76 -0
  353. package/dist/processors/document/ExcelProcessor.d.ts +238 -0
  354. package/dist/processors/document/ExcelProcessor.js +519 -0
  355. package/dist/processors/document/OpenDocumentProcessor.d.ts +69 -0
  356. package/dist/processors/document/OpenDocumentProcessor.js +210 -0
  357. package/dist/processors/document/RtfProcessor.d.ts +152 -0
  358. package/dist/processors/document/RtfProcessor.js +361 -0
  359. package/dist/processors/document/WordProcessor.d.ts +168 -0
  360. package/dist/processors/document/WordProcessor.js +353 -0
  361. package/dist/processors/document/index.d.ts +54 -0
  362. package/dist/processors/document/index.js +90 -0
  363. package/dist/processors/errors/FileErrorCode.d.ts +98 -0
  364. package/dist/processors/errors/FileErrorCode.js +255 -0
  365. package/dist/processors/errors/errorHelpers.d.ts +151 -0
  366. package/dist/processors/errors/errorHelpers.js +378 -0
  367. package/dist/processors/errors/errorSerializer.d.ts +139 -0
  368. package/dist/processors/errors/errorSerializer.js +507 -0
  369. package/dist/processors/errors/index.d.ts +46 -0
  370. package/dist/processors/errors/index.js +49 -0
  371. package/dist/processors/index.d.ts +76 -0
  372. package/dist/processors/index.js +112 -0
  373. package/dist/processors/integration/FileProcessorIntegration.d.ts +244 -0
  374. package/dist/processors/integration/FileProcessorIntegration.js +272 -0
  375. package/dist/processors/integration/index.d.ts +42 -0
  376. package/dist/processors/integration/index.js +44 -0
  377. package/dist/processors/markup/HtmlProcessor.d.ts +169 -0
  378. package/dist/processors/markup/HtmlProcessor.js +249 -0
  379. package/dist/processors/markup/MarkdownProcessor.d.ts +165 -0
  380. package/dist/processors/markup/MarkdownProcessor.js +244 -0
  381. package/dist/processors/markup/SvgProcessor.d.ts +156 -0
  382. package/dist/processors/markup/SvgProcessor.js +240 -0
  383. package/dist/processors/markup/TextProcessor.d.ts +135 -0
  384. package/dist/processors/markup/TextProcessor.js +188 -0
  385. package/dist/processors/markup/index.d.ts +66 -0
  386. package/dist/processors/markup/index.js +102 -0
  387. package/dist/processors/registry/ProcessorRegistry.d.ts +334 -0
  388. package/dist/processors/registry/ProcessorRegistry.js +608 -0
  389. package/dist/processors/registry/index.d.ts +12 -0
  390. package/dist/processors/registry/index.js +16 -0
  391. package/dist/processors/registry/types.d.ts +53 -0
  392. package/dist/processors/registry/types.js +10 -0
  393. package/dist/providers/amazonBedrock.d.ts +15 -2
  394. package/dist/providers/amazonBedrock.js +65 -8
  395. package/dist/providers/anthropic.d.ts +3 -3
  396. package/dist/providers/anthropic.js +10 -7
  397. package/dist/providers/googleAiStudio.d.ts +5 -5
  398. package/dist/providers/googleAiStudio.js +10 -7
  399. package/dist/providers/googleVertex.d.ts +16 -4
  400. package/dist/providers/googleVertex.js +72 -16
  401. package/dist/providers/litellm.d.ts +3 -3
  402. package/dist/providers/litellm.js +10 -10
  403. package/dist/providers/mistral.d.ts +3 -3
  404. package/dist/providers/mistral.js +7 -6
  405. package/dist/providers/ollama.d.ts +3 -4
  406. package/dist/providers/ollama.js +7 -8
  407. package/dist/providers/openAI.d.ts +14 -2
  408. package/dist/providers/openAI.js +60 -6
  409. package/dist/providers/openRouter.d.ts +2 -2
  410. package/dist/providers/openRouter.js +10 -6
  411. package/dist/rag/ChunkerFactory.d.ts +91 -0
  412. package/dist/rag/ChunkerFactory.js +320 -0
  413. package/dist/rag/ChunkerRegistry.d.ts +91 -0
  414. package/dist/rag/ChunkerRegistry.js +421 -0
  415. package/dist/rag/chunkers/BaseChunker.d.ts +53 -0
  416. package/dist/rag/chunkers/BaseChunker.js +143 -0
  417. package/dist/rag/chunkers/CharacterChunker.d.ts +18 -0
  418. package/dist/rag/chunkers/CharacterChunker.js +28 -0
  419. package/dist/rag/chunkers/HTMLChunker.d.ts +19 -0
  420. package/dist/rag/chunkers/HTMLChunker.js +38 -0
  421. package/dist/rag/chunkers/JSONChunker.d.ts +19 -0
  422. package/dist/rag/chunkers/JSONChunker.js +68 -0
  423. package/dist/rag/chunkers/LaTeXChunker.d.ts +15 -0
  424. package/dist/rag/chunkers/LaTeXChunker.js +63 -0
  425. package/dist/rag/chunkers/MarkdownChunker.d.ts +15 -0
  426. package/dist/rag/chunkers/MarkdownChunker.js +102 -0
  427. package/dist/rag/chunkers/RecursiveChunker.d.ts +27 -0
  428. package/dist/rag/chunkers/RecursiveChunker.js +139 -0
  429. package/dist/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
  430. package/dist/rag/chunkers/SemanticMarkdownChunker.js +138 -0
  431. package/dist/rag/chunkers/SentenceChunker.d.ts +19 -0
  432. package/dist/rag/chunkers/SentenceChunker.js +66 -0
  433. package/dist/rag/chunkers/TokenChunker.d.ts +19 -0
  434. package/dist/rag/chunkers/TokenChunker.js +61 -0
  435. package/dist/rag/chunkers/index.d.ts +15 -0
  436. package/dist/rag/chunkers/index.js +15 -0
  437. package/dist/rag/chunking/characterChunker.d.ts +16 -0
  438. package/dist/rag/chunking/characterChunker.js +142 -0
  439. package/dist/rag/chunking/chunkerRegistry.d.ts +67 -0
  440. package/dist/rag/chunking/chunkerRegistry.js +194 -0
  441. package/dist/rag/chunking/htmlChunker.d.ts +34 -0
  442. package/dist/rag/chunking/htmlChunker.js +247 -0
  443. package/dist/rag/chunking/index.d.ts +15 -0
  444. package/dist/rag/chunking/index.js +17 -0
  445. package/dist/rag/chunking/jsonChunker.d.ts +20 -0
  446. package/dist/rag/chunking/jsonChunker.js +281 -0
  447. package/dist/rag/chunking/latexChunker.d.ts +26 -0
  448. package/dist/rag/chunking/latexChunker.js +251 -0
  449. package/dist/rag/chunking/markdownChunker.d.ts +19 -0
  450. package/dist/rag/chunking/markdownChunker.js +201 -0
  451. package/dist/rag/chunking/recursiveChunker.d.ts +19 -0
  452. package/dist/rag/chunking/recursiveChunker.js +148 -0
  453. package/dist/rag/chunking/semanticChunker.d.ts +41 -0
  454. package/dist/rag/chunking/semanticChunker.js +306 -0
  455. package/dist/rag/chunking/sentenceChunker.d.ts +25 -0
  456. package/dist/rag/chunking/sentenceChunker.js +230 -0
  457. package/dist/rag/chunking/tokenChunker.d.ts +36 -0
  458. package/dist/rag/chunking/tokenChunker.js +183 -0
  459. package/dist/rag/document/MDocument.d.ts +198 -0
  460. package/dist/rag/document/MDocument.js +392 -0
  461. package/dist/rag/document/index.d.ts +5 -0
  462. package/dist/rag/document/index.js +5 -0
  463. package/dist/rag/document/loaders.d.ts +201 -0
  464. package/dist/rag/document/loaders.js +500 -0
  465. package/dist/rag/errors/RAGError.d.ts +244 -0
  466. package/dist/rag/errors/RAGError.js +274 -0
  467. package/dist/rag/errors/index.d.ts +6 -0
  468. package/dist/rag/errors/index.js +6 -0
  469. package/dist/rag/graphRag/graphRAG.d.ts +115 -0
  470. package/dist/rag/graphRag/graphRAG.js +384 -0
  471. package/dist/rag/graphRag/index.d.ts +4 -0
  472. package/dist/rag/graphRag/index.js +4 -0
  473. package/dist/rag/index.d.ts +103 -0
  474. package/dist/rag/index.js +141 -0
  475. package/dist/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
  476. package/dist/rag/metadata/MetadataExtractorFactory.js +418 -0
  477. package/dist/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
  478. package/dist/rag/metadata/MetadataExtractorRegistry.js +362 -0
  479. package/dist/rag/metadata/index.d.ts +6 -0
  480. package/dist/rag/metadata/index.js +9 -0
  481. package/dist/rag/metadata/metadataExtractor.d.ts +69 -0
  482. package/dist/rag/metadata/metadataExtractor.js +277 -0
  483. package/dist/rag/pipeline/RAGPipeline.d.ts +235 -0
  484. package/dist/rag/pipeline/RAGPipeline.js +401 -0
  485. package/dist/rag/pipeline/contextAssembly.d.ts +126 -0
  486. package/dist/rag/pipeline/contextAssembly.js +337 -0
  487. package/dist/rag/pipeline/index.d.ts +5 -0
  488. package/dist/rag/pipeline/index.js +5 -0
  489. package/dist/rag/ragIntegration.d.ts +38 -0
  490. package/dist/rag/ragIntegration.js +211 -0
  491. package/dist/rag/reranker/RerankerFactory.d.ts +184 -0
  492. package/dist/rag/reranker/RerankerFactory.js +430 -0
  493. package/dist/rag/reranker/RerankerRegistry.d.ts +119 -0
  494. package/dist/rag/reranker/RerankerRegistry.js +402 -0
  495. package/dist/rag/reranker/index.d.ts +6 -0
  496. package/dist/rag/reranker/index.js +9 -0
  497. package/dist/rag/reranker/reranker.d.ts +71 -0
  498. package/dist/rag/reranker/reranker.js +277 -0
  499. package/dist/rag/resilience/CircuitBreaker.d.ts +215 -0
  500. package/dist/rag/resilience/CircuitBreaker.js +431 -0
  501. package/dist/rag/resilience/RetryHandler.d.ts +115 -0
  502. package/dist/rag/resilience/RetryHandler.js +300 -0
  503. package/dist/rag/resilience/index.d.ts +7 -0
  504. package/dist/rag/resilience/index.js +7 -0
  505. package/dist/rag/retrieval/hybridSearch.d.ts +94 -0
  506. package/dist/rag/retrieval/hybridSearch.js +313 -0
  507. package/dist/rag/retrieval/index.d.ts +5 -0
  508. package/dist/rag/retrieval/index.js +5 -0
  509. package/dist/rag/retrieval/vectorQueryTool.d.ts +93 -0
  510. package/dist/rag/retrieval/vectorQueryTool.js +289 -0
  511. package/dist/rag/types.d.ts +768 -0
  512. package/dist/rag/types.js +8 -0
  513. package/dist/server/index.d.ts +15 -11
  514. package/dist/server/index.js +55 -51
  515. package/dist/server/utils/validation.d.ts +8 -8
  516. package/dist/types/common.d.ts +0 -1
  517. package/dist/types/fileTypes.d.ts +1 -1
  518. package/dist/types/generateTypes.d.ts +42 -8
  519. package/dist/types/generateTypes.js +1 -1
  520. package/dist/types/index.d.ts +25 -24
  521. package/dist/types/index.js +21 -20
  522. package/dist/types/modelTypes.d.ts +10 -10
  523. package/dist/types/pptTypes.d.ts +14 -2
  524. package/dist/types/pptTypes.js +16 -0
  525. package/dist/types/streamTypes.d.ts +28 -8
  526. package/dist/types/streamTypes.js +1 -1
  527. package/dist/utils/async/delay.d.ts +40 -0
  528. package/dist/utils/async/delay.js +42 -0
  529. package/dist/utils/async/index.d.ts +23 -0
  530. package/dist/utils/async/index.js +23 -0
  531. package/dist/utils/async/retry.d.ts +141 -0
  532. package/dist/utils/async/retry.js +171 -0
  533. package/dist/utils/async/withTimeout.d.ts +73 -0
  534. package/dist/utils/async/withTimeout.js +96 -0
  535. package/dist/utils/fileDetector.d.ts +7 -1
  536. package/dist/utils/fileDetector.js +91 -18
  537. package/dist/utils/json/extract.d.ts +103 -0
  538. package/dist/utils/json/extract.js +248 -0
  539. package/dist/utils/json/index.d.ts +36 -0
  540. package/dist/utils/json/index.js +36 -0
  541. package/dist/utils/json/safeParse.d.ts +137 -0
  542. package/dist/utils/json/safeParse.js +190 -0
  543. package/dist/utils/messageBuilder.d.ts +2 -2
  544. package/dist/utils/messageBuilder.js +15 -7
  545. package/dist/utils/modelRouter.d.ts +4 -4
  546. package/dist/utils/modelRouter.js +4 -4
  547. package/dist/utils/sanitizers/filename.d.ts +137 -0
  548. package/dist/utils/sanitizers/filename.js +365 -0
  549. package/dist/utils/sanitizers/html.d.ts +170 -0
  550. package/dist/utils/sanitizers/html.js +325 -0
  551. package/dist/utils/sanitizers/index.d.ts +26 -0
  552. package/dist/utils/sanitizers/index.js +29 -0
  553. package/dist/utils/sanitizers/svg.d.ts +81 -0
  554. package/dist/utils/sanitizers/svg.js +482 -0
  555. package/package.json +2 -2
@@ -0,0 +1,113 @@
1
+ /**
2
+ * File Processors Module
3
+ *
4
+ * Comprehensive file processing infrastructure for NeuroLink.
5
+ * Provides base classes, configuration, error handling, and registry
6
+ * for building and managing file processors.
7
+ *
8
+ * @module processors
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import {
13
+ * // Base processor infrastructure
14
+ * BaseFileProcessor,
15
+ * type FileInfo,
16
+ * type FileProcessingResult,
17
+ * type ProcessedFileBase,
18
+ *
19
+ * // Configuration
20
+ * MIME_TYPES,
21
+ * FILE_EXTENSIONS,
22
+ * SIZE_LIMITS,
23
+ *
24
+ * // Error handling
25
+ * FileErrorCode,
26
+ * createFileError,
27
+ *
28
+ * // Registry
29
+ * ProcessorRegistry,
30
+ * getProcessorRegistry,
31
+ * PROCESSOR_PRIORITIES,
32
+ * } from "./processors/index.js";
33
+ *
34
+ * // Create a custom processor
35
+ * class MyProcessor extends BaseFileProcessor<MyProcessedFile> {
36
+ * constructor() {
37
+ * super({
38
+ * maxSizeMB: 10,
39
+ * timeoutMs: 30000,
40
+ * supportedMimeTypes: ["application/x-custom"],
41
+ * supportedExtensions: [".custom"],
42
+ * fileTypeName: "custom",
43
+ * defaultFilename: "file.custom",
44
+ * });
45
+ * }
46
+ *
47
+ * protected buildProcessedResult(buffer: Buffer, fileInfo: FileInfo): MyProcessedFile {
48
+ * return {
49
+ * buffer,
50
+ * mimetype: fileInfo.mimetype,
51
+ * size: buffer.length,
52
+ * filename: this.getFilename(fileInfo),
53
+ * };
54
+ * }
55
+ * }
56
+ *
57
+ * // Register with the registry
58
+ * const registry = getProcessorRegistry();
59
+ * registry.register({
60
+ * name: "custom",
61
+ * priority: 100,
62
+ * processor: new MyProcessor(),
63
+ * isSupported: (mimetype) => mimetype === "application/x-custom",
64
+ * });
65
+ * ```
66
+ */
67
+ // =============================================================================
68
+ // BASE PROCESSOR INFRASTRUCTURE (single source of truth for ALL types)
69
+ // =============================================================================
70
+ export {
71
+ // Base class
72
+ BaseFileProcessor,
73
+ // Constants
74
+ DEFAULT_IMAGE_MAX_SIZE_MB, DEFAULT_IMAGE_TIMEOUT_MS, DEFAULT_RETRY_CONFIG, DEFAULT_TEXT_MAX_SIZE_MB, DEFAULT_TEXT_TIMEOUT_MS,
75
+ // Utility functions
76
+ getDefaultImageMaxSizeMB, getDefaultImageTimeout, getDefaultTextMaxSizeMB, getDefaultTextTimeout, PROCESSOR_PRIORITIES, } from "./base/index.js";
77
+ // =============================================================================
78
+ // CONFIGURATION
79
+ // =============================================================================
80
+ export { AI_VISION_EXTENSIONS, ARCHIVE_EXTENSIONS, ARCHIVE_LIMITS, ARCHIVE_MIME_TYPES, AUDIO_EXTENSIONS, AUDIO_MIME_TYPES, bytesToMB, CONFIG_EXTENSIONS, CSV_EXTENSIONS, DATA_EXTENSIONS, DATA_MIME_TYPES, DATABASE_EXTENSIONS, DESIGN_EXTENSIONS, DOCUMENT_EXTENSIONS, DOCUMENT_MIME_TYPES, detectLanguageFromFilename, EXACT_FILENAME_MAP, EXCEL_EXTENSIONS, EXECUTABLE_EXTENSIONS, FILE_EXTENSIONS, formatBytes, getLanguageIdentifier, getSizeLimitForType, getSupportedExtensions, getSupportedFilenames, HTML_EXTENSIONS, IMAGE_EXTENSIONS, IMAGE_MIME_TYPES, isSourceCodeFile, isWithinSizeLimit, JSON_EXTENSIONS, LANGUAGE_MAP, MARKDOWN_EXTENSIONS, MIME_TYPES, mbToBytes, OPENDOCUMENT_EXTENSIONS, PDF_EXTENSIONS, POWERPOINT_EXTENSIONS, PROCESSING_LIMITS, RTF_EXTENSIONS, SIZE_LIMITS, SIZE_LIMITS_BYTES, SIZE_LIMITS_MB, SOURCE_CODE_EXTENSIONS, SOURCE_CODE_MIME_TYPES, TEXT_EXTENSIONS, TEXT_MIME_TYPES, VIDEO_EXTENSIONS, VIDEO_MIME_TYPES, validateFileSize, WORD_EXTENSIONS, XML_EXTENSIONS, YAML_EXTENSIONS, YAML_LIMITS, } from "./config/index.js";
81
+ // =============================================================================
82
+ // ERROR HANDLING (functions and runtime values only — types come from base)
83
+ // =============================================================================
84
+ export { combineSummaries, createCustomFileError, createFileError, createProcessingSummary, ERROR_MESSAGES, extractHttpStatus, extractSafeMetadata, FileErrorCode, formatFileError, generateErrorFingerprint, getErrorTemplate, getRetryDelay, isFileProcessingError, isRetryableError, isRetryableErrorCode, mapErrorToCode, safeStringify, serializeError, summarizeError, } from "./errors/index.js";
85
+ // =============================================================================
86
+ // PROCESSOR REGISTRY (class and registration type only — shared types from base)
87
+ // =============================================================================
88
+ export { getProcessorRegistry, ProcessorRegistry, } from "./registry/index.js";
89
+ // =============================================================================
90
+ // MARKUP PROCESSORS
91
+ // =============================================================================
92
+ export { HtmlProcessor, htmlProcessor, isHtmlFile, isMarkdownFile, isSvgFile, isTextFile, MarkdownProcessor, markdownProcessor, processHtml, processMarkdown, processSvg, processText, SvgProcessor, svgProcessor, TextProcessor, textProcessor, validateHtmlSize, validateMarkdownSize, validateSvgSize, } from "./markup/index.js";
93
+ // =============================================================================
94
+ // CODE PROCESSORS
95
+ // =============================================================================
96
+ export { ConfigProcessor, configProcessor, detectLanguage, isConfigFile, processConfig, processSourceCode, SourceCodeProcessor, sourceCodeProcessor, validateSourceCodeSize, } from "./code/index.js";
97
+ // =============================================================================
98
+ // DATA PROCESSORS
99
+ // =============================================================================
100
+ export { isJsonFile, isXmlFile, isYamlFile, JsonProcessor, jsonProcessor, processJson, processXml, processYaml, validateJsonSize, validateXmlSize, validateYamlSize, XmlProcessor, xmlProcessor, YamlProcessor, yamlProcessor, } from "./data/index.js";
101
+ // =============================================================================
102
+ // DOCUMENT PROCESSORS
103
+ // =============================================================================
104
+ export { ExcelProcessor, excelProcessor, getExcelMaxRows, getExcelMaxSheets, getExcelMaxSizeMB, getOpenDocumentMaxSizeMB, isExcelFile, isOpenDocumentFile, isRtfFile, isWordFile, OpenDocumentProcessor, openDocumentProcessor, processExcel, processOpenDocument, processRtf, processWord, RtfProcessor, rtfProcessor, validateExcelSize, validateOpenDocumentSize, validateRtfSize, validateWordSize, WordProcessor, wordProcessor, } from "./document/index.js";
105
+ // =============================================================================
106
+ // FILE PROCESSOR INTEGRATION
107
+ // =============================================================================
108
+ export { getProcessorForFile, getSupportedFileTypes, isFileTypeSupported, processBatchWithRegistry, processFileWithRegistry, } from "./integration/index.js";
109
+ // =============================================================================
110
+ // CLI HELPERS
111
+ // =============================================================================
112
+ export { detectMimeType, fileExists, getCliUsage, getFileExtension, getSupportedFileTypes as getCliSupportedFileTypes, listSupportedFileTypes, loadFileFromPath, processFileFromPath, } from "./cli/index.js";
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,244 @@
1
+ /**
2
+ * File Processor Integration
3
+ *
4
+ * Provides integration between the ProcessorRegistry and message building.
5
+ * This module allows for automatic file type detection and processing
6
+ * using the registered file processors.
7
+ *
8
+ * @module processors/integration/FileProcessorIntegration
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import {
13
+ * processFileWithRegistry,
14
+ * processBatchWithRegistry,
15
+ * getSupportedFileTypes,
16
+ * isFileTypeSupported,
17
+ * getProcessorForFile,
18
+ * } from "./integration/index.js";
19
+ *
20
+ * // Process a single file
21
+ * const { processorName, result } = await processFileWithRegistry(fileInfo);
22
+ * if (result?.success) {
23
+ * console.log(`Processed with ${processorName}:`, result.data);
24
+ * }
25
+ *
26
+ * // Process multiple files
27
+ * const batchResult = await processBatchWithRegistry(files, { maxFiles: 50 });
28
+ * console.log(`Successful: ${batchResult.successful.length}`);
29
+ * console.log(`Failed: ${batchResult.failed.length}`);
30
+ * console.log(`Skipped: ${batchResult.skipped.length}`);
31
+ *
32
+ * // Check if a file type is supported
33
+ * if (isFileTypeSupported("application/pdf", "document.pdf")) {
34
+ * console.log("PDF files are supported");
35
+ * }
36
+ * ```
37
+ */
38
+ import type { FileInfo, FileProcessingResult, ProcessedFileBase, ProcessOptions, ProcessorMatch } from "../base/types.js";
39
+ /**
40
+ * Options for processing files through the registry.
41
+ * Extends base ProcessOptions with registry-specific options.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const options: FileProcessingOptions = {
46
+ * // Base options
47
+ * authHeaders: { Authorization: "Bearer token" },
48
+ * timeout: 60000,
49
+ *
50
+ * // Registry-specific options
51
+ * preferredProcessor: "pdf", // Use specific processor
52
+ * allowFallback: true, // Allow fallback if no processor found
53
+ * maxFiles: 50, // Limit batch processing
54
+ * };
55
+ * ```
56
+ */
57
+ export interface FileProcessingOptions extends ProcessOptions {
58
+ /** Preferred processor name (bypasses auto-detection) */
59
+ preferredProcessor?: string;
60
+ /** Whether to fall back to default processing if no processor found */
61
+ allowFallback?: boolean;
62
+ /** Maximum number of files to process (default: 100) */
63
+ maxFiles?: number;
64
+ }
65
+ /**
66
+ * Result of processing multiple files through the registry.
67
+ * Categorizes files into successful, failed, and skipped.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = await processBatchWithRegistry(files);
72
+ *
73
+ * // Handle successful files
74
+ * for (const { fileInfo, processorName, result } of result.successful) {
75
+ * console.log(`${fileInfo.name}: processed by ${processorName}`);
76
+ * }
77
+ *
78
+ * // Handle failed files
79
+ * for (const { fileInfo, error } of result.failed) {
80
+ * console.error(`${fileInfo.name}: ${error}`);
81
+ * }
82
+ *
83
+ * // Handle skipped files
84
+ * for (const { fileInfo, reason } of result.skipped) {
85
+ * console.warn(`${fileInfo.name}: ${reason}`);
86
+ * }
87
+ * ```
88
+ */
89
+ export interface BatchFileProcessingResult {
90
+ /** Successfully processed files */
91
+ successful: Array<{
92
+ fileInfo: FileInfo;
93
+ processorName: string;
94
+ result: FileProcessingResult<ProcessedFileBase>;
95
+ }>;
96
+ /** Files that failed to process */
97
+ failed: Array<{
98
+ fileInfo: FileInfo;
99
+ error: string;
100
+ }>;
101
+ /** Files that were skipped (no processor found or over limit) */
102
+ skipped: Array<{
103
+ fileInfo: FileInfo;
104
+ reason: string;
105
+ }>;
106
+ }
107
+ /**
108
+ * Process a single file using the ProcessorRegistry.
109
+ * Automatically detects the appropriate processor based on MIME type and filename.
110
+ *
111
+ * @param fileInfo - File information including content/URL
112
+ * @param options - Processing options (preferred processor, auth headers, timeout)
113
+ * @returns Object containing processor name (null if none found) and processing result
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Basic usage - auto-detect processor
118
+ * const { processorName, result } = await processFileWithRegistry({
119
+ * id: "file-123",
120
+ * name: "document.pdf",
121
+ * mimetype: "application/pdf",
122
+ * size: 1024000,
123
+ * url: "https://example.com/document.pdf",
124
+ * });
125
+ *
126
+ * if (result?.success) {
127
+ * console.log(`Processed by ${processorName}:`, result.data);
128
+ * }
129
+ *
130
+ * // Use a specific processor
131
+ * const { result } = await processFileWithRegistry(fileInfo, {
132
+ * preferredProcessor: "pdf",
133
+ * });
134
+ *
135
+ * // With authentication and timeout
136
+ * const { result } = await processFileWithRegistry(fileInfo, {
137
+ * authHeaders: { Authorization: "Bearer token123" },
138
+ * timeout: 60000,
139
+ * });
140
+ * ```
141
+ */
142
+ export declare function processFileWithRegistry(fileInfo: FileInfo, options?: FileProcessingOptions): Promise<{
143
+ processorName: string | null;
144
+ result: FileProcessingResult<ProcessedFileBase> | null;
145
+ }>;
146
+ /**
147
+ * Process multiple files using the ProcessorRegistry.
148
+ * Files are processed sequentially and categorized by outcome.
149
+ *
150
+ * @param files - Array of file information objects
151
+ * @param options - Processing options (max files, auth headers, timeout)
152
+ * @returns Batch result with successful, failed, and skipped files
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const files: FileInfo[] = [
157
+ * { id: "1", name: "image.jpg", mimetype: "image/jpeg", size: 512000 },
158
+ * { id: "2", name: "doc.pdf", mimetype: "application/pdf", size: 1024000 },
159
+ * { id: "3", name: "unknown.xyz", mimetype: "application/octet-stream", size: 100 },
160
+ * ];
161
+ *
162
+ * const result = await processBatchWithRegistry(files, {
163
+ * maxFiles: 50,
164
+ * timeout: 60000,
165
+ * });
166
+ *
167
+ * console.log(`Processed ${result.successful.length} files successfully`);
168
+ * console.log(`Failed: ${result.failed.length}`);
169
+ * console.log(`Skipped: ${result.skipped.length}`);
170
+ *
171
+ * // Access individual results
172
+ * for (const { fileInfo, processorName, result } of result.successful) {
173
+ * console.log(`${fileInfo.name}: ${result.data?.size} bytes`);
174
+ * }
175
+ * ```
176
+ */
177
+ export declare function processBatchWithRegistry(files: FileInfo[], options?: FileProcessingOptions): Promise<BatchFileProcessingResult>;
178
+ /**
179
+ * Get a list of supported file types from the registry.
180
+ * Returns information about each registered processor including
181
+ * supported MIME types, extensions, and priority.
182
+ *
183
+ * @returns Array of processor information objects
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const supportedTypes = getSupportedFileTypes();
188
+ *
189
+ * for (const { name, mimeTypes, extensions, priority } of supportedTypes) {
190
+ * console.log(`${name} (priority: ${priority})`);
191
+ * console.log(` MIME types: ${mimeTypes.join(", ")}`);
192
+ * console.log(` Extensions: ${extensions.join(", ")}`);
193
+ * }
194
+ * ```
195
+ */
196
+ export declare function getSupportedFileTypes(): Array<{
197
+ name: string;
198
+ mimeTypes: string[];
199
+ extensions: string[];
200
+ priority: number;
201
+ }>;
202
+ /**
203
+ * Check if a file type is supported by any registered processor.
204
+ *
205
+ * @param mimetype - MIME type of the file
206
+ * @param filename - Filename (for extension-based detection)
207
+ * @returns true if a processor exists for this file type
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * // Check by MIME type and filename
212
+ * if (isFileTypeSupported("application/pdf", "document.pdf")) {
213
+ * console.log("PDF files are supported");
214
+ * }
215
+ *
216
+ * // Useful for validation before upload
217
+ * function validateFile(file: File): boolean {
218
+ * return isFileTypeSupported(file.type, file.name);
219
+ * }
220
+ * ```
221
+ */
222
+ export declare function isFileTypeSupported(mimetype: string, filename: string): boolean;
223
+ /**
224
+ * Get the processor that would handle a specific file.
225
+ * Returns the full processor match including confidence score.
226
+ *
227
+ * @param mimetype - MIME type of the file
228
+ * @param filename - Filename (for extension-based detection)
229
+ * @returns Processor match or null if no processor found
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const match = getProcessorForFile("image/jpeg", "photo.jpg");
234
+ *
235
+ * if (match) {
236
+ * console.log(`Would use ${match.name} processor`);
237
+ * console.log(`Priority: ${match.priority}`);
238
+ * console.log(`Confidence: ${match.confidence}%`);
239
+ * } else {
240
+ * console.log("No processor available for this file type");
241
+ * }
242
+ * ```
243
+ */
244
+ export declare function getProcessorForFile(mimetype: string, filename: string): ProcessorMatch | null;
@@ -0,0 +1,273 @@
1
+ /**
2
+ * File Processor Integration
3
+ *
4
+ * Provides integration between the ProcessorRegistry and message building.
5
+ * This module allows for automatic file type detection and processing
6
+ * using the registered file processors.
7
+ *
8
+ * @module processors/integration/FileProcessorIntegration
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import {
13
+ * processFileWithRegistry,
14
+ * processBatchWithRegistry,
15
+ * getSupportedFileTypes,
16
+ * isFileTypeSupported,
17
+ * getProcessorForFile,
18
+ * } from "./integration/index.js";
19
+ *
20
+ * // Process a single file
21
+ * const { processorName, result } = await processFileWithRegistry(fileInfo);
22
+ * if (result?.success) {
23
+ * console.log(`Processed with ${processorName}:`, result.data);
24
+ * }
25
+ *
26
+ * // Process multiple files
27
+ * const batchResult = await processBatchWithRegistry(files, { maxFiles: 50 });
28
+ * console.log(`Successful: ${batchResult.successful.length}`);
29
+ * console.log(`Failed: ${batchResult.failed.length}`);
30
+ * console.log(`Skipped: ${batchResult.skipped.length}`);
31
+ *
32
+ * // Check if a file type is supported
33
+ * if (isFileTypeSupported("application/pdf", "document.pdf")) {
34
+ * console.log("PDF files are supported");
35
+ * }
36
+ * ```
37
+ */
38
+ import { withTimeout } from "../../utils/errorHandling.js";
39
+ import { getProcessorRegistry } from "../registry/index.js";
40
+ // =============================================================================
41
+ // SINGLE FILE PROCESSING
42
+ // =============================================================================
43
+ /**
44
+ * Process a single file using the ProcessorRegistry.
45
+ * Automatically detects the appropriate processor based on MIME type and filename.
46
+ *
47
+ * @param fileInfo - File information including content/URL
48
+ * @param options - Processing options (preferred processor, auth headers, timeout)
49
+ * @returns Object containing processor name (null if none found) and processing result
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Basic usage - auto-detect processor
54
+ * const { processorName, result } = await processFileWithRegistry({
55
+ * id: "file-123",
56
+ * name: "document.pdf",
57
+ * mimetype: "application/pdf",
58
+ * size: 1024000,
59
+ * url: "https://example.com/document.pdf",
60
+ * });
61
+ *
62
+ * if (result?.success) {
63
+ * console.log(`Processed by ${processorName}:`, result.data);
64
+ * }
65
+ *
66
+ * // Use a specific processor
67
+ * const { result } = await processFileWithRegistry(fileInfo, {
68
+ * preferredProcessor: "pdf",
69
+ * });
70
+ *
71
+ * // With authentication and timeout
72
+ * const { result } = await processFileWithRegistry(fileInfo, {
73
+ * authHeaders: { Authorization: "Bearer token123" },
74
+ * timeout: 60000,
75
+ * });
76
+ * ```
77
+ */
78
+ export async function processFileWithRegistry(fileInfo, options) {
79
+ const registry = getProcessorRegistry();
80
+ const timeout = options?.timeout ?? 30000;
81
+ // Use preferred processor if specified
82
+ if (options?.preferredProcessor) {
83
+ const processor = registry.getProcessor(options.preferredProcessor);
84
+ if (processor) {
85
+ const result = await withTimeout(processor.processor.processFile(fileInfo, options), timeout, new Error(`File processing timed out after ${timeout}ms`));
86
+ return { processorName: options.preferredProcessor, result };
87
+ }
88
+ }
89
+ // Auto-detect processor based on MIME type and filename
90
+ const match = registry.findProcessor(fileInfo.mimetype, fileInfo.name);
91
+ if (!match) {
92
+ return { processorName: null, result: null };
93
+ }
94
+ const processor = match.processor;
95
+ const result = await withTimeout(processor.processFile(fileInfo, options), timeout, new Error(`File processing timed out after ${timeout}ms`));
96
+ return { processorName: match.name, result };
97
+ }
98
+ // =============================================================================
99
+ // BATCH FILE PROCESSING
100
+ // =============================================================================
101
+ /**
102
+ * Process multiple files using the ProcessorRegistry.
103
+ * Files are processed sequentially and categorized by outcome.
104
+ *
105
+ * @param files - Array of file information objects
106
+ * @param options - Processing options (max files, auth headers, timeout)
107
+ * @returns Batch result with successful, failed, and skipped files
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const files: FileInfo[] = [
112
+ * { id: "1", name: "image.jpg", mimetype: "image/jpeg", size: 512000 },
113
+ * { id: "2", name: "doc.pdf", mimetype: "application/pdf", size: 1024000 },
114
+ * { id: "3", name: "unknown.xyz", mimetype: "application/octet-stream", size: 100 },
115
+ * ];
116
+ *
117
+ * const result = await processBatchWithRegistry(files, {
118
+ * maxFiles: 50,
119
+ * timeout: 60000,
120
+ * });
121
+ *
122
+ * console.log(`Processed ${result.successful.length} files successfully`);
123
+ * console.log(`Failed: ${result.failed.length}`);
124
+ * console.log(`Skipped: ${result.skipped.length}`);
125
+ *
126
+ * // Access individual results
127
+ * for (const { fileInfo, processorName, result } of result.successful) {
128
+ * console.log(`${fileInfo.name}: ${result.data?.size} bytes`);
129
+ * }
130
+ * ```
131
+ */
132
+ export async function processBatchWithRegistry(files, options) {
133
+ const result = {
134
+ successful: [],
135
+ failed: [],
136
+ skipped: [],
137
+ };
138
+ const maxFiles = options?.maxFiles ?? 100;
139
+ const filesToProcess = files.slice(0, maxFiles);
140
+ // Process files sequentially
141
+ for (const fileInfo of filesToProcess) {
142
+ try {
143
+ const { processorName, result: processResult } = await processFileWithRegistry(fileInfo, options);
144
+ if (!processorName || !processResult) {
145
+ // No processor found for this file type
146
+ if (!options?.allowFallback) {
147
+ result.skipped.push({
148
+ fileInfo,
149
+ reason: `No processor found for MIME type: ${fileInfo.mimetype}`,
150
+ });
151
+ }
152
+ else {
153
+ // allowFallback is true but no fallback processor implemented yet
154
+ result.skipped.push({
155
+ fileInfo,
156
+ reason: `No processor found for MIME type: ${fileInfo.mimetype} (fallback not yet implemented)`,
157
+ });
158
+ }
159
+ continue;
160
+ }
161
+ if (processResult.success) {
162
+ result.successful.push({
163
+ fileInfo,
164
+ processorName,
165
+ result: processResult,
166
+ });
167
+ }
168
+ else {
169
+ result.failed.push({
170
+ fileInfo,
171
+ error: processResult.error?.message || "Unknown error",
172
+ });
173
+ }
174
+ }
175
+ catch (error) {
176
+ result.failed.push({
177
+ fileInfo,
178
+ error: error instanceof Error ? error.message : String(error),
179
+ });
180
+ }
181
+ }
182
+ // Track skipped files that exceeded the limit
183
+ if (files.length > maxFiles) {
184
+ for (let i = maxFiles; i < files.length; i++) {
185
+ result.skipped.push({
186
+ fileInfo: files[i],
187
+ reason: `Exceeded maximum file limit (${maxFiles})`,
188
+ });
189
+ }
190
+ }
191
+ return result;
192
+ }
193
+ // =============================================================================
194
+ // PROCESSOR DISCOVERY
195
+ // =============================================================================
196
+ /**
197
+ * Get a list of supported file types from the registry.
198
+ * Returns information about each registered processor including
199
+ * supported MIME types, extensions, and priority.
200
+ *
201
+ * @returns Array of processor information objects
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const supportedTypes = getSupportedFileTypes();
206
+ *
207
+ * for (const { name, mimeTypes, extensions, priority } of supportedTypes) {
208
+ * console.log(`${name} (priority: ${priority})`);
209
+ * console.log(` MIME types: ${mimeTypes.join(", ")}`);
210
+ * console.log(` Extensions: ${extensions.join(", ")}`);
211
+ * }
212
+ * ```
213
+ */
214
+ export function getSupportedFileTypes() {
215
+ const registry = getProcessorRegistry();
216
+ const processors = registry.listProcessors();
217
+ return processors.map((p) => ({
218
+ name: p.name,
219
+ mimeTypes: p.processor.getConfig().supportedMimeTypes || [],
220
+ extensions: p.processor.getConfig().supportedExtensions || [],
221
+ priority: p.priority,
222
+ }));
223
+ }
224
+ /**
225
+ * Check if a file type is supported by any registered processor.
226
+ *
227
+ * @param mimetype - MIME type of the file
228
+ * @param filename - Filename (for extension-based detection)
229
+ * @returns true if a processor exists for this file type
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * // Check by MIME type and filename
234
+ * if (isFileTypeSupported("application/pdf", "document.pdf")) {
235
+ * console.log("PDF files are supported");
236
+ * }
237
+ *
238
+ * // Useful for validation before upload
239
+ * function validateFile(file: File): boolean {
240
+ * return isFileTypeSupported(file.type, file.name);
241
+ * }
242
+ * ```
243
+ */
244
+ export function isFileTypeSupported(mimetype, filename) {
245
+ const registry = getProcessorRegistry();
246
+ return registry.findProcessor(mimetype, filename) !== null;
247
+ }
248
+ /**
249
+ * Get the processor that would handle a specific file.
250
+ * Returns the full processor match including confidence score.
251
+ *
252
+ * @param mimetype - MIME type of the file
253
+ * @param filename - Filename (for extension-based detection)
254
+ * @returns Processor match or null if no processor found
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * const match = getProcessorForFile("image/jpeg", "photo.jpg");
259
+ *
260
+ * if (match) {
261
+ * console.log(`Would use ${match.name} processor`);
262
+ * console.log(`Priority: ${match.priority}`);
263
+ * console.log(`Confidence: ${match.confidence}%`);
264
+ * } else {
265
+ * console.log("No processor available for this file type");
266
+ * }
267
+ * ```
268
+ */
269
+ export function getProcessorForFile(mimetype, filename) {
270
+ const registry = getProcessorRegistry();
271
+ return registry.findProcessor(mimetype, filename);
272
+ }
273
+ //# sourceMappingURL=FileProcessorIntegration.js.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * File Processor Integration Module
3
+ *
4
+ * Provides integration between the ProcessorRegistry and message building.
5
+ * Exports utilities for processing files through registered processors
6
+ * with automatic type detection and batch processing support.
7
+ *
8
+ * @module processors/integration
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import {
13
+ * // Single file processing
14
+ * processFileWithRegistry,
15
+ *
16
+ * // Batch processing
17
+ * processBatchWithRegistry,
18
+ *
19
+ * // Discovery utilities
20
+ * getSupportedFileTypes,
21
+ * isFileTypeSupported,
22
+ * getProcessorForFile,
23
+ *
24
+ * // Types
25
+ * type FileProcessingOptions,
26
+ * type BatchFileProcessingResult,
27
+ * } from "./integration/index.js";
28
+ *
29
+ * // Process a single file with auto-detection
30
+ * const { processorName, result } = await processFileWithRegistry(fileInfo);
31
+ *
32
+ * // Process multiple files
33
+ * const batchResult = await processBatchWithRegistry(files, { maxFiles: 50 });
34
+ *
35
+ * // Check supported types
36
+ * const supported = getSupportedFileTypes();
37
+ * const isSupported = isFileTypeSupported("application/pdf", "doc.pdf");
38
+ * const match = getProcessorForFile("image/jpeg", "photo.jpg");
39
+ * ```
40
+ */
41
+ export { getProcessorForFile, getSupportedFileTypes, isFileTypeSupported, processBatchWithRegistry, processFileWithRegistry, } from "./FileProcessorIntegration.js";
42
+ export type { BatchFileProcessingResult, FileProcessingOptions, } from "./FileProcessorIntegration.js";