@ai-sdk/amazon-bedrock 5.0.0-beta.40 → 5.0.0-beta.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/amazon-bedrock",
3
- "version": "5.0.0-beta.40",
3
+ "version": "5.0.0-beta.42",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -38,9 +38,9 @@
38
38
  "@smithy/eventstream-codec": "^4.0.1",
39
39
  "@smithy/util-utf8": "^4.0.0",
40
40
  "aws4fetch": "^1.0.20",
41
- "@ai-sdk/anthropic": "4.0.0-beta.36",
41
+ "@ai-sdk/anthropic": "4.0.0-beta.38",
42
42
  "@ai-sdk/provider": "4.0.0-beta.12",
43
- "@ai-sdk/provider-utils": "5.0.0-beta.25"
43
+ "@ai-sdk/provider-utils": "5.0.0-beta.27"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "20.17.24",
@@ -57,7 +57,8 @@
57
57
  "node": ">=18"
58
58
  },
59
59
  "publishConfig": {
60
- "access": "public"
60
+ "access": "public",
61
+ "provenance": true
61
62
  },
62
63
  "homepage": "https://ai-sdk.dev/docs",
63
64
  "repository": {
@@ -14,7 +14,7 @@ import {
14
14
  } from '@ai-sdk/provider-utils';
15
15
  import {
16
16
  anthropicTools,
17
- AnthropicMessagesLanguageModel,
17
+ AnthropicLanguageModel,
18
18
  } from '@ai-sdk/anthropic/internal';
19
19
  import {
20
20
  BedrockCredentials,
@@ -249,7 +249,7 @@ export function createBedrockAnthropic(
249
249
  };
250
250
 
251
251
  const createChatModel = (modelId: BedrockAnthropicModelId) =>
252
- new AnthropicMessagesLanguageModel(modelId, {
252
+ new AnthropicLanguageModel(modelId, {
253
253
  provider: 'bedrock.anthropic.messages',
254
254
  baseURL: getBaseURL(),
255
255
  headers: getHeaders,
@@ -230,6 +230,10 @@ export class BedrockChatLanguageModel implements LanguageModelV4 {
230
230
  thinkingType === 'enabled'
231
231
  ? bedrockOptions.reasoningConfig?.budgetTokens
232
232
  : undefined;
233
+ const thinkingDisplay =
234
+ thinkingType === 'adaptive'
235
+ ? bedrockOptions.reasoningConfig?.display
236
+ : undefined;
233
237
  const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
234
238
 
235
239
  const inferenceConfig = {
@@ -259,6 +263,7 @@ export class BedrockChatLanguageModel implements LanguageModelV4 {
259
263
  ...bedrockOptions.additionalModelRequestFields,
260
264
  thinking: {
261
265
  type: 'adaptive',
266
+ ...(thinkingDisplay != null && { display: thinkingDisplay }),
262
267
  },
263
268
  };
264
269
  }
@@ -889,6 +894,13 @@ export class BedrockChatLanguageModel implements LanguageModelV4 {
889
894
  'signature' in reasoningContent &&
890
895
  reasoningContent.signature
891
896
  ) {
897
+ if (contentBlocks[blockIndex] == null) {
898
+ contentBlocks[blockIndex] = { type: 'reasoning' };
899
+ controller.enqueue({
900
+ type: 'reasoning-start',
901
+ id: String(blockIndex),
902
+ });
903
+ }
892
904
  controller.enqueue({
893
905
  type: 'reasoning-delta',
894
906
  id: String(blockIndex),
@@ -900,6 +912,13 @@ export class BedrockChatLanguageModel implements LanguageModelV4 {
900
912
  },
901
913
  });
902
914
  } else if ('data' in reasoningContent && reasoningContent.data) {
915
+ if (contentBlocks[blockIndex] == null) {
916
+ contentBlocks[blockIndex] = { type: 'reasoning' };
917
+ controller.enqueue({
918
+ type: 'reasoning-start',
919
+ id: String(blockIndex),
920
+ });
921
+ }
903
922
  controller.enqueue({
904
923
  type: 'reasoning-delta',
905
924
  id: String(blockIndex),
@@ -1190,7 +1209,7 @@ function resolveBedrockReasoningConfig({
1190
1209
  isAnthropicModel: boolean;
1191
1210
  modelId: string;
1192
1211
  }): AmazonBedrockLanguageModelOptions {
1193
- if (!isCustomReasoning(reasoning) || bedrockOptions.reasoningConfig != null) {
1212
+ if (!isCustomReasoning(reasoning)) {
1194
1213
  return bedrockOptions;
1195
1214
  }
1196
1215
 
@@ -1210,6 +1229,7 @@ function resolveBedrockReasoningConfig({
1210
1229
  result.reasoningConfig = {
1211
1230
  type: 'adaptive',
1212
1231
  maxReasoningEffort: effort,
1232
+ ...bedrockOptions.reasoningConfig,
1213
1233
  };
1214
1234
  } else {
1215
1235
  const budgetTokens = mapReasoningToProviderBudget({
@@ -1222,6 +1242,7 @@ function resolveBedrockReasoningConfig({
1222
1242
  result.reasoningConfig = {
1223
1243
  type: 'enabled',
1224
1244
  budgetTokens,
1245
+ ...bedrockOptions.reasoningConfig,
1225
1246
  };
1226
1247
  }
1227
1248
  }
@@ -1231,7 +1252,21 @@ function resolveBedrockReasoningConfig({
1231
1252
  effortMap: bedrockReasoningEffortMap,
1232
1253
  warnings,
1233
1254
  });
1234
- result.reasoningConfig = { maxReasoningEffort: effort };
1255
+ result.reasoningConfig = {
1256
+ maxReasoningEffort: effort,
1257
+ ...bedrockOptions.reasoningConfig,
1258
+ };
1259
+ }
1260
+
1261
+ /*
1262
+ * Mirror anthropic-messages-language-model.ts: when the merged type ends up
1263
+ * 'disabled' (user override combined with a non-none reasoning), strip
1264
+ * derived effort/budget so downstream does not emit output_config.effort
1265
+ * alongside disabled thinking.
1266
+ */
1267
+ if (result.reasoningConfig?.type === 'disabled') {
1268
+ delete result.reasoningConfig.maxReasoningEffort;
1269
+ delete result.reasoningConfig.budgetTokens;
1235
1270
  }
1236
1271
 
1237
1272
  return result;
@@ -117,7 +117,10 @@ export const amazonBedrockLanguageModelOptions = z.object({
117
117
  ])
118
118
  .optional(),
119
119
  budgetTokens: z.number().optional(),
120
- maxReasoningEffort: z.enum(['low', 'medium', 'high', 'max']).optional(),
120
+ maxReasoningEffort: z
121
+ .enum(['low', 'medium', 'high', 'xhigh', 'max'])
122
+ .optional(),
123
+ display: z.enum(['omitted', 'summarized']).optional(),
121
124
  })
122
125
  .optional(),
123
126
  /**
@@ -213,7 +213,7 @@ export async function convertToBedrockChatMessages(
213
213
  break;
214
214
  case 'execution-denied':
215
215
  toolResultContent = [
216
- { text: output.reason ?? 'Tool execution denied.' },
216
+ { text: output.reason ?? 'Tool call execution denied.' },
217
217
  ];
218
218
  break;
219
219
  case 'json':