@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
package/dist/lib/types/rag.d.ts
CHANGED
|
@@ -1271,3 +1271,25 @@ export type RAGCommandArgs = {
|
|
|
1271
1271
|
/** Use Graph RAG */
|
|
1272
1272
|
graph?: boolean;
|
|
1273
1273
|
};
|
|
1274
|
+
/** Options for the recursive JSON chunk extractor. */
|
|
1275
|
+
export type ExtractChunksOptions = {
|
|
1276
|
+
data: unknown;
|
|
1277
|
+
path: string;
|
|
1278
|
+
depth: number;
|
|
1279
|
+
maxDepth: number;
|
|
1280
|
+
maxSize: number;
|
|
1281
|
+
splitKeys: string[];
|
|
1282
|
+
preserveKeys: string[];
|
|
1283
|
+
includeJsonPath: boolean;
|
|
1284
|
+
};
|
|
1285
|
+
/** Document processing state held by MDocument. */
|
|
1286
|
+
export type DocumentState = {
|
|
1287
|
+
content: string;
|
|
1288
|
+
type: DocumentType;
|
|
1289
|
+
metadata: Record<string, unknown>;
|
|
1290
|
+
chunks: Chunk[];
|
|
1291
|
+
embeddings: number[][];
|
|
1292
|
+
history: string[];
|
|
1293
|
+
};
|
|
1294
|
+
/** Canonical RAG error code. */
|
|
1295
|
+
export type RAGErrorCode = "RAG_CHUNKING_ERROR" | "RAG_CHUNKING_INVALID_CONFIG" | "RAG_CHUNKING_STRATEGY_NOT_FOUND" | "RAG_CHUNKING_EMPTY_CONTENT" | "RAG_CHUNKING_SIZE_EXCEEDED" | "RAG_METADATA_EXTRACTION_ERROR" | "RAG_METADATA_EXTRACTION_TIMEOUT" | "RAG_METADATA_SCHEMA_INVALID" | "RAG_METADATA_EXTRACTOR_NOT_FOUND" | "RAG_EMBEDDING_ERROR" | "RAG_EMBEDDING_DIMENSION_MISMATCH" | "RAG_EMBEDDING_RATE_LIMIT" | "RAG_EMBEDDING_PROVIDER_ERROR" | "RAG_VECTOR_QUERY_ERROR" | "RAG_VECTOR_QUERY_TIMEOUT" | "RAG_VECTOR_STORE_UNAVAILABLE" | "RAG_VECTOR_STORE_CONNECTION_ERROR" | "RAG_VECTOR_INDEX_NOT_FOUND" | "RAG_RERANKER_ERROR" | "RAG_RERANKER_NOT_FOUND" | "RAG_RERANKER_API_ERROR" | "RAG_GRAPH_ERROR" | "RAG_GRAPH_TRAVERSAL_ERROR" | "RAG_GRAPH_NODE_NOT_FOUND" | "RAG_PIPELINE_ERROR" | "RAG_PIPELINE_STAGE_FAILED" | "RAG_PIPELINE_PARTIAL_FAILURE" | "RAG_CIRCUIT_BREAKER_OPEN" | "RAG_CIRCUIT_BREAKER_HALF_OPEN_LIMIT" | "RAG_OPERATION_TIMEOUT" | "RAG_RETRY_EXHAUSTED" | "RAG_INVALID_CONFIGURATION";
|
|
@@ -421,3 +421,144 @@ export type ReportConfig = {
|
|
|
421
421
|
/** Include timing information */
|
|
422
422
|
includeTiming?: boolean;
|
|
423
423
|
};
|
|
424
|
+
/** Similarity metric types. */
|
|
425
|
+
export type SimilarityMetric = "jaccard" | "cosine" | "levenshtein" | "dice" | "overlap";
|
|
426
|
+
/** Configuration specific to content similarity scoring. */
|
|
427
|
+
export type ContentSimilarityConfig = RuleScorerConfig & {
|
|
428
|
+
metric?: SimilarityMetric;
|
|
429
|
+
metrics?: SimilarityMetric[];
|
|
430
|
+
metricCombination?: "average" | "min" | "max" | "weighted";
|
|
431
|
+
metricWeights?: Record<SimilarityMetric, number>;
|
|
432
|
+
normalizeText?: boolean;
|
|
433
|
+
tokenLevel?: "word" | "character" | "ngram";
|
|
434
|
+
ngramSize?: number;
|
|
435
|
+
compareWith?: "groundTruth" | "context" | "custom";
|
|
436
|
+
referenceText?: string;
|
|
437
|
+
};
|
|
438
|
+
/** Similarity calculation detail row. */
|
|
439
|
+
export type SimilarityDetails = {
|
|
440
|
+
metric: SimilarityMetric;
|
|
441
|
+
score: number;
|
|
442
|
+
responseTokens: number;
|
|
443
|
+
referenceTokens: number;
|
|
444
|
+
commonTokens?: number;
|
|
445
|
+
};
|
|
446
|
+
/** Expected format types evaluated by the format scorer. */
|
|
447
|
+
export type FormatType = "json" | "markdown" | "code" | "list" | "numbered-list" | "bullet-list" | "table" | "yaml" | "xml" | "plain" | "html" | "custom";
|
|
448
|
+
/** Code language types for the code-format validator. */
|
|
449
|
+
export type CodeLanguage = "javascript" | "typescript" | "python" | "java" | "c" | "cpp" | "csharp" | "go" | "rust" | "sql" | "bash" | "any";
|
|
450
|
+
/** Configuration specific to format scoring. */
|
|
451
|
+
export type FormatScorerConfig = RuleScorerConfig & {
|
|
452
|
+
expectedFormat?: FormatType;
|
|
453
|
+
allowedFormats?: FormatType[];
|
|
454
|
+
codeLanguage?: CodeLanguage;
|
|
455
|
+
jsonSchema?: object;
|
|
456
|
+
markdownRequirements?: {
|
|
457
|
+
hasHeadings?: boolean;
|
|
458
|
+
hasCodeBlocks?: boolean;
|
|
459
|
+
hasLinks?: boolean;
|
|
460
|
+
hasLists?: boolean;
|
|
461
|
+
minHeadingLevel?: number;
|
|
462
|
+
maxHeadingLevel?: number;
|
|
463
|
+
};
|
|
464
|
+
listRequirements?: {
|
|
465
|
+
minItems?: number;
|
|
466
|
+
maxItems?: number;
|
|
467
|
+
itemPattern?: string;
|
|
468
|
+
};
|
|
469
|
+
customPattern?: string;
|
|
470
|
+
strictFormat?: boolean;
|
|
471
|
+
};
|
|
472
|
+
/** Format validation result. */
|
|
473
|
+
export type FormatValidationResult = {
|
|
474
|
+
isValid: boolean;
|
|
475
|
+
detectedFormat: FormatType | null;
|
|
476
|
+
issues: string[];
|
|
477
|
+
structureAnalysis?: object;
|
|
478
|
+
};
|
|
479
|
+
/** Configuration specific to keyword coverage scoring. */
|
|
480
|
+
export type KeywordCoverageConfig = RuleScorerConfig & {
|
|
481
|
+
keywords?: string[];
|
|
482
|
+
minCoverage?: number;
|
|
483
|
+
caseInsensitive?: boolean;
|
|
484
|
+
wordBoundary?: boolean;
|
|
485
|
+
synonyms?: Record<string, string[]>;
|
|
486
|
+
keywordWeights?: Record<string, number>;
|
|
487
|
+
};
|
|
488
|
+
/** Keyword coverage result details. */
|
|
489
|
+
export type KeywordCoverageDetails = {
|
|
490
|
+
totalKeywords: number;
|
|
491
|
+
foundKeywords: string[];
|
|
492
|
+
missingKeywords: string[];
|
|
493
|
+
coverageRatio: number;
|
|
494
|
+
weightedCoverage: number;
|
|
495
|
+
};
|
|
496
|
+
/** Length measurement unit. */
|
|
497
|
+
export type LengthUnit = "words" | "characters" | "sentences" | "paragraphs" | "tokens";
|
|
498
|
+
/** Length constraint type. */
|
|
499
|
+
export type LengthConstraintType = "exact" | "range" | "minimum" | "maximum" | "ratio";
|
|
500
|
+
/** Configuration specific to length scoring. */
|
|
501
|
+
export type LengthScorerConfig = RuleScorerConfig & {
|
|
502
|
+
unit?: LengthUnit;
|
|
503
|
+
constraintType?: LengthConstraintType;
|
|
504
|
+
minLength?: number;
|
|
505
|
+
maxLength?: number;
|
|
506
|
+
exactLength?: number;
|
|
507
|
+
tolerance?: number;
|
|
508
|
+
ratioTarget?: number;
|
|
509
|
+
ratioReference?: "query" | "context";
|
|
510
|
+
scoringMode?: "binary" | "proportional";
|
|
511
|
+
};
|
|
512
|
+
/** Length measurement result. */
|
|
513
|
+
export type LengthMeasurement = {
|
|
514
|
+
words: number;
|
|
515
|
+
characters: number;
|
|
516
|
+
sentences: number;
|
|
517
|
+
paragraphs: number;
|
|
518
|
+
estimatedTokens: number;
|
|
519
|
+
};
|
|
520
|
+
/** Row describing a built-in scorer in the scorer registry seed list. */
|
|
521
|
+
export type BuiltInScorerDefinition = {
|
|
522
|
+
metadata: ScorerMetadata;
|
|
523
|
+
factory: ScorerFactory;
|
|
524
|
+
aliases?: string[];
|
|
525
|
+
};
|
|
526
|
+
/** Bias instance reported by the bias-detection scorer. */
|
|
527
|
+
export type BiasInstance = {
|
|
528
|
+
type?: string;
|
|
529
|
+
text?: string;
|
|
530
|
+
explanation?: string;
|
|
531
|
+
severity?: string;
|
|
532
|
+
};
|
|
533
|
+
/** Context score row reported by the context-relevancy scorer. */
|
|
534
|
+
export type ContextScoreItem = {
|
|
535
|
+
index?: number;
|
|
536
|
+
score?: number;
|
|
537
|
+
reasoning?: string;
|
|
538
|
+
keyInfo?: string[];
|
|
539
|
+
};
|
|
540
|
+
/** Claim row reported by the faithfulness scorer. */
|
|
541
|
+
export type ClaimItem = {
|
|
542
|
+
claim?: string;
|
|
543
|
+
supported?: boolean;
|
|
544
|
+
evidence?: string;
|
|
545
|
+
};
|
|
546
|
+
/** Hallucination row reported by the hallucination scorer. */
|
|
547
|
+
export type HallucinationItem = {
|
|
548
|
+
text?: string;
|
|
549
|
+
reason?: string;
|
|
550
|
+
severity?: string;
|
|
551
|
+
};
|
|
552
|
+
/** Tone-shift location reported by the tone-consistency scorer. */
|
|
553
|
+
export type ToneShift = {
|
|
554
|
+
location?: string;
|
|
555
|
+
from?: string;
|
|
556
|
+
to?: string;
|
|
557
|
+
severity?: string;
|
|
558
|
+
};
|
|
559
|
+
/** Flagged content row reported by the toxicity scorer. */
|
|
560
|
+
export type FlaggedItem = {
|
|
561
|
+
text?: string;
|
|
562
|
+
category?: string;
|
|
563
|
+
severity?: string;
|
|
564
|
+
};
|
|
@@ -1010,3 +1010,102 @@ export type CacheEntry = {
|
|
|
1010
1010
|
ttlMs: number;
|
|
1011
1011
|
headers?: Record<string, string>;
|
|
1012
1012
|
};
|
|
1013
|
+
/** Voice-server conversation turn — superset role set. */
|
|
1014
|
+
export type Message = {
|
|
1015
|
+
role: "system" | "user" | "assistant";
|
|
1016
|
+
content: string;
|
|
1017
|
+
};
|
|
1018
|
+
/** Subset of Message that excludes the system role (assistant+user only). */
|
|
1019
|
+
export type ConversationMessage = {
|
|
1020
|
+
role: "user" | "assistant";
|
|
1021
|
+
content: string;
|
|
1022
|
+
};
|
|
1023
|
+
/** Configuration passed to the OpenAPI spec generator. */
|
|
1024
|
+
export type OpenAPIGeneratorConfig = {
|
|
1025
|
+
info?: {
|
|
1026
|
+
title?: string;
|
|
1027
|
+
version?: string;
|
|
1028
|
+
description?: string;
|
|
1029
|
+
};
|
|
1030
|
+
servers?: Array<{
|
|
1031
|
+
url: string;
|
|
1032
|
+
description?: string;
|
|
1033
|
+
}>;
|
|
1034
|
+
includeSecurity?: boolean;
|
|
1035
|
+
basePath?: string;
|
|
1036
|
+
additionalTags?: Array<{
|
|
1037
|
+
name: string;
|
|
1038
|
+
description: string;
|
|
1039
|
+
}>;
|
|
1040
|
+
customSchemas?: Record<string, JsonObject>;
|
|
1041
|
+
routes?: RouteDefinition[];
|
|
1042
|
+
};
|
|
1043
|
+
/** Structured OpenAPI 3.1 specification object. */
|
|
1044
|
+
export type OpenAPISpec = {
|
|
1045
|
+
openapi: "3.1.0";
|
|
1046
|
+
info: JsonObject;
|
|
1047
|
+
servers: JsonObject[];
|
|
1048
|
+
tags: JsonObject[];
|
|
1049
|
+
paths: Record<string, JsonObject>;
|
|
1050
|
+
components: {
|
|
1051
|
+
schemas: Record<string, JsonObject>;
|
|
1052
|
+
securitySchemes?: Record<string, JsonObject>;
|
|
1053
|
+
parameters?: Record<string, JsonObject>;
|
|
1054
|
+
};
|
|
1055
|
+
security?: JsonObject[];
|
|
1056
|
+
};
|
|
1057
|
+
/** Options for createAllRoutes / createRoutes. */
|
|
1058
|
+
export type CreateRoutesOptions = {
|
|
1059
|
+
enableSwagger?: boolean;
|
|
1060
|
+
getRoutes?: () => RouteDefinition[];
|
|
1061
|
+
claudeProxy?: boolean;
|
|
1062
|
+
};
|
|
1063
|
+
/** Data stream finish event. */
|
|
1064
|
+
export type FinishEvent = DataStreamEvent & {
|
|
1065
|
+
type: "finish";
|
|
1066
|
+
data: {
|
|
1067
|
+
reason?: string;
|
|
1068
|
+
usage?: {
|
|
1069
|
+
input: number;
|
|
1070
|
+
output: number;
|
|
1071
|
+
total: number;
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
/** Configuration for DataStreamWriter. */
|
|
1076
|
+
export type DataStreamWriterConfig = {
|
|
1077
|
+
write: (chunk: string) => void | Promise<void>;
|
|
1078
|
+
close?: () => void | Promise<void>;
|
|
1079
|
+
format?: "sse" | "ndjson";
|
|
1080
|
+
includeTimestamps?: boolean;
|
|
1081
|
+
};
|
|
1082
|
+
/** Configuration for the DataStreamResponse wrapper. */
|
|
1083
|
+
export type DataStreamResponseConfig = {
|
|
1084
|
+
contentType?: "text/event-stream" | "application/x-ndjson";
|
|
1085
|
+
headers?: Record<string, string>;
|
|
1086
|
+
keepAliveInterval?: number;
|
|
1087
|
+
includeTimestamps?: boolean;
|
|
1088
|
+
};
|
|
1089
|
+
/** Options for a single SSE message. */
|
|
1090
|
+
export type SSEEventOptions = {
|
|
1091
|
+
event?: string;
|
|
1092
|
+
data: string;
|
|
1093
|
+
id?: string;
|
|
1094
|
+
retry?: number;
|
|
1095
|
+
};
|
|
1096
|
+
/** Single token emitted by the Soniox STT stream. */
|
|
1097
|
+
export type SonioxToken = {
|
|
1098
|
+
is_final?: boolean;
|
|
1099
|
+
text?: string;
|
|
1100
|
+
};
|
|
1101
|
+
/** Envelope received from the Soniox STT WebSocket. */
|
|
1102
|
+
export type SonioxMessage = {
|
|
1103
|
+
error?: string;
|
|
1104
|
+
status?: string;
|
|
1105
|
+
type?: string;
|
|
1106
|
+
tokens?: SonioxToken[];
|
|
1107
|
+
};
|
|
1108
|
+
/** Control message received from the voice client over WebSocket. */
|
|
1109
|
+
export type ClientControlMessage = {
|
|
1110
|
+
type?: string;
|
|
1111
|
+
};
|
package/dist/lib/types/span.d.ts
CHANGED
package/dist/lib/types/span.js
CHANGED
|
@@ -51,6 +51,7 @@ export var SpanStatus;
|
|
|
51
51
|
SpanStatus[SpanStatus["UNSET"] = 0] = "UNSET";
|
|
52
52
|
SpanStatus[SpanStatus["OK"] = 1] = "OK";
|
|
53
53
|
SpanStatus[SpanStatus["ERROR"] = 2] = "ERROR";
|
|
54
|
+
SpanStatus[SpanStatus["WARNING"] = 3] = "WARNING";
|
|
54
55
|
})(SpanStatus || (SpanStatus = {}));
|
|
55
56
|
/**
|
|
56
57
|
* OpenTelemetry GenAI semantic conventions
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* argument patterns, execution metadata, context, and result types.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import type { Tool } from "ai";
|
|
6
7
|
import type { ErrorInfo, JsonObject, JsonValue, Result, UnknownRecord } from "./common.js";
|
|
7
8
|
import type { StandardRecord, StringArray, ZodUnknownSchema } from "./aliases.js";
|
|
8
9
|
import type { ValidationError } from "../utils/parameterValidation.js";
|
|
@@ -357,6 +358,49 @@ export type SimpleTool<TArgs = ToolArgs, TResult = JsonValue> = {
|
|
|
357
358
|
metadata?: ToolMetadata;
|
|
358
359
|
execute: (params: TArgs, context?: ToolContext) => Promise<TResult>;
|
|
359
360
|
};
|
|
361
|
+
/**
|
|
362
|
+
* Simple tool type accepted by the SDK registerTool() helper. Uses
|
|
363
|
+
* SDKToolContext (richer tool context with request metadata).
|
|
364
|
+
*/
|
|
365
|
+
export type SdkSimpleTool<TArgs = ToolArgs, TResult = JsonValue> = Omit<SimpleTool<TArgs, TResult>, "execute"> & {
|
|
366
|
+
description: string;
|
|
367
|
+
parameters?: ZodUnknownSchema;
|
|
368
|
+
execute: (params: TArgs, context?: SDKToolContext) => Promise<TResult>;
|
|
369
|
+
metadata?: {
|
|
370
|
+
category?: string;
|
|
371
|
+
version?: string;
|
|
372
|
+
author?: string;
|
|
373
|
+
tags?: string[];
|
|
374
|
+
documentation?: string;
|
|
375
|
+
[key: string]: JsonValue | undefined;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
/** Subset of directAgentTools exposing only the "basic" category. */
|
|
379
|
+
export type BasicToolsMap = {
|
|
380
|
+
getCurrentTime: Tool;
|
|
381
|
+
calculateMath: Tool;
|
|
382
|
+
};
|
|
383
|
+
/** Subset of directAgentTools exposing only the "filesystem" category. */
|
|
384
|
+
export type FilesystemToolsMap = {
|
|
385
|
+
readFile: Tool;
|
|
386
|
+
listDirectory: Tool;
|
|
387
|
+
writeFile: Tool;
|
|
388
|
+
};
|
|
389
|
+
/** Subset of directAgentTools exposing the "utility" category. */
|
|
390
|
+
export type UtilityToolsMap = {
|
|
391
|
+
getCurrentTime: Tool;
|
|
392
|
+
calculateMath: Tool;
|
|
393
|
+
listDirectory: Tool;
|
|
394
|
+
};
|
|
395
|
+
/** Full directAgentTools map, with the opt-in bashTool appended. */
|
|
396
|
+
export type AllToolsMap = {
|
|
397
|
+
getCurrentTime: Tool;
|
|
398
|
+
calculateMath: Tool;
|
|
399
|
+
readFile: Tool;
|
|
400
|
+
listDirectory: Tool;
|
|
401
|
+
writeFile: Tool;
|
|
402
|
+
executeBashCommand?: Tool;
|
|
403
|
+
};
|
|
360
404
|
/**
|
|
361
405
|
* Tool registry entry
|
|
362
406
|
*/
|
package/dist/lib/types/tts.d.ts
CHANGED
|
@@ -167,3 +167,9 @@ export type TTSChunk = {
|
|
|
167
167
|
/** Sample rate in Hz */
|
|
168
168
|
sampleRate?: number;
|
|
169
169
|
};
|
|
170
|
+
/** Message envelope received from the Cartesia TTS WebSocket. */
|
|
171
|
+
export type CartesiaMessage = {
|
|
172
|
+
data?: string;
|
|
173
|
+
done?: boolean;
|
|
174
|
+
error?: string;
|
|
175
|
+
};
|
|
@@ -241,3 +241,25 @@ export type ImageCacheStats = {
|
|
|
241
241
|
/** Cache hit rate as percentage */
|
|
242
242
|
hitRate: number;
|
|
243
243
|
};
|
|
244
|
+
/**
|
|
245
|
+
* Pending request held by TokenBucketRateLimiter's queue.
|
|
246
|
+
* Named RateLimiterPendingRequest to disambiguate from the MCP
|
|
247
|
+
* PendingRequest in mcp.ts (Rule 9).
|
|
248
|
+
*/
|
|
249
|
+
export type RateLimiterPendingRequest = {
|
|
250
|
+
resolve: () => void;
|
|
251
|
+
reject: (error: Error) => void;
|
|
252
|
+
timestamp: number;
|
|
253
|
+
timeoutTimer?: ReturnType<typeof setTimeout>;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Shape of a completed tool result as returned by the AI SDK in
|
|
257
|
+
* `onStepFinish`. Both `output` (AI SDK v4) and `result` (older shape)
|
|
258
|
+
* are supported so the helper works across SDK versions.
|
|
259
|
+
*/
|
|
260
|
+
export type StepToolResult = {
|
|
261
|
+
toolName: string;
|
|
262
|
+
output?: unknown;
|
|
263
|
+
result?: unknown;
|
|
264
|
+
error?: string;
|
|
265
|
+
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Testing Phase: Focuses on original output + evaluation metrics for AB testing
|
|
6
6
|
*/
|
|
7
|
+
import type { z } from "zod";
|
|
7
8
|
import type { AnalyticsData } from "./analytics.js";
|
|
8
9
|
import { AIProviderName } from "../constants/enums.js";
|
|
9
10
|
import type { JsonValue } from "./common.js";
|
|
@@ -578,3 +579,20 @@ export type RunWorkflowOptions = {
|
|
|
578
579
|
/** Enable progressive streaming (yield preliminary response) */
|
|
579
580
|
streaming?: boolean;
|
|
580
581
|
};
|
|
582
|
+
/**
|
|
583
|
+
* Generic workflow validation result — replaces three near-identical types
|
|
584
|
+
* (WorkflowConfigValidationResult, ModelConfigValidationResult,
|
|
585
|
+
* JudgeConfigValidationResult). Named with `Workflow*` prefix to avoid
|
|
586
|
+
* collision with `tools.ts#ValidationResult` (Rule 9).
|
|
587
|
+
*/
|
|
588
|
+
export type WorkflowValidation<T> = {
|
|
589
|
+
success: boolean;
|
|
590
|
+
data?: T;
|
|
591
|
+
error?: z.ZodError;
|
|
592
|
+
};
|
|
593
|
+
/** Progressive workflow response chunk streamed by runWorkflow(). */
|
|
594
|
+
export type WorkflowStreamChunk = {
|
|
595
|
+
type: "preliminary" | "final";
|
|
596
|
+
content: string;
|
|
597
|
+
partialResult?: Partial<WorkflowResult>;
|
|
598
|
+
};
|
|
@@ -3,16 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides retry logic with exponential backoff for resilient async operations.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
/**
|
|
8
|
-
* Local alias: the canonical type was renamed to AsyncRetryOptions to avoid
|
|
9
|
-
* collision with other RetryOptions types in the codebase.
|
|
10
|
-
*/
|
|
11
|
-
type RetryOptions = AsyncRetryOptions;
|
|
6
|
+
import type { RetryOptions } from "../../types/index.js";
|
|
12
7
|
/**
|
|
13
8
|
* Default retry configuration.
|
|
14
9
|
*/
|
|
15
|
-
export declare const DEFAULT_RETRY_OPTIONS: RetryOptions
|
|
10
|
+
export declare const DEFAULT_RETRY_OPTIONS: Required<Pick<RetryOptions, "maxAttempts" | "initialDelay" | "maxDelay" | "backoffMultiplier">>;
|
|
16
11
|
/**
|
|
17
12
|
* Calculate exponential backoff delay with optional jitter.
|
|
18
13
|
*
|
|
@@ -110,4 +105,3 @@ export declare function retry<T>(fn: () => Promise<T>, options?: Partial<RetryOp
|
|
|
110
105
|
* ```
|
|
111
106
|
*/
|
|
112
107
|
export declare function createRetry(defaultOptions: Partial<RetryOptions>): <T>(fn: () => Promise<T>, overrideOptions?: Partial<RetryOptions>) => Promise<T>;
|
|
113
|
-
export {};
|
|
@@ -8,9 +8,9 @@ import { delay } from "./delay.js";
|
|
|
8
8
|
* Default retry configuration.
|
|
9
9
|
*/
|
|
10
10
|
export const DEFAULT_RETRY_OPTIONS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
maxAttempts: 3,
|
|
12
|
+
initialDelay: 1000,
|
|
13
|
+
maxDelay: 30000,
|
|
14
14
|
backoffMultiplier: 2,
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
@@ -109,11 +109,11 @@ export async function retry(fn, options = {}) {
|
|
|
109
109
|
...DEFAULT_RETRY_OPTIONS,
|
|
110
110
|
...options,
|
|
111
111
|
};
|
|
112
|
-
const {
|
|
112
|
+
const { maxAttempts, initialDelay, maxDelay, backoffMultiplier, retryCondition = () => true, onRetry, } = config;
|
|
113
113
|
let lastError = new Error("Retry failed");
|
|
114
|
-
let currentDelay =
|
|
114
|
+
let currentDelay = initialDelay;
|
|
115
115
|
// Total attempts = initial attempt + retries
|
|
116
|
-
const totalAttempts =
|
|
116
|
+
const totalAttempts = maxAttempts + 1;
|
|
117
117
|
for (let attempt = 1; attempt <= totalAttempts; attempt++) {
|
|
118
118
|
try {
|
|
119
119
|
return await fn();
|
|
@@ -126,14 +126,14 @@ export async function retry(fn, options = {}) {
|
|
|
126
126
|
throw new RetryExhaustedError(`All ${totalAttempts} retry attempts exhausted`, totalAttempts, err);
|
|
127
127
|
}
|
|
128
128
|
// Check if we should retry this error
|
|
129
|
-
if (!
|
|
129
|
+
if (!retryCondition(err)) {
|
|
130
130
|
throw err;
|
|
131
131
|
}
|
|
132
132
|
// Calculate delay with exponential backoff (capped at maxDelay)
|
|
133
|
-
const delayMs = Math.min(currentDelay,
|
|
133
|
+
const delayMs = Math.min(currentDelay, maxDelay);
|
|
134
134
|
// Notify about retry
|
|
135
135
|
if (onRetry) {
|
|
136
|
-
onRetry(
|
|
136
|
+
onRetry(attempt, err);
|
|
137
137
|
}
|
|
138
138
|
// Wait before next attempt
|
|
139
139
|
await delay(delayMs);
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import type { ProviderName } from "../types/index.js";
|
|
2
|
-
declare const SUPPORTED_FORMATS: readonly ["jpeg", "png", "webp"];
|
|
3
|
-
type SupportedFormat = (typeof SUPPORTED_FORMATS)[number];
|
|
1
|
+
import type { CompressionOptions, CompressionResult, ProviderName } from "../types/index.js";
|
|
4
2
|
/**
|
|
5
3
|
* Provider-specific image size limits in bytes
|
|
6
4
|
*/
|
|
7
5
|
export declare const PROVIDER_IMAGE_LIMITS: Record<ProviderName, number>;
|
|
8
|
-
type CompressionOptions = {
|
|
9
|
-
provider: ProviderName;
|
|
10
|
-
quality?: number;
|
|
11
|
-
maxDimension?: number;
|
|
12
|
-
format?: SupportedFormat;
|
|
13
|
-
};
|
|
14
|
-
type CompressionResult = {
|
|
15
|
-
buffer: Buffer;
|
|
16
|
-
originalSize: number;
|
|
17
|
-
compressedSize: number;
|
|
18
|
-
compressionRatio: number;
|
|
19
|
-
metadata: {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
format: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
6
|
/**
|
|
26
7
|
* Compress an image to meet provider-specific size limits
|
|
27
8
|
* @param imageBuffer - Input image buffer
|
|
@@ -42,4 +23,3 @@ export declare function needsCompression(imageBuffer: Buffer, provider: Provider
|
|
|
42
23
|
* @returns Size limit in bytes
|
|
43
24
|
*/
|
|
44
25
|
export declare function getProviderSizeLimit(provider: ProviderName): number;
|
|
45
|
-
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import sharp from "sharp";
|
|
2
2
|
import { withTimeout } from "./async/index.js";
|
|
3
|
-
const SUPPORTED_FORMATS = [
|
|
3
|
+
const SUPPORTED_FORMATS = [
|
|
4
|
+
"jpeg",
|
|
5
|
+
"png",
|
|
6
|
+
"webp",
|
|
7
|
+
];
|
|
4
8
|
const IMAGE_COMPRESSION_TIMEOUT_MS = 30_000;
|
|
5
9
|
/**
|
|
6
10
|
* Provider-specific image size limits in bytes
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Enhanced with multimodal support for images
|
|
5
5
|
*/
|
|
6
6
|
import type { ModelMessage } from "ai";
|
|
7
|
-
import type { MultimodalChatMessage,
|
|
7
|
+
import type { GenerateOptions, MultimodalChatMessage, StreamOptions, TextGenerationOptions } from "../types/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* Type-safe conversion from MultimodalChatMessage[] to ModelMessage[]
|
|
10
10
|
* Filters out invalid content and ensures strict ModelMessage contract compliance
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Redis Utilities for NeuroLink
|
|
3
3
|
* Helper functions for Redis storage operations
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import type { RedisConversationObject, RedisStorageConfig } from "../types/index.js";
|
|
7
|
-
type RedisClient = ReturnType<typeof createClient>;
|
|
5
|
+
import type { RedisClient, RedisConversationObject, RedisStorageConfig } from "../types/index.js";
|
|
8
6
|
/**
|
|
9
7
|
* Get a pooled Redis connection. Multiple callers with the same host:port:db
|
|
10
8
|
* share a single connection, reducing connection count.
|
|
@@ -60,4 +58,3 @@ export declare function scanKeys(client: RedisClient, pattern: string, batchSize
|
|
|
60
58
|
* Get normalized Redis configuration with defaults
|
|
61
59
|
*/
|
|
62
60
|
export declare function getNormalizedConfig(config: RedisStorageConfig): Required<RedisStorageConfig>;
|
|
63
|
-
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolEndEmitter — shared helper for emitting `tool:end` events from
|
|
3
|
+
* AI-SDK `onStepFinish` callbacks.
|
|
4
|
+
*
|
|
5
|
+
* Pipeline B (metrics aggregator) listens for `tool:end` on the NeuroLink
|
|
6
|
+
* EventEmitter. When tools are executed by the AI SDK internally (via
|
|
7
|
+
* `generateText` / `streamText`) the SDK calls `onStepFinish` with the
|
|
8
|
+
* completed tool results. Without this helper those results are silently
|
|
9
|
+
* stored but never surfaced as `tool:end` events, leaving Pipeline B with
|
|
10
|
+
* zero tool spans for AI-SDK-driven tool calls (gaps G5 and S2).
|
|
11
|
+
*
|
|
12
|
+
* @module utils/toolEndEmitter
|
|
13
|
+
*/
|
|
14
|
+
import type { NeuroLinkEvents, StepToolResult, TypedEventEmitter } from "../types/index.js";
|
|
15
|
+
/**
|
|
16
|
+
* Emit a `tool:end` event for every completed tool result in an
|
|
17
|
+
* `onStepFinish` callback.
|
|
18
|
+
*
|
|
19
|
+
* @param emitter - The NeuroLink event emitter (obtained via
|
|
20
|
+
* `neurolink.getEventEmitter()`). When `undefined` the function is a
|
|
21
|
+
* no-op so callers need not guard every call site.
|
|
22
|
+
* @param toolResults - The `toolResults` array from `onStepFinish`. When
|
|
23
|
+
* `undefined` or empty the function is a no-op.
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitToolEndFromStepFinish(emitter: TypedEventEmitter<NeuroLinkEvents> | undefined, toolResults: StepToolResult[] | undefined): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolEndEmitter — shared helper for emitting `tool:end` events from
|
|
3
|
+
* AI-SDK `onStepFinish` callbacks.
|
|
4
|
+
*
|
|
5
|
+
* Pipeline B (metrics aggregator) listens for `tool:end` on the NeuroLink
|
|
6
|
+
* EventEmitter. When tools are executed by the AI SDK internally (via
|
|
7
|
+
* `generateText` / `streamText`) the SDK calls `onStepFinish` with the
|
|
8
|
+
* completed tool results. Without this helper those results are silently
|
|
9
|
+
* stored but never surfaced as `tool:end` events, leaving Pipeline B with
|
|
10
|
+
* zero tool spans for AI-SDK-driven tool calls (gaps G5 and S2).
|
|
11
|
+
*
|
|
12
|
+
* @module utils/toolEndEmitter
|
|
13
|
+
*/
|
|
14
|
+
import { createToolEventPayload } from "../core/toolEvents.js";
|
|
15
|
+
/**
|
|
16
|
+
* Emit a `tool:end` event for every completed tool result in an
|
|
17
|
+
* `onStepFinish` callback.
|
|
18
|
+
*
|
|
19
|
+
* @param emitter - The NeuroLink event emitter (obtained via
|
|
20
|
+
* `neurolink.getEventEmitter()`). When `undefined` the function is a
|
|
21
|
+
* no-op so callers need not guard every call site.
|
|
22
|
+
* @param toolResults - The `toolResults` array from `onStepFinish`. When
|
|
23
|
+
* `undefined` or empty the function is a no-op.
|
|
24
|
+
*/
|
|
25
|
+
export function emitToolEndFromStepFinish(emitter, toolResults) {
|
|
26
|
+
if (!emitter || !toolResults || toolResults.length === 0) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
for (const tr of toolResults) {
|
|
30
|
+
const output = tr.output ?? tr.result;
|
|
31
|
+
const isError = !!tr.error ||
|
|
32
|
+
(output !== null &&
|
|
33
|
+
output !== undefined &&
|
|
34
|
+
typeof output === "object" &&
|
|
35
|
+
"isError" in output &&
|
|
36
|
+
output.isError === true);
|
|
37
|
+
let errorMessage;
|
|
38
|
+
if (isError) {
|
|
39
|
+
if (tr.error) {
|
|
40
|
+
errorMessage = tr.error;
|
|
41
|
+
}
|
|
42
|
+
else if (output && typeof output === "object") {
|
|
43
|
+
const content = output.content;
|
|
44
|
+
if (Array.isArray(content)) {
|
|
45
|
+
const texts = content
|
|
46
|
+
.filter((c) => c.type === "text" && c.text)
|
|
47
|
+
.map((c) => c.text);
|
|
48
|
+
errorMessage =
|
|
49
|
+
texts.length > 0 ? texts.join(" ") : "Tool returned isError: true";
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
errorMessage = "Tool returned isError: true";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
emitter.emit("tool:end", createToolEventPayload(tr.toolName, {
|
|
57
|
+
responseTime: 0,
|
|
58
|
+
success: !isError,
|
|
59
|
+
timestamp: Date.now(),
|
|
60
|
+
result: output,
|
|
61
|
+
error: errorMessage,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=toolEndEmitter.js.map
|