@ai-sdk/anthropic 4.0.19 → 4.0.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.20
4
+
5
+ ### Patch Changes
6
+
7
+ - cbdc990: feat (provider/anthropic): support fallbacks 'default' mode, which routes safety classifier refusals to Anthropic's recommended fallback model (adds the server-side-fallback-2026-07-01 beta automatically)
8
+ - cbdc990: feat (provider/anthropic): support mid-conversation tool changes via the toolChanges system message provider option, emitting tool_addition/tool_removal content blocks and the mid-conversation-tool-changes-2026-07-01 beta
9
+ - cbdc990: feat (provider/anthropic): add claude-opus-5 model id with frontier-tier capabilities (128k output tokens, structured output, adaptive thinking, xhigh effort, sampling parameter rejection, thinking-disabled only at effort high or below)
10
+
3
11
  ## 4.0.19
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -183,7 +183,20 @@ interface AnthropicMessageMetadata {
183
183
  } | null;
184
184
  }
185
185
 
186
- type AnthropicModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
186
+ type AnthropicModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
187
+ /**
188
+ * Anthropic provider options for system messages.
189
+ */
190
+ declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
191
+ toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
192
+ type: z.ZodLiteral<"tool_addition">;
193
+ toolName: z.ZodString;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ type: z.ZodLiteral<"tool_removal">;
196
+ toolName: z.ZodString;
197
+ }, z.core.$strip>]>>>;
198
+ }, z.core.$strip>;
199
+ type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessageProviderOptions>;
187
200
  declare const anthropicLanguageModelOptions: z.ZodObject<{
188
201
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
189
202
  structuredOutputMode: z.ZodOptional<z.ZodEnum<{
@@ -254,7 +267,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
254
267
  us: "us";
255
268
  global: "global";
256
269
  }>>;
257
- fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
270
+ fallbacks: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"default">, z.ZodArray<z.ZodObject<{
258
271
  model: z.ZodString;
259
272
  max_tokens: z.ZodOptional<z.ZodNumber>;
260
273
  thinking: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -263,7 +276,7 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
263
276
  fast: "fast";
264
277
  standard: "standard";
265
278
  }>>;
266
- }, z.core.$strip>>>;
279
+ }, z.core.$strip>>]>>;
267
280
  anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
