@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/dist/index.mjs
CHANGED
|
@@ -421,7 +421,8 @@ import {
|
|
|
421
421
|
import { z as z3 } from "zod/v4";
|
|
422
422
|
var bedrockReasoningMetadataSchema = z3.object({
|
|
423
423
|
signature: z3.string().optional(),
|
|
424
|
-
redactedData: z3.string().optional()
|
|
424
|
+
redactedData: z3.string().optional(),
|
|
425
|
+
redactedContent: z3.string().optional()
|
|
425
426
|
});
|
|
426
427
|
|
|
427
428
|
// src/normalize-tool-call-id.ts
|
|
@@ -735,6 +736,12 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
735
736
|
}
|
|
736
737
|
}
|
|
737
738
|
});
|
|
739
|
+
} else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedContent) != null) {
|
|
740
|
+
bedrockContent.push({
|
|
741
|
+
reasoningContent: {
|
|
742
|
+
redactedContent: reasoningMetadata.redactedContent
|
|
743
|
+
}
|
|
744
|
+
});
|
|
738
745
|
} else if ((reasoningMetadata == null ? void 0 : reasoningMetadata.redactedData) != null) {
|
|
739
746
|
bedrockContent.push({
|
|
740
747
|
reasoningContent: {
|
|
@@ -1221,6 +1228,16 @@ var BedrockChatLanguageModel = class {
|
|
|
1221
1228
|
}
|
|
1222
1229
|
}
|
|
1223
1230
|
});
|
|
1231
|
+
} else if ("redactedContent" in part.reasoningContent) {
|
|
1232
|
+
content.push({
|
|
1233
|
+
type: "reasoning",
|
|
1234
|
+
text: "",
|
|
1235
|
+
providerMetadata: {
|
|
1236
|
+
bedrock: {
|
|
1237
|
+
redactedContent: part.reasoningContent.redactedContent
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1224
1241
|
}
|
|
1225
1242
|
}
|
|
1226
1243
|
if (part.toolUse) {
|
|
@@ -1334,7 +1351,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1334
1351
|
});
|
|
1335
1352
|
},
|
|
1336
1353
|
transform(chunk, controller) {
|
|
1337
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1354
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1338
1355
|
function enqueueError(bedrockError) {
|
|
1339
1356
|
finishReason = { unified: "error", raw: void 0 };
|
|
1340
1357
|
controller.enqueue({ type: "error", error: bedrockError });
|
|
@@ -1438,9 +1455,15 @@ var BedrockChatLanguageModel = class {
|
|
|
1438
1455
|
const contentBlock = contentBlocks[blockIndex];
|
|
1439
1456
|
if (contentBlock != null) {
|
|
1440
1457
|
if (contentBlock.type === "reasoning") {
|
|
1458
|
+
const redactedPayload = contentBlock.redactedContent != null ? { redactedContent: contentBlock.redactedContent } : null;
|
|
1441
1459
|
controller.enqueue({
|
|
1442
1460
|
type: "reasoning-end",
|
|
1443
|
-
id: String(blockIndex)
|
|
1461
|
+
id: String(blockIndex),
|
|
1462
|
+
...redactedPayload != null ? {
|
|
1463
|
+
providerMetadata: {
|
|
1464
|
+
bedrock: redactedPayload
|
|
1465
|
+
}
|
|
1466
|
+
} : {}
|
|
1444
1467
|
});
|
|
1445
1468
|
} else if (contentBlock.type === "text") {
|
|
1446
1469
|
controller.enqueue({
|
|
@@ -1531,10 +1554,22 @@ var BedrockChatLanguageModel = class {
|
|
|
1531
1554
|
}
|
|
1532
1555
|
}
|
|
1533
1556
|
});
|
|
1557
|
+
} else if ("redactedContent" in reasoningContent && reasoningContent.redactedContent) {
|
|
1558
|
+
if (contentBlocks[blockIndex] == null) {
|
|
1559
|
+
contentBlocks[blockIndex] = { type: "reasoning" };
|
|
1560
|
+
controller.enqueue({
|
|
1561
|
+
type: "reasoning-start",
|
|
1562
|
+
id: String(blockIndex)
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
const contentBlock = contentBlocks[blockIndex];
|
|
1566
|
+
if (contentBlock.type === "reasoning") {
|
|
1567
|
+
contentBlock.redactedContent = ((_p = contentBlock.redactedContent) != null ? _p : "") + reasoningContent.redactedContent;
|
|
1568
|
+
}
|
|
1534
1569
|
}
|
|
1535
1570
|
}
|
|
1536
1571
|
const contentBlockStart = value.contentBlockStart;
|
|
1537
|
-
if (((
|
|
1572
|
+
if (((_q = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _q.toolUse) != null) {
|
|
1538
1573
|
const toolUse = contentBlockStart.start.toolUse;
|
|
1539
1574
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
1540
1575
|
const isJsonResponseTool = usesJsonResponseTool && toolUse.name === "json";
|
|
@@ -1562,7 +1597,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1562
1597
|
const blockIndex = contentBlockDelta.contentBlockIndex;
|
|
1563
1598
|
const contentBlock = contentBlocks[blockIndex];
|
|
1564
1599
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
1565
|
-
const delta = (
|
|
1600
|
+
const delta = (_r = contentBlockDelta.delta.toolUse.input) != null ? _r : "";
|
|
1566
1601
|
if (!contentBlock.isJsonResponseTool) {
|
|
1567
1602
|
controller.enqueue({
|
|
1568
1603
|
type: "tool-input-delta",
|
|
@@ -1700,6 +1735,13 @@ var BedrockResponseSchema = z4.object({
|
|
|
1700
1735
|
}),
|
|
1701
1736
|
z4.object({
|
|
1702
1737
|
redactedReasoning: BedrockRedactedReasoningSchema
|
|
1738
|
+
}),
|
|
1739
|
+
// `redactedContent` is a member of the documented
|
|
1740
|
+
// ReasoningContentBlock union. OpenAI models on Bedrock
|
|
1741
|
+
// (e.g. `us.openai.gpt-5.6-luna`) return their encrypted
|
|
1742
|
+
// reasoning in this shape.
|
|
1743
|
+
z4.object({
|
|
1744
|
+
redactedContent: z4.string()
|
|
1703
1745
|
})
|
|
1704
1746
|
]).nullish()
|
|
1705
1747
|
})
|
|
@@ -1737,6 +1779,12 @@ var BedrockStreamSchema = z4.object({
|
|
|
1737
1779
|
}),
|
|
1738
1780
|
z4.object({
|
|
1739
1781
|
reasoningContent: z4.object({ data: z4.string() })
|
|
1782
|
+
}),
|
|
1783
|
+
// `redactedContent` is a member of the documented
|
|
1784
|
+
// ReasoningContentBlockDelta union. OpenAI models on Bedrock stream
|
|
1785
|
+
// their encrypted reasoning in this shape.
|
|
1786
|
+
z4.object({
|
|
1787
|
+
reasoningContent: z4.object({ redactedContent: z4.string() })
|
|
1740
1788
|
})
|
|
1741
1789
|
]).nullish()
|
|
1742
1790
|
}).nullish(),
|
|
@@ -2196,7 +2244,7 @@ import {
|
|
|
2196
2244
|
import { AwsV4Signer } from "aws4fetch";
|
|
2197
2245
|
|
|
2198
2246
|
// src/version.ts
|
|
2199
|
-
var VERSION = true ? "4.0.
|
|
2247
|
+
var VERSION = true ? "4.0.158" : "0.0.0-test";
|
|
2200
2248
|
|
|
2201
2249
|
// src/bedrock-sigv4-fetch.ts
|
|
2202
2250
|
function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {
|