@ai-sdk/amazon-bedrock 3.0.128 → 3.0.129

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/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.128" : "0.0.0-test";
11
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
12
12
 
13
13
  // src/bedrock-provider.ts
14
14
  import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
@@ -1079,7 +1079,7 @@ var BedrockChatLanguageModel = class {
1079
1079
  return combineHeaders(await resolve(this.config.headers), headers);
1080
1080
  }
1081
1081
  async doGenerate(options) {
1082
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1082
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1083
1083
  const {
1084
1084
  command: args,
1085
1085
  warnings,
@@ -1108,6 +1108,12 @@ var BedrockChatLanguageModel = class {
1108
1108
  for (const part of response.output.message.content) {
1109
1109
  if (part.text) {
1110
1110
  content.push({ type: "text", text: part.text });
1111
+ } else if (part.text == null && part.citationsContent) {
1112
+ for (const generatedContent of (_a = part.citationsContent.content) != null ? _a : []) {
1113
+ if (generatedContent.text != null) {
1114
+ content.push({ type: "text", text: generatedContent.text });
1115
+ }
1116
+ }
1111
1117
  }
1112
1118
  if (part.reasoningContent) {
1113
1119
  if ("reasoningText" in part.reasoningContent) {
@@ -1129,7 +1135,7 @@ var BedrockChatLanguageModel = class {
1129
1135
  text: "",
1130
1136
  providerMetadata: {
1131
1137
  bedrock: {
1132
- redactedData: (_a = part.reasoningContent.redactedReasoning.data) != null ? _a : ""
1138
+ redactedData: (_b = part.reasoningContent.redactedReasoning.data) != null ? _b : ""
1133
1139
  }
1134
1140
  }
1135
1141
  });
@@ -1156,18 +1162,18 @@ var BedrockChatLanguageModel = class {
1156
1162
  } else {
1157
1163
  content.push({
1158
1164
  type: "tool-call",
1159
- toolCallId: (_c = (_b = part.toolUse) == null ? void 0 : _b.toolUseId) != null ? _c : this.config.generateId(),
1160
- toolName: (_e = (_d = part.toolUse) == null ? void 0 : _d.name) != null ? _e : `tool-${this.config.generateId()}`,
1161
- input: JSON.stringify((_g = (_f = part.toolUse) == null ? void 0 : _f.input) != null ? _g : {})
1165
+ toolCallId: (_d = (_c = part.toolUse) == null ? void 0 : _c.toolUseId) != null ? _d : this.config.generateId(),
1166
+ toolName: (_f = (_e = part.toolUse) == null ? void 0 : _e.name) != null ? _f : `tool-${this.config.generateId()}`,
1167
+ input: JSON.stringify((_h = (_g = part.toolUse) == null ? void 0 : _g.input) != null ? _h : {})
1162
1168
  });
1163
1169
  }
1164
1170
  }
1165
1171
  }
1166
- const stopSequence = (_j = (_i = (_h = response.additionalModelResponseFields) == null ? void 0 : _h.delta) == null ? void 0 : _i.stop_sequence) != null ? _j : null;
1172
+ const stopSequence = (_k = (_j = (_i = response.additionalModelResponseFields) == null ? void 0 : _i.delta) == null ? void 0 : _j.stop_sequence) != null ? _k : null;
1167
1173
  const providerMetadata = response.trace || response.usage || isJsonResponseFromTool || stopSequence ? {
1168
1174
  bedrock: {
1169
1175
  ...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
1170
- ...((_k = response.usage) == null ? void 0 : _k.cacheWriteInputTokens) != null && {
1176
+ ...((_l = response.usage) == null ? void 0 : _l.cacheWriteInputTokens) != null && {
1171
1177
  usage: {
1172
1178
  cacheWriteInputTokens: response.usage.cacheWriteInputTokens
1173
1179
  }
@@ -1183,10 +1189,10 @@ var BedrockChatLanguageModel = class {
1183
1189
  isJsonResponseFromTool
1184
1190
  ),
1185
1191
  usage: {
1186
- inputTokens: (_l = response.usage) == null ? void 0 : _l.inputTokens,
1187
- outputTokens: (_m = response.usage) == null ? void 0 : _m.outputTokens,
1188
- totalTokens: ((_n = response.usage) == null ? void 0 : _n.inputTokens) + ((_o = response.usage) == null ? void 0 : _o.outputTokens),
1189
- cachedInputTokens: (_q = (_p = response.usage) == null ? void 0 : _p.cacheReadInputTokens) != null ? _q : void 0
1192
+ inputTokens: (_m = response.usage) == null ? void 0 : _m.inputTokens,
1193
+ outputTokens: (_n = response.usage) == null ? void 0 : _n.outputTokens,
1194
+ totalTokens: ((_o = response.usage) == null ? void 0 : _o.inputTokens) + ((_p = response.usage) == null ? void 0 : _p.outputTokens),
1195
+ cachedInputTokens: (_r = (_q = response.usage) == null ? void 0 : _q.cacheReadInputTokens) != null ? _r : void 0
1190
1196
  },
1191
1197
  response: {
1192
1198
  // TODO add id, timestamp, etc
@@ -1538,6 +1544,13 @@ var BedrockToolUseSchema = z4.object({
1538
1544
  name: z4.string(),
1539
1545
  input: z4.unknown()
1540
1546
  });
1547
+ var BedrockCitationsContentSchema = z4.object({
1548
+ content: z4.array(
1549
+ z4.object({
1550
+ text: z4.string().nullish()
1551
+ })
1552
+ ).nullish()
1553
+ });
1541
1554
  var BedrockReasoningTextSchema = z4.object({
1542
1555
  signature: z4.string().nullish(),
1543
1556
  text: z4.string()
@@ -1554,6 +1567,7 @@ var BedrockResponseSchema = z4.object({
1554
1567
  content: z4.array(
1555
1568
  z4.object({
1556
1569
  text: z4.string().nullish(),
1570
+ citationsContent: BedrockCitationsContentSchema.nullish(),
1557
1571
  toolUse: BedrockToolUseSchema.nullish(),
1558
1572
  reasoningContent: z4.union([
1559
1573
  z4.object({