268
281
  contextManagement: z.ZodOptional<z.ZodObject<{
269
282
  edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1284,4 +1297,4 @@ declare function forwardAnthropicContainerIdFromLastStep({ steps, }: {
1284
1297
 
1285
1298
  declare const VERSION: string;
1286
1299
 
1287
- export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
1300
+ export { type AnthropicLanguageModelOptions, type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicLanguageModelOptions as AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicSystemMessageProviderOptions, type AnthropicToolOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic, forwardAnthropicContainerIdFromLastStep };
package/dist/index.js CHANGED
@@ -980,6 +980,34 @@ var anthropicFilePartProviderOptions = z4.object({
980
980
  */
981
981
  context: z4.string().optional()
982
982
  });
983
+ var anthropicSystemMessageProviderOptions = z4.object({
984
+ /**
985
+ * Mid-conversation tool changes. Adds or removes tools from the
986
+ * conversation's tool set between turns without invalidating the prompt
987
+ * cache.
988
+ *
989
+ * Only supported on system messages that appear mid-conversation (not the
990
+ * initial system prompt). A system message carrying tool changes must come
991
+ * right before an assistant message or at the end of the messages.
992
+ *
993
+ * Tools referenced by a `tool_addition` must be declared in the `tools`
994
+ * option (typically with `deferLoading: true` so they are not loaded until
995
+ * the addition surfaces them). The required
996
+ * `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
997
+ */
998
+ toolChanges: z4.array(
999
+ z4.discriminatedUnion("type", [
1000
+ z4.object({
1001
+ type: z4.literal("tool_addition"),
1002
+ toolName: z4.string()
1003
+ }),
1004
+ z4.object({
1005
+ type: z4.literal("tool_removal"),
1006
+ toolName: z4.string()
1007
+ })
1008
+ ])
1009
+ ).optional()
1010
+ });
983
1011
  var anthropicLanguageModelOptions = z4.object({
984
1012
  /**
985
1013
  * Whether to send reasoning to the model.
@@ -1126,30 +1154,35 @@ var anthropicLanguageModelOptions = z4.object({
1126
1154
  */
1127
1155
  inferenceGeo: z4.enum(["us", "global"]).optional(),
1128
1156
  /**
1129
- * Server-side fallback chain.
1157
+ * Server-side fallback configuration.
1130
1158
  *
1131
1159
  * When the primary model's safety classifiers block a turn, the API
1132
- * automatically retries it on the next model in the chain, server-side. A
1133
- * `content-filter` finish reason means the entire chain refused.
1134
- *
1135
- * Each entry is merged into the request as a direct request to that entry's
1136
- * model, so it must be formatted accordingly: `model` is required, and an
1137
- * entry may additionally override `max_tokens`, `thinking`, `output_config`,
1138
- * and `speed` for that attempt only (`speed` additionally requires the speed
1139
- * beta). The value is passed through to the API as-is.
1160
+ * automatically retries it server-side on a fallback model. A
1161
+ * `content-filter` finish reason means the fallback(s) refused as well.
1140
1162
  *
1141
- * The required `server-side-fallback-2026-06-01` beta is added automatically
1142
- * when this option is set.
1163
+ * - `'default'` (recommended): the API routes the retry to Anthropic's
1164
+ * recommended fallback model based on the refusal category. Requires the
1165
+ * `server-side-fallback-2026-07-01` beta, which is added automatically.
1166
+ * - Array form: an explicit fallback chain. Each entry is merged into the
1167
+ * request as a direct request to that entry's model, so it must be
1168
+ * formatted accordingly: `model` is required, and an entry may
1169
+ * additionally override `max_tokens`, `thinking`, `output_config`, and
1170
+ * `speed` for that attempt only (`speed` additionally requires the speed
1171
+ * beta). The value is passed through to the API as-is, and the
1172
+ * `server-side-fallback-2026-06-01` beta is added automatically.
1143
1173
  */
1144
- fallbacks: z4.array(
1145
- z4.object({
1146
- model: z4.string(),
1147
- max_tokens: z4.number().int().optional(),
1148
- thinking: z4.record(z4.string(), z4.unknown()).optional(),
1149
- output_config: z4.record(z4.string(), z4.unknown()).optional(),
1150
- speed: z4.enum(["fast", "standard"]).optional()
1151
- })
1152
- ).optional(),
1174
+ fallbacks: z4.union([
1175
+ z4.literal("default"),
1176
+ z4.array(
1177
+ z4.object({
1178
+ model: z4.string(),
1179
+ max_tokens: z4.number().int().optional(),
1180
+ thinking: z4.record(z4.string(), z4.unknown()).optional(),
1181
+ output_config: z4.record(z4.string(), z4.unknown()).optional(),
1182
+ speed: z4.enum(["fast", "standard"]).optional()
1183
+ })
1184
+ )
1185
+ ]).optional(),
1153
1186
  /**
1154
1187
  * A set of beta features to enable.
1155
1188
  * Allow a provider to receive the full `betas` set if it needs it.
@@ -2342,7 +2375,7 @@ async function convertToAnthropicPrompt({
2342
2375
  cacheControlValidator,
2343
2376
  toolNameMapping
2344
2377
  }) {
2345
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2378
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
2346
2379
  const betas = /* @__PURE__ */ new Set();
2347
2380
  const blocks = groupIntoBlocks(prompt);
2348
2381
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -2383,19 +2416,52 @@ async function convertToAnthropicPrompt({
2383
2416
  const type = block.type;
2384
2417
  switch (type) {
2385
2418
  case "system": {
2386
- const content = block.messages.map(({ content: content2, providerOptions }) => ({
2387
- type: "text",
2388
- text: content2,
2389
- cache_control: validator.getCacheControl(providerOptions, {
2390
- type: "system message",
2391
- canCache: true
2392
- })
2393
- }));
2394
- if (system == null) {
2395
- system = content;
2419
+ const content = [];
2420
+ let toolChangeCount = 0;
2421
+ for (const { content: text, providerOptions } of block.messages) {
2422
+ const systemMessageOptions = await parseProviderOptions({
2423
+ provider: "anthropic",
2424
+ providerOptions,
2425
+ schema: anthropicSystemMessageProviderOptions
2426
+ });
2427
+ const toolChanges = (_a = systemMessageOptions == null ? void 0 : systemMessageOptions.toolChanges) != null ? _a : [];
2428
+ if (text !== "" || toolChanges.length === 0) {
2429
+ content.push({
2430
+ type: "text",
2431
+ text,
2432
+ cache_control: validator.getCacheControl(providerOptions, {
2433
+ type: "system message",
2434
+ canCache: true
2435
+ })
2436
+ });
2437
+ }
2438
+ for (const toolChange of toolChanges) {
2439
+ toolChangeCount++;
2440
+ content.push({
2441
+ type: toolChange.type,
2442
+ tool: {
2443
+ type: "tool_reference",
2444
+ name: toolNameMapping.toProviderToolName(toolChange.toolName)
2445
+ }
2446
+ });
2447
+ }
2448
+ }
2449
+ if (i === 0 || system == null && toolChangeCount === 0) {
2450
+ if (toolChangeCount > 0) {
2451
+ warnings.push({
2452
+ type: "other",
2453
+ message: "tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."
2454
+ });
2455
+ }
2456
+ system = content.filter(
2457
+ (part) => part.type === "text"
2458
+ );
2396
2459
  } else {
2397
2460
  messages.push({ role: "system", content });
2398
2461
  betas.add("mid-conversation-system-2026-04-07");
2462
+ if (toolChangeCount > 0) {
2463
+ betas.add("mid-conversation-tool-changes-2026-07-01");
2464
+ }
2399
2465
  }
2400
2466
  break;
2401
2467
  }
@@ -2408,10 +2474,10 @@ async function convertToAnthropicPrompt({
2408
2474
  for (let j = 0; j < content.length; j++) {
2409
2475
  const part = content[j];
2410
2476
  const isLastPart = j === content.length - 1;
2411
- const cacheControl = (_a = validator.getCacheControl(part.providerOptions, {
2477
+ const cacheControl = (_b = validator.getCacheControl(part.providerOptions, {
2412
2478
  type: "user message part",
2413
2479
  canCache: true
2414
- })) != null ? _a : isLastPart ? validator.getCacheControl(message.providerOptions, {
2480
+ })) != null ? _b : isLastPart ? validator.getCacheControl(message.providerOptions, {
2415
2481
  type: "user message",
2416
2482
  canCache: true
2417
2483
  }) : void 0;
@@ -2466,7 +2532,7 @@ async function convertToAnthropicPrompt({
2466
2532
  media_type: "text/plain",
2467
2533
  data: part.data.text
2468
2534
  },
2469
- title: (_b = metadata.title) != null ? _b : part.filename,
2535
+ title: (_c = metadata.title) != null ? _c : part.filename,
2470
2536
  ...metadata.context && {
2471
2537
  context: metadata.context
2472
2538
  },
@@ -2511,7 +2577,7 @@ async function convertToAnthropicPrompt({
2511
2577
  media_type: "application/pdf",
2512
2578
  data: convertToBase64(part.data.data)
2513
2579
  },
2514
- title: (_c = metadata.title) != null ? _c : part.filename,
2580
+ title: (_d = metadata.title) != null ? _d : part.filename,
2515
2581
  ...metadata.context && {
2516
2582
  context: metadata.context
2517
2583
  },
@@ -2539,7 +2605,7 @@ async function convertToAnthropicPrompt({
2539
2605
  part.data.data
2540
2606
  )
2541
2607
  },
2542
- title: (_d = metadata.title) != null ? _d : part.filename,
2608
+ title: (_e = metadata.title) != null ? _e : part.filename,
2543
2609
  ...metadata.context && {
2544
2610
  context: metadata.context
2545
2611
  },
@@ -2569,17 +2635,17 @@ async function convertToAnthropicPrompt({
2569
2635
  continue;
2570
2636
  }
2571
2637
  const output = part.output;
2572
- const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_e = output.value.find(
2638
+ const outputProviderOptions = "providerOptions" in output ? output.providerOptions : output.type === "content" ? (_f = output.value.find(
2573
2639
  (contentPart) => contentPart.providerOptions != null
2574
- )) == null ? void 0 : _e.providerOptions : void 0;
2640
+ )) == null ? void 0 : _f.providerOptions : void 0;
2575
2641
  const isLastPart = i2 === content.length - 1;
2576
- const cacheControl = (_g = (_f = validator.getCacheControl(part.providerOptions, {
2642
+ const cacheControl = (_h = (_g = validator.getCacheControl(part.providerOptions, {
2577
2643
  type: "tool result part",
2578
2644
  canCache: true
2579
- })) != null ? _f : validator.getCacheControl(outputProviderOptions, {
2645
+ })) != null ? _g : validator.getCacheControl(outputProviderOptions, {
2580
2646
  type: "tool result output",
2581
2647
  canCache: true
2582
- })) != null ? _g : isLastPart ? validator.getCacheControl(message.providerOptions, {
2648
+ })) != null ? _h : isLastPart ? validator.getCacheControl(message.providerOptions, {
2583
2649
  type: "tool result message",
2584
2650
  canCache: true
2585
2651
  }) : void 0;
@@ -2685,7 +2751,7 @@ async function convertToAnthropicPrompt({
2685
2751
  contentValue = output.value;
2686
2752
  break;
2687
2753
  case "execution-denied":
2688
- contentValue = (_h = output.reason) != null ? _h : "Tool call execution denied.";
2754
+ contentValue = (_i = output.reason) != null ? _i : "Tool call execution denied.";
2689
2755
  break;
2690
2756
  case "json":
2691
2757
  case "error-json":
@@ -2722,16 +2788,16 @@ async function convertToAnthropicPrompt({
2722
2788
  for (let k = 0; k < content.length; k++) {
2723
2789
  const part = content[k];
2724
2790
  const isLastContentPart = k === content.length - 1;
2725
- const cacheControl = (_i = validator.getCacheControl(part.providerOptions, {
2791
+ const cacheControl = (_j = validator.getCacheControl(part.providerOptions, {
2726
2792
  type: "assistant message part",
2727
2793
  canCache: true
2728
- })) != null ? _i : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2794
+ })) != null ? _j : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
2729
2795
  type: "assistant message",
2730
2796
  canCache: true
2731
2797
  }) : void 0;
2732
2798
  switch (part.type) {
2733
2799
  case "text": {
2734
- const textMetadata = (_j = part.providerOptions) == null ? void 0 : _j.anthropic;
2800
+ const textMetadata = (_k = part.providerOptions) == null ? void 0 : _k.anthropic;
2735
2801
  if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
2736
2802
  anthropicContent.push({
2737
2803
  type: "compaction",
@@ -2807,10 +2873,10 @@ async function convertToAnthropicPrompt({
2807
2873
  const providerToolName = toolNameMapping.toProviderToolName(
2808
2874
  part.toolName
2809
2875
  );
2810
- const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.type) === "mcp-tool-use";
2876
+ const isMcpToolUse = ((_m = (_l = part.providerOptions) == null ? void 0 : _l.anthropic) == null ? void 0 : _m.type) === "mcp-tool-use";
2811
2877
  if (isMcpToolUse) {
2812
2878
  mcpToolUseIds.add(part.toolCallId);
2813
- const serverName = (_n = (_m = part.providerOptions) == null ? void 0 : _m.anthropic) == null ? void 0 : _n.serverName;
2879
+ const serverName = (_o = (_n = part.providerOptions) == null ? void 0 : _n.anthropic) == null ? void 0 : _o.serverName;
2814
2880
  if (serverName == null || typeof serverName !== "string") {
2815
2881
  warnings.push({
2816
2882
  type: "other",
@@ -2886,7 +2952,7 @@ async function convertToAnthropicPrompt({
2886
2952
  }
2887
2953
  break;
2888
2954
  }
2889
- const callerOptions = (_o = part.providerOptions) == null ? void 0 : _o.anthropic;
2955
+ const callerOptions = (_p = part.providerOptions) == null ? void 0 : _p.anthropic;
2890
2956
  const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
2891
2957
  type: callerOptions.caller.type,
2892
2958
  tool_id: callerOptions.caller.toolId
@@ -2939,7 +3005,7 @@ async function convertToAnthropicPrompt({
2939
3005
  tool_use_id: part.toolCallId,
2940
3006
  content: {
2941
3007
  type: "code_execution_tool_result_error",
2942
- error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
3008
+ error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
2943
3009
  },
2944
3010
  cache_control: cacheControl
2945
3011
  });
@@ -2950,7 +3016,7 @@ async function convertToAnthropicPrompt({
2950
3016
  cache_control: cacheControl,
2951
3017
  content: {
2952
3018
  type: "bash_code_execution_tool_result_error",
2953
- error_code: (_q = errorInfo.errorCode) != null ? _q : "unknown"
3019
+ error_code: (_r = errorInfo.errorCode) != null ? _r : "unknown"
2954
3020
  }
2955
3021
  });
2956
3022
  }
@@ -2983,7 +3049,7 @@ async function convertToAnthropicPrompt({
2983
3049
  stdout: codeExecutionOutput.stdout,
2984
3050
  stderr: codeExecutionOutput.stderr,
2985
3051
  return_code: codeExecutionOutput.return_code,
2986
- content: (_r = codeExecutionOutput.content) != null ? _r : []
3052
+ content: (_s = codeExecutionOutput.content) != null ? _s : []
2987
3053
  },
2988
3054
  cache_control: cacheControl
2989
3055
  });
@@ -3001,7 +3067,7 @@ async function convertToAnthropicPrompt({
3001
3067
  encrypted_stdout: codeExecutionOutput.encrypted_stdout,
3002
3068
  stderr: codeExecutionOutput.stderr,
3003
3069
  return_code: codeExecutionOutput.return_code,
3004
- content: (_s = codeExecutionOutput.content) != null ? _s : []
3070
+ content: (_t = codeExecutionOutput.content) != null ? _t : []
3005
3071
  },
3006
3072
  cache_control: cacheControl
3007
3073
  });
@@ -3020,7 +3086,7 @@ async function convertToAnthropicPrompt({
3020
3086
  stdout: codeExecutionOutput.stdout,
3021
3087
  stderr: codeExecutionOutput.stderr,
3022
3088
  return_code: codeExecutionOutput.return_code,
3023
- content: (_t = codeExecutionOutput.content) != null ? _t : []
3089
+ content: (_u = codeExecutionOutput.content) != null ? _u : []
3024
3090
  },
3025
3091
  cache_control: cacheControl
3026
3092
  });
@@ -3050,7 +3116,7 @@ async function convertToAnthropicPrompt({
3050
3116
  tool_use_id: part.toolCallId,
3051
3117
  content: {
3052
3118
  type: "web_fetch_tool_result_error",
3053
- error_code: (_u = extractErrorValue(output.value).errorCode) != null ? _u : "unavailable"
3119
+ error_code: (_v = extractErrorValue(output.value).errorCode) != null ? _v : "unavailable"
3054
3120
  },
3055
3121
  cache_control: cacheControl
3056
3122
  });
@@ -3097,7 +3163,7 @@ async function convertToAnthropicPrompt({
3097
3163
  tool_use_id: part.toolCallId,
3098
3164
  content: {
3099
3165
  type: "web_search_tool_result_error",
3100
- error_code: (_v = extractErrorValue(output.value).errorCode) != null ? _v : "unavailable"
3166
+ error_code: (_w = extractErrorValue(output.value).errorCode) != null ? _w : "unavailable"
3101
3167
  },
3102
3168
  cache_control: cacheControl
3103
3169
  });
@@ -3568,7 +3634,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3568
3634
  providerOptions,
3569
3635
  stream
3570
3636
  }) {
3571
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
3637
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3572
3638
  const warnings = [];
3573
3639
  if (frequencyPenalty != null) {
3574
3640
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -3626,6 +3692,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3626
3692
  supportsAdaptiveThinking,
3627
3693
  rejectsSamplingParameters,
3628
3694
  supportsXhighEffort,
3695
+ rejectsThinkingDisabledAboveHighEffort,
3629
3696
  isKnownModel
3630
3697
  } = getModelCapabilities(this.modelId);
3631
3698
  if (!isKnownModel && maxOutputTokens == null) {
@@ -3729,11 +3796,19 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3729
3796
  }
3730
3797
  }
3731
3798
  }
3732
- const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
3799
+ if (rejectsThinkingDisabledAboveHighEffort && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type) === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
3800
+ warnings.push({
3801
+ type: "unsupported",
3802
+ feature: "providerOptions.anthropic.effort",
3803
+ details: `effort '${anthropicOptions.effort}' is not supported by ${this.modelId} when thinking is disabled. The effort has been lowered to 'high'.`
3804
+ });
3805
+ anthropicOptions.effort = "high";
3806
+ }
3807
+ const thinkingType = (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type;
3733
3808
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3734
3809
  const sendThinking = isThinking || thinkingType === "disabled";
3735
- let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
3736
- const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
3810
+ let thinkingBudget = thinkingType === "enabled" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.budgetTokens : void 0;
3811
+ const thinkingDisplay = thinkingType === "adaptive" ? (_i = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _i.display : void 0;
3737
3812
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3738
3813
  const baseArgs = {
3739
3814
  // model id:
@@ -3780,13 +3855,13 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3780
3855
  ...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
3781
3856
  inference_geo: anthropicOptions.inferenceGeo
3782
3857
  },
3783
- ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0 && {
3858
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) != null && (anthropicOptions.fallbacks === "default" || anthropicOptions.fallbacks.length > 0) && {
3784
3859
  fallbacks: anthropicOptions.fallbacks
3785
3860
  },
3786
3861
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
3787
3862
  cache_control: anthropicOptions.cacheControl
3788
3863
  },
3789
- ...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
3864
+ ...((_j = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _j.userId) != null && {
3790
3865
  metadata: { user_id: anthropicOptions.metadata.userId }
3791
3866
  },
3792
3867
  // mcp servers:
@@ -3962,10 +4037,12 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
3962
4037
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3963
4038
  betas.add("fast-mode-2026-02-01");
3964
4039
  }
3965
- if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
4040
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) === "default") {
4041
+ betas.add("server-side-fallback-2026-07-01");
4042
+ } else if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
3966
4043
  betas.add("server-side-fallback-2026-06-01");
3967
4044
  }
3968
- const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
4045
+ const defaultEagerInputStreaming = stream && ((_k = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _k : true);
3969
4046
  const {
3970
4047
  tools: anthropicTools2,
3971
4048
  toolChoice: anthropicToolChoice,
@@ -4004,7 +4081,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
4004
4081
  ...betas,
4005
4082
  ...toolsBetas,
4006
4083
  ...userSuppliedBetas,
4007
- ...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
4084
+ ...(_l = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _l : []
4008
4085
  ]),
4009
4086
  usesJsonResponseTool: jsonResponseTool != null,
4010
4087
  toolNameMapping,
@@ -5444,13 +5521,24 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
5444
5521
  }
5445
5522
  };
5446
5523
  function getModelCapabilities(modelId) {
5447
- if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5524
+ if (modelId.includes("claude-opus-5")) {
5525
+ return {
5526
+ maxOutputTokens: 128e3,
5527
+ supportsStructuredOutput: true,
5528
+ supportsAdaptiveThinking: true,
5529
+ rejectsSamplingParameters: true,
5530
+ supportsXhighEffort: true,
5531
+ rejectsThinkingDisabledAboveHighEffort: true,
5532
+ isKnownModel: true
5533
+ };
5534
+ } else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
5448
5535
  return {
5449
5536
  maxOutputTokens: 128e3,
5450
5537
  supportsStructuredOutput: true,
5451
5538
  supportsAdaptiveThinking: true,
5452
5539
  rejectsSamplingParameters: true,
5453
5540
  supportsXhighEffort: true,
5541
+ rejectsThinkingDisabledAboveHighEffort: false,
5454
5542
  isKnownModel: true
5455
5543
  };
5456
5544
  } else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
@@ -5460,6 +5548,7 @@ function getModelCapabilities(modelId) {
5460
5548
  supportsAdaptiveThinking: true,
5461
5549
  rejectsSamplingParameters: false,
5462
5550
  supportsXhighEffort: false,
5551
+ rejectsThinkingDisabledAboveHighEffort: false,
5463
5552
  isKnownModel: true
5464
5553
  };
5465
5554
  } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
@@ -5469,6 +5558,7 @@ function getModelCapabilities(modelId) {
5469
5558
  supportsAdaptiveThinking: false,
5470
5559
  rejectsSamplingParameters: false,
5471
5560
  supportsXhighEffort: false,
5561
+ rejectsThinkingDisabledAboveHighEffort: false,
5472
5562
  isKnownModel: true
5473
5563
  };
5474
5564
  } else if (modelId.includes("claude-opus-4-1")) {
@@ -5478,6 +5568,7 @@ function getModelCapabilities(modelId) {
5478
5568
  supportsAdaptiveThinking: false,
5479
5569
  rejectsSamplingParameters: false,
5480
5570
  supportsXhighEffort: false,
5571
+ rejectsThinkingDisabledAboveHighEffort: false,
5481
5572
  isKnownModel: true
5482
5573
  };
5483
5574
  } else if (modelId.includes("claude-sonnet-4-")) {
@@ -5487,6 +5578,7 @@ function getModelCapabilities(modelId) {
5487
5578
  supportsAdaptiveThinking: false,
5488
5579
  rejectsSamplingParameters: false,
5489
5580
  supportsXhighEffort: false,
5581
+ rejectsThinkingDisabledAboveHighEffort: false,
5490
5582
  isKnownModel: true
5491
5583
  };
5492
5584
  } else if (modelId.includes("claude-opus-4-")) {
@@ -5496,6 +5588,7 @@ function getModelCapabilities(modelId) {
5496
5588
  supportsAdaptiveThinking: false,
5497
5589
  rejectsSamplingParameters: false,
5498
5590
  supportsXhighEffort: false,
5591
+ rejectsThinkingDisabledAboveHighEffort: false,
5499
5592
  isKnownModel: true
5500
5593
  };
5501
5594
  } else if (modelId.includes("claude-3-haiku")) {
@@ -5505,6 +5598,7 @@ function getModelCapabilities(modelId) {
5505
5598
  supportsAdaptiveThinking: false,
5506
5599
  rejectsSamplingParameters: false,
5507
5600
  supportsXhighEffort: false,
5601
+ rejectsThinkingDisabledAboveHighEffort: false,
5508
5602
  isKnownModel: true
5509
5603
  };
5510
5604
  } else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
@@ -5514,6 +5608,7 @@ function getModelCapabilities(modelId) {
5514
5608
  supportsAdaptiveThinking: false,
5515
5609
  rejectsSamplingParameters: false,
5516
5610
  supportsXhighEffort: false,
5611
+ rejectsThinkingDisabledAboveHighEffort: false,
5517
5612
  isKnownModel: false
5518
5613
  };
5519
5614
  } else if (modelId.includes("claude-")) {
@@ -5523,6 +5618,7 @@ function getModelCapabilities(modelId) {
5523
5618
  supportsAdaptiveThinking: true,
5524
5619
  rejectsSamplingParameters: true,
5525
5620
  supportsXhighEffort: true,
5621
+ rejectsThinkingDisabledAboveHighEffort: true,
5526
5622
  isKnownModel: false
5527
5623
  };
5528
5624
  } else {
@@ -5532,6 +5628,7 @@ function getModelCapabilities(modelId) {
5532
5628
  supportsAdaptiveThinking: false,
5533
5629
  rejectsSamplingParameters: false,
5534
5630
  supportsXhighEffort: false,
5631
+ rejectsThinkingDisabledAboveHighEffort: false,
5535
5632
  isKnownModel: false
5536
5633
  };
5537
5634
  }
@@ -6365,7 +6462,7 @@ var AnthropicSkills = class {
6365
6462
  };
6366
6463
 
6367
6464
  // src/version.ts
6368
- var VERSION = true ? "4.0.19" : "0.0.0-test";
6465
+ var VERSION = true ? "4.0.20" : "0.0.0-test";
6369
6466
 
6370
6467
  // src/anthropic-provider.ts
6371
6468
  var ANTHROPIC_API_URL = "https://api.anthropic.com";