@ai-sdk/amazon-bedrock 3.0.116 → 3.0.118
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 +13 -0
- package/dist/anthropic/index.js +15 -12
- package/dist/anthropic/index.js.map +1 -1
- package/dist/anthropic/index.mjs +15 -12
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/index.js +69 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@ai-sdk/provider-utils";
|
|
9
9
|
|
|
10
10
|
// src/version.ts
|
|
11
|
-
var VERSION = true ? "3.0.
|
|
11
|
+
var VERSION = true ? "3.0.118" : "0.0.0-test";
|
|
12
12
|
|
|
13
13
|
// src/bedrock-provider.ts
|
|
14
14
|
import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
|
|
@@ -145,17 +145,20 @@ function createBedrockEventStreamDecoder(body, processEvent) {
|
|
|
145
145
|
if (buffer.length < totalLength) {
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
const subView = buffer.subarray(0, totalLength);
|
|
149
|
+
const decoded = codec.decode(subView);
|
|
150
|
+
buffer = buffer.slice(totalLength);
|
|
151
|
+
const messageType = (_a = decoded.headers[":message-type"]) == null ? void 0 : _a.value;
|
|
152
|
+
const eventType = (_b = decoded.headers[":event-type"]) == null ? void 0 : _b.value;
|
|
153
|
+
const data = textDecoder.decode(decoded.body);
|
|
154
|
+
await processEvent({ messageType, eventType, data }, controller);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
flush() {
|
|
158
|
+
if (buffer.length > 0) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Incomplete Amazon Bedrock event-stream frame: ${buffer.length} buffered bytes remain at end of stream.`
|
|
161
|
+
);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
})
|
|
@@ -356,7 +359,8 @@ import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
|
356
359
|
import { z as z3 } from "zod/v4";
|
|
357
360
|
var bedrockReasoningMetadataSchema = z3.object({
|
|
358
361
|
signature: z3.string().optional(),
|
|
359
|
-
redactedData: z3.string().optional()
|
|
362
|
+
redactedData: z3.string().optional(),
|
|
363
|
+
redactedContent: z3.string().optional()
|
|
360
364
|
});
|
|
361
365
|
|
|
362
366
|
// src/convert-to-bedrock-chat-messages.ts
|
|
@@ -585,6 +589,12 @@ async function convertToBedrockChatMessages(prompt) {
|
|
|
585
589
|
}
|
|
586
590
|
}
|
|
587
591
|
});
|
|
592
|
+
} else if (reasoningMetadata.redactedContent != null) {
|
|
593
|
+
bedrockContent.push({
|
|
594
|
+
reasoningContent: {
|
|
595
|
+
redactedContent: reasoningMetadata.redactedContent
|
|
596
|
+
}
|
|
597
|
+
});
|
|
588
598
|
} else if (reasoningMetadata.redactedData != null) {
|
|
589
599
|
bedrockContent.push({
|
|
590
600
|
reasoningContent: {
|
|
@@ -1046,6 +1056,16 @@ var BedrockChatLanguageModel = class {
|
|
|
1046
1056
|
}
|
|
1047
1057
|
}
|
|
1048
1058
|
});
|
|
1059
|
+
} else if ("redactedContent" in part.reasoningContent) {
|
|
1060
|
+
content.push({
|
|
1061
|
+
type: "reasoning",
|
|
1062
|
+
text: "",
|
|
1063
|
+
providerMetadata: {
|
|
1064
|
+
bedrock: {
|
|
1065
|
+
redactedContent: part.reasoningContent.redactedContent
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1049
1069
|
}
|
|
1050
1070
|
}
|
|
1051
1071
|
if (part.toolUse) {
|
|
@@ -1135,7 +1155,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1135
1155
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1136
1156
|
},
|
|
1137
1157
|
transform(chunk, controller) {
|
|
1138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1158
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1139
1159
|
function enqueueError(bedrockError) {
|
|
1140
1160
|
finishReason = "error";
|
|
1141
1161
|
controller.enqueue({ type: "error", error: bedrockError });
|
|
@@ -1223,7 +1243,14 @@ var BedrockChatLanguageModel = class {
|
|
|
1223
1243
|
if (contentBlock.type === "reasoning") {
|
|
1224
1244
|
controller.enqueue({
|
|
1225
1245
|
type: "reasoning-end",
|
|
1226
|
-
id: String(blockIndex)
|
|
1246
|
+
id: String(blockIndex),
|
|
1247
|
+
...contentBlock.redactedContent != null ? {
|
|
1248
|
+
providerMetadata: {
|
|
1249
|
+
bedrock: {
|
|
1250
|
+
redactedContent: contentBlock.redactedContent
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
} : {}
|
|
1227
1254
|
});
|
|
1228
1255
|
} else if (contentBlock.type === "text") {
|
|
1229
1256
|
controller.enqueue({
|
|
@@ -1314,10 +1341,22 @@ var BedrockChatLanguageModel = class {
|
|
|
1314
1341
|
}
|
|
1315
1342
|
}
|
|
1316
1343
|
});
|
|
1344
|
+
} else if ("redactedContent" in reasoningContent && reasoningContent.redactedContent) {
|
|
1345
|
+
if (contentBlocks[blockIndex] == null) {
|
|
1346
|
+
contentBlocks[blockIndex] = { type: "reasoning" };
|
|
1347
|
+
controller.enqueue({
|
|
1348
|
+
type: "reasoning-start",
|
|
1349
|
+
id: String(blockIndex)
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
const contentBlock = contentBlocks[blockIndex];
|
|
1353
|
+
if (contentBlock.type === "reasoning") {
|
|
1354
|
+
contentBlock.redactedContent = ((_s = contentBlock.redactedContent) != null ? _s : "") + reasoningContent.redactedContent;
|
|
1355
|
+
}
|
|
1317
1356
|
}
|
|
1318
1357
|
}
|
|
1319
1358
|
const contentBlockStart = value.contentBlockStart;
|
|
1320
|
-
if (((
|
|
1359
|
+
if (((_t = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _t.toolUse) != null) {
|
|
1321
1360
|
const toolUse = contentBlockStart.start.toolUse;
|
|
1322
1361
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
1323
1362
|
const isJsonResponseTool = usesJsonResponseTool && toolUse.name === "json";
|
|
@@ -1341,7 +1380,7 @@ var BedrockChatLanguageModel = class {
|
|
|
1341
1380
|
const blockIndex = contentBlockDelta.contentBlockIndex;
|
|
1342
1381
|
const contentBlock = contentBlocks[blockIndex];
|
|
1343
1382
|
if ((contentBlock == null ? void 0 : contentBlock.type) === "tool-call") {
|
|
1344
|
-
const delta = (
|
|
1383
|
+
const delta = (_u = contentBlockDelta.delta.toolUse.input) != null ? _u : "";
|
|
1345
1384
|
if (!contentBlock.isJsonResponseTool) {
|
|
1346
1385
|
controller.enqueue({
|
|
1347
1386
|
type: "tool-input-delta",
|
|
@@ -1432,6 +1471,13 @@ var BedrockResponseSchema = z4.object({
|
|
|
1432
1471
|
}),
|
|
1433
1472
|
z4.object({
|
|
1434
1473
|
redactedReasoning: BedrockRedactedReasoningSchema
|
|
1474
|
+
}),
|
|
1475
|
+
// `redactedContent` is a member of the documented
|
|
1476
|
+
// ReasoningContentBlock union. OpenAI models on Bedrock
|
|
1477
|
+
// (e.g. `us.openai.gpt-5.6-luna`) return their encrypted
|
|
1478
|
+
// reasoning in this shape.
|
|
1479
|
+
z4.object({
|
|
1480
|
+
redactedContent: z4.string()
|
|
1435
1481
|
})
|
|
1436
1482
|
]).nullish()
|
|
1437
1483
|
})
|
|
@@ -1466,6 +1512,12 @@ var BedrockStreamSchema = z4.object({
|
|
|
1466
1512
|
}),
|
|
1467
1513
|
z4.object({
|
|
1468
1514
|
reasoningContent: z4.object({ data: z4.string() })
|
|
1515
|
+
}),
|
|
1516
|
+
// `redactedContent` is a member of the documented
|
|
1517
|
+
// ReasoningContentBlockDelta union. OpenAI models on Bedrock stream
|
|
1518
|
+
// their encrypted reasoning in this shape.
|
|
1519
|
+
z4.object({
|
|
1520
|
+
reasoningContent: z4.object({ redactedContent: z4.string() })
|
|
1469
1521
|
})
|
|
1470
1522
|
]).nullish()
|
|
1471
1523
|
}).nullish(),
|