@juspay/neurolink 9.54.6 → 9.54.8
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 +8 -0
- package/dist/action/actionInputs.d.ts +1 -1
- package/dist/adapters/video/directorPipeline.js +6 -0
- package/dist/adapters/video/vertexVideoHandler.js +6 -0
- package/dist/agent/directTools.d.ts +3 -23
- package/dist/auth/AuthProviderFactory.d.ts +1 -3
- package/dist/auth/anthropicOAuth.d.ts +4 -7
- package/dist/auth/anthropicOAuth.js +23 -0
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/middleware/AuthMiddleware.d.ts +5 -60
- package/dist/auth/middleware/AuthMiddleware.js +3 -0
- package/dist/auth/middleware/rateLimitByUser.d.ts +4 -93
- package/dist/auth/middleware/rateLimitByUser.js +4 -0
- package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/auth/providers/CognitoProvider.js +3 -0
- package/dist/auth/providers/KeycloakProvider.js +3 -0
- package/dist/auth/providers/auth0.d.ts +1 -1
- package/dist/auth/sessionManager.d.ts +2 -0
- package/dist/auth/sessionManager.js +53 -11
- package/dist/auth/tokenStore.d.ts +2 -0
- package/dist/auth/tokenStore.js +45 -4
- package/dist/autoresearch/tools.d.ts +1 -16
- package/dist/browser/neurolink.min.js +358 -358
- package/dist/cli/commands/config.d.ts +3 -123
- package/dist/cli/commands/config.js +4 -2
- package/dist/cli/commands/evaluate.d.ts +1 -19
- package/dist/cli/commands/proxy.d.ts +1 -1
- package/dist/cli/commands/proxy.js +3 -0
- package/dist/cli/commands/rag.js +3 -0
- package/dist/cli/commands/setup-anthropic.d.ts +2 -6
- package/dist/cli/commands/setup-anthropic.js +1 -1
- package/dist/cli/commands/setup-azure.d.ts +2 -6
- package/dist/cli/commands/setup-azure.js +1 -1
- package/dist/cli/commands/setup-bedrock.d.ts +2 -6
- package/dist/cli/commands/setup-bedrock.js +1 -1
- package/dist/cli/commands/setup-gcp.d.ts +2 -6
- package/dist/cli/commands/setup-google-ai.d.ts +2 -6
- package/dist/cli/commands/setup-google-ai.js +1 -1
- package/dist/cli/commands/setup-huggingface.d.ts +1 -5
- package/dist/cli/commands/setup-mistral.d.ts +1 -5
- package/dist/cli/commands/setup-openai.d.ts +2 -6
- package/dist/cli/commands/setup-openai.js +1 -1
- package/dist/cli/commands/setup.d.ts +1 -8
- package/dist/cli/commands/task.js +1 -0
- package/dist/cli/commands/voiceServer.d.ts +1 -4
- package/dist/cli/loop/session.js +31 -10
- package/dist/cli/utils/interactiveSetup.d.ts +2 -15
- package/dist/cli/utils/videoFileUtils.d.ts +1 -15
- package/dist/client/aiSdkAdapter.d.ts +1 -1
- package/dist/client/aiSdkAdapter.js +1 -0
- package/dist/client/httpClient.d.ts +1 -0
- package/dist/client/httpClient.js +13 -0
- package/dist/client/sseClient.d.ts +1 -0
- package/dist/client/sseClient.js +29 -0
- package/dist/client/streamingClient.d.ts +2 -0
- package/dist/client/streamingClient.js +19 -0
- package/dist/client/wsClient.d.ts +6 -0
- package/dist/client/wsClient.js +90 -10
- package/dist/context/budgetChecker.js +3 -1
- package/dist/context/contextCompactor.js +163 -143
- package/dist/context/fileSummarizationService.d.ts +1 -9
- package/dist/context/summarizationEngine.js +29 -16
- package/dist/core/baseProvider.js +124 -153
- package/dist/core/infrastructure/baseRegistry.d.ts +1 -7
- package/dist/core/modules/GenerationHandler.d.ts +3 -2
- package/dist/core/modules/GenerationHandler.js +9 -1
- package/dist/core/modules/StreamHandler.js +9 -0
- package/dist/core/modules/ToolsManager.js +18 -2
- package/dist/evaluation/BatchEvaluator.d.ts +1 -97
- package/dist/evaluation/EvaluationAggregator.d.ts +1 -118
- package/dist/evaluation/EvaluatorFactory.d.ts +1 -13
- package/dist/evaluation/EvaluatorRegistry.d.ts +1 -50
- package/dist/evaluation/errors/EvaluationError.d.ts +2 -27
- package/dist/evaluation/hooks/langfuseAdapter.d.ts +1 -39
- package/dist/evaluation/hooks/observabilityHooks.d.ts +3 -55
- package/dist/evaluation/hooks/observabilityHooks.js +3 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +7 -7
- package/dist/evaluation/ragasEvaluator.js +54 -37
- package/dist/evaluation/reporting/metricsCollector.d.ts +1 -60
- package/dist/evaluation/reporting/reportGenerator.d.ts +1 -17
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
- package/dist/evaluation/scorers/rule/formatScorer.d.ts +1 -42
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
- package/dist/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
- package/dist/factories/providerFactory.d.ts +1 -16
- package/dist/factories/providerFactory.js +2 -0
- package/dist/image-gen/ImageGenService.d.ts +3 -0
- package/dist/image-gen/ImageGenService.js +3 -0
- package/dist/lib/action/actionInputs.d.ts +1 -1
- package/dist/lib/adapters/video/directorPipeline.js +6 -0
- package/dist/lib/adapters/video/vertexVideoHandler.js +6 -0
- package/dist/lib/agent/directTools.d.ts +3 -23
- package/dist/lib/auth/AuthProviderFactory.d.ts +1 -3
- package/dist/lib/auth/anthropicOAuth.d.ts +4 -7
- package/dist/lib/auth/anthropicOAuth.js +23 -0
- package/dist/lib/auth/errors.d.ts +1 -1
- package/dist/lib/auth/index.d.ts +11 -0
- package/dist/lib/auth/index.js +14 -0
- package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -60
- package/dist/lib/auth/middleware/AuthMiddleware.js +3 -0
- package/dist/lib/auth/middleware/rateLimitByUser.d.ts +4 -93
- package/dist/lib/auth/middleware/rateLimitByUser.js +4 -0
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/lib/auth/providers/CognitoProvider.js +3 -0
- package/dist/lib/auth/providers/KeycloakProvider.js +3 -0
- package/dist/lib/auth/providers/auth0.d.ts +1 -1
- package/dist/lib/auth/sessionManager.d.ts +2 -0
- package/dist/lib/auth/sessionManager.js +53 -11
- package/dist/lib/auth/tokenStore.d.ts +2 -0
- package/dist/lib/auth/tokenStore.js +45 -4
- package/dist/lib/autoresearch/tools.d.ts +1 -16
- package/dist/lib/client/aiSdkAdapter.d.ts +1 -1
- package/dist/lib/client/aiSdkAdapter.js +1 -0
- package/dist/lib/client/httpClient.d.ts +1 -0
- package/dist/lib/client/httpClient.js +13 -0
- package/dist/lib/client/sseClient.d.ts +1 -0
- package/dist/lib/client/sseClient.js +29 -0
- package/dist/lib/client/streamingClient.d.ts +2 -0
- package/dist/lib/client/streamingClient.js +19 -0
- package/dist/lib/client/wsClient.d.ts +6 -0
- package/dist/lib/client/wsClient.js +90 -10
- package/dist/lib/context/budgetChecker.js +3 -1
- package/dist/lib/context/contextCompactor.js +163 -143
- package/dist/lib/context/fileSummarizationService.d.ts +1 -9
- package/dist/lib/context/summarizationEngine.js +29 -16
- package/dist/lib/core/baseProvider.js +124 -153
- package/dist/lib/core/infrastructure/baseRegistry.d.ts +1 -7
- package/dist/lib/core/modules/GenerationHandler.d.ts +3 -2
- package/dist/lib/core/modules/GenerationHandler.js +9 -1
- package/dist/lib/core/modules/StreamHandler.js +9 -0
- package/dist/lib/core/modules/ToolsManager.js +18 -2
- package/dist/lib/evaluation/BatchEvaluator.d.ts +1 -97
- package/dist/lib/evaluation/EvaluationAggregator.d.ts +1 -118
- package/dist/lib/evaluation/EvaluatorFactory.d.ts +1 -13
- package/dist/lib/evaluation/EvaluatorRegistry.d.ts +1 -50
- package/dist/lib/evaluation/errors/EvaluationError.d.ts +2 -27
- package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +1 -39
- package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +3 -55
- package/dist/lib/evaluation/hooks/observabilityHooks.js +3 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +7 -7
- package/dist/lib/evaluation/ragasEvaluator.js +54 -37
- package/dist/lib/evaluation/reporting/metricsCollector.d.ts +1 -60
- package/dist/lib/evaluation/reporting/reportGenerator.d.ts +1 -17
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
- package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +1 -42
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
- package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
- package/dist/lib/factories/providerFactory.d.ts +1 -16
- package/dist/lib/factories/providerFactory.js +2 -0
- package/dist/lib/image-gen/ImageGenService.d.ts +3 -0
- package/dist/lib/image-gen/ImageGenService.js +3 -0
- package/dist/lib/mcp/batching/requestBatcher.js +99 -73
- package/dist/lib/mcp/httpRateLimiter.js +3 -1
- package/dist/lib/mcp/httpRetryHandler.js +3 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -1
- package/dist/lib/mcp/multiServerManager.d.ts +1 -14
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +70 -57
- package/dist/lib/mcp/toolRegistry.js +11 -1
- package/dist/lib/memory/memoryRetrievalTools.js +182 -141
- package/dist/lib/neurolink.js +236 -40
- package/dist/lib/observability/exporterRegistry.d.ts +3 -21
- package/dist/lib/observability/exporters/sentryExporter.js +1 -0
- package/dist/lib/observability/metricsAggregator.d.ts +1 -31
- package/dist/lib/observability/tokenTracker.d.ts +7 -16
- package/dist/lib/observability/tokenTracker.js +6 -4
- package/dist/lib/observability/utils/spanSerializer.d.ts +5 -1
- package/dist/lib/observability/utils/spanSerializer.js +24 -4
- package/dist/lib/processors/base/BaseFileProcessor.js +66 -53
- package/dist/lib/processors/document/ExcelProcessor.d.ts +1 -1
- package/dist/lib/processors/errors/errorHelpers.d.ts +1 -31
- package/dist/lib/processors/errors/errorSerializer.d.ts +1 -45
- package/dist/lib/processors/registry/ProcessorRegistry.js +17 -6
- package/dist/lib/providers/amazonBedrock.js +189 -15
- package/dist/lib/providers/amazonSagemaker.js +25 -11
- package/dist/lib/providers/anthropic.js +13 -0
- package/dist/lib/providers/azureOpenai.js +2 -0
- package/dist/lib/providers/googleAiStudio.js +96 -26
- package/dist/lib/providers/googleVertex.js +66 -27
- package/dist/lib/providers/huggingFace.js +2 -0
- package/dist/lib/providers/litellm.js +2 -0
- package/dist/lib/providers/mistral.js +2 -0
- package/dist/lib/providers/ollama.js +84 -5
- package/dist/lib/providers/openAI.d.ts +2 -0
- package/dist/lib/providers/openAI.js +17 -6
- package/dist/lib/providers/openRouter.js +2 -0
- package/dist/lib/providers/openaiCompatible.js +2 -0
- package/dist/lib/providers/sagemaker/detection.d.ts +1 -33
- package/dist/lib/providers/sagemaker/diagnostics.d.ts +1 -25
- package/dist/lib/providers/sagemaker/language-model.d.ts +1 -1
- package/dist/lib/proxy/proxyConfig.js +4 -0
- package/dist/lib/proxy/proxyEnv.d.ts +1 -17
- package/dist/lib/proxy/proxyTracer.d.ts +1 -36
- package/dist/lib/proxy/proxyTracer.js +9 -0
- package/dist/lib/proxy/quietDetector.d.ts +1 -7
- package/dist/lib/proxy/rawStreamCapture.d.ts +1 -10
- package/dist/lib/proxy/requestLogger.d.ts +1 -21
- package/dist/lib/proxy/sseInterceptor.d.ts +1 -66
- package/dist/lib/proxy/sseInterceptor.js +6 -0
- package/dist/lib/proxy/updateChecker.d.ts +1 -6
- package/dist/lib/proxy/updateState.d.ts +1 -12
- package/dist/lib/rag/chunkers/BaseChunker.js +36 -22
- package/dist/lib/rag/chunking/jsonChunker.d.ts +1 -1
- package/dist/lib/rag/errors/RAGError.d.ts +1 -2
- package/dist/lib/rag/ragIntegration.js +45 -32
- package/dist/lib/rag/reranker/reranker.js +151 -122
- package/dist/lib/rag/retrieval/vectorQueryTool.js +79 -65
- package/dist/lib/sdk/toolRegistration.d.ts +10 -44
- package/dist/lib/sdk/toolRegistration.js +1 -1
- package/dist/lib/server/middleware/abortSignal.d.ts +1 -11
- package/dist/lib/server/middleware/auth.d.ts +1 -21
- package/dist/lib/server/middleware/auth.js +12 -0
- package/dist/lib/server/middleware/common.js +48 -32
- package/dist/lib/server/middleware/deprecation.d.ts +1 -20
- package/dist/lib/server/middleware/rateLimit.d.ts +1 -75
- package/dist/lib/server/middleware/validation.d.ts +3 -81
- package/dist/lib/server/middleware/validation.js +3 -0
- package/dist/lib/server/openapi/generator.d.ts +1 -47
- package/dist/lib/server/routes/agentRoutes.js +112 -57
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +1 -6
- package/dist/lib/server/routes/claudeProxyRoutes.js +127 -13
- package/dist/lib/server/routes/healthRoutes.js +58 -12
- package/dist/lib/server/routes/index.d.ts +1 -26
- package/dist/lib/server/routes/mcpRoutes.js +40 -7
- package/dist/lib/server/routes/memoryRoutes.js +22 -7
- package/dist/lib/server/routes/openApiRoutes.js +30 -6
- package/dist/lib/server/routes/toolRoutes.js +140 -68
- package/dist/lib/server/streaming/dataStream.d.ts +1 -35
- package/dist/lib/server/streaming/dataStream.js +15 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +114 -14
- package/dist/lib/session/globalSessionState.d.ts +1 -10
- package/dist/lib/tasks/tools/taskTools.d.ts +2 -2
- package/dist/lib/telemetry/traceContext.d.ts +9 -0
- package/dist/lib/telemetry/traceContext.js +19 -0
- package/dist/lib/telemetry/tracers.d.ts +2 -0
- package/dist/lib/telemetry/tracers.js +2 -0
- package/dist/lib/types/action.d.ts +2 -0
- package/dist/lib/types/artifact.d.ts +7 -0
- package/dist/lib/types/auth.d.ts +125 -18
- package/dist/lib/types/autoresearch.d.ts +12 -0
- package/dist/lib/types/cli.d.ts +415 -0
- package/dist/lib/types/client.d.ts +34 -0
- package/dist/lib/types/common.d.ts +12 -41
- package/dist/lib/types/context.d.ts +5 -0
- package/dist/lib/types/evaluation.d.ts +332 -1
- package/dist/lib/types/file.d.ts +4 -0
- package/dist/lib/types/mcp.d.ts +102 -2
- package/dist/lib/types/middleware.d.ts +116 -0
- package/dist/lib/types/multimodal.d.ts +65 -0
- package/dist/lib/types/observability.d.ts +81 -0
- package/dist/lib/types/processor.d.ts +47 -0
- package/dist/lib/types/providers.d.ts +120 -16
- package/dist/lib/types/proxy.d.ts +321 -1
- package/dist/lib/types/rag.d.ts +22 -0
- package/dist/lib/types/scorer.d.ts +141 -0
- package/dist/lib/types/server.d.ts +99 -0
- package/dist/lib/types/span.d.ts +2 -1
- package/dist/lib/types/span.js +1 -0
- package/dist/lib/types/tools.d.ts +44 -0
- package/dist/lib/types/tts.d.ts +6 -0
- package/dist/lib/types/utilities.d.ts +22 -0
- package/dist/lib/types/workflow.d.ts +18 -0
- package/dist/lib/utils/async/retry.d.ts +2 -8
- package/dist/lib/utils/async/retry.js +9 -9
- package/dist/lib/utils/imageCompressor.d.ts +1 -21
- package/dist/lib/utils/imageCompressor.js +5 -1
- package/dist/lib/utils/messageBuilder.d.ts +1 -1
- package/dist/lib/utils/redis.d.ts +1 -4
- package/dist/lib/utils/toolEndEmitter.d.ts +25 -0
- package/dist/lib/utils/toolEndEmitter.js +65 -0
- package/dist/lib/workflow/config.d.ts +7 -32
- package/dist/lib/workflow/core/ensembleExecutor.js +28 -0
- package/dist/lib/workflow/core/judgeScorer.js +23 -0
- package/dist/lib/workflow/core/responseConditioner.js +17 -0
- package/dist/lib/workflow/core/workflowRunner.d.ts +1 -19
- package/dist/lib/workflow/core/workflowRunner.js +202 -147
- package/dist/mcp/batching/requestBatcher.js +99 -73
- package/dist/mcp/httpRateLimiter.js +3 -1
- package/dist/mcp/httpRetryHandler.js +3 -1
- package/dist/mcp/mcpClientFactory.js +3 -1
- package/dist/mcp/multiServerManager.d.ts +1 -14
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/mcp/toolDiscoveryService.js +70 -57
- package/dist/mcp/toolRegistry.js +11 -1
- package/dist/memory/memoryRetrievalTools.js +182 -141
- package/dist/neurolink.js +236 -40
- package/dist/observability/exporterRegistry.d.ts +3 -21
- package/dist/observability/exporters/sentryExporter.js +1 -0
- package/dist/observability/metricsAggregator.d.ts +1 -31
- package/dist/observability/tokenTracker.d.ts +7 -16
- package/dist/observability/tokenTracker.js +6 -4
- package/dist/observability/utils/spanSerializer.d.ts +5 -1
- package/dist/observability/utils/spanSerializer.js +24 -4
- package/dist/processors/base/BaseFileProcessor.js +66 -53
- package/dist/processors/document/ExcelProcessor.d.ts +1 -1
- package/dist/processors/errors/errorHelpers.d.ts +1 -31
- package/dist/processors/errors/errorSerializer.d.ts +1 -45
- package/dist/processors/registry/ProcessorRegistry.js +17 -6
- package/dist/providers/amazonBedrock.js +189 -15
- package/dist/providers/amazonSagemaker.js +25 -11
- package/dist/providers/anthropic.js +13 -0
- package/dist/providers/azureOpenai.js +2 -0
- package/dist/providers/googleAiStudio.js +96 -26
- package/dist/providers/googleVertex.js +66 -27
- package/dist/providers/huggingFace.js +2 -0
- package/dist/providers/litellm.js +2 -0
- package/dist/providers/mistral.js +2 -0
- package/dist/providers/ollama.js +84 -5
- package/dist/providers/openAI.d.ts +2 -0
- package/dist/providers/openAI.js +17 -6
- package/dist/providers/openRouter.js +2 -0
- package/dist/providers/openaiCompatible.js +2 -0
- package/dist/providers/sagemaker/detection.d.ts +1 -33
- package/dist/providers/sagemaker/diagnostics.d.ts +1 -25
- package/dist/providers/sagemaker/language-model.d.ts +1 -1
- package/dist/proxy/proxyConfig.js +4 -0
- package/dist/proxy/proxyEnv.d.ts +1 -17
- package/dist/proxy/proxyTracer.d.ts +1 -36
- package/dist/proxy/proxyTracer.js +9 -0
- package/dist/proxy/quietDetector.d.ts +1 -7
- package/dist/proxy/rawStreamCapture.d.ts +1 -10
- package/dist/proxy/requestLogger.d.ts +1 -21
- package/dist/proxy/sseInterceptor.d.ts +1 -66
- package/dist/proxy/sseInterceptor.js +6 -0
- package/dist/proxy/updateChecker.d.ts +1 -6
- package/dist/proxy/updateState.d.ts +1 -12
- package/dist/rag/chunkers/BaseChunker.js +36 -22
- package/dist/rag/chunking/jsonChunker.d.ts +1 -1
- package/dist/rag/errors/RAGError.d.ts +1 -2
- package/dist/rag/ragIntegration.js +45 -32
- package/dist/rag/reranker/reranker.js +151 -122
- package/dist/rag/retrieval/vectorQueryTool.js +79 -65
- package/dist/sdk/toolRegistration.d.ts +10 -44
- package/dist/sdk/toolRegistration.js +1 -1
- package/dist/server/middleware/abortSignal.d.ts +1 -11
- package/dist/server/middleware/auth.d.ts +1 -21
- package/dist/server/middleware/auth.js +12 -0
- package/dist/server/middleware/common.js +48 -32
- package/dist/server/middleware/deprecation.d.ts +1 -20
- package/dist/server/middleware/rateLimit.d.ts +1 -75
- package/dist/server/middleware/validation.d.ts +3 -81
- package/dist/server/middleware/validation.js +3 -0
- package/dist/server/openapi/generator.d.ts +1 -47
- package/dist/server/routes/agentRoutes.js +112 -57
- package/dist/server/routes/claudeProxyRoutes.d.ts +1 -6
- package/dist/server/routes/claudeProxyRoutes.js +127 -13
- package/dist/server/routes/healthRoutes.js +58 -12
- package/dist/server/routes/index.d.ts +1 -26
- package/dist/server/routes/mcpRoutes.js +40 -7
- package/dist/server/routes/memoryRoutes.js +22 -7
- package/dist/server/routes/openApiRoutes.js +30 -6
- package/dist/server/routes/toolRoutes.js +140 -68
- package/dist/server/streaming/dataStream.d.ts +1 -35
- package/dist/server/streaming/dataStream.js +15 -0
- package/dist/services/server/ai/observability/instrumentation.js +114 -14
- package/dist/session/globalSessionState.d.ts +1 -10
- package/dist/tasks/tools/taskTools.d.ts +2 -2
- package/dist/telemetry/traceContext.d.ts +9 -0
- package/dist/telemetry/traceContext.js +18 -0
- package/dist/telemetry/tracers.d.ts +2 -0
- package/dist/telemetry/tracers.js +2 -0
- package/dist/types/action.d.ts +2 -0
- package/dist/types/artifact.d.ts +7 -0
- package/dist/types/auth.d.ts +125 -18
- package/dist/types/autoresearch.d.ts +12 -0
- package/dist/types/cli.d.ts +415 -0
- package/dist/types/client.d.ts +34 -0
- package/dist/types/common.d.ts +12 -41
- package/dist/types/context.d.ts +5 -0
- package/dist/types/evaluation.d.ts +332 -1
- package/dist/types/file.d.ts +4 -0
- package/dist/types/mcp.d.ts +102 -2
- package/dist/types/middleware.d.ts +116 -0
- package/dist/types/multimodal.d.ts +65 -0
- package/dist/types/observability.d.ts +81 -0
- package/dist/types/processor.d.ts +47 -0
- package/dist/types/providers.d.ts +120 -16
- package/dist/types/proxy.d.ts +321 -1
- package/dist/types/rag.d.ts +22 -0
- package/dist/types/scorer.d.ts +141 -0
- package/dist/types/server.d.ts +99 -0
- package/dist/types/span.d.ts +2 -1
- package/dist/types/span.js +1 -0
- package/dist/types/tools.d.ts +44 -0
- package/dist/types/tts.d.ts +6 -0
- package/dist/types/utilities.d.ts +22 -0
- package/dist/types/workflow.d.ts +18 -0
- package/dist/utils/async/retry.d.ts +2 -8
- package/dist/utils/async/retry.js +9 -9
- package/dist/utils/imageCompressor.d.ts +1 -21
- package/dist/utils/imageCompressor.js +5 -1
- package/dist/utils/messageBuilder.d.ts +1 -1
- package/dist/utils/redis.d.ts +1 -4
- package/dist/utils/toolEndEmitter.d.ts +25 -0
- package/dist/utils/toolEndEmitter.js +64 -0
- package/dist/workflow/config.d.ts +4 -29
- package/dist/workflow/core/ensembleExecutor.js +28 -0
- package/dist/workflow/core/judgeScorer.js +23 -0
- package/dist/workflow/core/responseConditioner.js +17 -0
- package/dist/workflow/core/workflowRunner.d.ts +1 -19
- package/dist/workflow/core/workflowRunner.js +202 -147
- package/package.json +2 -8
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { HttpError, ClientNetworkError, ClientTimeoutError } from "./errors.js";
|
|
10
10
|
import { logger } from "../utils/logger.js";
|
|
11
|
+
import { tracers } from "../telemetry/tracers.js";
|
|
12
|
+
import { withClientSpan } from "../telemetry/withSpan.js";
|
|
11
13
|
// =============================================================================
|
|
12
14
|
// Shared Utilities
|
|
13
15
|
// =============================================================================
|
|
@@ -184,6 +186,17 @@ export class NeuroLinkClient {
|
|
|
184
186
|
* Execute HTTP request with middleware and retry logic
|
|
185
187
|
*/
|
|
186
188
|
async request(method, path, body, options) {
|
|
189
|
+
return withClientSpan({
|
|
190
|
+
name: "neurolink.client.http.request",
|
|
191
|
+
tracer: tracers.http,
|
|
192
|
+
attributes: {
|
|
193
|
+
"http.method": method,
|
|
194
|
+
"http.route": path,
|
|
195
|
+
"http.url": `${this.config.baseUrl}${path}`,
|
|
196
|
+
},
|
|
197
|
+
}, async () => this._doRequest(method, path, body, options));
|
|
198
|
+
}
|
|
199
|
+
async _doRequest(method, path, body, options) {
|
|
187
200
|
const url = `${this.config.baseUrl}${path}`;
|
|
188
201
|
const requestId = this.generateRequestId();
|
|
189
202
|
const { retry } = this.config;
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @neurolink/client/sseClient
|
|
9
9
|
*/
|
|
10
|
+
import { SpanStatusCode } from "@opentelemetry/api";
|
|
10
11
|
import { logger } from "../utils/logger.js";
|
|
12
|
+
import { withClientSpan } from "../telemetry/withSpan.js";
|
|
13
|
+
import { tracers } from "../telemetry/tracers.js";
|
|
11
14
|
// =============================================================================
|
|
12
15
|
// SSE Client Implementation
|
|
13
16
|
// =============================================================================
|
|
@@ -69,6 +72,32 @@ export class NeuroLinkSSE {
|
|
|
69
72
|
* Stream from an endpoint using SSE
|
|
70
73
|
*/
|
|
71
74
|
async stream(path, options = {}, callbacks = {}) {
|
|
75
|
+
return withClientSpan({
|
|
76
|
+
name: "neurolink.client.sse.stream",
|
|
77
|
+
tracer: tracers.http,
|
|
78
|
+
attributes: {
|
|
79
|
+
"http.method": options.body ? "POST" : "GET",
|
|
80
|
+
"http.route": path,
|
|
81
|
+
"http.url": this.buildUrl(path),
|
|
82
|
+
"sse.auto_reconnect": this.config.autoReconnect,
|
|
83
|
+
"sse.native_event_source": this.config.useNativeEventSource,
|
|
84
|
+
},
|
|
85
|
+
}, async (span) => {
|
|
86
|
+
// Wrap onError callback so the span is marked failed on stream errors
|
|
87
|
+
const wrappedCallbacks = {
|
|
88
|
+
...callbacks,
|
|
89
|
+
onError: (error) => {
|
|
90
|
+
span.setStatus({
|
|
91
|
+
code: SpanStatusCode.ERROR,
|
|
92
|
+
message: error?.message ?? "SSE stream error",
|
|
93
|
+
});
|
|
94
|
+
callbacks.onError?.(error);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
return this._streamInternal(path, options, wrappedCallbacks);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async _streamInternal(path, options = {}, callbacks = {}) {
|
|
72
101
|
const url = this.buildUrl(path);
|
|
73
102
|
const isGetRequest = !options.body;
|
|
74
103
|
// Use native EventSource for GET requests when configured and available
|
|
@@ -49,6 +49,7 @@ export declare class SSEClient {
|
|
|
49
49
|
body?: unknown;
|
|
50
50
|
headers?: Record<string, string>;
|
|
51
51
|
}): Promise<void>;
|
|
52
|
+
private _connectSSE;
|
|
52
53
|
/**
|
|
53
54
|
* Disconnect from SSE endpoint
|
|
54
55
|
*/
|
|
@@ -131,6 +132,7 @@ export declare class WebSocketStreamingClient {
|
|
|
131
132
|
* Connect to WebSocket server
|
|
132
133
|
*/
|
|
133
134
|
connect(): Promise<void>;
|
|
135
|
+
private _connectWS;
|
|
134
136
|
/**
|
|
135
137
|
* Disconnect from WebSocket server
|
|
136
138
|
*/
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { logger } from "../utils/logger.js";
|
|
10
10
|
import { combineSignals, sleep } from "./httpClient.js";
|
|
11
|
+
import { withClientSpan } from "../telemetry/withSpan.js";
|
|
12
|
+
import { tracers } from "../telemetry/tracers.js";
|
|
11
13
|
// =============================================================================
|
|
12
14
|
// Types
|
|
13
15
|
// =============================================================================
|
|
@@ -61,6 +63,16 @@ export class SSEClient {
|
|
|
61
63
|
* Connect to SSE endpoint
|
|
62
64
|
*/
|
|
63
65
|
async connect(requestOptions = {}) {
|
|
66
|
+
return withClientSpan({
|
|
67
|
+
name: "neurolink.client.streaming.sse.connect",
|
|
68
|
+
tracer: tracers.http,
|
|
69
|
+
attributes: {
|
|
70
|
+
"http.url": this.url,
|
|
71
|
+
"http.method": requestOptions.body ? "POST" : "GET",
|
|
72
|
+
},
|
|
73
|
+
}, async () => this._connectSSE(requestOptions));
|
|
74
|
+
}
|
|
75
|
+
async _connectSSE(requestOptions = {}) {
|
|
64
76
|
if (this.state === "connected" || this.state === "connecting") {
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
@@ -393,6 +405,13 @@ export class WebSocketStreamingClient {
|
|
|
393
405
|
* Connect to WebSocket server
|
|
394
406
|
*/
|
|
395
407
|
async connect() {
|
|
408
|
+
return withClientSpan({
|
|
409
|
+
name: "neurolink.client.streaming.ws.connect",
|
|
410
|
+
tracer: tracers.http,
|
|
411
|
+
attributes: { "http.url": this.options.url },
|
|
412
|
+
}, async () => this._connectWS());
|
|
413
|
+
}
|
|
414
|
+
async _connectWS() {
|
|
396
415
|
if (typeof WebSocket === "undefined") {
|
|
397
416
|
throw new Error("WebSocket is not available. Please use a polyfill for non-browser environments.");
|
|
398
417
|
}
|
|
@@ -43,6 +43,12 @@ export declare class NeuroLinkWebSocket {
|
|
|
43
43
|
private eventHandlers;
|
|
44
44
|
private subscriptions;
|
|
45
45
|
private pendingAuth;
|
|
46
|
+
/**
|
|
47
|
+
* Active OTel span for the current WebSocket connection lifecycle.
|
|
48
|
+
* Created at connect() and ended on close/error so we capture connection
|
|
49
|
+
* lifetime, reconnect counts, and error attribution in Langfuse.
|
|
50
|
+
*/
|
|
51
|
+
private connectionSpan;
|
|
46
52
|
/**
|
|
47
53
|
* Local flag to suppress reconnection during an explicit disconnect().
|
|
48
54
|
* Unlike mutating config.autoReconnect, this preserves the user's
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @neurolink/client/wsClient
|
|
9
9
|
*/
|
|
10
|
+
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
11
|
+
import { tracers } from "../telemetry/tracers.js";
|
|
10
12
|
// =============================================================================
|
|
11
13
|
// WebSocket Client
|
|
12
14
|
// =============================================================================
|
|
@@ -45,6 +47,12 @@ export class NeuroLinkWebSocket {
|
|
|
45
47
|
eventHandlers = {};
|
|
46
48
|
subscriptions = new Map();
|
|
47
49
|
pendingAuth = false;
|
|
50
|
+
/**
|
|
51
|
+
* Active OTel span for the current WebSocket connection lifecycle.
|
|
52
|
+
* Created at connect() and ended on close/error so we capture connection
|
|
53
|
+
* lifetime, reconnect counts, and error attribution in Langfuse.
|
|
54
|
+
*/
|
|
55
|
+
connectionSpan = null;
|
|
48
56
|
/**
|
|
49
57
|
* Local flag to suppress reconnection during an explicit disconnect().
|
|
50
58
|
* Unlike mutating config.autoReconnect, this preserves the user's
|
|
@@ -89,6 +97,28 @@ export class NeuroLinkWebSocket {
|
|
|
89
97
|
this.disconnectRequested = false;
|
|
90
98
|
this.eventHandlers = handlers ?? {};
|
|
91
99
|
this.setState("connecting");
|
|
100
|
+
// End any orphaned span from a prior connect() attempt (e.g., re-entrant call
|
|
101
|
+
// while a previous attempt was still connecting).
|
|
102
|
+
if (this.connectionSpan) {
|
|
103
|
+
this.connectionSpan.setAttribute("ws.superseded", true);
|
|
104
|
+
this.connectionSpan.setStatus({
|
|
105
|
+
code: SpanStatusCode.ERROR,
|
|
106
|
+
message: "Connection attempt superseded by new connect() call",
|
|
107
|
+
});
|
|
108
|
+
this.connectionSpan.end();
|
|
109
|
+
this.connectionSpan = null;
|
|
110
|
+
}
|
|
111
|
+
// Start an OTel span that tracks the lifetime of this connection attempt.
|
|
112
|
+
// Ended in onclose/onerror/disconnect so metrics capture connection
|
|
113
|
+
// duration and error attribution.
|
|
114
|
+
this.connectionSpan = tracers.http.startSpan("neurolink.client.ws.connect", {
|
|
115
|
+
kind: SpanKind.CLIENT,
|
|
116
|
+
attributes: {
|
|
117
|
+
"http.url": this.config.baseUrl,
|
|
118
|
+
"ws.auto_reconnect": this.config.autoReconnect,
|
|
119
|
+
"ws.reconnect_attempt": this.reconnectAttempts,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
92
122
|
// Build WebSocket URL (credentials are sent via headers, not query params,
|
|
93
123
|
// to avoid leaking secrets in server logs, browser history, and HTTP referers)
|
|
94
124
|
const url = new URL(this.config.baseUrl);
|
|
@@ -107,15 +137,25 @@ export class NeuroLinkWebSocket {
|
|
|
107
137
|
// credentials are sent as the first message after the connection opens.
|
|
108
138
|
const isNode = typeof globalThis.process !== "undefined" &&
|
|
109
139
|
typeof globalThis.process.versions?.node === "string";
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
try {
|
|
141
|
+
if (isNode && Object.keys(authHeaders).length > 0) {
|
|
142
|
+
this.ws = new WebSocket(url.toString(), { headers: authHeaders });
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.ws = new WebSocket(url.toString());
|
|
146
|
+
}
|
|
116
147
|
}
|
|
117
|
-
|
|
118
|
-
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (this.connectionSpan) {
|
|
150
|
+
this.connectionSpan.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
151
|
+
this.connectionSpan.setStatus({
|
|
152
|
+
code: SpanStatusCode.ERROR,
|
|
153
|
+
message: error instanceof Error ? error.message : String(error),
|
|
154
|
+
});
|
|
155
|
+
this.connectionSpan.end();
|
|
156
|
+
this.connectionSpan = null;
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
119
159
|
}
|
|
120
160
|
this.pendingAuth = !isNode && (!!this.config.apiKey || !!this.config.token);
|
|
121
161
|
this.setupEventListeners();
|
|
@@ -134,6 +174,15 @@ export class NeuroLinkWebSocket {
|
|
|
134
174
|
this.ws = null;
|
|
135
175
|
}
|
|
136
176
|
this.setState("disconnected");
|
|
177
|
+
// Let onclose finalize the span — it fires from ws.close(1000,...) and
|
|
178
|
+
// has the close code context. We only end here if ws is already null
|
|
179
|
+
// (e.g. connect was never called) to avoid leaking.
|
|
180
|
+
if (this.connectionSpan && !this.ws) {
|
|
181
|
+
this.connectionSpan.setAttribute("ws.close_reason", "client_disconnect");
|
|
182
|
+
this.connectionSpan.setStatus({ code: SpanStatusCode.OK });
|
|
183
|
+
this.connectionSpan.end();
|
|
184
|
+
this.connectionSpan = null;
|
|
185
|
+
}
|
|
137
186
|
}
|
|
138
187
|
/**
|
|
139
188
|
* Send a message through WebSocket
|
|
@@ -144,7 +193,7 @@ export class NeuroLinkWebSocket {
|
|
|
144
193
|
}
|
|
145
194
|
else {
|
|
146
195
|
// Queue message for when connected
|
|
147
|
-
if (this.messageQueue.length < this.config.queueSize) {
|
|
196
|
+
if (this.messageQueue.length < (this.config.queueSize ?? 100)) {
|
|
148
197
|
this.messageQueue.push(message);
|
|
149
198
|
}
|
|
150
199
|
}
|
|
@@ -199,6 +248,9 @@ export class NeuroLinkWebSocket {
|
|
|
199
248
|
this.ws.onopen = () => {
|
|
200
249
|
this.setState("connected");
|
|
201
250
|
this.reconnectAttempts = 0;
|
|
251
|
+
if (this.connectionSpan) {
|
|
252
|
+
this.connectionSpan.setAttribute("ws.connected", true);
|
|
253
|
+
}
|
|
202
254
|
// In browser environments, send credentials as the first message
|
|
203
255
|
// since the browser WebSocket API does not support custom headers.
|
|
204
256
|
if (this.pendingAuth && this.ws) {
|
|
@@ -223,6 +275,24 @@ export class NeuroLinkWebSocket {
|
|
|
223
275
|
this.setState("disconnected");
|
|
224
276
|
this.stopHeartbeat();
|
|
225
277
|
this.eventHandlers.onClose?.(event.code, event.reason);
|
|
278
|
+
if (this.connectionSpan) {
|
|
279
|
+
this.connectionSpan.setAttribute("ws.close_code", event.code);
|
|
280
|
+
if (event.reason) {
|
|
281
|
+
this.connectionSpan.setAttribute("ws.close_reason", event.reason);
|
|
282
|
+
}
|
|
283
|
+
// 1000 = normal closure; other codes are abnormal.
|
|
284
|
+
if (event.code === 1000) {
|
|
285
|
+
this.connectionSpan.setStatus({ code: SpanStatusCode.OK });
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
this.connectionSpan.setStatus({
|
|
289
|
+
code: SpanStatusCode.ERROR,
|
|
290
|
+
message: `WebSocket closed with code ${event.code}${event.reason ? `: ${event.reason}` : ""}`,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
this.connectionSpan.end();
|
|
294
|
+
this.connectionSpan = null;
|
|
295
|
+
}
|
|
226
296
|
// Only attempt reconnection when auto-reconnect is enabled AND this
|
|
227
297
|
// was not an intentional disconnect (code 1000 or explicit call).
|
|
228
298
|
if (this.config.autoReconnect &&
|
|
@@ -235,6 +305,16 @@ export class NeuroLinkWebSocket {
|
|
|
235
305
|
this.setState("error");
|
|
236
306
|
const error = new Error("WebSocket connection error");
|
|
237
307
|
this.eventHandlers.onError?.(error);
|
|
308
|
+
if (this.connectionSpan) {
|
|
309
|
+
this.connectionSpan.recordException(error);
|
|
310
|
+
this.connectionSpan.setStatus({
|
|
311
|
+
code: SpanStatusCode.ERROR,
|
|
312
|
+
message: error.message,
|
|
313
|
+
});
|
|
314
|
+
// Do not end here — onclose will fire next and end the span with
|
|
315
|
+
// the precise close code. Keeping the span open until close gives
|
|
316
|
+
// us the full connection lifetime on Langfuse.
|
|
317
|
+
}
|
|
238
318
|
};
|
|
239
319
|
this.ws.onmessage = (event) => {
|
|
240
320
|
try {
|
|
@@ -303,7 +383,7 @@ export class NeuroLinkWebSocket {
|
|
|
303
383
|
if (this.isConnected()) {
|
|
304
384
|
this.send({ type: "ping" });
|
|
305
385
|
}
|
|
306
|
-
}, this.config.heartbeatInterval);
|
|
386
|
+
}, this.config.heartbeatInterval ?? 30000);
|
|
307
387
|
}
|
|
308
388
|
stopHeartbeat() {
|
|
309
389
|
if (this.heartbeatTimer) {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { getAvailableInputTokens } from "../constants/contextWindows.js";
|
|
10
10
|
import { estimateMessagesTokens, estimateTokens, TOKENS_PER_MESSAGE, } from "../utils/tokenEstimation.js";
|
|
11
11
|
import { SpanSerializer, SpanType, SpanStatus, getMetricsAggregator, } from "../observability/index.js";
|
|
12
|
+
import { getActiveTraceContext } from "../telemetry/traceContext.js";
|
|
12
13
|
/** Default compaction threshold (80% of available input) */
|
|
13
14
|
const DEFAULT_COMPACTION_THRESHOLD = 0.8;
|
|
14
15
|
/** Estimated tokens per tool definition */
|
|
@@ -21,9 +22,10 @@ const TOKENS_PER_TOOL_DEFINITION = 200;
|
|
|
21
22
|
* against available input space.
|
|
22
23
|
*/
|
|
23
24
|
export function checkContextBudget(params) {
|
|
25
|
+
const { traceId, parentSpanId } = getActiveTraceContext();
|
|
24
26
|
const span = SpanSerializer.createSpan(SpanType.CONTEXT_COMPACTION, "context.budgetCheck", {
|
|
25
27
|
"context.operation": "budgetCheck",
|
|
26
|
-
});
|
|
28
|
+
}, parentSpanId, traceId);
|
|
27
29
|
const startTime = Date.now();
|
|
28
30
|
try {
|
|
29
31
|
const { provider, model, maxTokens, systemPrompt, conversationMessages, currentPrompt, toolDefinitions, fileAttachments, compactionThreshold = DEFAULT_COMPACTION_THRESHOLD, } = params;
|