@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
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Multi-factor scoring system for reranking retrieval results.
|
|
5
5
|
* Combines semantic relevance (LLM-based), vector similarity, and position.
|
|
6
6
|
*/
|
|
7
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
8
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
7
9
|
import { logger } from "../../utils/logger.js";
|
|
8
10
|
/**
|
|
9
11
|
* Default scoring weights
|
|
@@ -28,60 +30,73 @@ const DEFAULT_WEIGHTS = {
|
|
|
28
30
|
* @returns Reranked results with detailed scores
|
|
29
31
|
*/
|
|
30
32
|
export async function rerank(results, query, model, options) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
result
|
|
69
|
-
score
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
33
|
+
return withSpan({
|
|
34
|
+
name: "neurolink.rag.rerank",
|
|
35
|
+
tracer: tracers.rag,
|
|
36
|
+
attributes: {
|
|
37
|
+
"rag.reranker.input_count": results.length,
|
|
38
|
+
"rag.reranker.top_k": options?.topK ?? 3,
|
|
39
|
+
"rag.reranker.query_length": query.length,
|
|
40
|
+
},
|
|
41
|
+
}, async (span) => {
|
|
42
|
+
const { queryEmbedding: _queryEmbedding, topK = 3, weights = DEFAULT_WEIGHTS, } = options || {};
|
|
43
|
+
if (results.length === 0) {
|
|
44
|
+
span.setAttribute("rag.reranker.output_count", 0);
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
// Validate weights sum to 1.0
|
|
48
|
+
const totalWeight = (weights.semantic || DEFAULT_WEIGHTS.semantic) +
|
|
49
|
+
(weights.vector || DEFAULT_WEIGHTS.vector) +
|
|
50
|
+
(weights.position || DEFAULT_WEIGHTS.position);
|
|
51
|
+
if (Math.abs(totalWeight - 1.0) > 0.01) {
|
|
52
|
+
logger.warn("[Reranker] Weights do not sum to 1.0, normalizing", {
|
|
53
|
+
original: weights,
|
|
54
|
+
total: totalWeight,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const normalizedWeights = {
|
|
58
|
+
semantic: (weights.semantic || DEFAULT_WEIGHTS.semantic) / totalWeight,
|
|
59
|
+
vector: (weights.vector || DEFAULT_WEIGHTS.vector) / totalWeight,
|
|
60
|
+
position: (weights.position || DEFAULT_WEIGHTS.position) / totalWeight,
|
|
61
|
+
};
|
|
62
|
+
const rerankedResults = [];
|
|
63
|
+
// Process results in parallel batches for efficiency
|
|
64
|
+
const batchSize = 5;
|
|
65
|
+
for (let i = 0; i < results.length; i += batchSize) {
|
|
66
|
+
const batch = results.slice(i, i + batchSize);
|
|
67
|
+
const batchPromises = batch.map(async (result, batchIndex) => {
|
|
68
|
+
const globalIndex = i + batchIndex;
|
|
69
|
+
// Calculate vector score (use existing score or 0)
|
|
70
|
+
const vectorScore = result.score ?? 0;
|
|
71
|
+
// Calculate position score (inverse of position)
|
|
72
|
+
const positionScore = 1 - globalIndex / results.length;
|
|
73
|
+
// Calculate semantic score using LLM
|
|
74
|
+
const semanticResult = await calculateSemanticScore(query, result.text || result.metadata?.text || "", model);
|
|
75
|
+
// Combine scores
|
|
76
|
+
const combinedScore = normalizedWeights.semantic * semanticResult.score +
|
|
77
|
+
normalizedWeights.vector * vectorScore +
|
|
78
|
+
normalizedWeights.position * positionScore;
|
|
79
|
+
return {
|
|
80
|
+
result,
|
|
81
|
+
score: combinedScore,
|
|
82
|
+
details: {
|
|
83
|
+
semantic: semanticResult.score,
|
|
84
|
+
vector: vectorScore,
|
|
85
|
+
position: positionScore,
|
|
86
|
+
queryAnalysis: semanticResult.analysis,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
const batchResults = await Promise.all(batchPromises);
|
|
91
|
+
rerankedResults.push(...batchResults);
|
|
92
|
+
}
|
|
93
|
+
// Sort by combined score descending
|
|
94
|
+
rerankedResults.sort((a, b) => b.score - a.score);
|
|
95
|
+
// Return top K results
|
|
96
|
+
const output = rerankedResults.slice(0, topK);
|
|
97
|
+
span.setAttribute("rag.reranker.output_count", output.length);
|
|
98
|
+
return output;
|
|
99
|
+
}); // end withSpan
|
|
85
100
|
}
|
|
86
101
|
/**
|
|
87
102
|
* Calculate semantic relevance score using LLM
|
|
@@ -135,24 +150,35 @@ Score:`;
|
|
|
135
150
|
* @returns Reranked results
|
|
136
151
|
*/
|
|
137
152
|
export async function batchRerank(results, query, model, options) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
153
|
+
return withSpan({
|
|
154
|
+
name: "neurolink.rag.batchRerank",
|
|
155
|
+
tracer: tracers.rag,
|
|
156
|
+
attributes: {
|
|
157
|
+
"rag.reranker.input_count": results.length,
|
|
158
|
+
"rag.reranker.top_k": options?.topK ?? 3,
|
|
159
|
+
"rag.reranker.query_length": query.length,
|
|
160
|
+
"rag.reranker.batch": true,
|
|
161
|
+
},
|
|
162
|
+
}, async (span) => {
|
|
163
|
+
const { topK = 3, weights = DEFAULT_WEIGHTS } = options || {};
|
|
164
|
+
if (results.length === 0) {
|
|
165
|
+
span.setAttribute("rag.reranker.output_count", 0);
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
// Normalize weights
|
|
169
|
+
const totalWeight = (weights.semantic || DEFAULT_WEIGHTS.semantic) +
|
|
170
|
+
(weights.vector || DEFAULT_WEIGHTS.vector) +
|
|
171
|
+
(weights.position || DEFAULT_WEIGHTS.position);
|
|
172
|
+
const normalizedWeights = {
|
|
173
|
+
semantic: (weights.semantic || DEFAULT_WEIGHTS.semantic) / totalWeight,
|
|
174
|
+
vector: (weights.vector || DEFAULT_WEIGHTS.vector) / totalWeight,
|
|
175
|
+
position: (weights.position || DEFAULT_WEIGHTS.position) / totalWeight,
|
|
176
|
+
};
|
|
177
|
+
// Build batch scoring prompt
|
|
178
|
+
const documentsText = results
|
|
179
|
+
.map((r, i) => `[${i + 1}] ${(r.text || r.metadata?.text || "").slice(0, 300)}`)
|
|
180
|
+
.join("\n\n");
|
|
181
|
+
const prompt = `Rate the relevance of each document to the query on a scale of 0 to 1.
|
|
156
182
|
|
|
157
183
|
Query: ${query}
|
|
158
184
|
|
|
@@ -161,58 +187,61 @@ ${documentsText}
|
|
|
161
187
|
|
|
162
188
|
For each document, provide a score between 0 and 1.
|
|
163
189
|
Respond with only the scores, one per line, in order:`;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
try {
|
|
191
|
+
const result = await model.generate({
|
|
192
|
+
prompt,
|
|
193
|
+
maxTokens: 50,
|
|
194
|
+
temperature: 0,
|
|
195
|
+
});
|
|
196
|
+
// Parse scores from response
|
|
197
|
+
const scoreLines = (result?.content || "")
|
|
198
|
+
.trim()
|
|
199
|
+
.split("\n")
|
|
200
|
+
.map((line) => line.trim())
|
|
201
|
+
.filter((line) => line.length > 0);
|
|
202
|
+
const semanticScores = [];
|
|
203
|
+
for (let i = 0; i < results.length; i++) {
|
|
204
|
+
const scoreLine = scoreLines[i];
|
|
205
|
+
if (scoreLine) {
|
|
206
|
+
const score = parseFloat(scoreLine.match(/[\d.]+/)?.[0] || "0.5");
|
|
207
|
+
semanticScores.push(isNaN(score) || score < 0 || score > 1 ? 0.5 : score);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
semanticScores.push(0.5);
|
|
211
|
+
}
|
|
185
212
|
}
|
|
213
|
+
// Calculate combined scores
|
|
214
|
+
const rerankedResults = results.map((result, i) => {
|
|
215
|
+
const vectorScore = result.score ?? 0;
|
|
216
|
+
const positionScore = 1 - i / results.length;
|
|
217
|
+
const semanticScore = semanticScores[i] ?? 0.5;
|
|
218
|
+
const combinedScore = normalizedWeights.semantic * semanticScore +
|
|
219
|
+
normalizedWeights.vector * vectorScore +
|
|
220
|
+
normalizedWeights.position * positionScore;
|
|
221
|
+
return {
|
|
222
|
+
result,
|
|
223
|
+
score: combinedScore,
|
|
224
|
+
details: {
|
|
225
|
+
semantic: semanticScore,
|
|
226
|
+
vector: vectorScore,
|
|
227
|
+
position: positionScore,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
// Sort and return top K
|
|
232
|
+
rerankedResults.sort((a, b) => b.score - a.score);
|
|
233
|
+
const output = rerankedResults.slice(0, topK);
|
|
234
|
+
span.setAttribute("rag.reranker.output_count", output.length);
|
|
235
|
+
return output;
|
|
186
236
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
result,
|
|
197
|
-
score: combinedScore,
|
|
198
|
-
details: {
|
|
199
|
-
semantic: semanticScore,
|
|
200
|
-
vector: vectorScore,
|
|
201
|
-
position: positionScore,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
// Sort and return top K
|
|
206
|
-
rerankedResults.sort((a, b) => b.score - a.score);
|
|
207
|
-
return rerankedResults.slice(0, topK);
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
logger.warn("[Reranker] Batch scoring failed, using individual scoring", {
|
|
211
|
-
error: error instanceof Error ? error.message : String(error),
|
|
212
|
-
});
|
|
213
|
-
// Fall back to individual scoring
|
|
214
|
-
return rerank(results, query, model, options);
|
|
215
|
-
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
logger.warn("[Reranker] Batch scoring failed, using individual scoring", {
|
|
239
|
+
error: error instanceof Error ? error.message : String(error),
|
|
240
|
+
});
|
|
241
|
+
// Fall back to individual scoring
|
|
242
|
+
return rerank(results, query, model, options);
|
|
243
|
+
}
|
|
244
|
+
}); // end withSpan
|
|
216
245
|
}
|
|
217
246
|
/**
|
|
218
247
|
* Simple position-based reranker (no LLM required)
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { ProviderFactory } from "../../factories/providerFactory.js";
|
|
10
|
+
import { withSpan } from "../../telemetry/withSpan.js";
|
|
11
|
+
import { tracers } from "../../telemetry/tracers.js";
|
|
10
12
|
import { logger } from "../../utils/logger.js";
|
|
11
13
|
import { rerank } from "../reranker/reranker.js";
|
|
12
14
|
/**
|
|
@@ -46,75 +48,87 @@ export function createVectorQueryTool(config, vectorStore) {
|
|
|
46
48
|
* @returns Query results with relevant context
|
|
47
49
|
*/
|
|
48
50
|
execute: async (params, context) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const rerankedResults = await rerank(results, params.query, rerankerModel, {
|
|
81
|
-
weights: rerankerConfig.weights,
|
|
82
|
-
topK: rerankerConfig.topK,
|
|
83
|
-
queryEmbedding,
|
|
51
|
+
return withSpan({
|
|
52
|
+
name: "neurolink.rag.vectorQuery",
|
|
53
|
+
tracer: tracers.rag,
|
|
54
|
+
attributes: {
|
|
55
|
+
"rag.vector.index": indexName,
|
|
56
|
+
"rag.vector.top_k": params.topK ?? topK,
|
|
57
|
+
"rag.vector.query_length": params.query.length,
|
|
58
|
+
},
|
|
59
|
+
}, async (span) => {
|
|
60
|
+
const startTime = Date.now();
|
|
61
|
+
try {
|
|
62
|
+
// Resolve vector store if it's a function
|
|
63
|
+
const store = typeof vectorStore === "function"
|
|
64
|
+
? vectorStore(context || {})
|
|
65
|
+
: vectorStore;
|
|
66
|
+
// Generate query embedding
|
|
67
|
+
const embeddingProvider = await ProviderFactory.createProvider(embeddingModel.provider, embeddingModel.modelName);
|
|
68
|
+
// Check if provider has embed method
|
|
69
|
+
if (typeof embeddingProvider
|
|
70
|
+
.embed !== "function") {
|
|
71
|
+
throw new Error(`Provider ${embeddingModel.provider} does not support embeddings`);
|
|
72
|
+
}
|
|
73
|
+
const queryEmbedding = await embeddingProvider.embed(params.query);
|
|
74
|
+
// Query the vector store
|
|
75
|
+
let results = await store.query({
|
|
76
|
+
indexName,
|
|
77
|
+
queryVector: queryEmbedding,
|
|
78
|
+
topK: params.topK || topK,
|
|
79
|
+
filter: params.filter,
|
|
80
|
+
includeVectors,
|
|
81
|
+
...providerOptions,
|
|
84
82
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
let reranked = false;
|
|
84
|
+
// Apply reranking if configured
|
|
85
|
+
if (rerankerConfig && results.length > 0) {
|
|
86
|
+
const rerankerModel = await ProviderFactory.createProvider(typeof rerankerConfig.model === "object"
|
|
87
|
+
? rerankerConfig.model.provider
|
|
88
|
+
: rerankerConfig.model, typeof rerankerConfig.model === "object"
|
|
89
|
+
? rerankerConfig.model.modelName
|
|
90
|
+
: rerankerConfig.model);
|
|
91
|
+
const rerankedResults = await rerank(results, params.query, rerankerModel, {
|
|
92
|
+
weights: rerankerConfig.weights,
|
|
93
|
+
topK: rerankerConfig.topK,
|
|
94
|
+
queryEmbedding,
|
|
95
|
+
});
|
|
96
|
+
results = rerankedResults.map((r) => r.result);
|
|
97
|
+
reranked = true;
|
|
98
|
+
}
|
|
99
|
+
// Format results
|
|
100
|
+
const relevantContext = results
|
|
101
|
+
.map((r, i) => `[${i + 1}] ${r.metadata?.text || r.text || ""}`)
|
|
102
|
+
.join("\n\n");
|
|
103
|
+
const queryTime = Date.now() - startTime;
|
|
104
|
+
logger.info("[VectorQueryTool] Query completed", {
|
|
105
|
+
query: params.query.slice(0, 50),
|
|
106
|
+
resultsCount: results.length,
|
|
105
107
|
queryTime,
|
|
106
108
|
reranked,
|
|
107
109
|
filtered: !!params.filter,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
});
|
|
111
|
+
span.setAttribute("rag.vector.result_count", results.length);
|
|
112
|
+
span.setAttribute("rag.vector.reranked", reranked);
|
|
113
|
+
return {
|
|
114
|
+
relevantContext,
|
|
115
|
+
sources: includeSources ? results : [],
|
|
116
|
+
totalResults: results.length,
|
|
117
|
+
metadata: {
|
|
118
|
+
queryTime,
|
|
119
|
+
reranked,
|
|
120
|
+
filtered: !!params.filter,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
logger.error("[VectorQueryTool] Query failed", {
|
|
126
|
+
query: params.query.slice(0, 50),
|
|
127
|
+
error: error instanceof Error ? error.message : String(error),
|
|
128
|
+
});
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}); // end withSpan
|
|
118
132
|
},
|
|
119
133
|
};
|
|
120
134
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Simple interface for developers to register custom tools
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import type {
|
|
6
|
+
import type { JsonValue, MCPServerCategory, MCPServerInfo, SDKToolContext, SdkSimpleTool, ZodUnknownSchema } from "../types/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Enhanced validation configuration
|
|
9
9
|
*/
|
|
@@ -16,44 +16,10 @@ declare const VALIDATION_CONFIG: {
|
|
|
16
16
|
readonly RECOMMENDED_PATTERNS: readonly ["get_data", "fetch_info", "calculate_value", "send_message", "create_item", "update_record", "delete_file", "validate_input"];
|
|
17
17
|
readonly COMPILED_PATTERN_REGEXES: RegExp[];
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Context provided to tools during execution
|
|
21
|
-
* Type alias for backward compatibility
|
|
22
|
-
*/
|
|
23
|
-
type ToolContext = SDKToolContext;
|
|
24
|
-
/**
|
|
25
|
-
* Simple tool interface for SDK users
|
|
26
|
-
* Extends the core SimpleTool with specific types
|
|
27
|
-
*/
|
|
28
|
-
type SimpleTool<TArgs = ToolArgs, TResult = JsonValue> = Omit<CoreSimpleTool<TArgs, TResult>, "execute"> & {
|
|
29
|
-
/**
|
|
30
|
-
* Tool description that helps AI understand when to use it
|
|
31
|
-
*/
|
|
32
|
-
description: string;
|
|
33
|
-
/**
|
|
34
|
-
* Parameters schema using Zod (optional)
|
|
35
|
-
*/
|
|
36
|
-
parameters?: ZodUnknownSchema;
|
|
37
|
-
/**
|
|
38
|
-
* Tool execution function
|
|
39
|
-
*/
|
|
40
|
-
execute: (params: TArgs, context?: ToolContext) => Promise<TResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Optional metadata
|
|
43
|
-
*/
|
|
44
|
-
metadata?: {
|
|
45
|
-
category?: string;
|
|
46
|
-
version?: string;
|
|
47
|
-
author?: string;
|
|
48
|
-
tags?: string[];
|
|
49
|
-
documentation?: string;
|
|
50
|
-
[key: string]: JsonValue | undefined;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
19
|
/**
|
|
54
20
|
* Creates a MCPServerInfo from a set of tools
|
|
55
21
|
*/
|
|
56
|
-
export declare function createMCPServerFromTools(serverId: string, tools: Record<string,
|
|
22
|
+
export declare function createMCPServerFromTools(serverId: string, tools: Record<string, SdkSimpleTool>, metadata?: {
|
|
57
23
|
title?: string;
|
|
58
24
|
description?: string;
|
|
59
25
|
category?: MCPServerCategory;
|
|
@@ -64,29 +30,29 @@ export declare function createMCPServerFromTools(serverId: string, tools: Record
|
|
|
64
30
|
/**
|
|
65
31
|
* Helper to create a tool with type safety
|
|
66
32
|
*/
|
|
67
|
-
export declare function createTool(config:
|
|
33
|
+
export declare function createTool(config: SdkSimpleTool): SdkSimpleTool;
|
|
68
34
|
/**
|
|
69
35
|
* Helper to create a validated tool with suggested improvements
|
|
70
36
|
*/
|
|
71
|
-
export declare function createValidatedTool(name: string, config:
|
|
37
|
+
export declare function createValidatedTool(name: string, config: SdkSimpleTool, options?: {
|
|
72
38
|
strict?: boolean;
|
|
73
39
|
suggestions?: boolean;
|
|
74
|
-
}):
|
|
40
|
+
}): SdkSimpleTool;
|
|
75
41
|
/**
|
|
76
42
|
* Helper to create a tool with typed parameters
|
|
77
43
|
*/
|
|
78
|
-
export declare function createTypedTool<TParams extends ZodUnknownSchema>(config: Omit<
|
|
44
|
+
export declare function createTypedTool<TParams extends ZodUnknownSchema>(config: Omit<SdkSimpleTool, "execute"> & {
|
|
79
45
|
parameters: TParams;
|
|
80
|
-
execute: (params: z.infer<TParams>, context?:
|
|
81
|
-
}):
|
|
46
|
+
execute: (params: z.infer<TParams>, context?: SDKToolContext) => Promise<JsonValue> | JsonValue;
|
|
47
|
+
}): SdkSimpleTool;
|
|
82
48
|
/**
|
|
83
49
|
* Validate tool configuration with detailed error messages
|
|
84
50
|
*/
|
|
85
|
-
export declare function validateTool(name: string, tool:
|
|
51
|
+
export declare function validateTool(name: string, tool: SdkSimpleTool): void;
|
|
86
52
|
/**
|
|
87
53
|
* Utility to validate multiple tools at once
|
|
88
54
|
*/
|
|
89
|
-
export declare function validateTools(tools: Record<string,
|
|
55
|
+
export declare function validateTools(tools: Record<string, SdkSimpleTool>): {
|
|
90
56
|
valid: string[];
|
|
91
57
|
invalid: Array<{
|
|
92
58
|
name: string;
|
|
@@ -169,7 +169,7 @@ function provideToolSuggestions(name, tool) {
|
|
|
169
169
|
* Helper to create a tool with typed parameters
|
|
170
170
|
*/
|
|
171
171
|
export function createTypedTool(config) {
|
|
172
|
-
// Wrap the typed execute to match
|
|
172
|
+
// Wrap the typed execute to match SdkSimpleTool's signature.
|
|
173
173
|
// The Zod schema validates params at runtime, so the cast within the wrapper is safe.
|
|
174
174
|
const wrappedExecute = async (params, context) => {
|
|
175
175
|
const result = await config.execute(params, context);
|
|
@@ -2,16 +2,7 @@
|
|
|
2
2
|
* Abort Signal Middleware
|
|
3
3
|
* Provides client disconnection handling for long-running requests
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
/**
|
|
7
|
-
* Abort signal middleware options
|
|
8
|
-
*/
|
|
9
|
-
type AbortSignalMiddlewareOptions = {
|
|
10
|
-
/** Callback when abort is triggered */
|
|
11
|
-
onAbort?: (ctx: ServerContext) => void;
|
|
12
|
-
/** Request timeout in milliseconds */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
};
|
|
5
|
+
import type { AbortSignalMiddlewareOptions, MiddlewareDefinition } from "../../types/index.js";
|
|
15
6
|
/**
|
|
16
7
|
* Create abort signal middleware for handling client disconnections.
|
|
17
8
|
*
|
|
@@ -59,4 +50,3 @@ export declare function createExpressAbortMiddleware(options?: AbortSignalMiddle
|
|
|
59
50
|
writableFinished?: boolean;
|
|
60
51
|
locals: Record<string, unknown>;
|
|
61
52
|
}, next: () => void) => void;
|
|
62
|
-
export {};
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Authentication Middleware
|
|
3
3
|
* Provides flexible authentication support for server adapters
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
import type { AuthResult } from "../../types/index.js";
|
|
5
|
+
import type { ApiKeyAuthOptions, AuthResult, AuthenticatedUser, BearerAuthOptions, MiddlewareDefinition, ServerServerAuthConfig, TokenValidator } from "../../types/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* Check if request is from development playground.
|
|
9
8
|
* Detects playground requests via special headers for development mode.
|
|
@@ -111,18 +110,6 @@ export declare class ApiKeyStore {
|
|
|
111
110
|
/**
|
|
112
111
|
* Options for bearer auth middleware
|
|
113
112
|
*/
|
|
114
|
-
type BearerAuthOptions = {
|
|
115
|
-
/** Whether authentication is required (default: true) */
|
|
116
|
-
required?: boolean;
|
|
117
|
-
/** Header name (default: "authorization") */
|
|
118
|
-
headerName?: string;
|
|
119
|
-
/** Paths to skip authentication */
|
|
120
|
-
skipPaths?: string[];
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Token validation function type
|
|
124
|
-
*/
|
|
125
|
-
type TokenValidator = (token: string) => Promise<AuthenticatedUser | null> | AuthenticatedUser | null;
|
|
126
113
|
/**
|
|
127
114
|
* Create bearer token authentication middleware
|
|
128
115
|
*
|
|
@@ -141,12 +128,6 @@ export declare function createBearerAuthMiddleware(validate: TokenValidator, opt
|
|
|
141
128
|
/**
|
|
142
129
|
* Options for API key auth middleware
|
|
143
130
|
*/
|
|
144
|
-
type ApiKeyAuthOptions = {
|
|
145
|
-
/** Header name (default: "x-api-key") */
|
|
146
|
-
headerName?: string;
|
|
147
|
-
/** Paths to skip authentication */
|
|
148
|
-
skipPaths?: string[];
|
|
149
|
-
};
|
|
150
131
|
/**
|
|
151
132
|
* Create API key authentication middleware
|
|
152
133
|
*
|
|
@@ -183,4 +164,3 @@ export declare function createRoleAuthMiddleware(requiredRoles: string[], option
|
|
|
183
164
|
export declare function createPermissionAuthMiddleware(requiredPermissions: string[], options?: {
|
|
184
165
|
requireAll?: boolean;
|
|
185
166
|
}): MiddlewareDefinition;
|
|
186
|
-
export {};
|