@ai-sdk/amazon-bedrock 4.0.21 → 4.0.22
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 +6 -0
- package/anthropic/index.d.ts +1 -0
- package/dist/anthropic/index.d.mts +91 -0
- package/dist/anthropic/index.d.ts +91 -0
- package/dist/anthropic/index.js +404 -0
- package/dist/anthropic/index.js.map +1 -0
- package/dist/anthropic/index.mjs +392 -0
- package/dist/anthropic/index.mjs.map +1 -0
- package/dist/index.js +68 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/anthropic';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
4
|
+
|
|
5
|
+
interface BedrockCredentials {
|
|
6
|
+
region: string;
|
|
7
|
+
accessKeyId: string;
|
|
8
|
+
secretAccessKey: string;
|
|
9
|
+
sessionToken?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
|
|
13
|
+
|
|
14
|
+
interface BedrockAnthropicProvider extends ProviderV3 {
|
|
15
|
+
/**
|
|
16
|
+
Creates a model for text generation.
|
|
17
|
+
*/
|
|
18
|
+
(modelId: BedrockAnthropicModelId): LanguageModelV3;
|
|
19
|
+
/**
|
|
20
|
+
Creates a model for text generation.
|
|
21
|
+
*/
|
|
22
|
+
languageModel(modelId: BedrockAnthropicModelId): LanguageModelV3;
|
|
23
|
+
/**
|
|
24
|
+
Anthropic-specific computer use tool.
|
|
25
|
+
*/
|
|
26
|
+
tools: typeof anthropicTools;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `embeddingModel` instead.
|
|
29
|
+
*/
|
|
30
|
+
textEmbeddingModel(modelId: string): never;
|
|
31
|
+
}
|
|
32
|
+
interface BedrockAnthropicProviderSettings {
|
|
33
|
+
/**
|
|
34
|
+
The AWS region to use for the Bedrock provider. Defaults to the value of the
|
|
35
|
+
`AWS_REGION` environment variable.
|
|
36
|
+
*/
|
|
37
|
+
region?: string;
|
|
38
|
+
/**
|
|
39
|
+
API key for authenticating requests using Bearer token authentication.
|
|
40
|
+
When provided, this will be used instead of AWS SigV4 authentication.
|
|
41
|
+
Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.
|
|
42
|
+
*/
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
/**
|
|
45
|
+
The AWS access key ID to use for the Bedrock provider. Defaults to the value of the
|
|
46
|
+
`AWS_ACCESS_KEY_ID` environment variable.
|
|
47
|
+
*/
|
|
48
|
+
accessKeyId?: string;
|
|
49
|
+
/**
|
|
50
|
+
The AWS secret access key to use for the Bedrock provider. Defaults to the value of the
|
|
51
|
+
`AWS_SECRET_ACCESS_KEY` environment variable.
|
|
52
|
+
*/
|
|
53
|
+
secretAccessKey?: string;
|
|
54
|
+
/**
|
|
55
|
+
The AWS session token to use for the Bedrock provider. Defaults to the value of the
|
|
56
|
+
`AWS_SESSION_TOKEN` environment variable.
|
|
57
|
+
*/
|
|
58
|
+
sessionToken?: string;
|
|
59
|
+
/**
|
|
60
|
+
Base URL for the Bedrock API calls.
|
|
61
|
+
*/
|
|
62
|
+
baseURL?: string;
|
|
63
|
+
/**
|
|
64
|
+
Custom headers to include in the requests.
|
|
65
|
+
*/
|
|
66
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
67
|
+
/**
|
|
68
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
69
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
70
|
+
*/
|
|
71
|
+
fetch?: FetchFunction;
|
|
72
|
+
/**
|
|
73
|
+
The AWS credential provider to use for the Bedrock provider to get dynamic
|
|
74
|
+
credentials similar to the AWS SDK. Setting a provider here will cause its
|
|
75
|
+
credential values to be used instead of the `accessKeyId`, `secretAccessKey`,
|
|
76
|
+
and `sessionToken` settings.
|
|
77
|
+
*/
|
|
78
|
+
credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
Create an Amazon Bedrock Anthropic provider instance.
|
|
82
|
+
This provider uses the native Anthropic API through Bedrock's InvokeModel endpoint,
|
|
83
|
+
bypassing the Converse API for better feature compatibility.
|
|
84
|
+
*/
|
|
85
|
+
declare function createBedrockAnthropic(options?: BedrockAnthropicProviderSettings): BedrockAnthropicProvider;
|
|
86
|
+
/**
|
|
87
|
+
Default Bedrock Anthropic provider instance.
|
|
88
|
+
*/
|
|
89
|
+
declare const bedrockAnthropic: BedrockAnthropicProvider;
|
|
90
|
+
|
|
91
|
+
export { type BedrockAnthropicModelId, type BedrockAnthropicProvider, type BedrockAnthropicProviderSettings, bedrockAnthropic, createBedrockAnthropic };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { anthropicTools } from '@ai-sdk/anthropic/internal';
|
|
4
|
+
|
|
5
|
+
interface BedrockCredentials {
|
|
6
|
+
region: string;
|
|
7
|
+
accessKeyId: string;
|
|
8
|
+
secretAccessKey: string;
|
|
9
|
+
sessionToken?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type BedrockAnthropicModelId = 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
|
|
13
|
+
|
|
14
|
+
interface BedrockAnthropicProvider extends ProviderV3 {
|
|
15
|
+
/**
|
|
16
|
+
Creates a model for text generation.
|
|
17
|
+
*/
|
|
18
|
+
(modelId: BedrockAnthropicModelId): LanguageModelV3;
|
|
19
|
+
/**
|
|
20
|
+
Creates a model for text generation.
|
|
21
|
+
*/
|
|
22
|
+
languageModel(modelId: BedrockAnthropicModelId): LanguageModelV3;
|
|
23
|
+
/**
|
|
24
|
+
Anthropic-specific computer use tool.
|
|
25
|
+
*/
|
|
26
|
+
tools: typeof anthropicTools;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `embeddingModel` instead.
|
|
29
|
+
*/
|
|
30
|
+
textEmbeddingModel(modelId: string): never;
|
|
31
|
+
}
|
|
32
|
+
interface BedrockAnthropicProviderSettings {
|
|
33
|
+
/**
|
|
34
|
+
The AWS region to use for the Bedrock provider. Defaults to the value of the
|
|
35
|
+
`AWS_REGION` environment variable.
|
|
36
|
+
*/
|
|
37
|
+
region?: string;
|
|
38
|
+
/**
|
|
39
|
+
API key for authenticating requests using Bearer token authentication.
|
|
40
|
+
When provided, this will be used instead of AWS SigV4 authentication.
|
|
41
|
+
Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.
|
|
42
|
+
*/
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
/**
|
|
45
|
+
The AWS access key ID to use for the Bedrock provider. Defaults to the value of the
|
|
46
|
+
`AWS_ACCESS_KEY_ID` environment variable.
|
|
47
|
+
*/
|
|
48
|
+
accessKeyId?: string;
|
|
49
|
+
/**
|
|
50
|
+
The AWS secret access key to use for the Bedrock provider. Defaults to the value of the
|
|
51
|
+
`AWS_SECRET_ACCESS_KEY` environment variable.
|
|
52
|
+
*/
|
|
53
|
+
secretAccessKey?: string;
|
|
54
|
+
/**
|
|
55
|
+
The AWS session token to use for the Bedrock provider. Defaults to the value of the
|
|
56
|
+
`AWS_SESSION_TOKEN` environment variable.
|
|
57
|
+
*/
|
|
58
|
+
sessionToken?: string;
|
|
59
|
+
/**
|
|
60
|
+
Base URL for the Bedrock API calls.
|
|
61
|
+
*/
|
|
62
|
+
baseURL?: string;
|
|
63
|
+
/**
|
|
64
|
+
Custom headers to include in the requests.
|
|
65
|
+
*/
|
|
66
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
67
|
+
/**
|
|
68
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
69
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
70
|
+
*/
|
|
71
|
+
fetch?: FetchFunction;
|
|
72
|
+
/**
|
|
73
|
+
The AWS credential provider to use for the Bedrock provider to get dynamic
|
|
74
|
+
credentials similar to the AWS SDK. Setting a provider here will cause its
|
|
75
|
+
credential values to be used instead of the `accessKeyId`, `secretAccessKey`,
|
|
76
|
+
and `sessionToken` settings.
|
|
77
|
+
*/
|
|
78
|
+
credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
Create an Amazon Bedrock Anthropic provider instance.
|
|
82
|
+
This provider uses the native Anthropic API through Bedrock's InvokeModel endpoint,
|
|
83
|
+
bypassing the Converse API for better feature compatibility.
|
|
84
|
+
*/
|
|
85
|
+
declare function createBedrockAnthropic(options?: BedrockAnthropicProviderSettings): BedrockAnthropicProvider;
|
|
86
|
+
/**
|
|
87
|
+
Default Bedrock Anthropic provider instance.
|
|
88
|
+
*/
|
|
89
|
+
declare const bedrockAnthropic: BedrockAnthropicProvider;
|
|
90
|
+
|
|
91
|
+
export { type BedrockAnthropicModelId, type BedrockAnthropicProvider, type BedrockAnthropicProviderSettings, bedrockAnthropic, createBedrockAnthropic };
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/anthropic/index.ts
|
|
21
|
+
var anthropic_exports = {};
|
|
22
|
+
__export(anthropic_exports, {
|
|
23
|
+
bedrockAnthropic: () => bedrockAnthropic,
|
|
24
|
+
createBedrockAnthropic: () => createBedrockAnthropic
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(anthropic_exports);
|
|
27
|
+
|
|
28
|
+
// src/anthropic/bedrock-anthropic-provider.ts
|
|
29
|
+
var import_provider = require("@ai-sdk/provider");
|
|
30
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
31
|
+
var import_internal = require("@ai-sdk/anthropic/internal");
|
|
32
|
+
|
|
33
|
+
// src/bedrock-sigv4-fetch.ts
|
|
34
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
35
|
+
var import_aws4fetch = require("aws4fetch");
|
|
36
|
+
|
|
37
|
+
// src/version.ts
|
|
38
|
+
var VERSION = true ? "4.0.22" : "0.0.0-test";
|
|
39
|
+
|
|
40
|
+
// src/bedrock-sigv4-fetch.ts
|
|
41
|
+
function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
|
|
42
|
+
return async (input, init) => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const request = input instanceof Request ? input : void 0;
|
|
45
|
+
const originalHeaders = (0, import_provider_utils.combineHeaders)(
|
|
46
|
+
(0, import_provider_utils.normalizeHeaders)(request == null ? void 0 : request.headers),
|
|
47
|
+
(0, import_provider_utils.normalizeHeaders)(init == null ? void 0 : init.headers)
|
|
48
|
+
);
|
|
49
|
+
const headersWithUserAgent = (0, import_provider_utils.withUserAgentSuffix)(
|
|
50
|
+
originalHeaders,
|
|
51
|
+
`ai-sdk/amazon-bedrock/${VERSION}`,
|
|
52
|
+
(0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
|
|
53
|
+
);
|
|
54
|
+
let effectiveBody = (_a = init == null ? void 0 : init.body) != null ? _a : void 0;
|
|
55
|
+
if (effectiveBody === void 0 && request && request.body !== null) {
|
|
56
|
+
try {
|
|
57
|
+
effectiveBody = await request.clone().text();
|
|
58
|
+
} catch (e) {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const effectiveMethod = (_b = init == null ? void 0 : init.method) != null ? _b : request == null ? void 0 : request.method;
|
|
62
|
+
if ((effectiveMethod == null ? void 0 : effectiveMethod.toUpperCase()) !== "POST" || !effectiveBody) {
|
|
63
|
+
return fetch(input, {
|
|
64
|
+
...init,
|
|
65
|
+
headers: headersWithUserAgent
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
69
|
+
const body = prepareBodyString(effectiveBody);
|
|
70
|
+
const credentials = await getCredentials();
|
|
71
|
+
const signer = new import_aws4fetch.AwsV4Signer({
|
|
72
|
+
url,
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: Object.entries(headersWithUserAgent),
|
|
75
|
+
body,
|
|
76
|
+
region: credentials.region,
|
|
77
|
+
accessKeyId: credentials.accessKeyId,
|
|
78
|
+
secretAccessKey: credentials.secretAccessKey,
|
|
79
|
+
sessionToken: credentials.sessionToken,
|
|
80
|
+
service: "bedrock"
|
|
81
|
+
});
|
|
82
|
+
const signingResult = await signer.sign();
|
|
83
|
+
const signedHeaders = (0, import_provider_utils.normalizeHeaders)(signingResult.headers);
|
|
84
|
+
const combinedHeaders = (0, import_provider_utils.combineHeaders)(headersWithUserAgent, signedHeaders);
|
|
85
|
+
return fetch(input, {
|
|
86
|
+
...init,
|
|
87
|
+
body,
|
|
88
|
+
headers: combinedHeaders
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function prepareBodyString(body) {
|
|
93
|
+
if (typeof body === "string") {
|
|
94
|
+
return body;
|
|
95
|
+
} else if (body instanceof Uint8Array) {
|
|
96
|
+
return new TextDecoder().decode(body);
|
|
97
|
+
} else if (body instanceof ArrayBuffer) {
|
|
98
|
+
return new TextDecoder().decode(new Uint8Array(body));
|
|
99
|
+
} else {
|
|
100
|
+
return JSON.stringify(body);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
|
|
104
|
+
return async (input, init) => {
|
|
105
|
+
const originalHeaders = (0, import_provider_utils.normalizeHeaders)(init == null ? void 0 : init.headers);
|
|
106
|
+
const headersWithUserAgent = (0, import_provider_utils.withUserAgentSuffix)(
|
|
107
|
+
originalHeaders,
|
|
108
|
+
`ai-sdk/amazon-bedrock/${VERSION}`,
|
|
109
|
+
(0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
|
|
110
|
+
);
|
|
111
|
+
const finalHeaders = (0, import_provider_utils.combineHeaders)(headersWithUserAgent, {
|
|
112
|
+
Authorization: `Bearer ${apiKey}`
|
|
113
|
+
});
|
|
114
|
+
return fetch(input, {
|
|
115
|
+
...init,
|
|
116
|
+
headers: finalHeaders
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/anthropic/bedrock-anthropic-fetch.ts
|
|
122
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
123
|
+
|
|
124
|
+
// src/bedrock-event-stream-decoder.ts
|
|
125
|
+
var import_eventstream_codec = require("@smithy/eventstream-codec");
|
|
126
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
|
127
|
+
function createBedrockEventStreamDecoder(body, processEvent) {
|
|
128
|
+
const codec = new import_eventstream_codec.EventStreamCodec(import_util_utf8.toUtf8, import_util_utf8.fromUtf8);
|
|
129
|
+
let buffer = new Uint8Array(0);
|
|
130
|
+
const textDecoder = new TextDecoder();
|
|
131
|
+
return body.pipeThrough(
|
|
132
|
+
new TransformStream({
|
|
133
|
+
async transform(chunk, controller) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
const newBuffer = new Uint8Array(buffer.length + chunk.length);
|
|
136
|
+
newBuffer.set(buffer);
|
|
137
|
+
newBuffer.set(chunk, buffer.length);
|
|
138
|
+
buffer = newBuffer;
|
|
139
|
+
while (buffer.length >= 4) {
|
|
140
|
+
const totalLength = new DataView(
|
|
141
|
+
buffer.buffer,
|
|
142
|
+
buffer.byteOffset,
|
|
143
|
+
buffer.byteLength
|
|
144
|
+
).getUint32(0, false);
|
|
145
|
+
if (buffer.length < totalLength) {
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const subView = buffer.subarray(0, totalLength);
|
|
150
|
+
const decoded = codec.decode(subView);
|
|
151
|
+
buffer = buffer.slice(totalLength);
|
|
152
|
+
const messageType = (_a = decoded.headers[":message-type"]) == null ? void 0 : _a.value;
|
|
153
|
+
const eventType = (_b = decoded.headers[":event-type"]) == null ? void 0 : _b.value;
|
|
154
|
+
const data = textDecoder.decode(decoded.body);
|
|
155
|
+
await processEvent({ messageType, eventType, data }, controller);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/anthropic/bedrock-anthropic-fetch.ts
|
|
166
|
+
function createBedrockAnthropicFetch(baseFetch) {
|
|
167
|
+
return async (url, options) => {
|
|
168
|
+
const response = await baseFetch(url, options);
|
|
169
|
+
const contentType = response.headers.get("content-type");
|
|
170
|
+
if ((contentType == null ? void 0 : contentType.includes("application/vnd.amazon.eventstream")) && response.body != null) {
|
|
171
|
+
const transformedBody = transformBedrockEventStreamToSSE(response.body);
|
|
172
|
+
return new Response(transformedBody, {
|
|
173
|
+
status: response.status,
|
|
174
|
+
statusText: response.statusText,
|
|
175
|
+
headers: new Headers({
|
|
176
|
+
...Object.fromEntries(response.headers.entries()),
|
|
177
|
+
"content-type": "text/event-stream"
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return response;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function transformBedrockEventStreamToSSE(body) {
|
|
185
|
+
const textEncoder = new TextEncoder();
|
|
186
|
+
return createBedrockEventStreamDecoder(body, async (event, controller) => {
|
|
187
|
+
if (event.messageType === "event") {
|
|
188
|
+
if (event.eventType === "chunk") {
|
|
189
|
+
const parsed = await (0, import_provider_utils2.safeParseJSON)({ text: event.data });
|
|
190
|
+
if (!parsed.success) {
|
|
191
|
+
controller.enqueue(textEncoder.encode(`data: ${event.data}
|
|
192
|
+
|
|
193
|
+
`));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const bytes = parsed.value.bytes;
|
|
197
|
+
if (bytes) {
|
|
198
|
+
const anthropicEvent = atob(bytes);
|
|
199
|
+
controller.enqueue(textEncoder.encode(`data: ${anthropicEvent}
|
|
200
|
+
|
|
201
|
+
`));
|
|
202
|
+
} else {
|
|
203
|
+
controller.enqueue(textEncoder.encode(`data: ${event.data}
|
|
204
|
+
|
|
205
|
+
`));
|
|
206
|
+
}
|
|
207
|
+
} else if (event.eventType === "messageStop") {
|
|
208
|
+
controller.enqueue(textEncoder.encode("data: [DONE]\n\n"));
|
|
209
|
+
}
|
|
210
|
+
} else if (event.messageType === "exception") {
|
|
211
|
+
controller.enqueue(
|
|
212
|
+
textEncoder.encode(
|
|
213
|
+
`data: ${JSON.stringify({ type: "error", error: event.data })}
|
|
214
|
+
|
|
215
|
+
`
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/anthropic/bedrock-anthropic-provider.ts
|
|
223
|
+
var BEDROCK_TOOL_VERSION_MAP = {
|
|
224
|
+
bash_20241022: "bash_20250124",
|
|
225
|
+
text_editor_20241022: "text_editor_20250728",
|
|
226
|
+
computer_20241022: "computer_20250124"
|
|
227
|
+
};
|
|
228
|
+
var BEDROCK_TOOL_NAME_MAP = {
|
|
229
|
+
text_editor_20250728: "str_replace_based_edit_tool"
|
|
230
|
+
};
|
|
231
|
+
var BEDROCK_TOOL_BETA_MAP = {
|
|
232
|
+
bash_20250124: "computer-use-2025-01-24",
|
|
233
|
+
bash_20241022: "computer-use-2024-10-22",
|
|
234
|
+
text_editor_20250124: "computer-use-2025-01-24",
|
|
235
|
+
text_editor_20241022: "computer-use-2024-10-22",
|
|
236
|
+
text_editor_20250429: "computer-use-2025-01-24",
|
|
237
|
+
text_editor_20250728: "computer-use-2025-01-24",
|
|
238
|
+
computer_20250124: "computer-use-2025-01-24",
|
|
239
|
+
computer_20241022: "computer-use-2024-10-22"
|
|
240
|
+
};
|
|
241
|
+
function createBedrockAnthropic(options = {}) {
|
|
242
|
+
const rawApiKey = (0, import_provider_utils3.loadOptionalSetting)({
|
|
243
|
+
settingValue: options.apiKey,
|
|
244
|
+
environmentVariableName: "AWS_BEARER_TOKEN_BEDROCK"
|
|
245
|
+
});
|
|
246
|
+
const apiKey = rawApiKey && rawApiKey.trim().length > 0 ? rawApiKey.trim() : void 0;
|
|
247
|
+
const baseFetchFunction = apiKey ? createApiKeyFetchFunction(apiKey, options.fetch) : createSigV4FetchFunction(async () => {
|
|
248
|
+
const region = (0, import_provider_utils3.loadSetting)({
|
|
249
|
+
settingValue: options.region,
|
|
250
|
+
settingName: "region",
|
|
251
|
+
environmentVariableName: "AWS_REGION",
|
|
252
|
+
description: "AWS region"
|
|
253
|
+
});
|
|
254
|
+
if (options.credentialProvider) {
|
|
255
|
+
try {
|
|
256
|
+
return {
|
|
257
|
+
...await options.credentialProvider(),
|
|
258
|
+
region
|
|
259
|
+
};
|
|
260
|
+
} catch (error) {
|
|
261
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
262
|
+
throw new Error(
|
|
263
|
+
`AWS credential provider failed: ${errorMessage}. Please ensure your credential provider returns valid AWS credentials with accessKeyId and secretAccessKey properties.`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
return {
|
|
269
|
+
region,
|
|
270
|
+
accessKeyId: (0, import_provider_utils3.loadSetting)({
|
|
271
|
+
settingValue: options.accessKeyId,
|
|
272
|
+
settingName: "accessKeyId",
|
|
273
|
+
environmentVariableName: "AWS_ACCESS_KEY_ID",
|
|
274
|
+
description: "AWS access key ID"
|
|
275
|
+
}),
|
|
276
|
+
secretAccessKey: (0, import_provider_utils3.loadSetting)({
|
|
277
|
+
settingValue: options.secretAccessKey,
|
|
278
|
+
settingName: "secretAccessKey",
|
|
279
|
+
environmentVariableName: "AWS_SECRET_ACCESS_KEY",
|
|
280
|
+
description: "AWS secret access key"
|
|
281
|
+
}),
|
|
282
|
+
sessionToken: (0, import_provider_utils3.loadOptionalSetting)({
|
|
283
|
+
settingValue: options.sessionToken,
|
|
284
|
+
environmentVariableName: "AWS_SESSION_TOKEN"
|
|
285
|
+
})
|
|
286
|
+
};
|
|
287
|
+
} catch (error) {
|
|
288
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
289
|
+
if (errorMessage.includes("AWS_ACCESS_KEY_ID") || errorMessage.includes("accessKeyId")) {
|
|
290
|
+
throw new Error(
|
|
291
|
+
`AWS SigV4 authentication requires AWS credentials. Please provide either:
|
|
292
|
+
1. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
|
|
293
|
+
2. Provide accessKeyId and secretAccessKey in options
|
|
294
|
+
3. Use a credentialProvider function
|
|
295
|
+
4. Use API key authentication with AWS_BEARER_TOKEN_BEDROCK or apiKey option
|
|
296
|
+
Original error: ${errorMessage}`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
if (errorMessage.includes("AWS_SECRET_ACCESS_KEY") || errorMessage.includes("secretAccessKey")) {
|
|
300
|
+
throw new Error(
|
|
301
|
+
`AWS SigV4 authentication requires both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Please ensure both credentials are provided.
|
|
302
|
+
Original error: ${errorMessage}`
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}, options.fetch);
|
|
308
|
+
const fetchFunction = createBedrockAnthropicFetch(baseFetchFunction);
|
|
309
|
+
const getBaseURL = () => {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
return (_b = (0, import_provider_utils3.withoutTrailingSlash)(
|
|
312
|
+
(_a = options.baseURL) != null ? _a : `https://bedrock-runtime.${(0, import_provider_utils3.loadSetting)({
|
|
313
|
+
settingValue: options.region,
|
|
314
|
+
settingName: "region",
|
|
315
|
+
environmentVariableName: "AWS_REGION",
|
|
316
|
+
description: "AWS region"
|
|
317
|
+
})}.amazonaws.com`
|
|
318
|
+
)) != null ? _b : "https://bedrock-runtime.us-east-1.amazonaws.com";
|
|
319
|
+
};
|
|
320
|
+
const getHeaders = async () => {
|
|
321
|
+
var _a;
|
|
322
|
+
const baseHeaders = (_a = await (0, import_provider_utils3.resolve)(options.headers)) != null ? _a : {};
|
|
323
|
+
return (0, import_provider_utils3.withUserAgentSuffix)(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION}`);
|
|
324
|
+
};
|
|
325
|
+
const createChatModel = (modelId) => new import_internal.AnthropicMessagesLanguageModel(modelId, {
|
|
326
|
+
provider: "bedrock.anthropic.messages",
|
|
327
|
+
baseURL: getBaseURL(),
|
|
328
|
+
headers: getHeaders,
|
|
329
|
+
fetch: fetchFunction,
|
|
330
|
+
buildRequestUrl: (baseURL, isStreaming) => `${baseURL}/model/${encodeURIComponent(modelId)}/${isStreaming ? "invoke-with-response-stream" : "invoke"}`,
|
|
331
|
+
transformRequestBody: (args) => {
|
|
332
|
+
const { model, stream, tool_choice, tools, ...rest } = args;
|
|
333
|
+
const transformedToolChoice = tool_choice != null ? {
|
|
334
|
+
type: tool_choice.type,
|
|
335
|
+
...tool_choice.name != null ? { name: tool_choice.name } : {}
|
|
336
|
+
} : void 0;
|
|
337
|
+
const requiredBetas = /* @__PURE__ */ new Set();
|
|
338
|
+
const transformedTools = tools == null ? void 0 : tools.map((tool) => {
|
|
339
|
+
const toolType = tool.type;
|
|
340
|
+
if (toolType && toolType in BEDROCK_TOOL_VERSION_MAP) {
|
|
341
|
+
const newType = BEDROCK_TOOL_VERSION_MAP[toolType];
|
|
342
|
+
if (newType in BEDROCK_TOOL_BETA_MAP) {
|
|
343
|
+
requiredBetas.add(BEDROCK_TOOL_BETA_MAP[newType]);
|
|
344
|
+
}
|
|
345
|
+
const newName = newType in BEDROCK_TOOL_NAME_MAP ? BEDROCK_TOOL_NAME_MAP[newType] : tool.name;
|
|
346
|
+
return {
|
|
347
|
+
...tool,
|
|
348
|
+
type: newType,
|
|
349
|
+
name: newName
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
if (toolType && toolType in BEDROCK_TOOL_BETA_MAP) {
|
|
353
|
+
requiredBetas.add(BEDROCK_TOOL_BETA_MAP[toolType]);
|
|
354
|
+
}
|
|
355
|
+
if (toolType && toolType in BEDROCK_TOOL_NAME_MAP) {
|
|
356
|
+
return {
|
|
357
|
+
...tool,
|
|
358
|
+
name: BEDROCK_TOOL_NAME_MAP[toolType]
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return tool;
|
|
362
|
+
});
|
|
363
|
+
return {
|
|
364
|
+
...rest,
|
|
365
|
+
...transformedTools != null ? { tools: transformedTools } : {},
|
|
366
|
+
...transformedToolChoice != null ? { tool_choice: transformedToolChoice } : {},
|
|
367
|
+
...requiredBetas.size > 0 ? { anthropic_beta: Array.from(requiredBetas) } : {},
|
|
368
|
+
anthropic_version: "bedrock-2023-05-31"
|
|
369
|
+
};
|
|
370
|
+
},
|
|
371
|
+
// Bedrock Anthropic doesn't support URL sources, force download and base64 conversion
|
|
372
|
+
supportedUrls: () => ({}),
|
|
373
|
+
// force the use of JSON tool fallback for structured outputs since beta header isn't supported
|
|
374
|
+
supportsNativeStructuredOutput: false
|
|
375
|
+
});
|
|
376
|
+
const provider = function(modelId) {
|
|
377
|
+
if (new.target) {
|
|
378
|
+
throw new Error(
|
|
379
|
+
"The Bedrock Anthropic model function cannot be called with the new keyword."
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
return createChatModel(modelId);
|
|
383
|
+
};
|
|
384
|
+
provider.specificationVersion = "v3";
|
|
385
|
+
provider.languageModel = createChatModel;
|
|
386
|
+
provider.chat = createChatModel;
|
|
387
|
+
provider.messages = createChatModel;
|
|
388
|
+
provider.embeddingModel = (modelId) => {
|
|
389
|
+
throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
390
|
+
};
|
|
391
|
+
provider.textEmbeddingModel = provider.embeddingModel;
|
|
392
|
+
provider.imageModel = (modelId) => {
|
|
393
|
+
throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
394
|
+
};
|
|
395
|
+
provider.tools = import_internal.anthropicTools;
|
|
396
|
+
return provider;
|
|
397
|
+
}
|
|
398
|
+
var bedrockAnthropic = createBedrockAnthropic();
|
|
399
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
400
|
+
0 && (module.exports = {
|
|
401
|
+
bedrockAnthropic,
|
|
402
|
+
createBedrockAnthropic
|
|
403
|
+
});
|
|
404
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/anthropic/index.ts","../../src/anthropic/bedrock-anthropic-provider.ts","../../src/bedrock-sigv4-fetch.ts","../../src/version.ts","../../src/anthropic/bedrock-anthropic-fetch.ts","../../src/bedrock-event-stream-decoder.ts"],"sourcesContent":["export {\n bedrockAnthropic,\n createBedrockAnthropic,\n} from './bedrock-anthropic-provider';\nexport type {\n BedrockAnthropicProvider,\n BedrockAnthropicProviderSettings,\n} from './bedrock-anthropic-provider';\nexport type { BedrockAnthropicModelId } from './bedrock-anthropic-options';\n","import {\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadOptionalSetting,\n loadSetting,\n Resolvable,\n resolve,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicMessagesLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport {\n BedrockCredentials,\n createApiKeyFetchFunction,\n createSigV4FetchFunction,\n} from '../bedrock-sigv4-fetch';\nimport { createBedrockAnthropicFetch } from './bedrock-anthropic-fetch';\nimport { BedrockAnthropicModelId } from './bedrock-anthropic-options';\nimport { VERSION } from '../version';\n\n// Bedrock requires newer tool versions than the default Anthropic SDK versions\nconst BEDROCK_TOOL_VERSION_MAP = {\n bash_20241022: 'bash_20250124',\n text_editor_20241022: 'text_editor_20250728',\n computer_20241022: 'computer_20250124',\n} as const;\n\n// Tool name mappings when upgrading versions (text_editor_20250728 requires different name)\nconst BEDROCK_TOOL_NAME_MAP: Record<string, string> = {\n text_editor_20250728: 'str_replace_based_edit_tool',\n};\n\n// Map tool types to required anthropic_beta values for Bedrock\nconst BEDROCK_TOOL_BETA_MAP: Record<string, string> = {\n bash_20250124: 'computer-use-2025-01-24',\n bash_20241022: 'computer-use-2024-10-22',\n text_editor_20250124: 'computer-use-2025-01-24',\n text_editor_20241022: 'computer-use-2024-10-22',\n text_editor_20250429: 'computer-use-2025-01-24',\n text_editor_20250728: 'computer-use-2025-01-24',\n computer_20250124: 'computer-use-2025-01-24',\n computer_20241022: 'computer-use-2024-10-22',\n};\n\nexport interface BedrockAnthropicProvider extends ProviderV3 {\n /**\nCreates a model for text generation.\n*/\n (modelId: BedrockAnthropicModelId): LanguageModelV3;\n\n /**\nCreates a model for text generation.\n*/\n languageModel(modelId: BedrockAnthropicModelId): LanguageModelV3;\n\n /**\nAnthropic-specific computer use tool.\n */\n tools: typeof anthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface BedrockAnthropicProviderSettings {\n /**\nThe AWS region to use for the Bedrock provider. Defaults to the value of the\n`AWS_REGION` environment variable.\n */\n region?: string;\n\n /**\nAPI key for authenticating requests using Bearer token authentication.\nWhen provided, this will be used instead of AWS SigV4 authentication.\nDefaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.\n */\n apiKey?: string;\n\n /**\nThe AWS access key ID to use for the Bedrock provider. Defaults to the value of the\n`AWS_ACCESS_KEY_ID` environment variable.\n */\n accessKeyId?: string;\n\n /**\nThe AWS secret access key to use for the Bedrock provider. Defaults to the value of the\n`AWS_SECRET_ACCESS_KEY` environment variable.\n */\n secretAccessKey?: string;\n\n /**\nThe AWS session token to use for the Bedrock provider. Defaults to the value of the\n`AWS_SESSION_TOKEN` environment variable.\n */\n sessionToken?: string;\n\n /**\nBase URL for the Bedrock API calls.\n */\n baseURL?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n\n /**\nThe AWS credential provider to use for the Bedrock provider to get dynamic\ncredentials similar to the AWS SDK. Setting a provider here will cause its\ncredential values to be used instead of the `accessKeyId`, `secretAccessKey`,\nand `sessionToken` settings.\n */\n credentialProvider?: () => PromiseLike<Omit<BedrockCredentials, 'region'>>;\n}\n\n/**\nCreate an Amazon Bedrock Anthropic provider instance.\nThis provider uses the native Anthropic API through Bedrock's InvokeModel endpoint,\nbypassing the Converse API for better feature compatibility.\n */\nexport function createBedrockAnthropic(\n options: BedrockAnthropicProviderSettings = {},\n): BedrockAnthropicProvider {\n // Check for API key authentication first\n const rawApiKey = loadOptionalSetting({\n settingValue: options.apiKey,\n environmentVariableName: 'AWS_BEARER_TOKEN_BEDROCK',\n });\n\n // Only use API key if it's a non-empty, non-whitespace string\n const apiKey =\n rawApiKey && rawApiKey.trim().length > 0 ? rawApiKey.trim() : undefined;\n\n // Use API key authentication if available, otherwise fall back to SigV4\n const baseFetchFunction = apiKey\n ? createApiKeyFetchFunction(apiKey, options.fetch)\n : createSigV4FetchFunction(async () => {\n const region = loadSetting({\n settingValue: options.region,\n settingName: 'region',\n environmentVariableName: 'AWS_REGION',\n description: 'AWS region',\n });\n\n // If a credential provider is provided, use it to get the credentials.\n if (options.credentialProvider) {\n try {\n return {\n ...(await options.credentialProvider()),\n region,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n throw new Error(\n `AWS credential provider failed: ${errorMessage}. ` +\n 'Please ensure your credential provider returns valid AWS credentials ' +\n 'with accessKeyId and secretAccessKey properties.',\n );\n }\n }\n\n try {\n return {\n region,\n accessKeyId: loadSetting({\n settingValue: options.accessKeyId,\n settingName: 'accessKeyId',\n environmentVariableName: 'AWS_ACCESS_KEY_ID',\n description: 'AWS access key ID',\n }),\n secretAccessKey: loadSetting({\n settingValue: options.secretAccessKey,\n settingName: 'secretAccessKey',\n environmentVariableName: 'AWS_SECRET_ACCESS_KEY',\n description: 'AWS secret access key',\n }),\n sessionToken: loadOptionalSetting({\n settingValue: options.sessionToken,\n environmentVariableName: 'AWS_SESSION_TOKEN',\n }),\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n if (\n errorMessage.includes('AWS_ACCESS_KEY_ID') ||\n errorMessage.includes('accessKeyId')\n ) {\n throw new Error(\n 'AWS SigV4 authentication requires AWS credentials. Please provide either:\\n' +\n '1. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables\\n' +\n '2. Provide accessKeyId and secretAccessKey in options\\n' +\n '3. Use a credentialProvider function\\n' +\n '4. Use API key authentication with AWS_BEARER_TOKEN_BEDROCK or apiKey option\\n' +\n `Original error: ${errorMessage}`,\n );\n }\n if (\n errorMessage.includes('AWS_SECRET_ACCESS_KEY') ||\n errorMessage.includes('secretAccessKey')\n ) {\n throw new Error(\n 'AWS SigV4 authentication requires both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. ' +\n 'Please ensure both credentials are provided.\\n' +\n `Original error: ${errorMessage}`,\n );\n }\n throw error;\n }\n }, options.fetch);\n\n // Wrap with Bedrock event stream to SSE transformer for streaming support\n const fetchFunction = createBedrockAnthropicFetch(baseFetchFunction);\n\n const getBaseURL = (): string =>\n withoutTrailingSlash(\n options.baseURL ??\n `https://bedrock-runtime.${loadSetting({\n settingValue: options.region,\n settingName: 'region',\n environmentVariableName: 'AWS_REGION',\n description: 'AWS region',\n })}.amazonaws.com`,\n ) ?? 'https://bedrock-runtime.us-east-1.amazonaws.com';\n\n const getHeaders = async () => {\n const baseHeaders = (await resolve(options.headers)) ?? {};\n return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION}`);\n };\n\n const createChatModel = (modelId: BedrockAnthropicModelId) =>\n new AnthropicMessagesLanguageModel(modelId, {\n provider: 'bedrock.anthropic.messages',\n baseURL: getBaseURL(),\n headers: getHeaders,\n fetch: fetchFunction,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/model/${encodeURIComponent(modelId)}/${\n isStreaming ? 'invoke-with-response-stream' : 'invoke'\n }`,\n\n transformRequestBody: args => {\n const { model, stream, tool_choice, tools, ...rest } = args;\n\n const transformedToolChoice =\n tool_choice != null\n ? {\n type: tool_choice.type,\n ...(tool_choice.name != null ? { name: tool_choice.name } : {}),\n }\n : undefined;\n\n const requiredBetas = new Set<string>();\n const transformedTools = tools?.map((tool: Record<string, unknown>) => {\n const toolType = tool.type as string | undefined;\n\n if (toolType && toolType in BEDROCK_TOOL_VERSION_MAP) {\n const newType =\n BEDROCK_TOOL_VERSION_MAP[\n toolType as keyof typeof BEDROCK_TOOL_VERSION_MAP\n ];\n if (newType in BEDROCK_TOOL_BETA_MAP) {\n requiredBetas.add(BEDROCK_TOOL_BETA_MAP[newType]);\n }\n const newName =\n newType in BEDROCK_TOOL_NAME_MAP\n ? BEDROCK_TOOL_NAME_MAP[newType]\n : tool.name;\n return {\n ...tool,\n type: newType,\n name: newName,\n };\n }\n\n if (toolType && toolType in BEDROCK_TOOL_BETA_MAP) {\n requiredBetas.add(BEDROCK_TOOL_BETA_MAP[toolType]);\n }\n\n if (toolType && toolType in BEDROCK_TOOL_NAME_MAP) {\n return {\n ...tool,\n name: BEDROCK_TOOL_NAME_MAP[toolType],\n };\n }\n\n return tool;\n });\n\n return {\n ...rest,\n ...(transformedTools != null ? { tools: transformedTools } : {}),\n ...(transformedToolChoice != null\n ? { tool_choice: transformedToolChoice }\n : {}),\n ...(requiredBetas.size > 0\n ? { anthropic_beta: Array.from(requiredBetas) }\n : {}),\n anthropic_version: 'bedrock-2023-05-31',\n };\n },\n\n // Bedrock Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n });\n\n const provider = function (modelId: BedrockAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Bedrock Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v3' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = anthropicTools;\n\n return provider;\n}\n\n/**\nDefault Bedrock Anthropic provider instance.\n */\nexport const bedrockAnthropic = createBedrockAnthropic();\n","import {\n FetchFunction,\n combineHeaders,\n normalizeHeaders,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { AwsV4Signer } from 'aws4fetch';\nimport { VERSION } from './version';\n\nexport interface BedrockCredentials {\n region: string;\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken?: string;\n}\n\n/**\nCreates a fetch function that applies AWS Signature Version 4 signing.\n\n@param getCredentials - Function that returns the AWS credentials to use when signing.\n@param fetch - Optional original fetch implementation to wrap. Defaults to global fetch.\n@returns A FetchFunction that signs requests before passing them to the underlying fetch.\n */\nexport function createSigV4FetchFunction(\n getCredentials: () => BedrockCredentials | PromiseLike<BedrockCredentials>,\n fetch: FetchFunction = globalThis.fetch,\n): FetchFunction {\n return async (\n input: RequestInfo | URL,\n init?: RequestInit,\n ): Promise<Response> => {\n const request = input instanceof Request ? input : undefined;\n const originalHeaders = combineHeaders(\n normalizeHeaders(request?.headers),\n normalizeHeaders(init?.headers),\n );\n const headersWithUserAgent = withUserAgentSuffix(\n originalHeaders,\n `ai-sdk/amazon-bedrock/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n );\n\n let effectiveBody: BodyInit | undefined = init?.body ?? undefined;\n if (effectiveBody === undefined && request && request.body !== null) {\n try {\n effectiveBody = await request.clone().text();\n } catch {}\n }\n\n const effectiveMethod = init?.method ?? request?.method;\n\n if (effectiveMethod?.toUpperCase() !== 'POST' || !effectiveBody) {\n return fetch(input, {\n ...init,\n headers: headersWithUserAgent as HeadersInit,\n });\n }\n\n const url =\n typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.href\n : input.url;\n\n const body = prepareBodyString(effectiveBody);\n const credentials = await getCredentials();\n const signer = new AwsV4Signer({\n url,\n method: 'POST',\n headers: Object.entries(headersWithUserAgent),\n body,\n region: credentials.region,\n accessKeyId: credentials.accessKeyId,\n secretAccessKey: credentials.secretAccessKey,\n sessionToken: credentials.sessionToken,\n service: 'bedrock',\n });\n\n const signingResult = await signer.sign();\n const signedHeaders = normalizeHeaders(signingResult.headers);\n\n // Use the combined headers directly as HeadersInit\n const combinedHeaders = combineHeaders(headersWithUserAgent, signedHeaders);\n\n return fetch(input, {\n ...init,\n body,\n headers: combinedHeaders as HeadersInit,\n });\n };\n}\n\nfunction prepareBodyString(body: BodyInit | undefined): string {\n if (typeof body === 'string') {\n return body;\n } else if (body instanceof Uint8Array) {\n return new TextDecoder().decode(body);\n } else if (body instanceof ArrayBuffer) {\n return new TextDecoder().decode(new Uint8Array(body));\n } else {\n return JSON.stringify(body);\n }\n}\n\n/**\nCreates a fetch function that applies Bearer token authentication.\n\n@param apiKey - The API key to use for Bearer token authentication.\n@param fetch - Optional original fetch implementation to wrap. Defaults to global fetch.\n@returns A FetchFunction that adds Authorization header with Bearer token to requests.\n */\nexport function createApiKeyFetchFunction(\n apiKey: string,\n fetch: FetchFunction = globalThis.fetch,\n): FetchFunction {\n return async (\n input: RequestInfo | URL,\n init?: RequestInit,\n ): Promise<Response> => {\n const originalHeaders = normalizeHeaders(init?.headers);\n const headersWithUserAgent = withUserAgentSuffix(\n originalHeaders,\n `ai-sdk/amazon-bedrock/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n );\n\n const finalHeaders = combineHeaders(headersWithUserAgent, {\n Authorization: `Bearer ${apiKey}`,\n });\n\n return fetch(input, {\n ...init,\n headers: finalHeaders as HeadersInit,\n });\n };\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import { FetchFunction, safeParseJSON } from '@ai-sdk/provider-utils';\nimport { createBedrockEventStreamDecoder } from '../bedrock-event-stream-decoder';\n\nexport function createBedrockAnthropicFetch(\n baseFetch: FetchFunction,\n): FetchFunction {\n return async (url, options) => {\n const response = await baseFetch(url, options);\n\n const contentType = response.headers.get('content-type');\n if (\n contentType?.includes('application/vnd.amazon.eventstream') &&\n response.body != null\n ) {\n const transformedBody = transformBedrockEventStreamToSSE(response.body);\n\n return new Response(transformedBody, {\n status: response.status,\n statusText: response.statusText,\n headers: new Headers({\n ...Object.fromEntries(response.headers.entries()),\n 'content-type': 'text/event-stream',\n }),\n });\n }\n\n return response;\n };\n}\n\nfunction transformBedrockEventStreamToSSE(\n body: ReadableStream<Uint8Array>,\n): ReadableStream<Uint8Array> {\n const textEncoder = new TextEncoder();\n\n return createBedrockEventStreamDecoder(body, async (event, controller) => {\n if (event.messageType === 'event') {\n if (event.eventType === 'chunk') {\n const parsed = await safeParseJSON({ text: event.data });\n if (!parsed.success) {\n controller.enqueue(textEncoder.encode(`data: ${event.data}\\n\\n`));\n return;\n }\n const bytes = (parsed.value as { bytes?: string }).bytes;\n if (bytes) {\n const anthropicEvent = atob(bytes);\n controller.enqueue(textEncoder.encode(`data: ${anthropicEvent}\\n\\n`));\n } else {\n controller.enqueue(textEncoder.encode(`data: ${event.data}\\n\\n`));\n }\n } else if (event.eventType === 'messageStop') {\n controller.enqueue(textEncoder.encode('data: [DONE]\\n\\n'));\n }\n } else if (event.messageType === 'exception') {\n controller.enqueue(\n textEncoder.encode(\n `data: ${JSON.stringify({ type: 'error', error: event.data })}\\n\\n`,\n ),\n );\n }\n });\n}\n","import { EventStreamCodec } from '@smithy/eventstream-codec';\nimport { toUtf8, fromUtf8 } from '@smithy/util-utf8';\n\nexport interface DecodedEvent {\n messageType: string;\n eventType: string;\n data: string;\n}\n\nexport function createBedrockEventStreamDecoder<T>(\n body: ReadableStream<Uint8Array>,\n processEvent: (\n event: DecodedEvent,\n controller: TransformStreamDefaultController<T>,\n ) => void | Promise<void>,\n): ReadableStream<T> {\n const codec = new EventStreamCodec(toUtf8, fromUtf8);\n let buffer = new Uint8Array(0);\n const textDecoder = new TextDecoder();\n\n return body.pipeThrough(\n new TransformStream<Uint8Array, T>({\n async transform(chunk, controller) {\n const newBuffer = new Uint8Array(buffer.length + chunk.length);\n newBuffer.set(buffer);\n newBuffer.set(chunk, buffer.length);\n buffer = newBuffer;\n\n while (buffer.length >= 4) {\n const totalLength = new DataView(\n buffer.buffer,\n buffer.byteOffset,\n buffer.byteLength,\n ).getUint32(0, false);\n\n if (buffer.length < totalLength) {\n break;\n }\n\n try {\n const subView = buffer.subarray(0, totalLength);\n const decoded = codec.decode(subView);\n\n buffer = buffer.slice(totalLength);\n\n const messageType = decoded.headers[':message-type']\n ?.value as string;\n const eventType = decoded.headers[':event-type']?.value as string;\n const data = textDecoder.decode(decoded.body);\n\n await processEvent({ messageType, eventType, data }, controller);\n } catch {\n break;\n }\n }\n },\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAIO;AACP,IAAAA,yBAQO;AACP,sBAGO;;;ACjBP,4BAMO;AACP,uBAA4B;;;ACLrB,IAAM,UACX,OACI,WACA;;;ADmBC,SAAS,yBACd,gBACA,QAAuB,WAAW,OACnB;AACf,SAAO,OACL,OACA,SACsB;AA/B1B;AAgCI,UAAM,UAAU,iBAAiB,UAAU,QAAQ;A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