@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
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Conversation Memory Utilities
|
|
3
3
|
* Handles configuration merging and conversation memory operations
|
|
4
4
|
*/
|
|
5
|
-
import { getConversationMemoryDefaults, MEMORY_THRESHOLD_PERCENTAGE,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { DEFAULT_FALLBACK_THRESHOLD, getConversationMemoryDefaults, MEMORY_THRESHOLD_PERCENTAGE, } from "../config/conversationMemory.js";
|
|
6
|
+
import { getAvailableInputTokens } from "../constants/contextWindows.js";
|
|
7
|
+
import { buildSummarizationPrompt } from "../context/prompts/summarizationPrompt.js";
|
|
8
8
|
import { NeuroLink } from "../neurolink.js";
|
|
9
|
+
import { logger } from "./logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Apply conversation memory defaults to user configuration
|
|
11
12
|
* Merges user config with environment variables and default values
|
|
@@ -103,7 +104,22 @@ export async function storeConversationTurn(conversationMemory, originalOptions,
|
|
|
103
104
|
}
|
|
104
105
|
const userMessage = originalOptions.originalPrompt || originalOptions.prompt || "";
|
|
105
106
|
const aiResponse = result.content ?? "";
|
|
106
|
-
|
|
107
|
+
// Guard: skip storing conversation turn if AI response is empty AND no tools were used.
|
|
108
|
+
// Empty assistant messages cause "text content blocks must be non-empty" errors
|
|
109
|
+
// when loaded as conversation history on the next interaction.
|
|
110
|
+
// However, tool-only turns (empty text but tools were invoked) must still be stored
|
|
111
|
+
// to preserve tool-calling conversation history.
|
|
112
|
+
const hasToolActivity = (result.toolsUsed && result.toolsUsed.length > 0) ||
|
|
113
|
+
(result.toolExecutions && result.toolExecutions.length > 0);
|
|
114
|
+
if (!aiResponse.trim() && !hasToolActivity) {
|
|
115
|
+
logger.warn("[conversationMemoryUtils] Skipping conversation turn storage — AI response is empty and no tool activity", {
|
|
116
|
+
sessionId,
|
|
117
|
+
userId,
|
|
118
|
+
userMessageLength: userMessage.length,
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
let providerDetails;
|
|
107
123
|
if (result.provider && result.model) {
|
|
108
124
|
providerDetails = {
|
|
109
125
|
provider: result.provider,
|
|
@@ -119,6 +135,15 @@ export async function storeConversationTurn(conversationMemory, originalOptions,
|
|
|
119
135
|
startTimeStamp,
|
|
120
136
|
providerDetails,
|
|
121
137
|
enableSummarization: originalOptions.enableSummarization,
|
|
138
|
+
tokenUsage: result.usage
|
|
139
|
+
? {
|
|
140
|
+
inputTokens: result.usage.input,
|
|
141
|
+
outputTokens: result.usage.output,
|
|
142
|
+
totalTokens: result.usage.total,
|
|
143
|
+
cacheReadTokens: result.usage.cacheReadTokens,
|
|
144
|
+
cacheWriteTokens: result.usage.cacheCreationTokens,
|
|
145
|
+
}
|
|
146
|
+
: undefined,
|
|
122
147
|
});
|
|
123
148
|
logger.debug("[conversationMemoryUtils] Conversation turn stored successfully", {
|
|
124
149
|
sessionId,
|
|
@@ -189,49 +214,34 @@ export function createSummarizationPrompt(history, previousSummary) {
|
|
|
189
214
|
const formattedHistory = history
|
|
190
215
|
.map((msg) => `${msg.role}: ${msg.content}`)
|
|
191
216
|
.join("\n\n");
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
`
|
|
199
|
-
: "";
|
|
200
|
-
return `
|
|
201
|
-
You are a context summarization AI. Your task is to condense the following conversation history for another AI assistant.
|
|
202
|
-
${previousSummary ? "Build upon the previous summary and incorporate the new conversation turns below." : ""}
|
|
203
|
-
The summary must be a concise, third-person narrative that retains all critical information, including key entities, technical details, decisions made, and any specific dates or times mentioned.
|
|
204
|
-
Ensure the summary flows logically and is ready to be used as context for the next turn in the conversation.
|
|
217
|
+
const structuredPrompt = buildSummarizationPrompt({
|
|
218
|
+
isIncremental: !!previousSummary,
|
|
219
|
+
previousSummary,
|
|
220
|
+
});
|
|
221
|
+
return `${structuredPrompt}
|
|
205
222
|
|
|
206
|
-
|
|
223
|
+
Conversation History to Summarize:
|
|
207
224
|
---
|
|
208
225
|
${formattedHistory}
|
|
209
|
-
|
|
210
|
-
`.trim();
|
|
226
|
+
---`;
|
|
211
227
|
}
|
|
212
228
|
/**
|
|
213
|
-
* Calculate token threshold based on model's
|
|
214
|
-
* Uses
|
|
229
|
+
* Calculate token threshold based on model's context window and available input tokens
|
|
230
|
+
* Uses context window registry for accurate per-provider, per-model limits
|
|
215
231
|
* @param provider - AI provider name
|
|
216
232
|
* @param model - Model name
|
|
217
|
-
* @
|
|
233
|
+
* @param maxTokens - Optional explicit maxTokens for output reserve calculation
|
|
234
|
+
* @returns Token threshold (80% of available input tokens)
|
|
218
235
|
*/
|
|
219
|
-
export function calculateTokenThreshold(provider, model) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const modelTokenLimit = TokenUtils.getProviderTokenLimit(provider, model);
|
|
223
|
-
// Return 80% of token limit for conversation memory
|
|
224
|
-
// This is conservative since output limits are typically smaller than input limits
|
|
225
|
-
return Math.floor(modelTokenLimit * MEMORY_THRESHOLD_PERCENTAGE);
|
|
236
|
+
export function calculateTokenThreshold(provider, model, maxTokens) {
|
|
237
|
+
if (!provider) {
|
|
238
|
+
return DEFAULT_FALLBACK_THRESHOLD;
|
|
226
239
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
provider,
|
|
230
|
-
model,
|
|
231
|
-
error: error instanceof Error ? error.message : String(error),
|
|
232
|
-
});
|
|
240
|
+
const availableInput = getAvailableInputTokens(provider, model, maxTokens);
|
|
241
|
+
if (availableInput <= 0) {
|
|
233
242
|
return DEFAULT_FALLBACK_THRESHOLD;
|
|
234
243
|
}
|
|
244
|
+
return Math.floor(availableInput * MEMORY_THRESHOLD_PERCENTAGE);
|
|
235
245
|
}
|
|
236
246
|
/**
|
|
237
247
|
* Get effective token threshold for a session
|
|
@@ -297,3 +307,48 @@ export async function generateSummary(messages, config, logPrefix = "[Conversati
|
|
|
297
307
|
return null;
|
|
298
308
|
}
|
|
299
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Check if Redis is available for conversation memory.
|
|
312
|
+
* Migrated from the deprecated conversationMemoryUtils.ts.
|
|
313
|
+
*/
|
|
314
|
+
export async function checkRedisAvailability() {
|
|
315
|
+
const { createRedisClient, getNormalizedConfig } = await import("./redis.js");
|
|
316
|
+
let testClient = null;
|
|
317
|
+
try {
|
|
318
|
+
const testConfig = getNormalizedConfig({
|
|
319
|
+
host: process.env.REDIS_HOST,
|
|
320
|
+
port: process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : undefined,
|
|
321
|
+
password: process.env.REDIS_PASSWORD,
|
|
322
|
+
db: process.env.REDIS_DB ? Number(process.env.REDIS_DB) : undefined,
|
|
323
|
+
keyPrefix: process.env.REDIS_KEY_PREFIX,
|
|
324
|
+
ttl: process.env.REDIS_TTL ? Number(process.env.REDIS_TTL) : undefined,
|
|
325
|
+
connectionOptions: {
|
|
326
|
+
connectTimeout: 5000,
|
|
327
|
+
maxRetriesPerRequest: 1,
|
|
328
|
+
retryDelayOnFailover: 100,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
testClient = await createRedisClient(testConfig);
|
|
332
|
+
await testClient.ping();
|
|
333
|
+
logger.debug("Redis connection test successful");
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
logger.debug("Redis connection test failed", {
|
|
338
|
+
error: error instanceof Error ? error.message : String(error),
|
|
339
|
+
});
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
finally {
|
|
343
|
+
if (testClient) {
|
|
344
|
+
try {
|
|
345
|
+
await testClient.quit();
|
|
346
|
+
}
|
|
347
|
+
catch (quitError) {
|
|
348
|
+
logger.debug("Error during Redis test client disconnect", {
|
|
349
|
+
error: quitError instanceof Error ? quitError.message : String(quitError),
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
@@ -244,6 +244,11 @@ export declare class CircuitBreaker {
|
|
|
244
244
|
getState(): "closed" | "open" | "half-open";
|
|
245
245
|
getFailureCount(): number;
|
|
246
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Detect AbortError from any source (DOMException, plain Error, or message-based).
|
|
249
|
+
* Used to short-circuit retry/fallback loops when an abort signal fires.
|
|
250
|
+
*/
|
|
251
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
247
252
|
/**
|
|
248
253
|
* Error handler that decides whether to retry based on error type
|
|
249
254
|
*/
|
|
@@ -820,6 +820,25 @@ export class CircuitBreaker {
|
|
|
820
820
|
return this.failures;
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Detect AbortError from any source (DOMException, plain Error, or message-based).
|
|
825
|
+
* Used to short-circuit retry/fallback loops when an abort signal fires.
|
|
826
|
+
*/
|
|
827
|
+
export function isAbortError(error) {
|
|
828
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
829
|
+
return true;
|
|
830
|
+
}
|
|
831
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
832
|
+
return true;
|
|
833
|
+
}
|
|
834
|
+
if (error instanceof Error &&
|
|
835
|
+
(error.message === "This operation was aborted" ||
|
|
836
|
+
error.message === "The operation was aborted" ||
|
|
837
|
+
error.message?.includes("The user aborted a request"))) {
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
823
842
|
/**
|
|
824
843
|
* Error handler that decides whether to retry based on error type
|
|
825
844
|
*/
|
|
@@ -65,10 +65,72 @@ export declare class FileDetector {
|
|
|
65
65
|
* Load file content from various sources
|
|
66
66
|
*/
|
|
67
67
|
private static loadContent;
|
|
68
|
+
/**
|
|
69
|
+
* SDK-8: Format an informative placeholder when a file processor fails.
|
|
70
|
+
* Instead of bare "[Video file: name]" strings, include size, format, and
|
|
71
|
+
* the reason for failure so the LLM can acknowledge the attachment.
|
|
72
|
+
*/
|
|
73
|
+
private static formatInformativePlaceholder;
|
|
74
|
+
/**
|
|
75
|
+
* Extract metadata and printable strings from an unrecognized binary file.
|
|
76
|
+
* This is the "extract what you can" path for unknown file types.
|
|
77
|
+
*
|
|
78
|
+
* Extracts:
|
|
79
|
+
* - File size (human-readable)
|
|
80
|
+
* - MIME type / detected format
|
|
81
|
+
* - First N bytes as hex dump (for identification)
|
|
82
|
+
* - Printable ASCII/UTF-8 strings found in the binary (like `strings` command)
|
|
83
|
+
* - Known file signatures that we don't have full processors for
|
|
84
|
+
*
|
|
85
|
+
* @param content Raw file buffer
|
|
86
|
+
* @param detection Detection result (may be "unknown")
|
|
87
|
+
* @param filename Original filename (if known)
|
|
88
|
+
* @returns Formatted text summary suitable for LLM consumption
|
|
89
|
+
*/
|
|
90
|
+
private static extractBinaryMetadata;
|
|
91
|
+
/**
|
|
92
|
+
* Identify known binary file signatures beyond what we can process.
|
|
93
|
+
* Returns a human-readable description, or null if unrecognized.
|
|
94
|
+
*/
|
|
95
|
+
private static identifyBinarySignature;
|
|
96
|
+
/**
|
|
97
|
+
* Extract printable ASCII strings from a binary buffer.
|
|
98
|
+
* Similar to the Unix `strings` utility.
|
|
99
|
+
*
|
|
100
|
+
* @param buf Buffer to scan
|
|
101
|
+
* @param minLength Minimum string length to include (default 4)
|
|
102
|
+
* @param maxStrings Maximum number of strings to return (default 50)
|
|
103
|
+
* @returns Array of printable strings found in the binary
|
|
104
|
+
*/
|
|
105
|
+
private static extractPrintableStrings;
|
|
68
106
|
/**
|
|
69
107
|
* Route to appropriate processor
|
|
70
108
|
*/
|
|
71
109
|
private static processFile;
|
|
110
|
+
/**
|
|
111
|
+
* Process video file: extract metadata, keyframes, and subtitles via VideoProcessor
|
|
112
|
+
*/
|
|
113
|
+
private static processVideoFile;
|
|
114
|
+
/**
|
|
115
|
+
* Process audio file: extract metadata, tags, and cover art via AudioProcessor
|
|
116
|
+
*/
|
|
117
|
+
private static processAudioFile;
|
|
118
|
+
/**
|
|
119
|
+
* Process archive file: list contents and extract metadata via ArchiveProcessor
|
|
120
|
+
*/
|
|
121
|
+
private static processArchiveFile;
|
|
122
|
+
/**
|
|
123
|
+
* Process Excel/OpenDocument spreadsheet file via ExcelProcessor or OpenDocumentProcessor
|
|
124
|
+
*/
|
|
125
|
+
private static processXlsxFile;
|
|
126
|
+
/**
|
|
127
|
+
* Process Word/OpenDocument/RTF document via WordProcessor, OpenDocumentProcessor, or RtfProcessor
|
|
128
|
+
*/
|
|
129
|
+
private static processDocxFile;
|
|
130
|
+
/**
|
|
131
|
+
* Process PowerPoint/OpenDocument presentation via PptxProcessor
|
|
132
|
+
*/
|
|
133
|
+
private static processPptxFile;
|
|
72
134
|
/**
|
|
73
135
|
* Process SVG file as text content
|
|
74
136
|
* Uses SvgProcessor for security sanitization (removes XSS vectors)
|