@fairyhunter13/ai-anthropic 3.0.58-fork.3 → 3.0.58-fork.4
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 +87 -4
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +112 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +35 -14
- package/dist/internal/index.d.ts +35 -14
- package/dist/internal/index.js +112 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +114 -17
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +45 -4
- package/package.json +7 -3
- package/src/anthropic-messages-language-model.ts +140 -35
- package/src/anthropic-messages-options.ts +18 -0
- package/src/anthropic-prepare-tools.ts +22 -10
- package/src/anthropic-provider.ts +8 -8
- package/src/convert-anthropic-messages-usage.ts +2 -2
- package/src/convert-to-anthropic-messages-prompt.ts +21 -21
- package/src/get-cache-control.ts +5 -5
- package/src/internal/index.ts +4 -1
- package/src/map-anthropic-stop-reason.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
|
|
8
|
+
- Updated dependencies [3887c70]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
10
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
11
|
+
|
|
12
|
+
## 4.0.0-beta.9
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [776b617]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
19
|
+
|
|
20
|
+
## 4.0.0-beta.8
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [61753c3]
|
|
25
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
26
|
+
|
|
27
|
+
## 4.0.0-beta.7
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [f7d4f01]
|
|
32
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
33
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
34
|
+
|
|
35
|
+
## 4.0.0-beta.6
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 21d1ee3: fix(anthropic): skip passing beta header for tool search tools
|
|
40
|
+
|
|
41
|
+
## 4.0.0-beta.5
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [5c2a5a2]
|
|
46
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
47
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
48
|
+
|
|
49
|
+
## 4.0.0-beta.4
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
|
|
54
|
+
|
|
55
|
+
## 4.0.0-beta.3
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- e748b35: chore: update v3 specs to v4
|
|
60
|
+
|
|
61
|
+
## 4.0.0-beta.2
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- 1fe058b: fix(anthropic): preserve the error code returned by model
|
|
66
|
+
|
|
67
|
+
## 4.0.0-beta.1
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [531251e]
|
|
72
|
+
- @ai-sdk/provider-utils@5.0.0-beta.1
|
|
73
|
+
|
|
74
|
+
## 4.0.0-beta.0
|
|
75
|
+
|
|
76
|
+
### Major Changes
|
|
77
|
+
|
|
78
|
+
- 8359612: Start v7 pre-release
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Updated dependencies [8359612]
|
|
83
|
+
- @ai-sdk/provider@4.0.0-beta.0
|
|
84
|
+
- @ai-sdk/provider-utils@5.0.0-beta.0
|
|
85
|
+
|
|
3
86
|
## 3.0.58
|
|
4
87
|
|
|
5
88
|
### Patch Changes
|
|
@@ -415,13 +498,13 @@
|
|
|
415
498
|
Before
|
|
416
499
|
|
|
417
500
|
```ts
|
|
418
|
-
model.textEmbeddingModel(
|
|
501
|
+
model.textEmbeddingModel("my-model-id");
|
|
419
502
|
```
|
|
420
503
|
|
|
421
504
|
After
|
|
422
505
|
|
|
423
506
|
```ts
|
|
424
|
-
model.embeddingModel(
|
|
507
|
+
model.embeddingModel("my-model-id");
|
|
425
508
|
```
|
|
426
509
|
|
|
427
510
|
- f33a018: chore: add model ID for Haiku 4.5
|
|
@@ -761,13 +844,13 @@
|
|
|
761
844
|
Before
|
|
762
845
|
|
|
763
846
|
```ts
|
|
764
|
-
model.textEmbeddingModel(
|
|
847
|
+
model.textEmbeddingModel("my-model-id");
|
|
765
848
|
```
|
|
766
849
|
|
|
767
850
|
After
|
|
768
851
|
|
|
769
852
|
```ts
|
|
770
|
-
model.embeddingModel(
|
|
853
|
+
model.embeddingModel("my-model-id");
|
|
771
854
|
```
|
|
772
855
|
|
|
773
856
|
- Updated dependencies [8d9e8ad]
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONObject,
|
|
1
|
+
import { JSONObject, ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
@@ -188,6 +188,12 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
188
188
|
}>>;
|
|
189
189
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
190
|
prefill: z.ZodOptional<z.ZodString>;
|
|
191
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
auto: "auto";
|
|
196
|
+
}>>;
|
|
191
197
|
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
192
198
|
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
193
199
|
type: z.ZodLiteral<"clear_tool_uses_20250919">;
|
|
@@ -1016,17 +1022,17 @@ declare const anthropicTools: {
|
|
|
1016
1022
|
}[]>;
|
|
1017
1023
|
};
|
|
1018
1024
|
|
|
1019
|
-
interface AnthropicProvider extends
|
|
1025
|
+
interface AnthropicProvider extends ProviderV4 {
|
|
1020
1026
|
/**
|
|
1021
1027
|
* Creates a model for text generation.
|
|
1022
1028
|
*/
|
|
1023
|
-
(modelId: AnthropicMessagesModelId):
|
|
1029
|
+
(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1024
1030
|
/**
|
|
1025
1031
|
* Creates a model for text generation.
|
|
1026
1032
|
*/
|
|
1027
|
-
languageModel(modelId: AnthropicMessagesModelId):
|
|
1028
|
-
chat(modelId: AnthropicMessagesModelId):
|
|
1029
|
-
messages(modelId: AnthropicMessagesModelId):
|
|
1033
|
+
languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1034
|
+
chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1035
|
+
messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1030
1036
|
/**
|
|
1031
1037
|
* @deprecated Use `embeddingModel` instead.
|
|
1032
1038
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONObject,
|
|
1
|
+
import { JSONObject, ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
@@ -188,6 +188,12 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
188
188
|
}>>;
|
|
189
189
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
190
|
prefill: z.ZodOptional<z.ZodString>;
|
|
191
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
auto: "auto";
|
|
196
|
+
}>>;
|
|
191
197
|
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
192
198
|
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
193
199
|
type: z.ZodLiteral<"clear_tool_uses_20250919">;
|
|
@@ -1016,17 +1022,17 @@ declare const anthropicTools: {
|
|
|
1016
1022
|
}[]>;
|
|
1017
1023
|
};
|
|
1018
1024
|
|
|
1019
|
-
interface AnthropicProvider extends
|
|
1025
|
+
interface AnthropicProvider extends ProviderV4 {
|
|
1020
1026
|
/**
|
|
1021
1027
|
* Creates a model for text generation.
|
|
1022
1028
|
*/
|
|
1023
|
-
(modelId: AnthropicMessagesModelId):
|
|
1029
|
+
(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1024
1030
|
/**
|
|
1025
1031
|
* Creates a model for text generation.
|
|
1026
1032
|
*/
|
|
1027
|
-
languageModel(modelId: AnthropicMessagesModelId):
|
|
1028
|
-
chat(modelId: AnthropicMessagesModelId):
|
|
1029
|
-
messages(modelId: AnthropicMessagesModelId):
|
|
1033
|
+
languageModel(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1034
|
+
chat(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1035
|
+
messages(modelId: AnthropicMessagesModelId): LanguageModelV4;
|
|
1030
1036
|
/**
|
|
1031
1037
|
* @deprecated Use `embeddingModel` instead.
|
|
1032
1038
|
*/
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ 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 ? "
|
|
35
|
+
var VERSION = true ? "4.0.0-beta.10-fork.4" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -942,6 +942,20 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
942
942
|
* Example: Setting prefill to '{"' will make the model start its response with '{"'
|
|
943
943
|
*/
|
|
944
944
|
prefill: import_v43.z.string().optional(),
|
|
945
|
+
/**
|
|
946
|
+
* Request metadata. Use `user_id` to track per-user usage for abuse detection
|
|
947
|
+
* and rate limit apportioning. Should be a UUID or similar opaque identifier.
|
|
948
|
+
* See https://docs.anthropic.com/en/api/messages
|
|
949
|
+
*/
|
|
950
|
+
metadata: import_v43.z.object({
|
|
951
|
+
userId: import_v43.z.string().optional()
|
|
952
|
+
}).optional(),
|
|
953
|
+
/**
|
|
954
|
+
* Service tier selection.
|
|
955
|
+
* - 'auto': Allow Anthropic to pick standard or priority based on availability.
|
|
956
|
+
* See https://docs.anthropic.com/en/api/messages
|
|
957
|
+
*/
|
|
958
|
+
serviceTier: import_v43.z.enum(["auto"]).optional(),
|
|
945
959
|
contextManagement: import_v43.z.object({
|
|
946
960
|
edits: import_v43.z.array(
|
|
947
961
|
import_v43.z.discriminatedUnion("type", [
|
|
@@ -1289,7 +1303,8 @@ async function prepareTools({
|
|
|
1289
1303
|
toolChoice,
|
|
1290
1304
|
disableParallelToolUse,
|
|
1291
1305
|
cacheControlValidator,
|
|
1292
|
-
supportsStructuredOutput
|
|
1306
|
+
supportsStructuredOutput,
|
|
1307
|
+
supportsStrictTools
|
|
1293
1308
|
}) {
|
|
1294
1309
|
var _a;
|
|
1295
1310
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1311,13 +1326,20 @@ async function prepareTools({
|
|
|
1311
1326
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1312
1327
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1313
1328
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1329
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1330
|
+
toolWarnings.push({
|
|
1331
|
+
type: "unsupported",
|
|
1332
|
+
feature: "strict",
|
|
1333
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1314
1336
|
anthropicTools2.push({
|
|
1315
1337
|
name: tool.name,
|
|
1316
1338
|
description: tool.description,
|
|
1317
1339
|
input_schema: tool.inputSchema,
|
|
1318
1340
|
cache_control: cacheControl,
|
|
1319
1341
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1320
|
-
...
|
|
1342
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1321
1343
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1322
1344
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1323
1345
|
...tool.inputExamples != null ? {
|
|
@@ -1533,7 +1555,6 @@ async function prepareTools({
|
|
|
1533
1555
|
break;
|
|
1534
1556
|
}
|
|
1535
1557
|
case "anthropic.tool_search_regex_20251119": {
|
|
1536
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1537
1558
|
anthropicTools2.push({
|
|
1538
1559
|
type: "tool_search_tool_regex_20251119",
|
|
1539
1560
|
name: "tool_search_tool_regex"
|
|
@@ -1541,7 +1562,6 @@ async function prepareTools({
|
|
|
1541
1562
|
break;
|
|
1542
1563
|
}
|
|
1543
1564
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1544
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1545
1565
|
anthropicTools2.push({
|
|
1546
1566
|
type: "tool_search_tool_bm25_20251119",
|
|
1547
1567
|
name: "tool_search_tool_bm25"
|
|
@@ -2628,7 +2648,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2628
2648
|
} catch (e) {
|
|
2629
2649
|
const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
|
|
2630
2650
|
errorValue = {
|
|
2631
|
-
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "
|
|
2651
|
+
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2632
2652
|
};
|
|
2633
2653
|
}
|
|
2634
2654
|
anthropicContent.push({
|
|
@@ -2636,7 +2656,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2636
2656
|
tool_use_id: part.toolCallId,
|
|
2637
2657
|
content: {
|
|
2638
2658
|
type: "web_fetch_tool_result_error",
|
|
2639
|
-
error_code: (_t = errorValue.errorCode) != null ? _t : "
|
|
2659
|
+
error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
|
|
2640
2660
|
},
|
|
2641
2661
|
cache_control: cacheControl
|
|
2642
2662
|
});
|
|
@@ -2871,7 +2891,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2871
2891
|
}
|
|
2872
2892
|
var AnthropicMessagesLanguageModel = class {
|
|
2873
2893
|
constructor(modelId, config) {
|
|
2874
|
-
this.specificationVersion = "
|
|
2894
|
+
this.specificationVersion = "v4";
|
|
2875
2895
|
var _a;
|
|
2876
2896
|
this.modelId = modelId;
|
|
2877
2897
|
this.config = config;
|
|
@@ -2910,10 +2930,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2910
2930
|
seed,
|
|
2911
2931
|
tools,
|
|
2912
2932
|
toolChoice,
|
|
2933
|
+
reasoning,
|
|
2913
2934
|
providerOptions,
|
|
2914
2935
|
stream
|
|
2915
2936
|
}) {
|
|
2916
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2937
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2917
2938
|
const warnings = [];
|
|
2918
2939
|
if (frequencyPenalty != null) {
|
|
2919
2940
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2968,10 +2989,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2968
2989
|
const {
|
|
2969
2990
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2970
2991
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
2992
|
+
supportsAdaptiveThinking,
|
|
2971
2993
|
isKnownModel
|
|
2972
2994
|
} = getModelCapabilities(this.modelId);
|
|
2973
2995
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2974
|
-
const
|
|
2996
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2997
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2975
2998
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2976
2999
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2977
3000
|
type: "function",
|
|
@@ -3006,11 +3029,25 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3006
3029
|
});
|
|
3007
3030
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
3008
3031
|
prompt,
|
|
3009
|
-
sendReasoning: (
|
|
3032
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3010
3033
|
warnings,
|
|
3011
3034
|
cacheControlValidator,
|
|
3012
3035
|
toolNameMapping
|
|
3013
3036
|
});
|
|
3037
|
+
if ((0, import_provider_utils15.isCustomReasoning)(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3038
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3039
|
+
reasoning,
|
|
3040
|
+
supportsAdaptiveThinking,
|
|
3041
|
+
maxOutputTokensForModel,
|
|
3042
|
+
warnings
|
|
3043
|
+
});
|
|
3044
|
+
if (reasoningConfig != null) {
|
|
3045
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3046
|
+
if (reasoningConfig.effort != null) {
|
|
3047
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3014
3051
|
if (anthropicOptions == null ? void 0 : anthropicOptions.prefill) {
|
|
3015
3052
|
const lastMessage = messagesPrompt.messages[messagesPrompt.messages.length - 1];
|
|
3016
3053
|
if ((lastMessage == null ? void 0 : lastMessage.role) === "assistant") {
|
|
@@ -3032,9 +3069,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3032
3069
|
});
|
|
3033
3070
|
}
|
|
3034
3071
|
}
|
|
3035
|
-
const thinkingType = (
|
|
3072
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3036
3073
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3037
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3074
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
3038
3075
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3039
3076
|
const baseArgs = {
|
|
3040
3077
|
// model id:
|
|
@@ -3050,7 +3087,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3050
3087
|
thinking: {
|
|
3051
3088
|
type: thinkingType,
|
|
3052
3089
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3053
|
-
...((
|
|
3090
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type) !== "disabled" && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display) && {
|
|
3054
3091
|
display: anthropicOptions.thinking.display
|
|
3055
3092
|
}
|
|
3056
3093
|
}
|
|
@@ -3071,6 +3108,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3071
3108
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3072
3109
|
speed: anthropicOptions.speed
|
|
3073
3110
|
},
|
|
3111
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.metadata) && {
|
|
3112
|
+
metadata: {
|
|
3113
|
+
...anthropicOptions.metadata.userId && {
|
|
3114
|
+
user_id: anthropicOptions.metadata.userId
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
},
|
|
3118
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.serviceTier) && {
|
|
3119
|
+
service_tier: anthropicOptions.serviceTier
|
|
3120
|
+
},
|
|
3074
3121
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3075
3122
|
cache_control: anthropicOptions.cacheControl
|
|
3076
3123
|
},
|
|
@@ -3244,7 +3291,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3244
3291
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3245
3292
|
betas.add("fast-mode-2026-02-01");
|
|
3246
3293
|
}
|
|
3247
|
-
if (stream && ((
|
|
3294
|
+
if (stream && ((_i = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _i : true)) {
|
|
3248
3295
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3249
3296
|
}
|
|
3250
3297
|
const {
|
|
@@ -3258,13 +3305,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3258
3305
|
toolChoice: { type: "required" },
|
|
3259
3306
|
disableParallelToolUse: true,
|
|
3260
3307
|
cacheControlValidator,
|
|
3261
|
-
supportsStructuredOutput: false
|
|
3308
|
+
supportsStructuredOutput: false,
|
|
3309
|
+
supportsStrictTools
|
|
3262
3310
|
} : {
|
|
3263
3311
|
tools: tools != null ? tools : [],
|
|
3264
3312
|
toolChoice,
|
|
3265
3313
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3266
3314
|
cacheControlValidator,
|
|
3267
|
-
supportsStructuredOutput
|
|
3315
|
+
supportsStructuredOutput,
|
|
3316
|
+
supportsStrictTools
|
|
3268
3317
|
}
|
|
3269
3318
|
);
|
|
3270
3319
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3281,7 +3330,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3281
3330
|
...betas,
|
|
3282
3331
|
...toolsBetas,
|
|
3283
3332
|
...userSuppliedBetas,
|
|
3284
|
-
...(
|
|
3333
|
+
...(_j = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _j : []
|
|
3285
3334
|
]),
|
|
3286
3335
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3287
3336
|
toolNameMapping,
|
|
@@ -4544,42 +4593,49 @@ function getModelCapabilities(modelId) {
|
|
|
4544
4593
|
return {
|
|
4545
4594
|
maxOutputTokens: 128e3,
|
|
4546
4595
|
supportsStructuredOutput: true,
|
|
4596
|
+
supportsAdaptiveThinking: true,
|
|
4547
4597
|
isKnownModel: true
|
|
4548
4598
|
};
|
|
4549
4599
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4550
4600
|
return {
|
|
4551
4601
|
maxOutputTokens: 64e3,
|
|
4552
4602
|
supportsStructuredOutput: true,
|
|
4603
|
+
supportsAdaptiveThinking: false,
|
|
4553
4604
|
isKnownModel: true
|
|
4554
4605
|
};
|
|
4555
4606
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4556
4607
|
return {
|
|
4557
4608
|
maxOutputTokens: 32e3,
|
|
4558
4609
|
supportsStructuredOutput: true,
|
|
4610
|
+
supportsAdaptiveThinking: false,
|
|
4559
4611
|
isKnownModel: true
|
|
4560
4612
|
};
|
|
4561
4613
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4562
4614
|
return {
|
|
4563
4615
|
maxOutputTokens: 64e3,
|
|
4564
4616
|
supportsStructuredOutput: false,
|
|
4617
|
+
supportsAdaptiveThinking: false,
|
|
4565
4618
|
isKnownModel: true
|
|
4566
4619
|
};
|
|
4567
4620
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4568
4621
|
return {
|
|
4569
4622
|
maxOutputTokens: 32e3,
|
|
4570
4623
|
supportsStructuredOutput: false,
|
|
4624
|
+
supportsAdaptiveThinking: false,
|
|
4571
4625
|
isKnownModel: true
|
|
4572
4626
|
};
|
|
4573
4627
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4574
4628
|
return {
|
|
4575
4629
|
maxOutputTokens: 4096,
|
|
4576
4630
|
supportsStructuredOutput: false,
|
|
4631
|
+
supportsAdaptiveThinking: false,
|
|
4577
4632
|
isKnownModel: true
|
|
4578
4633
|
};
|
|
4579
4634
|
} else {
|
|
4580
4635
|
return {
|
|
4581
4636
|
maxOutputTokens: 4096,
|
|
4582
4637
|
supportsStructuredOutput: false,
|
|
4638
|
+
supportsAdaptiveThinking: false,
|
|
4583
4639
|
isKnownModel: false
|
|
4584
4640
|
};
|
|
4585
4641
|
}
|
|
@@ -4602,6 +4658,43 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4602
4658
|
}
|
|
4603
4659
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4604
4660
|
}
|
|
4661
|
+
function resolveAnthropicReasoningConfig({
|
|
4662
|
+
reasoning,
|
|
4663
|
+
supportsAdaptiveThinking,
|
|
4664
|
+
maxOutputTokensForModel,
|
|
4665
|
+
warnings
|
|
4666
|
+
}) {
|
|
4667
|
+
if (!(0, import_provider_utils15.isCustomReasoning)(reasoning)) {
|
|
4668
|
+
return void 0;
|
|
4669
|
+
}
|
|
4670
|
+
if (reasoning === "none") {
|
|
4671
|
+
return { thinking: { type: "disabled" } };
|
|
4672
|
+
}
|
|
4673
|
+
if (supportsAdaptiveThinking) {
|
|
4674
|
+
const effort = (0, import_provider_utils15.mapReasoningToProviderEffort)({
|
|
4675
|
+
reasoning,
|
|
4676
|
+
effortMap: {
|
|
4677
|
+
minimal: "low",
|
|
4678
|
+
low: "low",
|
|
4679
|
+
medium: "medium",
|
|
4680
|
+
high: "high",
|
|
4681
|
+
xhigh: "max"
|
|
4682
|
+
},
|
|
4683
|
+
warnings
|
|
4684
|
+
});
|
|
4685
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4686
|
+
}
|
|
4687
|
+
const budgetTokens = (0, import_provider_utils15.mapReasoningToProviderBudget)({
|
|
4688
|
+
reasoning,
|
|
4689
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4690
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4691
|
+
warnings
|
|
4692
|
+
});
|
|
4693
|
+
if (budgetTokens == null) {
|
|
4694
|
+
return void 0;
|
|
4695
|
+
}
|
|
4696
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4697
|
+
}
|
|
4605
4698
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4606
4699
|
return contextManagement ? {
|
|
4607
4700
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -5177,7 +5270,7 @@ function createAnthropic(options = {}) {
|
|
|
5177
5270
|
}
|
|
5178
5271
|
return createChatModel(modelId);
|
|
5179
5272
|
};
|
|
5180
|
-
provider.specificationVersion = "
|
|
5273
|
+
provider.specificationVersion = "v4";
|
|
5181
5274
|
provider.languageModel = createChatModel;
|
|
5182
5275
|
provider.chat = createChatModel;
|
|
5183
5276
|
provider.messages = createChatModel;
|