@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/CHANGELOG.md +12 -0
- package/dist/index.js +26 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -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 +25 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -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 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 41c6a56: fix(anthropic): skip passing beta header for tool search tools
|
|
8
|
+
|
|
9
|
+
## 3.0.61
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2381567: fix(vertex): throw warning when strict: true for vertexAnthropic
|
|
14
|
+
|
|
3
15
|
## 3.0.60
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -18,21 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
anthropic: () => anthropic,
|
|
25
25
|
createAnthropic: () => createAnthropic,
|
|
26
26
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
30
30
|
// src/anthropic-provider.ts
|
|
31
31
|
var import_provider4 = require("@ai-sdk/provider");
|
|
32
32
|
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "3.0.
|
|
35
|
+
var VERSION = true ? "3.0.62" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -1269,7 +1269,8 @@ async function prepareTools({
|
|
|
1269
1269
|
toolChoice,
|
|
1270
1270
|
disableParallelToolUse,
|
|
1271
1271
|
cacheControlValidator,
|
|
1272
|
-
supportsStructuredOutput
|
|
1272
|
+
supportsStructuredOutput,
|
|
1273
|
+
supportsStrictTools
|
|
1273
1274
|
}) {
|
|
1274
1275
|
var _a;
|
|
1275
1276
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1291,13 +1292,20 @@ async function prepareTools({
|
|
|
1291
1292
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1292
1293
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1293
1294
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1295
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1296
|
+
toolWarnings.push({
|
|
1297
|
+
type: "unsupported",
|
|
1298
|
+
feature: "strict",
|
|
1299
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1294
1302
|
anthropicTools2.push({
|
|
1295
1303
|
name: tool.name,
|
|
1296
1304
|
description: tool.description,
|
|
1297
1305
|
input_schema: tool.inputSchema,
|
|
1298
1306
|
cache_control: cacheControl,
|
|
1299
1307
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1300
|
-
...
|
|
1308
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1301
1309
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1302
1310
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1303
1311
|
...tool.inputExamples != null ? {
|
|
@@ -1513,7 +1521,6 @@ async function prepareTools({
|
|
|
1513
1521
|
break;
|
|
1514
1522
|
}
|
|
1515
1523
|
case "anthropic.tool_search_regex_20251119": {
|
|
1516
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1517
1524
|
anthropicTools2.push({
|
|
1518
1525
|
type: "tool_search_tool_regex_20251119",
|
|
1519
1526
|
name: "tool_search_tool_regex"
|
|
@@ -1521,7 +1528,6 @@ async function prepareTools({
|
|
|
1521
1528
|
break;
|
|
1522
1529
|
}
|
|
1523
1530
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1531
|
anthropicTools2.push({
|
|
1526
1532
|
type: "tool_search_tool_bm25_20251119",
|
|
1527
1533
|
name: "tool_search_tool_bm25"
|
|
@@ -2872,7 +2878,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2872
2878
|
providerOptions,
|
|
2873
2879
|
stream
|
|
2874
2880
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2881
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2876
2882
|
const warnings = [];
|
|
2877
2883
|
if (frequencyPenalty != null) {
|
|
2878
2884
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2930,7 +2936,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2930
2936
|
isKnownModel
|
|
2931
2937
|
} = getModelCapabilities(this.modelId);
|
|
2932
2938
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
|
-
const
|
|
2939
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2940
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2934
2941
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2935
2942
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2936
2943
|
type: "function",
|
|
@@ -2965,14 +2972,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2965
2972
|
});
|
|
2966
2973
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
2967
2974
|
prompt,
|
|
2968
|
-
sendReasoning: (
|
|
2975
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2969
2976
|
warnings,
|
|
2970
2977
|
cacheControlValidator,
|
|
2971
2978
|
toolNameMapping
|
|
2972
2979
|
});
|
|
2973
|
-
const thinkingType = (
|
|
2980
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
2974
2981
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2975
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
2982
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
2976
2983
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2977
2984
|
const baseArgs = {
|
|
2978
2985
|
// model id:
|
|
@@ -3179,7 +3186,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3179
3186
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3180
3187
|
betas.add("fast-mode-2026-02-01");
|
|
3181
3188
|
}
|
|
3182
|
-
if (stream && ((
|
|
3189
|
+
if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
|
|
3183
3190
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3184
3191
|
}
|
|
3185
3192
|
const {
|
|
@@ -3193,13 +3200,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3193
3200
|
toolChoice: { type: "required" },
|
|
3194
3201
|
disableParallelToolUse: true,
|
|
3195
3202
|
cacheControlValidator,
|
|
3196
|
-
supportsStructuredOutput: false
|
|
3203
|
+
supportsStructuredOutput: false,
|
|
3204
|
+
supportsStrictTools
|
|
3197
3205
|
} : {
|
|
3198
3206
|
tools: tools != null ? tools : [],
|
|
3199
3207
|
toolChoice,
|
|
3200
3208
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3201
3209
|
cacheControlValidator,
|
|
3202
|
-
supportsStructuredOutput
|
|
3210
|
+
supportsStructuredOutput,
|
|
3211
|
+
supportsStrictTools
|
|
3203
3212
|
}
|
|
3204
3213
|
);
|
|
3205
3214
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3216,7 +3225,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3216
3225
|
...betas,
|
|
3217
3226
|
...toolsBetas,
|
|
3218
3227
|
...userSuppliedBetas,
|
|
3219
|
-
...(
|
|
3228
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
3220
3229
|
]),
|
|
3221
3230
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3222
3231
|
toolNameMapping,
|