@fairyhunter13/ai-anthropic 3.0.58-fork.8 → 3.0.74-fork
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 +277 -0
- package/README.md +2 -0
- package/dist/index.d.ts +156 -67
- package/dist/index.js +2190 -1471
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +167 -58
- package/dist/internal/index.js +1950 -1458
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +116 -13
- package/package.json +15 -12
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +46 -15
- package/src/anthropic-error.ts +1 -1
- package/src/anthropic-files.ts +95 -0
- package/src/{anthropic-messages-options.ts → anthropic-language-model-options.ts} +80 -41
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +221 -138
- package/src/anthropic-message-metadata.ts +2 -1
- package/src/anthropic-prepare-tools.ts +68 -26
- package/src/anthropic-provider.ts +42 -13
- package/src/anthropic-tools.ts +18 -0
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +233 -180
- package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
- package/src/get-cache-control.ts +5 -2
- package/src/index.ts +1 -1
- package/src/internal/index.ts +9 -3
- package/src/map-anthropic-stop-reason.ts +1 -1
- package/src/sanitize-json-schema.ts +203 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +132 -0
- package/src/tool/bash_20241022.ts +2 -2
- package/src/tool/bash_20250124.ts +2 -2
- package/src/tool/code-execution_20250522.ts +2 -2
- package/src/tool/code-execution_20250825.ts +2 -2
- package/src/tool/code-execution_20260120.ts +2 -2
- package/src/tool/computer_20241022.ts +2 -2
- package/src/tool/computer_20250124.ts +2 -2
- package/src/tool/computer_20251124.ts +2 -2
- package/src/tool/memory_20250818.ts +2 -2
- package/src/tool/text-editor_20241022.ts +2 -2
- package/src/tool/text-editor_20250124.ts +2 -2
- package/src/tool/text-editor_20250429.ts +2 -2
- package/src/tool/text-editor_20250728.ts +6 -3
- package/src/tool/tool-search-bm25_20251119.ts +2 -2
- package/src/tool/tool-search-regex_20251119.ts +2 -2
- package/src/tool/web-fetch-20250910.ts +2 -2
- package/src/tool/web-fetch-20260209.ts +2 -2
- package/src/tool/web-fetch-20260309.ts +181 -0
- package/src/tool/web-search_20250305.ts +2 -2
- package/src/tool/web-search_20260209.ts +19 -2
- package/dist/index.d.mts +0 -1105
- package/dist/index.mjs +0 -5394
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -981
- package/dist/internal/index.mjs +0 -5287
- package/dist/internal/index.mjs.map +0 -1
package/dist/internal/index.js
CHANGED
|
@@ -1,368 +1,364 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
|
|
24
|
-
anthropicTools: () => anthropicTools,
|
|
25
|
-
getModelCapabilities: () => getModelCapabilities,
|
|
26
|
-
prepareTools: () => prepareTools
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/anthropic-messages-language-model.ts
|
|
31
|
-
var import_provider3 = require("@ai-sdk/provider");
|
|
32
|
-
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1
|
+
// src/anthropic-language-model.ts
|
|
2
|
+
import {
|
|
3
|
+
APICallError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
combineHeaders,
|
|
7
|
+
createEventSourceResponseHandler,
|
|
8
|
+
createJsonResponseHandler,
|
|
9
|
+
createToolNameMapping,
|
|
10
|
+
generateId,
|
|
11
|
+
isCustomReasoning,
|
|
12
|
+
mapReasoningToProviderBudget,
|
|
13
|
+
mapReasoningToProviderEffort,
|
|
14
|
+
parseProviderOptions as parseProviderOptions2,
|
|
15
|
+
postJsonToApi,
|
|
16
|
+
resolve,
|
|
17
|
+
resolveProviderReference as resolveProviderReference2,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE
|
|
21
|
+
} from "@ai-sdk/provider-utils";
|
|
33
22
|
|
|
34
23
|
// src/anthropic-error.ts
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
import {
|
|
25
|
+
createJsonErrorResponseHandler,
|
|
26
|
+
lazySchema,
|
|
27
|
+
zodSchema
|
|
28
|
+
} from "@ai-sdk/provider-utils";
|
|
29
|
+
import { z } from "zod/v4";
|
|
30
|
+
var anthropicErrorDataSchema = lazySchema(
|
|
31
|
+
() => zodSchema(
|
|
32
|
+
z.object({
|
|
33
|
+
type: z.literal("error"),
|
|
34
|
+
error: z.object({
|
|
35
|
+
type: z.string(),
|
|
36
|
+
message: z.string()
|
|
44
37
|
})
|
|
45
38
|
})
|
|
46
39
|
)
|
|
47
40
|
);
|
|
48
|
-
var anthropicFailedResponseHandler =
|
|
41
|
+
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
49
42
|
errorSchema: anthropicErrorDataSchema,
|
|
50
43
|
errorToMessage: (data) => data.error.message
|
|
51
44
|
});
|
|
52
45
|
|
|
53
|
-
// src/anthropic-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
46
|
+
// src/anthropic-api.ts
|
|
47
|
+
import {
|
|
48
|
+
lazySchema as lazySchema2,
|
|
49
|
+
zodSchema as zodSchema2
|
|
50
|
+
} from "@ai-sdk/provider-utils";
|
|
51
|
+
import { z as z2 } from "zod/v4";
|
|
52
|
+
var anthropicResponseSchema = lazySchema2(
|
|
53
|
+
() => zodSchema2(
|
|
54
|
+
z2.object({
|
|
55
|
+
type: z2.literal("message"),
|
|
56
|
+
id: z2.string().nullish(),
|
|
57
|
+
model: z2.string().nullish(),
|
|
58
|
+
content: z2.array(
|
|
59
|
+
z2.discriminatedUnion("type", [
|
|
60
|
+
z2.object({
|
|
61
|
+
type: z2.literal("text"),
|
|
62
|
+
text: z2.string(),
|
|
63
|
+
citations: z2.array(
|
|
64
|
+
z2.discriminatedUnion("type", [
|
|
65
|
+
z2.object({
|
|
66
|
+
type: z2.literal("web_search_result_location"),
|
|
67
|
+
cited_text: z2.string(),
|
|
68
|
+
url: z2.string(),
|
|
69
|
+
title: z2.string(),
|
|
70
|
+
encrypted_index: z2.string()
|
|
75
71
|
}),
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
cited_text:
|
|
79
|
-
document_index:
|
|
80
|
-
document_title:
|
|
81
|
-
start_page_number:
|
|
82
|
-
end_page_number:
|
|
72
|
+
z2.object({
|
|
73
|
+
type: z2.literal("page_location"),
|
|
74
|
+
cited_text: z2.string(),
|
|
75
|
+
document_index: z2.number(),
|
|
76
|
+
document_title: z2.string().nullable(),
|
|
77
|
+
start_page_number: z2.number(),
|
|
78
|
+
end_page_number: z2.number()
|
|
83
79
|
}),
|
|
84
|
-
|
|
85
|
-
type:
|
|
86
|
-
cited_text:
|
|
87
|
-
document_index:
|
|
88
|
-
document_title:
|
|
89
|
-
start_char_index:
|
|
90
|
-
end_char_index:
|
|
80
|
+
z2.object({
|
|
81
|
+
type: z2.literal("char_location"),
|
|
82
|
+
cited_text: z2.string(),
|
|
83
|
+
document_index: z2.number(),
|
|
84
|
+
document_title: z2.string().nullable(),
|
|
85
|
+
start_char_index: z2.number(),
|
|
86
|
+
end_char_index: z2.number()
|
|
91
87
|
})
|
|
92
88
|
])
|
|
93
89
|
).optional()
|
|
94
90
|
}),
|
|
95
|
-
|
|
96
|
-
type:
|
|
97
|
-
thinking:
|
|
98
|
-
signature:
|
|
91
|
+
z2.object({
|
|
92
|
+
type: z2.literal("thinking"),
|
|
93
|
+
thinking: z2.string(),
|
|
94
|
+
signature: z2.string()
|
|
99
95
|
}),
|
|
100
|
-
|
|
101
|
-
type:
|
|
102
|
-
data:
|
|
96
|
+
z2.object({
|
|
97
|
+
type: z2.literal("redacted_thinking"),
|
|
98
|
+
data: z2.string()
|
|
103
99
|
}),
|
|
104
|
-
|
|
105
|
-
type:
|
|
106
|
-
content:
|
|
100
|
+
z2.object({
|
|
101
|
+
type: z2.literal("compaction"),
|
|
102
|
+
content: z2.string()
|
|
107
103
|
}),
|
|
108
|
-
|
|
109
|
-
type:
|
|
110
|
-
id:
|
|
111
|
-
name:
|
|
112
|
-
input:
|
|
104
|
+
z2.object({
|
|
105
|
+
type: z2.literal("tool_use"),
|
|
106
|
+
id: z2.string(),
|
|
107
|
+
name: z2.string(),
|
|
108
|
+
input: z2.unknown(),
|
|
113
109
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
114
|
-
caller:
|
|
115
|
-
|
|
116
|
-
type:
|
|
117
|
-
tool_id:
|
|
110
|
+
caller: z2.union([
|
|
111
|
+
z2.object({
|
|
112
|
+
type: z2.literal("code_execution_20250825"),
|
|
113
|
+
tool_id: z2.string()
|
|
118
114
|
}),
|
|
119
|
-
|
|
120
|
-
type:
|
|
121
|
-
tool_id:
|
|
115
|
+
z2.object({
|
|
116
|
+
type: z2.literal("code_execution_20260120"),
|
|
117
|
+
tool_id: z2.string()
|
|
122
118
|
}),
|
|
123
|
-
|
|
124
|
-
type:
|
|
119
|
+
z2.object({
|
|
120
|
+
type: z2.literal("direct")
|
|
125
121
|
})
|
|
126
122
|
]).optional()
|
|
127
123
|
}),
|
|
128
|
-
|
|
129
|
-
type:
|
|
130
|
-
id:
|
|
131
|
-
name:
|
|
132
|
-
input:
|
|
133
|
-
caller:
|
|
134
|
-
|
|
135
|
-
type:
|
|
136
|
-
tool_id:
|
|
124
|
+
z2.object({
|
|
125
|
+
type: z2.literal("server_tool_use"),
|
|
126
|
+
id: z2.string(),
|
|
127
|
+
name: z2.string(),
|
|
128
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
129
|
+
caller: z2.union([
|
|
130
|
+
z2.object({
|
|
131
|
+
type: z2.literal("code_execution_20260120"),
|
|
132
|
+
tool_id: z2.string()
|
|
137
133
|
}),
|
|
138
|
-
|
|
139
|
-
type:
|
|
134
|
+
z2.object({
|
|
135
|
+
type: z2.literal("direct")
|
|
140
136
|
})
|
|
141
137
|
]).optional()
|
|
142
138
|
}),
|
|
143
|
-
|
|
144
|
-
type:
|
|
145
|
-
id:
|
|
146
|
-
name:
|
|
147
|
-
input:
|
|
148
|
-
server_name:
|
|
139
|
+
z2.object({
|
|
140
|
+
type: z2.literal("mcp_tool_use"),
|
|
141
|
+
id: z2.string(),
|
|
142
|
+
name: z2.string(),
|
|
143
|
+
input: z2.unknown(),
|
|
144
|
+
server_name: z2.string()
|
|
149
145
|
}),
|
|
150
|
-
|
|
151
|
-
type:
|
|
152
|
-
tool_use_id:
|
|
153
|
-
is_error:
|
|
154
|
-
content:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
z2.object({
|
|
147
|
+
type: z2.literal("mcp_tool_result"),
|
|
148
|
+
tool_use_id: z2.string(),
|
|
149
|
+
is_error: z2.boolean(),
|
|
150
|
+
content: z2.array(
|
|
151
|
+
z2.union([
|
|
152
|
+
z2.string(),
|
|
153
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
158
154
|
])
|
|
159
155
|
)
|
|
160
156
|
}),
|
|
161
|
-
|
|
162
|
-
type:
|
|
163
|
-
tool_use_id:
|
|
164
|
-
content:
|
|
165
|
-
|
|
166
|
-
type:
|
|
167
|
-
url:
|
|
168
|
-
retrieved_at:
|
|
169
|
-
content:
|
|
170
|
-
type:
|
|
171
|
-
title:
|
|
172
|
-
citations:
|
|
173
|
-
source:
|
|
174
|
-
|
|
175
|
-
type:
|
|
176
|
-
media_type:
|
|
177
|
-
data:
|
|
157
|
+
z2.object({
|
|
158
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
159
|
+
tool_use_id: z2.string(),
|
|
160
|
+
content: z2.union([
|
|
161
|
+
z2.object({
|
|
162
|
+
type: z2.literal("web_fetch_result"),
|
|
163
|
+
url: z2.string(),
|
|
164
|
+
retrieved_at: z2.string(),
|
|
165
|
+
content: z2.object({
|
|
166
|
+
type: z2.literal("document"),
|
|
167
|
+
title: z2.string().nullable(),
|
|
168
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
169
|
+
source: z2.union([
|
|
170
|
+
z2.object({
|
|
171
|
+
type: z2.literal("base64"),
|
|
172
|
+
media_type: z2.literal("application/pdf"),
|
|
173
|
+
data: z2.string()
|
|
178
174
|
}),
|
|
179
|
-
|
|
180
|
-
type:
|
|
181
|
-
media_type:
|
|
182
|
-
data:
|
|
175
|
+
z2.object({
|
|
176
|
+
type: z2.literal("text"),
|
|
177
|
+
media_type: z2.literal("text/plain"),
|
|
178
|
+
data: z2.string()
|
|
183
179
|
})
|
|
184
180
|
])
|
|
185
181
|
})
|
|
186
182
|
}),
|
|
187
|
-
|
|
188
|
-
type:
|
|
189
|
-
error_code:
|
|
183
|
+
z2.object({
|
|
184
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
185
|
+
error_code: z2.string()
|
|
190
186
|
})
|
|
191
187
|
])
|
|
192
188
|
}),
|
|
193
|
-
|
|
194
|
-
type:
|
|
195
|
-
tool_use_id:
|
|
196
|
-
content:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
type:
|
|
200
|
-
url:
|
|
201
|
-
title:
|
|
202
|
-
encrypted_content:
|
|
203
|
-
page_age:
|
|
189
|
+
z2.object({
|
|
190
|
+
type: z2.literal("web_search_tool_result"),
|
|
191
|
+
tool_use_id: z2.string(),
|
|
192
|
+
content: z2.union([
|
|
193
|
+
z2.array(
|
|
194
|
+
z2.object({
|
|
195
|
+
type: z2.literal("web_search_result"),
|
|
196
|
+
url: z2.string(),
|
|
197
|
+
title: z2.string(),
|
|
198
|
+
encrypted_content: z2.string(),
|
|
199
|
+
page_age: z2.string().nullish()
|
|
204
200
|
})
|
|
205
201
|
),
|
|
206
|
-
|
|
207
|
-
type:
|
|
208
|
-
error_code:
|
|
202
|
+
z2.object({
|
|
203
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
204
|
+
error_code: z2.string()
|
|
209
205
|
})
|
|
210
206
|
])
|
|
211
207
|
}),
|
|
212
208
|
// code execution results for code_execution_20250522 tool:
|
|
213
|
-
|
|
214
|
-
type:
|
|
215
|
-
tool_use_id:
|
|
216
|
-
content:
|
|
217
|
-
|
|
218
|
-
type:
|
|
219
|
-
stdout:
|
|
220
|
-
stderr:
|
|
221
|
-
return_code:
|
|
222
|
-
content:
|
|
223
|
-
|
|
224
|
-
type:
|
|
225
|
-
file_id:
|
|
209
|
+
z2.object({
|
|
210
|
+
type: z2.literal("code_execution_tool_result"),
|
|
211
|
+
tool_use_id: z2.string(),
|
|
212
|
+
content: z2.union([
|
|
213
|
+
z2.object({
|
|
214
|
+
type: z2.literal("code_execution_result"),
|
|
215
|
+
stdout: z2.string(),
|
|
216
|
+
stderr: z2.string(),
|
|
217
|
+
return_code: z2.number(),
|
|
218
|
+
content: z2.array(
|
|
219
|
+
z2.object({
|
|
220
|
+
type: z2.literal("code_execution_output"),
|
|
221
|
+
file_id: z2.string()
|
|
226
222
|
})
|
|
227
223
|
).optional().default([])
|
|
228
224
|
}),
|
|
229
|
-
|
|
230
|
-
type:
|
|
231
|
-
encrypted_stdout:
|
|
232
|
-
stderr:
|
|
233
|
-
return_code:
|
|
234
|
-
content:
|
|
235
|
-
|
|
236
|
-
type:
|
|
237
|
-
file_id:
|
|
225
|
+
z2.object({
|
|
226
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
227
|
+
encrypted_stdout: z2.string(),
|
|
228
|
+
stderr: z2.string(),
|
|
229
|
+
return_code: z2.number(),
|
|
230
|
+
content: z2.array(
|
|
231
|
+
z2.object({
|
|
232
|
+
type: z2.literal("code_execution_output"),
|
|
233
|
+
file_id: z2.string()
|
|
238
234
|
})
|
|
239
235
|
).optional().default([])
|
|
240
236
|
}),
|
|
241
|
-
|
|
242
|
-
type:
|
|
243
|
-
error_code:
|
|
237
|
+
z2.object({
|
|
238
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
239
|
+
error_code: z2.string()
|
|
244
240
|
})
|
|
245
241
|
])
|
|
246
242
|
}),
|
|
247
243
|
// bash code execution results for code_execution_20250825 tool:
|
|
248
|
-
|
|
249
|
-
type:
|
|
250
|
-
tool_use_id:
|
|
251
|
-
content:
|
|
252
|
-
|
|
253
|
-
type:
|
|
254
|
-
content:
|
|
255
|
-
|
|
256
|
-
type:
|
|
257
|
-
file_id:
|
|
244
|
+
z2.object({
|
|
245
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
246
|
+
tool_use_id: z2.string(),
|
|
247
|
+
content: z2.discriminatedUnion("type", [
|
|
248
|
+
z2.object({
|
|
249
|
+
type: z2.literal("bash_code_execution_result"),
|
|
250
|
+
content: z2.array(
|
|
251
|
+
z2.object({
|
|
252
|
+
type: z2.literal("bash_code_execution_output"),
|
|
253
|
+
file_id: z2.string()
|
|
258
254
|
})
|
|
259
255
|
),
|
|
260
|
-
stdout:
|
|
261
|
-
stderr:
|
|
262
|
-
return_code:
|
|
256
|
+
stdout: z2.string(),
|
|
257
|
+
stderr: z2.string(),
|
|
258
|
+
return_code: z2.number()
|
|
263
259
|
}),
|
|
264
|
-
|
|
265
|
-
type:
|
|
266
|
-
error_code:
|
|
260
|
+
z2.object({
|
|
261
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
262
|
+
error_code: z2.string()
|
|
267
263
|
})
|
|
268
264
|
])
|
|
269
265
|
}),
|
|
270
266
|
// text editor code execution results for code_execution_20250825 tool:
|
|
271
|
-
|
|
272
|
-
type:
|
|
273
|
-
tool_use_id:
|
|
274
|
-
content:
|
|
275
|
-
|
|
276
|
-
type:
|
|
277
|
-
error_code:
|
|
267
|
+
z2.object({
|
|
268
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
269
|
+
tool_use_id: z2.string(),
|
|
270
|
+
content: z2.discriminatedUnion("type", [
|
|
271
|
+
z2.object({
|
|
272
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
273
|
+
error_code: z2.string()
|
|
278
274
|
}),
|
|
279
|
-
|
|
280
|
-
type:
|
|
281
|
-
content:
|
|
282
|
-
file_type:
|
|
283
|
-
num_lines:
|
|
284
|
-
start_line:
|
|
285
|
-
total_lines:
|
|
275
|
+
z2.object({
|
|
276
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
277
|
+
content: z2.string(),
|
|
278
|
+
file_type: z2.string(),
|
|
279
|
+
num_lines: z2.number().nullable(),
|
|
280
|
+
start_line: z2.number().nullable(),
|
|
281
|
+
total_lines: z2.number().nullable()
|
|
286
282
|
}),
|
|
287
|
-
|
|
288
|
-
type:
|
|
289
|
-
is_file_update:
|
|
283
|
+
z2.object({
|
|
284
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
285
|
+
is_file_update: z2.boolean()
|
|
290
286
|
}),
|
|
291
|
-
|
|
292
|
-
type:
|
|
287
|
+
z2.object({
|
|
288
|
+
type: z2.literal(
|
|
293
289
|
"text_editor_code_execution_str_replace_result"
|
|
294
290
|
),
|
|
295
|
-
lines:
|
|
296
|
-
new_lines:
|
|
297
|
-
new_start:
|
|
298
|
-
old_lines:
|
|
299
|
-
old_start:
|
|
291
|
+
lines: z2.array(z2.string()).nullable(),
|
|
292
|
+
new_lines: z2.number().nullable(),
|
|
293
|
+
new_start: z2.number().nullable(),
|
|
294
|
+
old_lines: z2.number().nullable(),
|
|
295
|
+
old_start: z2.number().nullable()
|
|
300
296
|
})
|
|
301
297
|
])
|
|
302
298
|
}),
|
|
303
299
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
304
|
-
|
|
305
|
-
type:
|
|
306
|
-
tool_use_id:
|
|
307
|
-
content:
|
|
308
|
-
|
|
309
|
-
type:
|
|
310
|
-
tool_references:
|
|
311
|
-
|
|
312
|
-
type:
|
|
313
|
-
tool_name:
|
|
300
|
+
z2.object({
|
|
301
|
+
type: z2.literal("tool_search_tool_result"),
|
|
302
|
+
tool_use_id: z2.string(),
|
|
303
|
+
content: z2.union([
|
|
304
|
+
z2.object({
|
|
305
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
306
|
+
tool_references: z2.array(
|
|
307
|
+
z2.object({
|
|
308
|
+
type: z2.literal("tool_reference"),
|
|
309
|
+
tool_name: z2.string()
|
|
314
310
|
})
|
|
315
311
|
)
|
|
316
312
|
}),
|
|
317
|
-
|
|
318
|
-
type:
|
|
319
|
-
error_code:
|
|
313
|
+
z2.object({
|
|
314
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
315
|
+
error_code: z2.string()
|
|
320
316
|
})
|
|
321
317
|
])
|
|
322
318
|
})
|
|
323
319
|
])
|
|
324
320
|
),
|
|
325
|
-
stop_reason:
|
|
326
|
-
stop_sequence:
|
|
327
|
-
usage:
|
|
328
|
-
input_tokens:
|
|
329
|
-
output_tokens:
|
|
330
|
-
cache_creation_input_tokens:
|
|
331
|
-
cache_read_input_tokens:
|
|
332
|
-
iterations:
|
|
333
|
-
|
|
334
|
-
type:
|
|
335
|
-
input_tokens:
|
|
336
|
-
output_tokens:
|
|
321
|
+
stop_reason: z2.string().nullish(),
|
|
322
|
+
stop_sequence: z2.string().nullish(),
|
|
323
|
+
usage: z2.looseObject({
|
|
324
|
+
input_tokens: z2.number(),
|
|
325
|
+
output_tokens: z2.number(),
|
|
326
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
327
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
328
|
+
iterations: z2.array(
|
|
329
|
+
z2.object({
|
|
330
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
331
|
+
input_tokens: z2.number(),
|
|
332
|
+
output_tokens: z2.number()
|
|
337
333
|
})
|
|
338
334
|
).nullish()
|
|
339
335
|
}),
|
|
340
|
-
container:
|
|
341
|
-
expires_at:
|
|
342
|
-
id:
|
|
343
|
-
skills:
|
|
344
|
-
|
|
345
|
-
type:
|
|
346
|
-
skill_id:
|
|
347
|
-
version:
|
|
336
|
+
container: z2.object({
|
|
337
|
+
expires_at: z2.string(),
|
|
338
|
+
id: z2.string(),
|
|
339
|
+
skills: z2.array(
|
|
340
|
+
z2.object({
|
|
341
|
+
type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
|
|
342
|
+
skill_id: z2.string(),
|
|
343
|
+
version: z2.string()
|
|
348
344
|
})
|
|
349
345
|
).nullish()
|
|
350
346
|
}).nullish(),
|
|
351
|
-
context_management:
|
|
352
|
-
applied_edits:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
type:
|
|
356
|
-
cleared_tool_uses:
|
|
357
|
-
cleared_input_tokens:
|
|
347
|
+
context_management: z2.object({
|
|
348
|
+
applied_edits: z2.array(
|
|
349
|
+
z2.union([
|
|
350
|
+
z2.object({
|
|
351
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
352
|
+
cleared_tool_uses: z2.number(),
|
|
353
|
+
cleared_input_tokens: z2.number()
|
|
358
354
|
}),
|
|
359
|
-
|
|
360
|
-
type:
|
|
361
|
-
cleared_thinking_turns:
|
|
362
|
-
cleared_input_tokens:
|
|
355
|
+
z2.object({
|
|
356
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
357
|
+
cleared_thinking_turns: z2.number(),
|
|
358
|
+
cleared_input_tokens: z2.number()
|
|
363
359
|
}),
|
|
364
|
-
|
|
365
|
-
type:
|
|
360
|
+
z2.object({
|
|
361
|
+
type: z2.literal("compact_20260112")
|
|
366
362
|
})
|
|
367
363
|
])
|
|
368
364
|
)
|
|
@@ -370,457 +366,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
370
366
|
})
|
|
371
367
|
)
|
|
372
368
|
);
|
|
373
|
-
var
|
|
374
|
-
() => (
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
type:
|
|
378
|
-
message:
|
|
379
|
-
id:
|
|
380
|
-
model:
|
|
381
|
-
role:
|
|
382
|
-
usage:
|
|
383
|
-
input_tokens:
|
|
384
|
-
cache_creation_input_tokens:
|
|
385
|
-
cache_read_input_tokens:
|
|
369
|
+
var anthropicChunkSchema = lazySchema2(
|
|
370
|
+
() => zodSchema2(
|
|
371
|
+
z2.discriminatedUnion("type", [
|
|
372
|
+
z2.object({
|
|
373
|
+
type: z2.literal("message_start"),
|
|
374
|
+
message: z2.object({
|
|
375
|
+
id: z2.string().nullish(),
|
|
376
|
+
model: z2.string().nullish(),
|
|
377
|
+
role: z2.string().nullish(),
|
|
378
|
+
usage: z2.looseObject({
|
|
379
|
+
input_tokens: z2.number(),
|
|
380
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
381
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
386
382
|
}),
|
|
387
383
|
// Programmatic tool calling: content may be pre-populated for deferred tool calls
|
|
388
|
-
content:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
type:
|
|
392
|
-
id:
|
|
393
|
-
name:
|
|
394
|
-
input:
|
|
395
|
-
caller:
|
|
396
|
-
|
|
397
|
-
type:
|
|
398
|
-
tool_id:
|
|
384
|
+
content: z2.array(
|
|
385
|
+
z2.discriminatedUnion("type", [
|
|
386
|
+
z2.object({
|
|
387
|
+
type: z2.literal("tool_use"),
|
|
388
|
+
id: z2.string(),
|
|
389
|
+
name: z2.string(),
|
|
390
|
+
input: z2.unknown(),
|
|
391
|
+
caller: z2.union([
|
|
392
|
+
z2.object({
|
|
393
|
+
type: z2.literal("code_execution_20250825"),
|
|
394
|
+
tool_id: z2.string()
|
|
399
395
|
}),
|
|
400
|
-
|
|
401
|
-
type:
|
|
402
|
-
tool_id:
|
|
396
|
+
z2.object({
|
|
397
|
+
type: z2.literal("code_execution_20260120"),
|
|
398
|
+
tool_id: z2.string()
|
|
403
399
|
}),
|
|
404
|
-
|
|
405
|
-
type:
|
|
400
|
+
z2.object({
|
|
401
|
+
type: z2.literal("direct")
|
|
406
402
|
})
|
|
407
403
|
]).optional()
|
|
408
404
|
})
|
|
409
405
|
])
|
|
410
406
|
).nullish(),
|
|
411
|
-
stop_reason:
|
|
412
|
-
container:
|
|
413
|
-
expires_at:
|
|
414
|
-
id:
|
|
407
|
+
stop_reason: z2.string().nullish(),
|
|
408
|
+
container: z2.object({
|
|
409
|
+
expires_at: z2.string(),
|
|
410
|
+
id: z2.string()
|
|
415
411
|
}).nullish()
|
|
416
412
|
})
|
|
417
413
|
}),
|
|
418
|
-
|
|
419
|
-
type:
|
|
420
|
-
index:
|
|
421
|
-
content_block:
|
|
422
|
-
|
|
423
|
-
type:
|
|
424
|
-
text:
|
|
414
|
+
z2.object({
|
|
415
|
+
type: z2.literal("content_block_start"),
|
|
416
|
+
index: z2.number(),
|
|
417
|
+
content_block: z2.discriminatedUnion("type", [
|
|
418
|
+
z2.object({
|
|
419
|
+
type: z2.literal("text"),
|
|
420
|
+
text: z2.string()
|
|
425
421
|
}),
|
|
426
|
-
|
|
427
|
-
type:
|
|
428
|
-
thinking:
|
|
422
|
+
z2.object({
|
|
423
|
+
type: z2.literal("thinking"),
|
|
424
|
+
thinking: z2.string()
|
|
429
425
|
}),
|
|
430
|
-
|
|
431
|
-
type:
|
|
432
|
-
id:
|
|
433
|
-
name:
|
|
426
|
+
z2.object({
|
|
427
|
+
type: z2.literal("tool_use"),
|
|
428
|
+
id: z2.string(),
|
|
429
|
+
name: z2.string(),
|
|
434
430
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
435
|
-
input:
|
|
431
|
+
input: z2.record(z2.string(), z2.unknown()).optional(),
|
|
436
432
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
437
|
-
caller:
|
|
438
|
-
|
|
439
|
-
type:
|
|
440
|
-
tool_id:
|
|
433
|
+
caller: z2.union([
|
|
434
|
+
z2.object({
|
|
435
|
+
type: z2.literal("code_execution_20250825"),
|
|
436
|
+
tool_id: z2.string()
|
|
441
437
|
}),
|
|
442
|
-
|
|
443
|
-
type:
|
|
444
|
-
tool_id:
|
|
438
|
+
z2.object({
|
|
439
|
+
type: z2.literal("code_execution_20260120"),
|
|
440
|
+
tool_id: z2.string()
|
|
445
441
|
}),
|
|
446
|
-
|
|
447
|
-
type:
|
|
442
|
+
z2.object({
|
|
443
|
+
type: z2.literal("direct")
|
|
448
444
|
})
|
|
449
445
|
]).optional()
|
|
450
446
|
}),
|
|
451
|
-
|
|
452
|
-
type:
|
|
453
|
-
data:
|
|
447
|
+
z2.object({
|
|
448
|
+
type: z2.literal("redacted_thinking"),
|
|
449
|
+
data: z2.string()
|
|
454
450
|
}),
|
|
455
|
-
|
|
456
|
-
type:
|
|
457
|
-
content:
|
|
451
|
+
z2.object({
|
|
452
|
+
type: z2.literal("compaction"),
|
|
453
|
+
content: z2.string().nullish()
|
|
458
454
|
}),
|
|
459
|
-
|
|
460
|
-
type:
|
|
461
|
-
id:
|
|
462
|
-
name:
|
|
463
|
-
input:
|
|
464
|
-
caller:
|
|
465
|
-
|
|
466
|
-
type:
|
|
467
|
-
tool_id:
|
|
455
|
+
z2.object({
|
|
456
|
+
type: z2.literal("server_tool_use"),
|
|
457
|
+
id: z2.string(),
|
|
458
|
+
name: z2.string(),
|
|
459
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
460
|
+
caller: z2.union([
|
|
461
|
+
z2.object({
|
|
462
|
+
type: z2.literal("code_execution_20260120"),
|
|
463
|
+
tool_id: z2.string()
|
|
468
464
|
}),
|
|
469
|
-
|
|
470
|
-
type:
|
|
465
|
+
z2.object({
|
|
466
|
+
type: z2.literal("direct")
|
|
471
467
|
})
|
|
472
468
|
]).optional()
|
|
473
469
|
}),
|
|
474
|
-
|
|
475
|
-
type:
|
|
476
|
-
id:
|
|
477
|
-
name:
|
|
478
|
-
input:
|
|
479
|
-
server_name:
|
|
470
|
+
z2.object({
|
|
471
|
+
type: z2.literal("mcp_tool_use"),
|
|
472
|
+
id: z2.string(),
|
|
473
|
+
name: z2.string(),
|
|
474
|
+
input: z2.unknown(),
|
|
475
|
+
server_name: z2.string()
|
|
480
476
|
}),
|
|
481
|
-
|
|
482
|
-
type:
|
|
483
|
-
tool_use_id:
|
|
484
|
-
is_error:
|
|
485
|
-
content:
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
477
|
+
z2.object({
|
|
478
|
+
type: z2.literal("mcp_tool_result"),
|
|
479
|
+
tool_use_id: z2.string(),
|
|
480
|
+
is_error: z2.boolean(),
|
|
481
|
+
content: z2.array(
|
|
482
|
+
z2.union([
|
|
483
|
+
z2.string(),
|
|
484
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
489
485
|
])
|
|
490
486
|
)
|
|
491
487
|
}),
|
|
492
|
-
|
|
493
|
-
type:
|
|
494
|
-
tool_use_id:
|
|
495
|
-
content:
|
|
496
|
-
|
|
497
|
-
type:
|
|
498
|
-
url:
|
|
499
|
-
retrieved_at:
|
|
500
|
-
content:
|
|
501
|
-
type:
|
|
502
|
-
title:
|
|
503
|
-
citations:
|
|
504
|
-
source:
|
|
505
|
-
|
|
506
|
-
type:
|
|
507
|
-
media_type:
|
|
508
|
-
data:
|
|
488
|
+
z2.object({
|
|
489
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
490
|
+
tool_use_id: z2.string(),
|
|
491
|
+
content: z2.union([
|
|
492
|
+
z2.object({
|
|
493
|
+
type: z2.literal("web_fetch_result"),
|
|
494
|
+
url: z2.string(),
|
|
495
|
+
retrieved_at: z2.string(),
|
|
496
|
+
content: z2.object({
|
|
497
|
+
type: z2.literal("document"),
|
|
498
|
+
title: z2.string().nullable(),
|
|
499
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
500
|
+
source: z2.union([
|
|
501
|
+
z2.object({
|
|
502
|
+
type: z2.literal("base64"),
|
|
503
|
+
media_type: z2.literal("application/pdf"),
|
|
504
|
+
data: z2.string()
|
|
509
505
|
}),
|
|
510
|
-
|
|
511
|
-
type:
|
|
512
|
-
media_type:
|
|
513
|
-
data:
|
|
506
|
+
z2.object({
|
|
507
|
+
type: z2.literal("text"),
|
|
508
|
+
media_type: z2.literal("text/plain"),
|
|
509
|
+
data: z2.string()
|
|
514
510
|
})
|
|
515
511
|
])
|
|
516
512
|
})
|
|
517
513
|
}),
|
|
518
|
-
|
|
519
|
-
type:
|
|
520
|
-
error_code:
|
|
514
|
+
z2.object({
|
|
515
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
516
|
+
error_code: z2.string()
|
|
521
517
|
})
|
|
522
518
|
])
|
|
523
519
|
}),
|
|
524
|
-
|
|
525
|
-
type:
|
|
526
|
-
tool_use_id:
|
|
527
|
-
content:
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
type:
|
|
531
|
-
url:
|
|
532
|
-
title:
|
|
533
|
-
encrypted_content:
|
|
534
|
-
page_age:
|
|
520
|
+
z2.object({
|
|
521
|
+
type: z2.literal("web_search_tool_result"),
|
|
522
|
+
tool_use_id: z2.string(),
|
|
523
|
+
content: z2.union([
|
|
524
|
+
z2.array(
|
|
525
|
+
z2.object({
|
|
526
|
+
type: z2.literal("web_search_result"),
|
|
527
|
+
url: z2.string(),
|
|
528
|
+
title: z2.string(),
|
|
529
|
+
encrypted_content: z2.string(),
|
|
530
|
+
page_age: z2.string().nullish()
|
|
535
531
|
})
|
|
536
532
|
),
|
|
537
|
-
|
|
538
|
-
type:
|
|
539
|
-
error_code:
|
|
533
|
+
z2.object({
|
|
534
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
535
|
+
error_code: z2.string()
|
|
540
536
|
})
|
|
541
537
|
])
|
|
542
538
|
}),
|
|
543
539
|
// code execution results for code_execution_20250522 tool:
|
|
544
|
-
|
|
545
|
-
type:
|
|
546
|
-
tool_use_id:
|
|
547
|
-
content:
|
|
548
|
-
|
|
549
|
-
type:
|
|
550
|
-
stdout:
|
|
551
|
-
stderr:
|
|
552
|
-
return_code:
|
|
553
|
-
content:
|
|
554
|
-
|
|
555
|
-
type:
|
|
556
|
-
file_id:
|
|
540
|
+
z2.object({
|
|
541
|
+
type: z2.literal("code_execution_tool_result"),
|
|
542
|
+
tool_use_id: z2.string(),
|
|
543
|
+
content: z2.union([
|
|
544
|
+
z2.object({
|
|
545
|
+
type: z2.literal("code_execution_result"),
|
|
546
|
+
stdout: z2.string(),
|
|
547
|
+
stderr: z2.string(),
|
|
548
|
+
return_code: z2.number(),
|
|
549
|
+
content: z2.array(
|
|
550
|
+
z2.object({
|
|
551
|
+
type: z2.literal("code_execution_output"),
|
|
552
|
+
file_id: z2.string()
|
|
557
553
|
})
|
|
558
554
|
).optional().default([])
|
|
559
555
|
}),
|
|
560
|
-
|
|
561
|
-
type:
|
|
562
|
-
encrypted_stdout:
|
|
563
|
-
stderr:
|
|
564
|
-
return_code:
|
|
565
|
-
content:
|
|
566
|
-
|
|
567
|
-
type:
|
|
568
|
-
file_id:
|
|
556
|
+
z2.object({
|
|
557
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
558
|
+
encrypted_stdout: z2.string(),
|
|
559
|
+
stderr: z2.string(),
|
|
560
|
+
return_code: z2.number(),
|
|
561
|
+
content: z2.array(
|
|
562
|
+
z2.object({
|
|
563
|
+
type: z2.literal("code_execution_output"),
|
|
564
|
+
file_id: z2.string()
|
|
569
565
|
})
|
|
570
566
|
).optional().default([])
|
|
571
567
|
}),
|
|
572
|
-
|
|
573
|
-
type:
|
|
574
|
-
error_code:
|
|
568
|
+
z2.object({
|
|
569
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
570
|
+
error_code: z2.string()
|
|
575
571
|
})
|
|
576
572
|
])
|
|
577
573
|
}),
|
|
578
574
|
// bash code execution results for code_execution_20250825 tool:
|
|
579
|
-
|
|
580
|
-
type:
|
|
581
|
-
tool_use_id:
|
|
582
|
-
content:
|
|
583
|
-
|
|
584
|
-
type:
|
|
585
|
-
content:
|
|
586
|
-
|
|
587
|
-
type:
|
|
588
|
-
file_id:
|
|
575
|
+
z2.object({
|
|
576
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
577
|
+
tool_use_id: z2.string(),
|
|
578
|
+
content: z2.discriminatedUnion("type", [
|
|
579
|
+
z2.object({
|
|
580
|
+
type: z2.literal("bash_code_execution_result"),
|
|
581
|
+
content: z2.array(
|
|
582
|
+
z2.object({
|
|
583
|
+
type: z2.literal("bash_code_execution_output"),
|
|
584
|
+
file_id: z2.string()
|
|
589
585
|
})
|
|
590
586
|
),
|
|
591
|
-
stdout:
|
|
592
|
-
stderr:
|
|
593
|
-
return_code:
|
|
587
|
+
stdout: z2.string(),
|
|
588
|
+
stderr: z2.string(),
|
|
589
|
+
return_code: z2.number()
|
|
594
590
|
}),
|
|
595
|
-
|
|
596
|
-
type:
|
|
597
|
-
error_code:
|
|
591
|
+
z2.object({
|
|
592
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
593
|
+
error_code: z2.string()
|
|
598
594
|
})
|
|
599
595
|
])
|
|
600
596
|
}),
|
|
601
597
|
// text editor code execution results for code_execution_20250825 tool:
|
|
602
|
-
|
|
603
|
-
type:
|
|
604
|
-
tool_use_id:
|
|
605
|
-
content:
|
|
606
|
-
|
|
607
|
-
type:
|
|
608
|
-
error_code:
|
|
598
|
+
z2.object({
|
|
599
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
600
|
+
tool_use_id: z2.string(),
|
|
601
|
+
content: z2.discriminatedUnion("type", [
|
|
602
|
+
z2.object({
|
|
603
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
604
|
+
error_code: z2.string()
|
|
609
605
|
}),
|
|
610
|
-
|
|
611
|
-
type:
|
|
612
|
-
content:
|
|
613
|
-
file_type:
|
|
614
|
-
num_lines:
|
|
615
|
-
start_line:
|
|
616
|
-
total_lines:
|
|
606
|
+
z2.object({
|
|
607
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
608
|
+
content: z2.string(),
|
|
609
|
+
file_type: z2.string(),
|
|
610
|
+
num_lines: z2.number().nullable(),
|
|
611
|
+
start_line: z2.number().nullable(),
|
|
612
|
+
total_lines: z2.number().nullable()
|
|
617
613
|
}),
|
|
618
|
-
|
|
619
|
-
type:
|
|
620
|
-
is_file_update:
|
|
614
|
+
z2.object({
|
|
615
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
616
|
+
is_file_update: z2.boolean()
|
|
621
617
|
}),
|
|
622
|
-
|
|
623
|
-
type:
|
|
618
|
+
z2.object({
|
|
619
|
+
type: z2.literal(
|
|
624
620
|
"text_editor_code_execution_str_replace_result"
|
|
625
621
|
),
|
|
626
|
-
lines:
|
|
627
|
-
new_lines:
|
|
628
|
-
new_start:
|
|
629
|
-
old_lines:
|
|
630
|
-
old_start:
|
|
622
|
+
lines: z2.array(z2.string()).nullable(),
|
|
623
|
+
new_lines: z2.number().nullable(),
|
|
624
|
+
new_start: z2.number().nullable(),
|
|
625
|
+
old_lines: z2.number().nullable(),
|
|
626
|
+
old_start: z2.number().nullable()
|
|
631
627
|
})
|
|
632
628
|
])
|
|
633
629
|
}),
|
|
634
630
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
635
|
-
|
|
636
|
-
type:
|
|
637
|
-
tool_use_id:
|
|
638
|
-
content:
|
|
639
|
-
|
|
640
|
-
type:
|
|
641
|
-
tool_references:
|
|
642
|
-
|
|
643
|
-
type:
|
|
644
|
-
tool_name:
|
|
631
|
+
z2.object({
|
|
632
|
+
type: z2.literal("tool_search_tool_result"),
|
|
633
|
+
tool_use_id: z2.string(),
|
|
634
|
+
content: z2.union([
|
|
635
|
+
z2.object({
|
|
636
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
637
|
+
tool_references: z2.array(
|
|
638
|
+
z2.object({
|
|
639
|
+
type: z2.literal("tool_reference"),
|
|
640
|
+
tool_name: z2.string()
|
|
645
641
|
})
|
|
646
642
|
)
|
|
647
643
|
}),
|
|
648
|
-
|
|
649
|
-
type:
|
|
650
|
-
error_code:
|
|
644
|
+
z2.object({
|
|
645
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
646
|
+
error_code: z2.string()
|
|
651
647
|
})
|
|
652
648
|
])
|
|
653
649
|
})
|
|
654
650
|
])
|
|
655
651
|
}),
|
|
656
|
-
|
|
657
|
-
type:
|
|
658
|
-
index:
|
|
659
|
-
delta:
|
|
660
|
-
|
|
661
|
-
type:
|
|
662
|
-
partial_json:
|
|
652
|
+
z2.object({
|
|
653
|
+
type: z2.literal("content_block_delta"),
|
|
654
|
+
index: z2.number(),
|
|
655
|
+
delta: z2.discriminatedUnion("type", [
|
|
656
|
+
z2.object({
|
|
657
|
+
type: z2.literal("input_json_delta"),
|
|
658
|
+
partial_json: z2.string()
|
|
663
659
|
}),
|
|
664
|
-
|
|
665
|
-
type:
|
|
666
|
-
text:
|
|
660
|
+
z2.object({
|
|
661
|
+
type: z2.literal("text_delta"),
|
|
662
|
+
text: z2.string()
|
|
667
663
|
}),
|
|
668
|
-
|
|
669
|
-
type:
|
|
670
|
-
thinking:
|
|
664
|
+
z2.object({
|
|
665
|
+
type: z2.literal("thinking_delta"),
|
|
666
|
+
thinking: z2.string()
|
|
671
667
|
}),
|
|
672
|
-
|
|
673
|
-
type:
|
|
674
|
-
signature:
|
|
668
|
+
z2.object({
|
|
669
|
+
type: z2.literal("signature_delta"),
|
|
670
|
+
signature: z2.string()
|
|
675
671
|
}),
|
|
676
|
-
|
|
677
|
-
type:
|
|
678
|
-
content:
|
|
672
|
+
z2.object({
|
|
673
|
+
type: z2.literal("compaction_delta"),
|
|
674
|
+
content: z2.string().nullish()
|
|
679
675
|
}),
|
|
680
|
-
|
|
681
|
-
type:
|
|
682
|
-
citation:
|
|
683
|
-
|
|
684
|
-
type:
|
|
685
|
-
cited_text:
|
|
686
|
-
url:
|
|
687
|
-
title:
|
|
688
|
-
encrypted_index:
|
|
676
|
+
z2.object({
|
|
677
|
+
type: z2.literal("citations_delta"),
|
|
678
|
+
citation: z2.discriminatedUnion("type", [
|
|
679
|
+
z2.object({
|
|
680
|
+
type: z2.literal("web_search_result_location"),
|
|
681
|
+
cited_text: z2.string(),
|
|
682
|
+
url: z2.string(),
|
|
683
|
+
title: z2.string(),
|
|
684
|
+
encrypted_index: z2.string()
|
|
689
685
|
}),
|
|
690
|
-
|
|
691
|
-
type:
|
|
692
|
-
cited_text:
|
|
693
|
-
document_index:
|
|
694
|
-
document_title:
|
|
695
|
-
start_page_number:
|
|
696
|
-
end_page_number:
|
|
686
|
+
z2.object({
|
|
687
|
+
type: z2.literal("page_location"),
|
|
688
|
+
cited_text: z2.string(),
|
|
689
|
+
document_index: z2.number(),
|
|
690
|
+
document_title: z2.string().nullable(),
|
|
691
|
+
start_page_number: z2.number(),
|
|
692
|
+
end_page_number: z2.number()
|
|
697
693
|
}),
|
|
698
|
-
|
|
699
|
-
type:
|
|
700
|
-
cited_text:
|
|
701
|
-
document_index:
|
|
702
|
-
document_title:
|
|
703
|
-
start_char_index:
|
|
704
|
-
end_char_index:
|
|
694
|
+
z2.object({
|
|
695
|
+
type: z2.literal("char_location"),
|
|
696
|
+
cited_text: z2.string(),
|
|
697
|
+
document_index: z2.number(),
|
|
698
|
+
document_title: z2.string().nullable(),
|
|
699
|
+
start_char_index: z2.number(),
|
|
700
|
+
end_char_index: z2.number()
|
|
705
701
|
})
|
|
706
702
|
])
|
|
707
703
|
})
|
|
708
704
|
])
|
|
709
705
|
}),
|
|
710
|
-
|
|
711
|
-
type:
|
|
712
|
-
index:
|
|
706
|
+
z2.object({
|
|
707
|
+
type: z2.literal("content_block_stop"),
|
|
708
|
+
index: z2.number()
|
|
713
709
|
}),
|
|
714
|
-
|
|
715
|
-
type:
|
|
716
|
-
error:
|
|
717
|
-
type:
|
|
718
|
-
message:
|
|
710
|
+
z2.object({
|
|
711
|
+
type: z2.literal("error"),
|
|
712
|
+
error: z2.object({
|
|
713
|
+
type: z2.string(),
|
|
714
|
+
message: z2.string()
|
|
719
715
|
})
|
|
720
716
|
}),
|
|
721
|
-
|
|
722
|
-
type:
|
|
723
|
-
delta:
|
|
724
|
-
stop_reason:
|
|
725
|
-
stop_sequence:
|
|
726
|
-
container:
|
|
727
|
-
expires_at:
|
|
728
|
-
id:
|
|
729
|
-
skills:
|
|
730
|
-
|
|
731
|
-
type:
|
|
732
|
-
|
|
733
|
-
|
|
717
|
+
z2.object({
|
|
718
|
+
type: z2.literal("message_delta"),
|
|
719
|
+
delta: z2.object({
|
|
720
|
+
stop_reason: z2.string().nullish(),
|
|
721
|
+
stop_sequence: z2.string().nullish(),
|
|
722
|
+
container: z2.object({
|
|
723
|
+
expires_at: z2.string(),
|
|
724
|
+
id: z2.string(),
|
|
725
|
+
skills: z2.array(
|
|
726
|
+
z2.object({
|
|
727
|
+
type: z2.union([
|
|
728
|
+
z2.literal("anthropic"),
|
|
729
|
+
z2.literal("custom")
|
|
734
730
|
]),
|
|
735
|
-
skill_id:
|
|
736
|
-
version:
|
|
731
|
+
skill_id: z2.string(),
|
|
732
|
+
version: z2.string()
|
|
737
733
|
})
|
|
738
734
|
).nullish()
|
|
739
735
|
}).nullish()
|
|
740
736
|
}),
|
|
741
|
-
usage:
|
|
742
|
-
input_tokens:
|
|
743
|
-
output_tokens:
|
|
744
|
-
cache_creation_input_tokens:
|
|
745
|
-
cache_read_input_tokens:
|
|
746
|
-
iterations:
|
|
747
|
-
|
|
748
|
-
type:
|
|
749
|
-
input_tokens:
|
|
750
|
-
output_tokens:
|
|
737
|
+
usage: z2.looseObject({
|
|
738
|
+
input_tokens: z2.number().nullish(),
|
|
739
|
+
output_tokens: z2.number(),
|
|
740
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
741
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
742
|
+
iterations: z2.array(
|
|
743
|
+
z2.object({
|
|
744
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
745
|
+
input_tokens: z2.number(),
|
|
746
|
+
output_tokens: z2.number()
|
|
751
747
|
})
|
|
752
748
|
).nullish()
|
|
753
749
|
}),
|
|
754
|
-
context_management:
|
|
755
|
-
applied_edits:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
type:
|
|
759
|
-
cleared_tool_uses:
|
|
760
|
-
cleared_input_tokens:
|
|
750
|
+
context_management: z2.object({
|
|
751
|
+
applied_edits: z2.array(
|
|
752
|
+
z2.union([
|
|
753
|
+
z2.object({
|
|
754
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
755
|
+
cleared_tool_uses: z2.number(),
|
|
756
|
+
cleared_input_tokens: z2.number()
|
|
761
757
|
}),
|
|
762
|
-
|
|
763
|
-
type:
|
|
764
|
-
cleared_thinking_turns:
|
|
765
|
-
cleared_input_tokens:
|
|
758
|
+
z2.object({
|
|
759
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
760
|
+
cleared_thinking_turns: z2.number(),
|
|
761
|
+
cleared_input_tokens: z2.number()
|
|
766
762
|
}),
|
|
767
|
-
|
|
768
|
-
type:
|
|
763
|
+
z2.object({
|
|
764
|
+
type: z2.literal("compact_20260112")
|
|
769
765
|
})
|
|
770
766
|
])
|
|
771
767
|
)
|
|
772
768
|
}).nullish()
|
|
773
769
|
}),
|
|
774
|
-
|
|
775
|
-
type:
|
|
770
|
+
z2.object({
|
|
771
|
+
type: z2.literal("message_stop")
|
|
776
772
|
}),
|
|
777
|
-
|
|
778
|
-
type:
|
|
773
|
+
z2.object({
|
|
774
|
+
type: z2.literal("ping")
|
|
779
775
|
})
|
|
780
776
|
])
|
|
781
777
|
)
|
|
782
778
|
);
|
|
783
|
-
var anthropicReasoningMetadataSchema = (
|
|
784
|
-
() => (
|
|
785
|
-
|
|
786
|
-
signature:
|
|
787
|
-
redactedData:
|
|
779
|
+
var anthropicReasoningMetadataSchema = lazySchema2(
|
|
780
|
+
() => zodSchema2(
|
|
781
|
+
z2.object({
|
|
782
|
+
signature: z2.string().optional(),
|
|
783
|
+
redactedData: z2.string().optional()
|
|
788
784
|
})
|
|
789
785
|
)
|
|
790
786
|
);
|
|
791
787
|
|
|
792
|
-
// src/anthropic-
|
|
793
|
-
|
|
794
|
-
var anthropicFilePartProviderOptions =
|
|
788
|
+
// src/anthropic-language-model-options.ts
|
|
789
|
+
import { z as z3 } from "zod/v4";
|
|
790
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
795
791
|
/**
|
|
796
792
|
* Citation configuration for this document.
|
|
797
793
|
* When enabled, this document will generate citations in the response.
|
|
798
794
|
*/
|
|
799
|
-
citations:
|
|
795
|
+
citations: z3.object({
|
|
800
796
|
/**
|
|
801
797
|
* Enable citations for this document
|
|
802
798
|
*/
|
|
803
|
-
enabled:
|
|
799
|
+
enabled: z3.boolean()
|
|
804
800
|
}).optional(),
|
|
805
801
|
/**
|
|
806
802
|
* Custom title for the document.
|
|
807
803
|
* If not provided, the filename will be used.
|
|
808
804
|
*/
|
|
809
|
-
title:
|
|
805
|
+
title: z3.string().optional(),
|
|
810
806
|
/**
|
|
811
807
|
* Context about the document that will be passed to the model
|
|
812
808
|
* but not used towards cited content.
|
|
813
809
|
* Useful for storing document metadata as text or stringified JSON.
|
|
814
810
|
*/
|
|
815
|
-
context:
|
|
811
|
+
context: z3.string().optional()
|
|
816
812
|
});
|
|
817
|
-
var anthropicLanguageModelOptions =
|
|
813
|
+
var anthropicLanguageModelOptions = z3.object({
|
|
818
814
|
/**
|
|
819
815
|
* Whether to send reasoning to the model.
|
|
820
816
|
*
|
|
821
817
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
822
818
|
*/
|
|
823
|
-
sendReasoning:
|
|
819
|
+
sendReasoning: z3.boolean().optional(),
|
|
824
820
|
/**
|
|
825
821
|
* Determines how structured outputs are generated.
|
|
826
822
|
*
|
|
@@ -828,64 +824,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
828
824
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
829
825
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
830
826
|
*/
|
|
831
|
-
structuredOutputMode:
|
|
827
|
+
structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
832
828
|
/**
|
|
833
829
|
* Configuration for enabling Claude's extended thinking.
|
|
834
830
|
*
|
|
835
831
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
836
832
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
837
833
|
*/
|
|
838
|
-
thinking:
|
|
839
|
-
|
|
834
|
+
thinking: z3.discriminatedUnion("type", [
|
|
835
|
+
z3.object({
|
|
840
836
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
841
|
-
type:
|
|
837
|
+
type: z3.literal("adaptive"),
|
|
842
838
|
/**
|
|
843
|
-
* Controls thinking
|
|
844
|
-
* -
|
|
845
|
-
* -
|
|
839
|
+
* Controls whether thinking content is included in the response.
|
|
840
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
841
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
846
842
|
*/
|
|
847
|
-
display:
|
|
843
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
848
844
|
}),
|
|
849
|
-
|
|
845
|
+
z3.object({
|
|
850
846
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
851
|
-
type:
|
|
852
|
-
budgetTokens:
|
|
853
|
-
/**
|
|
854
|
-
* Controls thinking output visibility.
|
|
855
|
-
* - 'omitted': thinking happens but output is not returned (faster TTFT)
|
|
856
|
-
* - 'summarized': a summary of the thinking is returned
|
|
857
|
-
*/
|
|
858
|
-
display: import_v43.z.enum(["omitted", "summarized"]).optional()
|
|
847
|
+
type: z3.literal("enabled"),
|
|
848
|
+
budgetTokens: z3.number().optional()
|
|
859
849
|
}),
|
|
860
|
-
|
|
861
|
-
type:
|
|
850
|
+
z3.object({
|
|
851
|
+
type: z3.literal("disabled")
|
|
862
852
|
})
|
|
863
853
|
]).optional(),
|
|
864
854
|
/**
|
|
865
855
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
866
856
|
* When set to true, Claude will use at most one tool per response.
|
|
867
857
|
*/
|
|
868
|
-
disableParallelToolUse:
|
|
858
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
869
859
|
/**
|
|
870
860
|
* Cache control settings for this message.
|
|
871
861
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
872
862
|
*/
|
|
873
|
-
cacheControl:
|
|
874
|
-
type:
|
|
875
|
-
ttl:
|
|
863
|
+
cacheControl: z3.object({
|
|
864
|
+
type: z3.literal("ephemeral"),
|
|
865
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
866
|
+
}).optional(),
|
|
867
|
+
/**
|
|
868
|
+
* Metadata to include with the request.
|
|
869
|
+
*
|
|
870
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
871
|
+
*/
|
|
872
|
+
metadata: z3.object({
|
|
873
|
+
/**
|
|
874
|
+
* An external identifier for the user associated with the request.
|
|
875
|
+
*
|
|
876
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
877
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
878
|
+
*/
|
|
879
|
+
userId: z3.string().optional()
|
|
876
880
|
}).optional(),
|
|
877
881
|
/**
|
|
878
882
|
* MCP servers to be utilized in this request.
|
|
879
883
|
*/
|
|
880
|
-
mcpServers:
|
|
881
|
-
|
|
882
|
-
type:
|
|
883
|
-
name:
|
|
884
|
-
url:
|
|
885
|
-
authorizationToken:
|
|
886
|
-
toolConfiguration:
|
|
887
|
-
enabled:
|
|
888
|
-
allowedTools:
|
|
884
|
+
mcpServers: z3.array(
|
|
885
|
+
z3.object({
|
|
886
|
+
type: z3.literal("url"),
|
|
887
|
+
name: z3.string(),
|
|
888
|
+
url: z3.string(),
|
|
889
|
+
authorizationToken: z3.string().nullish(),
|
|
890
|
+
toolConfiguration: z3.object({
|
|
891
|
+
enabled: z3.boolean().nullish(),
|
|
892
|
+
allowedTools: z3.array(z3.string()).nullish()
|
|
889
893
|
}).nullish()
|
|
890
894
|
})
|
|
891
895
|
).optional(),
|
|
@@ -894,105 +898,129 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
894
898
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
895
899
|
* Requires code execution tool to be enabled.
|
|
896
900
|
*/
|
|
897
|
-
container:
|
|
898
|
-
id:
|
|
899
|
-
skills:
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
901
|
+
container: z3.object({
|
|
902
|
+
id: z3.string().optional(),
|
|
903
|
+
skills: z3.array(
|
|
904
|
+
z3.discriminatedUnion("type", [
|
|
905
|
+
z3.object({
|
|
906
|
+
type: z3.literal("anthropic"),
|
|
907
|
+
skillId: z3.string(),
|
|
908
|
+
version: z3.string().optional()
|
|
909
|
+
}),
|
|
910
|
+
z3.object({
|
|
911
|
+
type: z3.literal("custom"),
|
|
912
|
+
providerReference: z3.record(z3.string(), z3.string()),
|
|
913
|
+
version: z3.string().optional()
|
|
914
|
+
})
|
|
915
|
+
])
|
|
905
916
|
).optional()
|
|
906
917
|
}).optional(),
|
|
907
918
|
/**
|
|
908
|
-
* Whether to enable
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
919
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
920
|
+
* and structured outputs for every function tool in the request. When
|
|
921
|
+
* true (the default), each function tool receives a default of
|
|
922
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
923
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
912
924
|
*
|
|
913
925
|
* @default true
|
|
914
926
|
*/
|
|
915
|
-
toolStreaming:
|
|
927
|
+
toolStreaming: z3.boolean().optional(),
|
|
916
928
|
/**
|
|
917
929
|
* @default 'high'
|
|
918
930
|
*/
|
|
919
|
-
effort:
|
|
931
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
932
|
+
/**
|
|
933
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
934
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
935
|
+
* gracefully as the budget is consumed.
|
|
936
|
+
*
|
|
937
|
+
* Advisory only — does not enforce a hard token limit.
|
|
938
|
+
*/
|
|
939
|
+
taskBudget: z3.object({
|
|
940
|
+
type: z3.literal("tokens"),
|
|
941
|
+
total: z3.number().int().min(2e4),
|
|
942
|
+
remaining: z3.number().int().min(0).optional()
|
|
943
|
+
}).optional(),
|
|
920
944
|
/**
|
|
921
945
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
922
946
|
* Only supported with claude-opus-4-6.
|
|
923
947
|
*/
|
|
924
|
-
speed:
|
|
948
|
+
speed: z3.enum(["fast", "standard"]).optional(),
|
|
925
949
|
/**
|
|
926
|
-
*
|
|
927
|
-
*
|
|
950
|
+
* Advisor tool configuration. When enabled, Claude consults a cheaper
|
|
951
|
+
* advisor model before generating its response, improving tool-use
|
|
952
|
+
* accuracy and reducing cost on complex agentic tasks.
|
|
953
|
+
*
|
|
954
|
+
* Requires the `advisor-tool-2026-03-01` beta header (added automatically).
|
|
928
955
|
*/
|
|
929
|
-
|
|
956
|
+
advisor: z3.object({
|
|
957
|
+
/** The model ID for the advisor (e.g. "claude-haiku-4-5"). */
|
|
958
|
+
model: z3.string()
|
|
959
|
+
}).optional(),
|
|
930
960
|
/**
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
* Example: Setting prefill to '{"' will make the model start its response with '{"'
|
|
961
|
+
* Enable 300K output tokens per response (vs default ~8K/32K caps).
|
|
962
|
+
* When true, the `output-300k-2026-03-24` beta header is sent automatically
|
|
963
|
+
* and max_tokens capping is raised to 300,000.
|
|
936
964
|
*/
|
|
937
|
-
|
|
965
|
+
output300k: z3.boolean().optional(),
|
|
938
966
|
/**
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
967
|
+
* Controls where model inference runs for this request.
|
|
968
|
+
*
|
|
969
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
970
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
971
|
+
*
|
|
972
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
942
973
|
*/
|
|
943
|
-
|
|
944
|
-
userId: import_v43.z.string().optional()
|
|
945
|
-
}).optional(),
|
|
974
|
+
inferenceGeo: z3.enum(["us", "global"]).optional(),
|
|
946
975
|
/**
|
|
947
|
-
*
|
|
948
|
-
*
|
|
949
|
-
* See https://docs.anthropic.com/en/api/messages
|
|
976
|
+
* A set of beta features to enable.
|
|
977
|
+
* Allow a provider to receive the full `betas` set if it needs it.
|
|
950
978
|
*/
|
|
951
|
-
|
|
952
|
-
contextManagement:
|
|
953
|
-
edits:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
trigger:
|
|
958
|
-
|
|
959
|
-
type:
|
|
960
|
-
value:
|
|
979
|
+
anthropicBeta: z3.array(z3.string()).optional(),
|
|
980
|
+
contextManagement: z3.object({
|
|
981
|
+
edits: z3.array(
|
|
982
|
+
z3.discriminatedUnion("type", [
|
|
983
|
+
z3.object({
|
|
984
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
985
|
+
trigger: z3.discriminatedUnion("type", [
|
|
986
|
+
z3.object({
|
|
987
|
+
type: z3.literal("input_tokens"),
|
|
988
|
+
value: z3.number()
|
|
961
989
|
}),
|
|
962
|
-
|
|
963
|
-
type:
|
|
964
|
-
value:
|
|
990
|
+
z3.object({
|
|
991
|
+
type: z3.literal("tool_uses"),
|
|
992
|
+
value: z3.number()
|
|
965
993
|
})
|
|
966
994
|
]).optional(),
|
|
967
|
-
keep:
|
|
968
|
-
type:
|
|
969
|
-
value:
|
|
995
|
+
keep: z3.object({
|
|
996
|
+
type: z3.literal("tool_uses"),
|
|
997
|
+
value: z3.number()
|
|
970
998
|
}).optional(),
|
|
971
|
-
clearAtLeast:
|
|
972
|
-
type:
|
|
973
|
-
value:
|
|
999
|
+
clearAtLeast: z3.object({
|
|
1000
|
+
type: z3.literal("input_tokens"),
|
|
1001
|
+
value: z3.number()
|
|
974
1002
|
}).optional(),
|
|
975
|
-
clearToolInputs:
|
|
976
|
-
excludeTools:
|
|
1003
|
+
clearToolInputs: z3.boolean().optional(),
|
|
1004
|
+
excludeTools: z3.array(z3.string()).optional()
|
|
977
1005
|
}),
|
|
978
|
-
|
|
979
|
-
type:
|
|
980
|
-
keep:
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
type:
|
|
984
|
-
value:
|
|
1006
|
+
z3.object({
|
|
1007
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
1008
|
+
keep: z3.union([
|
|
1009
|
+
z3.literal("all"),
|
|
1010
|
+
z3.object({
|
|
1011
|
+
type: z3.literal("thinking_turns"),
|
|
1012
|
+
value: z3.number()
|
|
985
1013
|
})
|
|
986
1014
|
]).optional()
|
|
987
1015
|
}),
|
|
988
|
-
|
|
989
|
-
type:
|
|
990
|
-
trigger:
|
|
991
|
-
type:
|
|
992
|
-
value:
|
|
1016
|
+
z3.object({
|
|
1017
|
+
type: z3.literal("compact_20260112"),
|
|
1018
|
+
trigger: z3.object({
|
|
1019
|
+
type: z3.literal("input_tokens"),
|
|
1020
|
+
value: z3.number()
|
|
993
1021
|
}).optional(),
|
|
994
|
-
pauseAfterCompaction:
|
|
995
|
-
instructions:
|
|
1022
|
+
pauseAfterCompaction: z3.boolean().optional(),
|
|
1023
|
+
instructions: z3.string().optional()
|
|
996
1024
|
})
|
|
997
1025
|
])
|
|
998
1026
|
)
|
|
@@ -1000,7 +1028,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
1000
1028
|
});
|
|
1001
1029
|
|
|
1002
1030
|
// src/anthropic-prepare-tools.ts
|
|
1003
|
-
|
|
1031
|
+
import {
|
|
1032
|
+
UnsupportedFunctionalityError
|
|
1033
|
+
} from "@ai-sdk/provider";
|
|
1004
1034
|
|
|
1005
1035
|
// src/get-cache-control.ts
|
|
1006
1036
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1045,31 +1075,34 @@ var CacheControlValidator = class {
|
|
|
1045
1075
|
};
|
|
1046
1076
|
|
|
1047
1077
|
// src/tool/text-editor_20250728.ts
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1078
|
+
import {
|
|
1079
|
+
createProviderDefinedToolFactory,
|
|
1080
|
+
lazySchema as lazySchema3,
|
|
1081
|
+
zodSchema as zodSchema3
|
|
1082
|
+
} from "@ai-sdk/provider-utils";
|
|
1083
|
+
import { z as z4 } from "zod/v4";
|
|
1084
|
+
var textEditor_20250728ArgsSchema = lazySchema3(
|
|
1085
|
+
() => zodSchema3(
|
|
1086
|
+
z4.object({
|
|
1087
|
+
maxCharacters: z4.number().optional()
|
|
1055
1088
|
})
|
|
1056
1089
|
)
|
|
1057
1090
|
);
|
|
1058
|
-
var textEditor_20250728InputSchema = (
|
|
1059
|
-
() => (
|
|
1060
|
-
|
|
1061
|
-
command:
|
|
1062
|
-
path:
|
|
1063
|
-
file_text:
|
|
1064
|
-
insert_line:
|
|
1065
|
-
new_str:
|
|
1066
|
-
insert_text:
|
|
1067
|
-
old_str:
|
|
1068
|
-
view_range:
|
|
1091
|
+
var textEditor_20250728InputSchema = lazySchema3(
|
|
1092
|
+
() => zodSchema3(
|
|
1093
|
+
z4.object({
|
|
1094
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
1095
|
+
path: z4.string(),
|
|
1096
|
+
file_text: z4.string().optional(),
|
|
1097
|
+
insert_line: z4.number().int().optional(),
|
|
1098
|
+
new_str: z4.string().optional(),
|
|
1099
|
+
insert_text: z4.string().optional(),
|
|
1100
|
+
old_str: z4.string().optional(),
|
|
1101
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
1069
1102
|
})
|
|
1070
1103
|
)
|
|
1071
1104
|
);
|
|
1072
|
-
var factory = (
|
|
1105
|
+
var factory = createProviderDefinedToolFactory({
|
|
1073
1106
|
id: "anthropic.text_editor_20250728",
|
|
1074
1107
|
inputSchema: textEditor_20250728InputSchema
|
|
1075
1108
|
});
|
|
@@ -1078,45 +1111,56 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1078
1111
|
};
|
|
1079
1112
|
|
|
1080
1113
|
// src/tool/web-search_20260209.ts
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1114
|
+
import {
|
|
1115
|
+
createProviderExecutedToolFactory,
|
|
1116
|
+
lazySchema as lazySchema4,
|
|
1117
|
+
zodSchema as zodSchema4
|
|
1118
|
+
} from "@ai-sdk/provider-utils";
|
|
1119
|
+
import { z as z5 } from "zod/v4";
|
|
1120
|
+
var webSearch_20260209ArgsSchema = lazySchema4(
|
|
1121
|
+
() => zodSchema4(
|
|
1122
|
+
z5.object({
|
|
1123
|
+
maxUses: z5.number().optional(),
|
|
1124
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
1125
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
1126
|
+
userLocation: z5.object({
|
|
1127
|
+
type: z5.literal("approximate"),
|
|
1128
|
+
city: z5.string().optional(),
|
|
1129
|
+
region: z5.string().optional(),
|
|
1130
|
+
country: z5.string().optional(),
|
|
1131
|
+
timezone: z5.string().optional()
|
|
1132
|
+
}).optional(),
|
|
1133
|
+
allowedCallers: z5.array(
|
|
1134
|
+
z5.enum([
|
|
1135
|
+
"direct",
|
|
1136
|
+
"code_execution_20250825",
|
|
1137
|
+
"code_execution_20260120"
|
|
1138
|
+
])
|
|
1139
|
+
).optional()
|
|
1096
1140
|
})
|
|
1097
1141
|
)
|
|
1098
1142
|
);
|
|
1099
|
-
var webSearch_20260209OutputSchema = (
|
|
1100
|
-
() => (
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
url:
|
|
1104
|
-
title:
|
|
1105
|
-
pageAge:
|
|
1106
|
-
encryptedContent:
|
|
1107
|
-
type:
|
|
1143
|
+
var webSearch_20260209OutputSchema = lazySchema4(
|
|
1144
|
+
() => zodSchema4(
|
|
1145
|
+
z5.array(
|
|
1146
|
+
z5.object({
|
|
1147
|
+
url: z5.string(),
|
|
1148
|
+
title: z5.string().nullable(),
|
|
1149
|
+
pageAge: z5.string().nullable(),
|
|
1150
|
+
encryptedContent: z5.string(),
|
|
1151
|
+
type: z5.literal("web_search_result")
|
|
1108
1152
|
})
|
|
1109
1153
|
)
|
|
1110
1154
|
)
|
|
1111
1155
|
);
|
|
1112
|
-
var webSearch_20260209InputSchema = (
|
|
1113
|
-
() => (
|
|
1114
|
-
|
|
1115
|
-
query:
|
|
1156
|
+
var webSearch_20260209InputSchema = lazySchema4(
|
|
1157
|
+
() => zodSchema4(
|
|
1158
|
+
z5.object({
|
|
1159
|
+
query: z5.string()
|
|
1116
1160
|
})
|
|
1117
1161
|
)
|
|
1118
1162
|
);
|
|
1119
|
-
var factory2 = (
|
|
1163
|
+
var factory2 = createProviderExecutedToolFactory({
|
|
1120
1164
|
id: "anthropic.web_search_20260209",
|
|
1121
1165
|
inputSchema: webSearch_20260209InputSchema,
|
|
1122
1166
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1127,45 +1171,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1127
1171
|
};
|
|
1128
1172
|
|
|
1129
1173
|
// src/tool/web-search_20250305.ts
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1174
|
+
import {
|
|
1175
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
1176
|
+
lazySchema as lazySchema5,
|
|
1177
|
+
zodSchema as zodSchema5
|
|
1178
|
+
} from "@ai-sdk/provider-utils";
|
|
1179
|
+
import { z as z6 } from "zod/v4";
|
|
1180
|
+
var webSearch_20250305ArgsSchema = lazySchema5(
|
|
1181
|
+
() => zodSchema5(
|
|
1182
|
+
z6.object({
|
|
1183
|
+
maxUses: z6.number().optional(),
|
|
1184
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1185
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1186
|
+
userLocation: z6.object({
|
|
1187
|
+
type: z6.literal("approximate"),
|
|
1188
|
+
city: z6.string().optional(),
|
|
1189
|
+
region: z6.string().optional(),
|
|
1190
|
+
country: z6.string().optional(),
|
|
1191
|
+
timezone: z6.string().optional()
|
|
1144
1192
|
}).optional()
|
|
1145
1193
|
})
|
|
1146
1194
|
)
|
|
1147
1195
|
);
|
|
1148
|
-
var webSearch_20250305OutputSchema = (
|
|
1149
|
-
() => (
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
url:
|
|
1153
|
-
title:
|
|
1154
|
-
pageAge:
|
|
1155
|
-
encryptedContent:
|
|
1156
|
-
type:
|
|
1196
|
+
var webSearch_20250305OutputSchema = lazySchema5(
|
|
1197
|
+
() => zodSchema5(
|
|
1198
|
+
z6.array(
|
|
1199
|
+
z6.object({
|
|
1200
|
+
url: z6.string(),
|
|
1201
|
+
title: z6.string().nullable(),
|
|
1202
|
+
pageAge: z6.string().nullable(),
|
|
1203
|
+
encryptedContent: z6.string(),
|
|
1204
|
+
type: z6.literal("web_search_result")
|
|
1157
1205
|
})
|
|
1158
1206
|
)
|
|
1159
1207
|
)
|
|
1160
1208
|
);
|
|
1161
|
-
var webSearch_20250305InputSchema = (
|
|
1162
|
-
() => (
|
|
1163
|
-
|
|
1164
|
-
query:
|
|
1209
|
+
var webSearch_20250305InputSchema = lazySchema5(
|
|
1210
|
+
() => zodSchema5(
|
|
1211
|
+
z6.object({
|
|
1212
|
+
query: z6.string()
|
|
1165
1213
|
})
|
|
1166
1214
|
)
|
|
1167
1215
|
);
|
|
1168
|
-
var factory3 = (
|
|
1216
|
+
var factory3 = createProviderExecutedToolFactory2({
|
|
1169
1217
|
id: "anthropic.web_search_20250305",
|
|
1170
1218
|
inputSchema: webSearch_20250305InputSchema,
|
|
1171
1219
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1175,131 +1223,210 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1175
1223
|
return factory3(args);
|
|
1176
1224
|
};
|
|
1177
1225
|
|
|
1226
|
+
// src/tool/web-fetch-20260309.ts
|
|
1227
|
+
import {
|
|
1228
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
1229
|
+
lazySchema as lazySchema6,
|
|
1230
|
+
zodSchema as zodSchema6
|
|
1231
|
+
} from "@ai-sdk/provider-utils";
|
|
1232
|
+
import { z as z7 } from "zod/v4";
|
|
1233
|
+
var webFetch_20260309ArgsSchema = lazySchema6(
|
|
1234
|
+
() => zodSchema6(
|
|
1235
|
+
z7.object({
|
|
1236
|
+
maxUses: z7.number().optional(),
|
|
1237
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1238
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1239
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1240
|
+
maxContentTokens: z7.number().optional(),
|
|
1241
|
+
allowedCallers: z7.array(
|
|
1242
|
+
z7.enum([
|
|
1243
|
+
"direct",
|
|
1244
|
+
"code_execution_20250825",
|
|
1245
|
+
"code_execution_20260120"
|
|
1246
|
+
])
|
|
1247
|
+
).optional(),
|
|
1248
|
+
useCache: z7.boolean().optional(),
|
|
1249
|
+
deferLoading: z7.boolean().optional(),
|
|
1250
|
+
strict: z7.boolean().optional()
|
|
1251
|
+
})
|
|
1252
|
+
)
|
|
1253
|
+
);
|
|
1254
|
+
var webFetch_20260309OutputSchema = lazySchema6(
|
|
1255
|
+
() => zodSchema6(
|
|
1256
|
+
z7.object({
|
|
1257
|
+
type: z7.literal("web_fetch_result"),
|
|
1258
|
+
url: z7.string(),
|
|
1259
|
+
content: z7.object({
|
|
1260
|
+
type: z7.literal("document"),
|
|
1261
|
+
title: z7.string().nullable(),
|
|
1262
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1263
|
+
source: z7.union([
|
|
1264
|
+
z7.object({
|
|
1265
|
+
type: z7.literal("base64"),
|
|
1266
|
+
mediaType: z7.literal("application/pdf"),
|
|
1267
|
+
data: z7.string()
|
|
1268
|
+
}),
|
|
1269
|
+
z7.object({
|
|
1270
|
+
type: z7.literal("text"),
|
|
1271
|
+
mediaType: z7.literal("text/plain"),
|
|
1272
|
+
data: z7.string()
|
|
1273
|
+
})
|
|
1274
|
+
])
|
|
1275
|
+
}),
|
|
1276
|
+
retrievedAt: z7.string().nullable()
|
|
1277
|
+
})
|
|
1278
|
+
)
|
|
1279
|
+
);
|
|
1280
|
+
var webFetch_20260309InputSchema = lazySchema6(
|
|
1281
|
+
() => zodSchema6(
|
|
1282
|
+
z7.object({
|
|
1283
|
+
url: z7.string()
|
|
1284
|
+
})
|
|
1285
|
+
)
|
|
1286
|
+
);
|
|
1287
|
+
var factory4 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
1288
|
+
id: "anthropic.web_fetch_20260309",
|
|
1289
|
+
inputSchema: webFetch_20260309InputSchema,
|
|
1290
|
+
outputSchema: webFetch_20260309OutputSchema
|
|
1291
|
+
});
|
|
1292
|
+
var webFetch_20260309 = (args = {}) => {
|
|
1293
|
+
return factory4(args);
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1178
1296
|
// src/tool/web-fetch-20260209.ts
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1297
|
+
import {
|
|
1298
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
1299
|
+
lazySchema as lazySchema7,
|
|
1300
|
+
zodSchema as zodSchema7
|
|
1301
|
+
} from "@ai-sdk/provider-utils";
|
|
1302
|
+
import { z as z8 } from "zod/v4";
|
|
1303
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1304
|
+
() => zodSchema7(
|
|
1305
|
+
z8.object({
|
|
1306
|
+
maxUses: z8.number().optional(),
|
|
1307
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1308
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1309
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1310
|
+
maxContentTokens: z8.number().optional()
|
|
1189
1311
|
})
|
|
1190
1312
|
)
|
|
1191
1313
|
);
|
|
1192
|
-
var webFetch_20260209OutputSchema = (
|
|
1193
|
-
() => (
|
|
1194
|
-
|
|
1195
|
-
type:
|
|
1196
|
-
url:
|
|
1197
|
-
content:
|
|
1198
|
-
type:
|
|
1199
|
-
title:
|
|
1200
|
-
citations:
|
|
1201
|
-
source:
|
|
1202
|
-
|
|
1203
|
-
type:
|
|
1204
|
-
mediaType:
|
|
1205
|
-
data:
|
|
1314
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1315
|
+
() => zodSchema7(
|
|
1316
|
+
z8.object({
|
|
1317
|
+
type: z8.literal("web_fetch_result"),
|
|
1318
|
+
url: z8.string(),
|
|
1319
|
+
content: z8.object({
|
|
1320
|
+
type: z8.literal("document"),
|
|
1321
|
+
title: z8.string().nullable(),
|
|
1322
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1323
|
+
source: z8.union([
|
|
1324
|
+
z8.object({
|
|
1325
|
+
type: z8.literal("base64"),
|
|
1326
|
+
mediaType: z8.literal("application/pdf"),
|
|
1327
|
+
data: z8.string()
|
|
1206
1328
|
}),
|
|
1207
|
-
|
|
1208
|
-
type:
|
|
1209
|
-
mediaType:
|
|
1210
|
-
data:
|
|
1329
|
+
z8.object({
|
|
1330
|
+
type: z8.literal("text"),
|
|
1331
|
+
mediaType: z8.literal("text/plain"),
|
|
1332
|
+
data: z8.string()
|
|
1211
1333
|
})
|
|
1212
1334
|
])
|
|
1213
1335
|
}),
|
|
1214
|
-
retrievedAt:
|
|
1336
|
+
retrievedAt: z8.string().nullable()
|
|
1215
1337
|
})
|
|
1216
1338
|
)
|
|
1217
1339
|
);
|
|
1218
|
-
var webFetch_20260209InputSchema = (
|
|
1219
|
-
() => (
|
|
1220
|
-
|
|
1221
|
-
url:
|
|
1340
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1341
|
+
() => zodSchema7(
|
|
1342
|
+
z8.object({
|
|
1343
|
+
url: z8.string()
|
|
1222
1344
|
})
|
|
1223
1345
|
)
|
|
1224
1346
|
);
|
|
1225
|
-
var
|
|
1347
|
+
var factory5 = createProviderExecutedToolFactory3({
|
|
1226
1348
|
id: "anthropic.web_fetch_20260209",
|
|
1227
1349
|
inputSchema: webFetch_20260209InputSchema,
|
|
1228
1350
|
outputSchema: webFetch_20260209OutputSchema,
|
|
1229
1351
|
supportsDeferredResults: true
|
|
1230
1352
|
});
|
|
1231
1353
|
var webFetch_20260209 = (args = {}) => {
|
|
1232
|
-
return
|
|
1354
|
+
return factory5(args);
|
|
1233
1355
|
};
|
|
1234
1356
|
|
|
1235
1357
|
// src/tool/web-fetch-20250910.ts
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1358
|
+
import {
|
|
1359
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
1360
|
+
lazySchema as lazySchema8,
|
|
1361
|
+
zodSchema as zodSchema8
|
|
1362
|
+
} from "@ai-sdk/provider-utils";
|
|
1363
|
+
import { z as z9 } from "zod/v4";
|
|
1364
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1365
|
+
() => zodSchema8(
|
|
1366
|
+
z9.object({
|
|
1367
|
+
maxUses: z9.number().optional(),
|
|
1368
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1369
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1370
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1371
|
+
maxContentTokens: z9.number().optional()
|
|
1246
1372
|
})
|
|
1247
1373
|
)
|
|
1248
1374
|
);
|
|
1249
|
-
var webFetch_20250910OutputSchema = (
|
|
1250
|
-
() => (
|
|
1251
|
-
|
|
1252
|
-
type:
|
|
1253
|
-
url:
|
|
1254
|
-
content:
|
|
1255
|
-
type:
|
|
1256
|
-
title:
|
|
1257
|
-
citations:
|
|
1258
|
-
source:
|
|
1259
|
-
|
|
1260
|
-
type:
|
|
1261
|
-
mediaType:
|
|
1262
|
-
data:
|
|
1375
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1376
|
+
() => zodSchema8(
|
|
1377
|
+
z9.object({
|
|
1378
|
+
type: z9.literal("web_fetch_result"),
|
|
1379
|
+
url: z9.string(),
|
|
1380
|
+
content: z9.object({
|
|
1381
|
+
type: z9.literal("document"),
|
|
1382
|
+
title: z9.string().nullable(),
|
|
1383
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1384
|
+
source: z9.union([
|
|
1385
|
+
z9.object({
|
|
1386
|
+
type: z9.literal("base64"),
|
|
1387
|
+
mediaType: z9.literal("application/pdf"),
|
|
1388
|
+
data: z9.string()
|
|
1263
1389
|
}),
|
|
1264
|
-
|
|
1265
|
-
type:
|
|
1266
|
-
mediaType:
|
|
1267
|
-
data:
|
|
1390
|
+
z9.object({
|
|
1391
|
+
type: z9.literal("text"),
|
|
1392
|
+
mediaType: z9.literal("text/plain"),
|
|
1393
|
+
data: z9.string()
|
|
1268
1394
|
})
|
|
1269
1395
|
])
|
|
1270
1396
|
}),
|
|
1271
|
-
retrievedAt:
|
|
1397
|
+
retrievedAt: z9.string().nullable()
|
|
1272
1398
|
})
|
|
1273
1399
|
)
|
|
1274
1400
|
);
|
|
1275
|
-
var webFetch_20250910InputSchema = (
|
|
1276
|
-
() => (
|
|
1277
|
-
|
|
1278
|
-
url:
|
|
1401
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1402
|
+
() => zodSchema8(
|
|
1403
|
+
z9.object({
|
|
1404
|
+
url: z9.string()
|
|
1279
1405
|
})
|
|
1280
1406
|
)
|
|
1281
1407
|
);
|
|
1282
|
-
var
|
|
1408
|
+
var factory6 = createProviderExecutedToolFactory4({
|
|
1283
1409
|
id: "anthropic.web_fetch_20250910",
|
|
1284
1410
|
inputSchema: webFetch_20250910InputSchema,
|
|
1285
1411
|
outputSchema: webFetch_20250910OutputSchema,
|
|
1286
1412
|
supportsDeferredResults: true
|
|
1287
1413
|
});
|
|
1288
1414
|
var webFetch_20250910 = (args = {}) => {
|
|
1289
|
-
return
|
|
1415
|
+
return factory6(args);
|
|
1290
1416
|
};
|
|
1291
1417
|
|
|
1292
1418
|
// src/anthropic-prepare-tools.ts
|
|
1293
|
-
|
|
1419
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1294
1420
|
async function prepareTools({
|
|
1295
1421
|
tools,
|
|
1296
1422
|
toolChoice,
|
|
1297
1423
|
disableParallelToolUse,
|
|
1298
1424
|
cacheControlValidator,
|
|
1299
1425
|
supportsStructuredOutput,
|
|
1300
|
-
supportsStrictTools
|
|
1426
|
+
supportsStrictTools,
|
|
1427
|
+
defaultEagerInputStreaming = false
|
|
1301
1428
|
}) {
|
|
1302
|
-
var _a;
|
|
1429
|
+
var _a, _b, _c;
|
|
1303
1430
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1304
1431
|
const toolWarnings = [];
|
|
1305
1432
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1316,7 +1443,7 @@ async function prepareTools({
|
|
|
1316
1443
|
canCache: true
|
|
1317
1444
|
});
|
|
1318
1445
|
const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1319
|
-
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1446
|
+
const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
|
|
1320
1447
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1321
1448
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1322
1449
|
if (!supportsStrictTools && tool.strict != null) {
|
|
@@ -1350,28 +1477,33 @@ async function prepareTools({
|
|
|
1350
1477
|
break;
|
|
1351
1478
|
}
|
|
1352
1479
|
case "provider": {
|
|
1480
|
+
const providerCacheControl = (_c = validator.getCacheControl(tool.providerOptions, {
|
|
1481
|
+
type: "tool definition",
|
|
1482
|
+
canCache: true
|
|
1483
|
+
})) != null ? _c : void 0;
|
|
1353
1484
|
switch (tool.id) {
|
|
1354
1485
|
case "anthropic.code_execution_20250522": {
|
|
1355
1486
|
betas.add("code-execution-2025-05-22");
|
|
1356
1487
|
anthropicTools2.push({
|
|
1357
1488
|
type: "code_execution_20250522",
|
|
1358
1489
|
name: "code_execution",
|
|
1359
|
-
cache_control:
|
|
1490
|
+
cache_control: providerCacheControl
|
|
1360
1491
|
});
|
|
1361
1492
|
break;
|
|
1362
1493
|
}
|
|
1363
1494
|
case "anthropic.code_execution_20250825": {
|
|
1364
|
-
betas.add("code-execution-2025-08-25");
|
|
1365
1495
|
anthropicTools2.push({
|
|
1366
1496
|
type: "code_execution_20250825",
|
|
1367
|
-
name: "code_execution"
|
|
1497
|
+
name: "code_execution",
|
|
1498
|
+
cache_control: providerCacheControl
|
|
1368
1499
|
});
|
|
1369
1500
|
break;
|
|
1370
1501
|
}
|
|
1371
1502
|
case "anthropic.code_execution_20260120": {
|
|
1372
1503
|
anthropicTools2.push({
|
|
1373
1504
|
type: "code_execution_20260120",
|
|
1374
|
-
name: "code_execution"
|
|
1505
|
+
name: "code_execution",
|
|
1506
|
+
cache_control: providerCacheControl
|
|
1375
1507
|
});
|
|
1376
1508
|
break;
|
|
1377
1509
|
}
|
|
@@ -1383,7 +1515,7 @@ async function prepareTools({
|
|
|
1383
1515
|
display_width_px: tool.args.displayWidthPx,
|
|
1384
1516
|
display_height_px: tool.args.displayHeightPx,
|
|
1385
1517
|
display_number: tool.args.displayNumber,
|
|
1386
|
-
cache_control:
|
|
1518
|
+
cache_control: providerCacheControl
|
|
1387
1519
|
});
|
|
1388
1520
|
break;
|
|
1389
1521
|
}
|
|
@@ -1396,7 +1528,7 @@ async function prepareTools({
|
|
|
1396
1528
|
display_height_px: tool.args.displayHeightPx,
|
|
1397
1529
|
display_number: tool.args.displayNumber,
|
|
1398
1530
|
enable_zoom: tool.args.enableZoom,
|
|
1399
|
-
cache_control:
|
|
1531
|
+
cache_control: providerCacheControl
|
|
1400
1532
|
});
|
|
1401
1533
|
break;
|
|
1402
1534
|
}
|
|
@@ -1408,7 +1540,7 @@ async function prepareTools({
|
|
|
1408
1540
|
display_width_px: tool.args.displayWidthPx,
|
|
1409
1541
|
display_height_px: tool.args.displayHeightPx,
|
|
1410
1542
|
display_number: tool.args.displayNumber,
|
|
1411
|
-
cache_control:
|
|
1543
|
+
cache_control: providerCacheControl
|
|
1412
1544
|
});
|
|
1413
1545
|
break;
|
|
1414
1546
|
}
|
|
@@ -1417,7 +1549,7 @@ async function prepareTools({
|
|
|
1417
1549
|
anthropicTools2.push({
|
|
1418
1550
|
name: "str_replace_editor",
|
|
1419
1551
|
type: "text_editor_20250124",
|
|
1420
|
-
cache_control:
|
|
1552
|
+
cache_control: providerCacheControl
|
|
1421
1553
|
});
|
|
1422
1554
|
break;
|
|
1423
1555
|
}
|
|
@@ -1426,7 +1558,7 @@ async function prepareTools({
|
|
|
1426
1558
|
anthropicTools2.push({
|
|
1427
1559
|
name: "str_replace_editor",
|
|
1428
1560
|
type: "text_editor_20241022",
|
|
1429
|
-
cache_control:
|
|
1561
|
+
cache_control: providerCacheControl
|
|
1430
1562
|
});
|
|
1431
1563
|
break;
|
|
1432
1564
|
}
|
|
@@ -1435,12 +1567,12 @@ async function prepareTools({
|
|
|
1435
1567
|
anthropicTools2.push({
|
|
1436
1568
|
name: "str_replace_based_edit_tool",
|
|
1437
1569
|
type: "text_editor_20250429",
|
|
1438
|
-
cache_control:
|
|
1570
|
+
cache_control: providerCacheControl
|
|
1439
1571
|
});
|
|
1440
1572
|
break;
|
|
1441
1573
|
}
|
|
1442
1574
|
case "anthropic.text_editor_20250728": {
|
|
1443
|
-
const args = await
|
|
1575
|
+
const args = await validateTypes({
|
|
1444
1576
|
value: tool.args,
|
|
1445
1577
|
schema: textEditor_20250728ArgsSchema
|
|
1446
1578
|
});
|
|
@@ -1448,7 +1580,7 @@ async function prepareTools({
|
|
|
1448
1580
|
name: "str_replace_based_edit_tool",
|
|
1449
1581
|
type: "text_editor_20250728",
|
|
1450
1582
|
max_characters: args.maxCharacters,
|
|
1451
|
-
cache_control:
|
|
1583
|
+
cache_control: providerCacheControl
|
|
1452
1584
|
});
|
|
1453
1585
|
break;
|
|
1454
1586
|
}
|
|
@@ -1457,7 +1589,7 @@ async function prepareTools({
|
|
|
1457
1589
|
anthropicTools2.push({
|
|
1458
1590
|
name: "bash",
|
|
1459
1591
|
type: "bash_20250124",
|
|
1460
|
-
cache_control:
|
|
1592
|
+
cache_control: providerCacheControl
|
|
1461
1593
|
});
|
|
1462
1594
|
break;
|
|
1463
1595
|
}
|
|
@@ -1466,7 +1598,7 @@ async function prepareTools({
|
|
|
1466
1598
|
anthropicTools2.push({
|
|
1467
1599
|
name: "bash",
|
|
1468
1600
|
type: "bash_20241022",
|
|
1469
|
-
cache_control:
|
|
1601
|
+
cache_control: providerCacheControl
|
|
1470
1602
|
});
|
|
1471
1603
|
break;
|
|
1472
1604
|
}
|
|
@@ -1474,13 +1606,13 @@ async function prepareTools({
|
|
|
1474
1606
|
betas.add("context-management-2025-06-27");
|
|
1475
1607
|
anthropicTools2.push({
|
|
1476
1608
|
name: "memory",
|
|
1477
|
-
type: "memory_20250818"
|
|
1609
|
+
type: "memory_20250818",
|
|
1610
|
+
cache_control: providerCacheControl
|
|
1478
1611
|
});
|
|
1479
1612
|
break;
|
|
1480
1613
|
}
|
|
1481
1614
|
case "anthropic.web_fetch_20250910": {
|
|
1482
|
-
|
|
1483
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1615
|
+
const args = await validateTypes({
|
|
1484
1616
|
value: tool.args,
|
|
1485
1617
|
schema: webFetch_20250910ArgsSchema
|
|
1486
1618
|
});
|
|
@@ -1492,13 +1624,12 @@ async function prepareTools({
|
|
|
1492
1624
|
blocked_domains: args.blockedDomains,
|
|
1493
1625
|
citations: args.citations,
|
|
1494
1626
|
max_content_tokens: args.maxContentTokens,
|
|
1495
|
-
cache_control:
|
|
1627
|
+
cache_control: providerCacheControl
|
|
1496
1628
|
});
|
|
1497
1629
|
break;
|
|
1498
1630
|
}
|
|
1499
1631
|
case "anthropic.web_fetch_20260209": {
|
|
1500
|
-
|
|
1501
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1632
|
+
const args = await validateTypes({
|
|
1502
1633
|
value: tool.args,
|
|
1503
1634
|
schema: webFetch_20260209ArgsSchema
|
|
1504
1635
|
});
|
|
@@ -1510,12 +1641,33 @@ async function prepareTools({
|
|
|
1510
1641
|
blocked_domains: args.blockedDomains,
|
|
1511
1642
|
citations: args.citations,
|
|
1512
1643
|
max_content_tokens: args.maxContentTokens,
|
|
1513
|
-
cache_control:
|
|
1644
|
+
cache_control: providerCacheControl
|
|
1645
|
+
});
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
case "anthropic.web_fetch_20260309": {
|
|
1649
|
+
const args = await validateTypes({
|
|
1650
|
+
value: tool.args,
|
|
1651
|
+
schema: webFetch_20260309ArgsSchema
|
|
1652
|
+
});
|
|
1653
|
+
anthropicTools2.push({
|
|
1654
|
+
type: "web_fetch_20260309",
|
|
1655
|
+
name: "web_fetch",
|
|
1656
|
+
max_uses: args.maxUses,
|
|
1657
|
+
allowed_domains: args.allowedDomains,
|
|
1658
|
+
blocked_domains: args.blockedDomains,
|
|
1659
|
+
citations: args.citations,
|
|
1660
|
+
max_content_tokens: args.maxContentTokens,
|
|
1661
|
+
allowed_callers: args.allowedCallers,
|
|
1662
|
+
use_cache: args.useCache,
|
|
1663
|
+
defer_loading: args.deferLoading,
|
|
1664
|
+
strict: args.strict,
|
|
1665
|
+
cache_control: providerCacheControl
|
|
1514
1666
|
});
|
|
1515
1667
|
break;
|
|
1516
1668
|
}
|
|
1517
1669
|
case "anthropic.web_search_20250305": {
|
|
1518
|
-
const args = await
|
|
1670
|
+
const args = await validateTypes({
|
|
1519
1671
|
value: tool.args,
|
|
1520
1672
|
schema: webSearch_20250305ArgsSchema
|
|
1521
1673
|
});
|
|
@@ -1526,13 +1678,12 @@ async function prepareTools({
|
|
|
1526
1678
|
allowed_domains: args.allowedDomains,
|
|
1527
1679
|
blocked_domains: args.blockedDomains,
|
|
1528
1680
|
user_location: args.userLocation,
|
|
1529
|
-
cache_control:
|
|
1681
|
+
cache_control: providerCacheControl
|
|
1530
1682
|
});
|
|
1531
1683
|
break;
|
|
1532
1684
|
}
|
|
1533
1685
|
case "anthropic.web_search_20260209": {
|
|
1534
|
-
|
|
1535
|
-
const args = await (0, import_provider_utils9.validateTypes)({
|
|
1686
|
+
const args = await validateTypes({
|
|
1536
1687
|
value: tool.args,
|
|
1537
1688
|
schema: webSearch_20260209ArgsSchema
|
|
1538
1689
|
});
|
|
@@ -1543,21 +1694,24 @@ async function prepareTools({
|
|
|
1543
1694
|
allowed_domains: args.allowedDomains,
|
|
1544
1695
|
blocked_domains: args.blockedDomains,
|
|
1545
1696
|
user_location: args.userLocation,
|
|
1546
|
-
|
|
1697
|
+
allowed_callers: args.allowedCallers,
|
|
1698
|
+
cache_control: providerCacheControl
|
|
1547
1699
|
});
|
|
1548
1700
|
break;
|
|
1549
1701
|
}
|
|
1550
1702
|
case "anthropic.tool_search_regex_20251119": {
|
|
1551
1703
|
anthropicTools2.push({
|
|
1552
1704
|
type: "tool_search_tool_regex_20251119",
|
|
1553
|
-
name: "tool_search_tool_regex"
|
|
1705
|
+
name: "tool_search_tool_regex",
|
|
1706
|
+
cache_control: providerCacheControl
|
|
1554
1707
|
});
|
|
1555
1708
|
break;
|
|
1556
1709
|
}
|
|
1557
1710
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1558
1711
|
anthropicTools2.push({
|
|
1559
1712
|
type: "tool_search_tool_bm25_20251119",
|
|
1560
|
-
name: "tool_search_tool_bm25"
|
|
1713
|
+
name: "tool_search_tool_bm25",
|
|
1714
|
+
cache_control: providerCacheControl
|
|
1561
1715
|
});
|
|
1562
1716
|
break;
|
|
1563
1717
|
}
|
|
@@ -1625,15 +1779,15 @@ async function prepareTools({
|
|
|
1625
1779
|
};
|
|
1626
1780
|
default: {
|
|
1627
1781
|
const _exhaustiveCheck = type;
|
|
1628
|
-
throw new
|
|
1782
|
+
throw new UnsupportedFunctionalityError({
|
|
1629
1783
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1630
1784
|
});
|
|
1631
1785
|
}
|
|
1632
1786
|
}
|
|
1633
1787
|
}
|
|
1634
1788
|
|
|
1635
|
-
// src/convert-anthropic-
|
|
1636
|
-
function
|
|
1789
|
+
// src/convert-anthropic-usage.ts
|
|
1790
|
+
function convertAnthropicUsage({
|
|
1637
1791
|
usage,
|
|
1638
1792
|
rawUsage
|
|
1639
1793
|
}) {
|
|
@@ -1672,142 +1826,161 @@ function convertAnthropicMessagesUsage({
|
|
|
1672
1826
|
};
|
|
1673
1827
|
}
|
|
1674
1828
|
|
|
1675
|
-
// src/convert-to-anthropic-
|
|
1676
|
-
|
|
1677
|
-
|
|
1829
|
+
// src/convert-to-anthropic-prompt.ts
|
|
1830
|
+
import {
|
|
1831
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1832
|
+
} from "@ai-sdk/provider";
|
|
1833
|
+
import {
|
|
1834
|
+
convertBase64ToUint8Array,
|
|
1835
|
+
convertToBase64,
|
|
1836
|
+
getTopLevelMediaType,
|
|
1837
|
+
parseProviderOptions,
|
|
1838
|
+
resolveFullMediaType,
|
|
1839
|
+
resolveProviderReference,
|
|
1840
|
+
validateTypes as validateTypes2,
|
|
1841
|
+
isNonNullable
|
|
1842
|
+
} from "@ai-sdk/provider-utils";
|
|
1678
1843
|
|
|
1679
1844
|
// src/tool/code-execution_20250522.ts
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1845
|
+
import {
|
|
1846
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
1847
|
+
lazySchema as lazySchema9,
|
|
1848
|
+
zodSchema as zodSchema9
|
|
1849
|
+
} from "@ai-sdk/provider-utils";
|
|
1850
|
+
import { z as z10 } from "zod/v4";
|
|
1851
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1852
|
+
() => zodSchema9(
|
|
1853
|
+
z10.object({
|
|
1854
|
+
type: z10.literal("code_execution_result"),
|
|
1855
|
+
stdout: z10.string(),
|
|
1856
|
+
stderr: z10.string(),
|
|
1857
|
+
return_code: z10.number(),
|
|
1858
|
+
content: z10.array(
|
|
1859
|
+
z10.object({
|
|
1860
|
+
type: z10.literal("code_execution_output"),
|
|
1861
|
+
file_id: z10.string()
|
|
1693
1862
|
})
|
|
1694
1863
|
).optional().default([])
|
|
1695
1864
|
})
|
|
1696
1865
|
)
|
|
1697
1866
|
);
|
|
1698
|
-
var codeExecution_20250522InputSchema = (
|
|
1699
|
-
() => (
|
|
1700
|
-
|
|
1701
|
-
code:
|
|
1867
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1868
|
+
() => zodSchema9(
|
|
1869
|
+
z10.object({
|
|
1870
|
+
code: z10.string()
|
|
1702
1871
|
})
|
|
1703
1872
|
)
|
|
1704
1873
|
);
|
|
1705
|
-
var
|
|
1874
|
+
var factory7 = createProviderExecutedToolFactory5({
|
|
1706
1875
|
id: "anthropic.code_execution_20250522",
|
|
1707
1876
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1708
1877
|
outputSchema: codeExecution_20250522OutputSchema
|
|
1709
1878
|
});
|
|
1710
1879
|
var codeExecution_20250522 = (args = {}) => {
|
|
1711
|
-
return
|
|
1880
|
+
return factory7(args);
|
|
1712
1881
|
};
|
|
1713
1882
|
|
|
1714
1883
|
// src/tool/code-execution_20250825.ts
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1884
|
+
import {
|
|
1885
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
1886
|
+
lazySchema as lazySchema10,
|
|
1887
|
+
zodSchema as zodSchema10
|
|
1888
|
+
} from "@ai-sdk/provider-utils";
|
|
1889
|
+
import { z as z11 } from "zod/v4";
|
|
1890
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1891
|
+
() => zodSchema10(
|
|
1892
|
+
z11.discriminatedUnion("type", [
|
|
1893
|
+
z11.object({
|
|
1894
|
+
type: z11.literal("code_execution_result"),
|
|
1895
|
+
stdout: z11.string(),
|
|
1896
|
+
stderr: z11.string(),
|
|
1897
|
+
return_code: z11.number(),
|
|
1898
|
+
content: z11.array(
|
|
1899
|
+
z11.object({
|
|
1900
|
+
type: z11.literal("code_execution_output"),
|
|
1901
|
+
file_id: z11.string()
|
|
1729
1902
|
})
|
|
1730
1903
|
).optional().default([])
|
|
1731
1904
|
}),
|
|
1732
|
-
|
|
1733
|
-
type:
|
|
1734
|
-
content:
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
file_id:
|
|
1905
|
+
z11.object({
|
|
1906
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1907
|
+
content: z11.array(
|
|
1908
|
+
z11.object({
|
|
1909
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1910
|
+
file_id: z11.string()
|
|
1738
1911
|
})
|
|
1739
1912
|
),
|
|
1740
|
-
stdout:
|
|
1741
|
-
stderr:
|
|
1742
|
-
return_code:
|
|
1913
|
+
stdout: z11.string(),
|
|
1914
|
+
stderr: z11.string(),
|
|
1915
|
+
return_code: z11.number()
|
|
1743
1916
|
}),
|
|
1744
|
-
|
|
1745
|
-
type:
|
|
1746
|
-
error_code:
|
|
1917
|
+
z11.object({
|
|
1918
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1919
|
+
error_code: z11.string()
|
|
1747
1920
|
}),
|
|
1748
|
-
|
|
1749
|
-
type:
|
|
1750
|
-
error_code:
|
|
1921
|
+
z11.object({
|
|
1922
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1923
|
+
error_code: z11.string()
|
|
1751
1924
|
}),
|
|
1752
|
-
|
|
1753
|
-
type:
|
|
1754
|
-
content:
|
|
1755
|
-
file_type:
|
|
1756
|
-
num_lines:
|
|
1757
|
-
start_line:
|
|
1758
|
-
total_lines:
|
|
1925
|
+
z11.object({
|
|
1926
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1927
|
+
content: z11.string(),
|
|
1928
|
+
file_type: z11.string(),
|
|
1929
|
+
num_lines: z11.number().nullable(),
|
|
1930
|
+
start_line: z11.number().nullable(),
|
|
1931
|
+
total_lines: z11.number().nullable()
|
|
1759
1932
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
is_file_update:
|
|
1933
|
+
z11.object({
|
|
1934
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1935
|
+
is_file_update: z11.boolean()
|
|
1763
1936
|
}),
|
|
1764
|
-
|
|
1765
|
-
type:
|
|
1766
|
-
lines:
|
|
1767
|
-
new_lines:
|
|
1768
|
-
new_start:
|
|
1769
|
-
old_lines:
|
|
1770
|
-
old_start:
|
|
1937
|
+
z11.object({
|
|
1938
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1939
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1940
|
+
new_lines: z11.number().nullable(),
|
|
1941
|
+
new_start: z11.number().nullable(),
|
|
1942
|
+
old_lines: z11.number().nullable(),
|
|
1943
|
+
old_start: z11.number().nullable()
|
|
1771
1944
|
})
|
|
1772
1945
|
])
|
|
1773
1946
|
)
|
|
1774
1947
|
);
|
|
1775
|
-
var codeExecution_20250825InputSchema = (
|
|
1776
|
-
() => (
|
|
1777
|
-
|
|
1948
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1949
|
+
() => zodSchema10(
|
|
1950
|
+
z11.discriminatedUnion("type", [
|
|
1778
1951
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1779
|
-
|
|
1780
|
-
type:
|
|
1781
|
-
code:
|
|
1952
|
+
z11.object({
|
|
1953
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1954
|
+
code: z11.string()
|
|
1782
1955
|
}),
|
|
1783
|
-
|
|
1784
|
-
type:
|
|
1785
|
-
command:
|
|
1956
|
+
z11.object({
|
|
1957
|
+
type: z11.literal("bash_code_execution"),
|
|
1958
|
+
command: z11.string()
|
|
1786
1959
|
}),
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
type:
|
|
1790
|
-
command:
|
|
1791
|
-
path:
|
|
1960
|
+
z11.discriminatedUnion("command", [
|
|
1961
|
+
z11.object({
|
|
1962
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1963
|
+
command: z11.literal("view"),
|
|
1964
|
+
path: z11.string()
|
|
1792
1965
|
}),
|
|
1793
|
-
|
|
1794
|
-
type:
|
|
1795
|
-
command:
|
|
1796
|
-
path:
|
|
1797
|
-
file_text:
|
|
1966
|
+
z11.object({
|
|
1967
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1968
|
+
command: z11.literal("create"),
|
|
1969
|
+
path: z11.string(),
|
|
1970
|
+
file_text: z11.string().nullish()
|
|
1798
1971
|
}),
|
|
1799
|
-
|
|
1800
|
-
type:
|
|
1801
|
-
command:
|
|
1802
|
-
path:
|
|
1803
|
-
old_str:
|
|
1804
|
-
new_str:
|
|
1972
|
+
z11.object({
|
|
1973
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1974
|
+
command: z11.literal("str_replace"),
|
|
1975
|
+
path: z11.string(),
|
|
1976
|
+
old_str: z11.string(),
|
|
1977
|
+
new_str: z11.string()
|
|
1805
1978
|
})
|
|
1806
1979
|
])
|
|
1807
1980
|
])
|
|
1808
1981
|
)
|
|
1809
1982
|
);
|
|
1810
|
-
var
|
|
1983
|
+
var factory8 = createProviderExecutedToolFactory6({
|
|
1811
1984
|
id: "anthropic.code_execution_20250825",
|
|
1812
1985
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1813
1986
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1817,142 +1990,150 @@ var factory7 = (0, import_provider_utils11.createProviderToolFactoryWithOutputSc
|
|
|
1817
1990
|
supportsDeferredResults: true
|
|
1818
1991
|
});
|
|
1819
1992
|
var codeExecution_20250825 = (args = {}) => {
|
|
1820
|
-
return
|
|
1993
|
+
return factory8(args);
|
|
1821
1994
|
};
|
|
1822
1995
|
|
|
1823
1996
|
// src/tool/code-execution_20260120.ts
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1997
|
+
import {
|
|
1998
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
1999
|
+
lazySchema as lazySchema11,
|
|
2000
|
+
zodSchema as zodSchema11
|
|
2001
|
+
} from "@ai-sdk/provider-utils";
|
|
2002
|
+
import { z as z12 } from "zod/v4";
|
|
2003
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
2004
|
+
() => zodSchema11(
|
|
2005
|
+
z12.discriminatedUnion("type", [
|
|
2006
|
+
z12.object({
|
|
2007
|
+
type: z12.literal("code_execution_result"),
|
|
2008
|
+
stdout: z12.string(),
|
|
2009
|
+
stderr: z12.string(),
|
|
2010
|
+
return_code: z12.number(),
|
|
2011
|
+
content: z12.array(
|
|
2012
|
+
z12.object({
|
|
2013
|
+
type: z12.literal("code_execution_output"),
|
|
2014
|
+
file_id: z12.string()
|
|
1838
2015
|
})
|
|
1839
2016
|
).optional().default([])
|
|
1840
2017
|
}),
|
|
1841
|
-
|
|
1842
|
-
type:
|
|
1843
|
-
encrypted_stdout:
|
|
1844
|
-
stderr:
|
|
1845
|
-
return_code:
|
|
1846
|
-
content:
|
|
1847
|
-
|
|
1848
|
-
type:
|
|
1849
|
-
file_id:
|
|
2018
|
+
z12.object({
|
|
2019
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
2020
|
+
encrypted_stdout: z12.string(),
|
|
2021
|
+
stderr: z12.string(),
|
|
2022
|
+
return_code: z12.number(),
|
|
2023
|
+
content: z12.array(
|
|
2024
|
+
z12.object({
|
|
2025
|
+
type: z12.literal("code_execution_output"),
|
|
2026
|
+
file_id: z12.string()
|
|
1850
2027
|
})
|
|
1851
2028
|
).optional().default([])
|
|
1852
2029
|
}),
|
|
1853
|
-
|
|
1854
|
-
type:
|
|
1855
|
-
content:
|
|
1856
|
-
|
|
1857
|
-
type:
|
|
1858
|
-
file_id:
|
|
2030
|
+
z12.object({
|
|
2031
|
+
type: z12.literal("bash_code_execution_result"),
|
|
2032
|
+
content: z12.array(
|
|
2033
|
+
z12.object({
|
|
2034
|
+
type: z12.literal("bash_code_execution_output"),
|
|
2035
|
+
file_id: z12.string()
|
|
1859
2036
|
})
|
|
1860
2037
|
),
|
|
1861
|
-
stdout:
|
|
1862
|
-
stderr:
|
|
1863
|
-
return_code:
|
|
2038
|
+
stdout: z12.string(),
|
|
2039
|
+
stderr: z12.string(),
|
|
2040
|
+
return_code: z12.number()
|
|
1864
2041
|
}),
|
|
1865
|
-
|
|
1866
|
-
type:
|
|
1867
|
-
error_code:
|
|
2042
|
+
z12.object({
|
|
2043
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
2044
|
+
error_code: z12.string()
|
|
1868
2045
|
}),
|
|
1869
|
-
|
|
1870
|
-
type:
|
|
1871
|
-
error_code:
|
|
2046
|
+
z12.object({
|
|
2047
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
2048
|
+
error_code: z12.string()
|
|
1872
2049
|
}),
|
|
1873
|
-
|
|
1874
|
-
type:
|
|
1875
|
-
content:
|
|
1876
|
-
file_type:
|
|
1877
|
-
num_lines:
|
|
1878
|
-
start_line:
|
|
1879
|
-
total_lines:
|
|
2050
|
+
z12.object({
|
|
2051
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
2052
|
+
content: z12.string(),
|
|
2053
|
+
file_type: z12.string(),
|
|
2054
|
+
num_lines: z12.number().nullable(),
|
|
2055
|
+
start_line: z12.number().nullable(),
|
|
2056
|
+
total_lines: z12.number().nullable()
|
|
1880
2057
|
}),
|
|
1881
|
-
|
|
1882
|
-
type:
|
|
1883
|
-
is_file_update:
|
|
2058
|
+
z12.object({
|
|
2059
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
2060
|
+
is_file_update: z12.boolean()
|
|
1884
2061
|
}),
|
|
1885
|
-
|
|
1886
|
-
type:
|
|
1887
|
-
lines:
|
|
1888
|
-
new_lines:
|
|
1889
|
-
new_start:
|
|
1890
|
-
old_lines:
|
|
1891
|
-
old_start:
|
|
2062
|
+
z12.object({
|
|
2063
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2064
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2065
|
+
new_lines: z12.number().nullable(),
|
|
2066
|
+
new_start: z12.number().nullable(),
|
|
2067
|
+
old_lines: z12.number().nullable(),
|
|
2068
|
+
old_start: z12.number().nullable()
|
|
1892
2069
|
})
|
|
1893
2070
|
])
|
|
1894
2071
|
)
|
|
1895
2072
|
);
|
|
1896
|
-
var codeExecution_20260120InputSchema = (
|
|
1897
|
-
() => (
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
type:
|
|
1901
|
-
code:
|
|
2073
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
2074
|
+
() => zodSchema11(
|
|
2075
|
+
z12.discriminatedUnion("type", [
|
|
2076
|
+
z12.object({
|
|
2077
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2078
|
+
code: z12.string()
|
|
1902
2079
|
}),
|
|
1903
|
-
|
|
1904
|
-
type:
|
|
1905
|
-
command:
|
|
2080
|
+
z12.object({
|
|
2081
|
+
type: z12.literal("bash_code_execution"),
|
|
2082
|
+
command: z12.string()
|
|
1906
2083
|
}),
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
type:
|
|
1910
|
-
command:
|
|
1911
|
-
path:
|
|
2084
|
+
z12.discriminatedUnion("command", [
|
|
2085
|
+
z12.object({
|
|
2086
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2087
|
+
command: z12.literal("view"),
|
|
2088
|
+
path: z12.string()
|
|
1912
2089
|
}),
|
|
1913
|
-
|
|
1914
|
-
type:
|
|
1915
|
-
command:
|
|
1916
|
-
path:
|
|
1917
|
-
file_text:
|
|
2090
|
+
z12.object({
|
|
2091
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2092
|
+
command: z12.literal("create"),
|
|
2093
|
+
path: z12.string(),
|
|
2094
|
+
file_text: z12.string().nullish()
|
|
1918
2095
|
}),
|
|
1919
|
-
|
|
1920
|
-
type:
|
|
1921
|
-
command:
|
|
1922
|
-
path:
|
|
1923
|
-
old_str:
|
|
1924
|
-
new_str:
|
|
2096
|
+
z12.object({
|
|
2097
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2098
|
+
command: z12.literal("str_replace"),
|
|
2099
|
+
path: z12.string(),
|
|
2100
|
+
old_str: z12.string(),
|
|
2101
|
+
new_str: z12.string()
|
|
1925
2102
|
})
|
|
1926
2103
|
])
|
|
1927
2104
|
])
|
|
1928
2105
|
)
|
|
1929
2106
|
);
|
|
1930
|
-
var
|
|
2107
|
+
var factory9 = createProviderExecutedToolFactory7({
|
|
1931
2108
|
id: "anthropic.code_execution_20260120",
|
|
1932
2109
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1933
2110
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
1934
2111
|
supportsDeferredResults: true
|
|
1935
2112
|
});
|
|
1936
2113
|
var codeExecution_20260120 = (args = {}) => {
|
|
1937
|
-
return
|
|
2114
|
+
return factory9(args);
|
|
1938
2115
|
};
|
|
1939
2116
|
|
|
1940
2117
|
// src/tool/tool-search-regex_20251119.ts
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2118
|
+
import {
|
|
2119
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
|
|
2120
|
+
lazySchema as lazySchema12,
|
|
2121
|
+
zodSchema as zodSchema12
|
|
2122
|
+
} from "@ai-sdk/provider-utils";
|
|
2123
|
+
import { z as z13 } from "zod/v4";
|
|
2124
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2125
|
+
() => zodSchema12(
|
|
2126
|
+
z13.array(
|
|
2127
|
+
z13.object({
|
|
2128
|
+
type: z13.literal("tool_reference"),
|
|
2129
|
+
toolName: z13.string()
|
|
1949
2130
|
})
|
|
1950
2131
|
)
|
|
1951
2132
|
)
|
|
1952
2133
|
);
|
|
1953
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1954
|
-
() => (
|
|
1955
|
-
|
|
2134
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2135
|
+
() => zodSchema12(
|
|
2136
|
+
z13.object({
|
|
1956
2137
|
/**
|
|
1957
2138
|
* A regex pattern to search for tools.
|
|
1958
2139
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1963,57 +2144,32 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1963
2144
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1964
2145
|
* - "(?i)slack" - case-insensitive search
|
|
1965
2146
|
*/
|
|
1966
|
-
pattern:
|
|
2147
|
+
pattern: z13.string(),
|
|
1967
2148
|
/**
|
|
1968
2149
|
* Maximum number of tools to return. Optional.
|
|
1969
2150
|
*/
|
|
1970
|
-
limit:
|
|
2151
|
+
limit: z13.number().optional()
|
|
1971
2152
|
})
|
|
1972
2153
|
)
|
|
1973
2154
|
);
|
|
1974
|
-
var
|
|
2155
|
+
var factory10 = createProviderExecutedToolFactory8({
|
|
1975
2156
|
id: "anthropic.tool_search_regex_20251119",
|
|
1976
2157
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1977
2158
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
1978
2159
|
supportsDeferredResults: true
|
|
1979
2160
|
});
|
|
1980
2161
|
var toolSearchRegex_20251119 = (args = {}) => {
|
|
1981
|
-
return
|
|
2162
|
+
return factory10(args);
|
|
1982
2163
|
};
|
|
1983
2164
|
|
|
1984
|
-
// src/convert-to-anthropic-
|
|
1985
|
-
function
|
|
2165
|
+
// src/convert-to-anthropic-prompt.ts
|
|
2166
|
+
function convertBytesDataToString(data) {
|
|
1986
2167
|
if (typeof data === "string") {
|
|
1987
|
-
return new TextDecoder().decode(
|
|
1988
|
-
}
|
|
1989
|
-
if (data instanceof Uint8Array) {
|
|
1990
|
-
return new TextDecoder().decode(data);
|
|
2168
|
+
return new TextDecoder().decode(convertBase64ToUint8Array(data));
|
|
1991
2169
|
}
|
|
1992
|
-
|
|
1993
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1994
|
-
functionality: "URL-based text documents are not supported for citations"
|
|
1995
|
-
});
|
|
1996
|
-
}
|
|
1997
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1998
|
-
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
function isUrlData(data) {
|
|
2002
|
-
return data instanceof URL || isUrlString(data);
|
|
2003
|
-
}
|
|
2004
|
-
function isUrlString(data) {
|
|
2005
|
-
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
2170
|
+
return new TextDecoder().decode(data);
|
|
2006
2171
|
}
|
|
2007
|
-
function
|
|
2008
|
-
return typeof data === "string" && data.startsWith("anthropic-file://");
|
|
2009
|
-
}
|
|
2010
|
-
function getFileId(data) {
|
|
2011
|
-
return data.replace("anthropic-file://", "");
|
|
2012
|
-
}
|
|
2013
|
-
function getUrlString(data) {
|
|
2014
|
-
return data instanceof URL ? data.toString() : data;
|
|
2015
|
-
}
|
|
2016
|
-
async function convertToAnthropicMessagesPrompt({
|
|
2172
|
+
async function convertToAnthropicPrompt({
|
|
2017
2173
|
prompt,
|
|
2018
2174
|
sendReasoning,
|
|
2019
2175
|
warnings,
|
|
@@ -2028,7 +2184,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2028
2184
|
const messages = [];
|
|
2029
2185
|
async function shouldEnableCitations(providerMetadata) {
|
|
2030
2186
|
var _a2, _b2;
|
|
2031
|
-
const anthropicOptions = await
|
|
2187
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2032
2188
|
provider: "anthropic",
|
|
2033
2189
|
providerOptions: providerMetadata,
|
|
2034
2190
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2036,7 +2192,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2036
2192
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
2037
2193
|
}
|
|
2038
2194
|
async function getDocumentMetadata(providerMetadata) {
|
|
2039
|
-
const anthropicOptions = await
|
|
2195
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2040
2196
|
provider: "anthropic",
|
|
2041
2197
|
providerOptions: providerMetadata,
|
|
2042
2198
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2053,18 +2209,21 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2053
2209
|
switch (type) {
|
|
2054
2210
|
case "system": {
|
|
2055
2211
|
if (system != null) {
|
|
2056
|
-
throw new
|
|
2212
|
+
throw new UnsupportedFunctionalityError2({
|
|
2057
2213
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2058
2214
|
});
|
|
2059
2215
|
}
|
|
2060
|
-
system = block.messages.map(({ content, providerOptions }) =>
|
|
2061
|
-
|
|
2062
|
-
text: content,
|
|
2063
|
-
cache_control: validator.getCacheControl(providerOptions, {
|
|
2216
|
+
system = block.messages.map(({ content, providerOptions }) => {
|
|
2217
|
+
const cc = validator.getCacheControl(providerOptions, {
|
|
2064
2218
|
type: "system message",
|
|
2065
2219
|
canCache: true
|
|
2066
|
-
})
|
|
2067
|
-
|
|
2220
|
+
});
|
|
2221
|
+
return {
|
|
2222
|
+
type: "text",
|
|
2223
|
+
text: content,
|
|
2224
|
+
cache_control: cc
|
|
2225
|
+
};
|
|
2226
|
+
});
|
|
2068
2227
|
break;
|
|
2069
2228
|
}
|
|
2070
2229
|
case "user": {
|
|
@@ -2093,87 +2252,131 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2093
2252
|
break;
|
|
2094
2253
|
}
|
|
2095
2254
|
case "file": {
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2255
|
+
switch (part.data.type) {
|
|
2256
|
+
case "reference": {
|
|
2257
|
+
const fileId = resolveProviderReference({
|
|
2258
|
+
reference: part.data.reference,
|
|
2259
|
+
provider: "anthropic"
|
|
2260
|
+
});
|
|
2261
|
+
betas.add("files-api-2025-04-14");
|
|
2262
|
+
if (getTopLevelMediaType(part.mediaType) === "image") {
|
|
2263
|
+
anthropicContent.push({
|
|
2264
|
+
type: "image",
|
|
2265
|
+
source: { type: "file", file_id: fileId },
|
|
2266
|
+
cache_control: cacheControl
|
|
2267
|
+
});
|
|
2268
|
+
} else {
|
|
2269
|
+
anthropicContent.push({
|
|
2270
|
+
type: "document",
|
|
2271
|
+
source: { type: "file", file_id: fileId },
|
|
2272
|
+
cache_control: cacheControl
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
break;
|
|
2276
|
+
}
|
|
2277
|
+
case "text": {
|
|
2278
|
+
const enableCitations = await shouldEnableCitations(
|
|
2279
|
+
part.providerOptions
|
|
2280
|
+
);
|
|
2281
|
+
const metadata = await getDocumentMetadata(
|
|
2282
|
+
part.providerOptions
|
|
2283
|
+
);
|
|
2284
|
+
anthropicContent.push({
|
|
2285
|
+
type: "document",
|
|
2286
|
+
source: {
|
|
2287
|
+
type: "text",
|
|
2288
|
+
media_type: "text/plain",
|
|
2289
|
+
data: part.data.text
|
|
2290
|
+
},
|
|
2291
|
+
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2292
|
+
...metadata.context && {
|
|
2293
|
+
context: metadata.context
|
|
2294
|
+
},
|
|
2295
|
+
...enableCitations && {
|
|
2296
|
+
citations: { enabled: true }
|
|
2297
|
+
},
|
|
2298
|
+
cache_control: cacheControl
|
|
2299
|
+
});
|
|
2300
|
+
break;
|
|
2301
|
+
}
|
|
2302
|
+
case "url":
|
|
2303
|
+
case "data": {
|
|
2304
|
+
const topLevel = getTopLevelMediaType(part.mediaType);
|
|
2305
|
+
if (topLevel === "image") {
|
|
2306
|
+
anthropicContent.push({
|
|
2307
|
+
type: "image",
|
|
2308
|
+
source: part.data.type === "url" ? {
|
|
2309
|
+
type: "url",
|
|
2310
|
+
url: part.data.url.toString()
|
|
2311
|
+
} : {
|
|
2312
|
+
type: "base64",
|
|
2313
|
+
media_type: resolveFullMediaType({ part }),
|
|
2314
|
+
data: convertToBase64(part.data.data)
|
|
2315
|
+
},
|
|
2316
|
+
cache_control: cacheControl
|
|
2317
|
+
});
|
|
2318
|
+
} else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
|
|
2319
|
+
betas.add("pdfs-2024-09-25");
|
|
2320
|
+
const enableCitations = await shouldEnableCitations(
|
|
2321
|
+
part.providerOptions
|
|
2322
|
+
);
|
|
2323
|
+
const metadata = await getDocumentMetadata(
|
|
2324
|
+
part.providerOptions
|
|
2325
|
+
);
|
|
2326
|
+
anthropicContent.push({
|
|
2327
|
+
type: "document",
|
|
2328
|
+
source: part.data.type === "url" ? {
|
|
2329
|
+
type: "url",
|
|
2330
|
+
url: part.data.url.toString()
|
|
2331
|
+
} : {
|
|
2332
|
+
type: "base64",
|
|
2333
|
+
media_type: "application/pdf",
|
|
2334
|
+
data: convertToBase64(part.data.data)
|
|
2335
|
+
},
|
|
2336
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
2337
|
+
...metadata.context && {
|
|
2338
|
+
context: metadata.context
|
|
2339
|
+
},
|
|
2340
|
+
...enableCitations && {
|
|
2341
|
+
citations: { enabled: true }
|
|
2342
|
+
},
|
|
2343
|
+
cache_control: cacheControl
|
|
2344
|
+
});
|
|
2345
|
+
} else if (part.mediaType === "text/plain") {
|
|
2346
|
+
const enableCitations = await shouldEnableCitations(
|
|
2347
|
+
part.providerOptions
|
|
2348
|
+
);
|
|
2349
|
+
const metadata = await getDocumentMetadata(
|
|
2350
|
+
part.providerOptions
|
|
2351
|
+
);
|
|
2352
|
+
anthropicContent.push({
|
|
2353
|
+
type: "document",
|
|
2354
|
+
source: part.data.type === "url" ? {
|
|
2355
|
+
type: "url",
|
|
2356
|
+
url: part.data.url.toString()
|
|
2357
|
+
} : {
|
|
2358
|
+
type: "text",
|
|
2359
|
+
media_type: "text/plain",
|
|
2360
|
+
data: convertBytesDataToString(
|
|
2361
|
+
part.data.data
|
|
2362
|
+
)
|
|
2363
|
+
},
|
|
2364
|
+
title: (_d = metadata.title) != null ? _d : part.filename,
|
|
2365
|
+
...metadata.context && {
|
|
2366
|
+
context: metadata.context
|
|
2367
|
+
},
|
|
2368
|
+
...enableCitations && {
|
|
2369
|
+
citations: { enabled: true }
|
|
2370
|
+
},
|
|
2371
|
+
cache_control: cacheControl
|
|
2372
|
+
});
|
|
2373
|
+
} else {
|
|
2374
|
+
throw new UnsupportedFunctionalityError2({
|
|
2375
|
+
functionality: `media type: ${part.mediaType}`
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
break;
|
|
2379
|
+
}
|
|
2177
2380
|
}
|
|
2178
2381
|
break;
|
|
2179
2382
|
}
|
|
@@ -2207,26 +2410,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2207
2410
|
type: "text",
|
|
2208
2411
|
text: contentPart.text
|
|
2209
2412
|
};
|
|
2210
|
-
case "image-data": {
|
|
2211
|
-
return {
|
|
2212
|
-
type: "image",
|
|
2213
|
-
source: {
|
|
2214
|
-
type: "base64",
|
|
2215
|
-
media_type: contentPart.mediaType,
|
|
2216
|
-
data: contentPart.data
|
|
2217
|
-
}
|
|
2218
|
-
};
|
|
2219
|
-
}
|
|
2220
|
-
case "image-url": {
|
|
2221
|
-
return {
|
|
2222
|
-
type: "image",
|
|
2223
|
-
source: {
|
|
2224
|
-
type: "url",
|
|
2225
|
-
url: contentPart.url
|
|
2226
|
-
}
|
|
2227
|
-
};
|
|
2228
|
-
}
|
|
2229
2413
|
case "file-url": {
|
|
2414
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2415
|
+
return {
|
|
2416
|
+
type: "image",
|
|
2417
|
+
source: {
|
|
2418
|
+
type: "url",
|
|
2419
|
+
url: contentPart.url
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2422
|
+
}
|
|
2230
2423
|
return {
|
|
2231
2424
|
type: "document",
|
|
2232
2425
|
source: {
|
|
@@ -2236,6 +2429,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2236
2429
|
};
|
|
2237
2430
|
}
|
|
2238
2431
|
case "file-data": {
|
|
2432
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2433
|
+
return {
|
|
2434
|
+
type: "image",
|
|
2435
|
+
source: {
|
|
2436
|
+
type: "base64",
|
|
2437
|
+
media_type: contentPart.mediaType,
|
|
2438
|
+
data: contentPart.data
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2239
2442
|
if (contentPart.mediaType === "application/pdf") {
|
|
2240
2443
|
betas.add("pdfs-2024-09-25");
|
|
2241
2444
|
return {
|
|
@@ -2275,14 +2478,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2275
2478
|
return void 0;
|
|
2276
2479
|
}
|
|
2277
2480
|
}
|
|
2278
|
-
}).filter(
|
|
2481
|
+
}).filter(isNonNullable);
|
|
2279
2482
|
break;
|
|
2280
2483
|
case "text":
|
|
2281
2484
|
case "error-text":
|
|
2282
2485
|
contentValue = output.value;
|
|
2283
2486
|
break;
|
|
2284
2487
|
case "execution-denied":
|
|
2285
|
-
contentValue = (_f = output.reason) != null ? _f : "Tool execution denied.";
|
|
2488
|
+
contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
|
|
2286
2489
|
break;
|
|
2287
2490
|
case "json":
|
|
2288
2491
|
case "error-json":
|
|
@@ -2351,7 +2554,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2351
2554
|
}
|
|
2352
2555
|
case "reasoning": {
|
|
2353
2556
|
if (sendReasoning) {
|
|
2354
|
-
const reasoningMetadata = await
|
|
2557
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2355
2558
|
provider: "anthropic",
|
|
2356
2559
|
providerOptions: part.providerOptions,
|
|
2357
2560
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2557,7 +2760,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2557
2760
|
break;
|
|
2558
2761
|
}
|
|
2559
2762
|
if (output.value.type === "code_execution_result") {
|
|
2560
|
-
const codeExecutionOutput = await (
|
|
2763
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2561
2764
|
value: output.value,
|
|
2562
2765
|
schema: codeExecution_20250522OutputSchema
|
|
2563
2766
|
});
|
|
@@ -2574,7 +2777,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2574
2777
|
cache_control: cacheControl
|
|
2575
2778
|
});
|
|
2576
2779
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2577
|
-
const codeExecutionOutput = await (
|
|
2780
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2578
2781
|
value: output.value,
|
|
2579
2782
|
schema: codeExecution_20260120OutputSchema
|
|
2580
2783
|
});
|
|
@@ -2593,7 +2796,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2593
2796
|
});
|
|
2594
2797
|
}
|
|
2595
2798
|
} else {
|
|
2596
|
-
const codeExecutionOutput = await (
|
|
2799
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2597
2800
|
value: output.value,
|
|
2598
2801
|
schema: codeExecution_20250825OutputSchema
|
|
2599
2802
|
});
|
|
@@ -2662,7 +2865,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2662
2865
|
});
|
|
2663
2866
|
break;
|
|
2664
2867
|
}
|
|
2665
|
-
const webFetchOutput = await (
|
|
2868
|
+
const webFetchOutput = await validateTypes2({
|
|
2666
2869
|
value: output.value,
|
|
2667
2870
|
schema: webFetch_20250910OutputSchema
|
|
2668
2871
|
});
|
|
@@ -2690,6 +2893,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2690
2893
|
}
|
|
2691
2894
|
if (providerToolName === "web_search") {
|
|
2692
2895
|
const output = part.output;
|
|
2896
|
+
if (output.type === "error-text" || output.type === "error-json") {
|
|
2897
|
+
anthropicContent.push({
|
|
2898
|
+
type: "web_search_tool_result",
|
|
2899
|
+
tool_use_id: part.toolCallId,
|
|
2900
|
+
content: {
|
|
2901
|
+
type: "web_search_tool_result_error",
|
|
2902
|
+
error_code: "unavailable"
|
|
2903
|
+
},
|
|
2904
|
+
cache_control: cacheControl
|
|
2905
|
+
});
|
|
2906
|
+
break;
|
|
2907
|
+
}
|
|
2693
2908
|
if (output.type !== "json") {
|
|
2694
2909
|
warnings.push({
|
|
2695
2910
|
type: "other",
|
|
@@ -2697,7 +2912,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2697
2912
|
});
|
|
2698
2913
|
break;
|
|
2699
2914
|
}
|
|
2700
|
-
const webSearchOutput = await (
|
|
2915
|
+
const webSearchOutput = await validateTypes2({
|
|
2701
2916
|
value: output.value,
|
|
2702
2917
|
schema: webSearch_20250305OutputSchema
|
|
2703
2918
|
});
|
|
@@ -2717,6 +2932,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2717
2932
|
}
|
|
2718
2933
|
if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
2719
2934
|
const output = part.output;
|
|
2935
|
+
if (output.type === "error-text" || output.type === "error-json") {
|
|
2936
|
+
anthropicContent.push({
|
|
2937
|
+
type: "tool_search_tool_result",
|
|
2938
|
+
tool_use_id: part.toolCallId,
|
|
2939
|
+
content: {
|
|
2940
|
+
type: "tool_search_tool_result_error",
|
|
2941
|
+
error_code: "unavailable"
|
|
2942
|
+
},
|
|
2943
|
+
cache_control: cacheControl
|
|
2944
|
+
});
|
|
2945
|
+
break;
|
|
2946
|
+
}
|
|
2720
2947
|
if (output.type !== "json") {
|
|
2721
2948
|
warnings.push({
|
|
2722
2949
|
type: "other",
|
|
@@ -2724,7 +2951,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2724
2951
|
});
|
|
2725
2952
|
break;
|
|
2726
2953
|
}
|
|
2727
|
-
const toolSearchOutput = await (
|
|
2954
|
+
const toolSearchOutput = await validateTypes2({
|
|
2728
2955
|
value: output.value,
|
|
2729
2956
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2730
2957
|
});
|
|
@@ -2837,7 +3064,153 @@ function mapAnthropicStopReason({
|
|
|
2837
3064
|
}
|
|
2838
3065
|
}
|
|
2839
3066
|
|
|
2840
|
-
// src/
|
|
3067
|
+
// src/sanitize-json-schema.ts
|
|
3068
|
+
var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
3069
|
+
"date-time",
|
|
3070
|
+
"time",
|
|
3071
|
+
"date",
|
|
3072
|
+
"duration",
|
|
3073
|
+
"email",
|
|
3074
|
+
"hostname",
|
|
3075
|
+
"uri",
|
|
3076
|
+
"ipv4",
|
|
3077
|
+
"ipv6",
|
|
3078
|
+
"uuid"
|
|
3079
|
+
]);
|
|
3080
|
+
var DESCRIPTION_CONSTRAINT_KEYS = [
|
|
3081
|
+
"minimum",
|
|
3082
|
+
"maximum",
|
|
3083
|
+
"exclusiveMinimum",
|
|
3084
|
+
"exclusiveMaximum",
|
|
3085
|
+
"multipleOf",
|
|
3086
|
+
"minLength",
|
|
3087
|
+
"maxLength",
|
|
3088
|
+
"pattern",
|
|
3089
|
+
"minItems",
|
|
3090
|
+
"maxItems",
|
|
3091
|
+
"uniqueItems",
|
|
3092
|
+
"minProperties",
|
|
3093
|
+
"maxProperties",
|
|
3094
|
+
"not"
|
|
3095
|
+
];
|
|
3096
|
+
function sanitizeJsonSchema(schema) {
|
|
3097
|
+
return sanitizeSchema(schema);
|
|
3098
|
+
}
|
|
3099
|
+
function sanitizeDefinition(definition) {
|
|
3100
|
+
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
3101
|
+
return definition;
|
|
3102
|
+
}
|
|
3103
|
+
return sanitizeSchema(definition);
|
|
3104
|
+
}
|
|
3105
|
+
function sanitizeSchema(schema) {
|
|
3106
|
+
const result = {};
|
|
3107
|
+
const schemaWithDefs = schema;
|
|
3108
|
+
if (schema.$ref != null) {
|
|
3109
|
+
return { $ref: schema.$ref };
|
|
3110
|
+
}
|
|
3111
|
+
if (schema.$schema != null) {
|
|
3112
|
+
result.$schema = schema.$schema;
|
|
3113
|
+
}
|
|
3114
|
+
if (schema.$id != null) {
|
|
3115
|
+
result.$id = schema.$id;
|
|
3116
|
+
}
|
|
3117
|
+
if (schema.title != null) {
|
|
3118
|
+
result.title = schema.title;
|
|
3119
|
+
}
|
|
3120
|
+
if (schema.description != null) {
|
|
3121
|
+
result.description = schema.description;
|
|
3122
|
+
}
|
|
3123
|
+
if (schema.default !== void 0) {
|
|
3124
|
+
result.default = schema.default;
|
|
3125
|
+
}
|
|
3126
|
+
if (schema.const !== void 0) {
|
|
3127
|
+
result.const = schema.const;
|
|
3128
|
+
}
|
|
3129
|
+
if (schema.enum != null) {
|
|
3130
|
+
result.enum = schema.enum;
|
|
3131
|
+
}
|
|
3132
|
+
if (schema.type != null) {
|
|
3133
|
+
result.type = schema.type;
|
|
3134
|
+
}
|
|
3135
|
+
if (schema.anyOf != null) {
|
|
3136
|
+
result.anyOf = schema.anyOf.map(sanitizeDefinition);
|
|
3137
|
+
} else if (schema.oneOf != null) {
|
|
3138
|
+
result.anyOf = schema.oneOf.map(sanitizeDefinition);
|
|
3139
|
+
}
|
|
3140
|
+
if (schema.allOf != null) {
|
|
3141
|
+
result.allOf = schema.allOf.map(sanitizeDefinition);
|
|
3142
|
+
}
|
|
3143
|
+
if (schema.definitions != null) {
|
|
3144
|
+
result.definitions = Object.fromEntries(
|
|
3145
|
+
Object.entries(schema.definitions).map(([name, definition]) => [
|
|
3146
|
+
name,
|
|
3147
|
+
sanitizeDefinition(definition)
|
|
3148
|
+
])
|
|
3149
|
+
);
|
|
3150
|
+
}
|
|
3151
|
+
if (schemaWithDefs.$defs != null) {
|
|
3152
|
+
const resultWithDefs = result;
|
|
3153
|
+
resultWithDefs.$defs = Object.fromEntries(
|
|
3154
|
+
Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
|
|
3155
|
+
name,
|
|
3156
|
+
sanitizeDefinition(definition)
|
|
3157
|
+
])
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
if (schema.type === "object" || schema.properties != null) {
|
|
3161
|
+
if (schema.properties != null) {
|
|
3162
|
+
result.properties = Object.fromEntries(
|
|
3163
|
+
Object.entries(schema.properties).map(([name, definition]) => [
|
|
3164
|
+
name,
|
|
3165
|
+
sanitizeDefinition(definition)
|
|
3166
|
+
])
|
|
3167
|
+
);
|
|
3168
|
+
}
|
|
3169
|
+
result.additionalProperties = false;
|
|
3170
|
+
if (schema.required != null) {
|
|
3171
|
+
result.required = schema.required;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
if (schema.items != null) {
|
|
3175
|
+
result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
|
|
3176
|
+
}
|
|
3177
|
+
if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3178
|
+
result.format = schema.format;
|
|
3179
|
+
}
|
|
3180
|
+
const constraintDescription = getConstraintDescription(schema);
|
|
3181
|
+
if (constraintDescription != null) {
|
|
3182
|
+
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
3183
|
+
${constraintDescription}`;
|
|
3184
|
+
}
|
|
3185
|
+
return result;
|
|
3186
|
+
}
|
|
3187
|
+
function getConstraintDescription(schema) {
|
|
3188
|
+
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
3189
|
+
const value = schema[key];
|
|
3190
|
+
if (value == null || value === false) {
|
|
3191
|
+
return [];
|
|
3192
|
+
}
|
|
3193
|
+
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
3194
|
+
});
|
|
3195
|
+
if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3196
|
+
descriptions.push(`format: ${schema.format}`);
|
|
3197
|
+
}
|
|
3198
|
+
return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
|
|
3199
|
+
}
|
|
3200
|
+
function formatConstraintName(key) {
|
|
3201
|
+
return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
|
|
3202
|
+
}
|
|
3203
|
+
function formatConstraintValue(value) {
|
|
3204
|
+
if (typeof value === "string") {
|
|
3205
|
+
return value;
|
|
3206
|
+
}
|
|
3207
|
+
return JSON.stringify(value);
|
|
3208
|
+
}
|
|
3209
|
+
function isPlainObject(value) {
|
|
3210
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
// src/anthropic-language-model.ts
|
|
2841
3214
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
2842
3215
|
var _a;
|
|
2843
3216
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2882,13 +3255,22 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
2882
3255
|
}
|
|
2883
3256
|
};
|
|
2884
3257
|
}
|
|
2885
|
-
var
|
|
3258
|
+
var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
2886
3259
|
constructor(modelId, config) {
|
|
2887
3260
|
this.specificationVersion = "v4";
|
|
2888
3261
|
var _a;
|
|
2889
3262
|
this.modelId = modelId;
|
|
2890
3263
|
this.config = config;
|
|
2891
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3264
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3265
|
+
}
|
|
3266
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3267
|
+
return serializeModelOptions({
|
|
3268
|
+
modelId: model.modelId,
|
|
3269
|
+
config: model.config
|
|
3270
|
+
});
|
|
3271
|
+
}
|
|
3272
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3273
|
+
return new _AnthropicLanguageModel(options.modelId, options.config);
|
|
2892
3274
|
}
|
|
2893
3275
|
supportsUrl(url) {
|
|
2894
3276
|
return url.protocol === "https:";
|
|
@@ -2927,7 +3309,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
3309
|
providerOptions,
|
|
2928
3310
|
stream
|
|
2929
3311
|
}) {
|
|
2930
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3312
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2931
3313
|
const warnings = [];
|
|
2932
3314
|
if (frequencyPenalty != null) {
|
|
2933
3315
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2963,12 +3345,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2963
3345
|
}
|
|
2964
3346
|
}
|
|
2965
3347
|
const providerOptionsName = this.providerOptionsName;
|
|
2966
|
-
const canonicalOptions = await (
|
|
3348
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2967
3349
|
provider: "anthropic",
|
|
2968
3350
|
providerOptions,
|
|
2969
3351
|
schema: anthropicLanguageModelOptions
|
|
2970
3352
|
});
|
|
2971
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3353
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2972
3354
|
provider: providerOptionsName,
|
|
2973
3355
|
providerOptions,
|
|
2974
3356
|
schema: anthropicLanguageModelOptions
|
|
@@ -2983,8 +3365,37 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2983
3365
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2984
3366
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
2985
3367
|
supportsAdaptiveThinking,
|
|
3368
|
+
rejectsSamplingParameters,
|
|
3369
|
+
supportsXhighEffort,
|
|
2986
3370
|
isKnownModel
|
|
2987
3371
|
} = getModelCapabilities(this.modelId);
|
|
3372
|
+
if (rejectsSamplingParameters) {
|
|
3373
|
+
if (temperature != null) {
|
|
3374
|
+
warnings.push({
|
|
3375
|
+
type: "unsupported",
|
|
3376
|
+
feature: "temperature",
|
|
3377
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3378
|
+
});
|
|
3379
|
+
temperature = void 0;
|
|
3380
|
+
}
|
|
3381
|
+
if (topK != null) {
|
|
3382
|
+
warnings.push({
|
|
3383
|
+
type: "unsupported",
|
|
3384
|
+
feature: "topK",
|
|
3385
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3386
|
+
});
|
|
3387
|
+
topK = void 0;
|
|
3388
|
+
}
|
|
3389
|
+
if (topP != null) {
|
|
3390
|
+
warnings.push({
|
|
3391
|
+
type: "unsupported",
|
|
3392
|
+
feature: "topP",
|
|
3393
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3394
|
+
});
|
|
3395
|
+
topP = void 0;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2988
3399
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2989
3400
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2990
3401
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -2997,7 +3408,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2997
3408
|
} : void 0;
|
|
2998
3409
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2999
3410
|
const cacheControlValidator = new CacheControlValidator();
|
|
3000
|
-
const toolNameMapping =
|
|
3411
|
+
const toolNameMapping = createToolNameMapping({
|
|
3001
3412
|
tools,
|
|
3002
3413
|
providerToolNames: {
|
|
3003
3414
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -3020,51 +3431,42 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3020
3431
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
3021
3432
|
}
|
|
3022
3433
|
});
|
|
3023
|
-
const { prompt: messagesPrompt, betas } = await
|
|
3434
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
3024
3435
|
prompt,
|
|
3025
3436
|
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3026
3437
|
warnings,
|
|
3027
3438
|
cacheControlValidator,
|
|
3028
3439
|
toolNameMapping
|
|
3029
3440
|
});
|
|
3030
|
-
if (
|
|
3441
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3031
3442
|
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3032
3443
|
reasoning,
|
|
3033
3444
|
supportsAdaptiveThinking,
|
|
3445
|
+
supportsXhighEffort,
|
|
3034
3446
|
maxOutputTokensForModel,
|
|
3035
3447
|
warnings
|
|
3036
3448
|
});
|
|
3037
3449
|
if (reasoningConfig != null) {
|
|
3038
|
-
anthropicOptions.thinking
|
|
3039
|
-
|
|
3450
|
+
if (anthropicOptions.thinking == null) {
|
|
3451
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3452
|
+
}
|
|
3453
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3040
3454
|
anthropicOptions.effort = reasoningConfig.effort;
|
|
3041
3455
|
}
|
|
3042
3456
|
}
|
|
3043
3457
|
}
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
} else {
|
|
3053
|
-
messagesPrompt.messages.push({
|
|
3054
|
-
role: "assistant",
|
|
3055
|
-
content: [
|
|
3056
|
-
{
|
|
3057
|
-
type: "text",
|
|
3058
|
-
text: anthropicOptions.prefill.trim(),
|
|
3059
|
-
cache_control: void 0
|
|
3060
|
-
}
|
|
3061
|
-
]
|
|
3062
|
-
});
|
|
3063
|
-
}
|
|
3458
|
+
let thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
3459
|
+
if (thinkingType === "adaptive" && !supportsAdaptiveThinking) {
|
|
3460
|
+
warnings.push({
|
|
3461
|
+
type: "unsupported",
|
|
3462
|
+
feature: "adaptive-thinking",
|
|
3463
|
+
details: `adaptive thinking is not supported by ${this.modelId} and will be ignored`
|
|
3464
|
+
});
|
|
3465
|
+
thinkingType = void 0;
|
|
3064
3466
|
}
|
|
3065
|
-
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3066
3467
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3067
|
-
let thinkingBudget =
|
|
3468
|
+
let thinkingBudget = ((_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.type) === "enabled" ? anthropicOptions.thinking.budgetTokens : void 0;
|
|
3469
|
+
const thinkingDisplay = ((_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.type) === "adaptive" ? anthropicOptions.thinking.display : void 0;
|
|
3068
3470
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3069
3471
|
const baseArgs = {
|
|
3070
3472
|
// model id:
|
|
@@ -3080,20 +3482,27 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3080
3482
|
thinking: {
|
|
3081
3483
|
type: thinkingType,
|
|
3082
3484
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3083
|
-
...
|
|
3084
|
-
display: anthropicOptions.thinking.display
|
|
3085
|
-
}
|
|
3485
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
3086
3486
|
}
|
|
3087
3487
|
},
|
|
3088
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3488
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3089
3489
|
output_config: {
|
|
3090
3490
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
3091
3491
|
effort: anthropicOptions.effort
|
|
3092
3492
|
},
|
|
3493
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3494
|
+
task_budget: {
|
|
3495
|
+
type: anthropicOptions.taskBudget.type,
|
|
3496
|
+
total: anthropicOptions.taskBudget.total,
|
|
3497
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3498
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
},
|
|
3093
3502
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
3094
3503
|
format: {
|
|
3095
3504
|
type: "json_schema",
|
|
3096
|
-
schema: responseFormat.schema
|
|
3505
|
+
schema: sanitizeJsonSchema(responseFormat.schema)
|
|
3097
3506
|
}
|
|
3098
3507
|
}
|
|
3099
3508
|
}
|
|
@@ -3101,19 +3510,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3101
3510
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3102
3511
|
speed: anthropicOptions.speed
|
|
3103
3512
|
},
|
|
3104
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.
|
|
3105
|
-
|
|
3106
|
-
...anthropicOptions.metadata.userId && {
|
|
3107
|
-
user_id: anthropicOptions.metadata.userId
|
|
3108
|
-
}
|
|
3109
|
-
}
|
|
3513
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3514
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3110
3515
|
},
|
|
3111
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.
|
|
3112
|
-
|
|
3516
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.advisor) && {
|
|
3517
|
+
advisor: {
|
|
3518
|
+
model: anthropicOptions.advisor.model
|
|
3519
|
+
}
|
|
3113
3520
|
},
|
|
3114
3521
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3115
3522
|
cache_control: anthropicOptions.cacheControl
|
|
3116
3523
|
},
|
|
3524
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3525
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3526
|
+
},
|
|
3117
3527
|
// mcp servers:
|
|
3118
3528
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3119
3529
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3135,7 +3545,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3135
3545
|
id: anthropicOptions.container.id,
|
|
3136
3546
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3137
3547
|
type: skill.type,
|
|
3138
|
-
skill_id: skill.
|
|
3548
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3549
|
+
reference: skill.providerReference,
|
|
3550
|
+
provider: "anthropic"
|
|
3551
|
+
}) : skill.skillId,
|
|
3139
3552
|
version: skill.version
|
|
3140
3553
|
}))
|
|
3141
3554
|
}
|
|
@@ -3236,28 +3649,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3236
3649
|
});
|
|
3237
3650
|
}
|
|
3238
3651
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3239
|
-
} else {
|
|
3240
|
-
if (topP != null && temperature != null) {
|
|
3241
|
-
warnings.push({
|
|
3242
|
-
type: "unsupported",
|
|
3243
|
-
feature: "topP",
|
|
3244
|
-
details: `topP is not supported when temperature is set. topP is ignored.`
|
|
3245
|
-
});
|
|
3246
|
-
baseArgs.top_p = void 0;
|
|
3247
|
-
}
|
|
3248
3652
|
}
|
|
3249
|
-
|
|
3653
|
+
const effectiveMaxTokens = (anthropicOptions == null ? void 0 : anthropicOptions.output300k) ? Math.max(maxOutputTokensForModel, 3e5) : maxOutputTokensForModel;
|
|
3654
|
+
if (isKnownModel && baseArgs.max_tokens > effectiveMaxTokens) {
|
|
3250
3655
|
if (maxOutputTokens != null) {
|
|
3251
3656
|
warnings.push({
|
|
3252
3657
|
type: "unsupported",
|
|
3253
3658
|
feature: "maxOutputTokens",
|
|
3254
|
-
details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${
|
|
3659
|
+
details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${effectiveMaxTokens} max output tokens. The max output tokens have been limited to ${effectiveMaxTokens}.`
|
|
3255
3660
|
});
|
|
3256
3661
|
}
|
|
3257
|
-
baseArgs.max_tokens =
|
|
3662
|
+
baseArgs.max_tokens = effectiveMaxTokens;
|
|
3258
3663
|
}
|
|
3259
3664
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0) {
|
|
3260
|
-
betas.add("mcp-client-2025-
|
|
3665
|
+
betas.add("mcp-client-2025-11-20");
|
|
3261
3666
|
}
|
|
3262
3667
|
if (contextManagement) {
|
|
3263
3668
|
betas.add("context-management-2025-06-27");
|
|
@@ -3281,12 +3686,19 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3281
3686
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3282
3687
|
betas.add("effort-2025-11-24");
|
|
3283
3688
|
}
|
|
3689
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3690
|
+
betas.add("task-budgets-2026-03-13");
|
|
3691
|
+
}
|
|
3284
3692
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3285
3693
|
betas.add("fast-mode-2026-02-01");
|
|
3286
3694
|
}
|
|
3287
|
-
if (
|
|
3288
|
-
betas.add("
|
|
3695
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.advisor) {
|
|
3696
|
+
betas.add("advisor-tool-2026-03-01");
|
|
3289
3697
|
}
|
|
3698
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.output300k) {
|
|
3699
|
+
betas.add("output-300k-2026-03-24");
|
|
3700
|
+
}
|
|
3701
|
+
const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
|
|
3290
3702
|
const {
|
|
3291
3703
|
tools: anthropicTools2,
|
|
3292
3704
|
toolChoice: anthropicToolChoice,
|
|
@@ -3299,14 +3711,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3299
3711
|
disableParallelToolUse: true,
|
|
3300
3712
|
cacheControlValidator,
|
|
3301
3713
|
supportsStructuredOutput: false,
|
|
3302
|
-
supportsStrictTools
|
|
3714
|
+
supportsStrictTools,
|
|
3715
|
+
defaultEagerInputStreaming
|
|
3303
3716
|
} : {
|
|
3304
3717
|
tools: tools != null ? tools : [],
|
|
3305
3718
|
toolChoice,
|
|
3306
3719
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3307
3720
|
cacheControlValidator,
|
|
3308
3721
|
supportsStructuredOutput,
|
|
3309
|
-
supportsStrictTools
|
|
3722
|
+
supportsStrictTools,
|
|
3723
|
+
defaultEagerInputStreaming
|
|
3310
3724
|
}
|
|
3311
3725
|
);
|
|
3312
3726
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3323,7 +3737,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3323
3737
|
...betas,
|
|
3324
3738
|
...toolsBetas,
|
|
3325
3739
|
...userSuppliedBetas,
|
|
3326
|
-
...(
|
|
3740
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3327
3741
|
]),
|
|
3328
3742
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3329
3743
|
toolNameMapping,
|
|
@@ -3335,16 +3749,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3335
3749
|
betas,
|
|
3336
3750
|
headers
|
|
3337
3751
|
}) {
|
|
3338
|
-
return
|
|
3339
|
-
await
|
|
3752
|
+
return combineHeaders(
|
|
3753
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3340
3754
|
headers,
|
|
3341
3755
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3342
3756
|
);
|
|
3343
3757
|
}
|
|
3344
3758
|
async getBetasFromHeaders(requestHeaders) {
|
|
3345
3759
|
var _a, _b;
|
|
3346
|
-
const configHeaders = await
|
|
3347
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3760
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3761
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3348
3762
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3349
3763
|
return new Set(
|
|
3350
3764
|
[
|
|
@@ -3409,13 +3823,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3409
3823
|
responseHeaders,
|
|
3410
3824
|
value: response,
|
|
3411
3825
|
rawValue: rawResponse
|
|
3412
|
-
} = await
|
|
3826
|
+
} = await postJsonToApi({
|
|
3413
3827
|
url: this.buildRequestUrl(false),
|
|
3414
3828
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3415
3829
|
body: this.transformRequestBody(args, betas),
|
|
3416
3830
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3417
|
-
successfulResponseHandler:
|
|
3418
|
-
|
|
3831
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
3832
|
+
anthropicResponseSchema
|
|
3419
3833
|
),
|
|
3420
3834
|
abortSignal: options.abortSignal,
|
|
3421
3835
|
fetch: this.config.fetch
|
|
@@ -3764,7 +4178,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3764
4178
|
}),
|
|
3765
4179
|
raw: (_e = response.stop_reason) != null ? _e : void 0
|
|
3766
4180
|
},
|
|
3767
|
-
usage:
|
|
4181
|
+
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
3768
4182
|
request: { body: args },
|
|
3769
4183
|
response: {
|
|
3770
4184
|
id: (_f = response.id) != null ? _f : void 0,
|
|
@@ -3774,11 +4188,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3774
4188
|
},
|
|
3775
4189
|
warnings,
|
|
3776
4190
|
providerMetadata: (() => {
|
|
3777
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
4191
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
3778
4192
|
const anthropicMetadata = {
|
|
3779
4193
|
usage: response.usage,
|
|
3780
4194
|
cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
|
|
3781
|
-
|
|
4195
|
+
cacheReadInputTokens: (_b2 = response.usage.cache_read_input_tokens) != null ? _b2 : null,
|
|
4196
|
+
stopSequence: (_c2 = response.stop_sequence) != null ? _c2 : null,
|
|
3782
4197
|
iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
|
|
3783
4198
|
type: iter.type,
|
|
3784
4199
|
inputTokens: iter.input_tokens,
|
|
@@ -3787,15 +4202,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3787
4202
|
container: response.container ? {
|
|
3788
4203
|
expiresAt: response.container.expires_at,
|
|
3789
4204
|
id: response.container.id,
|
|
3790
|
-
skills: (
|
|
4205
|
+
skills: (_e2 = (_d2 = response.container.skills) == null ? void 0 : _d2.map((skill) => ({
|
|
3791
4206
|
type: skill.type,
|
|
3792
4207
|
skillId: skill.skill_id,
|
|
3793
4208
|
version: skill.version
|
|
3794
|
-
}))) != null ?
|
|
4209
|
+
}))) != null ? _e2 : null
|
|
3795
4210
|
} : null,
|
|
3796
|
-
contextManagement: (
|
|
4211
|
+
contextManagement: (_f2 = mapAnthropicResponseContextManagement(
|
|
3797
4212
|
response.context_management
|
|
3798
|
-
)) != null ?
|
|
4213
|
+
)) != null ? _f2 : null
|
|
3799
4214
|
};
|
|
3800
4215
|
const providerMetadata = {
|
|
3801
4216
|
anthropic: anthropicMetadata
|
|
@@ -3808,6 +4223,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3808
4223
|
};
|
|
3809
4224
|
}
|
|
3810
4225
|
async doStream(options) {
|
|
4226
|
+
"use step";
|
|
3811
4227
|
var _a, _b;
|
|
3812
4228
|
const {
|
|
3813
4229
|
args: body,
|
|
@@ -3829,14 +4245,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3829
4245
|
body.tools
|
|
3830
4246
|
);
|
|
3831
4247
|
const url = this.buildRequestUrl(true);
|
|
3832
|
-
const { responseHeaders, value: response } = await
|
|
4248
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3833
4249
|
url,
|
|
3834
4250
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3835
4251
|
body: this.transformRequestBody(body, betas),
|
|
3836
4252
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3837
|
-
successfulResponseHandler: (
|
|
3838
|
-
anthropicMessagesChunkSchema
|
|
3839
|
-
),
|
|
4253
|
+
successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
|
|
3840
4254
|
abortSignal: options.abortSignal,
|
|
3841
4255
|
fetch: this.config.fetch
|
|
3842
4256
|
});
|
|
@@ -3856,7 +4270,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3856
4270
|
const serverToolCalls = {};
|
|
3857
4271
|
let contextManagement = null;
|
|
3858
4272
|
let rawUsage = void 0;
|
|
3859
|
-
let cacheCreationInputTokens = null;
|
|
3860
4273
|
let stopSequence = null;
|
|
3861
4274
|
let container = null;
|
|
3862
4275
|
let isJsonResponseFromTool = false;
|
|
@@ -3868,7 +4281,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3868
4281
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3869
4282
|
},
|
|
3870
4283
|
transform(chunk, controller) {
|
|
3871
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4284
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
3872
4285
|
if (options.includeRawChunks) {
|
|
3873
4286
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3874
4287
|
}
|
|
@@ -4403,7 +4816,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4403
4816
|
rawUsage = {
|
|
4404
4817
|
...value.message.usage
|
|
4405
4818
|
};
|
|
4406
|
-
cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
|
|
4407
4819
|
if (value.message.container != null) {
|
|
4408
4820
|
container = {
|
|
4409
4821
|
expiresAt: value.message.container.expires_at,
|
|
@@ -4422,8 +4834,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4422
4834
|
}
|
|
4423
4835
|
controller.enqueue({
|
|
4424
4836
|
type: "response-metadata",
|
|
4425
|
-
id: (
|
|
4426
|
-
modelId: (
|
|
4837
|
+
id: (_g = value.message.id) != null ? _g : void 0,
|
|
4838
|
+
modelId: (_h = value.message.model) != null ? _h : void 0
|
|
4427
4839
|
});
|
|
4428
4840
|
if (value.message.content != null) {
|
|
4429
4841
|
for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
|
|
@@ -4439,7 +4851,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4439
4851
|
id: part.id,
|
|
4440
4852
|
toolName: part.name
|
|
4441
4853
|
});
|
|
4442
|
-
const inputStr = JSON.stringify((
|
|
4854
|
+
const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
|
|
4443
4855
|
controller.enqueue({
|
|
4444
4856
|
type: "tool-input-delta",
|
|
4445
4857
|
id: part.id,
|
|
@@ -4477,7 +4889,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4477
4889
|
}
|
|
4478
4890
|
if (value.usage.cache_creation_input_tokens != null) {
|
|
4479
4891
|
usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
|
|
4480
|
-
cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
|
|
4481
4892
|
}
|
|
4482
4893
|
if (value.usage.iterations != null) {
|
|
4483
4894
|
usage.iterations = value.usage.iterations;
|
|
@@ -4487,17 +4898,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4487
4898
|
finishReason: value.delta.stop_reason,
|
|
4488
4899
|
isJsonResponseFromTool
|
|
4489
4900
|
}),
|
|
4490
|
-
raw: (
|
|
4901
|
+
raw: (_j = value.delta.stop_reason) != null ? _j : void 0
|
|
4491
4902
|
};
|
|
4492
|
-
stopSequence = (
|
|
4903
|
+
stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
|
|
4493
4904
|
container = value.delta.container != null ? {
|
|
4494
4905
|
expiresAt: value.delta.container.expires_at,
|
|
4495
4906
|
id: value.delta.container.id,
|
|
4496
|
-
skills: (
|
|
4907
|
+
skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
|
|
4497
4908
|
type: skill.type,
|
|
4498
4909
|
skillId: skill.skill_id,
|
|
4499
4910
|
version: skill.version
|
|
4500
|
-
}))) != null ?
|
|
4911
|
+
}))) != null ? _m : null
|
|
4501
4912
|
} : null;
|
|
4502
4913
|
if (value.context_management) {
|
|
4503
4914
|
contextManagement = mapAnthropicResponseContextManagement(
|
|
@@ -4513,7 +4924,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4513
4924
|
case "message_stop": {
|
|
4514
4925
|
const anthropicMetadata = {
|
|
4515
4926
|
usage: rawUsage != null ? rawUsage : null,
|
|
4516
|
-
cacheCreationInputTokens,
|
|
4927
|
+
cacheCreationInputTokens: (_n = usage.cache_creation_input_tokens) != null ? _n : null,
|
|
4928
|
+
cacheReadInputTokens: (_o = usage.cache_read_input_tokens) != null ? _o : null,
|
|
4517
4929
|
stopSequence,
|
|
4518
4930
|
iterations: usage.iterations ? usage.iterations.map((iter) => ({
|
|
4519
4931
|
type: iter.type,
|
|
@@ -4532,7 +4944,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4532
4944
|
controller.enqueue({
|
|
4533
4945
|
type: "finish",
|
|
4534
4946
|
finishReason,
|
|
4535
|
-
usage:
|
|
4947
|
+
usage: convertAnthropicUsage({ usage, rawUsage }),
|
|
4536
4948
|
providerMetadata
|
|
4537
4949
|
});
|
|
4538
4950
|
return;
|
|
@@ -4559,7 +4971,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4559
4971
|
}
|
|
4560
4972
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4561
4973
|
const error = result.value.error;
|
|
4562
|
-
throw new
|
|
4974
|
+
throw new APICallError({
|
|
4563
4975
|
message: error.message,
|
|
4564
4976
|
url,
|
|
4565
4977
|
requestBodyValues: body,
|
|
@@ -4582,11 +4994,22 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4582
4994
|
}
|
|
4583
4995
|
};
|
|
4584
4996
|
function getModelCapabilities(modelId) {
|
|
4585
|
-
if (modelId.includes("claude-
|
|
4997
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4586
4998
|
return {
|
|
4587
4999
|
maxOutputTokens: 128e3,
|
|
4588
5000
|
supportsStructuredOutput: true,
|
|
4589
5001
|
supportsAdaptiveThinking: true,
|
|
5002
|
+
rejectsSamplingParameters: true,
|
|
5003
|
+
supportsXhighEffort: true,
|
|
5004
|
+
isKnownModel: true
|
|
5005
|
+
};
|
|
5006
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
5007
|
+
return {
|
|
5008
|
+
maxOutputTokens: 128e3,
|
|
5009
|
+
supportsStructuredOutput: true,
|
|
5010
|
+
supportsAdaptiveThinking: true,
|
|
5011
|
+
rejectsSamplingParameters: false,
|
|
5012
|
+
supportsXhighEffort: false,
|
|
4590
5013
|
isKnownModel: true
|
|
4591
5014
|
};
|
|
4592
5015
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
@@ -4594,6 +5017,8 @@ function getModelCapabilities(modelId) {
|
|
|
4594
5017
|
maxOutputTokens: 64e3,
|
|
4595
5018
|
supportsStructuredOutput: true,
|
|
4596
5019
|
supportsAdaptiveThinking: false,
|
|
5020
|
+
rejectsSamplingParameters: false,
|
|
5021
|
+
supportsXhighEffort: false,
|
|
4597
5022
|
isKnownModel: true
|
|
4598
5023
|
};
|
|
4599
5024
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
@@ -4601,6 +5026,8 @@ function getModelCapabilities(modelId) {
|
|
|
4601
5026
|
maxOutputTokens: 32e3,
|
|
4602
5027
|
supportsStructuredOutput: true,
|
|
4603
5028
|
supportsAdaptiveThinking: false,
|
|
5029
|
+
rejectsSamplingParameters: false,
|
|
5030
|
+
supportsXhighEffort: false,
|
|
4604
5031
|
isKnownModel: true
|
|
4605
5032
|
};
|
|
4606
5033
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
@@ -4608,6 +5035,8 @@ function getModelCapabilities(modelId) {
|
|
|
4608
5035
|
maxOutputTokens: 64e3,
|
|
4609
5036
|
supportsStructuredOutput: false,
|
|
4610
5037
|
supportsAdaptiveThinking: false,
|
|
5038
|
+
rejectsSamplingParameters: false,
|
|
5039
|
+
supportsXhighEffort: false,
|
|
4611
5040
|
isKnownModel: true
|
|
4612
5041
|
};
|
|
4613
5042
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
@@ -4615,6 +5044,8 @@ function getModelCapabilities(modelId) {
|
|
|
4615
5044
|
maxOutputTokens: 32e3,
|
|
4616
5045
|
supportsStructuredOutput: false,
|
|
4617
5046
|
supportsAdaptiveThinking: false,
|
|
5047
|
+
rejectsSamplingParameters: false,
|
|
5048
|
+
supportsXhighEffort: false,
|
|
4618
5049
|
isKnownModel: true
|
|
4619
5050
|
};
|
|
4620
5051
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
@@ -4622,6 +5053,8 @@ function getModelCapabilities(modelId) {
|
|
|
4622
5053
|
maxOutputTokens: 4096,
|
|
4623
5054
|
supportsStructuredOutput: false,
|
|
4624
5055
|
supportsAdaptiveThinking: false,
|
|
5056
|
+
rejectsSamplingParameters: false,
|
|
5057
|
+
supportsXhighEffort: false,
|
|
4625
5058
|
isKnownModel: true
|
|
4626
5059
|
};
|
|
4627
5060
|
} else {
|
|
@@ -4629,6 +5062,8 @@ function getModelCapabilities(modelId) {
|
|
|
4629
5062
|
maxOutputTokens: 4096,
|
|
4630
5063
|
supportsStructuredOutput: false,
|
|
4631
5064
|
supportsAdaptiveThinking: false,
|
|
5065
|
+
rejectsSamplingParameters: false,
|
|
5066
|
+
supportsXhighEffort: false,
|
|
4632
5067
|
isKnownModel: false
|
|
4633
5068
|
};
|
|
4634
5069
|
}
|
|
@@ -4654,30 +5089,31 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4654
5089
|
function resolveAnthropicReasoningConfig({
|
|
4655
5090
|
reasoning,
|
|
4656
5091
|
supportsAdaptiveThinking,
|
|
5092
|
+
supportsXhighEffort,
|
|
4657
5093
|
maxOutputTokensForModel,
|
|
4658
5094
|
warnings
|
|
4659
5095
|
}) {
|
|
4660
|
-
if (!
|
|
5096
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4661
5097
|
return void 0;
|
|
4662
5098
|
}
|
|
4663
5099
|
if (reasoning === "none") {
|
|
4664
5100
|
return { thinking: { type: "disabled" } };
|
|
4665
5101
|
}
|
|
4666
5102
|
if (supportsAdaptiveThinking) {
|
|
4667
|
-
const effort =
|
|
5103
|
+
const effort = mapReasoningToProviderEffort({
|
|
4668
5104
|
reasoning,
|
|
4669
5105
|
effortMap: {
|
|
4670
5106
|
minimal: "low",
|
|
4671
5107
|
low: "low",
|
|
4672
5108
|
medium: "medium",
|
|
4673
5109
|
high: "high",
|
|
4674
|
-
xhigh: "max"
|
|
5110
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
4675
5111
|
},
|
|
4676
5112
|
warnings
|
|
4677
5113
|
});
|
|
4678
5114
|
return { thinking: { type: "adaptive" }, effort };
|
|
4679
5115
|
}
|
|
4680
|
-
const budgetTokens =
|
|
5116
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4681
5117
|
reasoning,
|
|
4682
5118
|
maxOutputTokens: maxOutputTokensForModel,
|
|
4683
5119
|
maxReasoningBudget: maxOutputTokensForModel,
|
|
@@ -4715,44 +5151,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4715
5151
|
}
|
|
4716
5152
|
|
|
4717
5153
|
// src/tool/bash_20241022.ts
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
5154
|
+
import {
|
|
5155
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
5156
|
+
lazySchema as lazySchema13,
|
|
5157
|
+
zodSchema as zodSchema13
|
|
5158
|
+
} from "@ai-sdk/provider-utils";
|
|
5159
|
+
import { z as z14 } from "zod/v4";
|
|
5160
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
5161
|
+
() => zodSchema13(
|
|
5162
|
+
z14.object({
|
|
5163
|
+
command: z14.string(),
|
|
5164
|
+
restart: z14.boolean().optional()
|
|
4725
5165
|
})
|
|
4726
5166
|
)
|
|
4727
5167
|
);
|
|
4728
|
-
var bash_20241022 = (
|
|
5168
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
4729
5169
|
id: "anthropic.bash_20241022",
|
|
4730
5170
|
inputSchema: bash_20241022InputSchema
|
|
4731
5171
|
});
|
|
4732
5172
|
|
|
4733
5173
|
// src/tool/bash_20250124.ts
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
5174
|
+
import {
|
|
5175
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
5176
|
+
lazySchema as lazySchema14,
|
|
5177
|
+
zodSchema as zodSchema14
|
|
5178
|
+
} from "@ai-sdk/provider-utils";
|
|
5179
|
+
import { z as z15 } from "zod/v4";
|
|
5180
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
5181
|
+
() => zodSchema14(
|
|
5182
|
+
z15.object({
|
|
5183
|
+
command: z15.string(),
|
|
5184
|
+
restart: z15.boolean().optional()
|
|
4741
5185
|
})
|
|
4742
5186
|
)
|
|
4743
5187
|
);
|
|
4744
|
-
var bash_20250124 = (
|
|
5188
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
4745
5189
|
id: "anthropic.bash_20250124",
|
|
4746
5190
|
inputSchema: bash_20250124InputSchema
|
|
4747
5191
|
});
|
|
4748
5192
|
|
|
4749
5193
|
// src/tool/computer_20241022.ts
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
5194
|
+
import {
|
|
5195
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
5196
|
+
lazySchema as lazySchema15,
|
|
5197
|
+
zodSchema as zodSchema15
|
|
5198
|
+
} from "@ai-sdk/provider-utils";
|
|
5199
|
+
import { z as z16 } from "zod/v4";
|
|
5200
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
5201
|
+
() => zodSchema15(
|
|
5202
|
+
z16.object({
|
|
5203
|
+
action: z16.enum([
|
|
4756
5204
|
"key",
|
|
4757
5205
|
"type",
|
|
4758
5206
|
"mouse_move",
|
|
@@ -4764,23 +5212,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4764
5212
|
"screenshot",
|
|
4765
5213
|
"cursor_position"
|
|
4766
5214
|
]),
|
|
4767
|
-
coordinate:
|
|
4768
|
-
text:
|
|
5215
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
5216
|
+
text: z16.string().optional()
|
|
4769
5217
|
})
|
|
4770
5218
|
)
|
|
4771
5219
|
);
|
|
4772
|
-
var computer_20241022 = (
|
|
5220
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
4773
5221
|
id: "anthropic.computer_20241022",
|
|
4774
5222
|
inputSchema: computer_20241022InputSchema
|
|
4775
5223
|
});
|
|
4776
5224
|
|
|
4777
5225
|
// src/tool/computer_20250124.ts
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
5226
|
+
import {
|
|
5227
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
5228
|
+
lazySchema as lazySchema16,
|
|
5229
|
+
zodSchema as zodSchema16
|
|
5230
|
+
} from "@ai-sdk/provider-utils";
|
|
5231
|
+
import { z as z17 } from "zod/v4";
|
|
5232
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
5233
|
+
() => zodSchema16(
|
|
5234
|
+
z17.object({
|
|
5235
|
+
action: z17.enum([
|
|
4784
5236
|
"key",
|
|
4785
5237
|
"hold_key",
|
|
4786
5238
|
"type",
|
|
@@ -4798,27 +5250,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4798
5250
|
"wait",
|
|
4799
5251
|
"screenshot"
|
|
4800
5252
|
]),
|
|
4801
|
-
coordinate:
|
|
4802
|
-
duration:
|
|
4803
|
-
scroll_amount:
|
|
4804
|
-
scroll_direction:
|
|
4805
|
-
start_coordinate:
|
|
4806
|
-
text:
|
|
5253
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5254
|
+
duration: z17.number().optional(),
|
|
5255
|
+
scroll_amount: z17.number().optional(),
|
|
5256
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5257
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5258
|
+
text: z17.string().optional()
|
|
4807
5259
|
})
|
|
4808
5260
|
)
|
|
4809
5261
|
);
|
|
4810
|
-
var computer_20250124 = (
|
|
5262
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
4811
5263
|
id: "anthropic.computer_20250124",
|
|
4812
5264
|
inputSchema: computer_20250124InputSchema
|
|
4813
5265
|
});
|
|
4814
5266
|
|
|
4815
5267
|
// src/tool/computer_20251124.ts
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
5268
|
+
import {
|
|
5269
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
5270
|
+
lazySchema as lazySchema17,
|
|
5271
|
+
zodSchema as zodSchema17
|
|
5272
|
+
} from "@ai-sdk/provider-utils";
|
|
5273
|
+
import { z as z18 } from "zod/v4";
|
|
5274
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
5275
|
+
() => zodSchema17(
|
|
5276
|
+
z18.object({
|
|
5277
|
+
action: z18.enum([
|
|
4822
5278
|
"key",
|
|
4823
5279
|
"hold_key",
|
|
4824
5280
|
"type",
|
|
@@ -4837,173 +5293,193 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4837
5293
|
"screenshot",
|
|
4838
5294
|
"zoom"
|
|
4839
5295
|
]),
|
|
4840
|
-
coordinate:
|
|
4841
|
-
duration:
|
|
4842
|
-
region:
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
5296
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5297
|
+
duration: z18.number().optional(),
|
|
5298
|
+
region: z18.tuple([
|
|
5299
|
+
z18.number().int(),
|
|
5300
|
+
z18.number().int(),
|
|
5301
|
+
z18.number().int(),
|
|
5302
|
+
z18.number().int()
|
|
4847
5303
|
]).optional(),
|
|
4848
|
-
scroll_amount:
|
|
4849
|
-
scroll_direction:
|
|
4850
|
-
start_coordinate:
|
|
4851
|
-
text:
|
|
5304
|
+
scroll_amount: z18.number().optional(),
|
|
5305
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
5306
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5307
|
+
text: z18.string().optional()
|
|
4852
5308
|
})
|
|
4853
5309
|
)
|
|
4854
5310
|
);
|
|
4855
|
-
var computer_20251124 = (
|
|
5311
|
+
var computer_20251124 = createProviderDefinedToolFactory6({
|
|
4856
5312
|
id: "anthropic.computer_20251124",
|
|
4857
5313
|
inputSchema: computer_20251124InputSchema
|
|
4858
5314
|
});
|
|
4859
5315
|
|
|
4860
5316
|
// src/tool/memory_20250818.ts
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
5317
|
+
import {
|
|
5318
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
5319
|
+
lazySchema as lazySchema18,
|
|
5320
|
+
zodSchema as zodSchema18
|
|
5321
|
+
} from "@ai-sdk/provider-utils";
|
|
5322
|
+
import { z as z19 } from "zod/v4";
|
|
5323
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
5324
|
+
() => zodSchema18(
|
|
5325
|
+
z19.discriminatedUnion("command", [
|
|
5326
|
+
z19.object({
|
|
5327
|
+
command: z19.literal("view"),
|
|
5328
|
+
path: z19.string(),
|
|
5329
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4870
5330
|
}),
|
|
4871
|
-
|
|
4872
|
-
command:
|
|
4873
|
-
path:
|
|
4874
|
-
file_text:
|
|
5331
|
+
z19.object({
|
|
5332
|
+
command: z19.literal("create"),
|
|
5333
|
+
path: z19.string(),
|
|
5334
|
+
file_text: z19.string()
|
|
4875
5335
|
}),
|
|
4876
|
-
|
|
4877
|
-
command:
|
|
4878
|
-
path:
|
|
4879
|
-
old_str:
|
|
4880
|
-
new_str:
|
|
5336
|
+
z19.object({
|
|
5337
|
+
command: z19.literal("str_replace"),
|
|
5338
|
+
path: z19.string(),
|
|
5339
|
+
old_str: z19.string(),
|
|
5340
|
+
new_str: z19.string()
|
|
4881
5341
|
}),
|
|
4882
|
-
|
|
4883
|
-
command:
|
|
4884
|
-
path:
|
|
4885
|
-
insert_line:
|
|
4886
|
-
insert_text:
|
|
5342
|
+
z19.object({
|
|
5343
|
+
command: z19.literal("insert"),
|
|
5344
|
+
path: z19.string(),
|
|
5345
|
+
insert_line: z19.number(),
|
|
5346
|
+
insert_text: z19.string()
|
|
4887
5347
|
}),
|
|
4888
|
-
|
|
4889
|
-
command:
|
|
4890
|
-
path:
|
|
5348
|
+
z19.object({
|
|
5349
|
+
command: z19.literal("delete"),
|
|
5350
|
+
path: z19.string()
|
|
4891
5351
|
}),
|
|
4892
|
-
|
|
4893
|
-
command:
|
|
4894
|
-
old_path:
|
|
4895
|
-
new_path:
|
|
5352
|
+
z19.object({
|
|
5353
|
+
command: z19.literal("rename"),
|
|
5354
|
+
old_path: z19.string(),
|
|
5355
|
+
new_path: z19.string()
|
|
4896
5356
|
})
|
|
4897
5357
|
])
|
|
4898
5358
|
)
|
|
4899
5359
|
);
|
|
4900
|
-
var memory_20250818 = (
|
|
5360
|
+
var memory_20250818 = createProviderDefinedToolFactory7({
|
|
4901
5361
|
id: "anthropic.memory_20250818",
|
|
4902
5362
|
inputSchema: memory_20250818InputSchema
|
|
4903
5363
|
});
|
|
4904
5364
|
|
|
4905
5365
|
// src/tool/text-editor_20241022.ts
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
5366
|
+
import {
|
|
5367
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
5368
|
+
lazySchema as lazySchema19,
|
|
5369
|
+
zodSchema as zodSchema19
|
|
5370
|
+
} from "@ai-sdk/provider-utils";
|
|
5371
|
+
import { z as z20 } from "zod/v4";
|
|
5372
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
5373
|
+
() => zodSchema19(
|
|
5374
|
+
z20.object({
|
|
5375
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5376
|
+
path: z20.string(),
|
|
5377
|
+
file_text: z20.string().optional(),
|
|
5378
|
+
insert_line: z20.number().int().optional(),
|
|
5379
|
+
new_str: z20.string().optional(),
|
|
5380
|
+
insert_text: z20.string().optional(),
|
|
5381
|
+
old_str: z20.string().optional(),
|
|
5382
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4919
5383
|
})
|
|
4920
5384
|
)
|
|
4921
5385
|
);
|
|
4922
|
-
var textEditor_20241022 = (
|
|
5386
|
+
var textEditor_20241022 = createProviderDefinedToolFactory8({
|
|
4923
5387
|
id: "anthropic.text_editor_20241022",
|
|
4924
5388
|
inputSchema: textEditor_20241022InputSchema
|
|
4925
5389
|
});
|
|
4926
5390
|
|
|
4927
5391
|
// src/tool/text-editor_20250124.ts
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
5392
|
+
import {
|
|
5393
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
5394
|
+
lazySchema as lazySchema20,
|
|
5395
|
+
zodSchema as zodSchema20
|
|
5396
|
+
} from "@ai-sdk/provider-utils";
|
|
5397
|
+
import { z as z21 } from "zod/v4";
|
|
5398
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
5399
|
+
() => zodSchema20(
|
|
5400
|
+
z21.object({
|
|
5401
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5402
|
+
path: z21.string(),
|
|
5403
|
+
file_text: z21.string().optional(),
|
|
5404
|
+
insert_line: z21.number().int().optional(),
|
|
5405
|
+
new_str: z21.string().optional(),
|
|
5406
|
+
insert_text: z21.string().optional(),
|
|
5407
|
+
old_str: z21.string().optional(),
|
|
5408
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4941
5409
|
})
|
|
4942
5410
|
)
|
|
4943
5411
|
);
|
|
4944
|
-
var textEditor_20250124 = (
|
|
5412
|
+
var textEditor_20250124 = createProviderDefinedToolFactory9({
|
|
4945
5413
|
id: "anthropic.text_editor_20250124",
|
|
4946
5414
|
inputSchema: textEditor_20250124InputSchema
|
|
4947
5415
|
});
|
|
4948
5416
|
|
|
4949
5417
|
// src/tool/text-editor_20250429.ts
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
5418
|
+
import {
|
|
5419
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
|
|
5420
|
+
lazySchema as lazySchema21,
|
|
5421
|
+
zodSchema as zodSchema21
|
|
5422
|
+
} from "@ai-sdk/provider-utils";
|
|
5423
|
+
import { z as z22 } from "zod/v4";
|
|
5424
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
5425
|
+
() => zodSchema21(
|
|
5426
|
+
z22.object({
|
|
5427
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5428
|
+
path: z22.string(),
|
|
5429
|
+
file_text: z22.string().optional(),
|
|
5430
|
+
insert_line: z22.number().int().optional(),
|
|
5431
|
+
new_str: z22.string().optional(),
|
|
5432
|
+
insert_text: z22.string().optional(),
|
|
5433
|
+
old_str: z22.string().optional(),
|
|
5434
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
4963
5435
|
})
|
|
4964
5436
|
)
|
|
4965
5437
|
);
|
|
4966
|
-
var textEditor_20250429 = (
|
|
5438
|
+
var textEditor_20250429 = createProviderDefinedToolFactory10({
|
|
4967
5439
|
id: "anthropic.text_editor_20250429",
|
|
4968
5440
|
inputSchema: textEditor_20250429InputSchema
|
|
4969
5441
|
});
|
|
4970
5442
|
|
|
4971
5443
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
5444
|
+
import {
|
|
5445
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
|
|
5446
|
+
lazySchema as lazySchema22,
|
|
5447
|
+
zodSchema as zodSchema22
|
|
5448
|
+
} from "@ai-sdk/provider-utils";
|
|
5449
|
+
import { z as z23 } from "zod/v4";
|
|
5450
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5451
|
+
() => zodSchema22(
|
|
5452
|
+
z23.array(
|
|
5453
|
+
z23.object({
|
|
5454
|
+
type: z23.literal("tool_reference"),
|
|
5455
|
+
toolName: z23.string()
|
|
4980
5456
|
})
|
|
4981
5457
|
)
|
|
4982
5458
|
)
|
|
4983
5459
|
);
|
|
4984
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4985
|
-
() => (
|
|
4986
|
-
|
|
5460
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5461
|
+
() => zodSchema22(
|
|
5462
|
+
z23.object({
|
|
4987
5463
|
/**
|
|
4988
5464
|
* A natural language query to search for tools.
|
|
4989
5465
|
* Claude will use BM25 text search to find relevant tools.
|
|
4990
5466
|
*/
|
|
4991
|
-
query:
|
|
5467
|
+
query: z23.string(),
|
|
4992
5468
|
/**
|
|
4993
5469
|
* Maximum number of tools to return. Optional.
|
|
4994
5470
|
*/
|
|
4995
|
-
limit:
|
|
5471
|
+
limit: z23.number().optional()
|
|
4996
5472
|
})
|
|
4997
5473
|
)
|
|
4998
5474
|
);
|
|
4999
|
-
var
|
|
5475
|
+
var factory11 = createProviderExecutedToolFactory9({
|
|
5000
5476
|
id: "anthropic.tool_search_bm25_20251119",
|
|
5001
5477
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
5002
5478
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
5003
5479
|
supportsDeferredResults: true
|
|
5004
5480
|
});
|
|
5005
5481
|
var toolSearchBm25_20251119 = (args = {}) => {
|
|
5006
|
-
return
|
|
5482
|
+
return factory11(args);
|
|
5007
5483
|
};
|
|
5008
5484
|
|
|
5009
5485
|
// src/anthropic-tools.ts
|
|
@@ -5160,6 +5636,22 @@ var anthropicTools = {
|
|
|
5160
5636
|
* @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
|
|
5161
5637
|
*/
|
|
5162
5638
|
webFetch_20260209,
|
|
5639
|
+
/**
|
|
5640
|
+
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
5641
|
+
* GA version (no beta header required). Includes caller restrictions, cache control,
|
|
5642
|
+
* deferred loading, and strict mode.
|
|
5643
|
+
*
|
|
5644
|
+
* @param maxUses - The max_uses parameter limits the number of web fetches performed
|
|
5645
|
+
* @param allowedDomains - Only fetch from these domains
|
|
5646
|
+
* @param blockedDomains - Never fetch from these domains
|
|
5647
|
+
* @param citations - Citations configuration for fetched documents
|
|
5648
|
+
* @param maxContentTokens - Max content tokens included in context
|
|
5649
|
+
* @param allowedCallers - Restrict callers (e.g. ["direct"] to prevent code_execution usage)
|
|
5650
|
+
* @param useCache - Whether to use cached content (set false for fresh content)
|
|
5651
|
+
* @param deferLoading - Defer loading until tool_search discovers it
|
|
5652
|
+
* @param strict - Enable strict schema validation
|
|
5653
|
+
*/
|
|
5654
|
+
webFetch_20260309,
|
|
5163
5655
|
/**
|
|
5164
5656
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
5165
5657
|
*
|
|
@@ -5207,11 +5699,11 @@ var anthropicTools = {
|
|
|
5207
5699
|
*/
|
|
5208
5700
|
toolSearchBm25_20251119
|
|
5209
5701
|
};
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
AnthropicMessagesLanguageModel,
|
|
5702
|
+
export {
|
|
5703
|
+
AnthropicLanguageModel,
|
|
5704
|
+
AnthropicLanguageModel as AnthropicMessagesLanguageModel,
|
|
5213
5705
|
anthropicTools,
|
|
5214
5706
|
getModelCapabilities,
|
|
5215
5707
|
prepareTools
|
|
5216
|
-
}
|
|
5708
|
+
};
|
|
5217
5709
|
//# sourceMappingURL=index.js.map
|