@ai-sdk/amazon-bedrock 4.0.157 → 4.0.158
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/dist/anthropic/index.js +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/index.js +54 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -6
- package/dist/index.mjs.map +1 -1
- package/dist/mantle/index.js +1 -1
- package/dist/mantle/index.mjs +1 -1
- package/package.json +1 -1
- package/src/bedrock-api-types.ts +7 -0
- package/src/bedrock-chat-language-model.ts +57 -1
- package/src/bedrock-reasoning-metadata.ts +1 -0
- package/src/convert-to-bedrock-chat-messages.ts +6 -0
package/CHANGELOG.md
CHANGED
package/dist/anthropic/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
35
35
|
var import_aws4fetch = require("aws4fetch");
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = true ? "4.0.
|
|
38
|
+
var VERSION = true ? "4.0.158" : "0.0.0-test";
|
|
39
39
|
|
|
40
40
|
// src/bedrock-sigv4-fetch.ts
|
|
41
41
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/anthropic/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import { AwsV4Signer } from "aws4fetch";
|
|
25
25
|
|
|
26
26
|
// src/version.ts
|
|
27
|
-
var VERSION = true ? "4.0.
|
|
27
|
+
var VERSION = true ? "4.0.158" : "0.0.0-test";
|
|
28
28
|
|
|
29
29
|
// src/bedrock-sigv4-fetch.ts
|
|
30
30
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|
package/dist/index.js
CHANGED
|
@@ -417,7 +417,8 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
417
417
|
var import_v43 = require("zod/v4");
|
|
418
418
|
var bedrockReasoningMetadataSchema = import_v43.z.object({
|
|
419
419
|
signature: import_v43.z.string().optional(),
|
|
420
|
-
redactedData: import_v43.z.string().optional()
|
|
420
|
+
redactedData: import_v43.z.string().optional(),
|
|
421
|
+
redactedContent: import_v43.z.string().optional()
|
|
421
422
|
});
|
|
422
423
|
|
|
423
424
|
// src/normalize-tool-call-id.ts
|
|
@@ -731,6 +732,12 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
731
732
|
}
|
|
732
733
|
}
|
|
733
734
|
});
|
|
735
|
+
} else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedContent) != null) {
|
|
736
|
+
bedrockContent.push({
|
|
737
|
+
reasoningContent: {
|
|
738
|
+
redactedContent: reasoningMetadata.redactedContent
|
|
739
|
+
}
|
|
740
|
+
});
|
|
734
741
|
} else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedData) != null) {
|
|
735
742
|
bedrockContent.push({
|
|
736
743
|
reasoningContent: {
|
|
@@ -1217,6 +1224,16 @@ var BedrockChatLanguageModel = class {
|
|
|
1217
1224
|
}
|
|
1218
1225
|
}
|
|
1219
1226
|
});
|
|
1227
|
+
} else if ("redactedContent" in part.reasoningContent) {
|
|
1228
|
+
content.push({
|
|
1229
|
+
type: "reasoning",
|
|
1230
|
+
text: "",
|
|
1231
|
+
providerMetadata: {
|
|
1232
|
+
bedrock: {
|
|
1233
|
+
redactedContent: part.reasoningContent.redactedContent
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1220
1237
|
}
|
|
1221
1238
|
}
|
|
1222
1239
|
if (part.toolUse) {
|
|
@@ -1330,7 +1347,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1330
1347
|
});
|
|
1331
1348
|
},
|
|
1332
1349
|
transform(chunk, controller) {
|
|
1333
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1350
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1334
1351
|
function enqueueError(bedrockError) {
|
|
1335
1352
|
finishReason = { unified: "error", raw: void 0 };
|
|
1336
1353
|
controller.enqueue({ type: "error", error: bedrockError });
|
|
@@ -1434,9 +1451,15 @@ var BedrockChatLanguageModel = class {
|
|
|
1434
1451
|
const contentBlock = contentBlocks[blockIndex];
|
|
1435
1452
|
if (contentBlock != null) {
|
|
1436
1453
|
if (contentBlock.type === "reasoning") {
|
|
1454
|
+
const redactedPayload = contentBlock.redactedContent != null ? { redactedContent: contentBlock.redactedContent } : null;
|
|
1437
1455
|
controller.enqueue({
|
|
1438
1456
|
type: "reasoning-end",
|
|
1439
|
-
id: String(blockIndex)
|
|
1457
|
+
id: String(blockIndex),
|
|
1458
|
+
...redactedPayload != null ? {
|
|
1459
|
+
providerMetadata: {
|
|
1460
|
+
bedrock: redactedPayload
|
|
1461
|
+
}
|
|
1462
|
+
} : {}
|
|
1440
1463
|
});
|
|
1441
1464
|
} else if (contentBlock.type === "text") {
|
|
1442
1465
|
controller.enqueue({
|
|
@@ -1527,10 +1550,22 @@ var BedrockChatLanguageModel = class {
|
|
|
1527
1550
|
}
|
|
1528
1551
|
}
|
|
1529
1552
|
});
|
|
1553
|
+
} else if ("redactedContent" in reasoningContent && reasoningContent.redactedContent) {
|
|
1554
|
+
if (contentBlocks[blockIndex] == null) {
|
|
1555
|
+
contentBlocks[blockIndex] = { type: "reasoning" };
|
|
1556
|
+
controller.enqueue({
|
|
1557
|
+
type: "reasoning-start",
|
|
1558
|
+
id: String(blockIndex)
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
const contentBlock = contentBlocks[blockIndex];
|
|
1562
|
+
if (contentBlock.type === "reasoning") {
|
|
1563
|
+
contentBlock.redactedContent = ((_p = contentBlock.redactedContent) != null ? _p : "") + reasoningContent.redactedContent;
|
|
1564
|
+
}
|
|
1530
1565
|
}
|
|
1531
1566
|
}
|
|
1532
1567
|
const contentBlockStart = value.contentBlockStart;
|
|
1533
|
-
if (((
|
|
1568
|
+
if (((_q = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _q.toolUse) != null) {
|
|
1534
1569
|
const toolUse = contentBlockStart.start.toolUse;
|
|
1535
1570
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
1536
1571
|
const isJsonResponseTool = usesJsonResponseTool && toolUse.name === "json";
|
|
@@ -1558,7 +1593,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1558
1593
|
const blockIndex = contentBlockDelta.contentBlockIndex;
|
|
1559
1594
|
const contentBlock = contentBlocks[blockIndex];
|
|
1560
1595
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
1561
|
-
const delta = (
|
|
1596
|
+
const delta = (_r = contentBlockDelta.delta.toolUse.input) != null ? _r : "";
|
|
1562
1597
|
if (!contentBlock.isJsonResponseTool) {
|
|
1563
1598
|
controller.enqueue({
|
|
1564
1599
|
type: "tool-input-delta",
|
|
@@ -1696,6 +1731,13 @@ var BedrockResponseSchema = import_v44.z.object({
|
|
|
1696
1731
|
}),
|
|
1697
1732
|
import_v44.z.object({
|
|
1698
1733
|
redactedReasoning: BedrockRedactedReasoningSchema
|
|
1734
|
+
}),
|
|
1735
|
+
// `redactedContent` is a member of the documented
|
|
1736
|
+
// ReasoningContentBlock union. OpenAI models on Bedrock
|
|
1737
|
+
// (e.g. `us.openai.gpt-5.6-luna`) return their encrypted
|
|
1738
|
+
// reasoning in this shape.
|
|
1739
|
+
import_v44.z.object({
|
|
1740
|
+
redactedContent: import_v44.z.string()
|
|
1699
1741
|
})
|
|
1700
1742
|
]).nullish()
|
|
1701
1743
|
})
|
|
@@ -1733,6 +1775,12 @@ var BedrockStreamSchema = import_v44.z.object({
|
|
|
1733
1775
|
}),
|
|
1734
1776
|
import_v44.z.object({
|
|
1735
1777
|
reasoningContent: import_v44.z.object({ data: import_v44.z.string() })
|
|
1778
|
+
}),
|
|
1779
|
+
// `redactedContent` is a member of the documented
|
|
1780
|
+
// ReasoningContentBlockDelta union. OpenAI models on Bedrock stream
|
|
1781
|
+
// their encrypted reasoning in this shape.
|
|
1782
|
+
import_v44.z.object({
|
|
1783
|
+
reasoningContent: import_v44.z.object({ redactedContent: import_v44.z.string() })
|
|
1736
1784
|
})
|
|
1737
1785
|
]).nullish()
|
|
1738
1786
|
}).nullish(),
|
|
@@ -2171,7 +2219,7 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
|
2171
2219
|
var import_aws4fetch = require("aws4fetch");
|
|
2172
2220
|
|
|
2173
2221
|
// src/version.ts
|
|
2174
|
-
var VERSION = true ? "4.0.
|
|
2222
|
+
var VERSION = true ? "4.0.158" : "0.0.0-test";
|
|
2175
2223
|
|
|
2176
2224
|
// src/bedrock-sigv4-fetch.ts
|
|
2177
2225
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|