@ai-sdk/amazon-bedrock 3.0.21 → 3.1.0-beta.0

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.1.0-beta.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 78928cb: release: start 5.1 beta
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [78928cb]
12
+ - @ai-sdk/anthropic@2.1.0-beta.0
13
+ - @ai-sdk/provider@2.1.0-beta.0
14
+ - @ai-sdk/provider-utils@3.1.0-beta.0
15
+
16
+ ## 3.0.22
17
+
18
+ ### Patch Changes
19
+
20
+ - 32f3cef: feat: adding user-agent to all packages that use global fetch directly
21
+
3
22
  ## 3.0.21
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -117,4 +117,6 @@ Default Bedrock provider instance.
117
117
  */
118
118
  declare const bedrock: AmazonBedrockProvider;
119
119
 
120
- export { type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type BedrockProviderOptions, bedrock, createAmazonBedrock };
120
+ declare const VERSION: string;
121
+
122
+ export { type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type BedrockProviderOptions, VERSION, bedrock, createAmazonBedrock };
package/dist/index.d.ts CHANGED
@@ -117,4 +117,6 @@ Default Bedrock provider instance.
117
117
  */
118
118
  declare const bedrock: AmazonBedrockProvider;
119
119
 
120
- export { type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type BedrockProviderOptions, bedrock, createAmazonBedrock };
120
+ declare const VERSION: string;
121
+
122
+ export { type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type BedrockProviderOptions, VERSION, bedrock, createAmazonBedrock };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ VERSION: () => VERSION,
23
24
  bedrock: () => bedrock,
24
25
  createAmazonBedrock: () => createAmazonBedrock
25
26
  });
@@ -1487,20 +1488,33 @@ function convertHeadersToRecord(headers) {
1487
1488
  // src/bedrock-sigv4-fetch.ts
1488
1489
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1489
1490
  var import_aws4fetch = require("aws4fetch");
1491
+
1492
+ // src/version.ts
1493
+ var VERSION = true ? "3.1.0-beta.0" : "0.0.0-test";
1494
+
1495
+ // src/bedrock-sigv4-fetch.ts
1490
1496
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1491
1497
  return async (input, init) => {
1492
1498
  var _a;
1499
+ const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
1500
+ const headersWithUserAgent = (0, import_provider_utils7.withUserAgentSuffix)(
1501
+ originalHeaders,
1502
+ `ai-sdk/amazon-bedrock/${VERSION}`,
1503
+ (0, import_provider_utils7.getRuntimeEnvironmentUserAgent)()
1504
+ );
1493
1505
  if (((_a = init == null ? void 0 : init.method) == null ? void 0 : _a.toUpperCase()) !== "POST" || !(init == null ? void 0 : init.body)) {
1494
- return fetch(input, init);
1506
+ return fetch(input, {
1507
+ ...init,
1508
+ headers: headersWithUserAgent
1509
+ });
1495
1510
  }
1496
1511
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
1497
- const originalHeaders = extractHeaders(init.headers);
1498
1512
  const body = prepareBodyString(init.body);
1499
1513
  const credentials = await getCredentials();
1500
1514
  const signer = new import_aws4fetch.AwsV4Signer({
1501
1515
  url,
1502
1516
  method: "POST",
1503
- headers: Object.entries((0, import_provider_utils7.removeUndefinedEntries)(originalHeaders)),
1517
+ headers: Object.entries(headersWithUserAgent),
1504
1518
  body,
1505
1519
  region: credentials.region,
1506
1520
  accessKeyId: credentials.accessKeyId,
@@ -1510,12 +1524,11 @@ function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1510
1524
  });
1511
1525
  const signingResult = await signer.sign();
1512
1526
  const signedHeaders = convertHeadersToRecord(signingResult.headers);
1527
+ const combinedHeaders = (0, import_provider_utils7.combineHeaders)(headersWithUserAgent, signedHeaders);
1513
1528
  return fetch(input, {
1514
1529
  ...init,
1515
1530
  body,
1516
- headers: (0, import_provider_utils7.removeUndefinedEntries)(
1517
- (0, import_provider_utils7.combineHeaders)(originalHeaders, signedHeaders)
1518
- )
1531
+ headers: combinedHeaders
1519
1532
  });
1520
1533
  };
1521
1534
  }
@@ -1533,13 +1546,17 @@ function prepareBodyString(body) {
1533
1546
  function createApiKeyFetchFunction(apiKey, fetch = globalThis.fetch) {
1534
1547
  return async (input, init) => {
1535
1548
  const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
1549
+ const headersWithUserAgent = (0, import_provider_utils7.withUserAgentSuffix)(
1550
+ originalHeaders,
1551
+ `ai-sdk/amazon-bedrock/${VERSION}`,
1552
+ (0, import_provider_utils7.getRuntimeEnvironmentUserAgent)()
1553
+ );
1554
+ const finalHeaders = (0, import_provider_utils7.combineHeaders)(headersWithUserAgent, {
1555
+ Authorization: `Bearer ${apiKey}`
1556
+ });
1536
1557
  return fetch(input, {
1537
1558
  ...init,
1538
- headers: (0, import_provider_utils7.removeUndefinedEntries)(
1539
- (0, import_provider_utils7.combineHeaders)(originalHeaders, {
1540
- Authorization: `Bearer ${apiKey}`
1541
- })
1542
- )
1559
+ headers: finalHeaders
1543
1560
  });
1544
1561
  };
1545
1562
  }
@@ -1668,6 +1685,7 @@ Original error: ${errorMessage}`
1668
1685
  var bedrock = createAmazonBedrock();
1669
1686
  // Annotate the CommonJS export names for ESM import in node:
1670
1687
  0 && (module.exports = {
1688
+ VERSION,
1671
1689
  bedrock,
1672
1690
  createAmazonBedrock
1673
1691
  });