@ai-sdk/amazon-bedrock 4.0.204 → 4.0.206

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
@@ -1060,13 +1060,41 @@ var BedrockChatLanguageModel = class {
1060
1060
  const openAIModelId = (_c = /^(?:[^.]+\.)?(openai\..+)$/.exec(this.modelId)) == null ? void 0 : _c[1];
1061
1061
  const isOpenAIModel = openAIModelId != null;
1062
1062
  const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
1063
- const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
1064
1063
  const {
1065
1064
  supportsStructuredOutput: modelSupportsStructuredOutput,
1066
1065
  rejectsForcedToolUse,
1066
+ rejectsThinkingDisabled,
1067
+ rejectsThinkingDisabledAboveHighEffort,
1068
+ supportsBetweenToolsThinking,
1067
1069
  isKnownModel
1068
1070
  } = getModelCapabilities(this.modelId);
1069
- const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
1071
+ let thinkingType = (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type;
1072
+ let maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
1073
+ if (isAnthropicModel2 && thinkingType === "disabled") {
1074
+ if (/claude-(?:instant|v?2|3-(?:5-)?(?:haiku|sonnet|opus))(?=[-.:]|$)/.test(
1075
+ this.modelId
1076
+ )) {
1077
+ thinkingType = void 0;
1078
+ } else if (rejectsThinkingDisabled) {
1079
+ thinkingType = supportsBetweenToolsThinking ? "between_tools" : "adaptive";
1080
+ warnings.push({
1081
+ type: "unsupported",
1082
+ feature: "providerOptions.bedrock.reasoningConfig",
1083
+ details: `thinking cannot be disabled for ${this.modelId}. Using '${thinkingType}' thinking instead.`
1084
+ });
1085
+ }
1086
+ const effort = maxReasoningEffort != null ? maxReasoningEffort : (_h = (_g = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _g.output_config) == null ? void 0 : _h.effort;
1087
+ if ((thinkingType === "disabled" && rejectsThinkingDisabledAboveHighEffort || thinkingType === "between_tools") && (effort === "xhigh" || effort === "max")) {
1088
+ warnings.push({
1089
+ type: "unsupported",
1090
+ feature: maxReasoningEffort != null ? "providerOptions.bedrock.reasoningConfig.maxReasoningEffort" : "providerOptions.bedrock.additionalModelRequestFields.output_config.effort",
1091
+ details: `effort '${effort}' is not supported by ${this.modelId} with '${thinkingType}' thinking. The effort has been lowered to 'high'.`
1092
+ });
1093
+ maxReasoningEffort = "high";
1094
+ }
1095
+ }
1096
+ const isThinkingEnabled = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
1097
+ const structuredOutputMode = (_j = (_i = bedrockOptions.structuredOutputMode) != null ? _i : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _j : "auto";
1070
1098
  if (structuredOutputMode === "jsonTool") {
1071
1099
  const additionalModelRequestFields = {
1072
1100
  ...bedrockOptions.additionalModelRequestFields
@@ -1097,7 +1125,7 @@ var BedrockChatLanguageModel = class {
1097
1125
  toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
1098
1126
  modelId: this.modelId,
1099
1127
  modelFamily: this.config.modelFamily,
1100
- reasoningBudgetTokens: (_i = bedrockOptions.reasoningConfig) == null ? void 0 : _i.budgetTokens,
1128
+ reasoningBudgetTokens: (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.budgetTokens,
1101
1129
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
1102
1130
  });
1103
1131
  warnings.push(...toolWarnings);
@@ -1108,16 +1136,15 @@ var BedrockChatLanguageModel = class {
1108
1136
  };
1109
1137
  }
1110
1138
  if (betas.size > 0 || bedrockOptions.anthropicBeta) {
1111
- const existingBetas = (_j = bedrockOptions.anthropicBeta) != null ? _j : [];
1139
+ const existingBetas = (_l = bedrockOptions.anthropicBeta) != null ? _l : [];
1112
1140
  const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
1113
1141
  bedrockOptions.additionalModelRequestFields = {
1114
1142
  ...bedrockOptions.additionalModelRequestFields,
1115
1143
  anthropic_beta: mergedBetas
1116
1144
  };
1117
1145
  }
1118
- const thinkingType = (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.type;
1119
- const thinkingBudget = thinkingType === "enabled" ? (_l = bedrockOptions.reasoningConfig) == null ? void 0 : _l.budgetTokens : void 0;
1120
- const thinkingDisplay = thinkingType === "adaptive" ? (_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.display : void 0;
1146
+ const thinkingBudget = thinkingType === "enabled" ? (_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.budgetTokens : void 0;
1147
+ const thinkingDisplay = thinkingType === "adaptive" ? (_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.display : void 0;
1121
1148
  const isAnthropicThinkingEnabled = isAnthropicModel2 && isThinkingEnabled;
1122
1149
  const inferenceConfig = {
1123
1150
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
@@ -1126,7 +1153,7 @@ var BedrockChatLanguageModel = class {
1126
1153
  ...topK != null && { topK },
1127
1154
  ...stopSequences != null && { stopSequences }
1128
1155
  };
1129
- if (isAnthropicThinkingEnabled) {
1156
+ if (isAnthropicModel2) {
1130
1157
  if (thinkingBudget != null) {
1131
1158
  if (inferenceConfig.maxTokens != null) {
1132
1159
  inferenceConfig.maxTokens += thinkingBudget;
@@ -1148,9 +1175,14 @@ var BedrockChatLanguageModel = class {
1148
1175
  ...thinkingDisplay != null && { display: thinkingDisplay }
1149
1176
  }
1150
1177
  };
1178
+ } else if (thinkingType === "disabled" || thinkingType === "between_tools") {
1179
+ bedrockOptions.additionalModelRequestFields = {
1180
+ ...bedrockOptions.additionalModelRequestFields,
1181
+ thinking: { type: thinkingType }
1182
+ };
1151
1183
  }
1152
- } else if (!isAnthropicModel2) {
1153
- if (((_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.budgetTokens) != null) {
1184
+ } else {
1185
+ if (((_o = bedrockOptions.reasoningConfig) == null ? void 0 : _o.budgetTokens) != null) {
1154
1186
  warnings.push({
1155
1187
  type: "unsupported",
1156
1188
  feature: "budgetTokens",
@@ -1165,7 +1197,6 @@ var BedrockChatLanguageModel = class {
1165
1197
  });
1166
1198
  }
1167
1199
  }
1168
- const maxReasoningEffort = (_o = bedrockOptions.reasoningConfig) == null ? void 0 : _o.maxReasoningEffort;
1169
1200
  if (maxReasoningEffort != null) {
1170
1201
  if (isAnthropicModel2) {
1171
1202
  bedrockOptions.additionalModelRequestFields = {
@@ -2441,7 +2472,7 @@ import {
2441
2472
  import { AwsV4Signer } from "aws4fetch";
2442
2473
 
2443
2474
  // src/version.ts
2444
- var VERSION = true ? "4.0.204" : "0.0.0-test";
2475
+ var VERSION = true ? "4.0.206" : "0.0.0-test";
2445
2476
 
2446
2477
  // src/bedrock-sigv4-fetch.ts
2447
2478
  function createSigV4FetchFunction(getCredentials, fetch, service = "bedrock") {