@ai-sdk/amazon-bedrock 3.0.96 → 3.0.98

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.96" : "0.0.0-test";
11
+ var VERSION = true ? "3.0.98" : "0.0.0-test";
12
12
 
13
13
  // src/bedrock-provider.ts
14
14
  import { anthropicTools as anthropicTools2 } from "@ai-sdk/anthropic/internal";
@@ -86,12 +86,23 @@ var bedrockProviderOptions = z.object({
86
86
  z.literal("adaptive")
87
87
  ]).optional(),
88
88
  budgetTokens: z.number().optional(),
89
- maxReasoningEffort: z.enum(["low", "medium", "high", "max"]).optional()
89
+ maxReasoningEffort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
90
+ display: z.enum(["omitted", "summarized"]).optional()
90
91
  }).optional(),
91
92
  /**
92
93
  * Anthropic beta features to enable
93
94
  */
94
- anthropicBeta: z.array(z.string()).optional()
95
+ anthropicBeta: z.array(z.string()).optional(),
96
+ /**
97
+ * Service tier for the request.
98
+ * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html
99
+ *
100
+ * - 'reserved': Uses provisioned throughput capacity
101
+ * - 'priority': Prioritizes low-latency inference when capacity is available
102
+ * - 'default': Standard on-demand tier
103
+ * - 'flex': Lower-cost tier for flexible latency workloads
104
+ */
105
+ serviceTier: z.enum(["reserved", "priority", "default", "flex"]).optional()
95
106
  });
96
107
 
97
108
  // src/bedrock-error.ts
@@ -707,7 +718,7 @@ var BedrockChatLanguageModel = class {
707
718
  toolChoice,
708
719
  providerOptions
709
720
  }) {
710
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
721
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
711
722
  const bedrockOptions = (_a = await parseProviderOptions2({
712
723
  provider: "bedrock",
713
724
  providerOptions,
@@ -784,6 +795,7 @@ var BedrockChatLanguageModel = class {
784
795
  const thinkingType = (_c = bedrockOptions.reasoningConfig) == null ? void 0 : _c.type;
785
796
  const isThinkingRequested = thinkingType === "enabled" || thinkingType === "adaptive";
786
797
  const thinkingBudget = thinkingType === "enabled" ? (_d = bedrockOptions.reasoningConfig) == null ? void 0 : _d.budgetTokens : void 0;
798
+ const thinkingDisplay = thinkingType === "adaptive" ? (_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.display : void 0;
787
799
  const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingRequested;
788
800
  const inferenceConfig = {
789
801
  ...maxOutputTokens != null && { maxTokens: maxOutputTokens },
@@ -810,12 +822,13 @@ var BedrockChatLanguageModel = class {
810
822
  bedrockOptions.additionalModelRequestFields = {
811
823
  ...bedrockOptions.additionalModelRequestFields,
812
824
  thinking: {
813
- type: "adaptive"
825
+ type: "adaptive",
826
+ ...thinkingDisplay != null && { display: thinkingDisplay }
814
827
  }
815
828
  };
816
829
  }
817
830
  } else if (!isAnthropicModel) {
818
- if (((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.budgetTokens) != null) {
831
+ if (((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.budgetTokens) != null) {
819
832
  warnings.push({
820
833
  type: "unsupported-setting",
821
834
  setting: "budgetTokens",
@@ -830,12 +843,12 @@ var BedrockChatLanguageModel = class {
830
843
  });
831
844
  }
832
845
  }
833
- const maxReasoningEffort = (_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.maxReasoningEffort;
846
+ const maxReasoningEffort = (_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.maxReasoningEffort;
834
847
  if (maxReasoningEffort != null && !isAnthropicModel) {
835
848
  bedrockOptions.additionalModelRequestFields = {
836
849
  ...bedrockOptions.additionalModelRequestFields,
837
850
  reasoningConfig: {
838
- ...((_g = bedrockOptions.reasoningConfig) == null ? void 0 : _g.type) != null && {
851
+ ...((_h = bedrockOptions.reasoningConfig) == null ? void 0 : _h.type) != null && {
839
852
  type: bedrockOptions.reasoningConfig.type
840
853
  },
841
854
  maxReasoningEffort
@@ -873,7 +886,7 @@ var BedrockChatLanguageModel = class {
873
886
  details: "topK is not supported when thinking is enabled"
874
887
  });
875
888
  }
876
- const hasAnyTools = ((_i = (_h = toolConfig.tools) == null ? void 0 : _h.length) != null ? _i : 0) > 0 || additionalTools;
889
+ const hasAnyTools = ((_j = (_i = toolConfig.tools) == null ? void 0 : _i.length) != null ? _j : 0) > 0 || additionalTools;
877
890
  let filteredPrompt = prompt;
878
891
  if (!hasAnyTools) {
879
892
  const hasToolContent = prompt.some(
@@ -903,6 +916,7 @@ var BedrockChatLanguageModel = class {
903
916
  const {
904
917
  reasoningConfig: _,
905
918
  additionalModelRequestFields: __,
919
+ serviceTier: ___,
906
920
  ...filteredBedrockOptions
907
921
  } = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
908
922
  const additionalModelResponseFieldPaths = isAnthropicModel ? ["/delta/stop_sequence"] : void 0;
@@ -917,6 +931,11 @@ var BedrockChatLanguageModel = class {
917
931
  ...Object.keys(inferenceConfig).length > 0 && {
918
932
  inferenceConfig
919
933
  },
934
+ ...bedrockOptions.serviceTier != null && {
935
+ serviceTier: {
936
+ type: bedrockOptions.serviceTier
937
+ }
938
+ },
920
939
  ...filteredBedrockOptions,
921
940
  ...toolConfig.tools !== void 0 && toolConfig.tools.length > 0 ? { toolConfig } : {}
922
941
  },
@@ -1218,6 +1237,13 @@ var BedrockChatLanguageModel = class {
1218
1237
  delta: reasoningContent.text
1219
1238
  });
1220
1239
  } else if ("signature" in reasoningContent && reasoningContent.signature) {
1240
+ if (contentBlocks[blockIndex] == null) {
1241
+ contentBlocks[blockIndex] = { type: "reasoning" };
1242
+ controller.enqueue({
1243
+ type: "reasoning-start",
1244
+ id: String(blockIndex)
1245
+ });
1246
+ }
1221
1247
  controller.enqueue({
1222
1248
  type: "reasoning-delta",
1223
1249
  id: String(blockIndex),
@@ -1229,6 +1255,13 @@ var BedrockChatLanguageModel = class {
1229
1255
  }
1230
1256
  });
1231
1257
  } else if ("data" in reasoningContent && reasoningContent.data) {
1258
+ if (contentBlocks[blockIndex] == null) {
1259
+ contentBlocks[blockIndex] = { type: "reasoning" };
1260
+ controller.enqueue({
1261
+ type: "reasoning-start",
1262
+ id: String(blockIndex)
1263
+ });
1264
+ }
1232
1265
  controller.enqueue({
1233
1266
  type: "reasoning-delta",
1234
1267
  id: String(blockIndex),