@juspay/neurolink 9.54.5 → 9.54.7
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 +4 -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 -1
- package/dist/auth/tokenStore.js +45 -4
- package/dist/autoresearch/tools.d.ts +1 -16
- package/dist/browser/neurolink.min.js +353 -353
- 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 +2 -2
- package/dist/client/httpClient.js +13 -0
- package/dist/client/sseClient.d.ts +2 -2
- 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 +7 -2
- 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/core/toolEvents.d.ts +0 -1
- 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 -1
- 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 +2 -2
- package/dist/lib/client/httpClient.js +13 -0
- package/dist/lib/client/sseClient.d.ts +2 -2
- 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 +7 -2
- 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/core/toolEvents.d.ts +0 -1
- 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/hippocampusInitializer.d.ts +1 -2
- package/dist/lib/memory/hippocampusInitializer.js +1 -1
- package/dist/lib/memory/memoryRetrievalTools.js +182 -141
- package/dist/lib/models/anthropicModels.d.ts +0 -1
- package/dist/lib/models/anthropicModels.js +1 -0
- package/dist/lib/neurolink.js +237 -41
- package/dist/lib/observability/exporterRegistry.d.ts +3 -22
- package/dist/lib/observability/exporters/sentryExporter.js +1 -0
- package/dist/lib/observability/metricsAggregator.d.ts +1 -31
- package/dist/lib/observability/retryPolicy.d.ts +0 -1
- package/dist/lib/observability/sampling/samplers.d.ts +0 -1
- package/dist/lib/observability/spanProcessor.d.ts +0 -1
- 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 +82 -0
- package/dist/lib/providers/googleNativeGemini3.d.ts +1 -2
- package/dist/lib/providers/googleVertex.js +52 -0
- 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/proxyHealth.d.ts +0 -1
- 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/routingPolicy.d.ts +1 -2
- 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/sanitizers/filename.d.ts +0 -1
- 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/hippocampusInitializer.d.ts +1 -2
- package/dist/memory/hippocampusInitializer.js +1 -1
- package/dist/memory/memoryRetrievalTools.js +182 -141
- package/dist/models/anthropicModels.d.ts +0 -1
- package/dist/models/anthropicModels.js +1 -0
- package/dist/neurolink.js +237 -41
- package/dist/observability/exporterRegistry.d.ts +3 -22
- package/dist/observability/exporters/sentryExporter.js +1 -0
- package/dist/observability/metricsAggregator.d.ts +1 -31
- package/dist/observability/retryPolicy.d.ts +0 -1
- package/dist/observability/sampling/samplers.d.ts +0 -1
- package/dist/observability/spanProcessor.d.ts +0 -1
- 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 +82 -0
- package/dist/providers/googleNativeGemini3.d.ts +1 -2
- package/dist/providers/googleVertex.js +52 -0
- 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/proxyHealth.d.ts +0 -1
- 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/routingPolicy.d.ts +1 -2
- 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/sanitizers/filename.d.ts +0 -1
- 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 -1
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
* Health Routes
|
|
3
3
|
* Endpoints for health checks and system status
|
|
4
4
|
*/
|
|
5
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
6
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
7
|
+
/**
|
|
8
|
+
* Wrap a health-route handler with an OTel span that records the route,
|
|
9
|
+
* request id, and overall health status.
|
|
10
|
+
*/
|
|
11
|
+
function tracedHealthHandler(name, route, fn) {
|
|
12
|
+
return (ctx) => withSpan({
|
|
13
|
+
name,
|
|
14
|
+
tracer: tracers.http,
|
|
15
|
+
attributes: {
|
|
16
|
+
"http.route": route,
|
|
17
|
+
"http.request.id": ctx.requestId ?? "",
|
|
18
|
+
},
|
|
19
|
+
}, () => fn(ctx));
|
|
20
|
+
}
|
|
5
21
|
/**
|
|
6
22
|
* Create health check routes
|
|
7
23
|
*/
|
|
@@ -12,34 +28,41 @@ export function createHealthRoutes(basePath = "/api") {
|
|
|
12
28
|
{
|
|
13
29
|
method: "GET",
|
|
14
30
|
path: `${basePath}/health`,
|
|
15
|
-
handler: async () => {
|
|
31
|
+
handler: tracedHealthHandler("neurolink.http.health.check", `${basePath}/health`, async () => {
|
|
16
32
|
return {
|
|
17
33
|
status: "ok",
|
|
18
34
|
timestamp: new Date().toISOString(),
|
|
19
35
|
uptime: process.uptime() * 1000,
|
|
20
36
|
version: process.env.npm_package_version || "unknown",
|
|
21
37
|
};
|
|
22
|
-
},
|
|
38
|
+
}),
|
|
23
39
|
description: "Basic health check",
|
|
24
40
|
tags: ["health"],
|
|
25
41
|
},
|
|
26
42
|
{
|
|
27
43
|
method: "GET",
|
|
28
44
|
path: `${basePath}/health/live`,
|
|
29
|
-
handler: async () => {
|
|
45
|
+
handler: tracedHealthHandler("neurolink.http.health.live", `${basePath}/health/live`, async () => {
|
|
30
46
|
// Liveness probe - just checks if the server is running
|
|
31
47
|
return {
|
|
32
48
|
status: "alive",
|
|
33
49
|
timestamp: new Date().toISOString(),
|
|
34
50
|
};
|
|
35
|
-
},
|
|
51
|
+
}),
|
|
36
52
|
description: "Kubernetes liveness probe",
|
|
37
53
|
tags: ["health"],
|
|
38
54
|
},
|
|
39
55
|
{
|
|
40
56
|
method: "GET",
|
|
41
57
|
path: `${basePath}/health/ready`,
|
|
42
|
-
handler:
|
|
58
|
+
handler: (ctx) => withSpan({
|
|
59
|
+
name: "neurolink.http.health.ready",
|
|
60
|
+
tracer: tracers.http,
|
|
61
|
+
attributes: {
|
|
62
|
+
"http.route": `${basePath}/health/ready`,
|
|
63
|
+
"http.request.id": ctx.requestId ?? "",
|
|
64
|
+
},
|
|
65
|
+
}, async (span) => {
|
|
43
66
|
// Readiness probe - checks if all dependencies are ready
|
|
44
67
|
const tools = await ctx.toolRegistry.listTools();
|
|
45
68
|
const hasTools = tools.length > 0;
|
|
@@ -56,6 +79,9 @@ export function createHealthRoutes(basePath = "/api") {
|
|
|
56
79
|
}
|
|
57
80
|
}
|
|
58
81
|
const isReady = hasTools || !hasExternalManager || externalServersReady;
|
|
82
|
+
span.setAttribute("health.ready", isReady);
|
|
83
|
+
span.setAttribute("health.tools_count", tools.length);
|
|
84
|
+
span.setAttribute("health.external_servers_ready", externalServersReady);
|
|
59
85
|
return {
|
|
60
86
|
ready: isReady,
|
|
61
87
|
timestamp: new Date().toISOString(),
|
|
@@ -65,16 +91,24 @@ export function createHealthRoutes(basePath = "/api") {
|
|
|
65
91
|
externalServers: externalServersReady,
|
|
66
92
|
},
|
|
67
93
|
};
|
|
68
|
-
},
|
|
94
|
+
}),
|
|
69
95
|
description: "Kubernetes readiness probe",
|
|
70
96
|
tags: ["health"],
|
|
71
97
|
},
|
|
72
98
|
{
|
|
73
99
|
method: "GET",
|
|
74
100
|
path: `${basePath}/health/startup`,
|
|
75
|
-
handler:
|
|
101
|
+
handler: (ctx) => withSpan({
|
|
102
|
+
name: "neurolink.http.health.startup",
|
|
103
|
+
tracer: tracers.http,
|
|
104
|
+
attributes: {
|
|
105
|
+
"http.route": `${basePath}/health/startup`,
|
|
106
|
+
"http.request.id": ctx.requestId ?? "",
|
|
107
|
+
},
|
|
108
|
+
}, async (span) => {
|
|
76
109
|
// Startup probe - checks if the application has started successfully
|
|
77
110
|
const tools = await ctx.toolRegistry.listTools();
|
|
111
|
+
span.setAttribute("health.tools_count", tools.length);
|
|
78
112
|
return {
|
|
79
113
|
started: true,
|
|
80
114
|
timestamp: new Date().toISOString(),
|
|
@@ -84,14 +118,21 @@ export function createHealthRoutes(basePath = "/api") {
|
|
|
84
118
|
externalServerManager: !!ctx.externalServerManager,
|
|
85
119
|
},
|
|
86
120
|
};
|
|
87
|
-
},
|
|
121
|
+
}),
|
|
88
122
|
description: "Kubernetes startup probe",
|
|
89
123
|
tags: ["health"],
|
|
90
124
|
},
|
|
91
125
|
{
|
|
92
126
|
method: "GET",
|
|
93
127
|
path: `${basePath}/health/detailed`,
|
|
94
|
-
handler:
|
|
128
|
+
handler: (ctx) => withSpan({
|
|
129
|
+
name: "neurolink.http.health.detailed",
|
|
130
|
+
tracer: tracers.http,
|
|
131
|
+
attributes: {
|
|
132
|
+
"http.route": `${basePath}/health/detailed`,
|
|
133
|
+
"http.request.id": ctx.requestId ?? "",
|
|
134
|
+
},
|
|
135
|
+
}, async (span) => {
|
|
95
136
|
const tools = await ctx.toolRegistry.listTools();
|
|
96
137
|
// Group tools by source
|
|
97
138
|
const toolsBySource = {};
|
|
@@ -162,23 +203,28 @@ export function createHealthRoutes(basePath = "/api") {
|
|
|
162
203
|
healthyCount: pool.getHealthyCount(),
|
|
163
204
|
strategy: pool.getStrategy(),
|
|
164
205
|
};
|
|
206
|
+
span.setAttribute("health.proxy.accounts", allAccounts.length);
|
|
207
|
+
span.setAttribute("health.proxy.healthy", pool.getHealthyCount());
|
|
165
208
|
}
|
|
209
|
+
span.setAttribute("health.tools_count", tools.length);
|
|
210
|
+
span.setAttribute("health.external_servers_count", externalServers.length);
|
|
211
|
+
span.setAttribute("health.memory.heap_mb", Math.round(process.memoryUsage().heapUsed / 1024 / 1024));
|
|
166
212
|
return healthResponse;
|
|
167
|
-
},
|
|
213
|
+
}),
|
|
168
214
|
description: "Detailed health information",
|
|
169
215
|
tags: ["health"],
|
|
170
216
|
},
|
|
171
217
|
{
|
|
172
218
|
method: "GET",
|
|
173
219
|
path: `${basePath}/version`,
|
|
174
|
-
handler: async () => {
|
|
220
|
+
handler: tracedHealthHandler("neurolink.http.version", `${basePath}/version`, async () => {
|
|
175
221
|
return {
|
|
176
222
|
name: "@juspay/neurolink",
|
|
177
223
|
version: process.env.npm_package_version || "unknown",
|
|
178
224
|
node: process.version,
|
|
179
225
|
timestamp: new Date().toISOString(),
|
|
180
226
|
};
|
|
181
|
-
},
|
|
227
|
+
}),
|
|
182
228
|
description: "Get version information",
|
|
183
229
|
tags: ["health", "version"],
|
|
184
230
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Route Builders
|
|
3
3
|
* Pre-built route definitions for common NeuroLink endpoints
|
|
4
4
|
*/
|
|
5
|
-
import type { RouteDefinition, RouteGroup } from "../../types/index.js";
|
|
5
|
+
import type { CreateRoutesOptions, RouteDefinition, RouteGroup } from "../../types/index.js";
|
|
6
6
|
export { createAgentRoutes } from "./agentRoutes.js";
|
|
7
7
|
export { createClaudeProxyRoutes } from "./claudeProxyRoutes.js";
|
|
8
8
|
export { createHealthRoutes } from "./healthRoutes.js";
|
|
@@ -10,31 +10,6 @@ export { createMCPRoutes } from "./mcpRoutes.js";
|
|
|
10
10
|
export { createMemoryRoutes } from "./memoryRoutes.js";
|
|
11
11
|
export { createOpenApiRoutes } from "./openApiRoutes.js";
|
|
12
12
|
export { createToolRoutes } from "./toolRoutes.js";
|
|
13
|
-
/**
|
|
14
|
-
* Options for creating routes
|
|
15
|
-
*/
|
|
16
|
-
type CreateRoutesOptions = {
|
|
17
|
-
/** Enable OpenAPI/Swagger documentation endpoints (default: false) */
|
|
18
|
-
enableSwagger?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Callback to get registered routes for OpenAPI spec generation.
|
|
21
|
-
* This callback is invoked at request time when the OpenAPI spec is accessed,
|
|
22
|
-
* allowing it to reflect all routes registered with the adapter.
|
|
23
|
-
*
|
|
24
|
-
* When using `registerAllRoutes`, this is automatically bound to `adapter.listRoutes()`
|
|
25
|
-
* if the adapter supports it and no custom callback is provided.
|
|
26
|
-
*
|
|
27
|
-
* If not provided (and adapter doesn't have listRoutes), the spec will use
|
|
28
|
-
* default endpoint definitions.
|
|
29
|
-
*/
|
|
30
|
-
getRoutes?: () => RouteDefinition[];
|
|
31
|
-
/**
|
|
32
|
-
* Enable or disable the Claude-compatible proxy routes.
|
|
33
|
-
* When true, registers /v1/messages, /v1/models, and /v1/messages/count_tokens
|
|
34
|
-
* endpoints that accept Anthropic API format requests.
|
|
35
|
-
*/
|
|
36
|
-
claudeProxy?: boolean;
|
|
37
|
-
};
|
|
38
13
|
/**
|
|
39
14
|
* Create all standard routes
|
|
40
15
|
* Convenience method that combines all route groups
|
|
@@ -2,8 +2,41 @@
|
|
|
2
2
|
* MCP Routes
|
|
3
3
|
* Endpoints for MCP server management
|
|
4
4
|
*/
|
|
5
|
+
import { SpanStatusCode } from "@opentelemetry/api";
|
|
5
6
|
import { z } from "zod";
|
|
7
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
8
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
6
9
|
import { createErrorResponse, ServerNameParamSchema, ToolArgumentsSchema, validateParams, validateRequest, } from "../utils/validation.js";
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a route handler with an OTel span for HTTP observability.
|
|
12
|
+
*/
|
|
13
|
+
function tracedMcpHandler(name, route, fn) {
|
|
14
|
+
return (ctx) => withSpan({
|
|
15
|
+
name,
|
|
16
|
+
tracer: tracers.http,
|
|
17
|
+
attributes: {
|
|
18
|
+
"http.route": route,
|
|
19
|
+
"http.request.id": ctx.requestId,
|
|
20
|
+
},
|
|
21
|
+
}, async (otelSpan) => {
|
|
22
|
+
const result = await fn(ctx);
|
|
23
|
+
// Detect returned error responses (not thrown) and mark span as failed.
|
|
24
|
+
// Only flag when the error value is truthy to avoid false positives
|
|
25
|
+
// from handlers that always include an `error` key (e.g. handleGetServer).
|
|
26
|
+
if (result && typeof result === "object") {
|
|
27
|
+
const errVal = result.error;
|
|
28
|
+
if (errVal !== undefined && errVal !== null) {
|
|
29
|
+
const errMsg = typeof errVal === "string"
|
|
30
|
+
? errVal
|
|
31
|
+
: typeof errVal?.message === "string"
|
|
32
|
+
? errVal.message
|
|
33
|
+
: "MCP handler error";
|
|
34
|
+
otelSpan.setStatus({ code: SpanStatusCode.ERROR, message: errMsg });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
7
40
|
/**
|
|
8
41
|
* MCP tool execution params schema
|
|
9
42
|
*/
|
|
@@ -291,49 +324,49 @@ export function createMCPRoutes(basePath = "/api") {
|
|
|
291
324
|
{
|
|
292
325
|
method: "GET",
|
|
293
326
|
path: `${basePath}/mcp/servers`,
|
|
294
|
-
handler: handleListServers,
|
|
327
|
+
handler: tracedMcpHandler("neurolink.http.mcp.listServers", `${basePath}/mcp/servers`, handleListServers),
|
|
295
328
|
description: "List all MCP servers",
|
|
296
329
|
tags: ["mcp"],
|
|
297
330
|
},
|
|
298
331
|
{
|
|
299
332
|
method: "GET",
|
|
300
333
|
path: `${basePath}/mcp/servers/:name`,
|
|
301
|
-
handler: handleGetServer,
|
|
334
|
+
handler: tracedMcpHandler("neurolink.http.mcp.getServer", `${basePath}/mcp/servers/:name`, handleGetServer),
|
|
302
335
|
description: "Get MCP server status",
|
|
303
336
|
tags: ["mcp"],
|
|
304
337
|
},
|
|
305
338
|
{
|
|
306
339
|
method: "POST",
|
|
307
340
|
path: `${basePath}/mcp/servers/:name/reconnect`,
|
|
308
|
-
handler: handleReconnectServer,
|
|
341
|
+
handler: tracedMcpHandler("neurolink.http.mcp.reconnectServer", `${basePath}/mcp/servers/:name/reconnect`, handleReconnectServer),
|
|
309
342
|
description: "Reconnect to an MCP server",
|
|
310
343
|
tags: ["mcp"],
|
|
311
344
|
},
|
|
312
345
|
{
|
|
313
346
|
method: "DELETE",
|
|
314
347
|
path: `${basePath}/mcp/servers/:name`,
|
|
315
|
-
handler: handleRemoveServer,
|
|
348
|
+
handler: tracedMcpHandler("neurolink.http.mcp.removeServer", `${basePath}/mcp/servers/:name`, handleRemoveServer),
|
|
316
349
|
description: "Remove an MCP server",
|
|
317
350
|
tags: ["mcp"],
|
|
318
351
|
},
|
|
319
352
|
{
|
|
320
353
|
method: "GET",
|
|
321
354
|
path: `${basePath}/mcp/servers/:name/tools`,
|
|
322
|
-
handler: handleListServerTools,
|
|
355
|
+
handler: tracedMcpHandler("neurolink.http.mcp.listServerTools", `${basePath}/mcp/servers/:name/tools`, handleListServerTools),
|
|
323
356
|
description: "List tools from a specific MCP server",
|
|
324
357
|
tags: ["mcp", "tools"],
|
|
325
358
|
},
|
|
326
359
|
{
|
|
327
360
|
method: "POST",
|
|
328
361
|
path: `${basePath}/mcp/servers/:name/tools/:toolName/execute`,
|
|
329
|
-
handler: handleExecuteTool,
|
|
362
|
+
handler: tracedMcpHandler("neurolink.http.mcp.executeTool", `${basePath}/mcp/servers/:name/tools/:toolName/execute`, handleExecuteTool),
|
|
330
363
|
description: "Execute a tool from a specific MCP server",
|
|
331
364
|
tags: ["mcp", "tools"],
|
|
332
365
|
},
|
|
333
366
|
{
|
|
334
367
|
method: "GET",
|
|
335
368
|
path: `${basePath}/mcp/health`,
|
|
336
|
-
handler: handleMCPHealth,
|
|
369
|
+
handler: tracedMcpHandler("neurolink.http.mcp.health", `${basePath}/mcp/health`, handleMCPHealth),
|
|
337
370
|
description: "Health check for all MCP servers",
|
|
338
371
|
tags: ["mcp", "health"],
|
|
339
372
|
},
|
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
* Memory Routes
|
|
3
3
|
* Endpoints for conversation memory management
|
|
4
4
|
*/
|
|
5
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
6
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
5
7
|
import { createErrorResponse, IdParamSchema, SessionIdParamSchema, validateParams, } from "../utils/validation.js";
|
|
8
|
+
/**
|
|
9
|
+
* Wrap a route handler with an OTel span for HTTP observability.
|
|
10
|
+
*/
|
|
11
|
+
function tracedMemoryHandler(name, route, fn) {
|
|
12
|
+
return (ctx) => withSpan({
|
|
13
|
+
name,
|
|
14
|
+
tracer: tracers.http,
|
|
15
|
+
attributes: {
|
|
16
|
+
"http.route": route,
|
|
17
|
+
"http.request.id": ctx.requestId,
|
|
18
|
+
},
|
|
19
|
+
}, () => fn(ctx));
|
|
20
|
+
}
|
|
6
21
|
/**
|
|
7
22
|
* Handler: Get messages for a session
|
|
8
23
|
*/
|
|
@@ -297,7 +312,7 @@ export function createMemoryRoutes(basePath = "/api") {
|
|
|
297
312
|
{
|
|
298
313
|
method: "GET",
|
|
299
314
|
path: `${basePath}/memory/sessions/:id/messages`,
|
|
300
|
-
handler: handleGetSessionMessages,
|
|
315
|
+
handler: tracedMemoryHandler("neurolink.http.memory.getSessionMessages", `${basePath}/memory/sessions/:id/messages`, handleGetSessionMessages),
|
|
301
316
|
description: "Get messages for a session",
|
|
302
317
|
tags: ["memory"],
|
|
303
318
|
},
|
|
@@ -305,7 +320,7 @@ export function createMemoryRoutes(basePath = "/api") {
|
|
|
305
320
|
{
|
|
306
321
|
method: "GET",
|
|
307
322
|
path: `${basePath}/memory/sessions/:id`,
|
|
308
|
-
handler: handleGetSession,
|
|
323
|
+
handler: tracedMemoryHandler("neurolink.http.memory.getSession", `${basePath}/memory/sessions/:id`, handleGetSession),
|
|
309
324
|
description: "Get session by ID",
|
|
310
325
|
tags: ["memory"],
|
|
311
326
|
},
|
|
@@ -313,35 +328,35 @@ export function createMemoryRoutes(basePath = "/api") {
|
|
|
313
328
|
{
|
|
314
329
|
method: "GET",
|
|
315
330
|
path: `${basePath}/memory/sessions`,
|
|
316
|
-
handler: handleListSessions,
|
|
331
|
+
handler: tracedMemoryHandler("neurolink.http.memory.listSessions", `${basePath}/memory/sessions`, handleListSessions),
|
|
317
332
|
description: "List all conversation sessions",
|
|
318
333
|
tags: ["memory"],
|
|
319
334
|
},
|
|
320
335
|
{
|
|
321
336
|
method: "GET",
|
|
322
337
|
path: `${basePath}/memory/stats`,
|
|
323
|
-
handler: handleGetStats,
|
|
338
|
+
handler: tracedMemoryHandler("neurolink.http.memory.stats", `${basePath}/memory/stats`, handleGetStats),
|
|
324
339
|
description: "Get memory statistics",
|
|
325
340
|
tags: ["memory"],
|
|
326
341
|
},
|
|
327
342
|
{
|
|
328
343
|
method: "DELETE",
|
|
329
344
|
path: `${basePath}/memory/sessions/:sessionId`,
|
|
330
|
-
handler: handleClearSession,
|
|
345
|
+
handler: tracedMemoryHandler("neurolink.http.memory.clearSession", `${basePath}/memory/sessions/:sessionId`, handleClearSession),
|
|
331
346
|
description: "Clear a conversation session",
|
|
332
347
|
tags: ["memory"],
|
|
333
348
|
},
|
|
334
349
|
{
|
|
335
350
|
method: "DELETE",
|
|
336
351
|
path: `${basePath}/memory/sessions`,
|
|
337
|
-
handler: handleClearAllSessions,
|
|
352
|
+
handler: tracedMemoryHandler("neurolink.http.memory.clearAllSessions", `${basePath}/memory/sessions`, handleClearAllSessions),
|
|
338
353
|
description: "Clear all conversation sessions",
|
|
339
354
|
tags: ["memory"],
|
|
340
355
|
},
|
|
341
356
|
{
|
|
342
357
|
method: "GET",
|
|
343
358
|
path: `${basePath}/memory/health`,
|
|
344
|
-
handler: handleMemoryHealth,
|
|
359
|
+
handler: tracedMemoryHandler("neurolink.http.memory.health", `${basePath}/memory/health`, handleMemoryHealth),
|
|
345
360
|
description: "Check memory system health",
|
|
346
361
|
tags: ["memory", "health"],
|
|
347
362
|
},
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { logger } from "../../utils/logger.js";
|
|
6
6
|
import { OpenAPIGenerator } from "../openapi/generator.js";
|
|
7
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
8
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
7
9
|
/**
|
|
8
10
|
* Create OpenAPI documentation routes
|
|
9
11
|
*
|
|
@@ -44,7 +46,14 @@ export function createOpenApiRoutes(basePath = "/api", getRoutes) {
|
|
|
44
46
|
{
|
|
45
47
|
method: "GET",
|
|
46
48
|
path: `${basePath}/openapi.json`,
|
|
47
|
-
handler: async () => {
|
|
49
|
+
handler: async () => withSpan({
|
|
50
|
+
name: "neurolink.http.openapi.json",
|
|
51
|
+
tracer: tracers.http,
|
|
52
|
+
attributes: {
|
|
53
|
+
"http.route": `${basePath}/openapi.json`,
|
|
54
|
+
"openapi.format": "json",
|
|
55
|
+
},
|
|
56
|
+
}, async (span) => {
|
|
48
57
|
const routes = getRoutes?.() ?? [];
|
|
49
58
|
if (!getRoutes) {
|
|
50
59
|
logger.warn("[OpenAPI] No getRoutes callback provided. OpenAPI spec will use default endpoint definitions. " +
|
|
@@ -53,19 +62,27 @@ export function createOpenApiRoutes(basePath = "/api", getRoutes) {
|
|
|
53
62
|
else if (routes.length === 0) {
|
|
54
63
|
logger.debug("[OpenAPI] getRoutes returned empty array. No custom routes will be documented.");
|
|
55
64
|
}
|
|
65
|
+
span.setAttribute("openapi.route_count", routes.length);
|
|
56
66
|
const generator = new OpenAPIGenerator({
|
|
57
67
|
basePath,
|
|
58
68
|
routes,
|
|
59
69
|
});
|
|
60
70
|
return generator.generate();
|
|
61
|
-
},
|
|
71
|
+
}),
|
|
62
72
|
description: "Get OpenAPI specification as JSON",
|
|
63
73
|
tags: ["openapi", "documentation"],
|
|
64
74
|
},
|
|
65
75
|
{
|
|
66
76
|
method: "GET",
|
|
67
77
|
path: `${basePath}/openapi.yaml`,
|
|
68
|
-
handler: async () => {
|
|
78
|
+
handler: async () => withSpan({
|
|
79
|
+
name: "neurolink.http.openapi.yaml",
|
|
80
|
+
tracer: tracers.http,
|
|
81
|
+
attributes: {
|
|
82
|
+
"http.route": `${basePath}/openapi.yaml`,
|
|
83
|
+
"openapi.format": "yaml",
|
|
84
|
+
},
|
|
85
|
+
}, async (span) => {
|
|
69
86
|
const routes = getRoutes?.() ?? [];
|
|
70
87
|
if (!getRoutes) {
|
|
71
88
|
logger.warn("[OpenAPI] No getRoutes callback provided. OpenAPI spec will use default endpoint definitions. " +
|
|
@@ -74,6 +91,7 @@ export function createOpenApiRoutes(basePath = "/api", getRoutes) {
|
|
|
74
91
|
else if (routes.length === 0) {
|
|
75
92
|
logger.debug("[OpenAPI] getRoutes returned empty array. No custom routes will be documented.");
|
|
76
93
|
}
|
|
94
|
+
span.setAttribute("openapi.route_count", routes.length);
|
|
77
95
|
const generator = new OpenAPIGenerator({
|
|
78
96
|
basePath,
|
|
79
97
|
routes,
|
|
@@ -83,14 +101,20 @@ export function createOpenApiRoutes(basePath = "/api", getRoutes) {
|
|
|
83
101
|
contentType: "text/yaml",
|
|
84
102
|
body: generator.toYAML(),
|
|
85
103
|
};
|
|
86
|
-
},
|
|
104
|
+
}),
|
|
87
105
|
description: "Get OpenAPI specification as YAML",
|
|
88
106
|
tags: ["openapi", "documentation"],
|
|
89
107
|
},
|
|
90
108
|
{
|
|
91
109
|
method: "GET",
|
|
92
110
|
path: `${basePath}/docs`,
|
|
93
|
-
handler: async () => {
|
|
111
|
+
handler: async () => withSpan({
|
|
112
|
+
name: "neurolink.http.openapi.docs",
|
|
113
|
+
tracer: tracers.http,
|
|
114
|
+
attributes: {
|
|
115
|
+
"http.route": `${basePath}/docs`,
|
|
116
|
+
},
|
|
117
|
+
}, async () => {
|
|
94
118
|
const html = `<!DOCTYPE html>
|
|
95
119
|
<html>
|
|
96
120
|
<head>
|
|
@@ -117,7 +141,7 @@ export function createOpenApiRoutes(basePath = "/api", getRoutes) {
|
|
|
117
141
|
contentType: "text/html",
|
|
118
142
|
body: html,
|
|
119
143
|
};
|
|
120
|
-
},
|
|
144
|
+
}),
|
|
121
145
|
description: "Swagger UI documentation page",
|
|
122
146
|
tags: ["openapi", "documentation"],
|
|
123
147
|
},
|