@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.
- package/CHANGELOG.md +27 -0
- package/README.md +106 -37
- package/dist/agent/directTools.d.ts +11 -11
- package/dist/cli/commands/config.d.ts +6 -6
- package/dist/cli/commands/rag.d.ts +19 -0
- package/dist/cli/commands/rag.js +756 -0
- package/dist/cli/factories/commandFactory.js +146 -83
- package/dist/cli/parser.js +4 -1
- package/dist/core/baseProvider.d.ts +43 -30
- package/dist/core/baseProvider.js +98 -138
- package/dist/core/conversationMemoryFactory.d.ts +2 -2
- package/dist/core/conversationMemoryFactory.js +2 -2
- package/dist/core/conversationMemoryInitializer.d.ts +1 -2
- package/dist/core/conversationMemoryInitializer.js +2 -2
- package/dist/core/infrastructure/baseError.d.ts +21 -0
- package/dist/core/infrastructure/baseError.js +22 -0
- package/dist/core/infrastructure/baseFactory.d.ts +21 -0
- package/dist/core/infrastructure/baseFactory.js +54 -0
- package/dist/core/infrastructure/baseRegistry.d.ts +21 -0
- package/dist/core/infrastructure/baseRegistry.js +49 -0
- package/dist/core/infrastructure/index.d.ts +5 -0
- package/dist/core/infrastructure/index.js +5 -0
- package/dist/core/infrastructure/retry.d.ts +7 -0
- package/dist/core/infrastructure/retry.js +20 -0
- package/dist/core/infrastructure/typedEventEmitter.d.ts +8 -0
- package/dist/core/infrastructure/typedEventEmitter.js +23 -0
- package/dist/core/redisConversationMemoryManager.d.ts +1 -6
- package/dist/core/redisConversationMemoryManager.js +7 -19
- package/dist/factories/providerFactory.d.ts +5 -3
- package/dist/factories/providerFactory.js +31 -24
- package/dist/image-gen/ImageGenService.d.ts +143 -0
- package/dist/image-gen/ImageGenService.js +345 -0
- package/dist/image-gen/imageGenTools.d.ts +126 -0
- package/dist/image-gen/imageGenTools.js +304 -0
- package/dist/image-gen/index.d.ts +46 -0
- package/dist/image-gen/index.js +48 -0
- package/dist/image-gen/types.d.ts +237 -0
- package/dist/image-gen/types.js +24 -0
- package/dist/index.d.ts +46 -12
- package/dist/index.js +88 -36
- package/dist/lib/agent/directTools.d.ts +8 -8
- package/dist/lib/core/baseProvider.d.ts +43 -30
- package/dist/lib/core/baseProvider.js +98 -138
- package/dist/lib/core/conversationMemoryFactory.d.ts +2 -2
- package/dist/lib/core/conversationMemoryFactory.js +2 -2
- package/dist/lib/core/conversationMemoryInitializer.d.ts +1 -2
- package/dist/lib/core/conversationMemoryInitializer.js +2 -2
- package/dist/lib/core/infrastructure/baseError.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseError.js +23 -0
- package/dist/lib/core/infrastructure/baseFactory.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseFactory.js +55 -0
- package/dist/lib/core/infrastructure/baseRegistry.d.ts +21 -0
- package/dist/lib/core/infrastructure/baseRegistry.js +50 -0
- package/dist/lib/core/infrastructure/index.d.ts +5 -0
- package/dist/lib/core/infrastructure/index.js +6 -0
- package/dist/lib/core/infrastructure/retry.d.ts +7 -0
- package/dist/lib/core/infrastructure/retry.js +21 -0
- package/dist/lib/core/infrastructure/typedEventEmitter.d.ts +8 -0
- package/dist/lib/core/infrastructure/typedEventEmitter.js +24 -0
- package/dist/lib/core/redisConversationMemoryManager.d.ts +1 -6
- package/dist/lib/core/redisConversationMemoryManager.js +7 -19
- package/dist/lib/factories/providerFactory.d.ts +5 -3
- package/dist/lib/factories/providerFactory.js +31 -24
- package/dist/lib/image-gen/ImageGenService.d.ts +143 -0
- package/dist/lib/image-gen/ImageGenService.js +346 -0
- package/dist/lib/image-gen/imageGenTools.d.ts +126 -0
- package/dist/lib/image-gen/imageGenTools.js +305 -0
- package/dist/lib/image-gen/index.d.ts +46 -0
- package/dist/lib/image-gen/index.js +49 -0
- package/dist/lib/image-gen/types.d.ts +237 -0
- package/dist/lib/image-gen/types.js +25 -0
- package/dist/lib/index.d.ts +46 -12
- package/dist/lib/index.js +88 -36
- package/dist/lib/mcp/index.d.ts +6 -5
- package/dist/lib/mcp/index.js +7 -5
- package/dist/lib/neurolink.d.ts +11 -13
- package/dist/lib/neurolink.js +95 -29
- package/dist/lib/processors/base/BaseFileProcessor.d.ts +273 -0
- package/dist/lib/processors/base/BaseFileProcessor.js +614 -0
- package/dist/lib/processors/base/index.d.ts +14 -0
- package/dist/lib/processors/base/index.js +20 -0
- package/dist/lib/processors/base/types.d.ts +593 -0
- package/dist/lib/processors/base/types.js +77 -0
- package/dist/lib/processors/cli/fileProcessorCli.d.ts +163 -0
- package/dist/lib/processors/cli/fileProcessorCli.js +389 -0
- package/dist/lib/processors/cli/index.d.ts +37 -0
- package/dist/lib/processors/cli/index.js +50 -0
- package/dist/lib/processors/code/ConfigProcessor.d.ts +171 -0
- package/dist/lib/processors/code/ConfigProcessor.js +401 -0
- package/dist/lib/processors/code/SourceCodeProcessor.d.ts +174 -0
- package/dist/lib/processors/code/SourceCodeProcessor.js +305 -0
- package/dist/lib/processors/code/index.d.ts +44 -0
- package/dist/lib/processors/code/index.js +61 -0
- package/dist/lib/processors/config/fileTypes.d.ts +283 -0
- package/dist/lib/processors/config/fileTypes.js +521 -0
- package/dist/lib/processors/config/index.d.ts +32 -0
- package/dist/lib/processors/config/index.js +93 -0
- package/dist/lib/processors/config/languageMap.d.ts +66 -0
- package/dist/lib/processors/config/languageMap.js +411 -0
- package/dist/lib/processors/config/mimeTypes.d.ts +376 -0
- package/dist/lib/processors/config/mimeTypes.js +339 -0
- package/dist/lib/processors/config/sizeLimits.d.ts +194 -0
- package/dist/lib/processors/config/sizeLimits.js +247 -0
- package/dist/lib/processors/data/JsonProcessor.d.ts +122 -0
- package/dist/lib/processors/data/JsonProcessor.js +204 -0
- package/dist/lib/processors/data/XmlProcessor.d.ts +160 -0
- package/dist/lib/processors/data/XmlProcessor.js +284 -0
- package/dist/lib/processors/data/YamlProcessor.d.ts +163 -0
- package/dist/lib/processors/data/YamlProcessor.js +295 -0
- package/dist/lib/processors/data/index.d.ts +49 -0
- package/dist/lib/processors/data/index.js +77 -0
- package/dist/lib/processors/document/ExcelProcessor.d.ts +238 -0
- package/dist/lib/processors/document/ExcelProcessor.js +520 -0
- package/dist/lib/processors/document/OpenDocumentProcessor.d.ts +69 -0
- package/dist/lib/processors/document/OpenDocumentProcessor.js +211 -0
- package/dist/lib/processors/document/RtfProcessor.d.ts +152 -0
- package/dist/lib/processors/document/RtfProcessor.js +362 -0
- package/dist/lib/processors/document/WordProcessor.d.ts +168 -0
- package/dist/lib/processors/document/WordProcessor.js +354 -0
- package/dist/lib/processors/document/index.d.ts +54 -0
- package/dist/lib/processors/document/index.js +91 -0
- package/dist/lib/processors/errors/FileErrorCode.d.ts +98 -0
- package/dist/lib/processors/errors/FileErrorCode.js +256 -0
- package/dist/lib/processors/errors/errorHelpers.d.ts +151 -0
- package/dist/lib/processors/errors/errorHelpers.js +379 -0
- package/dist/lib/processors/errors/errorSerializer.d.ts +139 -0
- package/dist/lib/processors/errors/errorSerializer.js +508 -0
- package/dist/lib/processors/errors/index.d.ts +46 -0
- package/dist/lib/processors/errors/index.js +50 -0
- package/dist/lib/processors/index.d.ts +76 -0
- package/dist/lib/processors/index.js +113 -0
- package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +244 -0
- package/dist/lib/processors/integration/FileProcessorIntegration.js +273 -0
- package/dist/lib/processors/integration/index.d.ts +42 -0
- package/dist/lib/processors/integration/index.js +45 -0
- package/dist/lib/processors/markup/HtmlProcessor.d.ts +169 -0
- package/dist/lib/processors/markup/HtmlProcessor.js +250 -0
- package/dist/lib/processors/markup/MarkdownProcessor.d.ts +165 -0
- package/dist/lib/processors/markup/MarkdownProcessor.js +245 -0
- package/dist/lib/processors/markup/SvgProcessor.d.ts +156 -0
- package/dist/lib/processors/markup/SvgProcessor.js +241 -0
- package/dist/lib/processors/markup/TextProcessor.d.ts +135 -0
- package/dist/lib/processors/markup/TextProcessor.js +189 -0
- package/dist/lib/processors/markup/index.d.ts +66 -0
- package/dist/lib/processors/markup/index.js +103 -0
- package/dist/lib/processors/registry/ProcessorRegistry.d.ts +334 -0
- package/dist/lib/processors/registry/ProcessorRegistry.js +609 -0
- package/dist/lib/processors/registry/index.d.ts +12 -0
- package/dist/lib/processors/registry/index.js +17 -0
- package/dist/lib/processors/registry/types.d.ts +53 -0
- package/dist/lib/processors/registry/types.js +11 -0
- package/dist/lib/providers/amazonBedrock.d.ts +15 -2
- package/dist/lib/providers/amazonBedrock.js +65 -8
- package/dist/lib/providers/anthropic.d.ts +3 -3
- package/dist/lib/providers/anthropic.js +10 -7
- package/dist/lib/providers/googleAiStudio.d.ts +5 -5
- package/dist/lib/providers/googleAiStudio.js +10 -7
- package/dist/lib/providers/googleVertex.d.ts +16 -4
- package/dist/lib/providers/googleVertex.js +72 -16
- package/dist/lib/providers/litellm.d.ts +3 -3
- package/dist/lib/providers/litellm.js +10 -10
- package/dist/lib/providers/mistral.d.ts +3 -3
- package/dist/lib/providers/mistral.js +7 -6
- package/dist/lib/providers/ollama.d.ts +3 -4
- package/dist/lib/providers/ollama.js +7 -8
- package/dist/lib/providers/openAI.d.ts +14 -2
- package/dist/lib/providers/openAI.js +60 -6
- package/dist/lib/providers/openRouter.d.ts +2 -2
- package/dist/lib/providers/openRouter.js +10 -6
- package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/lib/rag/ChunkerFactory.d.ts +91 -0
- package/dist/lib/rag/ChunkerFactory.js +321 -0
- package/dist/lib/rag/ChunkerRegistry.d.ts +91 -0
- package/dist/lib/rag/ChunkerRegistry.js +422 -0
- package/dist/lib/rag/chunkers/BaseChunker.d.ts +53 -0
- package/dist/lib/rag/chunkers/BaseChunker.js +144 -0
- package/dist/lib/rag/chunkers/CharacterChunker.d.ts +18 -0
- package/dist/lib/rag/chunkers/CharacterChunker.js +29 -0
- package/dist/lib/rag/chunkers/HTMLChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/HTMLChunker.js +39 -0
- package/dist/lib/rag/chunkers/JSONChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/JSONChunker.js +69 -0
- package/dist/lib/rag/chunkers/LaTeXChunker.d.ts +15 -0
- package/dist/lib/rag/chunkers/LaTeXChunker.js +64 -0
- package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +15 -0
- package/dist/lib/rag/chunkers/MarkdownChunker.js +103 -0
- package/dist/lib/rag/chunkers/RecursiveChunker.d.ts +27 -0
- package/dist/lib/rag/chunkers/RecursiveChunker.js +140 -0
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.js +139 -0
- package/dist/lib/rag/chunkers/SentenceChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/SentenceChunker.js +67 -0
- package/dist/lib/rag/chunkers/TokenChunker.d.ts +19 -0
- package/dist/lib/rag/chunkers/TokenChunker.js +62 -0
- package/dist/lib/rag/chunkers/index.d.ts +15 -0
- package/dist/lib/rag/chunkers/index.js +16 -0
- package/dist/lib/rag/chunking/characterChunker.d.ts +16 -0
- package/dist/lib/rag/chunking/characterChunker.js +143 -0
- package/dist/lib/rag/chunking/chunkerRegistry.d.ts +67 -0
- package/dist/lib/rag/chunking/chunkerRegistry.js +195 -0
- package/dist/lib/rag/chunking/htmlChunker.d.ts +34 -0
- package/dist/lib/rag/chunking/htmlChunker.js +248 -0
- package/dist/lib/rag/chunking/index.d.ts +15 -0
- package/dist/lib/rag/chunking/index.js +18 -0
- package/dist/lib/rag/chunking/jsonChunker.d.ts +20 -0
- package/dist/lib/rag/chunking/jsonChunker.js +282 -0
- package/dist/lib/rag/chunking/latexChunker.d.ts +26 -0
- package/dist/lib/rag/chunking/latexChunker.js +252 -0
- package/dist/lib/rag/chunking/markdownChunker.d.ts +19 -0
- package/dist/lib/rag/chunking/markdownChunker.js +202 -0
- package/dist/lib/rag/chunking/recursiveChunker.d.ts +19 -0
- package/dist/lib/rag/chunking/recursiveChunker.js +149 -0
- package/dist/lib/rag/chunking/semanticChunker.d.ts +41 -0
- package/dist/lib/rag/chunking/semanticChunker.js +307 -0
- package/dist/lib/rag/chunking/sentenceChunker.d.ts +25 -0
- package/dist/lib/rag/chunking/sentenceChunker.js +231 -0
- package/dist/lib/rag/chunking/tokenChunker.d.ts +36 -0
- package/dist/lib/rag/chunking/tokenChunker.js +184 -0
- package/dist/lib/rag/document/MDocument.d.ts +198 -0
- package/dist/lib/rag/document/MDocument.js +393 -0
- package/dist/lib/rag/document/index.d.ts +5 -0
- package/dist/lib/rag/document/index.js +6 -0
- package/dist/lib/rag/document/loaders.d.ts +201 -0
- package/dist/lib/rag/document/loaders.js +501 -0
- package/dist/lib/rag/errors/RAGError.d.ts +244 -0
- package/dist/lib/rag/errors/RAGError.js +275 -0
- package/dist/lib/rag/errors/index.d.ts +6 -0
- package/dist/lib/rag/errors/index.js +7 -0
- package/dist/lib/rag/graphRag/graphRAG.d.ts +115 -0
- package/dist/lib/rag/graphRag/graphRAG.js +385 -0
- package/dist/lib/rag/graphRag/index.d.ts +4 -0
- package/dist/lib/rag/graphRag/index.js +5 -0
- package/dist/lib/rag/index.d.ts +103 -0
- package/dist/lib/rag/index.js +142 -0
- package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
- package/dist/lib/rag/metadata/MetadataExtractorFactory.js +419 -0
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.js +363 -0
- package/dist/lib/rag/metadata/index.d.ts +6 -0
- package/dist/lib/rag/metadata/index.js +10 -0
- package/dist/lib/rag/metadata/metadataExtractor.d.ts +69 -0
- package/dist/lib/rag/metadata/metadataExtractor.js +278 -0
- package/dist/lib/rag/pipeline/RAGPipeline.d.ts +235 -0
- package/dist/lib/rag/pipeline/RAGPipeline.js +402 -0
- package/dist/lib/rag/pipeline/contextAssembly.d.ts +126 -0
- package/dist/lib/rag/pipeline/contextAssembly.js +338 -0
- package/dist/lib/rag/pipeline/index.d.ts +5 -0
- package/dist/lib/rag/pipeline/index.js +6 -0
- package/dist/lib/rag/ragIntegration.d.ts +38 -0
- package/dist/lib/rag/ragIntegration.js +212 -0
- package/dist/lib/rag/reranker/RerankerFactory.d.ts +184 -0
- package/dist/lib/rag/reranker/RerankerFactory.js +431 -0
- package/dist/lib/rag/reranker/RerankerRegistry.d.ts +119 -0
- package/dist/lib/rag/reranker/RerankerRegistry.js +403 -0
- package/dist/lib/rag/reranker/index.d.ts +6 -0
- package/dist/lib/rag/reranker/index.js +10 -0
- package/dist/lib/rag/reranker/reranker.d.ts +71 -0
- package/dist/lib/rag/reranker/reranker.js +278 -0
- package/dist/lib/rag/resilience/CircuitBreaker.d.ts +215 -0
- package/dist/lib/rag/resilience/CircuitBreaker.js +432 -0
- package/dist/lib/rag/resilience/RetryHandler.d.ts +115 -0
- package/dist/lib/rag/resilience/RetryHandler.js +301 -0
- package/dist/lib/rag/resilience/index.d.ts +7 -0
- package/dist/lib/rag/resilience/index.js +8 -0
- package/dist/lib/rag/retrieval/hybridSearch.d.ts +94 -0
- package/dist/lib/rag/retrieval/hybridSearch.js +314 -0
- package/dist/lib/rag/retrieval/index.d.ts +5 -0
- package/dist/lib/rag/retrieval/index.js +6 -0
- package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +93 -0
- package/dist/lib/rag/retrieval/vectorQueryTool.js +290 -0
- package/dist/lib/rag/types.d.ts +768 -0
- package/dist/lib/rag/types.js +9 -0
- package/dist/lib/server/index.d.ts +15 -11
- package/dist/lib/server/index.js +55 -51
- package/dist/lib/server/utils/validation.d.ts +2 -2
- package/dist/lib/types/common.d.ts +0 -1
- package/dist/lib/types/fileTypes.d.ts +1 -1
- package/dist/lib/types/generateTypes.d.ts +42 -8
- package/dist/lib/types/generateTypes.js +1 -1
- package/dist/lib/types/index.d.ts +25 -24
- package/dist/lib/types/index.js +21 -20
- package/dist/lib/types/modelTypes.d.ts +16 -16
- package/dist/lib/types/pptTypes.d.ts +14 -2
- package/dist/lib/types/pptTypes.js +16 -0
- package/dist/lib/types/streamTypes.d.ts +28 -8
- package/dist/lib/types/streamTypes.js +1 -1
- package/dist/lib/utils/async/delay.d.ts +40 -0
- package/dist/lib/utils/async/delay.js +43 -0
- package/dist/lib/utils/async/index.d.ts +23 -0
- package/dist/lib/utils/async/index.js +24 -0
- package/dist/lib/utils/async/retry.d.ts +141 -0
- package/dist/lib/utils/async/retry.js +172 -0
- package/dist/lib/utils/async/withTimeout.d.ts +73 -0
- package/dist/lib/utils/async/withTimeout.js +97 -0
- package/dist/lib/utils/fileDetector.d.ts +7 -1
- package/dist/lib/utils/fileDetector.js +91 -18
- package/dist/lib/utils/json/extract.d.ts +103 -0
- package/dist/lib/utils/json/extract.js +249 -0
- package/dist/lib/utils/json/index.d.ts +36 -0
- package/dist/lib/utils/json/index.js +37 -0
- package/dist/lib/utils/json/safeParse.d.ts +137 -0
- package/dist/lib/utils/json/safeParse.js +191 -0
- package/dist/lib/utils/messageBuilder.d.ts +2 -2
- package/dist/lib/utils/messageBuilder.js +15 -7
- package/dist/lib/utils/modelRouter.d.ts +4 -4
- package/dist/lib/utils/modelRouter.js +4 -4
- package/dist/lib/utils/sanitizers/filename.d.ts +137 -0
- package/dist/lib/utils/sanitizers/filename.js +366 -0
- package/dist/lib/utils/sanitizers/html.d.ts +170 -0
- package/dist/lib/utils/sanitizers/html.js +326 -0
- package/dist/lib/utils/sanitizers/index.d.ts +26 -0
- package/dist/lib/utils/sanitizers/index.js +30 -0
- package/dist/lib/utils/sanitizers/svg.d.ts +81 -0
- package/dist/lib/utils/sanitizers/svg.js +483 -0
- package/dist/mcp/index.d.ts +6 -5
- package/dist/mcp/index.js +7 -5
- package/dist/neurolink.d.ts +11 -13
- package/dist/neurolink.js +95 -29
- package/dist/processors/base/BaseFileProcessor.d.ts +273 -0
- package/dist/processors/base/BaseFileProcessor.js +613 -0
- package/dist/processors/base/index.d.ts +14 -0
- package/dist/processors/base/index.js +19 -0
- package/dist/processors/base/types.d.ts +593 -0
- package/dist/processors/base/types.js +76 -0
- package/dist/processors/cli/fileProcessorCli.d.ts +163 -0
- package/dist/processors/cli/fileProcessorCli.js +388 -0
- package/dist/processors/cli/index.d.ts +37 -0
- package/dist/processors/cli/index.js +49 -0
- package/dist/processors/code/ConfigProcessor.d.ts +171 -0
- package/dist/processors/code/ConfigProcessor.js +400 -0
- package/dist/processors/code/SourceCodeProcessor.d.ts +174 -0
- package/dist/processors/code/SourceCodeProcessor.js +304 -0
- package/dist/processors/code/index.d.ts +44 -0
- package/dist/processors/code/index.js +60 -0
- package/dist/processors/config/fileTypes.d.ts +283 -0
- package/dist/processors/config/fileTypes.js +520 -0
- package/dist/processors/config/index.d.ts +32 -0
- package/dist/processors/config/index.js +92 -0
- package/dist/processors/config/languageMap.d.ts +66 -0
- package/dist/processors/config/languageMap.js +410 -0
- package/dist/processors/config/mimeTypes.d.ts +376 -0
- package/dist/processors/config/mimeTypes.js +338 -0
- package/dist/processors/config/sizeLimits.d.ts +194 -0
- package/dist/processors/config/sizeLimits.js +246 -0
- package/dist/processors/data/JsonProcessor.d.ts +122 -0
- package/dist/processors/data/JsonProcessor.js +203 -0
- package/dist/processors/data/XmlProcessor.d.ts +160 -0
- package/dist/processors/data/XmlProcessor.js +283 -0
- package/dist/processors/data/YamlProcessor.d.ts +163 -0
- package/dist/processors/data/YamlProcessor.js +294 -0
- package/dist/processors/data/index.d.ts +49 -0
- package/dist/processors/data/index.js +76 -0
- package/dist/processors/document/ExcelProcessor.d.ts +238 -0
- package/dist/processors/document/ExcelProcessor.js +519 -0
- package/dist/processors/document/OpenDocumentProcessor.d.ts +69 -0
- package/dist/processors/document/OpenDocumentProcessor.js +210 -0
- package/dist/processors/document/RtfProcessor.d.ts +152 -0
- package/dist/processors/document/RtfProcessor.js +361 -0
- package/dist/processors/document/WordProcessor.d.ts +168 -0
- package/dist/processors/document/WordProcessor.js +353 -0
- package/dist/processors/document/index.d.ts +54 -0
- package/dist/processors/document/index.js +90 -0
- package/dist/processors/errors/FileErrorCode.d.ts +98 -0
- package/dist/processors/errors/FileErrorCode.js +255 -0
- package/dist/processors/errors/errorHelpers.d.ts +151 -0
- package/dist/processors/errors/errorHelpers.js +378 -0
- package/dist/processors/errors/errorSerializer.d.ts +139 -0
- package/dist/processors/errors/errorSerializer.js +507 -0
- package/dist/processors/errors/index.d.ts +46 -0
- package/dist/processors/errors/index.js +49 -0
- package/dist/processors/index.d.ts +76 -0
- package/dist/processors/index.js +112 -0
- package/dist/processors/integration/FileProcessorIntegration.d.ts +244 -0
- package/dist/processors/integration/FileProcessorIntegration.js +272 -0
- package/dist/processors/integration/index.d.ts +42 -0
- package/dist/processors/integration/index.js +44 -0
- package/dist/processors/markup/HtmlProcessor.d.ts +169 -0
- package/dist/processors/markup/HtmlProcessor.js +249 -0
- package/dist/processors/markup/MarkdownProcessor.d.ts +165 -0
- package/dist/processors/markup/MarkdownProcessor.js +244 -0
- package/dist/processors/markup/SvgProcessor.d.ts +156 -0
- package/dist/processors/markup/SvgProcessor.js +240 -0
- package/dist/processors/markup/TextProcessor.d.ts +135 -0
- package/dist/processors/markup/TextProcessor.js +188 -0
- package/dist/processors/markup/index.d.ts +66 -0
- package/dist/processors/markup/index.js +102 -0
- package/dist/processors/registry/ProcessorRegistry.d.ts +334 -0
- package/dist/processors/registry/ProcessorRegistry.js +608 -0
- package/dist/processors/registry/index.d.ts +12 -0
- package/dist/processors/registry/index.js +16 -0
- package/dist/processors/registry/types.d.ts +53 -0
- package/dist/processors/registry/types.js +10 -0
- package/dist/providers/amazonBedrock.d.ts +15 -2
- package/dist/providers/amazonBedrock.js +65 -8
- package/dist/providers/anthropic.d.ts +3 -3
- package/dist/providers/anthropic.js +10 -7
- package/dist/providers/googleAiStudio.d.ts +5 -5
- package/dist/providers/googleAiStudio.js +10 -7
- package/dist/providers/googleVertex.d.ts +16 -4
- package/dist/providers/googleVertex.js +72 -16
- package/dist/providers/litellm.d.ts +3 -3
- package/dist/providers/litellm.js +10 -10
- package/dist/providers/mistral.d.ts +3 -3
- package/dist/providers/mistral.js +7 -6
- package/dist/providers/ollama.d.ts +3 -4
- package/dist/providers/ollama.js +7 -8
- package/dist/providers/openAI.d.ts +14 -2
- package/dist/providers/openAI.js +60 -6
- package/dist/providers/openRouter.d.ts +2 -2
- package/dist/providers/openRouter.js +10 -6
- package/dist/rag/ChunkerFactory.d.ts +91 -0
- package/dist/rag/ChunkerFactory.js +320 -0
- package/dist/rag/ChunkerRegistry.d.ts +91 -0
- package/dist/rag/ChunkerRegistry.js +421 -0
- package/dist/rag/chunkers/BaseChunker.d.ts +53 -0
- package/dist/rag/chunkers/BaseChunker.js +143 -0
- package/dist/rag/chunkers/CharacterChunker.d.ts +18 -0
- package/dist/rag/chunkers/CharacterChunker.js +28 -0
- package/dist/rag/chunkers/HTMLChunker.d.ts +19 -0
- package/dist/rag/chunkers/HTMLChunker.js +38 -0
- package/dist/rag/chunkers/JSONChunker.d.ts +19 -0
- package/dist/rag/chunkers/JSONChunker.js +68 -0
- package/dist/rag/chunkers/LaTeXChunker.d.ts +15 -0
- package/dist/rag/chunkers/LaTeXChunker.js +63 -0
- package/dist/rag/chunkers/MarkdownChunker.d.ts +15 -0
- package/dist/rag/chunkers/MarkdownChunker.js +102 -0
- package/dist/rag/chunkers/RecursiveChunker.d.ts +27 -0
- package/dist/rag/chunkers/RecursiveChunker.js +139 -0
- package/dist/rag/chunkers/SemanticMarkdownChunker.d.ts +22 -0
- package/dist/rag/chunkers/SemanticMarkdownChunker.js +138 -0
- package/dist/rag/chunkers/SentenceChunker.d.ts +19 -0
- package/dist/rag/chunkers/SentenceChunker.js +66 -0
- package/dist/rag/chunkers/TokenChunker.d.ts +19 -0
- package/dist/rag/chunkers/TokenChunker.js +61 -0
- package/dist/rag/chunkers/index.d.ts +15 -0
- package/dist/rag/chunkers/index.js +15 -0
- package/dist/rag/chunking/characterChunker.d.ts +16 -0
- package/dist/rag/chunking/characterChunker.js +142 -0
- package/dist/rag/chunking/chunkerRegistry.d.ts +67 -0
- package/dist/rag/chunking/chunkerRegistry.js +194 -0
- package/dist/rag/chunking/htmlChunker.d.ts +34 -0
- package/dist/rag/chunking/htmlChunker.js +247 -0
- package/dist/rag/chunking/index.d.ts +15 -0
- package/dist/rag/chunking/index.js +17 -0
- package/dist/rag/chunking/jsonChunker.d.ts +20 -0
- package/dist/rag/chunking/jsonChunker.js +281 -0
- package/dist/rag/chunking/latexChunker.d.ts +26 -0
- package/dist/rag/chunking/latexChunker.js +251 -0
- package/dist/rag/chunking/markdownChunker.d.ts +19 -0
- package/dist/rag/chunking/markdownChunker.js +201 -0
- package/dist/rag/chunking/recursiveChunker.d.ts +19 -0
- package/dist/rag/chunking/recursiveChunker.js +148 -0
- package/dist/rag/chunking/semanticChunker.d.ts +41 -0
- package/dist/rag/chunking/semanticChunker.js +306 -0
- package/dist/rag/chunking/sentenceChunker.d.ts +25 -0
- package/dist/rag/chunking/sentenceChunker.js +230 -0
- package/dist/rag/chunking/tokenChunker.d.ts +36 -0
- package/dist/rag/chunking/tokenChunker.js +183 -0
- package/dist/rag/document/MDocument.d.ts +198 -0
- package/dist/rag/document/MDocument.js +392 -0
- package/dist/rag/document/index.d.ts +5 -0
- package/dist/rag/document/index.js +5 -0
- package/dist/rag/document/loaders.d.ts +201 -0
- package/dist/rag/document/loaders.js +500 -0
- package/dist/rag/errors/RAGError.d.ts +244 -0
- package/dist/rag/errors/RAGError.js +274 -0
- package/dist/rag/errors/index.d.ts +6 -0
- package/dist/rag/errors/index.js +6 -0
- package/dist/rag/graphRag/graphRAG.d.ts +115 -0
- package/dist/rag/graphRag/graphRAG.js +384 -0
- package/dist/rag/graphRag/index.d.ts +4 -0
- package/dist/rag/graphRag/index.js +4 -0
- package/dist/rag/index.d.ts +103 -0
- package/dist/rag/index.js +141 -0
- package/dist/rag/metadata/MetadataExtractorFactory.d.ts +157 -0
- package/dist/rag/metadata/MetadataExtractorFactory.js +418 -0
- package/dist/rag/metadata/MetadataExtractorRegistry.d.ts +99 -0
- package/dist/rag/metadata/MetadataExtractorRegistry.js +362 -0
- package/dist/rag/metadata/index.d.ts +6 -0
- package/dist/rag/metadata/index.js +9 -0
- package/dist/rag/metadata/metadataExtractor.d.ts +69 -0
- package/dist/rag/metadata/metadataExtractor.js +277 -0
- package/dist/rag/pipeline/RAGPipeline.d.ts +235 -0
- package/dist/rag/pipeline/RAGPipeline.js +401 -0
- package/dist/rag/pipeline/contextAssembly.d.ts +126 -0
- package/dist/rag/pipeline/contextAssembly.js +337 -0
- package/dist/rag/pipeline/index.d.ts +5 -0
- package/dist/rag/pipeline/index.js +5 -0
- package/dist/rag/ragIntegration.d.ts +38 -0
- package/dist/rag/ragIntegration.js +211 -0
- package/dist/rag/reranker/RerankerFactory.d.ts +184 -0
- package/dist/rag/reranker/RerankerFactory.js +430 -0
- package/dist/rag/reranker/RerankerRegistry.d.ts +119 -0
- package/dist/rag/reranker/RerankerRegistry.js +402 -0
- package/dist/rag/reranker/index.d.ts +6 -0
- package/dist/rag/reranker/index.js +9 -0
- package/dist/rag/reranker/reranker.d.ts +71 -0
- package/dist/rag/reranker/reranker.js +277 -0
- package/dist/rag/resilience/CircuitBreaker.d.ts +215 -0
- package/dist/rag/resilience/CircuitBreaker.js +431 -0
- package/dist/rag/resilience/RetryHandler.d.ts +115 -0
- package/dist/rag/resilience/RetryHandler.js +300 -0
- package/dist/rag/resilience/index.d.ts +7 -0
- package/dist/rag/resilience/index.js +7 -0
- package/dist/rag/retrieval/hybridSearch.d.ts +94 -0
- package/dist/rag/retrieval/hybridSearch.js +313 -0
- package/dist/rag/retrieval/index.d.ts +5 -0
- package/dist/rag/retrieval/index.js +5 -0
- package/dist/rag/retrieval/vectorQueryTool.d.ts +93 -0
- package/dist/rag/retrieval/vectorQueryTool.js +289 -0
- package/dist/rag/types.d.ts +768 -0
- package/dist/rag/types.js +8 -0
- package/dist/server/index.d.ts +15 -11
- package/dist/server/index.js +55 -51
- package/dist/server/utils/validation.d.ts +8 -8
- package/dist/types/common.d.ts +0 -1
- package/dist/types/fileTypes.d.ts +1 -1
- package/dist/types/generateTypes.d.ts +42 -8
- package/dist/types/generateTypes.js +1 -1
- package/dist/types/index.d.ts +25 -24
- package/dist/types/index.js +21 -20
- package/dist/types/modelTypes.d.ts +10 -10
- package/dist/types/pptTypes.d.ts +14 -2
- package/dist/types/pptTypes.js +16 -0
- package/dist/types/streamTypes.d.ts +28 -8
- package/dist/types/streamTypes.js +1 -1
- package/dist/utils/async/delay.d.ts +40 -0
- package/dist/utils/async/delay.js +42 -0
- package/dist/utils/async/index.d.ts +23 -0
- package/dist/utils/async/index.js +23 -0
- package/dist/utils/async/retry.d.ts +141 -0
- package/dist/utils/async/retry.js +171 -0
- package/dist/utils/async/withTimeout.d.ts +73 -0
- package/dist/utils/async/withTimeout.js +96 -0
- package/dist/utils/fileDetector.d.ts +7 -1
- package/dist/utils/fileDetector.js +91 -18
- package/dist/utils/json/extract.d.ts +103 -0
- package/dist/utils/json/extract.js +248 -0
- package/dist/utils/json/index.d.ts +36 -0
- package/dist/utils/json/index.js +36 -0
- package/dist/utils/json/safeParse.d.ts +137 -0
- package/dist/utils/json/safeParse.js +190 -0
- package/dist/utils/messageBuilder.d.ts +2 -2
- package/dist/utils/messageBuilder.js +15 -7
- package/dist/utils/modelRouter.d.ts +4 -4
- package/dist/utils/modelRouter.js +4 -4
- package/dist/utils/sanitizers/filename.d.ts +137 -0
- package/dist/utils/sanitizers/filename.js +365 -0
- package/dist/utils/sanitizers/html.d.ts +170 -0
- package/dist/utils/sanitizers/html.js +325 -0
- package/dist/utils/sanitizers/index.d.ts +26 -0
- package/dist/utils/sanitizers/index.js +29 -0
- package/dist/utils/sanitizers/svg.d.ts +81 -0
- package/dist/utils/sanitizers/svg.js +482 -0
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { AIProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, AnalyticsData } from "../types/index.js";
|
|
4
|
-
import { AIProviderName } from "../constants/enums.js";
|
|
1
|
+
import type { CoreMessage, LanguageModelV1, Tool } from "ai";
|
|
2
|
+
import type { AIProviderName } from "../constants/enums.js";
|
|
5
3
|
import type { EvaluationData } from "../index.js";
|
|
4
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
5
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
6
|
+
import type { AIProvider, AnalyticsData, EnhancedGenerateResult, TextGenerationOptions, TextGenerationResult } from "../types/index.js";
|
|
6
7
|
import type { MiddlewareFactoryOptions } from "../types/middlewareTypes.js";
|
|
7
8
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
8
|
-
import type {
|
|
9
|
-
import type { NeuroLink } from "../neurolink.js";
|
|
9
|
+
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
10
10
|
import { TelemetryHandler } from "./modules/TelemetryHandler.js";
|
|
11
11
|
/**
|
|
12
12
|
* Abstract base class for all AI providers
|
|
@@ -50,6 +50,14 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
50
50
|
* Prepare generation context including tools and model
|
|
51
51
|
*/
|
|
52
52
|
private prepareGenerationContext;
|
|
53
|
+
/**
|
|
54
|
+
* Get merged tools for streaming: combines base tools (MCP/built-in) with
|
|
55
|
+
* user-provided tools (e.g., RAG tools passed via options.tools).
|
|
56
|
+
*
|
|
57
|
+
* This is the canonical tool-merge pattern for executeStream() implementations.
|
|
58
|
+
* All providers should call this instead of getAllTools() directly.
|
|
59
|
+
*/
|
|
60
|
+
protected getToolsForStream(options: StreamOptions | TextGenerationOptions): Promise<Record<string, Tool>>;
|
|
53
61
|
/**
|
|
54
62
|
* Build messages array for generation - delegated to MessageBuilder
|
|
55
63
|
*/
|
|
@@ -119,6 +127,35 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
119
127
|
* Ensures existing scripts using createAIProvider().generateText() continue to work
|
|
120
128
|
*/
|
|
121
129
|
generateText(options: TextGenerationOptions): Promise<TextGenerationResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Generate embeddings for text
|
|
132
|
+
*
|
|
133
|
+
* This is a default implementation that throws an error.
|
|
134
|
+
* Providers that support embeddings (OpenAI, Google Vertex, Amazon Bedrock)
|
|
135
|
+
* should override this method with their specific implementation.
|
|
136
|
+
*
|
|
137
|
+
* @param text - The text to embed
|
|
138
|
+
* @param _modelName - Optional embedding model name (provider-specific)
|
|
139
|
+
* @returns Promise resolving to the embedding vector (array of numbers)
|
|
140
|
+
* @throws Error if the provider does not support embeddings
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const provider = await ProviderFactory.createProvider('openai', 'text-embedding-3-small');
|
|
145
|
+
* const embedding = await provider.embed('Hello world');
|
|
146
|
+
* console.log(embedding); // [0.123, -0.456, ...]
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
embed(text: string, _modelName?: string): Promise<number[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Get the default embedding model for this provider
|
|
152
|
+
*
|
|
153
|
+
* Override in subclasses to provide provider-specific defaults.
|
|
154
|
+
* Returns undefined for providers that don't support embeddings.
|
|
155
|
+
*
|
|
156
|
+
* @returns The default embedding model name, or undefined if not supported
|
|
157
|
+
*/
|
|
158
|
+
protected getDefaultEmbeddingModel(): string | undefined;
|
|
122
159
|
/**
|
|
123
160
|
* Provider-specific streaming implementation (only used when tools are disabled)
|
|
124
161
|
*/
|
|
@@ -256,30 +293,6 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
256
293
|
* ```
|
|
257
294
|
*/
|
|
258
295
|
private handleVideoGeneration;
|
|
259
|
-
/**
|
|
260
|
-
* Handle PPT generation mode
|
|
261
|
-
*
|
|
262
|
-
* Generates a complete PowerPoint presentation using AI content planning
|
|
263
|
-
* and slide generation. This method orchestrates:
|
|
264
|
-
* 1. Input validation
|
|
265
|
-
* 2. Content planning via AI
|
|
266
|
-
* 3. Individual slide generation (with optional images)
|
|
267
|
-
* 4. PPTX assembly and file output
|
|
268
|
-
*
|
|
269
|
-
* @param options - Text generation options with PPT config
|
|
270
|
-
* @param startTime - Generation start timestamp for metrics
|
|
271
|
-
* @returns Enhanced result with PPT data
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* const result = await provider.generate({
|
|
276
|
-
* input: { text: "Introducing Our New Product" },
|
|
277
|
-
* output: { mode: "ppt", ppt: { pages: 10, theme: "modern" } }
|
|
278
|
-
* });
|
|
279
|
-
* // result.ppt contains the generated presentation info
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
private handlePPTGeneration;
|
|
283
296
|
/**
|
|
284
297
|
* Create analytics - delegated to TelemetryHandler
|
|
285
298
|
*/
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { directAgentTools } from "../agent/directTools.js";
|
|
2
|
+
import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
|
|
3
3
|
import { MiddlewareFactory } from "../middleware/factory.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
|
-
import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
|
|
6
|
-
import { directAgentTools } from "../agent/directTools.js";
|
|
7
5
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
8
6
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
9
|
-
import {
|
|
7
|
+
import { getKeyCount, getKeysAsString } from "../utils/transformationUtils.js";
|
|
8
|
+
import { TTSProcessor } from "../utils/ttsProcessor.js";
|
|
9
|
+
import { GenerationHandler } from "./modules/GenerationHandler.js";
|
|
10
10
|
// Import modules for composition
|
|
11
11
|
import { MessageBuilder } from "./modules/MessageBuilder.js";
|
|
12
12
|
import { StreamHandler } from "./modules/StreamHandler.js";
|
|
13
|
-
import { GenerationHandler } from "./modules/GenerationHandler.js";
|
|
14
13
|
import { TelemetryHandler } from "./modules/TelemetryHandler.js";
|
|
15
|
-
import { Utilities } from "./modules/Utilities.js";
|
|
16
14
|
import { ToolsManager } from "./modules/ToolsManager.js";
|
|
17
|
-
import {
|
|
15
|
+
import { Utilities } from "./modules/Utilities.js";
|
|
18
16
|
/**
|
|
19
17
|
* Abstract base class for all AI providers
|
|
20
18
|
* Tools are integrated as first-class citizens - always available by default
|
|
@@ -75,7 +73,7 @@ export class BaseProvider {
|
|
|
75
73
|
* When tools are involved, falls back to generate() with synthetic streaming
|
|
76
74
|
*/
|
|
77
75
|
async stream(optionsOrPrompt, analysisSchema) {
|
|
78
|
-
|
|
76
|
+
let options = this.normalizeStreamOptions(optionsOrPrompt);
|
|
79
77
|
logger.info(`Starting stream`, {
|
|
80
78
|
provider: this.providerName,
|
|
81
79
|
hasTools: !options.disableTools && this.supportsTools(),
|
|
@@ -98,6 +96,22 @@ export class BaseProvider {
|
|
|
98
96
|
// Skip real streaming, go directly to fake streaming
|
|
99
97
|
return await this.executeFakeStreaming(options, analysisSchema);
|
|
100
98
|
}
|
|
99
|
+
// Central tool merge: Pre-merge base tools (MCP/built-in) with user-provided
|
|
100
|
+
// tools (e.g. RAG tools) into options.tools. This way, every provider's
|
|
101
|
+
// executeStream() can simply use options.tools (or getAllTools() + options.tools)
|
|
102
|
+
// and get the complete tool set without needing per-provider merge logic.
|
|
103
|
+
if (!options.disableTools && this.supportsTools()) {
|
|
104
|
+
const baseTools = await this.getAllTools();
|
|
105
|
+
const externalTools = (options.tools || {});
|
|
106
|
+
const mergedTools = { ...baseTools, ...externalTools };
|
|
107
|
+
options = { ...options, tools: mergedTools };
|
|
108
|
+
logger.debug(`Central tool merge for stream`, {
|
|
109
|
+
provider: this.providerName,
|
|
110
|
+
baseToolCount: Object.keys(baseTools).length,
|
|
111
|
+
externalToolCount: Object.keys(externalTools).length,
|
|
112
|
+
totalToolCount: Object.keys(mergedTools).length,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
101
115
|
// CRITICAL FIX: Always prefer real streaming over fake streaming
|
|
102
116
|
// Try real streaming first, use fake streaming only as fallback
|
|
103
117
|
try {
|
|
@@ -148,6 +162,7 @@ export class BaseProvider {
|
|
|
148
162
|
systemPrompt: options.systemPrompt,
|
|
149
163
|
temperature: options.temperature,
|
|
150
164
|
maxTokens: options.maxTokens,
|
|
165
|
+
tools: options.tools, // 🔧 FIX: Pass user-provided tools (including RAG tools) to generation pipeline
|
|
151
166
|
disableTools: false,
|
|
152
167
|
maxSteps: options.maxSteps || 5,
|
|
153
168
|
provider: options.provider,
|
|
@@ -265,6 +280,29 @@ export class BaseProvider {
|
|
|
265
280
|
const model = await this.getAISDKModelWithMiddleware(options);
|
|
266
281
|
return { tools, model };
|
|
267
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Get merged tools for streaming: combines base tools (MCP/built-in) with
|
|
285
|
+
* user-provided tools (e.g., RAG tools passed via options.tools).
|
|
286
|
+
*
|
|
287
|
+
* This is the canonical tool-merge pattern for executeStream() implementations.
|
|
288
|
+
* All providers should call this instead of getAllTools() directly.
|
|
289
|
+
*/
|
|
290
|
+
async getToolsForStream(options) {
|
|
291
|
+
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
292
|
+
if (!shouldUseTools) {
|
|
293
|
+
return {};
|
|
294
|
+
}
|
|
295
|
+
const baseTools = await this.getAllTools();
|
|
296
|
+
const externalTools = (options.tools || {});
|
|
297
|
+
const merged = { ...baseTools, ...externalTools };
|
|
298
|
+
logger.debug(`Tools prepared for streaming`, {
|
|
299
|
+
provider: this.providerName,
|
|
300
|
+
baseToolCount: Object.keys(baseTools).length,
|
|
301
|
+
externalToolCount: Object.keys(externalTools).length,
|
|
302
|
+
totalToolCount: Object.keys(merged).length,
|
|
303
|
+
});
|
|
304
|
+
return merged;
|
|
305
|
+
}
|
|
268
306
|
/**
|
|
269
307
|
* Build messages array for generation - delegated to MessageBuilder
|
|
270
308
|
*/
|
|
@@ -346,15 +384,9 @@ export class BaseProvider {
|
|
|
346
384
|
try {
|
|
347
385
|
// ===== VIDEO GENERATION MODE =====
|
|
348
386
|
// Generate video from image + prompt using Veo 3.1
|
|
349
|
-
if (options.output?.mode === "video"
|
|
387
|
+
if (options.output?.mode === "video") {
|
|
350
388
|
return await this.handleVideoGeneration(options, startTime);
|
|
351
389
|
}
|
|
352
|
-
// ===== PPT GENERATION MODE =====
|
|
353
|
-
// Generate PowerPoint presentation from topic using AI content planning
|
|
354
|
-
// Triggered by mode="ppt" OR presence of ppt config block
|
|
355
|
-
if (options.output?.mode === "ppt" || options.output?.ppt) {
|
|
356
|
-
return await this.handlePPTGeneration(options, startTime);
|
|
357
|
-
}
|
|
358
390
|
// ===== IMAGE GENERATION MODE =====
|
|
359
391
|
// Route to executeImageGeneration for image generation models
|
|
360
392
|
const isImageModel = IMAGE_GENERATION_MODELS.some((m) => this.modelName.includes(m));
|
|
@@ -485,6 +517,46 @@ export class BaseProvider {
|
|
|
485
517
|
audio: result.audio,
|
|
486
518
|
};
|
|
487
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* Generate embeddings for text
|
|
522
|
+
*
|
|
523
|
+
* This is a default implementation that throws an error.
|
|
524
|
+
* Providers that support embeddings (OpenAI, Google Vertex, Amazon Bedrock)
|
|
525
|
+
* should override this method with their specific implementation.
|
|
526
|
+
*
|
|
527
|
+
* @param text - The text to embed
|
|
528
|
+
* @param _modelName - Optional embedding model name (provider-specific)
|
|
529
|
+
* @returns Promise resolving to the embedding vector (array of numbers)
|
|
530
|
+
* @throws Error if the provider does not support embeddings
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* const provider = await ProviderFactory.createProvider('openai', 'text-embedding-3-small');
|
|
535
|
+
* const embedding = await provider.embed('Hello world');
|
|
536
|
+
* console.log(embedding); // [0.123, -0.456, ...]
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
async embed(text, _modelName) {
|
|
540
|
+
logger.warn(`embed() called on ${this.providerName} which does not have a native implementation`, {
|
|
541
|
+
textLength: text.length,
|
|
542
|
+
});
|
|
543
|
+
throw new Error(`Embedding generation is not supported by the ${this.providerName} provider. ` +
|
|
544
|
+
`Supported providers: openai, vertex/google, bedrock. ` +
|
|
545
|
+
`Use an embedding model like text-embedding-3-small (OpenAI), text-embedding-004 (Vertex), ` +
|
|
546
|
+
`or amazon.titan-embed-text-v2:0 (Bedrock).`);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Get the default embedding model for this provider
|
|
550
|
+
*
|
|
551
|
+
* Override in subclasses to provide provider-specific defaults.
|
|
552
|
+
* Returns undefined for providers that don't support embeddings.
|
|
553
|
+
*
|
|
554
|
+
* @returns The default embedding model name, or undefined if not supported
|
|
555
|
+
*/
|
|
556
|
+
getDefaultEmbeddingModel() {
|
|
557
|
+
// Default implementation returns undefined - providers override this
|
|
558
|
+
return undefined;
|
|
559
|
+
}
|
|
488
560
|
/**
|
|
489
561
|
* Get AI SDK model with middleware applied
|
|
490
562
|
* This method wraps the base model with any configured middleware
|
|
@@ -688,21 +760,14 @@ export class BaseProvider {
|
|
|
688
760
|
}
|
|
689
761
|
async enhanceResult(result, options, startTime) {
|
|
690
762
|
const responseTime = Date.now() - startTime;
|
|
763
|
+
// CRITICAL FIX: Store imageOutput separately to ensure it's preserved
|
|
691
764
|
const imageOutput = result.imageOutput;
|
|
692
|
-
const ppt = result.ppt;
|
|
693
|
-
const video = result.video;
|
|
694
765
|
let enhancedResult = { ...result };
|
|
695
766
|
if (options.enableAnalytics) {
|
|
696
767
|
try {
|
|
697
768
|
const analytics = await this.createAnalytics(result, responseTime, options);
|
|
698
|
-
// Preserve ALL fields when adding analytics
|
|
699
|
-
enhancedResult = {
|
|
700
|
-
...enhancedResult,
|
|
701
|
-
analytics,
|
|
702
|
-
imageOutput,
|
|
703
|
-
ppt,
|
|
704
|
-
video,
|
|
705
|
-
};
|
|
769
|
+
// Preserve ALL fields including imageOutput when adding analytics
|
|
770
|
+
enhancedResult = { ...enhancedResult, analytics, imageOutput };
|
|
706
771
|
}
|
|
707
772
|
catch (error) {
|
|
708
773
|
logger.warn(`Analytics creation failed for ${this.providerName}:`, error);
|
|
@@ -711,28 +776,17 @@ export class BaseProvider {
|
|
|
711
776
|
if (options.enableEvaluation) {
|
|
712
777
|
try {
|
|
713
778
|
const evaluation = await this.createEvaluation(result, options);
|
|
714
|
-
// Preserve ALL fields when adding evaluation
|
|
715
|
-
enhancedResult = {
|
|
716
|
-
...enhancedResult,
|
|
717
|
-
evaluation,
|
|
718
|
-
imageOutput,
|
|
719
|
-
ppt,
|
|
720
|
-
video,
|
|
721
|
-
};
|
|
779
|
+
// Preserve ALL fields including imageOutput when adding evaluation
|
|
780
|
+
enhancedResult = { ...enhancedResult, evaluation, imageOutput };
|
|
722
781
|
}
|
|
723
782
|
catch (error) {
|
|
724
783
|
logger.warn(`Evaluation creation failed for ${this.providerName}:`, error);
|
|
725
784
|
}
|
|
726
785
|
}
|
|
786
|
+
// CRITICAL FIX: Always restore imageOutput if it existed in the original result
|
|
727
787
|
if (imageOutput) {
|
|
728
788
|
enhancedResult.imageOutput = imageOutput;
|
|
729
789
|
}
|
|
730
|
-
if (ppt) {
|
|
731
|
-
enhancedResult.ppt = ppt;
|
|
732
|
-
}
|
|
733
|
-
if (video) {
|
|
734
|
-
enhancedResult.video = video;
|
|
735
|
-
}
|
|
736
790
|
return enhancedResult;
|
|
737
791
|
}
|
|
738
792
|
/**
|
|
@@ -875,7 +929,10 @@ export class BaseProvider {
|
|
|
875
929
|
// Validate image format and size (for Buffer inputs)
|
|
876
930
|
const imageValidation = validateImageForVideo(imageBuffer);
|
|
877
931
|
if (imageValidation) {
|
|
878
|
-
throw ErrorFactory.invalidParameters("video-generation", new Error(imageValidation.message), {
|
|
932
|
+
throw ErrorFactory.invalidParameters("video-generation", new Error(imageValidation.message), {
|
|
933
|
+
field: "input.images[0]",
|
|
934
|
+
validation: imageValidation,
|
|
935
|
+
});
|
|
879
936
|
}
|
|
880
937
|
// Get prompt text
|
|
881
938
|
const prompt = options.prompt || options.input?.text || "";
|
|
@@ -904,103 +961,6 @@ export class BaseProvider {
|
|
|
904
961
|
};
|
|
905
962
|
return await this.enhanceResult(baseResult, options, startTime);
|
|
906
963
|
}
|
|
907
|
-
/**
|
|
908
|
-
* Handle PPT generation mode
|
|
909
|
-
*
|
|
910
|
-
* Generates a complete PowerPoint presentation using AI content planning
|
|
911
|
-
* and slide generation. This method orchestrates:
|
|
912
|
-
* 1. Input validation
|
|
913
|
-
* 2. Content planning via AI
|
|
914
|
-
* 3. Individual slide generation (with optional images)
|
|
915
|
-
* 4. PPTX assembly and file output
|
|
916
|
-
*
|
|
917
|
-
* @param options - Text generation options with PPT config
|
|
918
|
-
* @param startTime - Generation start timestamp for metrics
|
|
919
|
-
* @returns Enhanced result with PPT data
|
|
920
|
-
*
|
|
921
|
-
* @example
|
|
922
|
-
* ```typescript
|
|
923
|
-
* const result = await provider.generate({
|
|
924
|
-
* input: { text: "Introducing Our New Product" },
|
|
925
|
-
* output: { mode: "ppt", ppt: { pages: 10, theme: "modern" } }
|
|
926
|
-
* });
|
|
927
|
-
* // result.ppt contains the generated presentation info
|
|
928
|
-
* ```
|
|
929
|
-
*/
|
|
930
|
-
async handlePPTGeneration(options, startTime) {
|
|
931
|
-
// Dynamic imports to avoid loading PPT dependencies unless needed
|
|
932
|
-
const { generatePresentation } = await import("../features/ppt/presentationOrchestrator.js");
|
|
933
|
-
const { PPT_GENERATION_TIMEOUT_MS } = await import("../features/ppt/constants.js");
|
|
934
|
-
const { validatePPTGenerationInput } = await import("../utils/parameterValidation.js");
|
|
935
|
-
const { ErrorFactory, withTimeout } = await import("../utils/errorHandling.js");
|
|
936
|
-
const { extractPPTContext, getEffectivePPTProvider } = await import("../features/ppt/utils.js");
|
|
937
|
-
// Get effective PPT provider (handles validation and auto-selection)
|
|
938
|
-
const effective = await getEffectivePPTProvider(this, this.providerName, this.modelName, this.neurolink);
|
|
939
|
-
// Build input from prompt or input.text (preserve images for logo)
|
|
940
|
-
const inputText = options.input?.text || options.prompt || "";
|
|
941
|
-
const generateOptions = {
|
|
942
|
-
input: {
|
|
943
|
-
text: inputText,
|
|
944
|
-
images: options.input?.images, // Pass through images for logo
|
|
945
|
-
},
|
|
946
|
-
output: options.output,
|
|
947
|
-
provider: effective.providerName,
|
|
948
|
-
model: options.model,
|
|
949
|
-
};
|
|
950
|
-
// Validate PPT generation input
|
|
951
|
-
const validation = validatePPTGenerationInput(generateOptions);
|
|
952
|
-
if (!validation.isValid) {
|
|
953
|
-
const errorMessages = validation.errors.map((e) => e.message).join("; ");
|
|
954
|
-
throw ErrorFactory.invalidParameters("ppt-generation", new Error(errorMessages), { errors: validation.errors });
|
|
955
|
-
}
|
|
956
|
-
// Log warnings
|
|
957
|
-
for (const warning of validation.warnings) {
|
|
958
|
-
logger.warn(`PPT generation warning: ${warning}`);
|
|
959
|
-
}
|
|
960
|
-
// Extract context with all PPT options (including images for logo)
|
|
961
|
-
const context = extractPPTContext({
|
|
962
|
-
input: {
|
|
963
|
-
text: inputText,
|
|
964
|
-
images: options.input?.images, // Pass through images for logo
|
|
965
|
-
},
|
|
966
|
-
output: generateOptions.output,
|
|
967
|
-
provider: effective.providerName,
|
|
968
|
-
model: effective.modelName,
|
|
969
|
-
});
|
|
970
|
-
logger.info("Starting PPT generation", {
|
|
971
|
-
provider: effective.providerName,
|
|
972
|
-
model: effective.modelName,
|
|
973
|
-
topic: context.topic.substring(0, 100),
|
|
974
|
-
pages: context.pages,
|
|
975
|
-
theme: context.theme,
|
|
976
|
-
generateAIImages: context.generateAIImages,
|
|
977
|
-
});
|
|
978
|
-
// Generate presentation using orchestrator (with timeout)
|
|
979
|
-
const pptResult = await withTimeout(generatePresentation({
|
|
980
|
-
context,
|
|
981
|
-
provider: effective.provider,
|
|
982
|
-
providerName: effective.providerName,
|
|
983
|
-
modelName: effective.modelName,
|
|
984
|
-
neurolink: this.neurolink,
|
|
985
|
-
imageProvider: effective.providerName,
|
|
986
|
-
imageModel: effective.modelName,
|
|
987
|
-
}), PPT_GENERATION_TIMEOUT_MS, ErrorFactory.toolTimeout("pptGeneration", PPT_GENERATION_TIMEOUT_MS));
|
|
988
|
-
logger.info("PPT generation complete", {
|
|
989
|
-
filePath: pptResult.filePath,
|
|
990
|
-
totalSlides: pptResult.totalSlides,
|
|
991
|
-
processingTime: Date.now() - startTime,
|
|
992
|
-
});
|
|
993
|
-
// Ensure we always have model name - fallback to this provider's modelName or default
|
|
994
|
-
const finalModelName = effective.modelName || this.modelName || this.getDefaultModel();
|
|
995
|
-
// Build result
|
|
996
|
-
return await this.enhanceResult({
|
|
997
|
-
content: context.topic,
|
|
998
|
-
provider: effective.providerName,
|
|
999
|
-
model: finalModelName,
|
|
1000
|
-
usage: { input: 0, output: 0, total: 0 },
|
|
1001
|
-
ppt: pptResult,
|
|
1002
|
-
}, options, startTime);
|
|
1003
|
-
}
|
|
1004
964
|
/**
|
|
1005
965
|
* Create analytics - delegated to TelemetryHandler
|
|
1006
966
|
*/
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Creates appropriate conversation memory manager based on configuration
|
|
4
4
|
*/
|
|
5
5
|
import type { ConversationMemoryConfig, RedisStorageConfig } from "../types/conversation.js";
|
|
6
|
-
import type { StorageType
|
|
6
|
+
import type { StorageType } from "../types/common.js";
|
|
7
7
|
import { ConversationMemoryManager } from "./conversationMemoryManager.js";
|
|
8
8
|
import { RedisConversationMemoryManager } from "./redisConversationMemoryManager.js";
|
|
9
9
|
/**
|
|
10
10
|
* Creates a conversation memory manager based on configuration
|
|
11
11
|
*/
|
|
12
|
-
export declare function createConversationMemoryManager(config: ConversationMemoryConfig, storageType?: StorageType, redisConfig?: RedisStorageConfig
|
|
12
|
+
export declare function createConversationMemoryManager(config: ConversationMemoryConfig, storageType?: StorageType, redisConfig?: RedisStorageConfig): ConversationMemoryManager | RedisConversationMemoryManager;
|
|
13
13
|
/**
|
|
14
14
|
* Get storage type from environment variable or configuration
|
|
15
15
|
*/
|
|
@@ -8,7 +8,7 @@ import { logger } from "../utils/logger.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates a conversation memory manager based on configuration
|
|
10
10
|
*/
|
|
11
|
-
export function createConversationMemoryManager(config, storageType = "memory", redisConfig
|
|
11
|
+
export function createConversationMemoryManager(config, storageType = "memory", redisConfig) {
|
|
12
12
|
logger.debug("[conversationMemoryFactory] Creating conversation memory manager", {
|
|
13
13
|
storageType,
|
|
14
14
|
config: {
|
|
@@ -38,7 +38,7 @@ export function createConversationMemoryManager(config, storageType = "memory",
|
|
|
38
38
|
ttl: redisConfig?.ttl || 86400,
|
|
39
39
|
hasConnectionOptions: !!redisConfig?.connectionOptions,
|
|
40
40
|
});
|
|
41
|
-
const redisManager = new RedisConversationMemoryManager(config, redisConfig
|
|
41
|
+
const redisManager = new RedisConversationMemoryManager(config, redisConfig);
|
|
42
42
|
logger.debug("[conversationMemoryFactory] Redis conversation manager created successfully", {
|
|
43
43
|
managerType: redisManager.constructor.name,
|
|
44
44
|
config: {
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
import type { ConversationMemoryConfig } from "../types/conversation.js";
|
|
6
6
|
import type { ConversationMemoryManager } from "./conversationMemoryManager.js";
|
|
7
7
|
import type { RedisConversationMemoryManager } from "./redisConversationMemoryManager.js";
|
|
8
|
-
import type { TypedEventEmitter, NeuroLinkEvents } from "../types/common.js";
|
|
9
8
|
/**
|
|
10
9
|
* Initialize conversation memory for NeuroLink
|
|
11
10
|
* This function decides whether to use in-memory or Redis storage
|
|
12
11
|
*/
|
|
13
12
|
export declare function initializeConversationMemory(config?: {
|
|
14
13
|
conversationMemory?: Partial<ConversationMemoryConfig>;
|
|
15
|
-
}
|
|
14
|
+
}): Promise<ConversationMemoryManager | RedisConversationMemoryManager | null>;
|
|
@@ -9,7 +9,7 @@ import { logger } from "../utils/logger.js";
|
|
|
9
9
|
* Initialize conversation memory for NeuroLink
|
|
10
10
|
* This function decides whether to use in-memory or Redis storage
|
|
11
11
|
*/
|
|
12
|
-
export async function initializeConversationMemory(config
|
|
12
|
+
export async function initializeConversationMemory(config) {
|
|
13
13
|
logger.debug("[conversationMemoryInitializer] Initialize conversation memory called", {
|
|
14
14
|
hasConfig: !!config,
|
|
15
15
|
hasMemoryConfig: !!config?.conversationMemory,
|
|
@@ -55,7 +55,7 @@ export async function initializeConversationMemory(config, eventEmitter) {
|
|
|
55
55
|
});
|
|
56
56
|
// Create Redis-based conversation memory manager
|
|
57
57
|
logger.debug("[conversationMemoryInitializer] Creating Redis conversation memory manager");
|
|
58
|
-
const redisMemoryManager = createConversationMemoryManager(memoryConfig, "redis", redisConfig
|
|
58
|
+
const redisMemoryManager = createConversationMemoryManager(memoryConfig, "redis", redisConfig);
|
|
59
59
|
logger.debug("[conversationMemoryInitializer] Checking Redis manager creation result", {
|
|
60
60
|
managerType: redisMemoryManager?.constructor?.name || "unknown",
|
|
61
61
|
isRedisType: redisMemoryManager?.constructor?.name ===
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ErrorCode = string;
|
|
2
|
+
export declare class NeuroLinkFeatureError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly feature: string;
|
|
5
|
+
readonly retryable: boolean;
|
|
6
|
+
readonly details?: Record<string, unknown>;
|
|
7
|
+
readonly cause?: Error;
|
|
8
|
+
constructor(message: string, code: ErrorCode, feature: string, options?: {
|
|
9
|
+
retryable?: boolean;
|
|
10
|
+
details?: Record<string, unknown>;
|
|
11
|
+
cause?: Error;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export declare function createErrorFactory<TCodes extends Record<string, string>>(feature: string, codes: TCodes): {
|
|
15
|
+
codes: TCodes;
|
|
16
|
+
create: (code: keyof TCodes, message: string, options?: {
|
|
17
|
+
retryable?: boolean;
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
cause?: Error;
|
|
20
|
+
}) => NeuroLinkFeatureError;
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class NeuroLinkFeatureError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
feature;
|
|
4
|
+
retryable;
|
|
5
|
+
details;
|
|
6
|
+
cause;
|
|
7
|
+
constructor(message, code, feature, options) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = `${feature}Error`;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.feature = feature;
|
|
12
|
+
this.retryable = options?.retryable ?? false;
|
|
13
|
+
this.details = options?.details;
|
|
14
|
+
this.cause = options?.cause;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function createErrorFactory(feature, codes) {
|
|
18
|
+
return {
|
|
19
|
+
codes,
|
|
20
|
+
create: (code, message, options) => new NeuroLinkFeatureError(message, codes[code], feature, options),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type FactoryFunction<TInstance, TConfig> = (config?: TConfig) => Promise<TInstance>;
|
|
2
|
+
export type FactoryRegistration<TInstance, TConfig> = {
|
|
3
|
+
factory: FactoryFunction<TInstance, TConfig>;
|
|
4
|
+
aliases: string[];
|
|
5
|
+
metadata?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare abstract class BaseFactory<TInstance, TConfig = unknown> {
|
|
8
|
+
protected items: Map<string, FactoryRegistration<TInstance, TConfig>>;
|
|
9
|
+
protected aliasMap: Map<string, string>;
|
|
10
|
+
protected initialized: boolean;
|
|
11
|
+
protected initPromise: Promise<void> | null;
|
|
12
|
+
protected abstract registerAll(): Promise<void>;
|
|
13
|
+
ensureInitialized(): Promise<void>;
|
|
14
|
+
register(name: string, factory: FactoryFunction<TInstance, TConfig>, aliases?: string[], metadata?: Record<string, unknown>): void;
|
|
15
|
+
create(nameOrAlias: string, config?: TConfig): Promise<TInstance>;
|
|
16
|
+
resolveName(nameOrAlias: string): string;
|
|
17
|
+
has(nameOrAlias: string): boolean;
|
|
18
|
+
getAvailable(): string[];
|
|
19
|
+
getAliases(): Map<string, string>;
|
|
20
|
+
clear(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { logger } from "../../utils/logger.js";
|
|
2
|
+
export class BaseFactory {
|
|
3
|
+
items = new Map();
|
|
4
|
+
aliasMap = new Map();
|
|
5
|
+
initialized = false;
|
|
6
|
+
initPromise = null;
|
|
7
|
+
async ensureInitialized() {
|
|
8
|
+
if (this.initialized) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (this.initPromise) {
|
|
12
|
+
return this.initPromise;
|
|
13
|
+
}
|
|
14
|
+
this.initPromise = this.registerAll();
|
|
15
|
+
await this.initPromise;
|
|
16
|
+
this.initialized = true;
|
|
17
|
+
}
|
|
18
|
+
register(name, factory, aliases = [], metadata) {
|
|
19
|
+
this.items.set(name, { factory, aliases, metadata });
|
|
20
|
+
for (const alias of aliases) {
|
|
21
|
+
this.aliasMap.set(alias.toLowerCase(), name);
|
|
22
|
+
}
|
|
23
|
+
logger.debug(`Registered ${name} with aliases: ${aliases.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
async create(nameOrAlias, config) {
|
|
26
|
+
await this.ensureInitialized();
|
|
27
|
+
const name = this.resolveName(nameOrAlias);
|
|
28
|
+
const registration = this.items.get(name);
|
|
29
|
+
if (!registration) {
|
|
30
|
+
throw new Error(`Unknown item: ${nameOrAlias}`);
|
|
31
|
+
}
|
|
32
|
+
return registration.factory(config);
|
|
33
|
+
}
|
|
34
|
+
resolveName(nameOrAlias) {
|
|
35
|
+
const lower = nameOrAlias.toLowerCase();
|
|
36
|
+
return this.aliasMap.get(lower) || nameOrAlias;
|
|
37
|
+
}
|
|
38
|
+
has(nameOrAlias) {
|
|
39
|
+
const name = this.resolveName(nameOrAlias);
|
|
40
|
+
return this.items.has(name);
|
|
41
|
+
}
|
|
42
|
+
getAvailable() {
|
|
43
|
+
return Array.from(this.items.keys());
|
|
44
|
+
}
|
|
45
|
+
getAliases() {
|
|
46
|
+
return new Map(this.aliasMap);
|
|
47
|
+
}
|
|
48
|
+
clear() {
|
|
49
|
+
this.items.clear();
|
|
50
|
+
this.aliasMap.clear();
|
|
51
|
+
this.initialized = false;
|
|
52
|
+
this.initPromise = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type RegistryEntry<TItem, TMetadata = unknown> = {
|
|
2
|
+
factory: () => Promise<TItem>;
|
|
3
|
+
metadata: TMetadata;
|
|
4
|
+
instance?: TItem;
|
|
5
|
+
};
|
|
6
|
+
export declare abstract class BaseRegistry<TItem, TMetadata = unknown> {
|
|
7
|
+
protected items: Map<string, RegistryEntry<TItem, TMetadata>>;
|
|
8
|
+
protected initialized: boolean;
|
|
9
|
+
protected initPromise: Promise<void> | null;
|
|
10
|
+
protected abstract registerAll(): Promise<void>;
|
|
11
|
+
ensureInitialized(): Promise<void>;
|
|
12
|
+
register(id: string, factory: () => Promise<TItem>, metadata: TMetadata): void;
|
|
13
|
+
get(id: string): Promise<TItem | undefined>;
|
|
14
|
+
has(id: string): boolean;
|
|
15
|
+
list(): Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
metadata: TMetadata;
|
|
18
|
+
}>;
|
|
19
|
+
clear(): void;
|
|
20
|
+
isInitialized(): boolean;
|
|
21
|
+
}
|