@ai-sdk/anthropic 3.0.133 → 3.0.134
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 +6 -0
- package/dist/index.js +42 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -23
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +175 -139
- package/dist/internal/index.d.ts +175 -139
- package/dist/internal/index.js +41 -22
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +41 -22
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +8 -0
- package/src/anthropic-messages-language-model.ts +31 -8
- package/src/convert-to-anthropic-messages-prompt.ts +22 -0
- package/src/get-cache-control.ts +15 -3
|
@@ -1,15 +1,189 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSONSchema7, SharedV3ProviderMetadata, SharedV3Warning, LanguageModelV3FilePart, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-haiku-5-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
|
|
6
6
|
|
|
7
|
+
type AnthropicCacheControl = {
|
|
8
|
+
type: 'ephemeral';
|
|
9
|
+
ttl?: '5m' | '1h';
|
|
10
|
+
};
|
|
11
|
+
type AnthropicContentSource = {
|
|
12
|
+
type: 'base64';
|
|
13
|
+
media_type: string;
|
|
14
|
+
data: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'url';
|
|
17
|
+
url: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'text';
|
|
20
|
+
media_type: 'text/plain';
|
|
21
|
+
data: string;
|
|
22
|
+
};
|
|
23
|
+
interface AnthropicImageContent {
|
|
24
|
+
type: 'image';
|
|
25
|
+
source: AnthropicContentSource;
|
|
26
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Video blocks supplied by compatible providers through custom media conversion. */
|
|
29
|
+
interface AnthropicVideoContent {
|
|
30
|
+
type: 'video';
|
|
31
|
+
source: AnthropicContentSource;
|
|
32
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
33
|
+
}
|
|
34
|
+
type AnthropicTool = {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string | undefined;
|
|
37
|
+
input_schema: JSONSchema7;
|
|
38
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
39
|
+
eager_input_streaming?: boolean;
|
|
40
|
+
strict?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* When true, this tool is deferred and will only be loaded when
|
|
43
|
+
* discovered via the tool search tool.
|
|
44
|
+
*/
|
|
45
|
+
defer_loading?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Programmatic tool calling: specifies which server-executed tools
|
|
48
|
+
* are allowed to call this tool. When set, only the specified callers
|
|
49
|
+
* can invoke this tool programmatically.
|
|
50
|
+
*
|
|
51
|
+
* @example ['code_execution_20250825']
|
|
52
|
+
*/
|
|
53
|
+
allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'code_execution_20250522';
|
|
56
|
+
name: string;
|
|
57
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'code_execution_20250825';
|
|
60
|
+
name: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'code_execution_20260120';
|
|
63
|
+
name: string;
|
|
64
|
+
} | {
|
|
65
|
+
name: string;
|
|
66
|
+
type: 'computer_20250124' | 'computer_20241022';
|
|
67
|
+
display_width_px: number;
|
|
68
|
+
display_height_px: number;
|
|
69
|
+
display_number: number;
|
|
70
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
name: string;
|
|
73
|
+
type: 'computer_20251124';
|
|
74
|
+
display_width_px: number;
|
|
75
|
+
display_height_px: number;
|
|
76
|
+
display_number: number;
|
|
77
|
+
enable_zoom?: boolean;
|
|
78
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
79
|
+
} | {
|
|
80
|
+
/**
|
|
81
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
82
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
83
|
+
*/
|
|
84
|
+
type: 'computer_toolset_20260801';
|
|
85
|
+
configs?: Record<string, {
|
|
86
|
+
enabled?: boolean;
|
|
87
|
+
defer_loading?: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
93
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
name: string;
|
|
96
|
+
type: 'text_editor_20250728';
|
|
97
|
+
max_characters?: number;
|
|
98
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
99
|
+
} | {
|
|
100
|
+
name: string;
|
|
101
|
+
type: 'bash_20250124' | 'bash_20241022';
|
|
102
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
103
|
+
} | {
|
|
104
|
+
name: string;
|
|
105
|
+
type: 'memory_20250818';
|
|
106
|
+
} | {
|
|
107
|
+
type: 'web_fetch_20250910' | 'web_fetch_20260209';
|
|
108
|
+
name: string;
|
|
109
|
+
max_uses?: number;
|
|
110
|
+
allowed_domains?: string[];
|
|
111
|
+
blocked_domains?: string[];
|
|
112
|
+
citations?: {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
};
|
|
115
|
+
max_content_tokens?: number;
|
|
116
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
type: 'web_search_20250305' | 'web_search_20260209';
|
|
119
|
+
name: string;
|
|
120
|
+
max_uses?: number;
|
|
121
|
+
allowed_domains?: string[];
|
|
122
|
+
blocked_domains?: string[];
|
|
123
|
+
user_location?: {
|
|
124
|
+
type: 'approximate';
|
|
125
|
+
city?: string;
|
|
126
|
+
region?: string;
|
|
127
|
+
country?: string;
|
|
128
|
+
timezone?: string;
|
|
129
|
+
};
|
|
130
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'tool_search_tool_regex_20251119';
|
|
133
|
+
name: string;
|
|
134
|
+
} | {
|
|
135
|
+
type: 'tool_search_tool_bm25_20251119';
|
|
136
|
+
name: string;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'advisor_20260301';
|
|
139
|
+
name: 'advisor';
|
|
140
|
+
model: string;
|
|
141
|
+
max_uses?: number;
|
|
142
|
+
caching?: {
|
|
143
|
+
type: 'ephemeral';
|
|
144
|
+
ttl: '5m' | '1h';
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
type AnthropicToolChoice = {
|
|
148
|
+
type: 'auto' | 'any';
|
|
149
|
+
disable_parallel_tool_use?: boolean;
|
|
150
|
+
} | {
|
|
151
|
+
type: 'none';
|
|
152
|
+
} | {
|
|
153
|
+
type: 'tool';
|
|
154
|
+
name: string;
|
|
155
|
+
disable_parallel_tool_use?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
declare class CacheControlValidator {
|
|
159
|
+
private readonly providerOptionsName;
|
|
160
|
+
private breakpointCount;
|
|
161
|
+
private warnings;
|
|
162
|
+
constructor(providerOptionsName?: string);
|
|
163
|
+
getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
|
|
164
|
+
type: string;
|
|
165
|
+
canCache: boolean;
|
|
166
|
+
}): AnthropicCacheControl | undefined;
|
|
167
|
+
getWarnings(): SharedV3Warning[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Return undefined to use the default file conversion. */
|
|
171
|
+
type AnthropicMediaPartConverter = (part: LanguageModelV3FilePart) => PromiseLike<Omit<AnthropicImageContent | AnthropicVideoContent, 'cache_control'> | undefined>;
|
|
172
|
+
|
|
7
173
|
type AnthropicMessagesConfig = {
|
|
8
174
|
provider: string;
|
|
9
175
|
baseURL: string;
|
|
10
176
|
headers: Resolvable<Record<string, string | undefined>>;
|
|
11
177
|
fetch?: FetchFunction;
|
|
12
178
|
buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
|
|
179
|
+
/** Custom media conversion for compatible providers. */
|
|
180
|
+
convertMediaPart?: AnthropicMediaPartConverter;
|
|
181
|
+
/** Maximum temperature for compatible providers. Defaults to 1. */
|
|
182
|
+
maxTemperature?: number;
|
|
183
|
+
/** Preserve temperature and topP with thinking for compatible providers. */
|
|
184
|
+
supportsTemperatureAndTopPWithThinking?: boolean;
|
|
185
|
+
/** Cache option namespace for compatible providers. Defaults to anthropic. */
|
|
186
|
+
cacheControlProviderOptionsName?: string;
|
|
13
187
|
transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
|
|
14
188
|
supportedUrls?: () => LanguageModelV3['supportedUrls'];
|
|
15
189
|
generateId?: () => string;
|
|
@@ -962,144 +1136,6 @@ declare const anthropicTools: {
|
|
|
962
1136
|
}[]>;
|
|
963
1137
|
};
|
|
964
1138
|
|
|
965
|
-
type AnthropicCacheControl = {
|
|
966
|
-
type: 'ephemeral';
|
|
967
|
-
ttl?: '5m' | '1h';
|
|
968
|
-
};
|
|
969
|
-
type AnthropicTool = {
|
|
970
|
-
name: string;
|
|
971
|
-
description: string | undefined;
|
|
972
|
-
input_schema: JSONSchema7;
|
|
973
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
974
|
-
eager_input_streaming?: boolean;
|
|
975
|
-
strict?: boolean;
|
|
976
|
-
/**
|
|
977
|
-
* When true, this tool is deferred and will only be loaded when
|
|
978
|
-
* discovered via the tool search tool.
|
|
979
|
-
*/
|
|
980
|
-
defer_loading?: boolean;
|
|
981
|
-
/**
|
|
982
|
-
* Programmatic tool calling: specifies which server-executed tools
|
|
983
|
-
* are allowed to call this tool. When set, only the specified callers
|
|
984
|
-
* can invoke this tool programmatically.
|
|
985
|
-
*
|
|
986
|
-
* @example ['code_execution_20250825']
|
|
987
|
-
*/
|
|
988
|
-
allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
989
|
-
} | {
|
|
990
|
-
type: 'code_execution_20250522';
|
|
991
|
-
name: string;
|
|
992
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
993
|
-
} | {
|
|
994
|
-
type: 'code_execution_20250825';
|
|
995
|
-
name: string;
|
|
996
|
-
} | {
|
|
997
|
-
type: 'code_execution_20260120';
|
|
998
|
-
name: string;
|
|
999
|
-
} | {
|
|
1000
|
-
name: string;
|
|
1001
|
-
type: 'computer_20250124' | 'computer_20241022';
|
|
1002
|
-
display_width_px: number;
|
|
1003
|
-
display_height_px: number;
|
|
1004
|
-
display_number: number;
|
|
1005
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1006
|
-
} | {
|
|
1007
|
-
name: string;
|
|
1008
|
-
type: 'computer_20251124';
|
|
1009
|
-
display_width_px: number;
|
|
1010
|
-
display_height_px: number;
|
|
1011
|
-
display_number: number;
|
|
1012
|
-
enable_zoom?: boolean;
|
|
1013
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1014
|
-
} | {
|
|
1015
|
-
/**
|
|
1016
|
-
* Computer toolset. Declared without a `name`; the API returns member
|
|
1017
|
-
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
1018
|
-
*/
|
|
1019
|
-
type: 'computer_toolset_20260801';
|
|
1020
|
-
configs?: Record<string, {
|
|
1021
|
-
enabled?: boolean;
|
|
1022
|
-
defer_loading?: boolean;
|
|
1023
|
-
}>;
|
|
1024
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1025
|
-
} | {
|
|
1026
|
-
name: string;
|
|
1027
|
-
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
1028
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1029
|
-
} | {
|
|
1030
|
-
name: string;
|
|
1031
|
-
type: 'text_editor_20250728';
|
|
1032
|
-
max_characters?: number;
|
|
1033
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1034
|
-
} | {
|
|
1035
|
-
name: string;
|
|
1036
|
-
type: 'bash_20250124' | 'bash_20241022';
|
|
1037
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1038
|
-
} | {
|
|
1039
|
-
name: string;
|
|
1040
|
-
type: 'memory_20250818';
|
|
1041
|
-
} | {
|
|
1042
|
-
type: 'web_fetch_20250910' | 'web_fetch_20260209';
|
|
1043
|
-
name: string;
|
|
1044
|
-
max_uses?: number;
|
|
1045
|
-
allowed_domains?: string[];
|
|
1046
|
-
blocked_domains?: string[];
|
|
1047
|
-
citations?: {
|
|
1048
|
-
enabled: boolean;
|
|
1049
|
-
};
|
|
1050
|
-
max_content_tokens?: number;
|
|
1051
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1052
|
-
} | {
|
|
1053
|
-
type: 'web_search_20250305' | 'web_search_20260209';
|
|
1054
|
-
name: string;
|
|
1055
|
-
max_uses?: number;
|
|
1056
|
-
allowed_domains?: string[];
|
|
1057
|
-
blocked_domains?: string[];
|
|
1058
|
-
user_location?: {
|
|
1059
|
-
type: 'approximate';
|
|
1060
|
-
city?: string;
|
|
1061
|
-
region?: string;
|
|
1062
|
-
country?: string;
|
|
1063
|
-
timezone?: string;
|
|
1064
|
-
};
|
|
1065
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1066
|
-
} | {
|
|
1067
|
-
type: 'tool_search_tool_regex_20251119';
|
|
1068
|
-
name: string;
|
|
1069
|
-
} | {
|
|
1070
|
-
type: 'tool_search_tool_bm25_20251119';
|
|
1071
|
-
name: string;
|
|
1072
|
-
} | {
|
|
1073
|
-
type: 'advisor_20260301';
|
|
1074
|
-
name: 'advisor';
|
|
1075
|
-
model: string;
|
|
1076
|
-
max_uses?: number;
|
|
1077
|
-
caching?: {
|
|
1078
|
-
type: 'ephemeral';
|
|
1079
|
-
ttl: '5m' | '1h';
|
|
1080
|
-
};
|
|
1081
|
-
};
|
|
1082
|
-
type AnthropicToolChoice = {
|
|
1083
|
-
type: 'auto' | 'any';
|
|
1084
|
-
disable_parallel_tool_use?: boolean;
|
|
1085
|
-
} | {
|
|
1086
|
-
type: 'none';
|
|
1087
|
-
} | {
|
|
1088
|
-
type: 'tool';
|
|
1089
|
-
name: string;
|
|
1090
|
-
disable_parallel_tool_use?: boolean;
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
declare class CacheControlValidator {
|
|
1094
|
-
private breakpointCount;
|
|
1095
|
-
private warnings;
|
|
1096
|
-
getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
|
|
1097
|
-
type: string;
|
|
1098
|
-
canCache: boolean;
|
|
1099
|
-
}): AnthropicCacheControl | undefined;
|
|
1100
|
-
getWarnings(): SharedV3Warning[];
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
1139
|
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, rejectsForcedToolUse, }: {
|
|
1104
1140
|
tools: LanguageModelV3CallOptions['tools'];
|
|
1105
1141
|
toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,15 +1,189 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSONSchema7, SharedV3ProviderMetadata, SharedV3Warning, LanguageModelV3FilePart, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AnthropicMessagesModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-haiku-5-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-opus-5-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | 'claude-sonnet-5-5' | (string & {});
|
|
6
6
|
|
|
7
|
+
type AnthropicCacheControl = {
|
|
8
|
+
type: 'ephemeral';
|
|
9
|
+
ttl?: '5m' | '1h';
|
|
10
|
+
};
|
|
11
|
+
type AnthropicContentSource = {
|
|
12
|
+
type: 'base64';
|
|
13
|
+
media_type: string;
|
|
14
|
+
data: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'url';
|
|
17
|
+
url: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'text';
|
|
20
|
+
media_type: 'text/plain';
|
|
21
|
+
data: string;
|
|
22
|
+
};
|
|
23
|
+
interface AnthropicImageContent {
|
|
24
|
+
type: 'image';
|
|
25
|
+
source: AnthropicContentSource;
|
|
26
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Video blocks supplied by compatible providers through custom media conversion. */
|
|
29
|
+
interface AnthropicVideoContent {
|
|
30
|
+
type: 'video';
|
|
31
|
+
source: AnthropicContentSource;
|
|
32
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
33
|
+
}
|
|
34
|
+
type AnthropicTool = {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string | undefined;
|
|
37
|
+
input_schema: JSONSchema7;
|
|
38
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
39
|
+
eager_input_streaming?: boolean;
|
|
40
|
+
strict?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* When true, this tool is deferred and will only be loaded when
|
|
43
|
+
* discovered via the tool search tool.
|
|
44
|
+
*/
|
|
45
|
+
defer_loading?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Programmatic tool calling: specifies which server-executed tools
|
|
48
|
+
* are allowed to call this tool. When set, only the specified callers
|
|
49
|
+
* can invoke this tool programmatically.
|
|
50
|
+
*
|
|
51
|
+
* @example ['code_execution_20250825']
|
|
52
|
+
*/
|
|
53
|
+
allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'code_execution_20250522';
|
|
56
|
+
name: string;
|
|
57
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'code_execution_20250825';
|
|
60
|
+
name: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'code_execution_20260120';
|
|
63
|
+
name: string;
|
|
64
|
+
} | {
|
|
65
|
+
name: string;
|
|
66
|
+
type: 'computer_20250124' | 'computer_20241022';
|
|
67
|
+
display_width_px: number;
|
|
68
|
+
display_height_px: number;
|
|
69
|
+
display_number: number;
|
|
70
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
name: string;
|
|
73
|
+
type: 'computer_20251124';
|
|
74
|
+
display_width_px: number;
|
|
75
|
+
display_height_px: number;
|
|
76
|
+
display_number: number;
|
|
77
|
+
enable_zoom?: boolean;
|
|
78
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
79
|
+
} | {
|
|
80
|
+
/**
|
|
81
|
+
* Computer toolset. Declared without a `name`; the API returns member
|
|
82
|
+
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
83
|
+
*/
|
|
84
|
+
type: 'computer_toolset_20260801';
|
|
85
|
+
configs?: Record<string, {
|
|
86
|
+
enabled?: boolean;
|
|
87
|
+
defer_loading?: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
93
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
name: string;
|
|
96
|
+
type: 'text_editor_20250728';
|
|
97
|
+
max_characters?: number;
|
|
98
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
99
|
+
} | {
|
|
100
|
+
name: string;
|
|
101
|
+
type: 'bash_20250124' | 'bash_20241022';
|
|
102
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
103
|
+
} | {
|
|
104
|
+
name: string;
|
|
105
|
+
type: 'memory_20250818';
|
|
106
|
+
} | {
|
|
107
|
+
type: 'web_fetch_20250910' | 'web_fetch_20260209';
|
|
108
|
+
name: string;
|
|
109
|
+
max_uses?: number;
|
|
110
|
+
allowed_domains?: string[];
|
|
111
|
+
blocked_domains?: string[];
|
|
112
|
+
citations?: {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
};
|
|
115
|
+
max_content_tokens?: number;
|
|
116
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
type: 'web_search_20250305' | 'web_search_20260209';
|
|
119
|
+
name: string;
|
|
120
|
+
max_uses?: number;
|
|
121
|
+
allowed_domains?: string[];
|
|
122
|
+
blocked_domains?: string[];
|
|
123
|
+
user_location?: {
|
|
124
|
+
type: 'approximate';
|
|
125
|
+
city?: string;
|
|
126
|
+
region?: string;
|
|
127
|
+
country?: string;
|
|
128
|
+
timezone?: string;
|
|
129
|
+
};
|
|
130
|
+
cache_control: AnthropicCacheControl | undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'tool_search_tool_regex_20251119';
|
|
133
|
+
name: string;
|
|
134
|
+
} | {
|
|
135
|
+
type: 'tool_search_tool_bm25_20251119';
|
|
136
|
+
name: string;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'advisor_20260301';
|
|
139
|
+
name: 'advisor';
|
|
140
|
+
model: string;
|
|
141
|
+
max_uses?: number;
|
|
142
|
+
caching?: {
|
|
143
|
+
type: 'ephemeral';
|
|
144
|
+
ttl: '5m' | '1h';
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
type AnthropicToolChoice = {
|
|
148
|
+
type: 'auto' | 'any';
|
|
149
|
+
disable_parallel_tool_use?: boolean;
|
|
150
|
+
} | {
|
|
151
|
+
type: 'none';
|
|
152
|
+
} | {
|
|
153
|
+
type: 'tool';
|
|
154
|
+
name: string;
|
|
155
|
+
disable_parallel_tool_use?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
declare class CacheControlValidator {
|
|
159
|
+
private readonly providerOptionsName;
|
|
160
|
+
private breakpointCount;
|
|
161
|
+
private warnings;
|
|
162
|
+
constructor(providerOptionsName?: string);
|
|
163
|
+
getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
|
|
164
|
+
type: string;
|
|
165
|
+
canCache: boolean;
|
|
166
|
+
}): AnthropicCacheControl | undefined;
|
|
167
|
+
getWarnings(): SharedV3Warning[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Return undefined to use the default file conversion. */
|
|
171
|
+
type AnthropicMediaPartConverter = (part: LanguageModelV3FilePart) => PromiseLike<Omit<AnthropicImageContent | AnthropicVideoContent, 'cache_control'> | undefined>;
|
|
172
|
+
|
|
7
173
|
type AnthropicMessagesConfig = {
|
|
8
174
|
provider: string;
|
|
9
175
|
baseURL: string;
|
|
10
176
|
headers: Resolvable<Record<string, string | undefined>>;
|
|
11
177
|
fetch?: FetchFunction;
|
|
12
178
|
buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
|
|
179
|
+
/** Custom media conversion for compatible providers. */
|
|
180
|
+
convertMediaPart?: AnthropicMediaPartConverter;
|
|
181
|
+
/** Maximum temperature for compatible providers. Defaults to 1. */
|
|
182
|
+
maxTemperature?: number;
|
|
183
|
+
/** Preserve temperature and topP with thinking for compatible providers. */
|
|
184
|
+
supportsTemperatureAndTopPWithThinking?: boolean;
|
|
185
|
+
/** Cache option namespace for compatible providers. Defaults to anthropic. */
|
|
186
|
+
cacheControlProviderOptionsName?: string;
|
|
13
187
|
transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
|
|
14
188
|
supportedUrls?: () => LanguageModelV3['supportedUrls'];
|
|
15
189
|
generateId?: () => string;
|
|
@@ -962,144 +1136,6 @@ declare const anthropicTools: {
|
|
|
962
1136
|
}[]>;
|
|
963
1137
|
};
|
|
964
1138
|
|
|
965
|
-
type AnthropicCacheControl = {
|
|
966
|
-
type: 'ephemeral';
|
|
967
|
-
ttl?: '5m' | '1h';
|
|
968
|
-
};
|
|
969
|
-
type AnthropicTool = {
|
|
970
|
-
name: string;
|
|
971
|
-
description: string | undefined;
|
|
972
|
-
input_schema: JSONSchema7;
|
|
973
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
974
|
-
eager_input_streaming?: boolean;
|
|
975
|
-
strict?: boolean;
|
|
976
|
-
/**
|
|
977
|
-
* When true, this tool is deferred and will only be loaded when
|
|
978
|
-
* discovered via the tool search tool.
|
|
979
|
-
*/
|
|
980
|
-
defer_loading?: boolean;
|
|
981
|
-
/**
|
|
982
|
-
* Programmatic tool calling: specifies which server-executed tools
|
|
983
|
-
* are allowed to call this tool. When set, only the specified callers
|
|
984
|
-
* can invoke this tool programmatically.
|
|
985
|
-
*
|
|
986
|
-
* @example ['code_execution_20250825']
|
|
987
|
-
*/
|
|
988
|
-
allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
|
|
989
|
-
} | {
|
|
990
|
-
type: 'code_execution_20250522';
|
|
991
|
-
name: string;
|
|
992
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
993
|
-
} | {
|
|
994
|
-
type: 'code_execution_20250825';
|
|
995
|
-
name: string;
|
|
996
|
-
} | {
|
|
997
|
-
type: 'code_execution_20260120';
|
|
998
|
-
name: string;
|
|
999
|
-
} | {
|
|
1000
|
-
name: string;
|
|
1001
|
-
type: 'computer_20250124' | 'computer_20241022';
|
|
1002
|
-
display_width_px: number;
|
|
1003
|
-
display_height_px: number;
|
|
1004
|
-
display_number: number;
|
|
1005
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1006
|
-
} | {
|
|
1007
|
-
name: string;
|
|
1008
|
-
type: 'computer_20251124';
|
|
1009
|
-
display_width_px: number;
|
|
1010
|
-
display_height_px: number;
|
|
1011
|
-
display_number: number;
|
|
1012
|
-
enable_zoom?: boolean;
|
|
1013
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1014
|
-
} | {
|
|
1015
|
-
/**
|
|
1016
|
-
* Computer toolset. Declared without a `name`; the API returns member
|
|
1017
|
-
* tool calls (e.g. `left_click`) with `toolset_name: 'computer'`.
|
|
1018
|
-
*/
|
|
1019
|
-
type: 'computer_toolset_20260801';
|
|
1020
|
-
configs?: Record<string, {
|
|
1021
|
-
enabled?: boolean;
|
|
1022
|
-
defer_loading?: boolean;
|
|
1023
|
-
}>;
|
|
1024
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1025
|
-
} | {
|
|
1026
|
-
name: string;
|
|
1027
|
-
type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
|
|
1028
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1029
|
-
} | {
|
|
1030
|
-
name: string;
|
|
1031
|
-
type: 'text_editor_20250728';
|
|
1032
|
-
max_characters?: number;
|
|
1033
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1034
|
-
} | {
|
|
1035
|
-
name: string;
|
|
1036
|
-
type: 'bash_20250124' | 'bash_20241022';
|
|
1037
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1038
|
-
} | {
|
|
1039
|
-
name: string;
|
|
1040
|
-
type: 'memory_20250818';
|
|
1041
|
-
} | {
|
|
1042
|
-
type: 'web_fetch_20250910' | 'web_fetch_20260209';
|
|
1043
|
-
name: string;
|
|
1044
|
-
max_uses?: number;
|
|
1045
|
-
allowed_domains?: string[];
|
|
1046
|
-
blocked_domains?: string[];
|
|
1047
|
-
citations?: {
|
|
1048
|
-
enabled: boolean;
|
|
1049
|
-
};
|
|
1050
|
-
max_content_tokens?: number;
|
|
1051
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1052
|
-
} | {
|
|
1053
|
-
type: 'web_search_20250305' | 'web_search_20260209';
|
|
1054
|
-
name: string;
|
|
1055
|
-
max_uses?: number;
|
|
1056
|
-
allowed_domains?: string[];
|
|
1057
|
-
blocked_domains?: string[];
|
|
1058
|
-
user_location?: {
|
|
1059
|
-
type: 'approximate';
|
|
1060
|
-
city?: string;
|
|
1061
|
-
region?: string;
|
|
1062
|
-
country?: string;
|
|
1063
|
-
timezone?: string;
|
|
1064
|
-
};
|
|
1065
|
-
cache_control: AnthropicCacheControl | undefined;
|
|
1066
|
-
} | {
|
|
1067
|
-
type: 'tool_search_tool_regex_20251119';
|
|
1068
|
-
name: string;
|
|
1069
|
-
} | {
|
|
1070
|
-
type: 'tool_search_tool_bm25_20251119';
|
|
1071
|
-
name: string;
|
|
1072
|
-
} | {
|
|
1073
|
-
type: 'advisor_20260301';
|
|
1074
|
-
name: 'advisor';
|
|
1075
|
-
model: string;
|
|
1076
|
-
max_uses?: number;
|
|
1077
|
-
caching?: {
|
|
1078
|
-
type: 'ephemeral';
|
|
1079
|
-
ttl: '5m' | '1h';
|
|
1080
|
-
};
|
|
1081
|
-
};
|
|
1082
|
-
type AnthropicToolChoice = {
|
|
1083
|
-
type: 'auto' | 'any';
|
|
1084
|
-
disable_parallel_tool_use?: boolean;
|
|
1085
|
-
} | {
|
|
1086
|
-
type: 'none';
|
|
1087
|
-
} | {
|
|
1088
|
-
type: 'tool';
|
|
1089
|
-
name: string;
|
|
1090
|
-
disable_parallel_tool_use?: boolean;
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
declare class CacheControlValidator {
|
|
1094
|
-
private breakpointCount;
|
|
1095
|
-
private warnings;
|
|
1096
|
-
getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
|
|
1097
|
-
type: string;
|
|
1098
|
-
canCache: boolean;
|
|
1099
|
-
}): AnthropicCacheControl | undefined;
|
|
1100
|
-
getWarnings(): SharedV3Warning[];
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
1139
|
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming, rejectsForcedToolUse, }: {
|
|
1104
1140
|
tools: LanguageModelV3CallOptions['tools'];
|
|
1105
1141
|
toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
|