@juspay/neurolink 7.29.1 → 7.29.3
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 +12 -0
- package/dist/cli/commands/config.d.ts +86 -86
- package/dist/cli/commands/mcp.js +64 -9
- package/dist/cli/commands/models.js +25 -21
- package/dist/cli/commands/ollama.js +2 -2
- package/dist/cli/factories/commandFactory.d.ts +9 -0
- package/dist/cli/factories/commandFactory.js +177 -83
- package/dist/cli/factories/ollamaCommandFactory.js +3 -1
- package/dist/cli/factories/sagemakerCommandFactory.js +3 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +19 -11
- package/dist/cli/utils/envManager.js +5 -5
- package/dist/cli/utils/ollamaUtils.d.ts +12 -0
- package/dist/cli/utils/ollamaUtils.js +58 -42
- package/dist/config/configManager.js +5 -2
- package/dist/core/analytics.d.ts +2 -24
- package/dist/core/analytics.js +12 -17
- package/dist/core/baseProvider.d.ts +30 -1
- package/dist/core/baseProvider.js +180 -198
- package/dist/core/dynamicModels.d.ts +4 -4
- package/dist/core/dynamicModels.js +7 -7
- package/dist/core/evaluation.d.ts +9 -9
- package/dist/core/evaluation.js +117 -65
- package/dist/core/evaluationProviders.d.ts +18 -2
- package/dist/core/evaluationProviders.js +15 -13
- package/dist/core/factory.js +77 -4
- package/dist/core/modelConfiguration.d.ts +63 -0
- package/dist/core/modelConfiguration.js +354 -290
- package/dist/core/streamAnalytics.d.ts +10 -5
- package/dist/core/streamAnalytics.js +10 -10
- package/dist/core/types.d.ts +19 -109
- package/dist/core/types.js +13 -0
- package/dist/factories/providerFactory.js +4 -1
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/lib/config/configManager.js +5 -2
- package/dist/lib/core/analytics.d.ts +2 -24
- package/dist/lib/core/analytics.js +12 -17
- package/dist/lib/core/baseProvider.d.ts +30 -1
- package/dist/lib/core/baseProvider.js +180 -198
- package/dist/lib/core/dynamicModels.js +7 -7
- package/dist/lib/core/evaluation.d.ts +9 -9
- package/dist/lib/core/evaluation.js +117 -65
- package/dist/lib/core/evaluationProviders.d.ts +18 -2
- package/dist/lib/core/evaluationProviders.js +15 -13
- package/dist/lib/core/factory.js +77 -4
- package/dist/lib/core/modelConfiguration.d.ts +63 -0
- package/dist/lib/core/modelConfiguration.js +354 -290
- package/dist/lib/core/streamAnalytics.d.ts +10 -5
- package/dist/lib/core/streamAnalytics.js +10 -10
- package/dist/lib/core/types.d.ts +19 -109
- package/dist/lib/core/types.js +13 -0
- package/dist/lib/factories/providerFactory.js +4 -1
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/mcp/externalServerManager.js +14 -6
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/flexibleToolValidator.d.ts +50 -0
- package/dist/lib/mcp/flexibleToolValidator.js +161 -0
- package/dist/lib/mcp/index.d.ts +1 -1
- package/dist/lib/mcp/index.js +1 -1
- package/dist/lib/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -0
- package/dist/lib/mcp/registry.d.ts +3 -3
- package/dist/lib/mcp/registry.js +3 -3
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/lib/mcp/toolDiscoveryService.js +8 -2
- package/dist/lib/mcp/toolRegistry.d.ts +2 -2
- package/dist/lib/mcp/toolRegistry.js +29 -54
- package/dist/lib/middleware/builtin/analytics.js +4 -4
- package/dist/lib/middleware/builtin/guardrails.js +2 -2
- package/dist/lib/middleware/registry.js +11 -2
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +3 -3
- package/dist/lib/models/modelResolver.d.ts +1 -1
- package/dist/lib/models/modelResolver.js +2 -2
- package/dist/lib/neurolink.d.ts +118 -0
- package/dist/lib/neurolink.js +814 -952
- package/dist/lib/providers/amazonBedrock.d.ts +47 -6
- package/dist/lib/providers/amazonBedrock.js +282 -23
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/amazonSagemaker.js +12 -3
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +7 -6
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +4 -3
- package/dist/lib/providers/aws/credentialProvider.d.ts +58 -0
- package/dist/lib/providers/aws/credentialProvider.js +267 -0
- package/dist/lib/providers/aws/credentialTester.d.ts +49 -0
- package/dist/lib/providers/aws/credentialTester.js +394 -0
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +1 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +40 -0
- package/dist/lib/providers/googleVertex.js +330 -274
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.d.ts +4 -0
- package/dist/lib/providers/ollama.js +38 -18
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/lib/providers/sagemaker/client.js +13 -3
- package/dist/lib/providers/sagemaker/config.js +5 -1
- package/dist/lib/providers/sagemaker/detection.js +19 -9
- package/dist/lib/providers/sagemaker/errors.d.ts +8 -1
- package/dist/lib/providers/sagemaker/errors.js +103 -20
- package/dist/lib/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/lib/providers/sagemaker/language-model.js +4 -4
- package/dist/lib/providers/sagemaker/parsers.js +14 -6
- package/dist/lib/providers/sagemaker/streaming.js +14 -3
- package/dist/lib/providers/sagemaker/types.d.ts +1 -1
- package/dist/lib/proxy/awsProxyIntegration.d.ts +23 -0
- package/dist/lib/proxy/awsProxyIntegration.js +285 -0
- package/dist/lib/proxy/proxyFetch.d.ts +9 -5
- package/dist/lib/proxy/proxyFetch.js +232 -98
- package/dist/lib/proxy/utils/noProxyUtils.d.ts +39 -0
- package/dist/lib/proxy/utils/noProxyUtils.js +149 -0
- package/dist/lib/sdk/toolRegistration.d.ts +1 -1
- package/dist/lib/types/cli.d.ts +80 -8
- package/dist/lib/types/contextTypes.js +2 -2
- package/dist/lib/types/generateTypes.d.ts +4 -6
- package/dist/lib/types/providers.d.ts +124 -19
- package/dist/lib/types/providers.js +6 -6
- package/dist/lib/types/streamTypes.d.ts +4 -6
- package/dist/lib/types/typeAliases.d.ts +1 -1
- package/dist/lib/utils/analyticsUtils.d.ts +33 -0
- package/dist/lib/utils/analyticsUtils.js +76 -0
- package/dist/lib/utils/errorHandling.js +4 -1
- package/dist/lib/utils/evaluationUtils.d.ts +27 -0
- package/dist/lib/utils/evaluationUtils.js +131 -0
- package/dist/lib/utils/optionsUtils.js +10 -1
- package/dist/lib/utils/performance.d.ts +1 -1
- package/dist/lib/utils/performance.js +15 -3
- package/dist/lib/utils/providerConfig.d.ts +1 -0
- package/dist/lib/utils/providerConfig.js +2 -1
- package/dist/lib/utils/providerHealth.d.ts +48 -0
- package/dist/lib/utils/providerHealth.js +221 -158
- package/dist/lib/utils/providerUtils.js +2 -2
- package/dist/lib/utils/timeout.js +8 -3
- package/dist/mcp/externalServerManager.js +14 -6
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/flexibleToolValidator.d.ts +50 -0
- package/dist/mcp/flexibleToolValidator.js +161 -0
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/mcp/mcpClientFactory.js +3 -0
- package/dist/mcp/registry.d.ts +3 -3
- package/dist/mcp/registry.js +3 -3
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/mcp/toolDiscoveryService.js +8 -2
- package/dist/mcp/toolRegistry.d.ts +2 -2
- package/dist/mcp/toolRegistry.js +29 -54
- package/dist/middleware/builtin/analytics.js +4 -4
- package/dist/middleware/builtin/guardrails.js +2 -2
- package/dist/middleware/registry.js +11 -2
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +3 -3
- package/dist/models/modelResolver.d.ts +1 -1
- package/dist/models/modelResolver.js +2 -2
- package/dist/neurolink.d.ts +118 -0
- package/dist/neurolink.js +814 -952
- package/dist/providers/amazonBedrock.d.ts +47 -6
- package/dist/providers/amazonBedrock.js +282 -23
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/amazonSagemaker.js +12 -3
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +7 -6
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +4 -3
- package/dist/providers/aws/credentialProvider.d.ts +58 -0
- package/dist/providers/aws/credentialProvider.js +267 -0
- package/dist/providers/aws/credentialTester.d.ts +49 -0
- package/dist/providers/aws/credentialTester.js +394 -0
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +1 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +2 -2
- package/dist/providers/googleVertex.d.ts +40 -0
- package/dist/providers/googleVertex.js +330 -274
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.d.ts +4 -0
- package/dist/providers/ollama.js +38 -18
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/providers/sagemaker/client.js +13 -3
- package/dist/providers/sagemaker/config.js +5 -1
- package/dist/providers/sagemaker/detection.js +19 -9
- package/dist/providers/sagemaker/errors.d.ts +8 -1
- package/dist/providers/sagemaker/errors.js +103 -20
- package/dist/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/providers/sagemaker/language-model.js +4 -4
- package/dist/providers/sagemaker/parsers.js +14 -6
- package/dist/providers/sagemaker/streaming.js +14 -3
- package/dist/providers/sagemaker/types.d.ts +1 -1
- package/dist/proxy/awsProxyIntegration.d.ts +23 -0
- package/dist/proxy/awsProxyIntegration.js +285 -0
- package/dist/proxy/proxyFetch.d.ts +9 -5
- package/dist/proxy/proxyFetch.js +232 -98
- package/dist/proxy/utils/noProxyUtils.d.ts +39 -0
- package/dist/proxy/utils/noProxyUtils.js +149 -0
- package/dist/sdk/toolRegistration.d.ts +1 -1
- package/dist/types/cli.d.ts +80 -8
- package/dist/types/contextTypes.js +2 -2
- package/dist/types/generateTypes.d.ts +4 -6
- package/dist/types/providers.d.ts +124 -19
- package/dist/types/providers.js +6 -6
- package/dist/types/streamTypes.d.ts +4 -6
- package/dist/types/typeAliases.d.ts +1 -1
- package/dist/utils/analyticsUtils.d.ts +33 -0
- package/dist/utils/analyticsUtils.js +76 -0
- package/dist/utils/errorHandling.js +4 -1
- package/dist/utils/evaluationUtils.d.ts +27 -0
- package/dist/utils/evaluationUtils.js +131 -0
- package/dist/utils/optionsUtils.js +10 -1
- package/dist/utils/performance.d.ts +1 -1
- package/dist/utils/performance.js +15 -3
- package/dist/utils/providerConfig.d.ts +1 -0
- package/dist/utils/providerConfig.js +2 -1
- package/dist/utils/providerHealth.d.ts +48 -0
- package/dist/utils/providerHealth.js +221 -158
- package/dist/utils/providerUtils.js +2 -2
- package/dist/utils/timeout.js +8 -3
- package/package.json +5 -1
|
@@ -3,29 +3,70 @@ import { type LanguageModelV1 } from "ai";
|
|
|
3
3
|
import type { AIProviderName } from "../core/types.js";
|
|
4
4
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
5
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
|
+
import { AWSCredentialProvider } from "./aws/credentialProvider.js";
|
|
7
|
+
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
|
8
|
+
import type { AWSCredentialConfig } from "../types/providers.js";
|
|
9
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
6
10
|
/**
|
|
7
|
-
* Amazon Bedrock Provider
|
|
11
|
+
* Amazon Bedrock Provider v3 - Enhanced Authentication Implementation
|
|
8
12
|
*
|
|
9
|
-
*
|
|
13
|
+
* BEDROCK-MCP-CONNECTOR COMPATIBILITY: Complete AWS SDK credential chain support
|
|
10
14
|
*
|
|
11
15
|
* Features:
|
|
12
16
|
* - Extends BaseProvider for shared functionality
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
17
|
+
* - AWS SDK v3 defaultProvider credential chain (9 sources)
|
|
18
|
+
* - Dual access: AI SDK + Direct AWS SDK BedrockRuntimeClient
|
|
19
|
+
* - Full backward compatibility with existing configurations
|
|
16
20
|
* - Enhanced error handling with setup guidance
|
|
21
|
+
* - Bedrock-MCP-Connector compatible authentication patterns
|
|
17
22
|
*/
|
|
18
23
|
export declare class AmazonBedrockProvider extends BaseProvider {
|
|
24
|
+
private awsCredentialProvider;
|
|
25
|
+
private bedrockClient;
|
|
19
26
|
private bedrock;
|
|
20
27
|
private model;
|
|
21
|
-
constructor(modelName?: string);
|
|
28
|
+
constructor(modelName?: string, credentialConfig?: AWSCredentialConfig, neurolink?: NeuroLink);
|
|
29
|
+
/**
|
|
30
|
+
* Legacy AWS configuration for backward compatibility
|
|
31
|
+
*/
|
|
32
|
+
private createLegacyAWSConfig;
|
|
22
33
|
protected getProviderName(): AIProviderName;
|
|
23
34
|
protected getDefaultModel(): string;
|
|
24
35
|
/**
|
|
25
36
|
* Returns the Vercel AI SDK model instance for AWS Bedrock
|
|
26
37
|
*/
|
|
27
38
|
protected getAISDKModel(): LanguageModelV1;
|
|
39
|
+
/**
|
|
40
|
+
* Get AWS SDK BedrockRuntimeClient for direct access (Bedrock-MCP-Connector compatibility)
|
|
41
|
+
* This provides the same direct AWS SDK access that Bedrock-MCP-Connector uses
|
|
42
|
+
*/
|
|
43
|
+
getBedrockClient(): BedrockRuntimeClient;
|
|
44
|
+
/**
|
|
45
|
+
* Get AWS SDK BedrockRuntimeClient with proxy support ensured
|
|
46
|
+
* Use this method when proxy support is critical for the operation
|
|
47
|
+
*/
|
|
48
|
+
getBedrockClientWithProxy(): Promise<BedrockRuntimeClient>;
|
|
49
|
+
/**
|
|
50
|
+
* Get AWS credential provider for advanced credential management
|
|
51
|
+
*/
|
|
52
|
+
getCredentialProvider(): AWSCredentialProvider;
|
|
53
|
+
/**
|
|
54
|
+
* Ensure proxy support is configured for AWS SDK client if needed
|
|
55
|
+
*/
|
|
56
|
+
private ensureProxySupport;
|
|
57
|
+
/**
|
|
58
|
+
* Test AWS credentials and Bedrock connectivity
|
|
59
|
+
* Useful for debugging authentication issues
|
|
60
|
+
*/
|
|
61
|
+
testConnectivity(): Promise<{
|
|
62
|
+
credentialsValid: boolean;
|
|
63
|
+
bedrockAccessible: boolean;
|
|
64
|
+
credentialSource: string;
|
|
65
|
+
error?: string;
|
|
66
|
+
responseTime?: number;
|
|
67
|
+
}>;
|
|
28
68
|
protected executeStream(options: StreamOptions, _analysisSchema?: ZodUnknownSchema): Promise<StreamResult>;
|
|
69
|
+
protected handleStreamError(error: unknown): Error;
|
|
29
70
|
protected handleProviderError(error: unknown): Error;
|
|
30
71
|
}
|
|
31
72
|
export default AmazonBedrockProvider;
|
|
@@ -3,10 +3,12 @@ import { streamText } from "ai";
|
|
|
3
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
|
-
import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
|
|
6
|
+
import { DEFAULT_MAX_TOKENS, DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
7
7
|
import { validateApiKey, createAWSAccessKeyConfig, createAWSSecretConfig, getAWSRegion, getAWSSessionToken, } from "../utils/providerConfig.js";
|
|
8
8
|
import { buildMessagesArray } from "../utils/messageBuilder.js";
|
|
9
9
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
10
|
+
import { AWSCredentialProvider } from "./aws/credentialProvider.js";
|
|
11
|
+
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
|
10
12
|
// Configuration helpers
|
|
11
13
|
const getBedrockModelId = () => {
|
|
12
14
|
const model = process.env.BEDROCK_MODEL || process.env.BEDROCK_MODEL_ID;
|
|
@@ -27,23 +29,102 @@ const getAppEnvironment = () => {
|
|
|
27
29
|
return process.env.PUBLIC_APP_ENVIRONMENT || "production";
|
|
28
30
|
};
|
|
29
31
|
/**
|
|
30
|
-
* Amazon Bedrock Provider
|
|
32
|
+
* Amazon Bedrock Provider v3 - Enhanced Authentication Implementation
|
|
31
33
|
*
|
|
32
|
-
*
|
|
34
|
+
* BEDROCK-MCP-CONNECTOR COMPATIBILITY: Complete AWS SDK credential chain support
|
|
33
35
|
*
|
|
34
36
|
* Features:
|
|
35
37
|
* - Extends BaseProvider for shared functionality
|
|
36
|
-
* -
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
38
|
+
* - AWS SDK v3 defaultProvider credential chain (9 sources)
|
|
39
|
+
* - Dual access: AI SDK + Direct AWS SDK BedrockRuntimeClient
|
|
40
|
+
* - Full backward compatibility with existing configurations
|
|
39
41
|
* - Enhanced error handling with setup guidance
|
|
42
|
+
* - Bedrock-MCP-Connector compatible authentication patterns
|
|
40
43
|
*/
|
|
41
44
|
export class AmazonBedrockProvider extends BaseProvider {
|
|
45
|
+
awsCredentialProvider;
|
|
46
|
+
bedrockClient;
|
|
42
47
|
bedrock;
|
|
43
48
|
model;
|
|
44
|
-
constructor(modelName) {
|
|
45
|
-
super(modelName, "bedrock");
|
|
46
|
-
//
|
|
49
|
+
constructor(modelName, credentialConfig, neurolink) {
|
|
50
|
+
super(modelName, "bedrock", neurolink);
|
|
51
|
+
// Debug: Bedrock initialization started
|
|
52
|
+
logger.debug("[Bedrock] Provider initialization started", {
|
|
53
|
+
requestedModel: modelName || "default",
|
|
54
|
+
environment: getAppEnvironment(),
|
|
55
|
+
});
|
|
56
|
+
// Initialize AWS credential provider with full credential chain support
|
|
57
|
+
const defaultCredentialConfig = {
|
|
58
|
+
region: getAWSRegion(),
|
|
59
|
+
enableDebugLogging: getAppEnvironment() === "dev",
|
|
60
|
+
...credentialConfig,
|
|
61
|
+
};
|
|
62
|
+
// Debug: AWS configuration
|
|
63
|
+
logger.debug("[Bedrock] AWS configuration resolved", {
|
|
64
|
+
region: defaultCredentialConfig.region,
|
|
65
|
+
enableDebugLogging: defaultCredentialConfig.enableDebugLogging,
|
|
66
|
+
credentialConfigProvided: !!credentialConfig,
|
|
67
|
+
});
|
|
68
|
+
this.awsCredentialProvider = new AWSCredentialProvider(defaultCredentialConfig);
|
|
69
|
+
// Debug: AWS credential detection status
|
|
70
|
+
logger.debug("[Bedrock] AWS credential detection status", {
|
|
71
|
+
hasAccessKey: !!process.env.AWS_ACCESS_KEY_ID,
|
|
72
|
+
hasSecretKey: !!process.env.AWS_SECRET_ACCESS_KEY,
|
|
73
|
+
hasSessionToken: !!process.env.AWS_SESSION_TOKEN,
|
|
74
|
+
hasProfile: !!process.env.AWS_PROFILE,
|
|
75
|
+
credentialChainEnabled: true,
|
|
76
|
+
});
|
|
77
|
+
// Create AWS SDK v3 Bedrock client for direct access (Bedrock-MCP-Connector compatibility)
|
|
78
|
+
// Proxy support will be injected lazily when needed
|
|
79
|
+
this.bedrockClient = new BedrockRuntimeClient({
|
|
80
|
+
region: defaultCredentialConfig.region,
|
|
81
|
+
credentials: this.awsCredentialProvider.getCredentialProvider(),
|
|
82
|
+
});
|
|
83
|
+
// Debug: AWS region and service endpoint
|
|
84
|
+
logger.debug("[Bedrock] AWS service configuration", {
|
|
85
|
+
region: defaultCredentialConfig.region,
|
|
86
|
+
serviceEndpoint: `https://bedrock-runtime.${defaultCredentialConfig.region}.amazonaws.com`,
|
|
87
|
+
credentialProviderType: "AWS SDK v3 defaultProvider chain",
|
|
88
|
+
});
|
|
89
|
+
// For now, use legacy configuration as AI SDK may not support credential providers directly
|
|
90
|
+
// TODO: Update when @ai-sdk/amazon-bedrock supports credential providers
|
|
91
|
+
const legacyAwsConfig = this.createLegacyAWSConfig();
|
|
92
|
+
try {
|
|
93
|
+
this.bedrock = createAmazonBedrock(legacyAwsConfig);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
logger.error("Failed to create AI SDK provider", {
|
|
97
|
+
error: error instanceof Error ? error.message : String(error),
|
|
98
|
+
});
|
|
99
|
+
throw new Error(`Failed to initialize Amazon Bedrock AI SDK: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
// Pre-initialize model for efficiency
|
|
102
|
+
const resolvedModelId = this.modelName || getBedrockModelId();
|
|
103
|
+
// Debug: Bedrock model validation process
|
|
104
|
+
logger.debug("[Bedrock] Model validation and ARN processing", {
|
|
105
|
+
requestedModel: this.modelName || "from environment",
|
|
106
|
+
resolvedModelId: resolvedModelId,
|
|
107
|
+
isInferenceProfile: resolvedModelId.includes(":inference-profile/"),
|
|
108
|
+
isFoundationModel: resolvedModelId.startsWith("anthropic.") ||
|
|
109
|
+
resolvedModelId.startsWith("amazon.") ||
|
|
110
|
+
resolvedModelId.startsWith("meta."),
|
|
111
|
+
modelARNValidation: resolvedModelId.includes("arn:aws:bedrock:")
|
|
112
|
+
? "Full ARN provided"
|
|
113
|
+
: "Model ID provided",
|
|
114
|
+
});
|
|
115
|
+
this.model = this.bedrock(resolvedModelId);
|
|
116
|
+
logger.debug("Amazon Bedrock Provider v3 initialized", {
|
|
117
|
+
modelName: this.modelName,
|
|
118
|
+
region: defaultCredentialConfig.region,
|
|
119
|
+
credentialProvider: "AWS SDK v3 defaultProvider",
|
|
120
|
+
hasDualAccess: true,
|
|
121
|
+
provider: this.providerName,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Legacy AWS configuration for backward compatibility
|
|
126
|
+
*/
|
|
127
|
+
createLegacyAWSConfig() {
|
|
47
128
|
const awsConfig = {
|
|
48
129
|
accessKeyId: getAWSAccessKeyId(),
|
|
49
130
|
secretAccessKey: getAWSSecretAccessKey(),
|
|
@@ -57,16 +138,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
57
138
|
awsConfig.sessionToken = sessionToken;
|
|
58
139
|
}
|
|
59
140
|
}
|
|
60
|
-
|
|
61
|
-
this.bedrock = createAmazonBedrock(awsConfig);
|
|
62
|
-
// Pre-initialize model for efficiency
|
|
63
|
-
this.model = this.bedrock(this.modelName || getBedrockModelId());
|
|
64
|
-
logger.debug("Amazon Bedrock BaseProvider v2 initialized", {
|
|
65
|
-
modelName: this.modelName,
|
|
66
|
-
region: awsConfig.region,
|
|
67
|
-
hasSessionToken: !!awsConfig.sessionToken,
|
|
68
|
-
provider: this.providerName,
|
|
69
|
-
});
|
|
141
|
+
return awsConfig;
|
|
70
142
|
}
|
|
71
143
|
getProviderName() {
|
|
72
144
|
return "bedrock";
|
|
@@ -80,27 +152,203 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
80
152
|
getAISDKModel() {
|
|
81
153
|
return this.model;
|
|
82
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Get AWS SDK BedrockRuntimeClient for direct access (Bedrock-MCP-Connector compatibility)
|
|
157
|
+
* This provides the same direct AWS SDK access that Bedrock-MCP-Connector uses
|
|
158
|
+
*/
|
|
159
|
+
getBedrockClient() {
|
|
160
|
+
// Note: For synchronous access, proxy support is configured lazily
|
|
161
|
+
// If proxy support is critical, use getBedrockClientWithProxy() instead
|
|
162
|
+
return this.bedrockClient;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get AWS SDK BedrockRuntimeClient with proxy support ensured
|
|
166
|
+
* Use this method when proxy support is critical for the operation
|
|
167
|
+
*/
|
|
168
|
+
async getBedrockClientWithProxy() {
|
|
169
|
+
await this.ensureProxySupport();
|
|
170
|
+
return this.bedrockClient;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get AWS credential provider for advanced credential management
|
|
174
|
+
*/
|
|
175
|
+
getCredentialProvider() {
|
|
176
|
+
return this.awsCredentialProvider;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Ensure proxy support is configured for AWS SDK client if needed
|
|
180
|
+
*/
|
|
181
|
+
async ensureProxySupport() {
|
|
182
|
+
try {
|
|
183
|
+
const { createAWSProxyHandler } = await import("../proxy/awsProxyIntegration.js");
|
|
184
|
+
const proxyHandler = await createAWSProxyHandler();
|
|
185
|
+
if (proxyHandler) {
|
|
186
|
+
logger.debug("[Bedrock] Reinitializing client with proxy support");
|
|
187
|
+
// Recreate the client with proxy handler
|
|
188
|
+
this.bedrockClient = new BedrockRuntimeClient({
|
|
189
|
+
region: this.awsCredentialProvider.getConfig().region,
|
|
190
|
+
credentials: this.awsCredentialProvider.getCredentialProvider(),
|
|
191
|
+
requestHandler: proxyHandler,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
logger.warn("[Bedrock] Failed to configure proxy support", { error });
|
|
197
|
+
// Continue without proxy support
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Test AWS credentials and Bedrock connectivity
|
|
202
|
+
* Useful for debugging authentication issues
|
|
203
|
+
*/
|
|
204
|
+
async testConnectivity() {
|
|
205
|
+
const startTime = Date.now();
|
|
206
|
+
try {
|
|
207
|
+
// Ensure proxy support is configured before testing
|
|
208
|
+
await this.ensureProxySupport();
|
|
209
|
+
const { CredentialTester } = await import("./aws/credentialTester.js");
|
|
210
|
+
// Add timeout protection using AbortController
|
|
211
|
+
const timeout = 15000; // 15 second timeout
|
|
212
|
+
const abortController = new AbortController();
|
|
213
|
+
const timeoutId = setTimeout(() => {
|
|
214
|
+
abortController.abort();
|
|
215
|
+
}, timeout);
|
|
216
|
+
try {
|
|
217
|
+
const [credentialResult, connectivityResult] = await Promise.race([
|
|
218
|
+
Promise.all([
|
|
219
|
+
CredentialTester.validateCredentials(this.awsCredentialProvider),
|
|
220
|
+
CredentialTester.testBedrockConnectivity(this.awsCredentialProvider),
|
|
221
|
+
]),
|
|
222
|
+
new Promise((_, reject) => {
|
|
223
|
+
abortController.signal.addEventListener("abort", () => {
|
|
224
|
+
reject(new Error("Connectivity test timeout"));
|
|
225
|
+
});
|
|
226
|
+
}),
|
|
227
|
+
]);
|
|
228
|
+
clearTimeout(timeoutId);
|
|
229
|
+
return {
|
|
230
|
+
credentialsValid: credentialResult.isValid,
|
|
231
|
+
bedrockAccessible: connectivityResult.bedrockAccessible,
|
|
232
|
+
credentialSource: credentialResult.credentialSource,
|
|
233
|
+
error: credentialResult.error || connectivityResult.error,
|
|
234
|
+
responseTime: Date.now() - startTime,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
catch (timeoutError) {
|
|
238
|
+
clearTimeout(timeoutId);
|
|
239
|
+
throw timeoutError;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
244
|
+
return {
|
|
245
|
+
credentialsValid: false,
|
|
246
|
+
bedrockAccessible: false,
|
|
247
|
+
credentialSource: "unknown",
|
|
248
|
+
error: errorMessage,
|
|
249
|
+
responseTime: Date.now() - startTime,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
83
253
|
// executeGenerate removed - BaseProvider handles all generation with tools
|
|
84
254
|
async executeStream(options, _analysisSchema) {
|
|
85
255
|
try {
|
|
86
256
|
this.validateStreamOptions(options);
|
|
87
257
|
const timeout = this.getTimeout(options);
|
|
88
258
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
259
|
+
// Get tools consistently with generate method (now supports streaming with tools)
|
|
260
|
+
const shouldUseTools = !options.disableTools && this.supportsTools();
|
|
261
|
+
const tools = shouldUseTools ? await this.getAllTools() : {};
|
|
89
262
|
// Build message array from options
|
|
90
263
|
const messages = buildMessagesArray(options);
|
|
91
264
|
const result = streamText({
|
|
92
265
|
model: this.model,
|
|
93
266
|
messages: messages,
|
|
267
|
+
tools,
|
|
268
|
+
maxSteps: options.maxSteps || DEFAULT_MAX_STEPS,
|
|
269
|
+
toolChoice: shouldUseTools ? "auto" : "none",
|
|
94
270
|
maxTokens: options.maxTokens || DEFAULT_MAX_TOKENS,
|
|
95
271
|
temperature: options.temperature,
|
|
96
272
|
abortSignal: timeoutController?.controller.signal,
|
|
97
273
|
});
|
|
98
274
|
const streamResult = {
|
|
99
|
-
stream: (async function* () {
|
|
100
|
-
|
|
101
|
-
|
|
275
|
+
stream: (async function* (self) {
|
|
276
|
+
let chunkCount = 0;
|
|
277
|
+
let streamStarted = false;
|
|
278
|
+
let timeoutId = null;
|
|
279
|
+
try {
|
|
280
|
+
// Create timeout promise for first chunk with proper cleanup
|
|
281
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
282
|
+
timeoutId = setTimeout(() => {
|
|
283
|
+
if (!streamStarted && chunkCount === 0) {
|
|
284
|
+
reject(new Error("❌ Amazon Bedrock Streaming Timeout\n\n" +
|
|
285
|
+
"Stream failed to produce any content within 5 seconds.\n\n" +
|
|
286
|
+
"🔧 Common Causes:\n" +
|
|
287
|
+
"1. Expired AWS credentials - run: aws sts get-caller-identity\n" +
|
|
288
|
+
"2. Missing Bedrock permissions - need: bedrock:InvokeModelWithResponseStream\n" +
|
|
289
|
+
"3. Model not available in your region\n" +
|
|
290
|
+
"4. Network connectivity issues\n\n" +
|
|
291
|
+
'💡 Try: neurolink generate "test" --provider bedrock\n' +
|
|
292
|
+
" (Generate mode provides more detailed error messages)"));
|
|
293
|
+
}
|
|
294
|
+
}, 5000);
|
|
295
|
+
});
|
|
296
|
+
// Process stream with timeout handling
|
|
297
|
+
const streamIterator = result.textStream[Symbol.asyncIterator]();
|
|
298
|
+
let timeoutActive = true;
|
|
299
|
+
while (true) {
|
|
300
|
+
let nextResult;
|
|
301
|
+
if (timeoutActive) {
|
|
302
|
+
// Race between next chunk and timeout for first chunk only
|
|
303
|
+
nextResult = await Promise.race([
|
|
304
|
+
streamIterator.next(),
|
|
305
|
+
timeoutPromise,
|
|
306
|
+
]);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
// No timeout for subsequent chunks
|
|
310
|
+
nextResult = await streamIterator.next();
|
|
311
|
+
}
|
|
312
|
+
if (nextResult.done) {
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
if (!streamStarted) {
|
|
316
|
+
streamStarted = true;
|
|
317
|
+
timeoutActive = false;
|
|
318
|
+
// Clear the timeout now that we have content
|
|
319
|
+
if (timeoutId) {
|
|
320
|
+
clearTimeout(timeoutId);
|
|
321
|
+
timeoutId = null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
chunkCount++;
|
|
325
|
+
yield { content: nextResult.value };
|
|
326
|
+
}
|
|
327
|
+
// If no chunks received, likely an authentication error
|
|
328
|
+
if (chunkCount === 0) {
|
|
329
|
+
throw new Error("❌ Amazon Bedrock Streaming Error\n\n" +
|
|
330
|
+
"Stream completed with no content.\n\n" +
|
|
331
|
+
"🔧 Most Likely Causes:\n" +
|
|
332
|
+
"1. AWS credentials are expired or invalid\n" +
|
|
333
|
+
"2. Insufficient Bedrock permissions\n" +
|
|
334
|
+
"3. Model access not enabled in AWS console\n" +
|
|
335
|
+
"4. Region mismatch\n\n" +
|
|
336
|
+
"🔍 Debug Steps:\n" +
|
|
337
|
+
"1. Check credentials: aws sts get-caller-identity\n" +
|
|
338
|
+
'2. Test generate mode: neurolink generate "test" --provider bedrock\n' +
|
|
339
|
+
'3. Verify region: AWS_REGION=us-east-1 neurolink stream "test" --provider bedrock');
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
// Clean up timeout on error
|
|
344
|
+
if (timeoutId) {
|
|
345
|
+
clearTimeout(timeoutId);
|
|
346
|
+
}
|
|
347
|
+
throw self.handleStreamError
|
|
348
|
+
? self.handleStreamError(error)
|
|
349
|
+
: error;
|
|
102
350
|
}
|
|
103
|
-
})(),
|
|
351
|
+
})(this),
|
|
104
352
|
provider: this.providerName,
|
|
105
353
|
model: this.modelName,
|
|
106
354
|
};
|
|
@@ -111,6 +359,17 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
111
359
|
throw this.handleProviderError(error);
|
|
112
360
|
}
|
|
113
361
|
}
|
|
362
|
+
handleStreamError(error) {
|
|
363
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
364
|
+
// Stream-specific error handling
|
|
365
|
+
if (errorMessage.includes("no content") ||
|
|
366
|
+
errorMessage.includes("Streaming Timeout") ||
|
|
367
|
+
errorMessage.includes("Stream failed")) {
|
|
368
|
+
return new Error(errorMessage); // Already formatted in stream logic
|
|
369
|
+
}
|
|
370
|
+
// For other errors, use standard provider error handling
|
|
371
|
+
return this.handleProviderError(error);
|
|
372
|
+
}
|
|
114
373
|
handleProviderError(error) {
|
|
115
374
|
if (error instanceof Error && error.name === "TimeoutError") {
|
|
116
375
|
return new TimeoutError(`Amazon Bedrock request timed out. Consider increasing timeout or using a lighter model.`, this.defaultTimeout);
|
|
@@ -20,7 +20,7 @@ export declare class AmazonSageMakerProvider extends BaseProvider {
|
|
|
20
20
|
protected getProviderName(): AIProviderName;
|
|
21
21
|
protected getDefaultModel(): string;
|
|
22
22
|
protected getAISDKModel(): LanguageModelV1;
|
|
23
|
-
protected executeStream(
|
|
23
|
+
protected executeStream(_options: StreamOptions, _analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
|
|
24
24
|
protected handleProviderError(error: unknown): Error;
|
|
25
25
|
/**
|
|
26
26
|
* Get SageMaker-specific provider information
|
|
@@ -50,10 +50,14 @@ export class AmazonSageMakerProvider extends BaseProvider {
|
|
|
50
50
|
getAISDKModel() {
|
|
51
51
|
return this.sagemakerModel;
|
|
52
52
|
}
|
|
53
|
-
async executeStream(
|
|
53
|
+
async executeStream(_options, _analysisSchema) {
|
|
54
54
|
try {
|
|
55
55
|
// For now, throw an error indicating this is not yet implemented
|
|
56
|
-
throw new SageMakerError("SageMaker streaming not yet fully implemented. Coming in next phase.",
|
|
56
|
+
throw new SageMakerError("SageMaker streaming not yet fully implemented. Coming in next phase.", {
|
|
57
|
+
code: "MODEL_ERROR",
|
|
58
|
+
statusCode: 501,
|
|
59
|
+
endpoint: this.modelConfig.endpointName,
|
|
60
|
+
});
|
|
57
61
|
}
|
|
58
62
|
catch (error) {
|
|
59
63
|
throw this.handleProviderError(error);
|
|
@@ -64,7 +68,12 @@ export class AmazonSageMakerProvider extends BaseProvider {
|
|
|
64
68
|
return error;
|
|
65
69
|
}
|
|
66
70
|
if (error instanceof Error && error.name === "TimeoutError") {
|
|
67
|
-
return new SageMakerError(`SageMaker request timed out. Consider increasing timeout.`,
|
|
71
|
+
return new SageMakerError(`SageMaker request timed out. Consider increasing timeout.`, {
|
|
72
|
+
code: "NETWORK_ERROR",
|
|
73
|
+
statusCode: 408,
|
|
74
|
+
cause: error,
|
|
75
|
+
endpoint: this.modelConfig.endpointName,
|
|
76
|
+
});
|
|
68
77
|
}
|
|
69
78
|
return handleSageMakerError(error, this.modelConfig.endpointName);
|
|
70
79
|
}
|
|
@@ -17,7 +17,7 @@ export declare class AnthropicProvider extends BaseProvider {
|
|
|
17
17
|
*/
|
|
18
18
|
protected getAISDKModel(): LanguageModelV1;
|
|
19
19
|
protected handleProviderError(error: unknown): Error;
|
|
20
|
-
protected executeStream(options: StreamOptions,
|
|
20
|
+
protected executeStream(options: StreamOptions, _analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
21
21
|
isAvailable(): Promise<boolean>;
|
|
22
22
|
getModel(): LanguageModelV1;
|
|
23
23
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
+
import { AnthropicModels } from "../core/types.js";
|
|
3
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
5
|
import { logger } from "../utils/logger.js";
|
|
5
|
-
import { createTimeoutController, TimeoutError
|
|
6
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
7
|
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/errors.js";
|
|
7
8
|
import { DEFAULT_MAX_TOKENS, DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
8
9
|
import { validateApiKey, createAnthropicConfig, getProviderModel, } from "../utils/providerConfig.js";
|
|
@@ -13,7 +14,7 @@ const getAnthropicApiKey = () => {
|
|
|
13
14
|
return validateApiKey(createAnthropicConfig());
|
|
14
15
|
};
|
|
15
16
|
const getDefaultAnthropicModel = () => {
|
|
16
|
-
return getProviderModel("ANTHROPIC_MODEL",
|
|
17
|
+
return getProviderModel("ANTHROPIC_MODEL", AnthropicModels.CLAUDE_3_5_SONNET);
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* Anthropic Provider v2 - BaseProvider Implementation
|
|
@@ -83,7 +84,7 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
83
84
|
throw new ProviderError(`Anthropic error: ${message}`, this.providerName);
|
|
84
85
|
}
|
|
85
86
|
// executeGenerate removed - BaseProvider handles all generation with tools
|
|
86
|
-
async executeStream(options,
|
|
87
|
+
async executeStream(options, _analysisSchema) {
|
|
87
88
|
this.validateStreamOptions(options);
|
|
88
89
|
const timeout = this.getTimeout(options);
|
|
89
90
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
@@ -120,9 +121,9 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
120
121
|
toolResults, // ✅ Include tool results in stream result
|
|
121
122
|
usage: usage
|
|
122
123
|
? {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
input: usage.promptTokens || 0,
|
|
125
|
+
output: usage.completionTokens || 0,
|
|
126
|
+
total: usage.totalTokens || 0,
|
|
126
127
|
}
|
|
127
128
|
: undefined,
|
|
128
129
|
finishReason: finishReason || undefined,
|
|
@@ -18,6 +18,6 @@ export declare class AnthropicProviderV2 extends BaseProvider {
|
|
|
18
18
|
protected getAISDKModel(): LanguageModelV1;
|
|
19
19
|
protected handleProviderError(error: unknown): Error;
|
|
20
20
|
private getApiKey;
|
|
21
|
-
protected executeStream(options: StreamOptions,
|
|
21
|
+
protected executeStream(options: StreamOptions, _analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
|
|
22
22
|
}
|
|
23
23
|
export default AnthropicProviderV2;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
+
import { AnthropicModels } from "../core/types.js";
|
|
3
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
5
|
import { logger } from "../utils/logger.js";
|
|
5
|
-
import { createTimeoutController, TimeoutError
|
|
6
|
+
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
7
|
import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
|
|
7
8
|
import { validateApiKey, createAnthropicBaseConfig, } from "../utils/providerConfig.js";
|
|
8
9
|
/**
|
|
@@ -25,7 +26,7 @@ export class AnthropicProviderV2 extends BaseProvider {
|
|
|
25
26
|
return "anthropic";
|
|
26
27
|
}
|
|
27
28
|
getDefaultModel() {
|
|
28
|
-
return process.env.ANTHROPIC_MODEL ||
|
|
29
|
+
return process.env.ANTHROPIC_MODEL || AnthropicModels.CLAUDE_3_5_SONNET;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Returns the Vercel AI SDK model instance for Anthropic
|
|
@@ -56,7 +57,7 @@ export class AnthropicProviderV2 extends BaseProvider {
|
|
|
56
57
|
return validateApiKey(createAnthropicBaseConfig());
|
|
57
58
|
}
|
|
58
59
|
// executeGenerate removed - BaseProvider handles all generation with tools
|
|
59
|
-
async executeStream(options,
|
|
60
|
+
async executeStream(options, _analysisSchema) {
|
|
60
61
|
// Note: StreamOptions validation handled differently than TextGenerationOptions
|
|
61
62
|
const apiKey = this.getApiKey();
|
|
62
63
|
const anthropicClient = createAnthropic({ apiKey });
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Credential Provider for NeuroLink
|
|
3
|
+
*
|
|
4
|
+
* Provides 100% compatibility with Bedrock-MCP-Connector authentication patterns
|
|
5
|
+
* by leveraging AWS SDK v3's official defaultProvider credential chain.
|
|
6
|
+
*
|
|
7
|
+
* Supports all 9 AWS credential sources:
|
|
8
|
+
* 1. Environment Variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
|
|
9
|
+
* 2. AWS Credentials File (~/.aws/credentials)
|
|
10
|
+
* 3. AWS Config File (~/.aws/config)
|
|
11
|
+
* 4. IAM Roles (EC2/ECS/Lambda)
|
|
12
|
+
* 5. AWS SSO
|
|
13
|
+
* 6. STS Assume Role
|
|
14
|
+
* 7. Credential Process
|
|
15
|
+
* 8. Container Credentials
|
|
16
|
+
* 9. Instance Metadata Service (IMDS)
|
|
17
|
+
*/
|
|
18
|
+
import type { AwsCredentialIdentity, Provider } from "@aws-sdk/types";
|
|
19
|
+
import type { AWSCredentialConfig } from "../../types/providers.js";
|
|
20
|
+
/**
|
|
21
|
+
* AWS Credential Provider class that wraps AWS SDK v3's defaultProvider
|
|
22
|
+
* to provide seamless compatibility with Bedrock-MCP-Connector authentication
|
|
23
|
+
*/
|
|
24
|
+
export declare class AWSCredentialProvider {
|
|
25
|
+
private credentialProvider;
|
|
26
|
+
private config;
|
|
27
|
+
private isInitialized;
|
|
28
|
+
private lastCredentials;
|
|
29
|
+
private lastRefresh;
|
|
30
|
+
constructor(config?: AWSCredentialConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Get AWS credentials using the default provider chain
|
|
33
|
+
* Implements caching to avoid unnecessary credential resolution calls
|
|
34
|
+
*/
|
|
35
|
+
getCredentials(): Promise<AwsCredentialIdentity>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the raw credential provider for direct use with AWS SDK clients
|
|
38
|
+
* This allows the credential provider to be passed directly to BedrockRuntimeClient
|
|
39
|
+
*/
|
|
40
|
+
getCredentialProvider(): Provider<AwsCredentialIdentity>;
|
|
41
|
+
/**
|
|
42
|
+
* Force refresh of cached credentials
|
|
43
|
+
* Useful when credentials may have been updated externally
|
|
44
|
+
*/
|
|
45
|
+
refreshCredentials(): Promise<AwsCredentialIdentity>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if credentials are currently available without throwing errors
|
|
48
|
+
*/
|
|
49
|
+
isCredentialsAvailable(): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Get configuration information for debugging
|
|
52
|
+
*/
|
|
53
|
+
getConfig(): Readonly<Required<AWSCredentialConfig>>;
|
|
54
|
+
/**
|
|
55
|
+
* Clean up resources and clear cached credentials
|
|
56
|
+
*/
|
|
57
|
+
dispose(): void;
|
|
58
|
+
}
|