@ai-sdk/anthropic 2.0.106 → 2.0.108

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
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "2.0.106" : "0.0.0-test";
14
+ var VERSION = true ? "2.0.108" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -729,7 +729,7 @@ var anthropicProviderOptions = z3.object({
729
729
  *
730
730
  * - `outputFormat`: Use the `output_format` parameter to specify the structured output format.
731
731
  * - `jsonTool`: Use a special JSON response tool to specify the structured output format (default for most models).
732
- * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Opus 5.5 and Fable 5.1).
732
+ * - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Sonnet 5.5, Opus 5.5, and Fable 5.1).
733
733
  */
734
734
  structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
735
735
  /**
@@ -742,6 +742,9 @@ var anthropicProviderOptions = z3.object({
742
742
  * `claude-fable-5-1`) reject `enabled` and `disabled`. For those models the
743
743
  * provider drops the unsupported setting, emits a warning, and sends an
744
744
  * adaptive thinking request. Use `effort` to control how much they think.
745
+ *
746
+ * `claude-sonnet-5-5` supports `between_tools`, its lowest thinking setting,
747
+ * and the provider uses it in place of `disabled` for that model.
745
748
  */
746
749
  thinking: z3.union([
747
750
  z3.object({
@@ -773,6 +776,14 @@ var anthropicProviderOptions = z3.object({
773
776
  z3.object({
774
777
  type: z3.literal("disabled")
775
778
  }),
779
+ z3.object({
780
+ /**
781
+ * for `claude-sonnet-5-5`: no upfront thinking, but progress notes
782
+ * between tool calls are returned as summarized thinking blocks.
783
+ * Only supported at `low`, `medium`, and `high` effort.
784
+ */
785
+ type: z3.literal("between_tools")
786
+ }),
776
787
  z3.object({
777
788
  /**
778
789
  * Configure prefix mismatch handling without changing the model's
@@ -2669,6 +2680,7 @@ var AnthropicMessagesLanguageModel = class {
2669
2680
  rejectsThinkingDisabledAboveHighEffort,
2670
2681
  rejectsThinkingDisabled,
2671
2682
  rejectsForcedToolUse,
2683
+ supportsBetweenToolsThinking,
2672
2684
  isKnownModel
2673
2685
  } = getModelCapabilities(this.modelId);
2674
2686
  if (!isKnownModel && maxOutputTokens == null) {
@@ -2704,7 +2716,7 @@ var AnthropicMessagesLanguageModel = class {
2704
2716
  }
2705
2717
  }
2706
2718
  const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
2707
- const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : this.modelId.includes("claude-fable-5-1") || this.modelId.includes("claude-opus-5-5") ? "auto" : "jsonTool";
2719
+ const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : this.modelId.includes("claude-fable-5-1") || this.modelId.includes("claude-opus-5-5") || this.modelId.includes("claude-sonnet-5-5") ? "auto" : "jsonTool";
2708
2720
  let useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2709
2721
  if (!useStructuredOutput && rejectsForcedToolUse && supportsStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
2710
2722
  warnings.push({
@@ -2739,7 +2751,14 @@ var AnthropicMessagesLanguageModel = class {
2739
2751
  });
2740
2752
  if (rejectsThinkingDisabled && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) != null) {
2741
2753
  const thinking = anthropicOptions.thinking;
2742
- if ("type" in thinking && thinking.type === "disabled") {
2754
+ if ("type" in thinking && thinking.type === "disabled" && supportsBetweenToolsThinking) {
2755
+ warnings.push({
2756
+ type: "unsupported-setting",
2757
+ setting: "providerOptions.anthropic.thinking",
2758
+ details: `thinking cannot be disabled for ${this.modelId}. Using 'between_tools' thinking, the lowest thinking setting, instead.`
2759
+ });
2760
+ anthropicOptions.thinking = { type: "between_tools" };
2761
+ } else if ("type" in thinking && thinking.type === "disabled") {
2743
2762
  warnings.push({
2744
2763
  type: "unsupported-setting",
2745
2764
  setting: "providerOptions.anthropic.thinking",
@@ -2770,7 +2789,15 @@ var AnthropicMessagesLanguageModel = class {
2770
2789
  });
2771
2790
  anthropicOptions.effort = "high";
2772
2791
  }
2773
- const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
2792
+ if (thinkingType === "between_tools" && anthropicOptions != null && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
2793
+ warnings.push({
2794
+ type: "unsupported-setting",
2795
+ setting: "providerOptions.anthropic.effort",
2796
+ details: `effort '${anthropicOptions.effort}' is not supported with 'between_tools' thinking. The effort has been lowered to 'high'.`
2797
+ });
2798
+ anthropicOptions.effort = "high";
2799
+ }
2800
+ const isThinking = thinkingType === "enabled" || thinkingType === "adaptive" || thinkingType === "between_tools";
2774
2801
  let thinkingBudget = thinkingOptions != null && "budgetTokens" in thinkingOptions ? thinkingOptions.budgetTokens : void 0;
2775
2802
  const thinkingDisplay = thinkingOptions != null && "display" in thinkingOptions ? thinkingOptions.display : void 0;
2776
2803
  const thinkingBlockBinding = thinkingOptions != null && "blockBinding" in thinkingOptions ? thinkingOptions.blockBinding : void 0;
@@ -4135,7 +4162,18 @@ var AnthropicMessagesLanguageModel = class {
4135
4162
  }
4136
4163
  };
4137
4164
  function getModelCapabilities(modelId) {
4138
- if (modelId.includes("claude-opus-5-5")) {
4165
+ if (modelId.includes("claude-sonnet-5-5")) {
4166
+ return {
4167
+ maxOutputTokens: 128e3,
4168
+ supportsStructuredOutput: true,
4169
+ rejectsSamplingParameters: true,
4170
+ rejectsThinkingDisabledAboveHighEffort: true,
4171
+ rejectsThinkingDisabled: true,
4172
+ rejectsForcedToolUse: true,
4173
+ supportsBetweenToolsThinking: true,
4174
+ isKnownModel: true
4175
+ };
4176
+ } else if (modelId.includes("claude-opus-5-5")) {
4139
4177
  return {
4140
4178
  maxOutputTokens: 128e3,
4141
4179
  supportsStructuredOutput: true,
@@ -4143,6 +4181,7 @@ function getModelCapabilities(modelId) {
4143
4181
  rejectsThinkingDisabledAboveHighEffort: true,
4144
4182
  rejectsThinkingDisabled: true,
4145
4183
  rejectsForcedToolUse: true,
4184
+ supportsBetweenToolsThinking: false,
4146
4185
  isKnownModel: true
4147
4186
  };
4148
4187
  } else if (modelId.includes("claude-opus-5")) {
@@ -4153,6 +4192,7 @@ function getModelCapabilities(modelId) {
4153
4192
  rejectsThinkingDisabledAboveHighEffort: true,
4154
4193
  rejectsThinkingDisabled: false,
4155
4194
  rejectsForcedToolUse: false,
4195
+ supportsBetweenToolsThinking: false,
4156
4196
  isKnownModel: true
4157
4197
  };
4158
4198
  } else if (modelId.includes("claude-fable-5-1")) {
@@ -4163,6 +4203,7 @@ function getModelCapabilities(modelId) {
4163
4203
  rejectsThinkingDisabledAboveHighEffort: false,
4164
4204
  rejectsThinkingDisabled: true,
4165
4205
  rejectsForcedToolUse: true,
4206
+ supportsBetweenToolsThinking: false,
4166
4207
  isKnownModel: true
4167
4208
  };
4168
4209
  } else if (modelId.includes("claude-fable-5")) {
@@ -4173,6 +4214,7 @@ function getModelCapabilities(modelId) {
4173
4214
  rejectsThinkingDisabledAboveHighEffort: false,
4174
4215
  rejectsThinkingDisabled: true,
4175
4216
  rejectsForcedToolUse: false,
4217
+ supportsBetweenToolsThinking: false,
4176
4218
  isKnownModel: true
4177
4219
  };
4178
4220
  } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-sonnet-5")) {
@@ -4183,6 +4225,7 @@ function getModelCapabilities(modelId) {
4183
4225
  rejectsThinkingDisabledAboveHighEffort: false,
4184
4226
  rejectsThinkingDisabled: false,
4185
4227
  rejectsForcedToolUse: false,
4228
+ supportsBetweenToolsThinking: false,
4186
4229
  isKnownModel: true
4187
4230
  };
4188
4231
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -4193,6 +4236,7 @@ function getModelCapabilities(modelId) {
4193
4236
  rejectsThinkingDisabledAboveHighEffort: false,
4194
4237
  rejectsThinkingDisabled: false,
4195
4238
  rejectsForcedToolUse: false,
4239
+ supportsBetweenToolsThinking: false,
4196
4240
  isKnownModel: true
4197
4241
  };
4198
4242
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -4203,6 +4247,7 @@ function getModelCapabilities(modelId) {
4203
4247
  rejectsThinkingDisabledAboveHighEffort: false,
4204
4248
  rejectsThinkingDisabled: false,
4205
4249
  rejectsForcedToolUse: false,
4250
+ supportsBetweenToolsThinking: false,
4206
4251
  isKnownModel: true
4207
4252
  };
4208
4253
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -4213,6 +4258,7 @@ function getModelCapabilities(modelId) {
4213
4258
  rejectsThinkingDisabledAboveHighEffort: false,
4214
4259
  rejectsThinkingDisabled: false,
4215
4260
  rejectsForcedToolUse: false,
4261
+ supportsBetweenToolsThinking: false,
4216
4262
  isKnownModel: true
4217
4263
  };
4218
4264
  } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
@@ -4223,6 +4269,7 @@ function getModelCapabilities(modelId) {
4223
4269
  rejectsThinkingDisabledAboveHighEffort: false,
4224
4270
  rejectsThinkingDisabled: false,
4225
4271
  rejectsForcedToolUse: false,
4272
+ supportsBetweenToolsThinking: false,
4226
4273
  isKnownModel: true
4227
4274
  };
4228
4275
  } else if (modelId.includes("claude-opus-4-")) {
@@ -4233,6 +4280,7 @@ function getModelCapabilities(modelId) {
4233
4280
  rejectsThinkingDisabledAboveHighEffort: false,
4234
4281
  rejectsThinkingDisabled: false,
4235
4282
  rejectsForcedToolUse: false,
4283
+ supportsBetweenToolsThinking: false,
4236
4284
  isKnownModel: true
4237
4285
  };
4238
4286
  } else if (modelId.includes("claude-3-haiku")) {
@@ -4243,6 +4291,7 @@ function getModelCapabilities(modelId) {
4243
4291
  rejectsThinkingDisabledAboveHighEffort: false,
4244
4292
  rejectsThinkingDisabled: false,
4245
4293
  rejectsForcedToolUse: false,
4294
+ supportsBetweenToolsThinking: false,
4246
4295
  isKnownModel: true
4247
4296
  };
4248
4297
  } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
@@ -4253,6 +4302,7 @@ function getModelCapabilities(modelId) {
4253
4302
  rejectsThinkingDisabledAboveHighEffort: false,
4254
4303
  rejectsThinkingDisabled: false,
4255
4304
  rejectsForcedToolUse: false,
4305
+ supportsBetweenToolsThinking: false,
4256
4306
  isKnownModel: false
4257
4307
  };
4258
4308
  } else if (modelId.includes("claude-")) {
@@ -4263,6 +4313,7 @@ function getModelCapabilities(modelId) {
4263
4313
  rejectsThinkingDisabledAboveHighEffort: true,
4264
4314
  rejectsThinkingDisabled: false,
4265
4315
  rejectsForcedToolUse: false,
4316
+ supportsBetweenToolsThinking: false,
4266
4317
  isKnownModel: false
4267
4318
  };
4268
4319
  } else {
@@ -4273,6 +4324,7 @@ function getModelCapabilities(modelId) {
4273
4324
  rejectsThinkingDisabledAboveHighEffort: false,
4274
4325
  rejectsThinkingDisabled: false,
4275
4326
  rejectsForcedToolUse: false,
4327
+ supportsBetweenToolsThinking: false,
4276
4328
  isKnownModel: false
4277
4329
  };
4278
4330
  }