@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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Common utility types for NeuroLink
|
|
3
3
|
*/
|
|
4
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
5
|
+
import type { ConversationMemoryConfig } from "./conversation.js";
|
|
4
6
|
import type { AutoresearchErrorEvent, AutoresearchExperimentCompletedEvent, AutoresearchExperimentStartedEvent, AutoresearchInitializedEvent, AutoresearchMetricImprovedEvent, AutoresearchPhaseChangedEvent, AutoresearchResumedEvent, AutoresearchRevertEvent, AutoresearchRevertFailedEvent, AutoresearchStateUpdatedEvent } from "./autoresearch.js";
|
|
5
7
|
/**
|
|
6
8
|
* Type-safe unknown value - use when type is truly unknown
|
|
@@ -204,47 +206,6 @@ export type InfraRetryOptions = {
|
|
|
204
206
|
maxDelayMs?: number;
|
|
205
207
|
shouldRetry?: (error: Error) => boolean;
|
|
206
208
|
};
|
|
207
|
-
/**
|
|
208
|
-
* Configuration options for retry operations with exponential backoff.
|
|
209
|
-
* Named AsyncRetryOptions to avoid collision with utilities.ts RetryOptions.
|
|
210
|
-
*/
|
|
211
|
-
export type AsyncRetryOptions = {
|
|
212
|
-
/**
|
|
213
|
-
* Maximum number of retry attempts (not including the initial attempt).
|
|
214
|
-
* @default 3
|
|
215
|
-
*/
|
|
216
|
-
maxRetries: number;
|
|
217
|
-
/**
|
|
218
|
-
* Initial delay between retries in milliseconds.
|
|
219
|
-
* @default 1000
|
|
220
|
-
*/
|
|
221
|
-
baseDelayMs: number;
|
|
222
|
-
/**
|
|
223
|
-
* Maximum delay cap in milliseconds.
|
|
224
|
-
* @default 30000
|
|
225
|
-
*/
|
|
226
|
-
maxDelayMs: number;
|
|
227
|
-
/**
|
|
228
|
-
* Multiplier for exponential backoff.
|
|
229
|
-
* @default 2
|
|
230
|
-
*/
|
|
231
|
-
backoffMultiplier?: number;
|
|
232
|
-
/**
|
|
233
|
-
* Function to determine if a retry should be attempted.
|
|
234
|
-
* Return false to stop retrying immediately.
|
|
235
|
-
*/
|
|
236
|
-
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Whether to add random jitter to backoff delays to prevent thundering herd.
|
|
239
|
-
* @default true
|
|
240
|
-
*/
|
|
241
|
-
addJitter?: boolean;
|
|
242
|
-
/**
|
|
243
|
-
* Callback invoked before each retry attempt.
|
|
244
|
-
* Useful for logging or metrics.
|
|
245
|
-
*/
|
|
246
|
-
onRetry?: (error: Error, attempt: number, delayMs: number) => void;
|
|
247
|
-
};
|
|
248
209
|
/**
|
|
249
210
|
* Raw usage object that may come from various AI providers.
|
|
250
211
|
* Supports multiple naming conventions and nested structures.
|
|
@@ -441,3 +402,13 @@ export type StreamingParser = {
|
|
|
441
402
|
export type HippocampusMemory = import("@juspay/hippocampus").HippocampusConfig & {
|
|
442
403
|
enabled?: boolean;
|
|
443
404
|
};
|
|
405
|
+
/** Value types accepted as session variables by the loop REPL. */
|
|
406
|
+
export type SessionVariableValue = string | number | boolean;
|
|
407
|
+
/** State snapshot for the active REPL loop session. */
|
|
408
|
+
export type LoopSessionState = {
|
|
409
|
+
neurolinkInstance: NeuroLink;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
isActive: boolean;
|
|
412
|
+
conversationMemoryConfig?: ConversationMemoryConfig;
|
|
413
|
+
sessionVariables: Record<string, SessionVariableValue>;
|
|
414
|
+
};
|
|
@@ -463,4 +463,9 @@ export type DeduplicationResult = {
|
|
|
463
463
|
messages: ChatMessage[];
|
|
464
464
|
filesDeduped: number;
|
|
465
465
|
};
|
|
466
|
+
/** Options for FileSummarizationService. */
|
|
467
|
+
export type FileSummarizationServiceOptions = {
|
|
468
|
+
provider?: string;
|
|
469
|
+
model?: string;
|
|
470
|
+
};
|
|
466
471
|
export {};
|
|
@@ -7,7 +7,7 @@ import type { TokenUsage } from "./analytics.js";
|
|
|
7
7
|
import type { GenerateResult } from "./generate.js";
|
|
8
8
|
import type { ToolExecution } from "./tools.js";
|
|
9
9
|
import type { JsonObject } from "./common.js";
|
|
10
|
-
import type { AggregatedScores, PipelineConfig, ScorerInput } from "./scorer.js";
|
|
10
|
+
import type { AggregatedScores, EvaluationTraceContext, PipelineConfig, ReportConfig, ReportFormat, ScoreResult, ScorerInput } from "./scorer.js";
|
|
11
11
|
/**
|
|
12
12
|
* Evaluation provider type as specified in core module refactoring
|
|
13
13
|
*/
|
|
@@ -318,3 +318,334 @@ export type ScorerFunction = (input: ScorerInput) => Promise<{
|
|
|
318
318
|
reasoning: string;
|
|
319
319
|
metadata?: JsonObject;
|
|
320
320
|
}>;
|
|
321
|
+
/**
|
|
322
|
+
* Superset batch progress. `pending` is canonical; `remaining` in the
|
|
323
|
+
* pipeline's batchStrategy was renamed during consolidation (same value).
|
|
324
|
+
*/
|
|
325
|
+
export type BatchProgress = {
|
|
326
|
+
total: number;
|
|
327
|
+
completed: number;
|
|
328
|
+
failed: number;
|
|
329
|
+
pending: number;
|
|
330
|
+
percentComplete: number;
|
|
331
|
+
succeeded?: number;
|
|
332
|
+
estimatedTimeRemaining?: number;
|
|
333
|
+
};
|
|
334
|
+
/** Input item for BatchEvaluator. */
|
|
335
|
+
export type BatchEvaluationItem = {
|
|
336
|
+
id: string;
|
|
337
|
+
options: LanguageModelV3CallOptions;
|
|
338
|
+
result: GenerateResult;
|
|
339
|
+
threshold?: number;
|
|
340
|
+
};
|
|
341
|
+
/** Result of a single item in BatchEvaluator. */
|
|
342
|
+
export type BatchEvaluationItemResult = {
|
|
343
|
+
id: string;
|
|
344
|
+
success: boolean;
|
|
345
|
+
data?: EvaluationData;
|
|
346
|
+
error?: {
|
|
347
|
+
message: string;
|
|
348
|
+
code?: string;
|
|
349
|
+
retryable?: boolean;
|
|
350
|
+
};
|
|
351
|
+
duration: number;
|
|
352
|
+
retryCount: number;
|
|
353
|
+
};
|
|
354
|
+
/** Result of a single item in the pipeline batchStrategy. */
|
|
355
|
+
export type BatchItemResult = {
|
|
356
|
+
index: number;
|
|
357
|
+
input: ScorerInput;
|
|
358
|
+
result?: PipelineResult;
|
|
359
|
+
error?: string;
|
|
360
|
+
duration: number;
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Superset batch evaluation config. Union of pre-consolidation types
|
|
364
|
+
* (BatchEvaluationConfig in BatchEvaluator, BatchConfig in batchStrategy).
|
|
365
|
+
*/
|
|
366
|
+
export type BatchEvaluationConfig = EvaluationConfig & {
|
|
367
|
+
concurrency?: number;
|
|
368
|
+
continueOnError?: boolean;
|
|
369
|
+
onProgress?: (progress: BatchProgress) => void;
|
|
370
|
+
maxRetries?: number;
|
|
371
|
+
retryDelay?: number;
|
|
372
|
+
onItemComplete?: (result: BatchEvaluationItemResult) => void;
|
|
373
|
+
batchDelay?: number;
|
|
374
|
+
onResult?: (result: BatchItemResult) => void;
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Superset batch-result. `results` is a union of both item-result flavors;
|
|
378
|
+
* summary field names chosen from BatchEvaluator (`succeeded`, `passingRate`).
|
|
379
|
+
*/
|
|
380
|
+
export type BatchEvaluationResult = {
|
|
381
|
+
results: BatchEvaluationItemResult[] | BatchItemResult[];
|
|
382
|
+
summary: {
|
|
383
|
+
total: number;
|
|
384
|
+
succeeded: number;
|
|
385
|
+
failed: number;
|
|
386
|
+
averageScore: number;
|
|
387
|
+
averageDuration: number;
|
|
388
|
+
totalDuration: number;
|
|
389
|
+
passingRate: number;
|
|
390
|
+
};
|
|
391
|
+
allSucceeded?: boolean;
|
|
392
|
+
};
|
|
393
|
+
/** Statistical summary of evaluation scores. */
|
|
394
|
+
export type ScoreStatistics = {
|
|
395
|
+
min: number;
|
|
396
|
+
max: number;
|
|
397
|
+
mean: number;
|
|
398
|
+
median: number;
|
|
399
|
+
stdDev: number;
|
|
400
|
+
variance: number;
|
|
401
|
+
p25: number;
|
|
402
|
+
p75: number;
|
|
403
|
+
p90: number;
|
|
404
|
+
p95: number;
|
|
405
|
+
};
|
|
406
|
+
/** Score distribution across ranges. */
|
|
407
|
+
export type ScoreDistribution = {
|
|
408
|
+
/** Items scoring 1-3 (poor) */
|
|
409
|
+
poor: number;
|
|
410
|
+
/** Items scoring 4-5 (below average) */
|
|
411
|
+
belowAverage: number;
|
|
412
|
+
/** Items scoring 6-7 (average) */
|
|
413
|
+
average: number;
|
|
414
|
+
/** Items scoring 8-9 (good) */
|
|
415
|
+
good: number;
|
|
416
|
+
/** Items scoring 10 (excellent) */
|
|
417
|
+
excellent: number;
|
|
418
|
+
};
|
|
419
|
+
/** Trend analysis results. */
|
|
420
|
+
export type TrendAnalysis = {
|
|
421
|
+
direction: "improving" | "declining" | "stable";
|
|
422
|
+
slope: number;
|
|
423
|
+
rSquared: number;
|
|
424
|
+
percentChange: number;
|
|
425
|
+
movingAverage: number;
|
|
426
|
+
};
|
|
427
|
+
/** Dimension-specific analysis for RAGAS metrics. */
|
|
428
|
+
export type DimensionAnalysis = {
|
|
429
|
+
relevance: ScoreStatistics;
|
|
430
|
+
accuracy: ScoreStatistics;
|
|
431
|
+
completeness: ScoreStatistics;
|
|
432
|
+
overall: ScoreStatistics;
|
|
433
|
+
correlations: {
|
|
434
|
+
relevanceAccuracy: number;
|
|
435
|
+
relevanceCompleteness: number;
|
|
436
|
+
accuracyCompleteness: number;
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
/** Quality alerts summary. */
|
|
440
|
+
export type AlertSummary = {
|
|
441
|
+
total: number;
|
|
442
|
+
high: number;
|
|
443
|
+
medium: number;
|
|
444
|
+
offTopic: number;
|
|
445
|
+
alertRate: number;
|
|
446
|
+
};
|
|
447
|
+
/** Comprehensive aggregation result. */
|
|
448
|
+
export type AggregationResult = {
|
|
449
|
+
count: number;
|
|
450
|
+
statistics: ScoreStatistics;
|
|
451
|
+
distribution: ScoreDistribution;
|
|
452
|
+
dimensions: DimensionAnalysis;
|
|
453
|
+
sequenceTrend?: TrendAnalysis;
|
|
454
|
+
alerts: AlertSummary;
|
|
455
|
+
passingRate: number;
|
|
456
|
+
avgEvaluationTime: number;
|
|
457
|
+
metadata: {
|
|
458
|
+
aggregatedAt: string;
|
|
459
|
+
threshold: number;
|
|
460
|
+
evaluationModels: string[];
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
/** Configuration preset for common evaluation scenarios. */
|
|
464
|
+
export type EvaluatorPreset = {
|
|
465
|
+
name: string;
|
|
466
|
+
description: string;
|
|
467
|
+
config?: EvaluationConfig;
|
|
468
|
+
};
|
|
469
|
+
/** Configuration for evaluation strategies. */
|
|
470
|
+
export type EvaluationStrategyConfig = {
|
|
471
|
+
evaluationModel?: string;
|
|
472
|
+
provider?: string;
|
|
473
|
+
threshold?: number;
|
|
474
|
+
promptGenerator?: (context: {
|
|
475
|
+
userQuery: string;
|
|
476
|
+
history: string;
|
|
477
|
+
tools: string;
|
|
478
|
+
retryInfo: string;
|
|
479
|
+
aiResponse: string;
|
|
480
|
+
}) => string;
|
|
481
|
+
options?: Record<string, unknown>;
|
|
482
|
+
};
|
|
483
|
+
/** Function that performs evaluation and returns results. */
|
|
484
|
+
export type EvaluationStrategyFunction = (options: LanguageModelV3CallOptions, result: GenerateResult, config?: EvaluationStrategyConfig) => Promise<{
|
|
485
|
+
evaluationResult: EvaluationResult;
|
|
486
|
+
evalContext: EnhancedEvaluationContext;
|
|
487
|
+
}>;
|
|
488
|
+
/** Metadata for registered evaluation strategies. */
|
|
489
|
+
export type EvaluationStrategyMetadata = {
|
|
490
|
+
name: string;
|
|
491
|
+
description: string;
|
|
492
|
+
requiresLLM: boolean;
|
|
493
|
+
defaultModel?: string;
|
|
494
|
+
defaultProvider?: string;
|
|
495
|
+
version: string;
|
|
496
|
+
features: string[];
|
|
497
|
+
};
|
|
498
|
+
/** Canonical evaluation error code. */
|
|
499
|
+
export type EvaluationErrorCode = "EVALUATION_FAILED" | "PARSE_ERROR" | "STRATEGY_NOT_FOUND" | "PROVIDER_ERROR" | "CONFIGURATION_ERROR" | "CUSTOM_EVALUATOR_ERROR" | "BATCH_EVALUATION_ERROR" | "AGGREGATION_ERROR" | "REGISTRY_ERROR" | "MAX_RETRIES_EXCEEDED" | "TIMEOUT_ERROR" | "RATE_LIMIT_ERROR";
|
|
500
|
+
/** Extended evaluation context for error details. */
|
|
501
|
+
export type EvaluationErrorContext = {
|
|
502
|
+
userQueryLength?: number;
|
|
503
|
+
aiResponseLength?: number;
|
|
504
|
+
attemptNumber?: number;
|
|
505
|
+
previousScores?: number[];
|
|
506
|
+
strategy?: string;
|
|
507
|
+
evaluationModel?: string;
|
|
508
|
+
provider?: string;
|
|
509
|
+
rawResponseLength?: number;
|
|
510
|
+
additionalContext?: Record<string, unknown>;
|
|
511
|
+
};
|
|
512
|
+
/** Minimal Langfuse client interface for evaluation hooks. */
|
|
513
|
+
export type LangfuseClient = {
|
|
514
|
+
score: (params: {
|
|
515
|
+
name: string;
|
|
516
|
+
value: number;
|
|
517
|
+
traceId?: string;
|
|
518
|
+
observationId?: string;
|
|
519
|
+
comment?: string;
|
|
520
|
+
metadata?: Record<string, unknown>;
|
|
521
|
+
}) => Promise<unknown>;
|
|
522
|
+
trace?: (params: {
|
|
523
|
+
name: string;
|
|
524
|
+
metadata?: Record<string, unknown>;
|
|
525
|
+
tags?: string[];
|
|
526
|
+
}) => {
|
|
527
|
+
id: string;
|
|
528
|
+
};
|
|
529
|
+
shutdown?: () => Promise<void>;
|
|
530
|
+
};
|
|
531
|
+
/** Langfuse adapter configuration. */
|
|
532
|
+
export type LangfuseAdapterConfig = {
|
|
533
|
+
client: LangfuseClient;
|
|
534
|
+
scorePrefix?: string;
|
|
535
|
+
includeMetadata?: boolean;
|
|
536
|
+
tags?: string[];
|
|
537
|
+
sendPipelineScores?: boolean;
|
|
538
|
+
sendScorerScores?: boolean;
|
|
539
|
+
};
|
|
540
|
+
/** Events emitted by the evaluation pipeline. */
|
|
541
|
+
export type EvaluationEvents = {
|
|
542
|
+
"scorer:start": {
|
|
543
|
+
scorerId: string;
|
|
544
|
+
scorerName: string;
|
|
545
|
+
timestamp: number;
|
|
546
|
+
traceContext?: EvaluationTraceContext;
|
|
547
|
+
};
|
|
548
|
+
"scorer:end": {
|
|
549
|
+
scorerId: string;
|
|
550
|
+
scorerName: string;
|
|
551
|
+
result: ScoreResult;
|
|
552
|
+
timestamp: number;
|
|
553
|
+
duration: number;
|
|
554
|
+
traceContext?: EvaluationTraceContext;
|
|
555
|
+
};
|
|
556
|
+
"scorer:error": {
|
|
557
|
+
scorerId: string;
|
|
558
|
+
scorerName: string;
|
|
559
|
+
error: string;
|
|
560
|
+
timestamp: number;
|
|
561
|
+
traceContext?: EvaluationTraceContext;
|
|
562
|
+
};
|
|
563
|
+
"pipeline:start": {
|
|
564
|
+
pipelineName: string;
|
|
565
|
+
scorerCount: number;
|
|
566
|
+
timestamp: number;
|
|
567
|
+
correlationId: string;
|
|
568
|
+
traceContext?: EvaluationTraceContext;
|
|
569
|
+
};
|
|
570
|
+
"pipeline:end": {
|
|
571
|
+
pipelineName: string;
|
|
572
|
+
result: PipelineResult;
|
|
573
|
+
timestamp: number;
|
|
574
|
+
duration: number;
|
|
575
|
+
traceContext?: EvaluationTraceContext;
|
|
576
|
+
};
|
|
577
|
+
"pipeline:error": {
|
|
578
|
+
pipelineName: string;
|
|
579
|
+
error: string;
|
|
580
|
+
timestamp: number;
|
|
581
|
+
traceContext?: EvaluationTraceContext;
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Flat span attribute map used by the evaluation observability layer.
|
|
586
|
+
* Named EvaluationSpanAttributes to disambiguate from the richer telemetry
|
|
587
|
+
* SpanAttributes in span.ts (§Rule 9 domain prefix).
|
|
588
|
+
*/
|
|
589
|
+
export type EvaluationSpanAttributes = Record<string, string | number | boolean>;
|
|
590
|
+
/** Metrics captured per scorer execution. */
|
|
591
|
+
export type ScorerMetrics = {
|
|
592
|
+
scorerId: string;
|
|
593
|
+
scorerName: string;
|
|
594
|
+
totalExecutions: number;
|
|
595
|
+
successfulExecutions: number;
|
|
596
|
+
failedExecutions: number;
|
|
597
|
+
passedCount: number;
|
|
598
|
+
failedCount: number;
|
|
599
|
+
totalScore: number;
|
|
600
|
+
minScore: number;
|
|
601
|
+
maxScore: number;
|
|
602
|
+
totalDuration: number;
|
|
603
|
+
averageDuration: number;
|
|
604
|
+
averageScore: number;
|
|
605
|
+
passRate: number;
|
|
606
|
+
lastExecutionTime: number;
|
|
607
|
+
};
|
|
608
|
+
/** Metrics captured per evaluation pipeline. */
|
|
609
|
+
export type PipelineMetrics = {
|
|
610
|
+
pipelineName: string;
|
|
611
|
+
totalExecutions: number;
|
|
612
|
+
passedCount: number;
|
|
613
|
+
failedCount: number;
|
|
614
|
+
totalScore: number;
|
|
615
|
+
minScore: number;
|
|
616
|
+
maxScore: number;
|
|
617
|
+
totalDuration: number;
|
|
618
|
+
averageDuration: number;
|
|
619
|
+
averageScore: number;
|
|
620
|
+
passRate: number;
|
|
621
|
+
lastExecutionTime: number;
|
|
622
|
+
scorerMetrics: Map<string, ScorerMetrics>;
|
|
623
|
+
};
|
|
624
|
+
/** Aggregated metrics across pipelines and scorers. */
|
|
625
|
+
export type AggregatedMetrics = {
|
|
626
|
+
totalEvaluations: number;
|
|
627
|
+
overallPassRate: number;
|
|
628
|
+
averageScore: number;
|
|
629
|
+
averageDuration: number;
|
|
630
|
+
scoreDistribution: {
|
|
631
|
+
excellent: number;
|
|
632
|
+
good: number;
|
|
633
|
+
fair: number;
|
|
634
|
+
poor: number;
|
|
635
|
+
failing: number;
|
|
636
|
+
};
|
|
637
|
+
pipelineMetrics: Map<string, PipelineMetrics>;
|
|
638
|
+
scorerMetrics: Map<string, ScorerMetrics>;
|
|
639
|
+
collectionStartTime: number;
|
|
640
|
+
lastUpdateTime: number;
|
|
641
|
+
};
|
|
642
|
+
/** Generated evaluation report envelope. */
|
|
643
|
+
export type GeneratedReport = {
|
|
644
|
+
format: ReportFormat;
|
|
645
|
+
content: string;
|
|
646
|
+
metadata: {
|
|
647
|
+
generatedAt: number;
|
|
648
|
+
format: ReportFormat;
|
|
649
|
+
config: ReportConfig;
|
|
650
|
+
};
|
|
651
|
+
};
|
package/dist/lib/types/file.d.ts
CHANGED
|
@@ -371,3 +371,7 @@ export type SvgSanitizationResult = {
|
|
|
371
371
|
/** Whether any content was modified */
|
|
372
372
|
wasModified: boolean;
|
|
373
373
|
};
|
|
374
|
+
/** Contract implemented by each file-detection strategy. */
|
|
375
|
+
export type DetectionStrategy = {
|
|
376
|
+
detect(input: FileInput): Promise<FileDetectionResult>;
|
|
377
|
+
};
|
package/dist/lib/types/mcp.d.ts
CHANGED
|
@@ -245,13 +245,16 @@ export type MCPStatus = {
|
|
|
245
245
|
[key: string]: unknown;
|
|
246
246
|
};
|
|
247
247
|
/**
|
|
248
|
-
* Call record for circuit breaker statistics tracking
|
|
249
|
-
*
|
|
248
|
+
* Call record for circuit breaker statistics tracking.
|
|
249
|
+
* Superset shape: MCP breaker uses {timestamp, success, duration};
|
|
250
|
+
* RAG breaker also tracks `operationType` (optional, for routing and
|
|
251
|
+
* metrics). Both import from here.
|
|
250
252
|
*/
|
|
251
253
|
export type CallRecord = {
|
|
252
254
|
timestamp: number;
|
|
253
255
|
success: boolean;
|
|
254
256
|
duration: number;
|
|
257
|
+
operationType?: string;
|
|
255
258
|
};
|
|
256
259
|
/**
|
|
257
260
|
* Tool execution context - Rich context passed to every tool execution
|
|
@@ -2033,3 +2036,100 @@ export type MCPTool = ToolInfo & {
|
|
|
2033
2036
|
serverId?: string;
|
|
2034
2037
|
category?: string;
|
|
2035
2038
|
};
|
|
2039
|
+
/** Pending request in the batcher queue. */
|
|
2040
|
+
export type PendingRequest<T = unknown> = {
|
|
2041
|
+
id: string;
|
|
2042
|
+
tool: string;
|
|
2043
|
+
args: unknown;
|
|
2044
|
+
serverId?: string;
|
|
2045
|
+
resolve: (value: T) => void;
|
|
2046
|
+
reject: (error: Error) => void;
|
|
2047
|
+
addedAt: number;
|
|
2048
|
+
};
|
|
2049
|
+
/**
|
|
2050
|
+
* Cached entry held by ToolCache. Named McpCacheEntry to disambiguate from
|
|
2051
|
+
* the response-caching middleware's CacheEntry in server.ts (Rule 9).
|
|
2052
|
+
*/
|
|
2053
|
+
export type McpCacheEntry<T = unknown> = {
|
|
2054
|
+
value: T;
|
|
2055
|
+
expires: number;
|
|
2056
|
+
createdAt: number;
|
|
2057
|
+
accessedAt: number;
|
|
2058
|
+
accessCount: number;
|
|
2059
|
+
key: string;
|
|
2060
|
+
};
|
|
2061
|
+
/** Runtime metrics tracked per MCP server by MultiServerManager. */
|
|
2062
|
+
export type ServerMetrics = {
|
|
2063
|
+
activeRequests: number;
|
|
2064
|
+
totalRequests: number;
|
|
2065
|
+
completedRequests: number;
|
|
2066
|
+
averageResponseTime: number;
|
|
2067
|
+
errorRate: number;
|
|
2068
|
+
lastHealthCheck?: Date;
|
|
2069
|
+
isHealthy: boolean;
|
|
2070
|
+
};
|
|
2071
|
+
/** Synthesized test case produced by the AI workflow test-generator. */
|
|
2072
|
+
export type WorkflowTestCase = {
|
|
2073
|
+
name: string;
|
|
2074
|
+
type: string;
|
|
2075
|
+
code: string;
|
|
2076
|
+
description: string;
|
|
2077
|
+
assertions: number;
|
|
2078
|
+
};
|
|
2079
|
+
/** Result of the code-refactoring AI workflow. */
|
|
2080
|
+
export type RefactoringResult = {
|
|
2081
|
+
refactoredCode: string;
|
|
2082
|
+
changes: string[];
|
|
2083
|
+
improvements: string[];
|
|
2084
|
+
metrics: {
|
|
2085
|
+
linesReduced: number;
|
|
2086
|
+
complexityReduction: number;
|
|
2087
|
+
readabilityScore: number;
|
|
2088
|
+
};
|
|
2089
|
+
};
|
|
2090
|
+
/** Result of the AI documentation-generation workflow. */
|
|
2091
|
+
export type DocumentationResult = {
|
|
2092
|
+
documentation: string;
|
|
2093
|
+
sections: string[];
|
|
2094
|
+
examples: string[];
|
|
2095
|
+
coverage: number;
|
|
2096
|
+
};
|
|
2097
|
+
/** Result of the AI debugging workflow. */
|
|
2098
|
+
export type DebugResult = {
|
|
2099
|
+
issues: Array<{
|
|
2100
|
+
type: string;
|
|
2101
|
+
severity: "low" | "medium" | "high";
|
|
2102
|
+
description: string;
|
|
2103
|
+
location?: string;
|
|
2104
|
+
}>;
|
|
2105
|
+
suggestions: string[];
|
|
2106
|
+
possibleCauses: string[];
|
|
2107
|
+
fixedOutput?: string;
|
|
2108
|
+
};
|
|
2109
|
+
/** Provider name accepted by the AI analysis MCP tools. */
|
|
2110
|
+
export type AiAnalysisProvider = "openai" | "bedrock" | "vertex" | "anthropic" | "google-ai" | "azure" | "huggingface" | "ollama" | "mistral";
|
|
2111
|
+
/** Parsed input for the analyze-ai-usage MCP tool. */
|
|
2112
|
+
export type AnalyzeUsageParams = {
|
|
2113
|
+
sessionId?: string;
|
|
2114
|
+
timeRange: "1h" | "24h" | "7d" | "30d";
|
|
2115
|
+
provider?: AiAnalysisProvider;
|
|
2116
|
+
includeTokenBreakdown: boolean;
|
|
2117
|
+
includeCostEstimation: boolean;
|
|
2118
|
+
};
|
|
2119
|
+
/** Parsed input for the benchmark-provider-performance MCP tool. */
|
|
2120
|
+
export type BenchmarkParams = {
|
|
2121
|
+
providers?: AiAnalysisProvider[];
|
|
2122
|
+
testPrompts?: string[];
|
|
2123
|
+
iterations: number;
|
|
2124
|
+
metrics: Array<"latency" | "quality" | "cost" | "tokens">;
|
|
2125
|
+
maxTokens: number;
|
|
2126
|
+
};
|
|
2127
|
+
/** Parsed input for the optimize-prompt-parameters MCP tool. */
|
|
2128
|
+
export type OptimizeParametersParams = {
|
|
2129
|
+
prompt: string;
|
|
2130
|
+
provider?: AiAnalysisProvider;
|
|
2131
|
+
targetLength?: number;
|
|
2132
|
+
style: "creative" | "balanced" | "precise" | "factual";
|
|
2133
|
+
optimizeFor: "speed" | "quality" | "cost" | "tokens";
|
|
2134
|
+
iterations: number;
|
|
2135
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LanguageModelMiddleware } from "ai";
|
|
2
2
|
import type { JsonValue } from "../types/common.js";
|
|
3
3
|
import type { EvaluationData, GetPromptFunction } from "./evaluation.js";
|
|
4
|
+
import type { AuthenticatedUser, RouteDefinition, ServerContext } from "./server.js";
|
|
4
5
|
/**
|
|
5
6
|
* Metadata type for NeuroLink middleware
|
|
6
7
|
* Provides additional information about middleware without affecting execution
|
|
@@ -285,3 +286,118 @@ export type LifecycleMiddlewareConfig = {
|
|
|
285
286
|
onError?: OnErrorCallback;
|
|
286
287
|
onChunk?: OnChunkCallback;
|
|
287
288
|
};
|
|
289
|
+
/** Options for the abort-signal middleware. */
|
|
290
|
+
export type AbortSignalMiddlewareOptions = {
|
|
291
|
+
onAbort?: (ctx: ServerContext) => void;
|
|
292
|
+
timeout?: number;
|
|
293
|
+
};
|
|
294
|
+
/** Options for the bearer-token auth middleware. */
|
|
295
|
+
export type BearerAuthOptions = {
|
|
296
|
+
required?: boolean;
|
|
297
|
+
headerName?: string;
|
|
298
|
+
skipPaths?: string[];
|
|
299
|
+
};
|
|
300
|
+
/** Token-validation function signature. */
|
|
301
|
+
export type TokenValidator = (token: string) => Promise<AuthenticatedUser | null> | AuthenticatedUser | null;
|
|
302
|
+
/** Options for the API-key auth middleware. */
|
|
303
|
+
export type ApiKeyAuthOptions = {
|
|
304
|
+
headerName?: string;
|
|
305
|
+
skipPaths?: string[];
|
|
306
|
+
};
|
|
307
|
+
/** Configuration for the route-deprecation middleware. */
|
|
308
|
+
export type DeprecationConfig = {
|
|
309
|
+
routes: RouteDefinition[];
|
|
310
|
+
noticeHeader?: string;
|
|
311
|
+
includeLink?: boolean;
|
|
312
|
+
};
|
|
313
|
+
/** Rate-limit middleware configuration. */
|
|
314
|
+
export type RateLimitMiddlewareConfig = {
|
|
315
|
+
maxRequests: number;
|
|
316
|
+
windowMs: number;
|
|
317
|
+
message?: string;
|
|
318
|
+
skipPaths?: string[];
|
|
319
|
+
keyGenerator?: (ctx: ServerContext) => string;
|
|
320
|
+
onRateLimitExceeded?: (ctx: ServerContext, retryAfter: number) => unknown;
|
|
321
|
+
store?: RateLimitStore;
|
|
322
|
+
};
|
|
323
|
+
/** Rate-limit counter entry tracked per key. */
|
|
324
|
+
export type RateLimitEntry = {
|
|
325
|
+
count: number;
|
|
326
|
+
resetAt: number;
|
|
327
|
+
};
|
|
328
|
+
/** Rate-limit store contract (memory or Redis). */
|
|
329
|
+
export type RateLimitStore = {
|
|
330
|
+
get(key: string): Promise<RateLimitEntry | undefined>;
|
|
331
|
+
set(key: string, entry: RateLimitEntry): Promise<void>;
|
|
332
|
+
increment(key: string, windowMs: number): Promise<RateLimitEntry>;
|
|
333
|
+
reset(key: string): Promise<void>;
|
|
334
|
+
};
|
|
335
|
+
/** Simple fixed-window rate-limit configuration. */
|
|
336
|
+
export type FixedWindowRateLimitConfig = {
|
|
337
|
+
maxRequests: number;
|
|
338
|
+
windowMs: number;
|
|
339
|
+
message?: string;
|
|
340
|
+
skipPaths?: string[];
|
|
341
|
+
keyGenerator?: (ctx: ServerContext) => string;
|
|
342
|
+
onRateLimitExceeded?: (ctx: ServerContext, retryAfter: number) => unknown;
|
|
343
|
+
};
|
|
344
|
+
/** Per-field entry inside a ServerValidationError's `errors` array. */
|
|
345
|
+
export type ValidationErrorPayload = {
|
|
346
|
+
field: string;
|
|
347
|
+
message: string;
|
|
348
|
+
value?: unknown;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Minimal structural view of the server-side ValidationError class used by
|
|
352
|
+
* the request-validation middleware's errorFormatter callback.
|
|
353
|
+
*/
|
|
354
|
+
export type ValidationErrorInfo = {
|
|
355
|
+
errors: ValidationErrorPayload[];
|
|
356
|
+
requestId?: string;
|
|
357
|
+
};
|
|
358
|
+
/** Validation configuration for the request-validation middleware. */
|
|
359
|
+
export type ValidationConfig = {
|
|
360
|
+
bodySchema?: MiddlewareRequestSchema;
|
|
361
|
+
querySchema?: MiddlewareRequestSchema;
|
|
362
|
+
paramsSchema?: MiddlewareRequestSchema;
|
|
363
|
+
headersSchema?: MiddlewareRequestSchema;
|
|
364
|
+
customValidator?: (ctx: ServerContext) => Promise<void>;
|
|
365
|
+
skipPaths?: string[];
|
|
366
|
+
errorFormatter?: (errors: ValidationErrorInfo[]) => unknown;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Simple structural validation schema used by the request-validation
|
|
370
|
+
* middleware. Named MiddlewareRequestSchema to disambiguate from the zod
|
|
371
|
+
* `ValidationSchema` exported from aliases.ts (§Rule 9 domain prefix).
|
|
372
|
+
*/
|
|
373
|
+
export type MiddlewareRequestSchema = {
|
|
374
|
+
required?: string[];
|
|
375
|
+
properties?: Record<string, PropertySchema>;
|
|
376
|
+
additionalProperties?: boolean;
|
|
377
|
+
};
|
|
378
|
+
/** Schema for an individual property in ValidationSchema. */
|
|
379
|
+
export type PropertySchema = {
|
|
380
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
381
|
+
minimum?: number;
|
|
382
|
+
maximum?: number;
|
|
383
|
+
minLength?: number;
|
|
384
|
+
maxLength?: number;
|
|
385
|
+
minItems?: number;
|
|
386
|
+
maxItems?: number;
|
|
387
|
+
pattern?: string;
|
|
388
|
+
enum?: unknown[];
|
|
389
|
+
default?: unknown;
|
|
390
|
+
validate?: (value: unknown) => boolean | string;
|
|
391
|
+
};
|
|
392
|
+
/** PropertySchema with an extra `format` tag for common schemas. */
|
|
393
|
+
export type ExtendedPropertySchema = PropertySchema & {
|
|
394
|
+
format?: string;
|
|
395
|
+
};
|
|
396
|
+
/** Extended validation schema for common schemas. */
|
|
397
|
+
export type ExtendedValidationSchema = {
|
|
398
|
+
type?: string;
|
|
399
|
+
format?: string;
|
|
400
|
+
required?: string[];
|
|
401
|
+
properties?: Record<string, ExtendedPropertySchema>;
|
|
402
|
+
additionalProperties?: boolean;
|
|
403
|
+
};
|