@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,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video Processor
|
|
3
|
+
*
|
|
4
|
+
* Handles downloading, validating, and processing video files for AI consumption.
|
|
5
|
+
* Since LLMs cannot process raw video, this processor extracts:
|
|
6
|
+
* - Structured metadata (duration, resolution, codecs, etc.)
|
|
7
|
+
* - Keyframes at configurable intervals (resized to 768px JPEG)
|
|
8
|
+
* - Embedded subtitle tracks (if present)
|
|
9
|
+
*
|
|
10
|
+
* The extracted content is formatted as text + images that can be sent to any
|
|
11
|
+
* AI provider for analysis.
|
|
12
|
+
*
|
|
13
|
+
* Uses fluent-ffmpeg for video processing and sharp for frame resizing.
|
|
14
|
+
* Requires ffmpeg/ffprobe to be available (via ffmpeg-static or system PATH).
|
|
15
|
+
*
|
|
16
|
+
* Key features:
|
|
17
|
+
* - Adaptive keyframe extraction intervals based on video duration
|
|
18
|
+
* - Frame count capping (max 20 frames) to control token usage
|
|
19
|
+
* - JPEG quality optimization for AI vision models
|
|
20
|
+
* - Embedded subtitle extraction (SRT format)
|
|
21
|
+
* - Graceful degradation on corrupt files or missing codecs
|
|
22
|
+
* - Temp file cleanup with finally blocks
|
|
23
|
+
* - Configurable timeouts for ffmpeg and ffprobe operations
|
|
24
|
+
*
|
|
25
|
+
* @module processors/media/VideoProcessor
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { videoProcessor, processVideo, isVideoFile } from "./VideoProcessor.js";
|
|
30
|
+
*
|
|
31
|
+
* // Check if a file is a video file
|
|
32
|
+
* if (isVideoFile(fileInfo.mimetype, fileInfo.name)) {
|
|
33
|
+
* const result = await processVideo(fileInfo, {
|
|
34
|
+
* authHeaders: { Authorization: "Bearer token" },
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* if (result.success) {
|
|
38
|
+
* console.log(`Duration: ${result.data.metadata.durationFormatted}`);
|
|
39
|
+
* console.log(`Keyframes: ${result.data.frameCount}`);
|
|
40
|
+
* console.log(`Text for LLM:\n${result.data.textContent}`);
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import { BaseFileProcessor } from "../base/BaseFileProcessor.js";
|
|
46
|
+
import type { FileInfo, FileProcessingResult, ProcessedFileBase, ProcessOptions } from "../base/types.js";
|
|
47
|
+
/**
|
|
48
|
+
* Processed video result.
|
|
49
|
+
* Extends ProcessedFileBase with video-specific fields including metadata,
|
|
50
|
+
* extracted keyframes, subtitle text, and a pre-formatted textContent block
|
|
51
|
+
* suitable for sending to an LLM.
|
|
52
|
+
*/
|
|
53
|
+
export type ProcessedVideo = ProcessedFileBase & {
|
|
54
|
+
/** Pre-formatted text description for the LLM (metadata + subtitles summary) */
|
|
55
|
+
textContent: string;
|
|
56
|
+
/** Extracted keyframes as JPEG buffers (resized to max 768px dimension) */
|
|
57
|
+
keyframes: Buffer[];
|
|
58
|
+
/** Video metadata extracted via ffprobe */
|
|
59
|
+
metadata: {
|
|
60
|
+
/** Duration in seconds */
|
|
61
|
+
duration: number;
|
|
62
|
+
/** Human-readable duration (e.g., "2m 30s") */
|
|
63
|
+
durationFormatted: string;
|
|
64
|
+
/** Video width in pixels */
|
|
65
|
+
width: number;
|
|
66
|
+
/** Video height in pixels */
|
|
67
|
+
height: number;
|
|
68
|
+
/** Video codec name (e.g., "h264", "vp9") */
|
|
69
|
+
codec: string;
|
|
70
|
+
/** Frames per second */
|
|
71
|
+
fps: number;
|
|
72
|
+
/** Video bitrate in bits/second */
|
|
73
|
+
bitrate: number;
|
|
74
|
+
/** Audio codec name if present */
|
|
75
|
+
audioCodec?: string;
|
|
76
|
+
/** Number of audio channels */
|
|
77
|
+
audioChannels?: number;
|
|
78
|
+
/** Audio sample rate in Hz */
|
|
79
|
+
audioSampleRate?: number;
|
|
80
|
+
/** Number of subtitle tracks found */
|
|
81
|
+
subtitleTracks: number;
|
|
82
|
+
/** Original file size in bytes */
|
|
83
|
+
fileSize: number;
|
|
84
|
+
};
|
|
85
|
+
/** Extracted subtitle text (combined from all subtitle tracks) */
|
|
86
|
+
subtitleText?: string;
|
|
87
|
+
/** Whether any keyframes were successfully extracted */
|
|
88
|
+
hasKeyframes: boolean;
|
|
89
|
+
/** Number of keyframes extracted */
|
|
90
|
+
frameCount: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Video Processor - extracts metadata, keyframes, and subtitles from video files.
|
|
94
|
+
*
|
|
95
|
+
* Since LLMs cannot process raw video, this processor converts videos into
|
|
96
|
+
* a structured representation consisting of:
|
|
97
|
+
* 1. Text metadata block (duration, resolution, codecs, etc.)
|
|
98
|
+
* 2. Keyframe images (JPEG, resized to 768px max dimension)
|
|
99
|
+
* 3. Subtitle text (if embedded in the video)
|
|
100
|
+
*
|
|
101
|
+
* The processor uses a temp file approach because ffmpeg requires file paths
|
|
102
|
+
* for most operations. Temp files are always cleaned up in finally blocks.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const processor = new VideoProcessor();
|
|
107
|
+
* const result = await processor.processFile({
|
|
108
|
+
* id: "video-1",
|
|
109
|
+
* name: "presentation.mp4",
|
|
110
|
+
* mimetype: "video/mp4",
|
|
111
|
+
* size: 15_000_000,
|
|
112
|
+
* buffer: videoBuffer,
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* if (result.success) {
|
|
116
|
+
* // result.data.textContent - text description for LLM
|
|
117
|
+
* // result.data.keyframes - array of JPEG buffers
|
|
118
|
+
* // result.data.subtitleText - extracted subtitles (if any)
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare class VideoProcessor extends BaseFileProcessor<ProcessedVideo> {
|
|
123
|
+
constructor();
|
|
124
|
+
/**
|
|
125
|
+
* Build processed result stub.
|
|
126
|
+
* This is a synchronous placeholder - actual processing happens in the
|
|
127
|
+
* overridden processFile method since ffmpeg operations are asynchronous
|
|
128
|
+
* and require temp file I/O.
|
|
129
|
+
*
|
|
130
|
+
* @param buffer - Downloaded file content
|
|
131
|
+
* @param fileInfo - Original file information
|
|
132
|
+
* @returns Empty ProcessedVideo structure
|
|
133
|
+
*/
|
|
134
|
+
protected buildProcessedResult(buffer: Buffer, fileInfo: FileInfo): ProcessedVideo;
|
|
135
|
+
/**
|
|
136
|
+
* Override processFile for async video processing with ffmpeg.
|
|
137
|
+
*
|
|
138
|
+
* Processing pipeline:
|
|
139
|
+
* 1. Validate file type and size
|
|
140
|
+
* 2. Get buffer (from fileInfo.buffer or download from URL)
|
|
141
|
+
* 3. Write buffer to temp file (ffmpeg requires file paths)
|
|
142
|
+
* 4. Extract metadata using ffprobe
|
|
143
|
+
* 5. Extract keyframes at calculated intervals, resize with sharp
|
|
144
|
+
* 6. Extract subtitle tracks if embedded
|
|
145
|
+
* 7. Build textContent summary for LLM
|
|
146
|
+
* 8. Clean up temp files
|
|
147
|
+
*
|
|
148
|
+
* @param fileInfo - File information with URL or buffer
|
|
149
|
+
* @param options - Optional processing options
|
|
150
|
+
* @returns Processing result with extracted video data or error
|
|
151
|
+
*/
|
|
152
|
+
processFile(fileInfo: FileInfo, options?: ProcessOptions): Promise<FileProcessingResult<ProcessedVideo>>;
|
|
153
|
+
/**
|
|
154
|
+
* Probe a video file to extract metadata using ffprobe.
|
|
155
|
+
*
|
|
156
|
+
* @param filePath - Path to the video file
|
|
157
|
+
* @returns Success result with probe data or error message
|
|
158
|
+
*/
|
|
159
|
+
private probeVideo;
|
|
160
|
+
/**
|
|
161
|
+
* Build a structured metadata object from ffprobe data.
|
|
162
|
+
*
|
|
163
|
+
* @param probeData - Raw ffprobe output
|
|
164
|
+
* @param fileSize - Original file size in bytes
|
|
165
|
+
* @returns Structured video metadata
|
|
166
|
+
*/
|
|
167
|
+
private buildMetadata;
|
|
168
|
+
/**
|
|
169
|
+
* Extract keyframes from a video at calculated intervals.
|
|
170
|
+
*
|
|
171
|
+
* The interval between frames is determined by the video duration:
|
|
172
|
+
* - <= 10s: every 1s (very short clips — dense coverage)
|
|
173
|
+
* - <= 30s: every 2s (short bug clips)
|
|
174
|
+
* - <= 120s: every 5s (standard screen recordings)
|
|
175
|
+
* - <= 600s: every 15s (longer demos)
|
|
176
|
+
* - <= 1800s: every 60s (meeting recordings)
|
|
177
|
+
* - > 1800s: every 180s (full meetings)
|
|
178
|
+
*
|
|
179
|
+
* Results are capped at MAX_FRAMES (100) and each frame is resized
|
|
180
|
+
* to fit within 768x768px while maintaining aspect ratio.
|
|
181
|
+
* The interval is adaptive: if the tier interval would exceed MAX_FRAMES,
|
|
182
|
+
* the interval widens to duration/MAX_FRAMES for full-video coverage.
|
|
183
|
+
*
|
|
184
|
+
* @param videoPath - Path to the video file
|
|
185
|
+
* @param tempDir - Temp directory for frame output
|
|
186
|
+
* @param durationSec - Video duration in seconds
|
|
187
|
+
* @returns Array of JPEG frame buffers
|
|
188
|
+
*/
|
|
189
|
+
private extractKeyframes;
|
|
190
|
+
/**
|
|
191
|
+
* Run ffmpeg to extract frames at specified timestamps.
|
|
192
|
+
*
|
|
193
|
+
* Uses the `-vf select` filter to pick frames at exact timestamps,
|
|
194
|
+
* which is more efficient than seeking for each frame individually.
|
|
195
|
+
*
|
|
196
|
+
* @param videoPath - Path to the video file
|
|
197
|
+
* @param outputDir - Directory to write frame files
|
|
198
|
+
* @param timestamps - Array of timestamps in seconds
|
|
199
|
+
*/
|
|
200
|
+
private runFfmpegFrameExtraction;
|
|
201
|
+
/**
|
|
202
|
+
* Determine the frame extraction interval based on video duration.
|
|
203
|
+
*
|
|
204
|
+
* @param durationSec - Video duration in seconds
|
|
205
|
+
* @returns Interval in seconds between extracted frames
|
|
206
|
+
*/
|
|
207
|
+
private getFrameInterval;
|
|
208
|
+
/**
|
|
209
|
+
* Extract embedded subtitle text from the first subtitle track.
|
|
210
|
+
*
|
|
211
|
+
* Uses ffmpeg to convert the first subtitle stream to SRT format,
|
|
212
|
+
* then strips SRT formatting (timestamps, sequence numbers) to produce
|
|
213
|
+
* plain text.
|
|
214
|
+
*
|
|
215
|
+
* @param videoPath - Path to the video file
|
|
216
|
+
* @param tempDir - Temp directory for subtitle output
|
|
217
|
+
* @returns Extracted subtitle text, or undefined if extraction fails
|
|
218
|
+
*/
|
|
219
|
+
private extractSubtitles;
|
|
220
|
+
/**
|
|
221
|
+
* Parse SRT subtitle content into plain text.
|
|
222
|
+
* Strips sequence numbers, timestamps, and blank lines.
|
|
223
|
+
*
|
|
224
|
+
* @param srt - Raw SRT content
|
|
225
|
+
* @returns Plain text from subtitles
|
|
226
|
+
*/
|
|
227
|
+
private parseSrtToPlainText;
|
|
228
|
+
/**
|
|
229
|
+
* Build a structured text description of the video for LLM consumption.
|
|
230
|
+
*
|
|
231
|
+
* The output includes:
|
|
232
|
+
* - File name and basic info
|
|
233
|
+
* - Technical metadata (resolution, codec, duration, etc.)
|
|
234
|
+
* - Frame extraction summary
|
|
235
|
+
* - Subtitle text (if available)
|
|
236
|
+
*
|
|
237
|
+
* @param metadata - Extracted video metadata
|
|
238
|
+
* @param frameCount - Number of keyframes extracted
|
|
239
|
+
* @param subtitleText - Extracted subtitle text (if any)
|
|
240
|
+
* @param filename - Original filename
|
|
241
|
+
* @returns Formatted text content for the LLM
|
|
242
|
+
*/
|
|
243
|
+
private buildTextContent;
|
|
244
|
+
/**
|
|
245
|
+
* Format a duration in seconds to a human-readable string.
|
|
246
|
+
*
|
|
247
|
+
* @param seconds - Duration in seconds
|
|
248
|
+
* @returns Formatted string (e.g., "1h 23m 45s")
|
|
249
|
+
*/
|
|
250
|
+
private formatDuration;
|
|
251
|
+
/**
|
|
252
|
+
* Get a file extension from FileInfo, falling back to ".mp4".
|
|
253
|
+
*
|
|
254
|
+
* @param fileInfo - File information
|
|
255
|
+
* @returns File extension with leading dot
|
|
256
|
+
*/
|
|
257
|
+
private getExtensionFromFileInfo;
|
|
258
|
+
/**
|
|
259
|
+
* Write a buffer to a file using streaming to handle large files efficiently.
|
|
260
|
+
*
|
|
261
|
+
* @param buffer - Buffer to write
|
|
262
|
+
* @param filePath - Destination file path
|
|
263
|
+
*/
|
|
264
|
+
private writeBufferToFile;
|
|
265
|
+
/**
|
|
266
|
+
* Extract frames from a specific time range in a video.
|
|
267
|
+
*
|
|
268
|
+
* This is the on-demand extraction method called by the `extract_file_content`
|
|
269
|
+
* tool. Unlike initial keyframe extraction (which covers the full video),
|
|
270
|
+
* this targets a specific time window with configurable frame count.
|
|
271
|
+
*
|
|
272
|
+
* @param buffer - Video file buffer
|
|
273
|
+
* @param filename - Original filename (for extension detection)
|
|
274
|
+
* @param startSec - Start time in seconds
|
|
275
|
+
* @param endSec - End time in seconds
|
|
276
|
+
* @param frameCount - Number of frames to extract in the range (default: 5)
|
|
277
|
+
* @returns Array of JPEG frame buffers
|
|
278
|
+
*/
|
|
279
|
+
extractFrameRange(buffer: Buffer, filename: string, startSec: number, endSec: number, frameCount?: number): Promise<Buffer[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Guess file extension from filename, with fallback to .mp4.
|
|
282
|
+
*/
|
|
283
|
+
private guessExtensionFromName;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Singleton Video processor instance.
|
|
287
|
+
* Use this for standard video processing operations.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* import { videoProcessor } from "./VideoProcessor.js";
|
|
292
|
+
*
|
|
293
|
+
* const result = await videoProcessor.processFile(fileInfo);
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare const videoProcessor: VideoProcessor;
|
|
297
|
+
/**
|
|
298
|
+
* Check if a file is a video file.
|
|
299
|
+
* Matches by MIME type or file extension.
|
|
300
|
+
*
|
|
301
|
+
* @param mimetype - MIME type of the file
|
|
302
|
+
* @param filename - Filename (for extension-based detection)
|
|
303
|
+
* @returns true if the file is a supported video file
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* if (isVideoFile("video/mp4", "recording.mp4")) {
|
|
308
|
+
* const result = await processVideo(fileInfo);
|
|
309
|
+
* }
|
|
310
|
+
*
|
|
311
|
+
* if (isVideoFile("", "clip.mkv")) {
|
|
312
|
+
* // Also matches by extension
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export declare function isVideoFile(mimetype: string, filename: string): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Process a single video file.
|
|
319
|
+
* Convenience function that uses the singleton processor.
|
|
320
|
+
*
|
|
321
|
+
* @param fileInfo - File information (can include URL or buffer)
|
|
322
|
+
* @param options - Optional processing options (auth headers, timeout, retry config)
|
|
323
|
+
* @returns Processing result with extracted video data or error
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* import { processVideo } from "./VideoProcessor.js";
|
|
328
|
+
*
|
|
329
|
+
* const result = await processVideo({
|
|
330
|
+
* id: "vid-123",
|
|
331
|
+
* name: "demo.mp4",
|
|
332
|
+
* mimetype: "video/mp4",
|
|
333
|
+
* size: 15_000_000,
|
|
334
|
+
* buffer: videoBuffer,
|
|
335
|
+
* });
|
|
336
|
+
*
|
|
337
|
+
* if (result.success) {
|
|
338
|
+
* console.log(`Duration: ${result.data.metadata.durationFormatted}`);
|
|
339
|
+
* console.log(`Extracted ${result.data.frameCount} keyframes`);
|
|
340
|
+
* console.log(`Text content:\n${result.data.textContent}`);
|
|
341
|
+
*
|
|
342
|
+
* if (result.data.subtitleText) {
|
|
343
|
+
* console.log(`Subtitles:\n${result.data.subtitleText}`);
|
|
344
|
+
* }
|
|
345
|
+
* } else {
|
|
346
|
+
* console.error(`Processing failed: ${result.error?.userMessage}`);
|
|
347
|
+
* }
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
export declare function processVideo(fileInfo: FileInfo, options?: ProcessOptions): Promise<FileProcessingResult<ProcessedVideo>>;
|