@ai-sdk/anthropic 3.0.59 → 3.0.61

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.59" : "0.0.0-test";
15
+ var VERSION = true ? "3.0.61" : "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 ? {
@@ -2624,7 +2632,7 @@ async function convertToAnthropicMessagesPrompt({
2624
2632
  } catch (e) {
2625
2633
  const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
2626
2634
  errorValue = {
2627
- errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unknown"
2635
+ errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
2628
2636
  };
2629
2637
  }
2630
2638
  anthropicContent.push({
@@ -2632,7 +2640,7 @@ async function convertToAnthropicMessagesPrompt({
2632
2640
  tool_use_id: part.toolCallId,
2633
2641
  content: {
2634
2642
  type: "web_fetch_tool_result_error",
2635
- error_code: (_s = errorValue.errorCode) != null ? _s : "unknown"
2643
+ error_code: (_s = errorValue.errorCode) != null ? _s : "unavailable"
2636
2644
  },
2637
2645
  cache_control: cacheControl
2638
2646
  });
@@ -2909,7 +2917,7 @@ var AnthropicMessagesLanguageModel = class {
2909
2917
  providerOptions,
2910
2918
  stream
2911
2919
  }) {
2912
- var _a, _b, _c, _d, _e, _f, _g;
2920
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2913
2921
  const warnings = [];
2914
2922
  if (frequencyPenalty != null) {
2915
2923
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -2967,7 +2975,8 @@ var AnthropicMessagesLanguageModel = class {
2967
2975
  isKnownModel
2968
2976
  } = getModelCapabilities(this.modelId);
2969
2977
  const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
2970
- const structureOutputMode = (_b = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b : "auto";
2978
+ const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
2979
+ const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
2971
2980
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
2972
2981
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
2973
2982
  type: "function",
@@ -3002,14 +3011,14 @@ var AnthropicMessagesLanguageModel = class {
3002
3011
  });
3003
3012
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
3004
3013
  prompt,
3005
- sendReasoning: (_c = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c : true,
3014
+ sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
3006
3015
  warnings,
3007
3016
  cacheControlValidator,
3008
3017
  toolNameMapping
3009
3018
  });
3010
- const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
3019
+ const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
3011
3020
  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;
3021
+ let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
3013
3022
  const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
3014
3023
  const baseArgs = {
3015
3024
  // model id:
@@ -3216,7 +3225,7 @@ var AnthropicMessagesLanguageModel = class {
3216
3225
  if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
3217
3226
  betas.add("fast-mode-2026-02-01");
3218
3227
  }
3219
- if (stream && ((_f = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _f : true)) {
3228
+ if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
3220
3229
  betas.add("fine-grained-tool-streaming-2025-05-14");
3221
3230
  }
3222
3231
  const {
@@ -3230,13 +3239,15 @@ var AnthropicMessagesLanguageModel = class {
3230
3239
  toolChoice: { type: "required" },
3231
3240
  disableParallelToolUse: true,
3232
3241
  cacheControlValidator,
3233
- supportsStructuredOutput: false
3242
+ supportsStructuredOutput: false,
3243
+ supportsStrictTools
3234
3244
  } : {
3235
3245
  tools: tools != null ? tools : [],
3236
3246
  toolChoice,
3237
3247
  disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
3238
3248
  cacheControlValidator,
3239
- supportsStructuredOutput
3249
+ supportsStructuredOutput,
3250
+ supportsStrictTools
3240
3251
  }
3241
3252
  );
3242
3253
  const cacheWarnings = cacheControlValidator.getWarnings();
@@ -3253,7 +3264,7 @@ var AnthropicMessagesLanguageModel = class {
3253
3264
  ...betas,
3254
3265
  ...toolsBetas,
3255
3266
  ...userSuppliedBetas,
3256
- ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
3267
+ ...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
3257
3268
  ]),
3258
3269
  usesJsonResponseTool: jsonResponseTool != null,
3259
3270
  toolNameMapping,