@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/CHANGELOG.md +12 -0
- package/dist/index.js +28 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +11 -2
- package/dist/internal/index.d.ts +11 -2
- package/dist/internal/index.js +27 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -13
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +45 -4
- package/package.json +1 -1
- package/src/anthropic-messages-language-model.ts +12 -0
- package/src/anthropic-prepare-tools.ts +16 -2
- package/src/convert-to-anthropic-messages-prompt.ts +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -1266,7 +1266,8 @@ async function prepareTools({
|
|
|
1266
1266
|
toolChoice,
|
|
1267
1267
|
disableParallelToolUse,
|
|
1268
1268
|
cacheControlValidator,
|
|
1269
|
-
supportsStructuredOutput
|
|
1269
|
+
supportsStructuredOutput,
|
|
1270
|
+
supportsStrictTools
|
|
1270
1271
|
}) {
|
|
1271
1272
|
var _a;
|
|
1272
1273
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1288,13 +1289,20 @@ async function prepareTools({
|
|
|
1288
1289
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1289
1290
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1290
1291
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1292
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1293
|
+
toolWarnings.push({
|
|
1294
|
+
type: "unsupported",
|
|
1295
|
+
feature: "strict",
|
|
1296
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1291
1299
|
anthropicTools2.push({
|
|
1292
1300
|
name: tool.name,
|
|
1293
1301
|
description: tool.description,
|
|
1294
1302
|
input_schema: tool.inputSchema,
|
|
1295
1303
|
cache_control: cacheControl,
|
|
1296
1304
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1297
|
-
...
|
|
1305
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1298
1306
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1299
1307
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1300
1308
|
...tool.inputExamples != null ? {
|
|
@@ -2608,7 +2616,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2608
2616
|
} catch (e) {
|
|
2609
2617
|
const extractedErrorCode = (_r = output.value) == null ? void 0 : _r.errorCode;
|
|
2610
2618
|
errorValue = {
|
|
2611
|
-
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "
|
|
2619
|
+
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2612
2620
|
};
|
|
2613
2621
|
}
|
|
2614
2622
|
anthropicContent.push({
|
|
@@ -2616,7 +2624,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2616
2624
|
tool_use_id: part.toolCallId,
|
|
2617
2625
|
content: {
|
|
2618
2626
|
type: "web_fetch_tool_result_error",
|
|
2619
|
-
error_code: (_s = errorValue.errorCode) != null ? _s : "
|
|
2627
|
+
error_code: (_s = errorValue.errorCode) != null ? _s : "unavailable"
|
|
2620
2628
|
},
|
|
2621
2629
|
cache_control: cacheControl
|
|
2622
2630
|
});
|
|
@@ -2893,7 +2901,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2893
2901
|
providerOptions,
|
|
2894
2902
|
stream
|
|
2895
2903
|
}) {
|
|
2896
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2904
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2897
2905
|
const warnings = [];
|
|
2898
2906
|
if (frequencyPenalty != null) {
|
|
2899
2907
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2951,7 +2959,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2951
2959
|
isKnownModel
|
|
2952
2960
|
} = getModelCapabilities(this.modelId);
|
|
2953
2961
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2954
|
-
const
|
|
2962
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2963
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2955
2964
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2956
2965
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2957
2966
|
type: "function",
|
|
@@ -2986,14 +2995,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2986
2995
|
});
|
|
2987
2996
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
2988
2997
|
prompt,
|
|
2989
|
-
sendReasoning: (
|
|
2998
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2990
2999
|
warnings,
|
|
2991
3000
|
cacheControlValidator,
|
|
2992
3001
|
toolNameMapping
|
|
2993
3002
|
});
|
|
2994
|
-
const thinkingType = (
|
|
3003
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
2995
3004
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2996
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3005
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
2997
3006
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2998
3007
|
const baseArgs = {
|
|
2999
3008
|
// model id:
|
|
@@ -3200,7 +3209,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3200
3209
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3201
3210
|
betas.add("fast-mode-2026-02-01");
|
|
3202
3211
|
}
|
|
3203
|
-
if (stream && ((
|
|
3212
|
+
if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
|
|
3204
3213
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3205
3214
|
}
|
|
3206
3215
|
const {
|
|
@@ -3214,13 +3223,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3214
3223
|
toolChoice: { type: "required" },
|
|
3215
3224
|
disableParallelToolUse: true,
|
|
3216
3225
|
cacheControlValidator,
|
|
3217
|
-
supportsStructuredOutput: false
|
|
3226
|
+
supportsStructuredOutput: false,
|
|
3227
|
+
supportsStrictTools
|
|
3218
3228
|
} : {
|
|
3219
3229
|
tools: tools != null ? tools : [],
|
|
3220
3230
|
toolChoice,
|
|
3221
3231
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3222
3232
|
cacheControlValidator,
|
|
3223
|
-
supportsStructuredOutput
|
|
3233
|
+
supportsStructuredOutput,
|
|
3234
|
+
supportsStrictTools
|
|
3224
3235
|
}
|
|
3225
3236
|
);
|
|
3226
3237
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3237,7 +3248,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3237
3248
|
...betas,
|
|
3238
3249
|
...toolsBetas,
|
|
3239
3250
|
...userSuppliedBetas,
|
|
3240
|
-
...(
|
|
3251
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
3241
3252
|
]),
|
|
3242
3253
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3243
3254
|
toolNameMapping,
|