@ai-sdk/anthropic 3.0.60 → 3.0.62

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
@@ -12,7 +12,7 @@ import {
12
12
  } from "@ai-sdk/provider-utils";
13
13
 
14
14
  // src/version.ts
15
- var VERSION = true ? "3.0.60" : "0.0.0-test";
15
+ var VERSION = true ? "3.0.62" : "0.0.0-test";
16
16
 
17
17
  // src/anthropic-messages-language-model.ts
18
18
  import {
@@ -1282,7 +1282,8 @@ async function prepareTools({
1282
1282
  toolChoice,
1283
1283
  disableParallelToolUse,
1284
1284
  cacheControlValidator,
1285
- supportsStructuredOutput
1285
+ supportsStructuredOutput,
1286
+ supportsStrictTools
1286
1287
  }) {
1287
1288
  var _a;
1288
1289
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -1304,13 +1305,20 @@ async function prepareTools({
1304
1305
  const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
1305
1306
  const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
1306
1307
  const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
1308
+ if (!supportsStrictTools && tool.strict != null) {
1309
+ toolWarnings.push({
1310
+ type: "unsupported",
1311
+ feature: "strict",
1312
+ details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
1313
+ });
1314
+ }
1307
1315
  anthropicTools2.push({
1308
1316
  name: tool.name,
1309
1317
  description: tool.description,
1310
1318
  input_schema: tool.inputSchema,
1311
1319
  cache_control: cacheControl,
1312
1320
  ...eagerInputStreaming ? { eager_input_streaming: true } : {},
1313
- ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {},
1321
+ ...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
1314
1322
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
1315
1323
  ...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
1316
1324
  ...tool.inputExamples != null ? {
@@ -1526,7 +1534,6 @@ async function prepareTools({
1526
1534
  break;
1527
1535
  }
1528
1536
  case "anthropic.tool_search_regex_20251119": {
1529
- betas.add("advanced-tool-use-2025-11-20");
1530
1537
  anthropicTools2.push({
1531
1538
  type: "tool_search_tool_regex_20251119",
1532
1539
  name: "tool_search_tool_regex"
@@ -1534,7 +1541,6 @@ async function prepareTools({
1534
1541
  break;
1535
1542
  }
1536
1543
  case "anthropic.tool_search_bm25_20251119": {
1537
- betas.add("advanced-tool-use-2025-11-20");
1538
1544
  anthropicTools2.push({
1539
1545
  type: "tool_search_tool_bm25_20251119",
1540
1546
  name: "tool_search_tool_bm25"
@@ -2909,7 +2915,7 @@ var AnthropicMessagesLanguageModel = class {
2909
2915
  providerOptions,
2910
2916
  stream
2911
2917
  }) {
2912
- var _a, _b, _c, _d, _e, _f, _g;
2918
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2913
2919
  const warnings = [];
2914
2920
  if (frequencyPenalty != null) {
2915
2921
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2967,7 +2973,8 @@ var AnthropicMessagesLanguageModel = class {
2967
2973
  isKnownModel
2968
2974
  } = getModelCapabilities(this.modelId);
2969
2975
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2970
- const structureOutputMode = (_b = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b : "auto";
2976
+ const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2977
+ const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
2971
2978
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2972
2979
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
2973
2980
  type: "function",
@@ -3002,14 +3009,14 @@ var AnthropicMessagesLanguageModel = class {
3002
3009
  });
3003
3010
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3004
3011
  prompt,
3005
- sendReasoning: (_c = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c : true,
3012
+ sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
3006
3013
  warnings,
3007
3014
  cacheControlValidator,
3008
3015
  toolNameMapping
3009
3016
  });
3010
- const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
3017
+ const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3011
3018
  const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
3012
- let thinkingBudget = thinkingType === "enabled" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.budgetTokens : void 0;
3019
+ let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3013
3020
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3014
3021
  const baseArgs = {
3015
3022
  // model id:
@@ -3216,7 +3223,7 @@ var AnthropicMessagesLanguageModel = class {
3216
3223
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3217
3224
  betas.add("fast-mode-2026-02-01");
3218
3225
  }
3219
- if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
3226
+ if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3220
3227
  betas.add("fine-grained-tool-streaming-2025-05-14");
3221
3228
  }
3222
3229
  const {
@@ -3230,13 +3237,15 @@ var AnthropicMessagesLanguageModel = class {
3230
3237
  toolChoice: { type: "required" },
3231
3238
  disableParallelToolUse: true,
3232
3239
  cacheControlValidator,
3233
- supportsStructuredOutput: false
3240
+ supportsStructuredOutput: false,
3241
+ supportsStrictTools
3234
3242
  } : {
3235
3243
  tools: tools != null ? tools : [],
3236
3244
  toolChoice,
3237
3245
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3238
3246
  cacheControlValidator,
3239
- supportsStructuredOutput
3247
+ supportsStructuredOutput,
3248
+ supportsStrictTools
3240
3249
  }
3241
3250
  );
3242
3251
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3253,7 +3262,7 @@ var AnthropicMessagesLanguageModel = class {
3253
3262
  ...betas,
3254
3263
  ...toolsBetas,
3255
3264
  ...userSuppliedBetas,
3256
- ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3265
+ ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3257
3266
  ]),
3258
3267
  usesJsonResponseTool: jsonResponseTool != null,
3259
3268
  toolNameMapping,