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