@ai-sdk/anthropic 4.0.0-beta.2 → 4.0.0-beta.21
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 +148 -4
- package/README.md +2 -0
- package/dist/index.d.mts +50 -38
- package/dist/index.d.ts +50 -38
- package/dist/index.js +1403 -1075
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1440 -1091
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +64 -43
- package/dist/internal/index.d.ts +64 -43
- package/dist/internal/index.js +143 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +146 -23
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +53 -6
- package/package.json +3 -5
- package/src/anthropic-files.ts +106 -0
- package/src/anthropic-messages-api.ts +4 -0
- package/src/anthropic-messages-language-model.ts +147 -38
- package/src/anthropic-messages-options.ts +29 -5
- package/src/anthropic-prepare-tools.ts +22 -10
- package/src/anthropic-provider.ts +38 -9
- package/src/convert-anthropic-messages-usage.ts +2 -2
- package/src/convert-to-anthropic-messages-prompt.ts +40 -18
- package/src/get-cache-control.ts +5 -5
- package/src/internal/index.ts +4 -1
- package/src/map-anthropic-stop-reason.ts +2 -2
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +136 -0
package/dist/index.mjs
CHANGED
|
@@ -11,23 +11,17 @@ import {
|
|
|
11
11
|
withUserAgentSuffix
|
|
12
12
|
} from "@ai-sdk/provider-utils";
|
|
13
13
|
|
|
14
|
-
// src/
|
|
15
|
-
var VERSION = true ? "4.0.0-beta.2" : "0.0.0-test";
|
|
16
|
-
|
|
17
|
-
// src/anthropic-messages-language-model.ts
|
|
18
|
-
import {
|
|
19
|
-
APICallError
|
|
20
|
-
} from "@ai-sdk/provider";
|
|
14
|
+
// src/anthropic-files.ts
|
|
21
15
|
import {
|
|
22
16
|
combineHeaders,
|
|
23
|
-
|
|
17
|
+
convertBase64ToUint8Array,
|
|
24
18
|
createJsonResponseHandler,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
resolve
|
|
19
|
+
lazySchema as lazySchema2,
|
|
20
|
+
parseProviderOptions,
|
|
21
|
+
postFormDataToApi,
|
|
22
|
+
zodSchema as zodSchema2
|
|
30
23
|
} from "@ai-sdk/provider-utils";
|
|
24
|
+
import { z as z2 } from "zod/v4";
|
|
31
25
|
|
|
32
26
|
// src/anthropic-error.ts
|
|
33
27
|
import {
|
|
@@ -52,319 +46,411 @@ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
52
46
|
errorToMessage: (data) => data.error.message
|
|
53
47
|
});
|
|
54
48
|
|
|
55
|
-
// src/anthropic-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var anthropicMessagesResponseSchema = lazySchema2(
|
|
49
|
+
// src/anthropic-files.ts
|
|
50
|
+
var anthropicUploadFileProviderOptions = z2.object({});
|
|
51
|
+
var anthropicUploadFileResponseSchema = lazySchema2(
|
|
59
52
|
() => zodSchema2(
|
|
60
53
|
z2.object({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
54
|
+
id: z2.string(),
|
|
55
|
+
type: z2.literal("file"),
|
|
56
|
+
filename: z2.string(),
|
|
57
|
+
mime_type: z2.string(),
|
|
58
|
+
size_bytes: z2.number(),
|
|
59
|
+
created_at: z2.string(),
|
|
60
|
+
downloadable: z2.boolean().nullish()
|
|
61
|
+
})
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
var AnthropicFiles = class {
|
|
65
|
+
constructor(config) {
|
|
66
|
+
this.config = config;
|
|
67
|
+
this.specificationVersion = "v4";
|
|
68
|
+
}
|
|
69
|
+
get provider() {
|
|
70
|
+
return this.config.provider;
|
|
71
|
+
}
|
|
72
|
+
async uploadFile({
|
|
73
|
+
data,
|
|
74
|
+
mediaType,
|
|
75
|
+
filename,
|
|
76
|
+
providerOptions
|
|
77
|
+
}) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
const anthropicOptions = await parseProviderOptions({
|
|
80
|
+
provider: "anthropic",
|
|
81
|
+
providerOptions,
|
|
82
|
+
schema: zodSchema2(anthropicUploadFileProviderOptions)
|
|
83
|
+
});
|
|
84
|
+
const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
|
|
85
|
+
const blob = new Blob([fileBytes], { type: mediaType });
|
|
86
|
+
const formData = new FormData();
|
|
87
|
+
if (filename != null) {
|
|
88
|
+
formData.append("file", blob, filename);
|
|
89
|
+
} else {
|
|
90
|
+
formData.append("file", blob);
|
|
91
|
+
}
|
|
92
|
+
const { value: response } = await postFormDataToApi({
|
|
93
|
+
url: `${this.config.baseURL}/files`,
|
|
94
|
+
headers: combineHeaders(this.config.headers(), {
|
|
95
|
+
"anthropic-beta": "files-api-2025-04-14"
|
|
96
|
+
}),
|
|
97
|
+
formData,
|
|
98
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
99
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
100
|
+
anthropicUploadFileResponseSchema
|
|
101
|
+
),
|
|
102
|
+
fetch: this.config.fetch
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
warnings: [],
|
|
106
|
+
providerReference: { anthropic: response.id },
|
|
107
|
+
mediaType: (_a = response.mime_type) != null ? _a : mediaType,
|
|
108
|
+
filename: (_b = response.filename) != null ? _b : filename,
|
|
109
|
+
providerMetadata: {
|
|
110
|
+
anthropic: {
|
|
111
|
+
filename: response.filename,
|
|
112
|
+
mimeType: response.mime_type,
|
|
113
|
+
sizeBytes: response.size_bytes,
|
|
114
|
+
createdAt: response.created_at,
|
|
115
|
+
...response.downloadable != null ? { downloadable: response.downloadable } : {}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/anthropic-messages-language-model.ts
|
|
123
|
+
import {
|
|
124
|
+
APICallError
|
|
125
|
+
} from "@ai-sdk/provider";
|
|
126
|
+
import {
|
|
127
|
+
combineHeaders as combineHeaders2,
|
|
128
|
+
createEventSourceResponseHandler,
|
|
129
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
130
|
+
createToolNameMapping,
|
|
131
|
+
generateId,
|
|
132
|
+
isCustomReasoning,
|
|
133
|
+
mapReasoningToProviderBudget,
|
|
134
|
+
mapReasoningToProviderEffort,
|
|
135
|
+
parseProviderOptions as parseProviderOptions3,
|
|
136
|
+
postJsonToApi,
|
|
137
|
+
resolve,
|
|
138
|
+
resolveProviderReference as resolveProviderReference2
|
|
139
|
+
} from "@ai-sdk/provider-utils";
|
|
140
|
+
|
|
141
|
+
// src/anthropic-messages-api.ts
|
|
142
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
143
|
+
import { z as z3 } from "zod/v4";
|
|
144
|
+
var anthropicMessagesResponseSchema = lazySchema3(
|
|
145
|
+
() => zodSchema3(
|
|
146
|
+
z3.object({
|
|
147
|
+
type: z3.literal("message"),
|
|
148
|
+
id: z3.string().nullish(),
|
|
149
|
+
model: z3.string().nullish(),
|
|
150
|
+
content: z3.array(
|
|
151
|
+
z3.discriminatedUnion("type", [
|
|
152
|
+
z3.object({
|
|
153
|
+
type: z3.literal("text"),
|
|
154
|
+
text: z3.string(),
|
|
155
|
+
citations: z3.array(
|
|
156
|
+
z3.discriminatedUnion("type", [
|
|
157
|
+
z3.object({
|
|
158
|
+
type: z3.literal("web_search_result_location"),
|
|
159
|
+
cited_text: z3.string(),
|
|
160
|
+
url: z3.string(),
|
|
161
|
+
title: z3.string(),
|
|
162
|
+
encrypted_index: z3.string()
|
|
77
163
|
}),
|
|
78
|
-
|
|
79
|
-
type:
|
|
80
|
-
cited_text:
|
|
81
|
-
document_index:
|
|
82
|
-
document_title:
|
|
83
|
-
start_page_number:
|
|
84
|
-
end_page_number:
|
|
164
|
+
z3.object({
|
|
165
|
+
type: z3.literal("page_location"),
|
|
166
|
+
cited_text: z3.string(),
|
|
167
|
+
document_index: z3.number(),
|
|
168
|
+
document_title: z3.string().nullable(),
|
|
169
|
+
start_page_number: z3.number(),
|
|
170
|
+
end_page_number: z3.number()
|
|
85
171
|
}),
|
|
86
|
-
|
|
87
|
-
type:
|
|
88
|
-
cited_text:
|
|
89
|
-
document_index:
|
|
90
|
-
document_title:
|
|
91
|
-
start_char_index:
|
|
92
|
-
end_char_index:
|
|
172
|
+
z3.object({
|
|
173
|
+
type: z3.literal("char_location"),
|
|
174
|
+
cited_text: z3.string(),
|
|
175
|
+
document_index: z3.number(),
|
|
176
|
+
document_title: z3.string().nullable(),
|
|
177
|
+
start_char_index: z3.number(),
|
|
178
|
+
end_char_index: z3.number()
|
|
93
179
|
})
|
|
94
180
|
])
|
|
95
181
|
).optional()
|
|
96
182
|
}),
|
|
97
|
-
|
|
98
|
-
type:
|
|
99
|
-
thinking:
|
|
100
|
-
signature:
|
|
183
|
+
z3.object({
|
|
184
|
+
type: z3.literal("thinking"),
|
|
185
|
+
thinking: z3.string(),
|
|
186
|
+
signature: z3.string()
|
|
101
187
|
}),
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
data:
|
|
188
|
+
z3.object({
|
|
189
|
+
type: z3.literal("redacted_thinking"),
|
|
190
|
+
data: z3.string()
|
|
105
191
|
}),
|
|
106
|
-
|
|
107
|
-
type:
|
|
108
|
-
content:
|
|
192
|
+
z3.object({
|
|
193
|
+
type: z3.literal("compaction"),
|
|
194
|
+
content: z3.string()
|
|
109
195
|
}),
|
|
110
|
-
|
|
111
|
-
type:
|
|
112
|
-
id:
|
|
113
|
-
name:
|
|
114
|
-
input:
|
|
196
|
+
z3.object({
|
|
197
|
+
type: z3.literal("tool_use"),
|
|
198
|
+
id: z3.string(),
|
|
199
|
+
name: z3.string(),
|
|
200
|
+
input: z3.unknown(),
|
|
115
201
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
116
|
-
caller:
|
|
117
|
-
|
|
118
|
-
type:
|
|
119
|
-
tool_id:
|
|
202
|
+
caller: z3.union([
|
|
203
|
+
z3.object({
|
|
204
|
+
type: z3.literal("code_execution_20250825"),
|
|
205
|
+
tool_id: z3.string()
|
|
120
206
|
}),
|
|
121
|
-
|
|
122
|
-
type:
|
|
123
|
-
tool_id:
|
|
207
|
+
z3.object({
|
|
208
|
+
type: z3.literal("code_execution_20260120"),
|
|
209
|
+
tool_id: z3.string()
|
|
124
210
|
}),
|
|
125
|
-
|
|
126
|
-
type:
|
|
211
|
+
z3.object({
|
|
212
|
+
type: z3.literal("direct")
|
|
127
213
|
})
|
|
128
214
|
]).optional()
|
|
129
215
|
}),
|
|
130
|
-
|
|
131
|
-
type:
|
|
132
|
-
id:
|
|
133
|
-
name:
|
|
134
|
-
input:
|
|
135
|
-
caller:
|
|
136
|
-
|
|
137
|
-
type:
|
|
138
|
-
tool_id:
|
|
216
|
+
z3.object({
|
|
217
|
+
type: z3.literal("server_tool_use"),
|
|
218
|
+
id: z3.string(),
|
|
219
|
+
name: z3.string(),
|
|
220
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
221
|
+
caller: z3.union([
|
|
222
|
+
z3.object({
|
|
223
|
+
type: z3.literal("code_execution_20260120"),
|
|
224
|
+
tool_id: z3.string()
|
|
139
225
|
}),
|
|
140
|
-
|
|
141
|
-
type:
|
|
226
|
+
z3.object({
|
|
227
|
+
type: z3.literal("direct")
|
|
142
228
|
})
|
|
143
229
|
]).optional()
|
|
144
230
|
}),
|
|
145
|
-
|
|
146
|
-
type:
|
|
147
|
-
id:
|
|
148
|
-
name:
|
|
149
|
-
input:
|
|
150
|
-
server_name:
|
|
231
|
+
z3.object({
|
|
232
|
+
type: z3.literal("mcp_tool_use"),
|
|
233
|
+
id: z3.string(),
|
|
234
|
+
name: z3.string(),
|
|
235
|
+
input: z3.unknown(),
|
|
236
|
+
server_name: z3.string()
|
|
151
237
|
}),
|
|
152
|
-
|
|
153
|
-
type:
|
|
154
|
-
tool_use_id:
|
|
155
|
-
is_error:
|
|
156
|
-
content:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
238
|
+
z3.object({
|
|
239
|
+
type: z3.literal("mcp_tool_result"),
|
|
240
|
+
tool_use_id: z3.string(),
|
|
241
|
+
is_error: z3.boolean(),
|
|
242
|
+
content: z3.array(
|
|
243
|
+
z3.union([
|
|
244
|
+
z3.string(),
|
|
245
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
160
246
|
])
|
|
161
247
|
)
|
|
162
248
|
}),
|
|
163
|
-
|
|
164
|
-
type:
|
|
165
|
-
tool_use_id:
|
|
166
|
-
content:
|
|
167
|
-
|
|
168
|
-
type:
|
|
169
|
-
url:
|
|
170
|
-
retrieved_at:
|
|
171
|
-
content:
|
|
172
|
-
type:
|
|
173
|
-
title:
|
|
174
|
-
citations:
|
|
175
|
-
source:
|
|
176
|
-
|
|
177
|
-
type:
|
|
178
|
-
media_type:
|
|
179
|
-
data:
|
|
249
|
+
z3.object({
|
|
250
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
251
|
+
tool_use_id: z3.string(),
|
|
252
|
+
content: z3.union([
|
|
253
|
+
z3.object({
|
|
254
|
+
type: z3.literal("web_fetch_result"),
|
|
255
|
+
url: z3.string(),
|
|
256
|
+
retrieved_at: z3.string(),
|
|
257
|
+
content: z3.object({
|
|
258
|
+
type: z3.literal("document"),
|
|
259
|
+
title: z3.string().nullable(),
|
|
260
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
261
|
+
source: z3.union([
|
|
262
|
+
z3.object({
|
|
263
|
+
type: z3.literal("base64"),
|
|
264
|
+
media_type: z3.literal("application/pdf"),
|
|
265
|
+
data: z3.string()
|
|
180
266
|
}),
|
|
181
|
-
|
|
182
|
-
type:
|
|
183
|
-
media_type:
|
|
184
|
-
data:
|
|
267
|
+
z3.object({
|
|
268
|
+
type: z3.literal("text"),
|
|
269
|
+
media_type: z3.literal("text/plain"),
|
|
270
|
+
data: z3.string()
|
|
185
271
|
})
|
|
186
272
|
])
|
|
187
273
|
})
|
|
188
274
|
}),
|
|
189
|
-
|
|
190
|
-
type:
|
|
191
|
-
error_code:
|
|
275
|
+
z3.object({
|
|
276
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
277
|
+
error_code: z3.string()
|
|
192
278
|
})
|
|
193
279
|
])
|
|
194
280
|
}),
|
|
195
|
-
|
|
196
|
-
type:
|
|
197
|
-
tool_use_id:
|
|
198
|
-
content:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
type:
|
|
202
|
-
url:
|
|
203
|
-
title:
|
|
204
|
-
encrypted_content:
|
|
205
|
-
page_age:
|
|
281
|
+
z3.object({
|
|
282
|
+
type: z3.literal("web_search_tool_result"),
|
|
283
|
+
tool_use_id: z3.string(),
|
|
284
|
+
content: z3.union([
|
|
285
|
+
z3.array(
|
|
286
|
+
z3.object({
|
|
287
|
+
type: z3.literal("web_search_result"),
|
|
288
|
+
url: z3.string(),
|
|
289
|
+
title: z3.string(),
|
|
290
|
+
encrypted_content: z3.string(),
|
|
291
|
+
page_age: z3.string().nullish()
|
|
206
292
|
})
|
|
207
293
|
),
|
|
208
|
-
|
|
209
|
-
type:
|
|
210
|
-
error_code:
|
|
294
|
+
z3.object({
|
|
295
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
296
|
+
error_code: z3.string()
|
|
211
297
|
})
|
|
212
298
|
])
|
|
213
299
|
}),
|
|
214
300
|
// code execution results for code_execution_20250522 tool:
|
|
215
|
-
|
|
216
|
-
type:
|
|
217
|
-
tool_use_id:
|
|
218
|
-
content:
|
|
219
|
-
|
|
220
|
-
type:
|
|
221
|
-
stdout:
|
|
222
|
-
stderr:
|
|
223
|
-
return_code:
|
|
224
|
-
content:
|
|
225
|
-
|
|
226
|
-
type:
|
|
227
|
-
file_id:
|
|
301
|
+
z3.object({
|
|
302
|
+
type: z3.literal("code_execution_tool_result"),
|
|
303
|
+
tool_use_id: z3.string(),
|
|
304
|
+
content: z3.union([
|
|
305
|
+
z3.object({
|
|
306
|
+
type: z3.literal("code_execution_result"),
|
|
307
|
+
stdout: z3.string(),
|
|
308
|
+
stderr: z3.string(),
|
|
309
|
+
return_code: z3.number(),
|
|
310
|
+
content: z3.array(
|
|
311
|
+
z3.object({
|
|
312
|
+
type: z3.literal("code_execution_output"),
|
|
313
|
+
file_id: z3.string()
|
|
228
314
|
})
|
|
229
315
|
).optional().default([])
|
|
230
316
|
}),
|
|
231
|
-
|
|
232
|
-
type:
|
|
233
|
-
encrypted_stdout:
|
|
234
|
-
stderr:
|
|
235
|
-
return_code:
|
|
236
|
-
content:
|
|
237
|
-
|
|
238
|
-
type:
|
|
239
|
-
file_id:
|
|
317
|
+
z3.object({
|
|
318
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
319
|
+
encrypted_stdout: z3.string(),
|
|
320
|
+
stderr: z3.string(),
|
|
321
|
+
return_code: z3.number(),
|
|
322
|
+
content: z3.array(
|
|
323
|
+
z3.object({
|
|
324
|
+
type: z3.literal("code_execution_output"),
|
|
325
|
+
file_id: z3.string()
|
|
240
326
|
})
|
|
241
327
|
).optional().default([])
|
|
242
328
|
}),
|
|
243
|
-
|
|
244
|
-
type:
|
|
245
|
-
error_code:
|
|
329
|
+
z3.object({
|
|
330
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
331
|
+
error_code: z3.string()
|
|
246
332
|
})
|
|
247
333
|
])
|
|
248
334
|
}),
|
|
249
335
|
// bash code execution results for code_execution_20250825 tool:
|
|
250
|
-
|
|
251
|
-
type:
|
|
252
|
-
tool_use_id:
|
|
253
|
-
content:
|
|
254
|
-
|
|
255
|
-
type:
|
|
256
|
-
content:
|
|
257
|
-
|
|
258
|
-
type:
|
|
259
|
-
file_id:
|
|
336
|
+
z3.object({
|
|
337
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
338
|
+
tool_use_id: z3.string(),
|
|
339
|
+
content: z3.discriminatedUnion("type", [
|
|
340
|
+
z3.object({
|
|
341
|
+
type: z3.literal("bash_code_execution_result"),
|
|
342
|
+
content: z3.array(
|
|
343
|
+
z3.object({
|
|
344
|
+
type: z3.literal("bash_code_execution_output"),
|
|
345
|
+
file_id: z3.string()
|
|
260
346
|
})
|
|
261
347
|
),
|
|
262
|
-
stdout:
|
|
263
|
-
stderr:
|
|
264
|
-
return_code:
|
|
348
|
+
stdout: z3.string(),
|
|
349
|
+
stderr: z3.string(),
|
|
350
|
+
return_code: z3.number()
|
|
265
351
|
}),
|
|
266
|
-
|
|
267
|
-
type:
|
|
268
|
-
error_code:
|
|
352
|
+
z3.object({
|
|
353
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
354
|
+
error_code: z3.string()
|
|
269
355
|
})
|
|
270
356
|
])
|
|
271
357
|
}),
|
|
272
358
|
// text editor code execution results for code_execution_20250825 tool:
|
|
273
|
-
|
|
274
|
-
type:
|
|
275
|
-
tool_use_id:
|
|
276
|
-
content:
|
|
277
|
-
|
|
278
|
-
type:
|
|
279
|
-
error_code:
|
|
359
|
+
z3.object({
|
|
360
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
361
|
+
tool_use_id: z3.string(),
|
|
362
|
+
content: z3.discriminatedUnion("type", [
|
|
363
|
+
z3.object({
|
|
364
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
365
|
+
error_code: z3.string()
|
|
280
366
|
}),
|
|
281
|
-
|
|
282
|
-
type:
|
|
283
|
-
content:
|
|
284
|
-
file_type:
|
|
285
|
-
num_lines:
|
|
286
|
-
start_line:
|
|
287
|
-
total_lines:
|
|
367
|
+
z3.object({
|
|
368
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
369
|
+
content: z3.string(),
|
|
370
|
+
file_type: z3.string(),
|
|
371
|
+
num_lines: z3.number().nullable(),
|
|
372
|
+
start_line: z3.number().nullable(),
|
|
373
|
+
total_lines: z3.number().nullable()
|
|
288
374
|
}),
|
|
289
|
-
|
|
290
|
-
type:
|
|
291
|
-
is_file_update:
|
|
375
|
+
z3.object({
|
|
376
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
377
|
+
is_file_update: z3.boolean()
|
|
292
378
|
}),
|
|
293
|
-
|
|
294
|
-
type:
|
|
379
|
+
z3.object({
|
|
380
|
+
type: z3.literal(
|
|
295
381
|
"text_editor_code_execution_str_replace_result"
|
|
296
382
|
),
|
|
297
|
-
lines:
|
|
298
|
-
new_lines:
|
|
299
|
-
new_start:
|
|
300
|
-
old_lines:
|
|
301
|
-
old_start:
|
|
383
|
+
lines: z3.array(z3.string()).nullable(),
|
|
384
|
+
new_lines: z3.number().nullable(),
|
|
385
|
+
new_start: z3.number().nullable(),
|
|
386
|
+
old_lines: z3.number().nullable(),
|
|
387
|
+
old_start: z3.number().nullable()
|
|
302
388
|
})
|
|
303
389
|
])
|
|
304
390
|
}),
|
|
305
391
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
306
|
-
|
|
307
|
-
type:
|
|
308
|
-
tool_use_id:
|
|
309
|
-
content:
|
|
310
|
-
|
|
311
|
-
type:
|
|
312
|
-
tool_references:
|
|
313
|
-
|
|
314
|
-
type:
|
|
315
|
-
tool_name:
|
|
392
|
+
z3.object({
|
|
393
|
+
type: z3.literal("tool_search_tool_result"),
|
|
394
|
+
tool_use_id: z3.string(),
|
|
395
|
+
content: z3.union([
|
|
396
|
+
z3.object({
|
|
397
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
398
|
+
tool_references: z3.array(
|
|
399
|
+
z3.object({
|
|
400
|
+
type: z3.literal("tool_reference"),
|
|
401
|
+
tool_name: z3.string()
|
|
316
402
|
})
|
|
317
403
|
)
|
|
318
404
|
}),
|
|
319
|
-
|
|
320
|
-
type:
|
|
321
|
-
error_code:
|
|
405
|
+
z3.object({
|
|
406
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
407
|
+
error_code: z3.string()
|
|
322
408
|
})
|
|
323
409
|
])
|
|
324
410
|
})
|
|
325
411
|
])
|
|
326
412
|
),
|
|
327
|
-
stop_reason:
|
|
328
|
-
stop_sequence:
|
|
329
|
-
usage:
|
|
330
|
-
input_tokens:
|
|
331
|
-
output_tokens:
|
|
332
|
-
cache_creation_input_tokens:
|
|
333
|
-
cache_read_input_tokens:
|
|
334
|
-
iterations:
|
|
335
|
-
|
|
336
|
-
type:
|
|
337
|
-
input_tokens:
|
|
338
|
-
output_tokens:
|
|
413
|
+
stop_reason: z3.string().nullish(),
|
|
414
|
+
stop_sequence: z3.string().nullish(),
|
|
415
|
+
usage: z3.looseObject({
|
|
416
|
+
input_tokens: z3.number(),
|
|
417
|
+
output_tokens: z3.number(),
|
|
418
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
419
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
420
|
+
iterations: z3.array(
|
|
421
|
+
z3.object({
|
|
422
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
423
|
+
input_tokens: z3.number(),
|
|
424
|
+
output_tokens: z3.number()
|
|
339
425
|
})
|
|
340
426
|
).nullish()
|
|
341
427
|
}),
|
|
342
|
-
container:
|
|
343
|
-
expires_at:
|
|
344
|
-
id:
|
|
345
|
-
skills:
|
|
346
|
-
|
|
347
|
-
type:
|
|
348
|
-
skill_id:
|
|
349
|
-
version:
|
|
428
|
+
container: z3.object({
|
|
429
|
+
expires_at: z3.string(),
|
|
430
|
+
id: z3.string(),
|
|
431
|
+
skills: z3.array(
|
|
432
|
+
z3.object({
|
|
433
|
+
type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
|
|
434
|
+
skill_id: z3.string(),
|
|
435
|
+
version: z3.string()
|
|
350
436
|
})
|
|
351
437
|
).nullish()
|
|
352
438
|
}).nullish(),
|
|
353
|
-
context_management:
|
|
354
|
-
applied_edits:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
type:
|
|
358
|
-
cleared_tool_uses:
|
|
359
|
-
cleared_input_tokens:
|
|
439
|
+
context_management: z3.object({
|
|
440
|
+
applied_edits: z3.array(
|
|
441
|
+
z3.union([
|
|
442
|
+
z3.object({
|
|
443
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
444
|
+
cleared_tool_uses: z3.number(),
|
|
445
|
+
cleared_input_tokens: z3.number()
|
|
360
446
|
}),
|
|
361
|
-
|
|
362
|
-
type:
|
|
363
|
-
cleared_thinking_turns:
|
|
364
|
-
cleared_input_tokens:
|
|
447
|
+
z3.object({
|
|
448
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
449
|
+
cleared_thinking_turns: z3.number(),
|
|
450
|
+
cleared_input_tokens: z3.number()
|
|
365
451
|
}),
|
|
366
|
-
|
|
367
|
-
type:
|
|
452
|
+
z3.object({
|
|
453
|
+
type: z3.literal("compact_20260112")
|
|
368
454
|
})
|
|
369
455
|
])
|
|
370
456
|
)
|
|
@@ -372,457 +458,457 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
372
458
|
})
|
|
373
459
|
)
|
|
374
460
|
);
|
|
375
|
-
var anthropicMessagesChunkSchema =
|
|
376
|
-
() =>
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
type:
|
|
380
|
-
message:
|
|
381
|
-
id:
|
|
382
|
-
model:
|
|
383
|
-
role:
|
|
384
|
-
usage:
|
|
385
|
-
input_tokens:
|
|
386
|
-
cache_creation_input_tokens:
|
|
387
|
-
cache_read_input_tokens:
|
|
461
|
+
var anthropicMessagesChunkSchema = lazySchema3(
|
|
462
|
+
() => zodSchema3(
|
|
463
|
+
z3.discriminatedUnion("type", [
|
|
464
|
+
z3.object({
|
|
465
|
+
type: z3.literal("message_start"),
|
|
466
|
+
message: z3.object({
|
|
467
|
+
id: z3.string().nullish(),
|
|
468
|
+
model: z3.string().nullish(),
|
|
469
|
+
role: z3.string().nullish(),
|
|
470
|
+
usage: z3.looseObject({
|
|
471
|
+
input_tokens: z3.number(),
|
|
472
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
473
|
+
cache_read_input_tokens: z3.number().nullish()
|
|
388
474
|
}),
|
|
389
475
|
// Programmatic tool calling: content may be pre-populated for deferred tool calls
|
|
390
|
-
content:
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
type:
|
|
394
|
-
id:
|
|
395
|
-
name:
|
|
396
|
-
input:
|
|
397
|
-
caller:
|
|
398
|
-
|
|
399
|
-
type:
|
|
400
|
-
tool_id:
|
|
476
|
+
content: z3.array(
|
|
477
|
+
z3.discriminatedUnion("type", [
|
|
478
|
+
z3.object({
|
|
479
|
+
type: z3.literal("tool_use"),
|
|
480
|
+
id: z3.string(),
|
|
481
|
+
name: z3.string(),
|
|
482
|
+
input: z3.unknown(),
|
|
483
|
+
caller: z3.union([
|
|
484
|
+
z3.object({
|
|
485
|
+
type: z3.literal("code_execution_20250825"),
|
|
486
|
+
tool_id: z3.string()
|
|
401
487
|
}),
|
|
402
|
-
|
|
403
|
-
type:
|
|
404
|
-
tool_id:
|
|
488
|
+
z3.object({
|
|
489
|
+
type: z3.literal("code_execution_20260120"),
|
|
490
|
+
tool_id: z3.string()
|
|
405
491
|
}),
|
|
406
|
-
|
|
407
|
-
type:
|
|
492
|
+
z3.object({
|
|
493
|
+
type: z3.literal("direct")
|
|
408
494
|
})
|
|
409
495
|
]).optional()
|
|
410
496
|
})
|
|
411
497
|
])
|
|
412
498
|
).nullish(),
|
|
413
|
-
stop_reason:
|
|
414
|
-
container:
|
|
415
|
-
expires_at:
|
|
416
|
-
id:
|
|
499
|
+
stop_reason: z3.string().nullish(),
|
|
500
|
+
container: z3.object({
|
|
501
|
+
expires_at: z3.string(),
|
|
502
|
+
id: z3.string()
|
|
417
503
|
}).nullish()
|
|
418
504
|
})
|
|
419
505
|
}),
|
|
420
|
-
|
|
421
|
-
type:
|
|
422
|
-
index:
|
|
423
|
-
content_block:
|
|
424
|
-
|
|
425
|
-
type:
|
|
426
|
-
text:
|
|
506
|
+
z3.object({
|
|
507
|
+
type: z3.literal("content_block_start"),
|
|
508
|
+
index: z3.number(),
|
|
509
|
+
content_block: z3.discriminatedUnion("type", [
|
|
510
|
+
z3.object({
|
|
511
|
+
type: z3.literal("text"),
|
|
512
|
+
text: z3.string()
|
|
427
513
|
}),
|
|
428
|
-
|
|
429
|
-
type:
|
|
430
|
-
thinking:
|
|
514
|
+
z3.object({
|
|
515
|
+
type: z3.literal("thinking"),
|
|
516
|
+
thinking: z3.string()
|
|
431
517
|
}),
|
|
432
|
-
|
|
433
|
-
type:
|
|
434
|
-
id:
|
|
435
|
-
name:
|
|
518
|
+
z3.object({
|
|
519
|
+
type: z3.literal("tool_use"),
|
|
520
|
+
id: z3.string(),
|
|
521
|
+
name: z3.string(),
|
|
436
522
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
437
|
-
input:
|
|
523
|
+
input: z3.record(z3.string(), z3.unknown()).optional(),
|
|
438
524
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
439
|
-
caller:
|
|
440
|
-
|
|
441
|
-
type:
|
|
442
|
-
tool_id:
|
|
525
|
+
caller: z3.union([
|
|
526
|
+
z3.object({
|
|
527
|
+
type: z3.literal("code_execution_20250825"),
|
|
528
|
+
tool_id: z3.string()
|
|
443
529
|
}),
|
|
444
|
-
|
|
445
|
-
type:
|
|
446
|
-
tool_id:
|
|
530
|
+
z3.object({
|
|
531
|
+
type: z3.literal("code_execution_20260120"),
|
|
532
|
+
tool_id: z3.string()
|
|
447
533
|
}),
|
|
448
|
-
|
|
449
|
-
type:
|
|
534
|
+
z3.object({
|
|
535
|
+
type: z3.literal("direct")
|
|
450
536
|
})
|
|
451
537
|
]).optional()
|
|
452
538
|
}),
|
|
453
|
-
|
|
454
|
-
type:
|
|
455
|
-
data:
|
|
539
|
+
z3.object({
|
|
540
|
+
type: z3.literal("redacted_thinking"),
|
|
541
|
+
data: z3.string()
|
|
456
542
|
}),
|
|
457
|
-
|
|
458
|
-
type:
|
|
459
|
-
content:
|
|
543
|
+
z3.object({
|
|
544
|
+
type: z3.literal("compaction"),
|
|
545
|
+
content: z3.string().nullish()
|
|
460
546
|
}),
|
|
461
|
-
|
|
462
|
-
type:
|
|
463
|
-
id:
|
|
464
|
-
name:
|
|
465
|
-
input:
|
|
466
|
-
caller:
|
|
467
|
-
|
|
468
|
-
type:
|
|
469
|
-
tool_id:
|
|
547
|
+
z3.object({
|
|
548
|
+
type: z3.literal("server_tool_use"),
|
|
549
|
+
id: z3.string(),
|
|
550
|
+
name: z3.string(),
|
|
551
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
552
|
+
caller: z3.union([
|
|
553
|
+
z3.object({
|
|
554
|
+
type: z3.literal("code_execution_20260120"),
|
|
555
|
+
tool_id: z3.string()
|
|
470
556
|
}),
|
|
471
|
-
|
|
472
|
-
type:
|
|
557
|
+
z3.object({
|
|
558
|
+
type: z3.literal("direct")
|
|
473
559
|
})
|
|
474
560
|
]).optional()
|
|
475
561
|
}),
|
|
476
|
-
|
|
477
|
-
type:
|
|
478
|
-
id:
|
|
479
|
-
name:
|
|
480
|
-
input:
|
|
481
|
-
server_name:
|
|
562
|
+
z3.object({
|
|
563
|
+
type: z3.literal("mcp_tool_use"),
|
|
564
|
+
id: z3.string(),
|
|
565
|
+
name: z3.string(),
|
|
566
|
+
input: z3.unknown(),
|
|
567
|
+
server_name: z3.string()
|
|
482
568
|
}),
|
|
483
|
-
|
|
484
|
-
type:
|
|
485
|
-
tool_use_id:
|
|
486
|
-
is_error:
|
|
487
|
-
content:
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
569
|
+
z3.object({
|
|
570
|
+
type: z3.literal("mcp_tool_result"),
|
|
571
|
+
tool_use_id: z3.string(),
|
|
572
|
+
is_error: z3.boolean(),
|
|
573
|
+
content: z3.array(
|
|
574
|
+
z3.union([
|
|
575
|
+
z3.string(),
|
|
576
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
491
577
|
])
|
|
492
578
|
)
|
|
493
579
|
}),
|
|
494
|
-
|
|
495
|
-
type:
|
|
496
|
-
tool_use_id:
|
|
497
|
-
content:
|
|
498
|
-
|
|
499
|
-
type:
|
|
500
|
-
url:
|
|
501
|
-
retrieved_at:
|
|
502
|
-
content:
|
|
503
|
-
type:
|
|
504
|
-
title:
|
|
505
|
-
citations:
|
|
506
|
-
source:
|
|
507
|
-
|
|
508
|
-
type:
|
|
509
|
-
media_type:
|
|
510
|
-
data:
|
|
580
|
+
z3.object({
|
|
581
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
582
|
+
tool_use_id: z3.string(),
|
|
583
|
+
content: z3.union([
|
|
584
|
+
z3.object({
|
|
585
|
+
type: z3.literal("web_fetch_result"),
|
|
586
|
+
url: z3.string(),
|
|
587
|
+
retrieved_at: z3.string(),
|
|
588
|
+
content: z3.object({
|
|
589
|
+
type: z3.literal("document"),
|
|
590
|
+
title: z3.string().nullable(),
|
|
591
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
592
|
+
source: z3.union([
|
|
593
|
+
z3.object({
|
|
594
|
+
type: z3.literal("base64"),
|
|
595
|
+
media_type: z3.literal("application/pdf"),
|
|
596
|
+
data: z3.string()
|
|
511
597
|
}),
|
|
512
|
-
|
|
513
|
-
type:
|
|
514
|
-
media_type:
|
|
515
|
-
data:
|
|
598
|
+
z3.object({
|
|
599
|
+
type: z3.literal("text"),
|
|
600
|
+
media_type: z3.literal("text/plain"),
|
|
601
|
+
data: z3.string()
|
|
516
602
|
})
|
|
517
603
|
])
|
|
518
604
|
})
|
|
519
605
|
}),
|
|
520
|
-
|
|
521
|
-
type:
|
|
522
|
-
error_code:
|
|
606
|
+
z3.object({
|
|
607
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
608
|
+
error_code: z3.string()
|
|
523
609
|
})
|
|
524
610
|
])
|
|
525
611
|
}),
|
|
526
|
-
|
|
527
|
-
type:
|
|
528
|
-
tool_use_id:
|
|
529
|
-
content:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
type:
|
|
533
|
-
url:
|
|
534
|
-
title:
|
|
535
|
-
encrypted_content:
|
|
536
|
-
page_age:
|
|
612
|
+
z3.object({
|
|
613
|
+
type: z3.literal("web_search_tool_result"),
|
|
614
|
+
tool_use_id: z3.string(),
|
|
615
|
+
content: z3.union([
|
|
616
|
+
z3.array(
|
|
617
|
+
z3.object({
|
|
618
|
+
type: z3.literal("web_search_result"),
|
|
619
|
+
url: z3.string(),
|
|
620
|
+
title: z3.string(),
|
|
621
|
+
encrypted_content: z3.string(),
|
|
622
|
+
page_age: z3.string().nullish()
|
|
537
623
|
})
|
|
538
624
|
),
|
|
539
|
-
|
|
540
|
-
type:
|
|
541
|
-
error_code:
|
|
625
|
+
z3.object({
|
|
626
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
627
|
+
error_code: z3.string()
|
|
542
628
|
})
|
|
543
629
|
])
|
|
544
630
|
}),
|
|
545
631
|
// code execution results for code_execution_20250522 tool:
|
|
546
|
-
|
|
547
|
-
type:
|
|
548
|
-
tool_use_id:
|
|
549
|
-
content:
|
|
550
|
-
|
|
551
|
-
type:
|
|
552
|
-
stdout:
|
|
553
|
-
stderr:
|
|
554
|
-
return_code:
|
|
555
|
-
content:
|
|
556
|
-
|
|
557
|
-
type:
|
|
558
|
-
file_id:
|
|
632
|
+
z3.object({
|
|
633
|
+
type: z3.literal("code_execution_tool_result"),
|
|
634
|
+
tool_use_id: z3.string(),
|
|
635
|
+
content: z3.union([
|
|
636
|
+
z3.object({
|
|
637
|
+
type: z3.literal("code_execution_result"),
|
|
638
|
+
stdout: z3.string(),
|
|
639
|
+
stderr: z3.string(),
|
|
640
|
+
return_code: z3.number(),
|
|
641
|
+
content: z3.array(
|
|
642
|
+
z3.object({
|
|
643
|
+
type: z3.literal("code_execution_output"),
|
|
644
|
+
file_id: z3.string()
|
|
559
645
|
})
|
|
560
646
|
).optional().default([])
|
|
561
647
|
}),
|
|
562
|
-
|
|
563
|
-
type:
|
|
564
|
-
encrypted_stdout:
|
|
565
|
-
stderr:
|
|
566
|
-
return_code:
|
|
567
|
-
content:
|
|
568
|
-
|
|
569
|
-
type:
|
|
570
|
-
file_id:
|
|
648
|
+
z3.object({
|
|
649
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
650
|
+
encrypted_stdout: z3.string(),
|
|
651
|
+
stderr: z3.string(),
|
|
652
|
+
return_code: z3.number(),
|
|
653
|
+
content: z3.array(
|
|
654
|
+
z3.object({
|
|
655
|
+
type: z3.literal("code_execution_output"),
|
|
656
|
+
file_id: z3.string()
|
|
571
657
|
})
|
|
572
658
|
).optional().default([])
|
|
573
659
|
}),
|
|
574
|
-
|
|
575
|
-
type:
|
|
576
|
-
error_code:
|
|
660
|
+
z3.object({
|
|
661
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
662
|
+
error_code: z3.string()
|
|
577
663
|
})
|
|
578
664
|
])
|
|
579
665
|
}),
|
|
580
666
|
// bash code execution results for code_execution_20250825 tool:
|
|
581
|
-
|
|
582
|
-
type:
|
|
583
|
-
tool_use_id:
|
|
584
|
-
content:
|
|
585
|
-
|
|
586
|
-
type:
|
|
587
|
-
content:
|
|
588
|
-
|
|
589
|
-
type:
|
|
590
|
-
file_id:
|
|
667
|
+
z3.object({
|
|
668
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
669
|
+
tool_use_id: z3.string(),
|
|
670
|
+
content: z3.discriminatedUnion("type", [
|
|
671
|
+
z3.object({
|
|
672
|
+
type: z3.literal("bash_code_execution_result"),
|
|
673
|
+
content: z3.array(
|
|
674
|
+
z3.object({
|
|
675
|
+
type: z3.literal("bash_code_execution_output"),
|
|
676
|
+
file_id: z3.string()
|
|
591
677
|
})
|
|
592
678
|
),
|
|
593
|
-
stdout:
|
|
594
|
-
stderr:
|
|
595
|
-
return_code:
|
|
679
|
+
stdout: z3.string(),
|
|
680
|
+
stderr: z3.string(),
|
|
681
|
+
return_code: z3.number()
|
|
596
682
|
}),
|
|
597
|
-
|
|
598
|
-
type:
|
|
599
|
-
error_code:
|
|
683
|
+
z3.object({
|
|
684
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
685
|
+
error_code: z3.string()
|
|
600
686
|
})
|
|
601
687
|
])
|
|
602
688
|
}),
|
|
603
689
|
// text editor code execution results for code_execution_20250825 tool:
|
|
604
|
-
|
|
605
|
-
type:
|
|
606
|
-
tool_use_id:
|
|
607
|
-
content:
|
|
608
|
-
|
|
609
|
-
type:
|
|
610
|
-
error_code:
|
|
690
|
+
z3.object({
|
|
691
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
692
|
+
tool_use_id: z3.string(),
|
|
693
|
+
content: z3.discriminatedUnion("type", [
|
|
694
|
+
z3.object({
|
|
695
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
696
|
+
error_code: z3.string()
|
|
611
697
|
}),
|
|
612
|
-
|
|
613
|
-
type:
|
|
614
|
-
content:
|
|
615
|
-
file_type:
|
|
616
|
-
num_lines:
|
|
617
|
-
start_line:
|
|
618
|
-
total_lines:
|
|
698
|
+
z3.object({
|
|
699
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
700
|
+
content: z3.string(),
|
|
701
|
+
file_type: z3.string(),
|
|
702
|
+
num_lines: z3.number().nullable(),
|
|
703
|
+
start_line: z3.number().nullable(),
|
|
704
|
+
total_lines: z3.number().nullable()
|
|
619
705
|
}),
|
|
620
|
-
|
|
621
|
-
type:
|
|
622
|
-
is_file_update:
|
|
706
|
+
z3.object({
|
|
707
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
708
|
+
is_file_update: z3.boolean()
|
|
623
709
|
}),
|
|
624
|
-
|
|
625
|
-
type:
|
|
710
|
+
z3.object({
|
|
711
|
+
type: z3.literal(
|
|
626
712
|
"text_editor_code_execution_str_replace_result"
|
|
627
713
|
),
|
|
628
|
-
lines:
|
|
629
|
-
new_lines:
|
|
630
|
-
new_start:
|
|
631
|
-
old_lines:
|
|
632
|
-
old_start:
|
|
714
|
+
lines: z3.array(z3.string()).nullable(),
|
|
715
|
+
new_lines: z3.number().nullable(),
|
|
716
|
+
new_start: z3.number().nullable(),
|
|
717
|
+
old_lines: z3.number().nullable(),
|
|
718
|
+
old_start: z3.number().nullable()
|
|
633
719
|
})
|
|
634
720
|
])
|
|
635
721
|
}),
|
|
636
722
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
637
|
-
|
|
638
|
-
type:
|
|
639
|
-
tool_use_id:
|
|
640
|
-
content:
|
|
641
|
-
|
|
642
|
-
type:
|
|
643
|
-
tool_references:
|
|
644
|
-
|
|
645
|
-
type:
|
|
646
|
-
tool_name:
|
|
723
|
+
z3.object({
|
|
724
|
+
type: z3.literal("tool_search_tool_result"),
|
|
725
|
+
tool_use_id: z3.string(),
|
|
726
|
+
content: z3.union([
|
|
727
|
+
z3.object({
|
|
728
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
729
|
+
tool_references: z3.array(
|
|
730
|
+
z3.object({
|
|
731
|
+
type: z3.literal("tool_reference"),
|
|
732
|
+
tool_name: z3.string()
|
|
647
733
|
})
|
|
648
734
|
)
|
|
649
735
|
}),
|
|
650
|
-
|
|
651
|
-
type:
|
|
652
|
-
error_code:
|
|
736
|
+
z3.object({
|
|
737
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
738
|
+
error_code: z3.string()
|
|
653
739
|
})
|
|
654
740
|
])
|
|
655
741
|
})
|
|
656
742
|
])
|
|
657
743
|
}),
|
|
658
|
-
|
|
659
|
-
type:
|
|
660
|
-
index:
|
|
661
|
-
delta:
|
|
662
|
-
|
|
663
|
-
type:
|
|
664
|
-
partial_json:
|
|
744
|
+
z3.object({
|
|
745
|
+
type: z3.literal("content_block_delta"),
|
|
746
|
+
index: z3.number(),
|
|
747
|
+
delta: z3.discriminatedUnion("type", [
|
|
748
|
+
z3.object({
|
|
749
|
+
type: z3.literal("input_json_delta"),
|
|
750
|
+
partial_json: z3.string()
|
|
665
751
|
}),
|
|
666
|
-
|
|
667
|
-
type:
|
|
668
|
-
text:
|
|
752
|
+
z3.object({
|
|
753
|
+
type: z3.literal("text_delta"),
|
|
754
|
+
text: z3.string()
|
|
669
755
|
}),
|
|
670
|
-
|
|
671
|
-
type:
|
|
672
|
-
thinking:
|
|
756
|
+
z3.object({
|
|
757
|
+
type: z3.literal("thinking_delta"),
|
|
758
|
+
thinking: z3.string()
|
|
673
759
|
}),
|
|
674
|
-
|
|
675
|
-
type:
|
|
676
|
-
signature:
|
|
760
|
+
z3.object({
|
|
761
|
+
type: z3.literal("signature_delta"),
|
|
762
|
+
signature: z3.string()
|
|
677
763
|
}),
|
|
678
|
-
|
|
679
|
-
type:
|
|
680
|
-
content:
|
|
764
|
+
z3.object({
|
|
765
|
+
type: z3.literal("compaction_delta"),
|
|
766
|
+
content: z3.string().nullish()
|
|
681
767
|
}),
|
|
682
|
-
|
|
683
|
-
type:
|
|
684
|
-
citation:
|
|
685
|
-
|
|
686
|
-
type:
|
|
687
|
-
cited_text:
|
|
688
|
-
url:
|
|
689
|
-
title:
|
|
690
|
-
encrypted_index:
|
|
768
|
+
z3.object({
|
|
769
|
+
type: z3.literal("citations_delta"),
|
|
770
|
+
citation: z3.discriminatedUnion("type", [
|
|
771
|
+
z3.object({
|
|
772
|
+
type: z3.literal("web_search_result_location"),
|
|
773
|
+
cited_text: z3.string(),
|
|
774
|
+
url: z3.string(),
|
|
775
|
+
title: z3.string(),
|
|
776
|
+
encrypted_index: z3.string()
|
|
691
777
|
}),
|
|
692
|
-
|
|
693
|
-
type:
|
|
694
|
-
cited_text:
|
|
695
|
-
document_index:
|
|
696
|
-
document_title:
|
|
697
|
-
start_page_number:
|
|
698
|
-
end_page_number:
|
|
778
|
+
z3.object({
|
|
779
|
+
type: z3.literal("page_location"),
|
|
780
|
+
cited_text: z3.string(),
|
|
781
|
+
document_index: z3.number(),
|
|
782
|
+
document_title: z3.string().nullable(),
|
|
783
|
+
start_page_number: z3.number(),
|
|
784
|
+
end_page_number: z3.number()
|
|
699
785
|
}),
|
|
700
|
-
|
|
701
|
-
type:
|
|
702
|
-
cited_text:
|
|
703
|
-
document_index:
|
|
704
|
-
document_title:
|
|
705
|
-
start_char_index:
|
|
706
|
-
end_char_index:
|
|
786
|
+
z3.object({
|
|
787
|
+
type: z3.literal("char_location"),
|
|
788
|
+
cited_text: z3.string(),
|
|
789
|
+
document_index: z3.number(),
|
|
790
|
+
document_title: z3.string().nullable(),
|
|
791
|
+
start_char_index: z3.number(),
|
|
792
|
+
end_char_index: z3.number()
|
|
707
793
|
})
|
|
708
794
|
])
|
|
709
795
|
})
|
|
710
796
|
])
|
|
711
797
|
}),
|
|
712
|
-
|
|
713
|
-
type:
|
|
714
|
-
index:
|
|
798
|
+
z3.object({
|
|
799
|
+
type: z3.literal("content_block_stop"),
|
|
800
|
+
index: z3.number()
|
|
715
801
|
}),
|
|
716
|
-
|
|
717
|
-
type:
|
|
718
|
-
error:
|
|
719
|
-
type:
|
|
720
|
-
message:
|
|
802
|
+
z3.object({
|
|
803
|
+
type: z3.literal("error"),
|
|
804
|
+
error: z3.object({
|
|
805
|
+
type: z3.string(),
|
|
806
|
+
message: z3.string()
|
|
721
807
|
})
|
|
722
808
|
}),
|
|
723
|
-
|
|
724
|
-
type:
|
|
725
|
-
delta:
|
|
726
|
-
stop_reason:
|
|
727
|
-
stop_sequence:
|
|
728
|
-
container:
|
|
729
|
-
expires_at:
|
|
730
|
-
id:
|
|
731
|
-
skills:
|
|
732
|
-
|
|
733
|
-
type:
|
|
734
|
-
|
|
735
|
-
|
|
809
|
+
z3.object({
|
|
810
|
+
type: z3.literal("message_delta"),
|
|
811
|
+
delta: z3.object({
|
|
812
|
+
stop_reason: z3.string().nullish(),
|
|
813
|
+
stop_sequence: z3.string().nullish(),
|
|
814
|
+
container: z3.object({
|
|
815
|
+
expires_at: z3.string(),
|
|
816
|
+
id: z3.string(),
|
|
817
|
+
skills: z3.array(
|
|
818
|
+
z3.object({
|
|
819
|
+
type: z3.union([
|
|
820
|
+
z3.literal("anthropic"),
|
|
821
|
+
z3.literal("custom")
|
|
736
822
|
]),
|
|
737
|
-
skill_id:
|
|
738
|
-
version:
|
|
823
|
+
skill_id: z3.string(),
|
|
824
|
+
version: z3.string()
|
|
739
825
|
})
|
|
740
826
|
).nullish()
|
|
741
827
|
}).nullish()
|
|
742
828
|
}),
|
|
743
|
-
usage:
|
|
744
|
-
input_tokens:
|
|
745
|
-
output_tokens:
|
|
746
|
-
cache_creation_input_tokens:
|
|
747
|
-
cache_read_input_tokens:
|
|
748
|
-
iterations:
|
|
749
|
-
|
|
750
|
-
type:
|
|
751
|
-
input_tokens:
|
|
752
|
-
output_tokens:
|
|
829
|
+
usage: z3.looseObject({
|
|
830
|
+
input_tokens: z3.number().nullish(),
|
|
831
|
+
output_tokens: z3.number(),
|
|
832
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
833
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
834
|
+
iterations: z3.array(
|
|
835
|
+
z3.object({
|
|
836
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
837
|
+
input_tokens: z3.number(),
|
|
838
|
+
output_tokens: z3.number()
|
|
753
839
|
})
|
|
754
840
|
).nullish()
|
|
755
841
|
}),
|
|
756
|
-
context_management:
|
|
757
|
-
applied_edits:
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
type:
|
|
761
|
-
cleared_tool_uses:
|
|
762
|
-
cleared_input_tokens:
|
|
842
|
+
context_management: z3.object({
|
|
843
|
+
applied_edits: z3.array(
|
|
844
|
+
z3.union([
|
|
845
|
+
z3.object({
|
|
846
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
847
|
+
cleared_tool_uses: z3.number(),
|
|
848
|
+
cleared_input_tokens: z3.number()
|
|
763
849
|
}),
|
|
764
|
-
|
|
765
|
-
type:
|
|
766
|
-
cleared_thinking_turns:
|
|
767
|
-
cleared_input_tokens:
|
|
850
|
+
z3.object({
|
|
851
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
852
|
+
cleared_thinking_turns: z3.number(),
|
|
853
|
+
cleared_input_tokens: z3.number()
|
|
768
854
|
}),
|
|
769
|
-
|
|
770
|
-
type:
|
|
855
|
+
z3.object({
|
|
856
|
+
type: z3.literal("compact_20260112")
|
|
771
857
|
})
|
|
772
858
|
])
|
|
773
859
|
)
|
|
774
860
|
}).nullish()
|
|
775
861
|
}),
|
|
776
|
-
|
|
777
|
-
type:
|
|
862
|
+
z3.object({
|
|
863
|
+
type: z3.literal("message_stop")
|
|
778
864
|
}),
|
|
779
|
-
|
|
780
|
-
type:
|
|
865
|
+
z3.object({
|
|
866
|
+
type: z3.literal("ping")
|
|
781
867
|
})
|
|
782
868
|
])
|
|
783
869
|
)
|
|
784
870
|
);
|
|
785
|
-
var anthropicReasoningMetadataSchema =
|
|
786
|
-
() =>
|
|
787
|
-
|
|
788
|
-
signature:
|
|
789
|
-
redactedData:
|
|
871
|
+
var anthropicReasoningMetadataSchema = lazySchema3(
|
|
872
|
+
() => zodSchema3(
|
|
873
|
+
z3.object({
|
|
874
|
+
signature: z3.string().optional(),
|
|
875
|
+
redactedData: z3.string().optional()
|
|
790
876
|
})
|
|
791
877
|
)
|
|
792
878
|
);
|
|
793
879
|
|
|
794
880
|
// src/anthropic-messages-options.ts
|
|
795
|
-
import { z as
|
|
796
|
-
var anthropicFilePartProviderOptions =
|
|
881
|
+
import { z as z4 } from "zod/v4";
|
|
882
|
+
var anthropicFilePartProviderOptions = z4.object({
|
|
797
883
|
/**
|
|
798
884
|
* Citation configuration for this document.
|
|
799
885
|
* When enabled, this document will generate citations in the response.
|
|
800
886
|
*/
|
|
801
|
-
citations:
|
|
887
|
+
citations: z4.object({
|
|
802
888
|
/**
|
|
803
889
|
* Enable citations for this document
|
|
804
890
|
*/
|
|
805
|
-
enabled:
|
|
891
|
+
enabled: z4.boolean()
|
|
806
892
|
}).optional(),
|
|
807
893
|
/**
|
|
808
894
|
* Custom title for the document.
|
|
809
895
|
* If not provided, the filename will be used.
|
|
810
896
|
*/
|
|
811
|
-
title:
|
|
897
|
+
title: z4.string().optional(),
|
|
812
898
|
/**
|
|
813
899
|
* Context about the document that will be passed to the model
|
|
814
900
|
* but not used towards cited content.
|
|
815
901
|
* Useful for storing document metadata as text or stringified JSON.
|
|
816
902
|
*/
|
|
817
|
-
context:
|
|
903
|
+
context: z4.string().optional()
|
|
818
904
|
});
|
|
819
|
-
var anthropicLanguageModelOptions =
|
|
905
|
+
var anthropicLanguageModelOptions = z4.object({
|
|
820
906
|
/**
|
|
821
907
|
* Whether to send reasoning to the model.
|
|
822
908
|
*
|
|
823
909
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
824
910
|
*/
|
|
825
|
-
sendReasoning:
|
|
911
|
+
sendReasoning: z4.boolean().optional(),
|
|
826
912
|
/**
|
|
827
913
|
* Determines how structured outputs are generated.
|
|
828
914
|
*
|
|
@@ -830,52 +916,66 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
830
916
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
831
917
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
832
918
|
*/
|
|
833
|
-
structuredOutputMode:
|
|
919
|
+
structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
834
920
|
/**
|
|
835
921
|
* Configuration for enabling Claude's extended thinking.
|
|
836
922
|
*
|
|
837
923
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
838
924
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
839
925
|
*/
|
|
840
|
-
thinking:
|
|
841
|
-
|
|
926
|
+
thinking: z4.discriminatedUnion("type", [
|
|
927
|
+
z4.object({
|
|
842
928
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
843
|
-
type:
|
|
929
|
+
type: z4.literal("adaptive")
|
|
844
930
|
}),
|
|
845
|
-
|
|
931
|
+
z4.object({
|
|
846
932
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
847
|
-
type:
|
|
848
|
-
budgetTokens:
|
|
933
|
+
type: z4.literal("enabled"),
|
|
934
|
+
budgetTokens: z4.number().optional()
|
|
849
935
|
}),
|
|
850
|
-
|
|
851
|
-
type:
|
|
936
|
+
z4.object({
|
|
937
|
+
type: z4.literal("disabled")
|
|
852
938
|
})
|
|
853
939
|
]).optional(),
|
|
854
940
|
/**
|
|
855
941
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
856
942
|
* When set to true, Claude will use at most one tool per response.
|
|
857
943
|
*/
|
|
858
|
-
disableParallelToolUse:
|
|
944
|
+
disableParallelToolUse: z4.boolean().optional(),
|
|
859
945
|
/**
|
|
860
946
|
* Cache control settings for this message.
|
|
861
947
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
862
948
|
*/
|
|
863
|
-
cacheControl:
|
|
864
|
-
type:
|
|
865
|
-
ttl:
|
|
949
|
+
cacheControl: z4.object({
|
|
950
|
+
type: z4.literal("ephemeral"),
|
|
951
|
+
ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
|
|
952
|
+
}).optional(),
|
|
953
|
+
/**
|
|
954
|
+
* Metadata to include with the request.
|
|
955
|
+
*
|
|
956
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
957
|
+
*/
|
|
958
|
+
metadata: z4.object({
|
|
959
|
+
/**
|
|
960
|
+
* An external identifier for the user associated with the request.
|
|
961
|
+
*
|
|
962
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
963
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
964
|
+
*/
|
|
965
|
+
userId: z4.string().optional()
|
|
866
966
|
}).optional(),
|
|
867
967
|
/**
|
|
868
968
|
* MCP servers to be utilized in this request.
|
|
869
969
|
*/
|
|
870
|
-
mcpServers:
|
|
871
|
-
|
|
872
|
-
type:
|
|
873
|
-
name:
|
|
874
|
-
url:
|
|
875
|
-
authorizationToken:
|
|
876
|
-
toolConfiguration:
|
|
877
|
-
enabled:
|
|
878
|
-
allowedTools:
|
|
970
|
+
mcpServers: z4.array(
|
|
971
|
+
z4.object({
|
|
972
|
+
type: z4.literal("url"),
|
|
973
|
+
name: z4.string(),
|
|
974
|
+
url: z4.string(),
|
|
975
|
+
authorizationToken: z4.string().nullish(),
|
|
976
|
+
toolConfiguration: z4.object({
|
|
977
|
+
enabled: z4.boolean().nullish(),
|
|
978
|
+
allowedTools: z4.array(z4.string()).nullish()
|
|
879
979
|
}).nullish()
|
|
880
980
|
})
|
|
881
981
|
).optional(),
|
|
@@ -884,14 +984,21 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
884
984
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
885
985
|
* Requires code execution tool to be enabled.
|
|
886
986
|
*/
|
|
887
|
-
container:
|
|
888
|
-
id:
|
|
889
|
-
skills:
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
987
|
+
container: z4.object({
|
|
988
|
+
id: z4.string().optional(),
|
|
989
|
+
skills: z4.array(
|
|
990
|
+
z4.discriminatedUnion("type", [
|
|
991
|
+
z4.object({
|
|
992
|
+
type: z4.literal("anthropic"),
|
|
993
|
+
skillId: z4.string(),
|
|
994
|
+
version: z4.string().optional()
|
|
995
|
+
}),
|
|
996
|
+
z4.object({
|
|
997
|
+
type: z4.literal("custom"),
|
|
998
|
+
providerReference: z4.record(z4.string(), z4.string()),
|
|
999
|
+
version: z4.string().optional()
|
|
1000
|
+
})
|
|
1001
|
+
])
|
|
895
1002
|
).optional()
|
|
896
1003
|
}).optional(),
|
|
897
1004
|
/**
|
|
@@ -902,65 +1009,65 @@ var anthropicLanguageModelOptions = z3.object({
|
|
|
902
1009
|
*
|
|
903
1010
|
* @default true
|
|
904
1011
|
*/
|
|
905
|
-
toolStreaming:
|
|
1012
|
+
toolStreaming: z4.boolean().optional(),
|
|
906
1013
|
/**
|
|
907
1014
|
* @default 'high'
|
|
908
1015
|
*/
|
|
909
|
-
effort:
|
|
1016
|
+
effort: z4.enum(["low", "medium", "high", "max"]).optional(),
|
|
910
1017
|
/**
|
|
911
1018
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
912
1019
|
* Only supported with claude-opus-4-6.
|
|
913
1020
|
*/
|
|
914
|
-
speed:
|
|
1021
|
+
speed: z4.enum(["fast", "standard"]).optional(),
|
|
915
1022
|
/**
|
|
916
1023
|
* A set of beta features to enable.
|
|
917
1024
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
918
1025
|
*/
|
|
919
|
-
anthropicBeta:
|
|
920
|
-
contextManagement:
|
|
921
|
-
edits:
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
type:
|
|
925
|
-
trigger:
|
|
926
|
-
|
|
927
|
-
type:
|
|
928
|
-
value:
|
|
1026
|
+
anthropicBeta: z4.array(z4.string()).optional(),
|
|
1027
|
+
contextManagement: z4.object({
|
|
1028
|
+
edits: z4.array(
|
|
1029
|
+
z4.discriminatedUnion("type", [
|
|
1030
|
+
z4.object({
|
|
1031
|
+
type: z4.literal("clear_tool_uses_20250919"),
|
|
1032
|
+
trigger: z4.discriminatedUnion("type", [
|
|
1033
|
+
z4.object({
|
|
1034
|
+
type: z4.literal("input_tokens"),
|
|
1035
|
+
value: z4.number()
|
|
929
1036
|
}),
|
|
930
|
-
|
|
931
|
-
type:
|
|
932
|
-
value:
|
|
1037
|
+
z4.object({
|
|
1038
|
+
type: z4.literal("tool_uses"),
|
|
1039
|
+
value: z4.number()
|
|
933
1040
|
})
|
|
934
1041
|
]).optional(),
|
|
935
|
-
keep:
|
|
936
|
-
type:
|
|
937
|
-
value:
|
|
1042
|
+
keep: z4.object({
|
|
1043
|
+
type: z4.literal("tool_uses"),
|
|
1044
|
+
value: z4.number()
|
|
938
1045
|
}).optional(),
|
|
939
|
-
clearAtLeast:
|
|
940
|
-
type:
|
|
941
|
-
value:
|
|
1046
|
+
clearAtLeast: z4.object({
|
|
1047
|
+
type: z4.literal("input_tokens"),
|
|
1048
|
+
value: z4.number()
|
|
942
1049
|
}).optional(),
|
|
943
|
-
clearToolInputs:
|
|
944
|
-
excludeTools:
|
|
1050
|
+
clearToolInputs: z4.boolean().optional(),
|
|
1051
|
+
excludeTools: z4.array(z4.string()).optional()
|
|
945
1052
|
}),
|
|
946
|
-
|
|
947
|
-
type:
|
|
948
|
-
keep:
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
type:
|
|
952
|
-
value:
|
|
1053
|
+
z4.object({
|
|
1054
|
+
type: z4.literal("clear_thinking_20251015"),
|
|
1055
|
+
keep: z4.union([
|
|
1056
|
+
z4.literal("all"),
|
|
1057
|
+
z4.object({
|
|
1058
|
+
type: z4.literal("thinking_turns"),
|
|
1059
|
+
value: z4.number()
|
|
953
1060
|
})
|
|
954
1061
|
]).optional()
|
|
955
1062
|
}),
|
|
956
|
-
|
|
957
|
-
type:
|
|
958
|
-
trigger:
|
|
959
|
-
type:
|
|
960
|
-
value:
|
|
1063
|
+
z4.object({
|
|
1064
|
+
type: z4.literal("compact_20260112"),
|
|
1065
|
+
trigger: z4.object({
|
|
1066
|
+
type: z4.literal("input_tokens"),
|
|
1067
|
+
value: z4.number()
|
|
961
1068
|
}).optional(),
|
|
962
|
-
pauseAfterCompaction:
|
|
963
|
-
instructions:
|
|
1069
|
+
pauseAfterCompaction: z4.boolean().optional(),
|
|
1070
|
+
instructions: z4.string().optional()
|
|
964
1071
|
})
|
|
965
1072
|
])
|
|
966
1073
|
)
|
|
@@ -1016,26 +1123,26 @@ var CacheControlValidator = class {
|
|
|
1016
1123
|
|
|
1017
1124
|
// src/tool/text-editor_20250728.ts
|
|
1018
1125
|
import { createProviderToolFactory } from "@ai-sdk/provider-utils";
|
|
1019
|
-
import { z as
|
|
1020
|
-
import { lazySchema as
|
|
1021
|
-
var textEditor_20250728ArgsSchema =
|
|
1022
|
-
() =>
|
|
1023
|
-
|
|
1024
|
-
maxCharacters:
|
|
1126
|
+
import { z as z5 } from "zod/v4";
|
|
1127
|
+
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
1128
|
+
var textEditor_20250728ArgsSchema = lazySchema4(
|
|
1129
|
+
() => zodSchema4(
|
|
1130
|
+
z5.object({
|
|
1131
|
+
maxCharacters: z5.number().optional()
|
|
1025
1132
|
})
|
|
1026
1133
|
)
|
|
1027
1134
|
);
|
|
1028
|
-
var textEditor_20250728InputSchema =
|
|
1029
|
-
() =>
|
|
1030
|
-
|
|
1031
|
-
command:
|
|
1032
|
-
path:
|
|
1033
|
-
file_text:
|
|
1034
|
-
insert_line:
|
|
1035
|
-
new_str:
|
|
1036
|
-
insert_text:
|
|
1037
|
-
old_str:
|
|
1038
|
-
view_range:
|
|
1135
|
+
var textEditor_20250728InputSchema = lazySchema4(
|
|
1136
|
+
() => zodSchema4(
|
|
1137
|
+
z5.object({
|
|
1138
|
+
command: z5.enum(["view", "create", "str_replace", "insert"]),
|
|
1139
|
+
path: z5.string(),
|
|
1140
|
+
file_text: z5.string().optional(),
|
|
1141
|
+
insert_line: z5.number().int().optional(),
|
|
1142
|
+
new_str: z5.string().optional(),
|
|
1143
|
+
insert_text: z5.string().optional(),
|
|
1144
|
+
old_str: z5.string().optional(),
|
|
1145
|
+
view_range: z5.array(z5.number().int()).optional()
|
|
1039
1146
|
})
|
|
1040
1147
|
)
|
|
1041
1148
|
);
|
|
@@ -1050,64 +1157,11 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1050
1157
|
// src/tool/web-search_20260209.ts
|
|
1051
1158
|
import {
|
|
1052
1159
|
createProviderToolFactoryWithOutputSchema,
|
|
1053
|
-
lazySchema as lazySchema4,
|
|
1054
|
-
zodSchema as zodSchema4
|
|
1055
|
-
} from "@ai-sdk/provider-utils";
|
|
1056
|
-
import { z as z5 } from "zod/v4";
|
|
1057
|
-
var webSearch_20260209ArgsSchema = lazySchema4(
|
|
1058
|
-
() => zodSchema4(
|
|
1059
|
-
z5.object({
|
|
1060
|
-
maxUses: z5.number().optional(),
|
|
1061
|
-
allowedDomains: z5.array(z5.string()).optional(),
|
|
1062
|
-
blockedDomains: z5.array(z5.string()).optional(),
|
|
1063
|
-
userLocation: z5.object({
|
|
1064
|
-
type: z5.literal("approximate"),
|
|
1065
|
-
city: z5.string().optional(),
|
|
1066
|
-
region: z5.string().optional(),
|
|
1067
|
-
country: z5.string().optional(),
|
|
1068
|
-
timezone: z5.string().optional()
|
|
1069
|
-
}).optional()
|
|
1070
|
-
})
|
|
1071
|
-
)
|
|
1072
|
-
);
|
|
1073
|
-
var webSearch_20260209OutputSchema = lazySchema4(
|
|
1074
|
-
() => zodSchema4(
|
|
1075
|
-
z5.array(
|
|
1076
|
-
z5.object({
|
|
1077
|
-
url: z5.string(),
|
|
1078
|
-
title: z5.string().nullable(),
|
|
1079
|
-
pageAge: z5.string().nullable(),
|
|
1080
|
-
encryptedContent: z5.string(),
|
|
1081
|
-
type: z5.literal("web_search_result")
|
|
1082
|
-
})
|
|
1083
|
-
)
|
|
1084
|
-
)
|
|
1085
|
-
);
|
|
1086
|
-
var webSearch_20260209InputSchema = lazySchema4(
|
|
1087
|
-
() => zodSchema4(
|
|
1088
|
-
z5.object({
|
|
1089
|
-
query: z5.string()
|
|
1090
|
-
})
|
|
1091
|
-
)
|
|
1092
|
-
);
|
|
1093
|
-
var factory2 = createProviderToolFactoryWithOutputSchema({
|
|
1094
|
-
id: "anthropic.web_search_20260209",
|
|
1095
|
-
inputSchema: webSearch_20260209InputSchema,
|
|
1096
|
-
outputSchema: webSearch_20260209OutputSchema,
|
|
1097
|
-
supportsDeferredResults: true
|
|
1098
|
-
});
|
|
1099
|
-
var webSearch_20260209 = (args = {}) => {
|
|
1100
|
-
return factory2(args);
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
|
-
// src/tool/web-search_20250305.ts
|
|
1104
|
-
import {
|
|
1105
|
-
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1106
1160
|
lazySchema as lazySchema5,
|
|
1107
1161
|
zodSchema as zodSchema5
|
|
1108
1162
|
} from "@ai-sdk/provider-utils";
|
|
1109
1163
|
import { z as z6 } from "zod/v4";
|
|
1110
|
-
var
|
|
1164
|
+
var webSearch_20260209ArgsSchema = lazySchema5(
|
|
1111
1165
|
() => zodSchema5(
|
|
1112
1166
|
z6.object({
|
|
1113
1167
|
maxUses: z6.number().optional(),
|
|
@@ -1123,7 +1177,7 @@ var webSearch_20250305ArgsSchema = lazySchema5(
|
|
|
1123
1177
|
})
|
|
1124
1178
|
)
|
|
1125
1179
|
);
|
|
1126
|
-
var
|
|
1180
|
+
var webSearch_20260209OutputSchema = lazySchema5(
|
|
1127
1181
|
() => zodSchema5(
|
|
1128
1182
|
z6.array(
|
|
1129
1183
|
z6.object({
|
|
@@ -1136,92 +1190,84 @@ var webSearch_20250305OutputSchema = lazySchema5(
|
|
|
1136
1190
|
)
|
|
1137
1191
|
)
|
|
1138
1192
|
);
|
|
1139
|
-
var
|
|
1193
|
+
var webSearch_20260209InputSchema = lazySchema5(
|
|
1140
1194
|
() => zodSchema5(
|
|
1141
1195
|
z6.object({
|
|
1142
1196
|
query: z6.string()
|
|
1143
1197
|
})
|
|
1144
1198
|
)
|
|
1145
1199
|
);
|
|
1146
|
-
var
|
|
1147
|
-
id: "anthropic.
|
|
1148
|
-
inputSchema:
|
|
1149
|
-
outputSchema:
|
|
1200
|
+
var factory2 = createProviderToolFactoryWithOutputSchema({
|
|
1201
|
+
id: "anthropic.web_search_20260209",
|
|
1202
|
+
inputSchema: webSearch_20260209InputSchema,
|
|
1203
|
+
outputSchema: webSearch_20260209OutputSchema,
|
|
1150
1204
|
supportsDeferredResults: true
|
|
1151
1205
|
});
|
|
1152
|
-
var
|
|
1153
|
-
return
|
|
1206
|
+
var webSearch_20260209 = (args = {}) => {
|
|
1207
|
+
return factory2(args);
|
|
1154
1208
|
};
|
|
1155
1209
|
|
|
1156
|
-
// src/tool/web-
|
|
1210
|
+
// src/tool/web-search_20250305.ts
|
|
1157
1211
|
import {
|
|
1158
|
-
createProviderToolFactoryWithOutputSchema as
|
|
1212
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1159
1213
|
lazySchema as lazySchema6,
|
|
1160
1214
|
zodSchema as zodSchema6
|
|
1161
1215
|
} from "@ai-sdk/provider-utils";
|
|
1162
1216
|
import { z as z7 } from "zod/v4";
|
|
1163
|
-
var
|
|
1217
|
+
var webSearch_20250305ArgsSchema = lazySchema6(
|
|
1164
1218
|
() => zodSchema6(
|
|
1165
1219
|
z7.object({
|
|
1166
1220
|
maxUses: z7.number().optional(),
|
|
1167
1221
|
allowedDomains: z7.array(z7.string()).optional(),
|
|
1168
1222
|
blockedDomains: z7.array(z7.string()).optional(),
|
|
1169
|
-
|
|
1170
|
-
|
|
1223
|
+
userLocation: z7.object({
|
|
1224
|
+
type: z7.literal("approximate"),
|
|
1225
|
+
city: z7.string().optional(),
|
|
1226
|
+
region: z7.string().optional(),
|
|
1227
|
+
country: z7.string().optional(),
|
|
1228
|
+
timezone: z7.string().optional()
|
|
1229
|
+
}).optional()
|
|
1171
1230
|
})
|
|
1172
1231
|
)
|
|
1173
1232
|
);
|
|
1174
|
-
var
|
|
1233
|
+
var webSearch_20250305OutputSchema = lazySchema6(
|
|
1175
1234
|
() => zodSchema6(
|
|
1176
|
-
z7.
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
content: z7.object({
|
|
1180
|
-
type: z7.literal("document"),
|
|
1235
|
+
z7.array(
|
|
1236
|
+
z7.object({
|
|
1237
|
+
url: z7.string(),
|
|
1181
1238
|
title: z7.string().nullable(),
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
data: z7.string()
|
|
1188
|
-
}),
|
|
1189
|
-
z7.object({
|
|
1190
|
-
type: z7.literal("text"),
|
|
1191
|
-
mediaType: z7.literal("text/plain"),
|
|
1192
|
-
data: z7.string()
|
|
1193
|
-
})
|
|
1194
|
-
])
|
|
1195
|
-
}),
|
|
1196
|
-
retrievedAt: z7.string().nullable()
|
|
1197
|
-
})
|
|
1239
|
+
pageAge: z7.string().nullable(),
|
|
1240
|
+
encryptedContent: z7.string(),
|
|
1241
|
+
type: z7.literal("web_search_result")
|
|
1242
|
+
})
|
|
1243
|
+
)
|
|
1198
1244
|
)
|
|
1199
1245
|
);
|
|
1200
|
-
var
|
|
1246
|
+
var webSearch_20250305InputSchema = lazySchema6(
|
|
1201
1247
|
() => zodSchema6(
|
|
1202
1248
|
z7.object({
|
|
1203
|
-
|
|
1249
|
+
query: z7.string()
|
|
1204
1250
|
})
|
|
1205
1251
|
)
|
|
1206
1252
|
);
|
|
1207
|
-
var
|
|
1208
|
-
id: "anthropic.
|
|
1209
|
-
inputSchema:
|
|
1210
|
-
outputSchema:
|
|
1253
|
+
var factory3 = createProviderToolFactoryWithOutputSchema2({
|
|
1254
|
+
id: "anthropic.web_search_20250305",
|
|
1255
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
1256
|
+
outputSchema: webSearch_20250305OutputSchema,
|
|
1211
1257
|
supportsDeferredResults: true
|
|
1212
1258
|
});
|
|
1213
|
-
var
|
|
1214
|
-
return
|
|
1259
|
+
var webSearch_20250305 = (args = {}) => {
|
|
1260
|
+
return factory3(args);
|
|
1215
1261
|
};
|
|
1216
1262
|
|
|
1217
|
-
// src/tool/web-fetch-
|
|
1263
|
+
// src/tool/web-fetch-20260209.ts
|
|
1218
1264
|
import {
|
|
1219
|
-
createProviderToolFactoryWithOutputSchema as
|
|
1265
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1220
1266
|
lazySchema as lazySchema7,
|
|
1221
1267
|
zodSchema as zodSchema7
|
|
1222
1268
|
} from "@ai-sdk/provider-utils";
|
|
1223
1269
|
import { z as z8 } from "zod/v4";
|
|
1224
|
-
var
|
|
1270
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1225
1271
|
() => zodSchema7(
|
|
1226
1272
|
z8.object({
|
|
1227
1273
|
maxUses: z8.number().optional(),
|
|
@@ -1232,7 +1278,7 @@ var webFetch_20250910ArgsSchema = lazySchema7(
|
|
|
1232
1278
|
})
|
|
1233
1279
|
)
|
|
1234
1280
|
);
|
|
1235
|
-
var
|
|
1281
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1236
1282
|
() => zodSchema7(
|
|
1237
1283
|
z8.object({
|
|
1238
1284
|
type: z8.literal("web_fetch_result"),
|
|
@@ -1258,13 +1304,74 @@ var webFetch_20250910OutputSchema = lazySchema7(
|
|
|
1258
1304
|
})
|
|
1259
1305
|
)
|
|
1260
1306
|
);
|
|
1261
|
-
var
|
|
1307
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1262
1308
|
() => zodSchema7(
|
|
1263
1309
|
z8.object({
|
|
1264
1310
|
url: z8.string()
|
|
1265
1311
|
})
|
|
1266
1312
|
)
|
|
1267
1313
|
);
|
|
1314
|
+
var factory4 = createProviderToolFactoryWithOutputSchema3({
|
|
1315
|
+
id: "anthropic.web_fetch_20260209",
|
|
1316
|
+
inputSchema: webFetch_20260209InputSchema,
|
|
1317
|
+
outputSchema: webFetch_20260209OutputSchema,
|
|
1318
|
+
supportsDeferredResults: true
|
|
1319
|
+
});
|
|
1320
|
+
var webFetch_20260209 = (args = {}) => {
|
|
1321
|
+
return factory4(args);
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
// src/tool/web-fetch-20250910.ts
|
|
1325
|
+
import {
|
|
1326
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
1327
|
+
lazySchema as lazySchema8,
|
|
1328
|
+
zodSchema as zodSchema8
|
|
1329
|
+
} from "@ai-sdk/provider-utils";
|
|
1330
|
+
import { z as z9 } from "zod/v4";
|
|
1331
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1332
|
+
() => zodSchema8(
|
|
1333
|
+
z9.object({
|
|
1334
|
+
maxUses: z9.number().optional(),
|
|
1335
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1336
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1337
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1338
|
+
maxContentTokens: z9.number().optional()
|
|
1339
|
+
})
|
|
1340
|
+
)
|
|
1341
|
+
);
|
|
1342
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1343
|
+
() => zodSchema8(
|
|
1344
|
+
z9.object({
|
|
1345
|
+
type: z9.literal("web_fetch_result"),
|
|
1346
|
+
url: z9.string(),
|
|
1347
|
+
content: z9.object({
|
|
1348
|
+
type: z9.literal("document"),
|
|
1349
|
+
title: z9.string().nullable(),
|
|
1350
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1351
|
+
source: z9.union([
|
|
1352
|
+
z9.object({
|
|
1353
|
+
type: z9.literal("base64"),
|
|
1354
|
+
mediaType: z9.literal("application/pdf"),
|
|
1355
|
+
data: z9.string()
|
|
1356
|
+
}),
|
|
1357
|
+
z9.object({
|
|
1358
|
+
type: z9.literal("text"),
|
|
1359
|
+
mediaType: z9.literal("text/plain"),
|
|
1360
|
+
data: z9.string()
|
|
1361
|
+
})
|
|
1362
|
+
])
|
|
1363
|
+
}),
|
|
1364
|
+
retrievedAt: z9.string().nullable()
|
|
1365
|
+
})
|
|
1366
|
+
)
|
|
1367
|
+
);
|
|
1368
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1369
|
+
() => zodSchema8(
|
|
1370
|
+
z9.object({
|
|
1371
|
+
url: z9.string()
|
|
1372
|
+
})
|
|
1373
|
+
)
|
|
1374
|
+
);
|
|
1268
1375
|
var factory5 = createProviderToolFactoryWithOutputSchema4({
|
|
1269
1376
|
id: "anthropic.web_fetch_20250910",
|
|
1270
1377
|
inputSchema: webFetch_20250910InputSchema,
|
|
@@ -1282,7 +1389,8 @@ async function prepareTools({
|
|
|
1282
1389
|
toolChoice,
|
|
1283
1390
|
disableParallelToolUse,
|
|
1284
1391
|
cacheControlValidator,
|
|
1285
|
-
supportsStructuredOutput
|
|
1392
|
+
supportsStructuredOutput,
|
|
1393
|
+
supportsStrictTools
|
|
1286
1394
|
}) {
|
|
1287
1395
|
var _a;
|
|
1288
1396
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1304,13 +1412,20 @@ async function prepareTools({
|
|
|
1304
1412
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1305
1413
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1306
1414
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1415
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1416
|
+
toolWarnings.push({
|
|
1417
|
+
type: "unsupported",
|
|
1418
|
+
feature: "strict",
|
|
1419
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1307
1422
|
anthropicTools2.push({
|
|
1308
1423
|
name: tool.name,
|
|
1309
1424
|
description: tool.description,
|
|
1310
1425
|
input_schema: tool.inputSchema,
|
|
1311
1426
|
cache_control: cacheControl,
|
|
1312
1427
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1313
|
-
...
|
|
1428
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1314
1429
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1315
1430
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1316
1431
|
...tool.inputExamples != null ? {
|
|
@@ -1526,7 +1641,6 @@ async function prepareTools({
|
|
|
1526
1641
|
break;
|
|
1527
1642
|
}
|
|
1528
1643
|
case "anthropic.tool_search_regex_20251119": {
|
|
1529
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1530
1644
|
anthropicTools2.push({
|
|
1531
1645
|
type: "tool_search_tool_regex_20251119",
|
|
1532
1646
|
name: "tool_search_tool_regex"
|
|
@@ -1534,7 +1648,6 @@ async function prepareTools({
|
|
|
1534
1648
|
break;
|
|
1535
1649
|
}
|
|
1536
1650
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1537
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1538
1651
|
anthropicTools2.push({
|
|
1539
1652
|
type: "tool_search_tool_bm25_20251119",
|
|
1540
1653
|
name: "tool_search_tool_bm25"
|
|
@@ -1657,9 +1770,11 @@ import {
|
|
|
1657
1770
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1658
1771
|
} from "@ai-sdk/provider";
|
|
1659
1772
|
import {
|
|
1660
|
-
convertBase64ToUint8Array,
|
|
1773
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1661
1774
|
convertToBase64,
|
|
1662
|
-
|
|
1775
|
+
isProviderReference,
|
|
1776
|
+
parseProviderOptions as parseProviderOptions2,
|
|
1777
|
+
resolveProviderReference,
|
|
1663
1778
|
validateTypes as validateTypes2,
|
|
1664
1779
|
isNonNullable
|
|
1665
1780
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1667,30 +1782,30 @@ import {
|
|
|
1667
1782
|
// src/tool/code-execution_20250522.ts
|
|
1668
1783
|
import {
|
|
1669
1784
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
1670
|
-
lazySchema as
|
|
1671
|
-
zodSchema as
|
|
1785
|
+
lazySchema as lazySchema9,
|
|
1786
|
+
zodSchema as zodSchema9
|
|
1672
1787
|
} from "@ai-sdk/provider-utils";
|
|
1673
|
-
import { z as
|
|
1674
|
-
var codeExecution_20250522OutputSchema =
|
|
1675
|
-
() =>
|
|
1676
|
-
|
|
1677
|
-
type:
|
|
1678
|
-
stdout:
|
|
1679
|
-
stderr:
|
|
1680
|
-
return_code:
|
|
1681
|
-
content:
|
|
1682
|
-
|
|
1683
|
-
type:
|
|
1684
|
-
file_id:
|
|
1788
|
+
import { z as z10 } from "zod/v4";
|
|
1789
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1790
|
+
() => zodSchema9(
|
|
1791
|
+
z10.object({
|
|
1792
|
+
type: z10.literal("code_execution_result"),
|
|
1793
|
+
stdout: z10.string(),
|
|
1794
|
+
stderr: z10.string(),
|
|
1795
|
+
return_code: z10.number(),
|
|
1796
|
+
content: z10.array(
|
|
1797
|
+
z10.object({
|
|
1798
|
+
type: z10.literal("code_execution_output"),
|
|
1799
|
+
file_id: z10.string()
|
|
1685
1800
|
})
|
|
1686
1801
|
).optional().default([])
|
|
1687
1802
|
})
|
|
1688
1803
|
)
|
|
1689
1804
|
);
|
|
1690
|
-
var codeExecution_20250522InputSchema =
|
|
1691
|
-
() =>
|
|
1692
|
-
|
|
1693
|
-
code:
|
|
1805
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1806
|
+
() => zodSchema9(
|
|
1807
|
+
z10.object({
|
|
1808
|
+
code: z10.string()
|
|
1694
1809
|
})
|
|
1695
1810
|
)
|
|
1696
1811
|
);
|
|
@@ -1706,98 +1821,98 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1706
1821
|
// src/tool/code-execution_20250825.ts
|
|
1707
1822
|
import {
|
|
1708
1823
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
1709
|
-
lazySchema as
|
|
1710
|
-
zodSchema as
|
|
1824
|
+
lazySchema as lazySchema10,
|
|
1825
|
+
zodSchema as zodSchema10
|
|
1711
1826
|
} from "@ai-sdk/provider-utils";
|
|
1712
|
-
import { z as
|
|
1713
|
-
var codeExecution_20250825OutputSchema =
|
|
1714
|
-
() =>
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
type:
|
|
1718
|
-
stdout:
|
|
1719
|
-
stderr:
|
|
1720
|
-
return_code:
|
|
1721
|
-
content:
|
|
1722
|
-
|
|
1723
|
-
type:
|
|
1724
|
-
file_id:
|
|
1827
|
+
import { z as z11 } from "zod/v4";
|
|
1828
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1829
|
+
() => zodSchema10(
|
|
1830
|
+
z11.discriminatedUnion("type", [
|
|
1831
|
+
z11.object({
|
|
1832
|
+
type: z11.literal("code_execution_result"),
|
|
1833
|
+
stdout: z11.string(),
|
|
1834
|
+
stderr: z11.string(),
|
|
1835
|
+
return_code: z11.number(),
|
|
1836
|
+
content: z11.array(
|
|
1837
|
+
z11.object({
|
|
1838
|
+
type: z11.literal("code_execution_output"),
|
|
1839
|
+
file_id: z11.string()
|
|
1725
1840
|
})
|
|
1726
1841
|
).optional().default([])
|
|
1727
1842
|
}),
|
|
1728
|
-
|
|
1729
|
-
type:
|
|
1730
|
-
content:
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
file_id:
|
|
1843
|
+
z11.object({
|
|
1844
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1845
|
+
content: z11.array(
|
|
1846
|
+
z11.object({
|
|
1847
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1848
|
+
file_id: z11.string()
|
|
1734
1849
|
})
|
|
1735
1850
|
),
|
|
1736
|
-
stdout:
|
|
1737
|
-
stderr:
|
|
1738
|
-
return_code:
|
|
1851
|
+
stdout: z11.string(),
|
|
1852
|
+
stderr: z11.string(),
|
|
1853
|
+
return_code: z11.number()
|
|
1739
1854
|
}),
|
|
1740
|
-
|
|
1741
|
-
type:
|
|
1742
|
-
error_code:
|
|
1855
|
+
z11.object({
|
|
1856
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1857
|
+
error_code: z11.string()
|
|
1743
1858
|
}),
|
|
1744
|
-
|
|
1745
|
-
type:
|
|
1746
|
-
error_code:
|
|
1859
|
+
z11.object({
|
|
1860
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1861
|
+
error_code: z11.string()
|
|
1747
1862
|
}),
|
|
1748
|
-
|
|
1749
|
-
type:
|
|
1750
|
-
content:
|
|
1751
|
-
file_type:
|
|
1752
|
-
num_lines:
|
|
1753
|
-
start_line:
|
|
1754
|
-
total_lines:
|
|
1863
|
+
z11.object({
|
|
1864
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1865
|
+
content: z11.string(),
|
|
1866
|
+
file_type: z11.string(),
|
|
1867
|
+
num_lines: z11.number().nullable(),
|
|
1868
|
+
start_line: z11.number().nullable(),
|
|
1869
|
+
total_lines: z11.number().nullable()
|
|
1755
1870
|
}),
|
|
1756
|
-
|
|
1757
|
-
type:
|
|
1758
|
-
is_file_update:
|
|
1871
|
+
z11.object({
|
|
1872
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1873
|
+
is_file_update: z11.boolean()
|
|
1759
1874
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
lines:
|
|
1763
|
-
new_lines:
|
|
1764
|
-
new_start:
|
|
1765
|
-
old_lines:
|
|
1766
|
-
old_start:
|
|
1875
|
+
z11.object({
|
|
1876
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1877
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1878
|
+
new_lines: z11.number().nullable(),
|
|
1879
|
+
new_start: z11.number().nullable(),
|
|
1880
|
+
old_lines: z11.number().nullable(),
|
|
1881
|
+
old_start: z11.number().nullable()
|
|
1767
1882
|
})
|
|
1768
1883
|
])
|
|
1769
1884
|
)
|
|
1770
1885
|
);
|
|
1771
|
-
var codeExecution_20250825InputSchema =
|
|
1772
|
-
() =>
|
|
1773
|
-
|
|
1886
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1887
|
+
() => zodSchema10(
|
|
1888
|
+
z11.discriminatedUnion("type", [
|
|
1774
1889
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1775
|
-
|
|
1776
|
-
type:
|
|
1777
|
-
code:
|
|
1890
|
+
z11.object({
|
|
1891
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1892
|
+
code: z11.string()
|
|
1778
1893
|
}),
|
|
1779
|
-
|
|
1780
|
-
type:
|
|
1781
|
-
command:
|
|
1894
|
+
z11.object({
|
|
1895
|
+
type: z11.literal("bash_code_execution"),
|
|
1896
|
+
command: z11.string()
|
|
1782
1897
|
}),
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
type:
|
|
1786
|
-
command:
|
|
1787
|
-
path:
|
|
1898
|
+
z11.discriminatedUnion("command", [
|
|
1899
|
+
z11.object({
|
|
1900
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1901
|
+
command: z11.literal("view"),
|
|
1902
|
+
path: z11.string()
|
|
1788
1903
|
}),
|
|
1789
|
-
|
|
1790
|
-
type:
|
|
1791
|
-
command:
|
|
1792
|
-
path:
|
|
1793
|
-
file_text:
|
|
1904
|
+
z11.object({
|
|
1905
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1906
|
+
command: z11.literal("create"),
|
|
1907
|
+
path: z11.string(),
|
|
1908
|
+
file_text: z11.string().nullish()
|
|
1794
1909
|
}),
|
|
1795
|
-
|
|
1796
|
-
type:
|
|
1797
|
-
command:
|
|
1798
|
-
path:
|
|
1799
|
-
old_str:
|
|
1800
|
-
new_str:
|
|
1910
|
+
z11.object({
|
|
1911
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1912
|
+
command: z11.literal("str_replace"),
|
|
1913
|
+
path: z11.string(),
|
|
1914
|
+
old_str: z11.string(),
|
|
1915
|
+
new_str: z11.string()
|
|
1801
1916
|
})
|
|
1802
1917
|
])
|
|
1803
1918
|
])
|
|
@@ -1819,109 +1934,109 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1819
1934
|
// src/tool/code-execution_20260120.ts
|
|
1820
1935
|
import {
|
|
1821
1936
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
1822
|
-
lazySchema as
|
|
1823
|
-
zodSchema as
|
|
1937
|
+
lazySchema as lazySchema11,
|
|
1938
|
+
zodSchema as zodSchema11
|
|
1824
1939
|
} from "@ai-sdk/provider-utils";
|
|
1825
|
-
import { z as
|
|
1826
|
-
var codeExecution_20260120OutputSchema =
|
|
1827
|
-
() =>
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
type:
|
|
1831
|
-
stdout:
|
|
1832
|
-
stderr:
|
|
1833
|
-
return_code:
|
|
1834
|
-
content:
|
|
1835
|
-
|
|
1836
|
-
type:
|
|
1837
|
-
file_id:
|
|
1940
|
+
import { z as z12 } from "zod/v4";
|
|
1941
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
1942
|
+
() => zodSchema11(
|
|
1943
|
+
z12.discriminatedUnion("type", [
|
|
1944
|
+
z12.object({
|
|
1945
|
+
type: z12.literal("code_execution_result"),
|
|
1946
|
+
stdout: z12.string(),
|
|
1947
|
+
stderr: z12.string(),
|
|
1948
|
+
return_code: z12.number(),
|
|
1949
|
+
content: z12.array(
|
|
1950
|
+
z12.object({
|
|
1951
|
+
type: z12.literal("code_execution_output"),
|
|
1952
|
+
file_id: z12.string()
|
|
1838
1953
|
})
|
|
1839
1954
|
).optional().default([])
|
|
1840
1955
|
}),
|
|
1841
|
-
|
|
1842
|
-
type:
|
|
1843
|
-
encrypted_stdout:
|
|
1844
|
-
stderr:
|
|
1845
|
-
return_code:
|
|
1846
|
-
content:
|
|
1847
|
-
|
|
1848
|
-
type:
|
|
1849
|
-
file_id:
|
|
1956
|
+
z12.object({
|
|
1957
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
1958
|
+
encrypted_stdout: z12.string(),
|
|
1959
|
+
stderr: z12.string(),
|
|
1960
|
+
return_code: z12.number(),
|
|
1961
|
+
content: z12.array(
|
|
1962
|
+
z12.object({
|
|
1963
|
+
type: z12.literal("code_execution_output"),
|
|
1964
|
+
file_id: z12.string()
|
|
1850
1965
|
})
|
|
1851
1966
|
).optional().default([])
|
|
1852
1967
|
}),
|
|
1853
|
-
|
|
1854
|
-
type:
|
|
1855
|
-
content:
|
|
1856
|
-
|
|
1857
|
-
type:
|
|
1858
|
-
file_id:
|
|
1968
|
+
z12.object({
|
|
1969
|
+
type: z12.literal("bash_code_execution_result"),
|
|
1970
|
+
content: z12.array(
|
|
1971
|
+
z12.object({
|
|
1972
|
+
type: z12.literal("bash_code_execution_output"),
|
|
1973
|
+
file_id: z12.string()
|
|
1859
1974
|
})
|
|
1860
1975
|
),
|
|
1861
|
-
stdout:
|
|
1862
|
-
stderr:
|
|
1863
|
-
return_code:
|
|
1864
|
-
}),
|
|
1865
|
-
z11.object({
|
|
1866
|
-
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1867
|
-
error_code: z11.string()
|
|
1976
|
+
stdout: z12.string(),
|
|
1977
|
+
stderr: z12.string(),
|
|
1978
|
+
return_code: z12.number()
|
|
1868
1979
|
}),
|
|
1869
|
-
|
|
1870
|
-
type:
|
|
1871
|
-
error_code:
|
|
1872
|
-
}),
|
|
1873
|
-
z11.object({
|
|
1874
|
-
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1875
|
-
content: z11.string(),
|
|
1876
|
-
file_type: z11.string(),
|
|
1877
|
-
num_lines: z11.number().nullable(),
|
|
1878
|
-
start_line: z11.number().nullable(),
|
|
1879
|
-
total_lines: z11.number().nullable()
|
|
1980
|
+
z12.object({
|
|
1981
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
1982
|
+
error_code: z12.string()
|
|
1880
1983
|
}),
|
|
1881
|
-
|
|
1882
|
-
type:
|
|
1883
|
-
|
|
1984
|
+
z12.object({
|
|
1985
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
1986
|
+
error_code: z12.string()
|
|
1884
1987
|
}),
|
|
1885
|
-
|
|
1886
|
-
type:
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1988
|
+
z12.object({
|
|
1989
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
1990
|
+
content: z12.string(),
|
|
1991
|
+
file_type: z12.string(),
|
|
1992
|
+
num_lines: z12.number().nullable(),
|
|
1993
|
+
start_line: z12.number().nullable(),
|
|
1994
|
+
total_lines: z12.number().nullable()
|
|
1995
|
+
}),
|
|
1996
|
+
z12.object({
|
|
1997
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
1998
|
+
is_file_update: z12.boolean()
|
|
1999
|
+
}),
|
|
2000
|
+
z12.object({
|
|
2001
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2002
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2003
|
+
new_lines: z12.number().nullable(),
|
|
2004
|
+
new_start: z12.number().nullable(),
|
|
2005
|
+
old_lines: z12.number().nullable(),
|
|
2006
|
+
old_start: z12.number().nullable()
|
|
1892
2007
|
})
|
|
1893
2008
|
])
|
|
1894
2009
|
)
|
|
1895
2010
|
);
|
|
1896
|
-
var codeExecution_20260120InputSchema =
|
|
1897
|
-
() =>
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
type:
|
|
1901
|
-
code:
|
|
2011
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
2012
|
+
() => zodSchema11(
|
|
2013
|
+
z12.discriminatedUnion("type", [
|
|
2014
|
+
z12.object({
|
|
2015
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2016
|
+
code: z12.string()
|
|
1902
2017
|
}),
|
|
1903
|
-
|
|
1904
|
-
type:
|
|
1905
|
-
command:
|
|
2018
|
+
z12.object({
|
|
2019
|
+
type: z12.literal("bash_code_execution"),
|
|
2020
|
+
command: z12.string()
|
|
1906
2021
|
}),
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
type:
|
|
1910
|
-
command:
|
|
1911
|
-
path:
|
|
2022
|
+
z12.discriminatedUnion("command", [
|
|
2023
|
+
z12.object({
|
|
2024
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2025
|
+
command: z12.literal("view"),
|
|
2026
|
+
path: z12.string()
|
|
1912
2027
|
}),
|
|
1913
|
-
|
|
1914
|
-
type:
|
|
1915
|
-
command:
|
|
1916
|
-
path:
|
|
1917
|
-
file_text:
|
|
2028
|
+
z12.object({
|
|
2029
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2030
|
+
command: z12.literal("create"),
|
|
2031
|
+
path: z12.string(),
|
|
2032
|
+
file_text: z12.string().nullish()
|
|
1918
2033
|
}),
|
|
1919
|
-
|
|
1920
|
-
type:
|
|
1921
|
-
command:
|
|
1922
|
-
path:
|
|
1923
|
-
old_str:
|
|
1924
|
-
new_str:
|
|
2034
|
+
z12.object({
|
|
2035
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2036
|
+
command: z12.literal("str_replace"),
|
|
2037
|
+
path: z12.string(),
|
|
2038
|
+
old_str: z12.string(),
|
|
2039
|
+
new_str: z12.string()
|
|
1925
2040
|
})
|
|
1926
2041
|
])
|
|
1927
2042
|
])
|
|
@@ -1940,23 +2055,23 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1940
2055
|
// src/tool/tool-search-regex_20251119.ts
|
|
1941
2056
|
import {
|
|
1942
2057
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
1943
|
-
lazySchema as
|
|
1944
|
-
zodSchema as
|
|
2058
|
+
lazySchema as lazySchema12,
|
|
2059
|
+
zodSchema as zodSchema12
|
|
1945
2060
|
} from "@ai-sdk/provider-utils";
|
|
1946
|
-
import { z as
|
|
1947
|
-
var toolSearchRegex_20251119OutputSchema =
|
|
1948
|
-
() =>
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
type:
|
|
1952
|
-
toolName:
|
|
2061
|
+
import { z as z13 } from "zod/v4";
|
|
2062
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2063
|
+
() => zodSchema12(
|
|
2064
|
+
z13.array(
|
|
2065
|
+
z13.object({
|
|
2066
|
+
type: z13.literal("tool_reference"),
|
|
2067
|
+
toolName: z13.string()
|
|
1953
2068
|
})
|
|
1954
2069
|
)
|
|
1955
2070
|
)
|
|
1956
2071
|
);
|
|
1957
|
-
var toolSearchRegex_20251119InputSchema =
|
|
1958
|
-
() =>
|
|
1959
|
-
|
|
2072
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2073
|
+
() => zodSchema12(
|
|
2074
|
+
z13.object({
|
|
1960
2075
|
/**
|
|
1961
2076
|
* A regex pattern to search for tools.
|
|
1962
2077
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1967,11 +2082,11 @@ var toolSearchRegex_20251119InputSchema = lazySchema11(
|
|
|
1967
2082
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1968
2083
|
* - "(?i)slack" - case-insensitive search
|
|
1969
2084
|
*/
|
|
1970
|
-
pattern:
|
|
2085
|
+
pattern: z13.string(),
|
|
1971
2086
|
/**
|
|
1972
2087
|
* Maximum number of tools to return. Optional.
|
|
1973
2088
|
*/
|
|
1974
|
-
limit:
|
|
2089
|
+
limit: z13.number().optional()
|
|
1975
2090
|
})
|
|
1976
2091
|
)
|
|
1977
2092
|
);
|
|
@@ -1988,7 +2103,7 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1988
2103
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1989
2104
|
function convertToString(data) {
|
|
1990
2105
|
if (typeof data === "string") {
|
|
1991
|
-
return new TextDecoder().decode(
|
|
2106
|
+
return new TextDecoder().decode(convertBase64ToUint8Array2(data));
|
|
1992
2107
|
}
|
|
1993
2108
|
if (data instanceof Uint8Array) {
|
|
1994
2109
|
return new TextDecoder().decode(data);
|
|
@@ -2026,7 +2141,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2026
2141
|
const messages = [];
|
|
2027
2142
|
async function shouldEnableCitations(providerMetadata) {
|
|
2028
2143
|
var _a2, _b2;
|
|
2029
|
-
const anthropicOptions = await
|
|
2144
|
+
const anthropicOptions = await parseProviderOptions2({
|
|
2030
2145
|
provider: "anthropic",
|
|
2031
2146
|
providerOptions: providerMetadata,
|
|
2032
2147
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2034,7 +2149,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2034
2149
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
2035
2150
|
}
|
|
2036
2151
|
async function getDocumentMetadata(providerMetadata) {
|
|
2037
|
-
const anthropicOptions = await
|
|
2152
|
+
const anthropicOptions = await parseProviderOptions2({
|
|
2038
2153
|
provider: "anthropic",
|
|
2039
2154
|
providerOptions: providerMetadata,
|
|
2040
2155
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2091,7 +2206,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2091
2206
|
break;
|
|
2092
2207
|
}
|
|
2093
2208
|
case "file": {
|
|
2094
|
-
if (part.
|
|
2209
|
+
if (isProviderReference(part.data)) {
|
|
2210
|
+
const fileId = resolveProviderReference({
|
|
2211
|
+
reference: part.data,
|
|
2212
|
+
provider: "anthropic"
|
|
2213
|
+
});
|
|
2214
|
+
betas.add("files-api-2025-04-14");
|
|
2215
|
+
if (part.mediaType.startsWith("image/")) {
|
|
2216
|
+
anthropicContent.push({
|
|
2217
|
+
type: "image",
|
|
2218
|
+
source: { type: "file", file_id: fileId },
|
|
2219
|
+
cache_control: cacheControl
|
|
2220
|
+
});
|
|
2221
|
+
} else {
|
|
2222
|
+
anthropicContent.push({
|
|
2223
|
+
type: "document",
|
|
2224
|
+
source: { type: "file", file_id: fileId },
|
|
2225
|
+
cache_control: cacheControl
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
} else if (part.mediaType.startsWith("image/")) {
|
|
2095
2229
|
anthropicContent.push({
|
|
2096
2230
|
type: "image",
|
|
2097
2231
|
source: isUrlData(part.data) ? {
|
|
@@ -2334,7 +2468,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2334
2468
|
}
|
|
2335
2469
|
case "reasoning": {
|
|
2336
2470
|
if (sendReasoning) {
|
|
2337
|
-
const reasoningMetadata = await
|
|
2471
|
+
const reasoningMetadata = await parseProviderOptions2({
|
|
2338
2472
|
provider: "anthropic",
|
|
2339
2473
|
providerOptions: part.providerOptions,
|
|
2340
2474
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2867,7 +3001,7 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2867
3001
|
}
|
|
2868
3002
|
var AnthropicMessagesLanguageModel = class {
|
|
2869
3003
|
constructor(modelId, config) {
|
|
2870
|
-
this.specificationVersion = "
|
|
3004
|
+
this.specificationVersion = "v4";
|
|
2871
3005
|
var _a;
|
|
2872
3006
|
this.modelId = modelId;
|
|
2873
3007
|
this.config = config;
|
|
@@ -2906,10 +3040,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2906
3040
|
seed,
|
|
2907
3041
|
tools,
|
|
2908
3042
|
toolChoice,
|
|
3043
|
+
reasoning,
|
|
2909
3044
|
providerOptions,
|
|
2910
3045
|
stream
|
|
2911
3046
|
}) {
|
|
2912
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3047
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2913
3048
|
const warnings = [];
|
|
2914
3049
|
if (frequencyPenalty != null) {
|
|
2915
3050
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2945,12 +3080,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2945
3080
|
}
|
|
2946
3081
|
}
|
|
2947
3082
|
const providerOptionsName = this.providerOptionsName;
|
|
2948
|
-
const canonicalOptions = await
|
|
3083
|
+
const canonicalOptions = await parseProviderOptions3({
|
|
2949
3084
|
provider: "anthropic",
|
|
2950
3085
|
providerOptions,
|
|
2951
3086
|
schema: anthropicLanguageModelOptions
|
|
2952
3087
|
});
|
|
2953
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await
|
|
3088
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions3({
|
|
2954
3089
|
provider: providerOptionsName,
|
|
2955
3090
|
providerOptions,
|
|
2956
3091
|
schema: anthropicLanguageModelOptions
|
|
@@ -2964,10 +3099,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2964
3099
|
const {
|
|
2965
3100
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2966
3101
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3102
|
+
supportsAdaptiveThinking,
|
|
2967
3103
|
isKnownModel
|
|
2968
3104
|
} = getModelCapabilities(this.modelId);
|
|
3105
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2969
3106
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2970
|
-
const
|
|
3107
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3108
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2971
3109
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2972
3110
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2973
3111
|
type: "function",
|
|
@@ -3002,14 +3140,28 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3002
3140
|
});
|
|
3003
3141
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
3004
3142
|
prompt,
|
|
3005
|
-
sendReasoning: (
|
|
3143
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
3006
3144
|
warnings,
|
|
3007
3145
|
cacheControlValidator,
|
|
3008
3146
|
toolNameMapping
|
|
3009
3147
|
});
|
|
3010
|
-
|
|
3148
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3149
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3150
|
+
reasoning,
|
|
3151
|
+
supportsAdaptiveThinking,
|
|
3152
|
+
maxOutputTokensForModel,
|
|
3153
|
+
warnings
|
|
3154
|
+
});
|
|
3155
|
+
if (reasoningConfig != null) {
|
|
3156
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3157
|
+
if (reasoningConfig.effort != null) {
|
|
3158
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
3011
3163
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
3012
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3164
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
3013
3165
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
3014
3166
|
const baseArgs = {
|
|
3015
3167
|
// model id:
|
|
@@ -3046,6 +3198,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3046
3198
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3047
3199
|
cache_control: anthropicOptions.cacheControl
|
|
3048
3200
|
},
|
|
3201
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
|
|
3202
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3203
|
+
},
|
|
3049
3204
|
// mcp servers:
|
|
3050
3205
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3051
3206
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3067,7 +3222,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3067
3222
|
id: anthropicOptions.container.id,
|
|
3068
3223
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3069
3224
|
type: skill.type,
|
|
3070
|
-
skill_id: skill.
|
|
3225
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3226
|
+
reference: skill.providerReference,
|
|
3227
|
+
provider: "anthropic"
|
|
3228
|
+
}) : skill.skillId,
|
|
3071
3229
|
version: skill.version
|
|
3072
3230
|
}))
|
|
3073
3231
|
}
|
|
@@ -3169,7 +3327,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3169
3327
|
}
|
|
3170
3328
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3171
3329
|
} else {
|
|
3172
|
-
if (topP != null && temperature != null) {
|
|
3330
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3173
3331
|
warnings.push({
|
|
3174
3332
|
type: "unsupported",
|
|
3175
3333
|
feature: "topP",
|
|
@@ -3216,7 +3374,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3216
3374
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3217
3375
|
betas.add("fast-mode-2026-02-01");
|
|
3218
3376
|
}
|
|
3219
|
-
if (stream && ((
|
|
3377
|
+
if (stream && ((_h = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _h : true)) {
|
|
3220
3378
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3221
3379
|
}
|
|
3222
3380
|
const {
|
|
@@ -3230,13 +3388,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3230
3388
|
toolChoice: { type: "required" },
|
|
3231
3389
|
disableParallelToolUse: true,
|
|
3232
3390
|
cacheControlValidator,
|
|
3233
|
-
supportsStructuredOutput: false
|
|
3391
|
+
supportsStructuredOutput: false,
|
|
3392
|
+
supportsStrictTools
|
|
3234
3393
|
} : {
|
|
3235
3394
|
tools: tools != null ? tools : [],
|
|
3236
3395
|
toolChoice,
|
|
3237
3396
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3238
3397
|
cacheControlValidator,
|
|
3239
|
-
supportsStructuredOutput
|
|
3398
|
+
supportsStructuredOutput,
|
|
3399
|
+
supportsStrictTools
|
|
3240
3400
|
}
|
|
3241
3401
|
);
|
|
3242
3402
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3253,7 +3413,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3253
3413
|
...betas,
|
|
3254
3414
|
...toolsBetas,
|
|
3255
3415
|
...userSuppliedBetas,
|
|
3256
|
-
...(
|
|
3416
|
+
...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
|
|
3257
3417
|
]),
|
|
3258
3418
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3259
3419
|
toolNameMapping,
|
|
@@ -3265,7 +3425,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3265
3425
|
betas,
|
|
3266
3426
|
headers
|
|
3267
3427
|
}) {
|
|
3268
|
-
return
|
|
3428
|
+
return combineHeaders2(
|
|
3269
3429
|
await resolve(this.config.headers),
|
|
3270
3430
|
headers,
|
|
3271
3431
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
@@ -3344,7 +3504,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3344
3504
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3345
3505
|
body: this.transformRequestBody(args, betas),
|
|
3346
3506
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3347
|
-
successfulResponseHandler:
|
|
3507
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
3348
3508
|
anthropicMessagesResponseSchema
|
|
3349
3509
|
),
|
|
3350
3510
|
abortSignal: options.abortSignal,
|
|
@@ -4516,42 +4676,49 @@ function getModelCapabilities(modelId) {
|
|
|
4516
4676
|
return {
|
|
4517
4677
|
maxOutputTokens: 128e3,
|
|
4518
4678
|
supportsStructuredOutput: true,
|
|
4679
|
+
supportsAdaptiveThinking: true,
|
|
4519
4680
|
isKnownModel: true
|
|
4520
4681
|
};
|
|
4521
4682
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4522
4683
|
return {
|
|
4523
4684
|
maxOutputTokens: 64e3,
|
|
4524
4685
|
supportsStructuredOutput: true,
|
|
4686
|
+
supportsAdaptiveThinking: false,
|
|
4525
4687
|
isKnownModel: true
|
|
4526
4688
|
};
|
|
4527
4689
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4528
4690
|
return {
|
|
4529
4691
|
maxOutputTokens: 32e3,
|
|
4530
4692
|
supportsStructuredOutput: true,
|
|
4693
|
+
supportsAdaptiveThinking: false,
|
|
4531
4694
|
isKnownModel: true
|
|
4532
4695
|
};
|
|
4533
4696
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4534
4697
|
return {
|
|
4535
4698
|
maxOutputTokens: 64e3,
|
|
4536
4699
|
supportsStructuredOutput: false,
|
|
4700
|
+
supportsAdaptiveThinking: false,
|
|
4537
4701
|
isKnownModel: true
|
|
4538
4702
|
};
|
|
4539
4703
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4540
4704
|
return {
|
|
4541
4705
|
maxOutputTokens: 32e3,
|
|
4542
4706
|
supportsStructuredOutput: false,
|
|
4707
|
+
supportsAdaptiveThinking: false,
|
|
4543
4708
|
isKnownModel: true
|
|
4544
4709
|
};
|
|
4545
4710
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4546
4711
|
return {
|
|
4547
4712
|
maxOutputTokens: 4096,
|
|
4548
4713
|
supportsStructuredOutput: false,
|
|
4714
|
+
supportsAdaptiveThinking: false,
|
|
4549
4715
|
isKnownModel: true
|
|
4550
4716
|
};
|
|
4551
4717
|
} else {
|
|
4552
4718
|
return {
|
|
4553
4719
|
maxOutputTokens: 4096,
|
|
4554
4720
|
supportsStructuredOutput: false,
|
|
4721
|
+
supportsAdaptiveThinking: false,
|
|
4555
4722
|
isKnownModel: false
|
|
4556
4723
|
};
|
|
4557
4724
|
}
|
|
@@ -4574,6 +4741,43 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4574
4741
|
}
|
|
4575
4742
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4576
4743
|
}
|
|
4744
|
+
function resolveAnthropicReasoningConfig({
|
|
4745
|
+
reasoning,
|
|
4746
|
+
supportsAdaptiveThinking,
|
|
4747
|
+
maxOutputTokensForModel,
|
|
4748
|
+
warnings
|
|
4749
|
+
}) {
|
|
4750
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4751
|
+
return void 0;
|
|
4752
|
+
}
|
|
4753
|
+
if (reasoning === "none") {
|
|
4754
|
+
return { thinking: { type: "disabled" } };
|
|
4755
|
+
}
|
|
4756
|
+
if (supportsAdaptiveThinking) {
|
|
4757
|
+
const effort = mapReasoningToProviderEffort({
|
|
4758
|
+
reasoning,
|
|
4759
|
+
effortMap: {
|
|
4760
|
+
minimal: "low",
|
|
4761
|
+
low: "low",
|
|
4762
|
+
medium: "medium",
|
|
4763
|
+
high: "high",
|
|
4764
|
+
xhigh: "max"
|
|
4765
|
+
},
|
|
4766
|
+
warnings
|
|
4767
|
+
});
|
|
4768
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4769
|
+
}
|
|
4770
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4771
|
+
reasoning,
|
|
4772
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4773
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4774
|
+
warnings
|
|
4775
|
+
});
|
|
4776
|
+
if (budgetTokens == null) {
|
|
4777
|
+
return void 0;
|
|
4778
|
+
}
|
|
4779
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4780
|
+
}
|
|
4577
4781
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4578
4782
|
return contextManagement ? {
|
|
4579
4783
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4603,15 +4807,15 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4603
4807
|
// src/tool/bash_20241022.ts
|
|
4604
4808
|
import {
|
|
4605
4809
|
createProviderToolFactory as createProviderToolFactory2,
|
|
4606
|
-
lazySchema as
|
|
4607
|
-
zodSchema as
|
|
4810
|
+
lazySchema as lazySchema13,
|
|
4811
|
+
zodSchema as zodSchema13
|
|
4608
4812
|
} from "@ai-sdk/provider-utils";
|
|
4609
|
-
import { z as
|
|
4610
|
-
var bash_20241022InputSchema =
|
|
4611
|
-
() =>
|
|
4612
|
-
|
|
4613
|
-
command:
|
|
4614
|
-
restart:
|
|
4813
|
+
import { z as z14 } from "zod/v4";
|
|
4814
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
4815
|
+
() => zodSchema13(
|
|
4816
|
+
z14.object({
|
|
4817
|
+
command: z14.string(),
|
|
4818
|
+
restart: z14.boolean().optional()
|
|
4615
4819
|
})
|
|
4616
4820
|
)
|
|
4617
4821
|
);
|
|
@@ -4623,15 +4827,15 @@ var bash_20241022 = createProviderToolFactory2({
|
|
|
4623
4827
|
// src/tool/bash_20250124.ts
|
|
4624
4828
|
import {
|
|
4625
4829
|
createProviderToolFactory as createProviderToolFactory3,
|
|
4626
|
-
lazySchema as
|
|
4627
|
-
zodSchema as
|
|
4830
|
+
lazySchema as lazySchema14,
|
|
4831
|
+
zodSchema as zodSchema14
|
|
4628
4832
|
} from "@ai-sdk/provider-utils";
|
|
4629
|
-
import { z as
|
|
4630
|
-
var bash_20250124InputSchema =
|
|
4631
|
-
() =>
|
|
4632
|
-
|
|
4633
|
-
command:
|
|
4634
|
-
restart:
|
|
4833
|
+
import { z as z15 } from "zod/v4";
|
|
4834
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
4835
|
+
() => zodSchema14(
|
|
4836
|
+
z15.object({
|
|
4837
|
+
command: z15.string(),
|
|
4838
|
+
restart: z15.boolean().optional()
|
|
4635
4839
|
})
|
|
4636
4840
|
)
|
|
4637
4841
|
);
|
|
@@ -4643,14 +4847,14 @@ var bash_20250124 = createProviderToolFactory3({
|
|
|
4643
4847
|
// src/tool/computer_20241022.ts
|
|
4644
4848
|
import {
|
|
4645
4849
|
createProviderToolFactory as createProviderToolFactory4,
|
|
4646
|
-
lazySchema as
|
|
4647
|
-
zodSchema as
|
|
4850
|
+
lazySchema as lazySchema15,
|
|
4851
|
+
zodSchema as zodSchema15
|
|
4648
4852
|
} from "@ai-sdk/provider-utils";
|
|
4649
|
-
import { z as
|
|
4650
|
-
var computer_20241022InputSchema =
|
|
4651
|
-
() =>
|
|
4652
|
-
|
|
4653
|
-
action:
|
|
4853
|
+
import { z as z16 } from "zod/v4";
|
|
4854
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
4855
|
+
() => zodSchema15(
|
|
4856
|
+
z16.object({
|
|
4857
|
+
action: z16.enum([
|
|
4654
4858
|
"key",
|
|
4655
4859
|
"type",
|
|
4656
4860
|
"mouse_move",
|
|
@@ -4662,8 +4866,8 @@ var computer_20241022InputSchema = lazySchema14(
|
|
|
4662
4866
|
"screenshot",
|
|
4663
4867
|
"cursor_position"
|
|
4664
4868
|
]),
|
|
4665
|
-
coordinate:
|
|
4666
|
-
text:
|
|
4869
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
4870
|
+
text: z16.string().optional()
|
|
4667
4871
|
})
|
|
4668
4872
|
)
|
|
4669
4873
|
);
|
|
@@ -4675,14 +4879,14 @@ var computer_20241022 = createProviderToolFactory4({
|
|
|
4675
4879
|
// src/tool/computer_20250124.ts
|
|
4676
4880
|
import {
|
|
4677
4881
|
createProviderToolFactory as createProviderToolFactory5,
|
|
4678
|
-
lazySchema as
|
|
4679
|
-
zodSchema as
|
|
4882
|
+
lazySchema as lazySchema16,
|
|
4883
|
+
zodSchema as zodSchema16
|
|
4680
4884
|
} from "@ai-sdk/provider-utils";
|
|
4681
|
-
import { z as
|
|
4682
|
-
var computer_20250124InputSchema =
|
|
4683
|
-
() =>
|
|
4684
|
-
|
|
4685
|
-
action:
|
|
4885
|
+
import { z as z17 } from "zod/v4";
|
|
4886
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
4887
|
+
() => zodSchema16(
|
|
4888
|
+
z17.object({
|
|
4889
|
+
action: z17.enum([
|
|
4686
4890
|
"key",
|
|
4687
4891
|
"hold_key",
|
|
4688
4892
|
"type",
|
|
@@ -4700,12 +4904,12 @@ var computer_20250124InputSchema = lazySchema15(
|
|
|
4700
4904
|
"wait",
|
|
4701
4905
|
"screenshot"
|
|
4702
4906
|
]),
|
|
4703
|
-
coordinate:
|
|
4704
|
-
duration:
|
|
4705
|
-
scroll_amount:
|
|
4706
|
-
scroll_direction:
|
|
4707
|
-
start_coordinate:
|
|
4708
|
-
text:
|
|
4907
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
4908
|
+
duration: z17.number().optional(),
|
|
4909
|
+
scroll_amount: z17.number().optional(),
|
|
4910
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
4911
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
4912
|
+
text: z17.string().optional()
|
|
4709
4913
|
})
|
|
4710
4914
|
)
|
|
4711
4915
|
);
|
|
@@ -4717,14 +4921,14 @@ var computer_20250124 = createProviderToolFactory5({
|
|
|
4717
4921
|
// src/tool/computer_20251124.ts
|
|
4718
4922
|
import {
|
|
4719
4923
|
createProviderToolFactory as createProviderToolFactory6,
|
|
4720
|
-
lazySchema as
|
|
4721
|
-
zodSchema as
|
|
4924
|
+
lazySchema as lazySchema17,
|
|
4925
|
+
zodSchema as zodSchema17
|
|
4722
4926
|
} from "@ai-sdk/provider-utils";
|
|
4723
|
-
import { z as
|
|
4724
|
-
var computer_20251124InputSchema =
|
|
4725
|
-
() =>
|
|
4726
|
-
|
|
4727
|
-
action:
|
|
4927
|
+
import { z as z18 } from "zod/v4";
|
|
4928
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
4929
|
+
() => zodSchema17(
|
|
4930
|
+
z18.object({
|
|
4931
|
+
action: z18.enum([
|
|
4728
4932
|
"key",
|
|
4729
4933
|
"hold_key",
|
|
4730
4934
|
"type",
|
|
@@ -4743,18 +4947,18 @@ var computer_20251124InputSchema = lazySchema16(
|
|
|
4743
4947
|
"screenshot",
|
|
4744
4948
|
"zoom"
|
|
4745
4949
|
]),
|
|
4746
|
-
coordinate:
|
|
4747
|
-
duration:
|
|
4748
|
-
region:
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4950
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
4951
|
+
duration: z18.number().optional(),
|
|
4952
|
+
region: z18.tuple([
|
|
4953
|
+
z18.number().int(),
|
|
4954
|
+
z18.number().int(),
|
|
4955
|
+
z18.number().int(),
|
|
4956
|
+
z18.number().int()
|
|
4753
4957
|
]).optional(),
|
|
4754
|
-
scroll_amount:
|
|
4755
|
-
scroll_direction:
|
|
4756
|
-
start_coordinate:
|
|
4757
|
-
text:
|
|
4958
|
+
scroll_amount: z18.number().optional(),
|
|
4959
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
4960
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
4961
|
+
text: z18.string().optional()
|
|
4758
4962
|
})
|
|
4759
4963
|
)
|
|
4760
4964
|
);
|
|
@@ -4766,43 +4970,43 @@ var computer_20251124 = createProviderToolFactory6({
|
|
|
4766
4970
|
// src/tool/memory_20250818.ts
|
|
4767
4971
|
import {
|
|
4768
4972
|
createProviderToolFactory as createProviderToolFactory7,
|
|
4769
|
-
lazySchema as
|
|
4770
|
-
zodSchema as
|
|
4973
|
+
lazySchema as lazySchema18,
|
|
4974
|
+
zodSchema as zodSchema18
|
|
4771
4975
|
} from "@ai-sdk/provider-utils";
|
|
4772
|
-
import { z as
|
|
4773
|
-
var memory_20250818InputSchema =
|
|
4774
|
-
() =>
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
command:
|
|
4778
|
-
path:
|
|
4779
|
-
view_range:
|
|
4976
|
+
import { z as z19 } from "zod/v4";
|
|
4977
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
4978
|
+
() => zodSchema18(
|
|
4979
|
+
z19.discriminatedUnion("command", [
|
|
4980
|
+
z19.object({
|
|
4981
|
+
command: z19.literal("view"),
|
|
4982
|
+
path: z19.string(),
|
|
4983
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4780
4984
|
}),
|
|
4781
|
-
|
|
4782
|
-
command:
|
|
4783
|
-
path:
|
|
4784
|
-
file_text:
|
|
4985
|
+
z19.object({
|
|
4986
|
+
command: z19.literal("create"),
|
|
4987
|
+
path: z19.string(),
|
|
4988
|
+
file_text: z19.string()
|
|
4785
4989
|
}),
|
|
4786
|
-
|
|
4787
|
-
command:
|
|
4788
|
-
path:
|
|
4789
|
-
old_str:
|
|
4790
|
-
new_str:
|
|
4990
|
+
z19.object({
|
|
4991
|
+
command: z19.literal("str_replace"),
|
|
4992
|
+
path: z19.string(),
|
|
4993
|
+
old_str: z19.string(),
|
|
4994
|
+
new_str: z19.string()
|
|
4791
4995
|
}),
|
|
4792
|
-
|
|
4793
|
-
command:
|
|
4794
|
-
path:
|
|
4795
|
-
insert_line:
|
|
4796
|
-
insert_text:
|
|
4996
|
+
z19.object({
|
|
4997
|
+
command: z19.literal("insert"),
|
|
4998
|
+
path: z19.string(),
|
|
4999
|
+
insert_line: z19.number(),
|
|
5000
|
+
insert_text: z19.string()
|
|
4797
5001
|
}),
|
|
4798
|
-
|
|
4799
|
-
command:
|
|
4800
|
-
path:
|
|
5002
|
+
z19.object({
|
|
5003
|
+
command: z19.literal("delete"),
|
|
5004
|
+
path: z19.string()
|
|
4801
5005
|
}),
|
|
4802
|
-
|
|
4803
|
-
command:
|
|
4804
|
-
old_path:
|
|
4805
|
-
new_path:
|
|
5006
|
+
z19.object({
|
|
5007
|
+
command: z19.literal("rename"),
|
|
5008
|
+
old_path: z19.string(),
|
|
5009
|
+
new_path: z19.string()
|
|
4806
5010
|
})
|
|
4807
5011
|
])
|
|
4808
5012
|
)
|
|
@@ -4815,37 +5019,11 @@ var memory_20250818 = createProviderToolFactory7({
|
|
|
4815
5019
|
// src/tool/text-editor_20241022.ts
|
|
4816
5020
|
import {
|
|
4817
5021
|
createProviderToolFactory as createProviderToolFactory8,
|
|
4818
|
-
lazySchema as lazySchema18,
|
|
4819
|
-
zodSchema as zodSchema18
|
|
4820
|
-
} from "@ai-sdk/provider-utils";
|
|
4821
|
-
import { z as z19 } from "zod/v4";
|
|
4822
|
-
var textEditor_20241022InputSchema = lazySchema18(
|
|
4823
|
-
() => zodSchema18(
|
|
4824
|
-
z19.object({
|
|
4825
|
-
command: z19.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4826
|
-
path: z19.string(),
|
|
4827
|
-
file_text: z19.string().optional(),
|
|
4828
|
-
insert_line: z19.number().int().optional(),
|
|
4829
|
-
new_str: z19.string().optional(),
|
|
4830
|
-
insert_text: z19.string().optional(),
|
|
4831
|
-
old_str: z19.string().optional(),
|
|
4832
|
-
view_range: z19.array(z19.number().int()).optional()
|
|
4833
|
-
})
|
|
4834
|
-
)
|
|
4835
|
-
);
|
|
4836
|
-
var textEditor_20241022 = createProviderToolFactory8({
|
|
4837
|
-
id: "anthropic.text_editor_20241022",
|
|
4838
|
-
inputSchema: textEditor_20241022InputSchema
|
|
4839
|
-
});
|
|
4840
|
-
|
|
4841
|
-
// src/tool/text-editor_20250124.ts
|
|
4842
|
-
import {
|
|
4843
|
-
createProviderToolFactory as createProviderToolFactory9,
|
|
4844
5022
|
lazySchema as lazySchema19,
|
|
4845
5023
|
zodSchema as zodSchema19
|
|
4846
5024
|
} from "@ai-sdk/provider-utils";
|
|
4847
5025
|
import { z as z20 } from "zod/v4";
|
|
4848
|
-
var
|
|
5026
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
4849
5027
|
() => zodSchema19(
|
|
4850
5028
|
z20.object({
|
|
4851
5029
|
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -4859,22 +5037,22 @@ var textEditor_20250124InputSchema = lazySchema19(
|
|
|
4859
5037
|
})
|
|
4860
5038
|
)
|
|
4861
5039
|
);
|
|
4862
|
-
var
|
|
4863
|
-
id: "anthropic.
|
|
4864
|
-
inputSchema:
|
|
5040
|
+
var textEditor_20241022 = createProviderToolFactory8({
|
|
5041
|
+
id: "anthropic.text_editor_20241022",
|
|
5042
|
+
inputSchema: textEditor_20241022InputSchema
|
|
4865
5043
|
});
|
|
4866
5044
|
|
|
4867
|
-
// src/tool/text-
|
|
5045
|
+
// src/tool/text-editor_20250124.ts
|
|
4868
5046
|
import {
|
|
4869
|
-
createProviderToolFactory as
|
|
5047
|
+
createProviderToolFactory as createProviderToolFactory9,
|
|
4870
5048
|
lazySchema as lazySchema20,
|
|
4871
5049
|
zodSchema as zodSchema20
|
|
4872
5050
|
} from "@ai-sdk/provider-utils";
|
|
4873
5051
|
import { z as z21 } from "zod/v4";
|
|
4874
|
-
var
|
|
5052
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
4875
5053
|
() => zodSchema20(
|
|
4876
5054
|
z21.object({
|
|
4877
|
-
command: z21.enum(["view", "create", "str_replace", "insert"]),
|
|
5055
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
4878
5056
|
path: z21.string(),
|
|
4879
5057
|
file_text: z21.string().optional(),
|
|
4880
5058
|
insert_line: z21.number().int().optional(),
|
|
@@ -4885,6 +5063,32 @@ var textEditor_20250429InputSchema = lazySchema20(
|
|
|
4885
5063
|
})
|
|
4886
5064
|
)
|
|
4887
5065
|
);
|
|
5066
|
+
var textEditor_20250124 = createProviderToolFactory9({
|
|
5067
|
+
id: "anthropic.text_editor_20250124",
|
|
5068
|
+
inputSchema: textEditor_20250124InputSchema
|
|
5069
|
+
});
|
|
5070
|
+
|
|
5071
|
+
// src/tool/text-editor_20250429.ts
|
|
5072
|
+
import {
|
|
5073
|
+
createProviderToolFactory as createProviderToolFactory10,
|
|
5074
|
+
lazySchema as lazySchema21,
|
|
5075
|
+
zodSchema as zodSchema21
|
|
5076
|
+
} from "@ai-sdk/provider-utils";
|
|
5077
|
+
import { z as z22 } from "zod/v4";
|
|
5078
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
5079
|
+
() => zodSchema21(
|
|
5080
|
+
z22.object({
|
|
5081
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5082
|
+
path: z22.string(),
|
|
5083
|
+
file_text: z22.string().optional(),
|
|
5084
|
+
insert_line: z22.number().int().optional(),
|
|
5085
|
+
new_str: z22.string().optional(),
|
|
5086
|
+
insert_text: z22.string().optional(),
|
|
5087
|
+
old_str: z22.string().optional(),
|
|
5088
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
5089
|
+
})
|
|
5090
|
+
)
|
|
5091
|
+
);
|
|
4888
5092
|
var textEditor_20250429 = createProviderToolFactory10({
|
|
4889
5093
|
id: "anthropic.text_editor_20250429",
|
|
4890
5094
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -4893,32 +5097,32 @@ var textEditor_20250429 = createProviderToolFactory10({
|
|
|
4893
5097
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4894
5098
|
import {
|
|
4895
5099
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
4896
|
-
lazySchema as
|
|
4897
|
-
zodSchema as
|
|
5100
|
+
lazySchema as lazySchema22,
|
|
5101
|
+
zodSchema as zodSchema22
|
|
4898
5102
|
} from "@ai-sdk/provider-utils";
|
|
4899
|
-
import { z as
|
|
4900
|
-
var toolSearchBm25_20251119OutputSchema =
|
|
4901
|
-
() =>
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
type:
|
|
4905
|
-
toolName:
|
|
5103
|
+
import { z as z23 } from "zod/v4";
|
|
5104
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5105
|
+
() => zodSchema22(
|
|
5106
|
+
z23.array(
|
|
5107
|
+
z23.object({
|
|
5108
|
+
type: z23.literal("tool_reference"),
|
|
5109
|
+
toolName: z23.string()
|
|
4906
5110
|
})
|
|
4907
5111
|
)
|
|
4908
5112
|
)
|
|
4909
5113
|
);
|
|
4910
|
-
var toolSearchBm25_20251119InputSchema =
|
|
4911
|
-
() =>
|
|
4912
|
-
|
|
5114
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5115
|
+
() => zodSchema22(
|
|
5116
|
+
z23.object({
|
|
4913
5117
|
/**
|
|
4914
5118
|
* A natural language query to search for tools.
|
|
4915
5119
|
* Claude will use BM25 text search to find relevant tools.
|
|
4916
5120
|
*/
|
|
4917
|
-
query:
|
|
5121
|
+
query: z23.string(),
|
|
4918
5122
|
/**
|
|
4919
5123
|
* Maximum number of tools to return. Optional.
|
|
4920
5124
|
*/
|
|
4921
|
-
limit:
|
|
5125
|
+
limit: z23.number().optional()
|
|
4922
5126
|
})
|
|
4923
5127
|
)
|
|
4924
5128
|
);
|
|
@@ -5134,6 +5338,138 @@ var anthropicTools = {
|
|
|
5134
5338
|
toolSearchBm25_20251119
|
|
5135
5339
|
};
|
|
5136
5340
|
|
|
5341
|
+
// src/skills/anthropic-skills.ts
|
|
5342
|
+
import {
|
|
5343
|
+
combineHeaders as combineHeaders3,
|
|
5344
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
5345
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
5346
|
+
getFromApi,
|
|
5347
|
+
postFormDataToApi as postFormDataToApi2,
|
|
5348
|
+
resolve as resolve2
|
|
5349
|
+
} from "@ai-sdk/provider-utils";
|
|
5350
|
+
|
|
5351
|
+
// src/skills/anthropic-skills-api.ts
|
|
5352
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
5353
|
+
import { z as z24 } from "zod/v4";
|
|
5354
|
+
var anthropicSkillResponseSchema = lazySchema23(
|
|
5355
|
+
() => zodSchema23(
|
|
5356
|
+
z24.object({
|
|
5357
|
+
id: z24.string(),
|
|
5358
|
+
display_title: z24.string().nullish(),
|
|
5359
|
+
name: z24.string().nullish(),
|
|
5360
|
+
description: z24.string().nullish(),
|
|
5361
|
+
latest_version: z24.string().nullish(),
|
|
5362
|
+
source: z24.string(),
|
|
5363
|
+
created_at: z24.string(),
|
|
5364
|
+
updated_at: z24.string()
|
|
5365
|
+
})
|
|
5366
|
+
)
|
|
5367
|
+
);
|
|
5368
|
+
var anthropicSkillVersionListResponseSchema = lazySchema23(
|
|
5369
|
+
() => zodSchema23(
|
|
5370
|
+
z24.object({
|
|
5371
|
+
data: z24.array(
|
|
5372
|
+
z24.object({
|
|
5373
|
+
version: z24.string()
|
|
5374
|
+
})
|
|
5375
|
+
)
|
|
5376
|
+
})
|
|
5377
|
+
)
|
|
5378
|
+
);
|
|
5379
|
+
var anthropicSkillVersionResponseSchema = lazySchema23(
|
|
5380
|
+
() => zodSchema23(
|
|
5381
|
+
z24.object({
|
|
5382
|
+
type: z24.string(),
|
|
5383
|
+
skill_id: z24.string(),
|
|
5384
|
+
name: z24.string().nullish(),
|
|
5385
|
+
description: z24.string().nullish()
|
|
5386
|
+
})
|
|
5387
|
+
)
|
|
5388
|
+
);
|
|
5389
|
+
|
|
5390
|
+
// src/skills/anthropic-skills.ts
|
|
5391
|
+
var AnthropicSkills = class {
|
|
5392
|
+
constructor(config) {
|
|
5393
|
+
this.config = config;
|
|
5394
|
+
this.specificationVersion = "v4";
|
|
5395
|
+
}
|
|
5396
|
+
get provider() {
|
|
5397
|
+
return this.config.provider;
|
|
5398
|
+
}
|
|
5399
|
+
async getHeaders() {
|
|
5400
|
+
return combineHeaders3(await resolve2(this.config.headers), {
|
|
5401
|
+
"anthropic-beta": "skills-2025-10-02"
|
|
5402
|
+
});
|
|
5403
|
+
}
|
|
5404
|
+
async fetchVersionMetadata({
|
|
5405
|
+
skillId,
|
|
5406
|
+
version,
|
|
5407
|
+
headers
|
|
5408
|
+
}) {
|
|
5409
|
+
const { value: versionResponse } = await getFromApi({
|
|
5410
|
+
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
5411
|
+
headers,
|
|
5412
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5413
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5414
|
+
anthropicSkillVersionResponseSchema
|
|
5415
|
+
),
|
|
5416
|
+
fetch: this.config.fetch
|
|
5417
|
+
});
|
|
5418
|
+
return {
|
|
5419
|
+
...versionResponse.name != null ? { name: versionResponse.name } : {},
|
|
5420
|
+
...versionResponse.description != null ? { description: versionResponse.description } : {}
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
async upload(params) {
|
|
5424
|
+
var _a, _b;
|
|
5425
|
+
const warnings = [];
|
|
5426
|
+
const formData = new FormData();
|
|
5427
|
+
if (params.displayTitle != null) {
|
|
5428
|
+
formData.append("display_title", params.displayTitle);
|
|
5429
|
+
}
|
|
5430
|
+
for (const file of params.files) {
|
|
5431
|
+
const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
|
|
5432
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
5433
|
+
}
|
|
5434
|
+
const headers = await this.getHeaders();
|
|
5435
|
+
const { value: response } = await postFormDataToApi2({
|
|
5436
|
+
url: `${this.config.baseURL}/skills`,
|
|
5437
|
+
headers,
|
|
5438
|
+
formData,
|
|
5439
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5440
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5441
|
+
anthropicSkillResponseSchema
|
|
5442
|
+
),
|
|
5443
|
+
fetch: this.config.fetch
|
|
5444
|
+
});
|
|
5445
|
+
const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
|
|
5446
|
+
skillId: response.id,
|
|
5447
|
+
version: response.latest_version,
|
|
5448
|
+
headers
|
|
5449
|
+
}) : {};
|
|
5450
|
+
const name = (_a = versionMetadata.name) != null ? _a : response.name;
|
|
5451
|
+
const description = (_b = versionMetadata.description) != null ? _b : response.description;
|
|
5452
|
+
return {
|
|
5453
|
+
providerReference: { anthropic: response.id },
|
|
5454
|
+
...response.display_title != null ? { displayTitle: response.display_title } : {},
|
|
5455
|
+
...name != null ? { name } : {},
|
|
5456
|
+
...description != null ? { description } : {},
|
|
5457
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
5458
|
+
providerMetadata: {
|
|
5459
|
+
anthropic: {
|
|
5460
|
+
...response.source != null ? { source: response.source } : {},
|
|
5461
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
5462
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
5463
|
+
}
|
|
5464
|
+
},
|
|
5465
|
+
warnings
|
|
5466
|
+
};
|
|
5467
|
+
}
|
|
5468
|
+
};
|
|
5469
|
+
|
|
5470
|
+
// src/version.ts
|
|
5471
|
+
var VERSION = true ? "4.0.0-beta.21" : "0.0.0-test";
|
|
5472
|
+
|
|
5137
5473
|
// src/anthropic-provider.ts
|
|
5138
5474
|
function createAnthropic(options = {}) {
|
|
5139
5475
|
var _a, _b;
|
|
@@ -5181,6 +5517,12 @@ function createAnthropic(options = {}) {
|
|
|
5181
5517
|
})
|
|
5182
5518
|
});
|
|
5183
5519
|
};
|
|
5520
|
+
const createSkills = () => new AnthropicSkills({
|
|
5521
|
+
provider: `${providerName.replace(".messages", "")}.skills`,
|
|
5522
|
+
baseURL,
|
|
5523
|
+
headers: getHeaders,
|
|
5524
|
+
fetch: options.fetch
|
|
5525
|
+
});
|
|
5184
5526
|
const provider = function(modelId) {
|
|
5185
5527
|
if (new.target) {
|
|
5186
5528
|
throw new Error(
|
|
@@ -5189,7 +5531,7 @@ function createAnthropic(options = {}) {
|
|
|
5189
5531
|
}
|
|
5190
5532
|
return createChatModel(modelId);
|
|
5191
5533
|
};
|
|
5192
|
-
provider.specificationVersion = "
|
|
5534
|
+
provider.specificationVersion = "v4";
|
|
5193
5535
|
provider.languageModel = createChatModel;
|
|
5194
5536
|
provider.chat = createChatModel;
|
|
5195
5537
|
provider.messages = createChatModel;
|
|
@@ -5200,6 +5542,13 @@ function createAnthropic(options = {}) {
|
|
|
5200
5542
|
provider.imageModel = (modelId) => {
|
|
5201
5543
|
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
5202
5544
|
};
|
|
5545
|
+
provider.files = () => new AnthropicFiles({
|
|
5546
|
+
provider: providerName,
|
|
5547
|
+
baseURL,
|
|
5548
|
+
headers: getHeaders,
|
|
5549
|
+
fetch: options.fetch
|
|
5550
|
+
});
|
|
5551
|
+
provider.skills = createSkills;
|
|
5203
5552
|
provider.tools = anthropicTools;
|
|
5204
5553
|
return provider;
|
|
5205
5554
|
}
|