@juspay/neurolink 9.54.5 → 9.54.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/action/actionInputs.d.ts +1 -1
- package/dist/adapters/video/directorPipeline.js +6 -0
- package/dist/adapters/video/vertexVideoHandler.js +6 -0
- package/dist/agent/directTools.d.ts +3 -23
- package/dist/auth/AuthProviderFactory.d.ts +1 -3
- package/dist/auth/anthropicOAuth.d.ts +4 -7
- package/dist/auth/anthropicOAuth.js +23 -0
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/middleware/AuthMiddleware.d.ts +5 -60
- package/dist/auth/middleware/AuthMiddleware.js +3 -0
- package/dist/auth/middleware/rateLimitByUser.d.ts +4 -93
- package/dist/auth/middleware/rateLimitByUser.js +4 -0
- package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/auth/providers/CognitoProvider.js +3 -0
- package/dist/auth/providers/KeycloakProvider.js +3 -0
- package/dist/auth/providers/auth0.d.ts +1 -1
- package/dist/auth/sessionManager.d.ts +2 -0
- package/dist/auth/sessionManager.js +53 -11
- package/dist/auth/tokenStore.d.ts +2 -1
- package/dist/auth/tokenStore.js +45 -4
- package/dist/autoresearch/tools.d.ts +1 -16
- package/dist/browser/neurolink.min.js +353 -353
- package/dist/cli/commands/config.d.ts +3 -123
- package/dist/cli/commands/config.js +4 -2
- package/dist/cli/commands/evaluate.d.ts +1 -19
- package/dist/cli/commands/proxy.d.ts +1 -1
- package/dist/cli/commands/proxy.js +3 -0
- package/dist/cli/commands/rag.js +3 -0
- package/dist/cli/commands/setup-anthropic.d.ts +2 -6
- package/dist/cli/commands/setup-anthropic.js +1 -1
- package/dist/cli/commands/setup-azure.d.ts +2 -6
- package/dist/cli/commands/setup-azure.js +1 -1
- package/dist/cli/commands/setup-bedrock.d.ts +2 -6
- package/dist/cli/commands/setup-bedrock.js +1 -1
- package/dist/cli/commands/setup-gcp.d.ts +2 -6
- package/dist/cli/commands/setup-google-ai.d.ts +2 -6
- package/dist/cli/commands/setup-google-ai.js +1 -1
- package/dist/cli/commands/setup-huggingface.d.ts +1 -5
- package/dist/cli/commands/setup-mistral.d.ts +1 -5
- package/dist/cli/commands/setup-openai.d.ts +2 -6
- package/dist/cli/commands/setup-openai.js +1 -1
- package/dist/cli/commands/setup.d.ts +1 -8
- package/dist/cli/commands/task.js +1 -0
- package/dist/cli/commands/voiceServer.d.ts +1 -4
- package/dist/cli/loop/session.js +31 -10
- package/dist/cli/utils/interactiveSetup.d.ts +2 -15
- package/dist/cli/utils/videoFileUtils.d.ts +1 -15
- package/dist/client/aiSdkAdapter.d.ts +1 -1
- package/dist/client/aiSdkAdapter.js +1 -0
- package/dist/client/httpClient.d.ts +2 -2
- package/dist/client/httpClient.js +13 -0
- package/dist/client/sseClient.d.ts +2 -2
- package/dist/client/sseClient.js +29 -0
- package/dist/client/streamingClient.d.ts +2 -0
- package/dist/client/streamingClient.js +19 -0
- package/dist/client/wsClient.d.ts +7 -2
- package/dist/client/wsClient.js +90 -10
- package/dist/context/budgetChecker.js +3 -1
- package/dist/context/contextCompactor.js +163 -143
- package/dist/context/fileSummarizationService.d.ts +1 -9
- package/dist/context/summarizationEngine.js +29 -16
- package/dist/core/baseProvider.js +124 -153
- package/dist/core/infrastructure/baseRegistry.d.ts +1 -7
- package/dist/core/modules/GenerationHandler.d.ts +3 -2
- package/dist/core/modules/GenerationHandler.js +9 -1
- package/dist/core/modules/StreamHandler.js +9 -0
- package/dist/core/modules/ToolsManager.js +18 -2
- package/dist/core/toolEvents.d.ts +0 -1
- package/dist/evaluation/BatchEvaluator.d.ts +1 -97
- package/dist/evaluation/EvaluationAggregator.d.ts +1 -118
- package/dist/evaluation/EvaluatorFactory.d.ts +1 -13
- package/dist/evaluation/EvaluatorRegistry.d.ts +1 -50
- package/dist/evaluation/errors/EvaluationError.d.ts +2 -27
- package/dist/evaluation/hooks/langfuseAdapter.d.ts +1 -39
- package/dist/evaluation/hooks/observabilityHooks.d.ts +3 -55
- package/dist/evaluation/hooks/observabilityHooks.js +3 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +7 -7
- package/dist/evaluation/ragasEvaluator.js +54 -37
- package/dist/evaluation/reporting/metricsCollector.d.ts +1 -60
- package/dist/evaluation/reporting/reportGenerator.d.ts +1 -17
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
- package/dist/evaluation/scorers/rule/formatScorer.d.ts +1 -42
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
- package/dist/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
- package/dist/factories/providerFactory.d.ts +1 -16
- package/dist/factories/providerFactory.js +2 -0
- package/dist/image-gen/ImageGenService.d.ts +3 -0
- package/dist/image-gen/ImageGenService.js +3 -0
- package/dist/lib/action/actionInputs.d.ts +1 -1
- package/dist/lib/adapters/video/directorPipeline.js +6 -0
- package/dist/lib/adapters/video/vertexVideoHandler.js +6 -0
- package/dist/lib/agent/directTools.d.ts +3 -23
- package/dist/lib/auth/AuthProviderFactory.d.ts +1 -3
- package/dist/lib/auth/anthropicOAuth.d.ts +4 -7
- package/dist/lib/auth/anthropicOAuth.js +23 -0
- package/dist/lib/auth/errors.d.ts +1 -1
- package/dist/lib/auth/index.d.ts +11 -0
- package/dist/lib/auth/index.js +14 -0
- package/dist/lib/auth/middleware/AuthMiddleware.d.ts +5 -60
- package/dist/lib/auth/middleware/AuthMiddleware.js +3 -0
- package/dist/lib/auth/middleware/rateLimitByUser.d.ts +4 -93
- package/dist/lib/auth/middleware/rateLimitByUser.js +4 -0
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/lib/auth/providers/CognitoProvider.js +3 -0
- package/dist/lib/auth/providers/KeycloakProvider.js +3 -0
- package/dist/lib/auth/providers/auth0.d.ts +1 -1
- package/dist/lib/auth/sessionManager.d.ts +2 -0
- package/dist/lib/auth/sessionManager.js +53 -11
- package/dist/lib/auth/tokenStore.d.ts +2 -1
- package/dist/lib/auth/tokenStore.js +45 -4
- package/dist/lib/autoresearch/tools.d.ts +1 -16
- package/dist/lib/client/aiSdkAdapter.d.ts +1 -1
- package/dist/lib/client/aiSdkAdapter.js +1 -0
- package/dist/lib/client/httpClient.d.ts +2 -2
- package/dist/lib/client/httpClient.js +13 -0
- package/dist/lib/client/sseClient.d.ts +2 -2
- package/dist/lib/client/sseClient.js +29 -0
- package/dist/lib/client/streamingClient.d.ts +2 -0
- package/dist/lib/client/streamingClient.js +19 -0
- package/dist/lib/client/wsClient.d.ts +7 -2
- package/dist/lib/client/wsClient.js +90 -10
- package/dist/lib/context/budgetChecker.js +3 -1
- package/dist/lib/context/contextCompactor.js +163 -143
- package/dist/lib/context/fileSummarizationService.d.ts +1 -9
- package/dist/lib/context/summarizationEngine.js +29 -16
- package/dist/lib/core/baseProvider.js +124 -153
- package/dist/lib/core/infrastructure/baseRegistry.d.ts +1 -7
- package/dist/lib/core/modules/GenerationHandler.d.ts +3 -2
- package/dist/lib/core/modules/GenerationHandler.js +9 -1
- package/dist/lib/core/modules/StreamHandler.js +9 -0
- package/dist/lib/core/modules/ToolsManager.js +18 -2
- package/dist/lib/core/toolEvents.d.ts +0 -1
- package/dist/lib/evaluation/BatchEvaluator.d.ts +1 -97
- package/dist/lib/evaluation/EvaluationAggregator.d.ts +1 -118
- package/dist/lib/evaluation/EvaluatorFactory.d.ts +1 -13
- package/dist/lib/evaluation/EvaluatorRegistry.d.ts +1 -50
- package/dist/lib/evaluation/errors/EvaluationError.d.ts +2 -27
- package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +1 -39
- package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +3 -55
- package/dist/lib/evaluation/hooks/observabilityHooks.js +3 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +7 -61
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +7 -7
- package/dist/lib/evaluation/ragasEvaluator.js +54 -37
- package/dist/lib/evaluation/reporting/metricsCollector.d.ts +1 -60
- package/dist/lib/evaluation/reporting/reportGenerator.d.ts +1 -17
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +1 -29
- package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +1 -42
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +1 -19
- package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +1 -33
- package/dist/lib/factories/providerFactory.d.ts +1 -16
- package/dist/lib/factories/providerFactory.js +2 -0
- package/dist/lib/image-gen/ImageGenService.d.ts +3 -0
- package/dist/lib/image-gen/ImageGenService.js +3 -0
- package/dist/lib/mcp/batching/requestBatcher.js +99 -73
- package/dist/lib/mcp/httpRateLimiter.js +3 -1
- package/dist/lib/mcp/httpRetryHandler.js +3 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -1
- package/dist/lib/mcp/multiServerManager.d.ts +1 -14
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +70 -57
- package/dist/lib/mcp/toolRegistry.js +11 -1
- package/dist/lib/memory/hippocampusInitializer.d.ts +1 -2
- package/dist/lib/memory/hippocampusInitializer.js +1 -1
- package/dist/lib/memory/memoryRetrievalTools.js +182 -141
- package/dist/lib/models/anthropicModels.d.ts +0 -1
- package/dist/lib/models/anthropicModels.js +1 -0
- package/dist/lib/neurolink.js +237 -41
- package/dist/lib/observability/exporterRegistry.d.ts +3 -22
- package/dist/lib/observability/exporters/sentryExporter.js +1 -0
- package/dist/lib/observability/metricsAggregator.d.ts +1 -31
- package/dist/lib/observability/retryPolicy.d.ts +0 -1
- package/dist/lib/observability/sampling/samplers.d.ts +0 -1
- package/dist/lib/observability/spanProcessor.d.ts +0 -1
- package/dist/lib/observability/tokenTracker.d.ts +7 -16
- package/dist/lib/observability/tokenTracker.js +6 -4
- package/dist/lib/observability/utils/spanSerializer.d.ts +5 -1
- package/dist/lib/observability/utils/spanSerializer.js +24 -4
- package/dist/lib/processors/base/BaseFileProcessor.js +66 -53
- package/dist/lib/processors/document/ExcelProcessor.d.ts +1 -1
- package/dist/lib/processors/errors/errorHelpers.d.ts +1 -31
- package/dist/lib/processors/errors/errorSerializer.d.ts +1 -45
- package/dist/lib/processors/registry/ProcessorRegistry.js +17 -6
- package/dist/lib/providers/amazonBedrock.js +189 -15
- package/dist/lib/providers/amazonSagemaker.js +25 -11
- package/dist/lib/providers/anthropic.js +13 -0
- package/dist/lib/providers/azureOpenai.js +2 -0
- package/dist/lib/providers/googleAiStudio.js +82 -0
- package/dist/lib/providers/googleNativeGemini3.d.ts +1 -2
- package/dist/lib/providers/googleVertex.js +52 -0
- package/dist/lib/providers/huggingFace.js +2 -0
- package/dist/lib/providers/litellm.js +2 -0
- package/dist/lib/providers/mistral.js +2 -0
- package/dist/lib/providers/ollama.js +84 -5
- package/dist/lib/providers/openAI.d.ts +2 -0
- package/dist/lib/providers/openAI.js +17 -6
- package/dist/lib/providers/openRouter.js +2 -0
- package/dist/lib/providers/openaiCompatible.js +2 -0
- package/dist/lib/providers/sagemaker/detection.d.ts +1 -33
- package/dist/lib/providers/sagemaker/diagnostics.d.ts +1 -25
- package/dist/lib/providers/sagemaker/language-model.d.ts +1 -1
- package/dist/lib/proxy/proxyConfig.js +4 -0
- package/dist/lib/proxy/proxyEnv.d.ts +1 -17
- package/dist/lib/proxy/proxyHealth.d.ts +0 -1
- package/dist/lib/proxy/proxyTracer.d.ts +1 -36
- package/dist/lib/proxy/proxyTracer.js +9 -0
- package/dist/lib/proxy/quietDetector.d.ts +1 -7
- package/dist/lib/proxy/rawStreamCapture.d.ts +1 -10
- package/dist/lib/proxy/requestLogger.d.ts +1 -21
- package/dist/lib/proxy/routingPolicy.d.ts +1 -2
- package/dist/lib/proxy/sseInterceptor.d.ts +1 -66
- package/dist/lib/proxy/sseInterceptor.js +6 -0
- package/dist/lib/proxy/updateChecker.d.ts +1 -6
- package/dist/lib/proxy/updateState.d.ts +1 -12
- package/dist/lib/rag/chunkers/BaseChunker.js +36 -22
- package/dist/lib/rag/chunking/jsonChunker.d.ts +1 -1
- package/dist/lib/rag/errors/RAGError.d.ts +1 -2
- package/dist/lib/rag/ragIntegration.js +45 -32
- package/dist/lib/rag/reranker/reranker.js +151 -122
- package/dist/lib/rag/retrieval/vectorQueryTool.js +79 -65
- package/dist/lib/sdk/toolRegistration.d.ts +10 -44
- package/dist/lib/sdk/toolRegistration.js +1 -1
- package/dist/lib/server/middleware/abortSignal.d.ts +1 -11
- package/dist/lib/server/middleware/auth.d.ts +1 -21
- package/dist/lib/server/middleware/auth.js +12 -0
- package/dist/lib/server/middleware/common.js +48 -32
- package/dist/lib/server/middleware/deprecation.d.ts +1 -20
- package/dist/lib/server/middleware/rateLimit.d.ts +1 -75
- package/dist/lib/server/middleware/validation.d.ts +3 -81
- package/dist/lib/server/middleware/validation.js +3 -0
- package/dist/lib/server/openapi/generator.d.ts +1 -47
- package/dist/lib/server/routes/agentRoutes.js +112 -57
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +1 -6
- package/dist/lib/server/routes/claudeProxyRoutes.js +127 -13
- package/dist/lib/server/routes/healthRoutes.js +58 -12
- package/dist/lib/server/routes/index.d.ts +1 -26
- package/dist/lib/server/routes/mcpRoutes.js +40 -7
- package/dist/lib/server/routes/memoryRoutes.js +22 -7
- package/dist/lib/server/routes/openApiRoutes.js +30 -6
- package/dist/lib/server/routes/toolRoutes.js +140 -68
- package/dist/lib/server/streaming/dataStream.d.ts +1 -35
- package/dist/lib/server/streaming/dataStream.js +15 -0
- package/dist/lib/services/server/ai/observability/instrumentation.js +114 -14
- package/dist/lib/session/globalSessionState.d.ts +1 -10
- package/dist/lib/tasks/tools/taskTools.d.ts +2 -2
- package/dist/lib/telemetry/traceContext.d.ts +9 -0
- package/dist/lib/telemetry/traceContext.js +19 -0
- package/dist/lib/telemetry/tracers.d.ts +2 -0
- package/dist/lib/telemetry/tracers.js +2 -0
- package/dist/lib/types/action.d.ts +2 -0
- package/dist/lib/types/artifact.d.ts +7 -0
- package/dist/lib/types/auth.d.ts +125 -18
- package/dist/lib/types/autoresearch.d.ts +12 -0
- package/dist/lib/types/cli.d.ts +415 -0
- package/dist/lib/types/client.d.ts +34 -0
- package/dist/lib/types/common.d.ts +12 -41
- package/dist/lib/types/context.d.ts +5 -0
- package/dist/lib/types/evaluation.d.ts +332 -1
- package/dist/lib/types/file.d.ts +4 -0
- package/dist/lib/types/mcp.d.ts +102 -2
- package/dist/lib/types/middleware.d.ts +116 -0
- package/dist/lib/types/multimodal.d.ts +65 -0
- package/dist/lib/types/observability.d.ts +81 -0
- package/dist/lib/types/processor.d.ts +47 -0
- package/dist/lib/types/providers.d.ts +120 -16
- package/dist/lib/types/proxy.d.ts +321 -1
- package/dist/lib/types/rag.d.ts +22 -0
- package/dist/lib/types/scorer.d.ts +141 -0
- package/dist/lib/types/server.d.ts +99 -0
- package/dist/lib/types/span.d.ts +2 -1
- package/dist/lib/types/span.js +1 -0
- package/dist/lib/types/tools.d.ts +44 -0
- package/dist/lib/types/tts.d.ts +6 -0
- package/dist/lib/types/utilities.d.ts +22 -0
- package/dist/lib/types/workflow.d.ts +18 -0
- package/dist/lib/utils/async/retry.d.ts +2 -8
- package/dist/lib/utils/async/retry.js +9 -9
- package/dist/lib/utils/imageCompressor.d.ts +1 -21
- package/dist/lib/utils/imageCompressor.js +5 -1
- package/dist/lib/utils/messageBuilder.d.ts +1 -1
- package/dist/lib/utils/redis.d.ts +1 -4
- package/dist/lib/utils/sanitizers/filename.d.ts +0 -1
- package/dist/lib/utils/toolEndEmitter.d.ts +25 -0
- package/dist/lib/utils/toolEndEmitter.js +65 -0
- package/dist/lib/workflow/config.d.ts +7 -32
- package/dist/lib/workflow/core/ensembleExecutor.js +28 -0
- package/dist/lib/workflow/core/judgeScorer.js +23 -0
- package/dist/lib/workflow/core/responseConditioner.js +17 -0
- package/dist/lib/workflow/core/workflowRunner.d.ts +1 -19
- package/dist/lib/workflow/core/workflowRunner.js +202 -147
- package/dist/mcp/batching/requestBatcher.js +99 -73
- package/dist/mcp/httpRateLimiter.js +3 -1
- package/dist/mcp/httpRetryHandler.js +3 -1
- package/dist/mcp/mcpClientFactory.js +3 -1
- package/dist/mcp/multiServerManager.d.ts +1 -14
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -1
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +1 -0
- package/dist/mcp/toolDiscoveryService.js +70 -57
- package/dist/mcp/toolRegistry.js +11 -1
- package/dist/memory/hippocampusInitializer.d.ts +1 -2
- package/dist/memory/hippocampusInitializer.js +1 -1
- package/dist/memory/memoryRetrievalTools.js +182 -141
- package/dist/models/anthropicModels.d.ts +0 -1
- package/dist/models/anthropicModels.js +1 -0
- package/dist/neurolink.js +237 -41
- package/dist/observability/exporterRegistry.d.ts +3 -22
- package/dist/observability/exporters/sentryExporter.js +1 -0
- package/dist/observability/metricsAggregator.d.ts +1 -31
- package/dist/observability/retryPolicy.d.ts +0 -1
- package/dist/observability/sampling/samplers.d.ts +0 -1
- package/dist/observability/spanProcessor.d.ts +0 -1
- package/dist/observability/tokenTracker.d.ts +7 -16
- package/dist/observability/tokenTracker.js +6 -4
- package/dist/observability/utils/spanSerializer.d.ts +5 -1
- package/dist/observability/utils/spanSerializer.js +24 -4
- package/dist/processors/base/BaseFileProcessor.js +66 -53
- package/dist/processors/document/ExcelProcessor.d.ts +1 -1
- package/dist/processors/errors/errorHelpers.d.ts +1 -31
- package/dist/processors/errors/errorSerializer.d.ts +1 -45
- package/dist/processors/registry/ProcessorRegistry.js +17 -6
- package/dist/providers/amazonBedrock.js +189 -15
- package/dist/providers/amazonSagemaker.js +25 -11
- package/dist/providers/anthropic.js +13 -0
- package/dist/providers/azureOpenai.js +2 -0
- package/dist/providers/googleAiStudio.js +82 -0
- package/dist/providers/googleNativeGemini3.d.ts +1 -2
- package/dist/providers/googleVertex.js +52 -0
- package/dist/providers/huggingFace.js +2 -0
- package/dist/providers/litellm.js +2 -0
- package/dist/providers/mistral.js +2 -0
- package/dist/providers/ollama.js +84 -5
- package/dist/providers/openAI.d.ts +2 -0
- package/dist/providers/openAI.js +17 -6
- package/dist/providers/openRouter.js +2 -0
- package/dist/providers/openaiCompatible.js +2 -0
- package/dist/providers/sagemaker/detection.d.ts +1 -33
- package/dist/providers/sagemaker/diagnostics.d.ts +1 -25
- package/dist/providers/sagemaker/language-model.d.ts +1 -1
- package/dist/proxy/proxyConfig.js +4 -0
- package/dist/proxy/proxyEnv.d.ts +1 -17
- package/dist/proxy/proxyHealth.d.ts +0 -1
- package/dist/proxy/proxyTracer.d.ts +1 -36
- package/dist/proxy/proxyTracer.js +9 -0
- package/dist/proxy/quietDetector.d.ts +1 -7
- package/dist/proxy/rawStreamCapture.d.ts +1 -10
- package/dist/proxy/requestLogger.d.ts +1 -21
- package/dist/proxy/routingPolicy.d.ts +1 -2
- package/dist/proxy/sseInterceptor.d.ts +1 -66
- package/dist/proxy/sseInterceptor.js +6 -0
- package/dist/proxy/updateChecker.d.ts +1 -6
- package/dist/proxy/updateState.d.ts +1 -12
- package/dist/rag/chunkers/BaseChunker.js +36 -22
- package/dist/rag/chunking/jsonChunker.d.ts +1 -1
- package/dist/rag/errors/RAGError.d.ts +1 -2
- package/dist/rag/ragIntegration.js +45 -32
- package/dist/rag/reranker/reranker.js +151 -122
- package/dist/rag/retrieval/vectorQueryTool.js +79 -65
- package/dist/sdk/toolRegistration.d.ts +10 -44
- package/dist/sdk/toolRegistration.js +1 -1
- package/dist/server/middleware/abortSignal.d.ts +1 -11
- package/dist/server/middleware/auth.d.ts +1 -21
- package/dist/server/middleware/auth.js +12 -0
- package/dist/server/middleware/common.js +48 -32
- package/dist/server/middleware/deprecation.d.ts +1 -20
- package/dist/server/middleware/rateLimit.d.ts +1 -75
- package/dist/server/middleware/validation.d.ts +3 -81
- package/dist/server/middleware/validation.js +3 -0
- package/dist/server/openapi/generator.d.ts +1 -47
- package/dist/server/routes/agentRoutes.js +112 -57
- package/dist/server/routes/claudeProxyRoutes.d.ts +1 -6
- package/dist/server/routes/claudeProxyRoutes.js +127 -13
- package/dist/server/routes/healthRoutes.js +58 -12
- package/dist/server/routes/index.d.ts +1 -26
- package/dist/server/routes/mcpRoutes.js +40 -7
- package/dist/server/routes/memoryRoutes.js +22 -7
- package/dist/server/routes/openApiRoutes.js +30 -6
- package/dist/server/routes/toolRoutes.js +140 -68
- package/dist/server/streaming/dataStream.d.ts +1 -35
- package/dist/server/streaming/dataStream.js +15 -0
- package/dist/services/server/ai/observability/instrumentation.js +114 -14
- package/dist/session/globalSessionState.d.ts +1 -10
- package/dist/tasks/tools/taskTools.d.ts +2 -2
- package/dist/telemetry/traceContext.d.ts +9 -0
- package/dist/telemetry/traceContext.js +18 -0
- package/dist/telemetry/tracers.d.ts +2 -0
- package/dist/telemetry/tracers.js +2 -0
- package/dist/types/action.d.ts +2 -0
- package/dist/types/artifact.d.ts +7 -0
- package/dist/types/auth.d.ts +125 -18
- package/dist/types/autoresearch.d.ts +12 -0
- package/dist/types/cli.d.ts +415 -0
- package/dist/types/client.d.ts +34 -0
- package/dist/types/common.d.ts +12 -41
- package/dist/types/context.d.ts +5 -0
- package/dist/types/evaluation.d.ts +332 -1
- package/dist/types/file.d.ts +4 -0
- package/dist/types/mcp.d.ts +102 -2
- package/dist/types/middleware.d.ts +116 -0
- package/dist/types/multimodal.d.ts +65 -0
- package/dist/types/observability.d.ts +81 -0
- package/dist/types/processor.d.ts +47 -0
- package/dist/types/providers.d.ts +120 -16
- package/dist/types/proxy.d.ts +321 -1
- package/dist/types/rag.d.ts +22 -0
- package/dist/types/scorer.d.ts +141 -0
- package/dist/types/server.d.ts +99 -0
- package/dist/types/span.d.ts +2 -1
- package/dist/types/span.js +1 -0
- package/dist/types/tools.d.ts +44 -0
- package/dist/types/tts.d.ts +6 -0
- package/dist/types/utilities.d.ts +22 -0
- package/dist/types/workflow.d.ts +18 -0
- package/dist/utils/async/retry.d.ts +2 -8
- package/dist/utils/async/retry.js +9 -9
- package/dist/utils/imageCompressor.d.ts +1 -21
- package/dist/utils/imageCompressor.js +5 -1
- package/dist/utils/messageBuilder.d.ts +1 -1
- package/dist/utils/redis.d.ts +1 -4
- package/dist/utils/sanitizers/filename.d.ts +0 -1
- package/dist/utils/toolEndEmitter.d.ts +25 -0
- package/dist/utils/toolEndEmitter.js +64 -0
- package/dist/workflow/config.d.ts +4 -29
- package/dist/workflow/core/ensembleExecutor.js +28 -0
- package/dist/workflow/core/judgeScorer.js +23 -0
- package/dist/workflow/core/responseConditioner.js +17 -0
- package/dist/workflow/core/workflowRunner.d.ts +1 -19
- package/dist/workflow/core/workflowRunner.js +202 -147
- package/package.json +2 -1
|
@@ -419,3 +419,84 @@ export type SpanOptions = {
|
|
|
419
419
|
kind?: import("@opentelemetry/api").SpanKind;
|
|
420
420
|
attributes?: Record<string, string | number | boolean | undefined>;
|
|
421
421
|
};
|
|
422
|
+
/** Trace + parent span IDs used to correlate metric records with spans. */
|
|
423
|
+
export type MetricsTraceContext = {
|
|
424
|
+
traceId: string;
|
|
425
|
+
parentSpanId: string;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Runtime state for the observability exporter circuit breaker.
|
|
429
|
+
* Prefixed to disambiguate from the richer MCP CircuitBreakerState in mcp.ts.
|
|
430
|
+
*/
|
|
431
|
+
export type ObservabilityCircuitBreakerState = {
|
|
432
|
+
failures: number;
|
|
433
|
+
lastFailure: number;
|
|
434
|
+
state: "closed" | "open" | "half-open";
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* Minimal config for the observability exporter circuit breaker.
|
|
438
|
+
* Prefixed to disambiguate from the richer MCP CircuitBreakerConfig in mcp.ts.
|
|
439
|
+
*/
|
|
440
|
+
export type ObservabilityCircuitBreakerConfig = {
|
|
441
|
+
failureThreshold: number;
|
|
442
|
+
resetTimeout: number;
|
|
443
|
+
};
|
|
444
|
+
/** Minimal view of the dynamically-imported @sentry/node module. */
|
|
445
|
+
export type SentryModule = {
|
|
446
|
+
init: (options: {
|
|
447
|
+
dsn: string;
|
|
448
|
+
tracesSampleRate: number;
|
|
449
|
+
release?: string;
|
|
450
|
+
environment: string;
|
|
451
|
+
}) => void;
|
|
452
|
+
withScope: (callback: (scope: SentryScope) => void) => void;
|
|
453
|
+
captureException: (error: Error) => void;
|
|
454
|
+
startInactiveSpan: (options: {
|
|
455
|
+
name: string;
|
|
456
|
+
op: string;
|
|
457
|
+
startTime: number;
|
|
458
|
+
attributes?: Record<string, unknown>;
|
|
459
|
+
}) => {
|
|
460
|
+
end: (timestamp?: number) => void;
|
|
461
|
+
};
|
|
462
|
+
flush: (timeout: number) => Promise<boolean>;
|
|
463
|
+
close: (timeout: number) => Promise<boolean>;
|
|
464
|
+
};
|
|
465
|
+
/** Sentry scope surface used by SentryExporter.withScope callbacks. */
|
|
466
|
+
export type SentryScope = {
|
|
467
|
+
setTags: (tags: Record<string, string>) => void;
|
|
468
|
+
setContext: (name: string, context: Record<string, unknown>) => void;
|
|
469
|
+
setUser: (user: {
|
|
470
|
+
id: string;
|
|
471
|
+
}) => void;
|
|
472
|
+
};
|
|
473
|
+
/** Aggregated metrics for a single time window. */
|
|
474
|
+
export type TimeWindowStats = {
|
|
475
|
+
windowStart: Date;
|
|
476
|
+
windowEnd: Date;
|
|
477
|
+
windowDurationMs: number;
|
|
478
|
+
requestCount: number;
|
|
479
|
+
errorCount: number;
|
|
480
|
+
successRate: number;
|
|
481
|
+
throughput: number;
|
|
482
|
+
latency: LatencyStats;
|
|
483
|
+
tokens: TokenUsageStats;
|
|
484
|
+
costByProvider: Map<string, ProviderCostStats>;
|
|
485
|
+
costByModel: Map<string, ModelCostStats>;
|
|
486
|
+
};
|
|
487
|
+
/** Configuration for MetricsAggregator. */
|
|
488
|
+
export type MetricsAggregatorConfig = {
|
|
489
|
+
maxSpansRetained?: number;
|
|
490
|
+
enableTimeWindows?: boolean;
|
|
491
|
+
timeWindowMs?: number;
|
|
492
|
+
maxTimeWindows?: number;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Per-million-token pricing used by the observability TokenTracker.
|
|
496
|
+
* Prefixed to disambiguate from the richer providers.ts ModelPricing.
|
|
497
|
+
*/
|
|
498
|
+
export type ObservabilityModelPricing = {
|
|
499
|
+
inputPricePerMillion: number;
|
|
500
|
+
outputPricePerMillion: number;
|
|
501
|
+
cachedInputPricePerMillion?: number;
|
|
502
|
+
};
|
|
@@ -823,3 +823,50 @@ export type BatchFileProcessingResult = {
|
|
|
823
823
|
reason: string;
|
|
824
824
|
}>;
|
|
825
825
|
};
|
|
826
|
+
/** Alias for ExcelJS.CellValue to avoid leaking exceljs types across files. */
|
|
827
|
+
export type CellValue = import("exceljs").CellValue;
|
|
828
|
+
/** Summary of file processing operations. */
|
|
829
|
+
export type FileProcessingSummary = {
|
|
830
|
+
totalFiles: number;
|
|
831
|
+
processedFiles: Array<{
|
|
832
|
+
filename: string;
|
|
833
|
+
size?: number;
|
|
834
|
+
type?: string;
|
|
835
|
+
}>;
|
|
836
|
+
failedFiles: Array<{
|
|
837
|
+
filename: string;
|
|
838
|
+
error: FileProcessingError;
|
|
839
|
+
}>;
|
|
840
|
+
skippedFiles: Array<{
|
|
841
|
+
filename: string;
|
|
842
|
+
reason: string;
|
|
843
|
+
suggestedAlternative?: string;
|
|
844
|
+
}>;
|
|
845
|
+
warnings: Array<{
|
|
846
|
+
filename: string;
|
|
847
|
+
message: string;
|
|
848
|
+
}>;
|
|
849
|
+
};
|
|
850
|
+
/** Serialized error representation with full context. */
|
|
851
|
+
export type SerializedError = {
|
|
852
|
+
errorId: string;
|
|
853
|
+
errorFingerprint: string;
|
|
854
|
+
errorType: string;
|
|
855
|
+
message: string;
|
|
856
|
+
stack?: string;
|
|
857
|
+
stackFrames?: string[];
|
|
858
|
+
statusCode?: number;
|
|
859
|
+
isOperational?: boolean;
|
|
860
|
+
isRetryable?: boolean;
|
|
861
|
+
code?: string;
|
|
862
|
+
metadata?: Record<string, unknown>;
|
|
863
|
+
cause?: SerializedError;
|
|
864
|
+
timestamp: string;
|
|
865
|
+
};
|
|
866
|
+
/** Options for error serialization. */
|
|
867
|
+
export type SerializeOptions = {
|
|
868
|
+
includeStack?: boolean;
|
|
869
|
+
maxDepth?: number;
|
|
870
|
+
filterStacks?: boolean;
|
|
871
|
+
context?: Record<string, unknown>;
|
|
872
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider-specific type definitions for NeuroLink
|
|
3
3
|
*/
|
|
4
|
-
import type { UnknownRecord, JsonValue } from "./common.js";
|
|
4
|
+
import type { UnknownRecord, JsonValue, StreamingCapability } from "./common.js";
|
|
5
|
+
import type { ProviderError } from "./errors.js";
|
|
5
6
|
import { AIProviderName, AnthropicModels, BedrockModels, GoogleAIModels, OpenAIModels, VertexModels } from "../constants/enums.js";
|
|
6
7
|
import type { Tool } from "ai";
|
|
7
8
|
import type { ValidationSchema } from "./aliases.js";
|
|
@@ -443,21 +444,6 @@ export type ProviderCreationError = {
|
|
|
443
444
|
* Provider factory function type
|
|
444
445
|
*/
|
|
445
446
|
export type ProviderFactory = (modelName?: string, providerName?: string, sdk?: unknown) => Promise<unknown>;
|
|
446
|
-
/**
|
|
447
|
-
* Provider constructor type
|
|
448
|
-
*/
|
|
449
|
-
export type ProviderConstructor = {
|
|
450
|
-
new (modelName?: string, providerName?: string, sdk?: unknown): unknown;
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Provider registration entry
|
|
454
|
-
*/
|
|
455
|
-
export type ProviderRegistration = {
|
|
456
|
-
name: string;
|
|
457
|
-
constructor: ProviderConstructor | ProviderFactory;
|
|
458
|
-
capabilities?: ProviderCapabilities;
|
|
459
|
-
defaultConfig?: IndividualProviderConfig;
|
|
460
|
-
};
|
|
461
447
|
/**
|
|
462
448
|
* Configuration options for the provider registry
|
|
463
449
|
*/
|
|
@@ -1473,3 +1459,121 @@ export type ToolWithLegacyParams = {
|
|
|
1473
1459
|
/** Legacy field from AI SDK v3/v4 */
|
|
1474
1460
|
parameters?: unknown;
|
|
1475
1461
|
};
|
|
1462
|
+
/**
|
|
1463
|
+
* Provider constructor interface - supports both sync constructors and async
|
|
1464
|
+
* factory functions.
|
|
1465
|
+
*/
|
|
1466
|
+
export type ProviderConstructor = {
|
|
1467
|
+
new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string): AIProvider;
|
|
1468
|
+
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string) => Promise<AIProvider>);
|
|
1469
|
+
/** Provider registration entry held by ProviderFactory. */
|
|
1470
|
+
export type ProviderRegistration = {
|
|
1471
|
+
constructor: ProviderConstructor;
|
|
1472
|
+
defaultModel?: string;
|
|
1473
|
+
aliases?: string[];
|
|
1474
|
+
};
|
|
1475
|
+
/** Minimal NeuroLink-like instance accepted by the image generation service. */
|
|
1476
|
+
export type NeuroLinkInstance = {
|
|
1477
|
+
generate: (options: Record<string, unknown>) => Promise<unknown>;
|
|
1478
|
+
};
|
|
1479
|
+
/** ProviderError enriched with HTTP response fields from Ollama. */
|
|
1480
|
+
export type OllamaHttpError = ProviderError & {
|
|
1481
|
+
statusCode: number;
|
|
1482
|
+
statusText: string;
|
|
1483
|
+
responseBody: string;
|
|
1484
|
+
};
|
|
1485
|
+
/** Model type detection result. */
|
|
1486
|
+
export type ModelDetectionResult = {
|
|
1487
|
+
type: StreamingCapability["modelType"];
|
|
1488
|
+
confidence: number;
|
|
1489
|
+
evidence: string[];
|
|
1490
|
+
suggestedConfig?: Partial<SageMakerModelConfig>;
|
|
1491
|
+
};
|
|
1492
|
+
/** Endpoint health and metadata information. */
|
|
1493
|
+
export type EndpointHealth = {
|
|
1494
|
+
status: "healthy" | "unhealthy" | "unknown";
|
|
1495
|
+
responseTime: number;
|
|
1496
|
+
metadata?: Record<string, unknown>;
|
|
1497
|
+
modelInfo?: {
|
|
1498
|
+
name?: string;
|
|
1499
|
+
version?: string;
|
|
1500
|
+
framework?: string;
|
|
1501
|
+
architecture?: string;
|
|
1502
|
+
};
|
|
1503
|
+
};
|
|
1504
|
+
/** Configuration object for a detection test wrapper. */
|
|
1505
|
+
export type DetectionTestConfig = {
|
|
1506
|
+
test: () => Promise<void>;
|
|
1507
|
+
index: number;
|
|
1508
|
+
testName: string;
|
|
1509
|
+
endpointName: string;
|
|
1510
|
+
semaphore: {
|
|
1511
|
+
acquire(): Promise<void>;
|
|
1512
|
+
release(): void;
|
|
1513
|
+
};
|
|
1514
|
+
incrementRateLimit: () => void;
|
|
1515
|
+
maxRateLimitRetries: number;
|
|
1516
|
+
rateLimitState: {
|
|
1517
|
+
count: number;
|
|
1518
|
+
};
|
|
1519
|
+
};
|
|
1520
|
+
/** Configuration object for parallel detection test execution. */
|
|
1521
|
+
export type ParallelDetectionConfig = {
|
|
1522
|
+
maxConcurrentTests: number;
|
|
1523
|
+
maxRateLimitRetries: number;
|
|
1524
|
+
initialRateLimitCount: number;
|
|
1525
|
+
};
|
|
1526
|
+
/** Individual SageMaker diagnostic result. */
|
|
1527
|
+
export type DiagnosticResult = {
|
|
1528
|
+
name: string;
|
|
1529
|
+
category: "configuration" | "connectivity" | "streaming";
|
|
1530
|
+
status: "pass" | "fail" | "warning";
|
|
1531
|
+
message: string;
|
|
1532
|
+
details?: string;
|
|
1533
|
+
recommendation?: string;
|
|
1534
|
+
};
|
|
1535
|
+
/** Aggregated SageMaker diagnostic report. */
|
|
1536
|
+
export type DiagnosticReport = {
|
|
1537
|
+
overallStatus: "healthy" | "issues" | "critical";
|
|
1538
|
+
results: DiagnosticResult[];
|
|
1539
|
+
summary: {
|
|
1540
|
+
total: number;
|
|
1541
|
+
passed: number;
|
|
1542
|
+
failed: number;
|
|
1543
|
+
warnings: number;
|
|
1544
|
+
};
|
|
1545
|
+
};
|
|
1546
|
+
/** SageMaker tool_call item in the OpenAI-compatible payload shape. */
|
|
1547
|
+
export type SageMakerOpenAIToolCall = {
|
|
1548
|
+
type: "function";
|
|
1549
|
+
id: string;
|
|
1550
|
+
function: {
|
|
1551
|
+
name: string;
|
|
1552
|
+
arguments: string;
|
|
1553
|
+
};
|
|
1554
|
+
};
|
|
1555
|
+
/**
|
|
1556
|
+
* Event pushed through the Google AI Studio voice session's internal queue
|
|
1557
|
+
* while audio chunks stream back from the Gemini Live API.
|
|
1558
|
+
*/
|
|
1559
|
+
export type GoogleLiveAudioQueueItem = {
|
|
1560
|
+
type: "audio";
|
|
1561
|
+
audio: import("./stream.js").AudioChunk;
|
|
1562
|
+
} | {
|
|
1563
|
+
type: "end";
|
|
1564
|
+
} | {
|
|
1565
|
+
type: "error";
|
|
1566
|
+
error: unknown;
|
|
1567
|
+
};
|
|
1568
|
+
/**
|
|
1569
|
+
* Single part inside a Google Vertex "native" (non-AI-SDK) generateContent
|
|
1570
|
+
* payload — either inline text or an inline base64 data blob.
|
|
1571
|
+
*/
|
|
1572
|
+
export type VertexNativePart = {
|
|
1573
|
+
text: string;
|
|
1574
|
+
} | {
|
|
1575
|
+
inlineData: {
|
|
1576
|
+
mimeType: string;
|
|
1577
|
+
data: string;
|
|
1578
|
+
};
|
|
1579
|
+
};
|
package/dist/types/proxy.d.ts
CHANGED
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
* - src/lib/proxy/accountQuota.ts (quota type)
|
|
14
14
|
* - src/lib/server/routes/claudeProxyRoutes.ts (runtime state, deps)
|
|
15
15
|
*/
|
|
16
|
-
import type { Span } from "@opentelemetry/api";
|
|
16
|
+
import type { Counter, Histogram, Span } from "@opentelemetry/api";
|
|
17
|
+
import type { Hono } from "hono";
|
|
18
|
+
import type { Ora } from "ora";
|
|
19
|
+
import type { MCPToolRegistry } from "../mcp/toolRegistry.js";
|
|
17
20
|
import type { ProxyTracer } from "../proxy/proxyTracer.js";
|
|
18
21
|
import type { FallbackEntry, ProxyRoutingConfig, CloakingConfig } from "./subscription.js";
|
|
19
22
|
import type { RouteDeprecation } from "./server.js";
|
|
@@ -643,6 +646,10 @@ export type RuntimeAccountState = {
|
|
|
643
646
|
permanentlyDisabled: boolean;
|
|
644
647
|
lastToken?: string;
|
|
645
648
|
lastRefreshToken?: string;
|
|
649
|
+
/** Epoch-ms timestamp until which the account should not be used for new
|
|
650
|
+
* requests (set after 429 retries are exhausted). Other requests arriving
|
|
651
|
+
* during this window will skip the account rather than hammering it again. */
|
|
652
|
+
coolingUntil?: number;
|
|
646
653
|
};
|
|
647
654
|
/** A passthrough account used in the proxy route handler. */
|
|
648
655
|
export type ProxyPassthroughAccount = {
|
|
@@ -737,3 +744,316 @@ export type ProxyPaths = {
|
|
|
737
744
|
/** Whether this is a dev-mode isolated instance */
|
|
738
745
|
isDev: boolean;
|
|
739
746
|
};
|
|
747
|
+
/** OTel metric instruments used by the proxy tracer. */
|
|
748
|
+
export type ProxyMetrics = {
|
|
749
|
+
requestsTotal: Counter;
|
|
750
|
+
requestDuration: Histogram;
|
|
751
|
+
tokensInput: Counter;
|
|
752
|
+
tokensOutput: Counter;
|
|
753
|
+
tokensCacheRead: Counter;
|
|
754
|
+
tokensCacheCreation: Counter;
|
|
755
|
+
tokensReasoning: Counter;
|
|
756
|
+
costTotal: Counter;
|
|
757
|
+
errorsTotal: Counter;
|
|
758
|
+
retriesTotal: Counter;
|
|
759
|
+
modelSubstitutionTotal: Counter;
|
|
760
|
+
requestBodySize: Histogram;
|
|
761
|
+
responseBodySize: Histogram;
|
|
762
|
+
fallbackAttemptsTotal: Counter;
|
|
763
|
+
fallbackSuccessTotal: Counter;
|
|
764
|
+
fallbackFailureTotal: Counter;
|
|
765
|
+
};
|
|
766
|
+
/** Context for a proxy request at the root span level. */
|
|
767
|
+
export type ProxyRequestContext = {
|
|
768
|
+
requestId: string;
|
|
769
|
+
method: string;
|
|
770
|
+
path: string;
|
|
771
|
+
model: string;
|
|
772
|
+
stream: boolean;
|
|
773
|
+
toolCount: number;
|
|
774
|
+
sessionId?: string;
|
|
775
|
+
userAgent?: string;
|
|
776
|
+
clientApp?: string;
|
|
777
|
+
};
|
|
778
|
+
/** Context recorded when an account is selected for a proxy request. */
|
|
779
|
+
export type AccountSelectionContext = {
|
|
780
|
+
strategy: string;
|
|
781
|
+
accountsTotal: number;
|
|
782
|
+
accountsHealthy: number;
|
|
783
|
+
selectedAccount: string;
|
|
784
|
+
accountType: string;
|
|
785
|
+
rateLimitBefore5h?: number;
|
|
786
|
+
rateLimitBefore7d?: number;
|
|
787
|
+
};
|
|
788
|
+
/** Context for a single upstream attempt (one per retry). */
|
|
789
|
+
export type UpstreamAttemptContext = {
|
|
790
|
+
attempt: number;
|
|
791
|
+
account: string;
|
|
792
|
+
polyfillHeaders: boolean;
|
|
793
|
+
polyfillBody: boolean;
|
|
794
|
+
upstreamUrl: string;
|
|
795
|
+
};
|
|
796
|
+
/** Token usage and rate-limit utilisation recorded at end of request. */
|
|
797
|
+
export type UsageContext = {
|
|
798
|
+
inputTokens: number;
|
|
799
|
+
outputTokens: number;
|
|
800
|
+
cacheCreationTokens: number;
|
|
801
|
+
cacheReadTokens: number;
|
|
802
|
+
reasoningTokens?: number;
|
|
803
|
+
rateLimitAfter5h?: number;
|
|
804
|
+
rateLimitAfter7d?: number;
|
|
805
|
+
};
|
|
806
|
+
/** Where a proxy env file path was sourced from. */
|
|
807
|
+
export type ProxyEnvSource = "cli" | "environment" | "default" | "none";
|
|
808
|
+
/** Result of resolving which proxy env file to load. */
|
|
809
|
+
export type ProxyEnvResolution = {
|
|
810
|
+
path?: string;
|
|
811
|
+
source: ProxyEnvSource;
|
|
812
|
+
required: boolean;
|
|
813
|
+
};
|
|
814
|
+
/** Result of loading the proxy env file. */
|
|
815
|
+
export type ProxyEnvLoadResult = {
|
|
816
|
+
loaded: boolean;
|
|
817
|
+
path?: string;
|
|
818
|
+
source: ProxyEnvSource;
|
|
819
|
+
};
|
|
820
|
+
/** Options controlling proxy env file resolution. */
|
|
821
|
+
export type ProxyEnvOptions = {
|
|
822
|
+
explicitEnvFile?: string;
|
|
823
|
+
env?: NodeJS.ProcessEnv;
|
|
824
|
+
homeDir?: string;
|
|
825
|
+
};
|
|
826
|
+
/** Snapshot of proxy-related environment variables captured at startup. */
|
|
827
|
+
export type ProxyEnvironmentSnapshot = {
|
|
828
|
+
httpsProxy?: string;
|
|
829
|
+
httpProxy?: string;
|
|
830
|
+
allProxy?: string;
|
|
831
|
+
socksProxy?: string;
|
|
832
|
+
noProxy?: string;
|
|
833
|
+
};
|
|
834
|
+
/** Result of a traffic-quiet check. */
|
|
835
|
+
export type QuietStatus = {
|
|
836
|
+
isQuiet: boolean;
|
|
837
|
+
lastActivityAt: Date | null;
|
|
838
|
+
silenceDurationMs: number;
|
|
839
|
+
};
|
|
840
|
+
/** Accumulated upstream body capture from a raw stream. */
|
|
841
|
+
export type RawStreamCapture = {
|
|
842
|
+
totalBytes: number;
|
|
843
|
+
text: string;
|
|
844
|
+
truncated: boolean;
|
|
845
|
+
};
|
|
846
|
+
/** Transformed stream pair used to capture upstream bodies without buffering. */
|
|
847
|
+
export type RawStreamCaptureResult = {
|
|
848
|
+
stream: TransformStream<Uint8Array, Uint8Array>;
|
|
849
|
+
capture: Promise<RawStreamCapture>;
|
|
850
|
+
};
|
|
851
|
+
/** Single captured body/headers entry written to disk by the proxy logger. */
|
|
852
|
+
export type ProxyBodyCaptureEntry = {
|
|
853
|
+
timestamp: string;
|
|
854
|
+
requestId: string;
|
|
855
|
+
phase: string;
|
|
856
|
+
model: string;
|
|
857
|
+
stream: boolean;
|
|
858
|
+
headers?: Record<string, string>;
|
|
859
|
+
body?: unknown;
|
|
860
|
+
bodySize?: number;
|
|
861
|
+
contentType?: string;
|
|
862
|
+
responseStatus?: number;
|
|
863
|
+
durationMs?: number;
|
|
864
|
+
account?: string;
|
|
865
|
+
accountType?: string;
|
|
866
|
+
attempt?: number;
|
|
867
|
+
traceId?: string;
|
|
868
|
+
spanId?: string;
|
|
869
|
+
metadata?: Record<string, unknown>;
|
|
870
|
+
};
|
|
871
|
+
/** Persisted artifact produced when a body is stored to disk. */
|
|
872
|
+
export type StoredBodyArtifact = {
|
|
873
|
+
bodyPath?: string;
|
|
874
|
+
bodySha256?: string;
|
|
875
|
+
redactedBodyBytes?: number;
|
|
876
|
+
storedFileBytes?: number;
|
|
877
|
+
redactedBody?: string;
|
|
878
|
+
bodyTruncated?: boolean;
|
|
879
|
+
};
|
|
880
|
+
/** File the proxy logger tracks for rotation and cleanup. */
|
|
881
|
+
export type ManagedLogFile = {
|
|
882
|
+
path: string;
|
|
883
|
+
mtime: number;
|
|
884
|
+
size: number;
|
|
885
|
+
};
|
|
886
|
+
/** Individual content block observed during an SSE stream. */
|
|
887
|
+
export type SSEContentBlock = {
|
|
888
|
+
index: number;
|
|
889
|
+
type: "text" | "thinking" | "tool_use" | "tool_result";
|
|
890
|
+
/** Accumulated text for text blocks. Capped at MAX_BLOCK_CONTENT_BYTES. */
|
|
891
|
+
text?: string;
|
|
892
|
+
/** Accumulated thinking content. Capped at MAX_BLOCK_CONTENT_BYTES. */
|
|
893
|
+
thinking?: string;
|
|
894
|
+
/** Tool name for tool_use blocks. */
|
|
895
|
+
toolName?: string;
|
|
896
|
+
/** Tool call id for tool_use blocks. */
|
|
897
|
+
toolId?: string;
|
|
898
|
+
/** Accumulated partial JSON input for tool_use blocks. Capped at MAX_BLOCK_CONTENT_BYTES. */
|
|
899
|
+
toolInput?: string;
|
|
900
|
+
};
|
|
901
|
+
/** Aggregated telemetry resolved when an SSE stream completes. */
|
|
902
|
+
export type SSETelemetry = {
|
|
903
|
+
messageId: string;
|
|
904
|
+
model: string;
|
|
905
|
+
usage: {
|
|
906
|
+
inputTokens: number;
|
|
907
|
+
outputTokens: number;
|
|
908
|
+
cacheCreationInputTokens: number;
|
|
909
|
+
cacheReadInputTokens: number;
|
|
910
|
+
totalTokens: number;
|
|
911
|
+
};
|
|
912
|
+
contentBlocks: SSEContentBlock[];
|
|
913
|
+
stopReason: string | null;
|
|
914
|
+
stopSequence: string | null;
|
|
915
|
+
eventCount: number;
|
|
916
|
+
streamDurationMs: number;
|
|
917
|
+
totalBytesReceived: number;
|
|
918
|
+
events: Array<{
|
|
919
|
+
type: string;
|
|
920
|
+
timestamp: number;
|
|
921
|
+
data: string;
|
|
922
|
+
}>;
|
|
923
|
+
rawText?: string;
|
|
924
|
+
};
|
|
925
|
+
/** Mutable accumulator the SSE interceptor uses internally. */
|
|
926
|
+
export type TelemetryAccumulator = {
|
|
927
|
+
messageId: string;
|
|
928
|
+
model: string;
|
|
929
|
+
inputTokens: number;
|
|
930
|
+
outputTokens: number;
|
|
931
|
+
cacheCreationInputTokens: number;
|
|
932
|
+
cacheReadInputTokens: number;
|
|
933
|
+
contentBlocks: SSEContentBlock[];
|
|
934
|
+
blockByteCounts: Map<number, number>;
|
|
935
|
+
stopReason: string | null;
|
|
936
|
+
stopSequence: string | null;
|
|
937
|
+
eventCount: number;
|
|
938
|
+
startTime: number;
|
|
939
|
+
totalBytesReceived: number;
|
|
940
|
+
events: Array<{
|
|
941
|
+
type: string;
|
|
942
|
+
timestamp: number;
|
|
943
|
+
data: string;
|
|
944
|
+
}>;
|
|
945
|
+
rawTextChunks?: string[];
|
|
946
|
+
rawTextBytes: number;
|
|
947
|
+
rawTextTruncated: boolean;
|
|
948
|
+
eventLogTruncated: boolean;
|
|
949
|
+
};
|
|
950
|
+
/** Result of createSSEInterceptor: the pass-through stream and a telemetry promise. */
|
|
951
|
+
export type SSEInterceptorResult = {
|
|
952
|
+
stream: TransformStream<Uint8Array, Uint8Array>;
|
|
953
|
+
telemetry: Promise<SSETelemetry>;
|
|
954
|
+
};
|
|
955
|
+
/** Options for createSSEInterceptor. */
|
|
956
|
+
export type SSEInterceptorOptions = {
|
|
957
|
+
captureRawText?: boolean;
|
|
958
|
+
};
|
|
959
|
+
/** Outcome of a proxy auto-update version check against npm. */
|
|
960
|
+
export type UpdateCheckResult = {
|
|
961
|
+
currentVersion: string;
|
|
962
|
+
latestVersion: string;
|
|
963
|
+
updateAvailable: boolean;
|
|
964
|
+
};
|
|
965
|
+
/** Parsed major.minor.patch components of a semver string. */
|
|
966
|
+
export type SemVer = {
|
|
967
|
+
major: number;
|
|
968
|
+
minor: number;
|
|
969
|
+
patch: number;
|
|
970
|
+
};
|
|
971
|
+
/** Entry describing a version suppressed from auto-update. */
|
|
972
|
+
export type SuppressedVersion = {
|
|
973
|
+
suppressedAt: string;
|
|
974
|
+
reason: string;
|
|
975
|
+
};
|
|
976
|
+
/** Persisted state for the proxy auto-update feature. */
|
|
977
|
+
export type UpdateState = {
|
|
978
|
+
lastCheckAt: string;
|
|
979
|
+
lastCheckVersion: string;
|
|
980
|
+
suppressedVersions: Record<string, SuppressedVersion>;
|
|
981
|
+
lastUpdateAt: string | null;
|
|
982
|
+
lastUpdateVersion: string | null;
|
|
983
|
+
};
|
|
984
|
+
/** Shape of the dynamically-imported js-yaml module. */
|
|
985
|
+
export type YamlModule = {
|
|
986
|
+
load(content: string): unknown;
|
|
987
|
+
default?: {
|
|
988
|
+
load(content: string): unknown;
|
|
989
|
+
};
|
|
990
|
+
};
|
|
991
|
+
/** Parsed fields captured from a Claude Code client request body. */
|
|
992
|
+
export type ClaudeSnapshotBody = {
|
|
993
|
+
metadataUserId?: string;
|
|
994
|
+
billingHeader?: string;
|
|
995
|
+
agentBlock?: string;
|
|
996
|
+
sessionId?: string;
|
|
997
|
+
};
|
|
998
|
+
/** Snapshot of headers and body from a Claude Code request, used for polyfill. */
|
|
999
|
+
export type ClaudeSnapshot = {
|
|
1000
|
+
accountKey: string;
|
|
1001
|
+
capturedAt: string;
|
|
1002
|
+
source: "claude-code";
|
|
1003
|
+
headers: Record<string, string>;
|
|
1004
|
+
body?: ClaudeSnapshotBody;
|
|
1005
|
+
};
|
|
1006
|
+
/** Parsed shape of a Claude API error body. */
|
|
1007
|
+
export type ParsedClaudeError = {
|
|
1008
|
+
errorType?: string;
|
|
1009
|
+
message?: string;
|
|
1010
|
+
};
|
|
1011
|
+
/** ora spinner instance held by proxy CLI commands, nullable when --quiet. */
|
|
1012
|
+
export type ProxySpinner = Ora | null;
|
|
1013
|
+
/** Load-balancing strategy used by the proxy across accounts. */
|
|
1014
|
+
export type ProxyStartStrategy = "round-robin" | "fill-first";
|
|
1015
|
+
/** Alias for the model router's constructor configuration. */
|
|
1016
|
+
export type ProxyModelRouterConfig = ProxyRoutingConfig;
|
|
1017
|
+
/** Partial proxy config consumed by the start command. */
|
|
1018
|
+
export type LoadedProxyConfig = {
|
|
1019
|
+
routing?: Partial<ProxyModelRouterConfig> & {
|
|
1020
|
+
strategy?: ProxyStartStrategy;
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Handle for a NeuroLink runtime created by the proxy start command.
|
|
1025
|
+
* The `neurolink` field is typed structurally (only the method used by the
|
|
1026
|
+
* proxy layer is exposed) so types/proxy.ts does not depend on the full
|
|
1027
|
+
* NeuroLink class.
|
|
1028
|
+
*/
|
|
1029
|
+
export type ProxyNeurolinkRuntime = {
|
|
1030
|
+
neurolink: {
|
|
1031
|
+
getToolRegistry(): MCPToolRegistry;
|
|
1032
|
+
};
|
|
1033
|
+
cleanupLogs: (daysToKeep?: number, maxFiles?: number) => void;
|
|
1034
|
+
};
|
|
1035
|
+
/** Hono app + readiness state created by the proxy start command. */
|
|
1036
|
+
export type ProxyStartApp = {
|
|
1037
|
+
app: Hono;
|
|
1038
|
+
readiness: ProxyReadinessState;
|
|
1039
|
+
};
|
|
1040
|
+
/** Stats shape consumed by the proxy status printer. */
|
|
1041
|
+
export type StatusStats = {
|
|
1042
|
+
totalAttempts?: number;
|
|
1043
|
+
totalRequests: number;
|
|
1044
|
+
totalSuccess: number;
|
|
1045
|
+
totalErrors: number;
|
|
1046
|
+
totalRateLimits: number;
|
|
1047
|
+
accounts?: {
|
|
1048
|
+
label: string;
|
|
1049
|
+
type: string;
|
|
1050
|
+
attempts?: number;
|
|
1051
|
+
requests?: number;
|
|
1052
|
+
success?: number;
|
|
1053
|
+
errors?: number;
|
|
1054
|
+
rateLimits?: number;
|
|
1055
|
+
cooling: boolean;
|
|
1056
|
+
}[];
|
|
1057
|
+
};
|
|
1058
|
+
/** Sub-action of the `proxy telemetry` CLI command. */
|
|
1059
|
+
export type ProxyTelemetryAction = "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard";
|
package/dist/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";
|