@ai-sdk/anthropic 2.0.23 → 2.0.25
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 +15 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +693 -569
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +711 -539
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +687 -563
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +710 -538
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -38,67 +38,400 @@ module.exports = __toCommonJS(internal_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/anthropic-messages-language-model.ts
|
|
40
40
|
var import_provider3 = require("@ai-sdk/provider");
|
|
41
|
-
var
|
|
42
|
-
var import_v47 = require("zod/v4");
|
|
41
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
43
42
|
|
|
44
43
|
// src/anthropic-error.ts
|
|
45
44
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
46
|
-
var
|
|
47
|
-
var anthropicErrorDataSchema =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
var z = __toESM(require("zod/v4"));
|
|
46
|
+
var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
|
|
47
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
48
|
+
z.object({
|
|
49
|
+
type: z.literal("error"),
|
|
50
|
+
error: z.object({
|
|
51
|
+
type: z.string(),
|
|
52
|
+
message: z.string()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
);
|
|
54
57
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
55
58
|
errorSchema: anthropicErrorDataSchema,
|
|
56
59
|
errorToMessage: (data) => data.error.message
|
|
57
60
|
});
|
|
58
61
|
|
|
62
|
+
// src/anthropic-messages-api.ts
|
|
63
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
64
|
+
var z2 = __toESM(require("zod/v4"));
|
|
65
|
+
var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
66
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
67
|
+
z2.object({
|
|
68
|
+
type: z2.literal("message"),
|
|
69
|
+
id: z2.string().nullish(),
|
|
70
|
+
model: z2.string().nullish(),
|
|
71
|
+
content: z2.array(
|
|
72
|
+
z2.discriminatedUnion("type", [
|
|
73
|
+
z2.object({
|
|
74
|
+
type: z2.literal("text"),
|
|
75
|
+
text: z2.string(),
|
|
76
|
+
citations: z2.array(
|
|
77
|
+
z2.discriminatedUnion("type", [
|
|
78
|
+
z2.object({
|
|
79
|
+
type: z2.literal("web_search_result_location"),
|
|
80
|
+
cited_text: z2.string(),
|
|
81
|
+
url: z2.string(),
|
|
82
|
+
title: z2.string(),
|
|
83
|
+
encrypted_index: z2.string()
|
|
84
|
+
}),
|
|
85
|
+
z2.object({
|
|
86
|
+
type: z2.literal("page_location"),
|
|
87
|
+
cited_text: z2.string(),
|
|
88
|
+
document_index: z2.number(),
|
|
89
|
+
document_title: z2.string().nullable(),
|
|
90
|
+
start_page_number: z2.number(),
|
|
91
|
+
end_page_number: z2.number()
|
|
92
|
+
}),
|
|
93
|
+
z2.object({
|
|
94
|
+
type: z2.literal("char_location"),
|
|
95
|
+
cited_text: z2.string(),
|
|
96
|
+
document_index: z2.number(),
|
|
97
|
+
document_title: z2.string().nullable(),
|
|
98
|
+
start_char_index: z2.number(),
|
|
99
|
+
end_char_index: z2.number()
|
|
100
|
+
})
|
|
101
|
+
])
|
|
102
|
+
).optional()
|
|
103
|
+
}),
|
|
104
|
+
z2.object({
|
|
105
|
+
type: z2.literal("thinking"),
|
|
106
|
+
thinking: z2.string(),
|
|
107
|
+
signature: z2.string()
|
|
108
|
+
}),
|
|
109
|
+
z2.object({
|
|
110
|
+
type: z2.literal("redacted_thinking"),
|
|
111
|
+
data: z2.string()
|
|
112
|
+
}),
|
|
113
|
+
z2.object({
|
|
114
|
+
type: z2.literal("tool_use"),
|
|
115
|
+
id: z2.string(),
|
|
116
|
+
name: z2.string(),
|
|
117
|
+
input: z2.unknown()
|
|
118
|
+
}),
|
|
119
|
+
z2.object({
|
|
120
|
+
type: z2.literal("server_tool_use"),
|
|
121
|
+
id: z2.string(),
|
|
122
|
+
name: z2.string(),
|
|
123
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
124
|
+
}),
|
|
125
|
+
z2.object({
|
|
126
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
127
|
+
tool_use_id: z2.string(),
|
|
128
|
+
content: z2.union([
|
|
129
|
+
z2.object({
|
|
130
|
+
type: z2.literal("web_fetch_result"),
|
|
131
|
+
url: z2.string(),
|
|
132
|
+
retrieved_at: z2.string(),
|
|
133
|
+
content: z2.object({
|
|
134
|
+
type: z2.literal("document"),
|
|
135
|
+
title: z2.string().nullable(),
|
|
136
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
137
|
+
source: z2.object({
|
|
138
|
+
type: z2.literal("text"),
|
|
139
|
+
media_type: z2.string(),
|
|
140
|
+
data: z2.string()
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
}),
|
|
144
|
+
z2.object({
|
|
145
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
146
|
+
error_code: z2.string()
|
|
147
|
+
})
|
|
148
|
+
])
|
|
149
|
+
}),
|
|
150
|
+
z2.object({
|
|
151
|
+
type: z2.literal("web_search_tool_result"),
|
|
152
|
+
tool_use_id: z2.string(),
|
|
153
|
+
content: z2.union([
|
|
154
|
+
z2.array(
|
|
155
|
+
z2.object({
|
|
156
|
+
type: z2.literal("web_search_result"),
|
|
157
|
+
url: z2.string(),
|
|
158
|
+
title: z2.string(),
|
|
159
|
+
encrypted_content: z2.string(),
|
|
160
|
+
page_age: z2.string().nullish()
|
|
161
|
+
})
|
|
162
|
+
),
|
|
163
|
+
z2.object({
|
|
164
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
165
|
+
error_code: z2.string()
|
|
166
|
+
})
|
|
167
|
+
])
|
|
168
|
+
}),
|
|
169
|
+
z2.object({
|
|
170
|
+
type: z2.literal("code_execution_tool_result"),
|
|
171
|
+
tool_use_id: z2.string(),
|
|
172
|
+
content: z2.union([
|
|
173
|
+
z2.object({
|
|
174
|
+
type: z2.literal("code_execution_result"),
|
|
175
|
+
stdout: z2.string(),
|
|
176
|
+
stderr: z2.string(),
|
|
177
|
+
return_code: z2.number()
|
|
178
|
+
}),
|
|
179
|
+
z2.object({
|
|
180
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
181
|
+
error_code: z2.string()
|
|
182
|
+
})
|
|
183
|
+
])
|
|
184
|
+
})
|
|
185
|
+
])
|
|
186
|
+
),
|
|
187
|
+
stop_reason: z2.string().nullish(),
|
|
188
|
+
stop_sequence: z2.string().nullish(),
|
|
189
|
+
usage: z2.looseObject({
|
|
190
|
+
input_tokens: z2.number(),
|
|
191
|
+
output_tokens: z2.number(),
|
|
192
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
193
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
199
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
200
|
+
z2.discriminatedUnion("type", [
|
|
201
|
+
z2.object({
|
|
202
|
+
type: z2.literal("message_start"),
|
|
203
|
+
message: z2.object({
|
|
204
|
+
id: z2.string().nullish(),
|
|
205
|
+
model: z2.string().nullish(),
|
|
206
|
+
usage: z2.looseObject({
|
|
207
|
+
input_tokens: z2.number(),
|
|
208
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
209
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
}),
|
|
213
|
+
z2.object({
|
|
214
|
+
type: z2.literal("content_block_start"),
|
|
215
|
+
index: z2.number(),
|
|
216
|
+
content_block: z2.discriminatedUnion("type", [
|
|
217
|
+
z2.object({
|
|
218
|
+
type: z2.literal("text"),
|
|
219
|
+
text: z2.string()
|
|
220
|
+
}),
|
|
221
|
+
z2.object({
|
|
222
|
+
type: z2.literal("thinking"),
|
|
223
|
+
thinking: z2.string()
|
|
224
|
+
}),
|
|
225
|
+
z2.object({
|
|
226
|
+
type: z2.literal("tool_use"),
|
|
227
|
+
id: z2.string(),
|
|
228
|
+
name: z2.string()
|
|
229
|
+
}),
|
|
230
|
+
z2.object({
|
|
231
|
+
type: z2.literal("redacted_thinking"),
|
|
232
|
+
data: z2.string()
|
|
233
|
+
}),
|
|
234
|
+
z2.object({
|
|
235
|
+
type: z2.literal("server_tool_use"),
|
|
236
|
+
id: z2.string(),
|
|
237
|
+
name: z2.string(),
|
|
238
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
239
|
+
}),
|
|
240
|
+
z2.object({
|
|
241
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
242
|
+
tool_use_id: z2.string(),
|
|
243
|
+
content: z2.union([
|
|
244
|
+
z2.object({
|
|
245
|
+
type: z2.literal("web_fetch_result"),
|
|
246
|
+
url: z2.string(),
|
|
247
|
+
retrieved_at: z2.string(),
|
|
248
|
+
content: z2.object({
|
|
249
|
+
type: z2.literal("document"),
|
|
250
|
+
title: z2.string().nullable(),
|
|
251
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
252
|
+
source: z2.object({
|
|
253
|
+
type: z2.literal("text"),
|
|
254
|
+
media_type: z2.string(),
|
|
255
|
+
data: z2.string()
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
}),
|
|
259
|
+
z2.object({
|
|
260
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
261
|
+
error_code: z2.string()
|
|
262
|
+
})
|
|
263
|
+
])
|
|
264
|
+
}),
|
|
265
|
+
z2.object({
|
|
266
|
+
type: z2.literal("web_search_tool_result"),
|
|
267
|
+
tool_use_id: z2.string(),
|
|
268
|
+
content: z2.union([
|
|
269
|
+
z2.array(
|
|
270
|
+
z2.object({
|
|
271
|
+
type: z2.literal("web_search_result"),
|
|
272
|
+
url: z2.string(),
|
|
273
|
+
title: z2.string(),
|
|
274
|
+
encrypted_content: z2.string(),
|
|
275
|
+
page_age: z2.string().nullish()
|
|
276
|
+
})
|
|
277
|
+
),
|
|
278
|
+
z2.object({
|
|
279
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
280
|
+
error_code: z2.string()
|
|
281
|
+
})
|
|
282
|
+
])
|
|
283
|
+
}),
|
|
284
|
+
z2.object({
|
|
285
|
+
type: z2.literal("code_execution_tool_result"),
|
|
286
|
+
tool_use_id: z2.string(),
|
|
287
|
+
content: z2.union([
|
|
288
|
+
z2.object({
|
|
289
|
+
type: z2.literal("code_execution_result"),
|
|
290
|
+
stdout: z2.string(),
|
|
291
|
+
stderr: z2.string(),
|
|
292
|
+
return_code: z2.number()
|
|
293
|
+
}),
|
|
294
|
+
z2.object({
|
|
295
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
296
|
+
error_code: z2.string()
|
|
297
|
+
})
|
|
298
|
+
])
|
|
299
|
+
})
|
|
300
|
+
])
|
|
301
|
+
}),
|
|
302
|
+
z2.object({
|
|
303
|
+
type: z2.literal("content_block_delta"),
|
|
304
|
+
index: z2.number(),
|
|
305
|
+
delta: z2.discriminatedUnion("type", [
|
|
306
|
+
z2.object({
|
|
307
|
+
type: z2.literal("input_json_delta"),
|
|
308
|
+
partial_json: z2.string()
|
|
309
|
+
}),
|
|
310
|
+
z2.object({
|
|
311
|
+
type: z2.literal("text_delta"),
|
|
312
|
+
text: z2.string()
|
|
313
|
+
}),
|
|
314
|
+
z2.object({
|
|
315
|
+
type: z2.literal("thinking_delta"),
|
|
316
|
+
thinking: z2.string()
|
|
317
|
+
}),
|
|
318
|
+
z2.object({
|
|
319
|
+
type: z2.literal("signature_delta"),
|
|
320
|
+
signature: z2.string()
|
|
321
|
+
}),
|
|
322
|
+
z2.object({
|
|
323
|
+
type: z2.literal("citations_delta"),
|
|
324
|
+
citation: z2.discriminatedUnion("type", [
|
|
325
|
+
z2.object({
|
|
326
|
+
type: z2.literal("web_search_result_location"),
|
|
327
|
+
cited_text: z2.string(),
|
|
328
|
+
url: z2.string(),
|
|
329
|
+
title: z2.string(),
|
|
330
|
+
encrypted_index: z2.string()
|
|
331
|
+
}),
|
|
332
|
+
z2.object({
|
|
333
|
+
type: z2.literal("page_location"),
|
|
334
|
+
cited_text: z2.string(),
|
|
335
|
+
document_index: z2.number(),
|
|
336
|
+
document_title: z2.string().nullable(),
|
|
337
|
+
start_page_number: z2.number(),
|
|
338
|
+
end_page_number: z2.number()
|
|
339
|
+
}),
|
|
340
|
+
z2.object({
|
|
341
|
+
type: z2.literal("char_location"),
|
|
342
|
+
cited_text: z2.string(),
|
|
343
|
+
document_index: z2.number(),
|
|
344
|
+
document_title: z2.string().nullable(),
|
|
345
|
+
start_char_index: z2.number(),
|
|
346
|
+
end_char_index: z2.number()
|
|
347
|
+
})
|
|
348
|
+
])
|
|
349
|
+
})
|
|
350
|
+
])
|
|
351
|
+
}),
|
|
352
|
+
z2.object({
|
|
353
|
+
type: z2.literal("content_block_stop"),
|
|
354
|
+
index: z2.number()
|
|
355
|
+
}),
|
|
356
|
+
z2.object({
|
|
357
|
+
type: z2.literal("error"),
|
|
358
|
+
error: z2.object({
|
|
359
|
+
type: z2.string(),
|
|
360
|
+
message: z2.string()
|
|
361
|
+
})
|
|
362
|
+
}),
|
|
363
|
+
z2.object({
|
|
364
|
+
type: z2.literal("message_delta"),
|
|
365
|
+
delta: z2.object({
|
|
366
|
+
stop_reason: z2.string().nullish(),
|
|
367
|
+
stop_sequence: z2.string().nullish()
|
|
368
|
+
}),
|
|
369
|
+
usage: z2.looseObject({
|
|
370
|
+
output_tokens: z2.number(),
|
|
371
|
+
cache_creation_input_tokens: z2.number().nullish()
|
|
372
|
+
})
|
|
373
|
+
}),
|
|
374
|
+
z2.object({
|
|
375
|
+
type: z2.literal("message_stop")
|
|
376
|
+
}),
|
|
377
|
+
z2.object({
|
|
378
|
+
type: z2.literal("ping")
|
|
379
|
+
})
|
|
380
|
+
])
|
|
381
|
+
)
|
|
382
|
+
);
|
|
383
|
+
var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
|
|
384
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
385
|
+
z2.object({
|
|
386
|
+
signature: z2.string().optional(),
|
|
387
|
+
redactedData: z2.string().optional()
|
|
388
|
+
})
|
|
389
|
+
)
|
|
390
|
+
);
|
|
391
|
+
|
|
59
392
|
// src/anthropic-messages-options.ts
|
|
60
|
-
var
|
|
61
|
-
var anthropicFilePartProviderOptions =
|
|
393
|
+
var z3 = __toESM(require("zod/v4"));
|
|
394
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
62
395
|
/**
|
|
63
396
|
* Citation configuration for this document.
|
|
64
397
|
* When enabled, this document will generate citations in the response.
|
|
65
398
|
*/
|
|
66
|
-
citations:
|
|
399
|
+
citations: z3.object({
|
|
67
400
|
/**
|
|
68
401
|
* Enable citations for this document
|
|
69
402
|
*/
|
|
70
|
-
enabled:
|
|
403
|
+
enabled: z3.boolean()
|
|
71
404
|
}).optional(),
|
|
72
405
|
/**
|
|
73
406
|
* Custom title for the document.
|
|
74
407
|
* If not provided, the filename will be used.
|
|
75
408
|
*/
|
|
76
|
-
title:
|
|
409
|
+
title: z3.string().optional(),
|
|
77
410
|
/**
|
|
78
411
|
* Context about the document that will be passed to the model
|
|
79
412
|
* but not used towards cited content.
|
|
80
413
|
* Useful for storing document metadata as text or stringified JSON.
|
|
81
414
|
*/
|
|
82
|
-
context:
|
|
415
|
+
context: z3.string().optional()
|
|
83
416
|
});
|
|
84
|
-
var anthropicProviderOptions =
|
|
85
|
-
sendReasoning:
|
|
86
|
-
thinking:
|
|
87
|
-
type:
|
|
88
|
-
budgetTokens:
|
|
417
|
+
var anthropicProviderOptions = z3.object({
|
|
418
|
+
sendReasoning: z3.boolean().optional(),
|
|
419
|
+
thinking: z3.object({
|
|
420
|
+
type: z3.union([z3.literal("enabled"), z3.literal("disabled")]),
|
|
421
|
+
budgetTokens: z3.number().optional()
|
|
89
422
|
}).optional(),
|
|
90
423
|
/**
|
|
91
424
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
92
425
|
* When set to true, Claude will use at most one tool per response.
|
|
93
426
|
*/
|
|
94
|
-
disableParallelToolUse:
|
|
427
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
95
428
|
/**
|
|
96
429
|
* Cache control settings for this message.
|
|
97
430
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
98
431
|
*/
|
|
99
|
-
cacheControl:
|
|
100
|
-
type:
|
|
101
|
-
ttl:
|
|
432
|
+
cacheControl: z3.object({
|
|
433
|
+
type: z3.literal("ephemeral"),
|
|
434
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
102
435
|
}).optional()
|
|
103
436
|
});
|
|
104
437
|
|
|
@@ -114,58 +447,81 @@ function getCacheControl(providerMetadata) {
|
|
|
114
447
|
}
|
|
115
448
|
|
|
116
449
|
// src/tool/text-editor_20250728.ts
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
450
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
451
|
+
var z4 = __toESM(require("zod/v4"));
|
|
452
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
453
|
+
var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
|
|
454
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
455
|
+
z4.object({
|
|
456
|
+
maxCharacters: z4.number().optional()
|
|
457
|
+
})
|
|
458
|
+
)
|
|
459
|
+
);
|
|
460
|
+
var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
|
|
461
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
462
|
+
z4.object({
|
|
463
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
464
|
+
path: z4.string(),
|
|
465
|
+
file_text: z4.string().optional(),
|
|
466
|
+
insert_line: z4.number().int().optional(),
|
|
467
|
+
new_str: z4.string().optional(),
|
|
468
|
+
old_str: z4.string().optional(),
|
|
469
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
470
|
+
})
|
|
471
|
+
)
|
|
472
|
+
);
|
|
473
|
+
var factory = (0, import_provider_utils3.createProviderDefinedToolFactory)({
|
|
123
474
|
id: "anthropic.text_editor_20250728",
|
|
124
475
|
name: "str_replace_based_edit_tool",
|
|
125
|
-
inputSchema:
|
|
126
|
-
command: import_v43.z.enum(["view", "create", "str_replace", "insert"]),
|
|
127
|
-
path: import_v43.z.string(),
|
|
128
|
-
file_text: import_v43.z.string().optional(),
|
|
129
|
-
insert_line: import_v43.z.number().int().optional(),
|
|
130
|
-
new_str: import_v43.z.string().optional(),
|
|
131
|
-
old_str: import_v43.z.string().optional(),
|
|
132
|
-
view_range: import_v43.z.array(import_v43.z.number().int()).optional()
|
|
133
|
-
})
|
|
476
|
+
inputSchema: textEditor_20250728InputSchema
|
|
134
477
|
});
|
|
135
478
|
var textEditor_20250728 = (args = {}) => {
|
|
136
479
|
return factory(args);
|
|
137
480
|
};
|
|
138
481
|
|
|
139
482
|
// src/tool/web-search_20250305.ts
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var webSearch_20250305ArgsSchema =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
483
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
484
|
+
var z5 = __toESM(require("zod/v4"));
|
|
485
|
+
var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
|
|
486
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
487
|
+
z5.object({
|
|
488
|
+
maxUses: z5.number().optional(),
|
|
489
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
490
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
491
|
+
userLocation: z5.object({
|
|
492
|
+
type: z5.literal("approximate"),
|
|
493
|
+
city: z5.string().optional(),
|
|
494
|
+
region: z5.string().optional(),
|
|
495
|
+
country: z5.string().optional(),
|
|
496
|
+
timezone: z5.string().optional()
|
|
497
|
+
}).optional()
|
|
498
|
+
})
|
|
499
|
+
)
|
|
500
|
+
);
|
|
501
|
+
var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
|
|
502
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
503
|
+
z5.array(
|
|
504
|
+
z5.object({
|
|
505
|
+
url: z5.string(),
|
|
506
|
+
title: z5.string(),
|
|
507
|
+
pageAge: z5.string().nullable(),
|
|
508
|
+
encryptedContent: z5.string(),
|
|
509
|
+
type: z5.literal("web_search_result")
|
|
510
|
+
})
|
|
511
|
+
)
|
|
512
|
+
)
|
|
513
|
+
);
|
|
514
|
+
var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
|
|
515
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
516
|
+
z5.object({
|
|
517
|
+
query: z5.string()
|
|
518
|
+
})
|
|
519
|
+
)
|
|
162
520
|
);
|
|
163
|
-
var factory2 = (0,
|
|
521
|
+
var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
164
522
|
id: "anthropic.web_search_20250305",
|
|
165
523
|
name: "web_search",
|
|
166
|
-
inputSchema:
|
|
167
|
-
query: import_v44.z.string()
|
|
168
|
-
}),
|
|
524
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
169
525
|
outputSchema: webSearch_20250305OutputSchema
|
|
170
526
|
});
|
|
171
527
|
var webSearch_20250305 = (args = {}) => {
|
|
@@ -173,43 +529,56 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
173
529
|
};
|
|
174
530
|
|
|
175
531
|
// src/tool/web-fetch-20250910.ts
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
var webFetch_20250910ArgsSchema =
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
532
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
533
|
+
var z6 = __toESM(require("zod/v4"));
|
|
534
|
+
var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
535
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
536
|
+
z6.object({
|
|
537
|
+
maxUses: z6.number().optional(),
|
|
538
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
539
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
540
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
541
|
+
maxContentTokens: z6.number().optional()
|
|
542
|
+
})
|
|
543
|
+
)
|
|
544
|
+
);
|
|
545
|
+
var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
546
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
547
|
+
z6.object({
|
|
548
|
+
type: z6.literal("web_fetch_result"),
|
|
549
|
+
url: z6.string(),
|
|
550
|
+
content: z6.object({
|
|
551
|
+
type: z6.literal("document"),
|
|
552
|
+
title: z6.string(),
|
|
553
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
554
|
+
source: z6.union([
|
|
555
|
+
z6.object({
|
|
556
|
+
type: z6.literal("base64"),
|
|
557
|
+
mediaType: z6.literal("application/pdf"),
|
|
558
|
+
data: z6.string()
|
|
559
|
+
}),
|
|
560
|
+
z6.object({
|
|
561
|
+
type: z6.literal("text"),
|
|
562
|
+
mediaType: z6.literal("text/plain"),
|
|
563
|
+
data: z6.string()
|
|
564
|
+
})
|
|
565
|
+
])
|
|
197
566
|
}),
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
})
|
|
207
|
-
|
|
567
|
+
retrievedAt: z6.string().nullable()
|
|
568
|
+
})
|
|
569
|
+
)
|
|
570
|
+
);
|
|
571
|
+
var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
|
|
572
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
573
|
+
z6.object({
|
|
574
|
+
url: z6.string()
|
|
575
|
+
})
|
|
576
|
+
)
|
|
577
|
+
);
|
|
578
|
+
var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
208
579
|
id: "anthropic.web_fetch_20250910",
|
|
209
580
|
name: "web_fetch",
|
|
210
|
-
inputSchema:
|
|
211
|
-
url: import_v45.z.string()
|
|
212
|
-
}),
|
|
581
|
+
inputSchema: webFetch_20250910InputSchema,
|
|
213
582
|
outputSchema: webFetch_20250910OutputSchema
|
|
214
583
|
});
|
|
215
584
|
var webFetch_20250910 = (args = {}) => {
|
|
@@ -217,7 +586,8 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
217
586
|
};
|
|
218
587
|
|
|
219
588
|
// src/anthropic-prepare-tools.ts
|
|
220
|
-
|
|
589
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
590
|
+
async function prepareTools({
|
|
221
591
|
tools,
|
|
222
592
|
toolChoice,
|
|
223
593
|
disableParallelToolUse
|
|
@@ -298,7 +668,10 @@ function prepareTools({
|
|
|
298
668
|
break;
|
|
299
669
|
}
|
|
300
670
|
case "anthropic.text_editor_20250728": {
|
|
301
|
-
const args =
|
|
671
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
672
|
+
value: tool.args,
|
|
673
|
+
schema: textEditor_20250728ArgsSchema
|
|
674
|
+
});
|
|
302
675
|
anthropicTools2.push({
|
|
303
676
|
name: "str_replace_based_edit_tool",
|
|
304
677
|
type: "text_editor_20250728",
|
|
@@ -324,7 +697,10 @@ function prepareTools({
|
|
|
324
697
|
}
|
|
325
698
|
case "anthropic.web_fetch_20250910": {
|
|
326
699
|
betas.add("web-fetch-2025-09-10");
|
|
327
|
-
const args =
|
|
700
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
701
|
+
value: tool.args,
|
|
702
|
+
schema: webFetch_20250910ArgsSchema
|
|
703
|
+
});
|
|
328
704
|
anthropicTools2.push({
|
|
329
705
|
type: "web_fetch_20250910",
|
|
330
706
|
name: "web_fetch",
|
|
@@ -337,7 +713,10 @@ function prepareTools({
|
|
|
337
713
|
break;
|
|
338
714
|
}
|
|
339
715
|
case "anthropic.web_search_20250305": {
|
|
340
|
-
const args =
|
|
716
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
717
|
+
value: tool.args,
|
|
718
|
+
schema: webSearch_20250305ArgsSchema
|
|
719
|
+
});
|
|
341
720
|
anthropicTools2.push({
|
|
342
721
|
type: "web_search_20250305",
|
|
343
722
|
name: "web_search",
|
|
@@ -415,23 +794,32 @@ function prepareTools({
|
|
|
415
794
|
|
|
416
795
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
417
796
|
var import_provider2 = require("@ai-sdk/provider");
|
|
418
|
-
var
|
|
797
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
419
798
|
|
|
420
799
|
// src/tool/code-execution_20250522.ts
|
|
421
|
-
var
|
|
422
|
-
var
|
|
423
|
-
var codeExecution_20250522OutputSchema =
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
800
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
801
|
+
var z7 = __toESM(require("zod/v4"));
|
|
802
|
+
var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
803
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
804
|
+
z7.object({
|
|
805
|
+
type: z7.literal("code_execution_result"),
|
|
806
|
+
stdout: z7.string(),
|
|
807
|
+
stderr: z7.string(),
|
|
808
|
+
return_code: z7.number()
|
|
809
|
+
})
|
|
810
|
+
)
|
|
811
|
+
);
|
|
812
|
+
var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
813
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
814
|
+
z7.object({
|
|
815
|
+
code: z7.string()
|
|
816
|
+
})
|
|
817
|
+
)
|
|
818
|
+
);
|
|
819
|
+
var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
430
820
|
id: "anthropic.code_execution_20250522",
|
|
431
821
|
name: "code_execution",
|
|
432
|
-
inputSchema:
|
|
433
|
-
code: import_v46.z.string()
|
|
434
|
-
}),
|
|
822
|
+
inputSchema: codeExecution_20250522InputSchema,
|
|
435
823
|
outputSchema: codeExecution_20250522OutputSchema
|
|
436
824
|
});
|
|
437
825
|
var codeExecution_20250522 = (args = {}) => {
|
|
@@ -467,7 +855,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
467
855
|
const messages = [];
|
|
468
856
|
async function shouldEnableCitations(providerMetadata) {
|
|
469
857
|
var _a2, _b2;
|
|
470
|
-
const anthropicOptions = await (0,
|
|
858
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
471
859
|
provider: "anthropic",
|
|
472
860
|
providerOptions: providerMetadata,
|
|
473
861
|
schema: anthropicFilePartProviderOptions
|
|
@@ -475,7 +863,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
475
863
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
476
864
|
}
|
|
477
865
|
async function getDocumentMetadata(providerMetadata) {
|
|
478
|
-
const anthropicOptions = await (0,
|
|
866
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
479
867
|
provider: "anthropic",
|
|
480
868
|
providerOptions: providerMetadata,
|
|
481
869
|
schema: anthropicFilePartProviderOptions
|
|
@@ -532,7 +920,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
532
920
|
} : {
|
|
533
921
|
type: "base64",
|
|
534
922
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
535
|
-
data: (0,
|
|
923
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
536
924
|
},
|
|
537
925
|
cache_control: cacheControl
|
|
538
926
|
});
|
|
@@ -552,7 +940,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
552
940
|
} : {
|
|
553
941
|
type: "base64",
|
|
554
942
|
media_type: "application/pdf",
|
|
555
|
-
data: (0,
|
|
943
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
556
944
|
},
|
|
557
945
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
558
946
|
...metadata.context && { context: metadata.context },
|
|
@@ -687,7 +1075,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
687
1075
|
}
|
|
688
1076
|
case "reasoning": {
|
|
689
1077
|
if (sendReasoning) {
|
|
690
|
-
const reasoningMetadata = await (0,
|
|
1078
|
+
const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
|
|
691
1079
|
provider: "anthropic",
|
|
692
1080
|
providerOptions: part.providerOptions,
|
|
693
1081
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -763,7 +1151,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
763
1151
|
});
|
|
764
1152
|
break;
|
|
765
1153
|
}
|
|
766
|
-
const codeExecutionOutput =
|
|
1154
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1155
|
+
value: output.value,
|
|
1156
|
+
schema: codeExecution_20250522OutputSchema
|
|
1157
|
+
});
|
|
767
1158
|
anthropicContent.push({
|
|
768
1159
|
type: "code_execution_tool_result",
|
|
769
1160
|
tool_use_id: part.toolCallId,
|
|
@@ -786,9 +1177,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
786
1177
|
});
|
|
787
1178
|
break;
|
|
788
1179
|
}
|
|
789
|
-
const webFetchOutput =
|
|
790
|
-
output.value
|
|
791
|
-
|
|
1180
|
+
const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1181
|
+
value: output.value,
|
|
1182
|
+
schema: webFetch_20250910OutputSchema
|
|
1183
|
+
});
|
|
792
1184
|
anthropicContent.push({
|
|
793
1185
|
type: "web_fetch_tool_result",
|
|
794
1186
|
tool_use_id: part.toolCallId,
|
|
@@ -820,9 +1212,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
820
1212
|
});
|
|
821
1213
|
break;
|
|
822
1214
|
}
|
|
823
|
-
const webSearchOutput =
|
|
824
|
-
output.value
|
|
825
|
-
|
|
1215
|
+
const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1216
|
+
value: output.value,
|
|
1217
|
+
schema: webSearch_20250305OutputSchema
|
|
1218
|
+
});
|
|
826
1219
|
anthropicContent.push({
|
|
827
1220
|
type: "web_search_tool_result",
|
|
828
1221
|
tool_use_id: part.toolCallId,
|
|
@@ -929,67 +1322,15 @@ function mapAnthropicStopReason({
|
|
|
929
1322
|
}
|
|
930
1323
|
|
|
931
1324
|
// src/anthropic-messages-language-model.ts
|
|
932
|
-
var citationSchemas = {
|
|
933
|
-
webSearchResult: import_v47.z.object({
|
|
934
|
-
type: import_v47.z.literal("web_search_result_location"),
|
|
935
|
-
cited_text: import_v47.z.string(),
|
|
936
|
-
url: import_v47.z.string(),
|
|
937
|
-
title: import_v47.z.string(),
|
|
938
|
-
encrypted_index: import_v47.z.string()
|
|
939
|
-
}),
|
|
940
|
-
pageLocation: import_v47.z.object({
|
|
941
|
-
type: import_v47.z.literal("page_location"),
|
|
942
|
-
cited_text: import_v47.z.string(),
|
|
943
|
-
document_index: import_v47.z.number(),
|
|
944
|
-
document_title: import_v47.z.string().nullable(),
|
|
945
|
-
start_page_number: import_v47.z.number(),
|
|
946
|
-
end_page_number: import_v47.z.number()
|
|
947
|
-
}),
|
|
948
|
-
charLocation: import_v47.z.object({
|
|
949
|
-
type: import_v47.z.literal("char_location"),
|
|
950
|
-
cited_text: import_v47.z.string(),
|
|
951
|
-
document_index: import_v47.z.number(),
|
|
952
|
-
document_title: import_v47.z.string().nullable(),
|
|
953
|
-
start_char_index: import_v47.z.number(),
|
|
954
|
-
end_char_index: import_v47.z.number()
|
|
955
|
-
})
|
|
956
|
-
};
|
|
957
|
-
var citationSchema = import_v47.z.discriminatedUnion("type", [
|
|
958
|
-
citationSchemas.webSearchResult,
|
|
959
|
-
citationSchemas.pageLocation,
|
|
960
|
-
citationSchemas.charLocation
|
|
961
|
-
]);
|
|
962
|
-
var documentCitationSchema = import_v47.z.discriminatedUnion("type", [
|
|
963
|
-
citationSchemas.pageLocation,
|
|
964
|
-
citationSchemas.charLocation
|
|
965
|
-
]);
|
|
966
|
-
function processCitation(citation, citationDocuments, generateId2, onSource) {
|
|
967
|
-
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
968
|
-
const source = createCitationSource(
|
|
969
|
-
citation,
|
|
970
|
-
citationDocuments,
|
|
971
|
-
generateId2
|
|
972
|
-
);
|
|
973
|
-
if (source) {
|
|
974
|
-
onSource(source);
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
1325
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
979
1326
|
var _a;
|
|
1327
|
+
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
980
1330
|
const documentInfo = citationDocuments[citation.document_index];
|
|
981
1331
|
if (!documentInfo) {
|
|
982
|
-
return
|
|
1332
|
+
return;
|
|
983
1333
|
}
|
|
984
|
-
const providerMetadata = citation.type === "page_location" ? {
|
|
985
|
-
citedText: citation.cited_text,
|
|
986
|
-
startPageNumber: citation.start_page_number,
|
|
987
|
-
endPageNumber: citation.end_page_number
|
|
988
|
-
} : {
|
|
989
|
-
citedText: citation.cited_text,
|
|
990
|
-
startCharIndex: citation.start_char_index,
|
|
991
|
-
endCharIndex: citation.end_char_index
|
|
992
|
-
};
|
|
993
1334
|
return {
|
|
994
1335
|
type: "source",
|
|
995
1336
|
sourceType: "document",
|
|
@@ -998,7 +1339,15 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
998
1339
|
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
999
1340
|
filename: documentInfo.filename,
|
|
1000
1341
|
providerMetadata: {
|
|
1001
|
-
anthropic:
|
|
1342
|
+
anthropic: citation.type === "page_location" ? {
|
|
1343
|
+
citedText: citation.cited_text,
|
|
1344
|
+
startPageNumber: citation.start_page_number,
|
|
1345
|
+
endPageNumber: citation.end_page_number
|
|
1346
|
+
} : {
|
|
1347
|
+
citedText: citation.cited_text,
|
|
1348
|
+
startCharIndex: citation.start_char_index,
|
|
1349
|
+
endCharIndex: citation.end_char_index
|
|
1350
|
+
}
|
|
1002
1351
|
}
|
|
1003
1352
|
};
|
|
1004
1353
|
}
|
|
@@ -1008,7 +1357,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1008
1357
|
var _a;
|
|
1009
1358
|
this.modelId = modelId;
|
|
1010
1359
|
this.config = config;
|
|
1011
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1360
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
|
|
1012
1361
|
}
|
|
1013
1362
|
supportsUrl(url) {
|
|
1014
1363
|
return url.protocol === "https:";
|
|
@@ -1077,7 +1426,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1077
1426
|
description: "Respond with a JSON object.",
|
|
1078
1427
|
inputSchema: responseFormat.schema
|
|
1079
1428
|
} : void 0;
|
|
1080
|
-
const anthropicOptions = await (0,
|
|
1429
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1081
1430
|
provider: "anthropic",
|
|
1082
1431
|
providerOptions,
|
|
1083
1432
|
schema: anthropicProviderOptions
|
|
@@ -1143,7 +1492,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1143
1492
|
toolChoice: anthropicToolChoice,
|
|
1144
1493
|
toolWarnings,
|
|
1145
1494
|
betas: toolsBetas
|
|
1146
|
-
} = prepareTools(
|
|
1495
|
+
} = await prepareTools(
|
|
1147
1496
|
jsonResponseTool != null ? {
|
|
1148
1497
|
tools: [jsonResponseTool],
|
|
1149
1498
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
@@ -1169,8 +1518,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1169
1518
|
betas,
|
|
1170
1519
|
headers
|
|
1171
1520
|
}) {
|
|
1172
|
-
return (0,
|
|
1173
|
-
await (0,
|
|
1521
|
+
return (0, import_provider_utils10.combineHeaders)(
|
|
1522
|
+
await (0, import_provider_utils10.resolve)(this.config.headers),
|
|
1174
1523
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1175
1524
|
headers
|
|
1176
1525
|
);
|
|
@@ -1214,12 +1563,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1214
1563
|
responseHeaders,
|
|
1215
1564
|
value: response,
|
|
1216
1565
|
rawValue: rawResponse
|
|
1217
|
-
} = await (0,
|
|
1566
|
+
} = await (0, import_provider_utils10.postJsonToApi)({
|
|
1218
1567
|
url: this.buildRequestUrl(false),
|
|
1219
1568
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1220
1569
|
body: this.transformRequestBody(args),
|
|
1221
1570
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1222
|
-
successfulResponseHandler: (0,
|
|
1571
|
+
successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
|
|
1223
1572
|
anthropicMessagesResponseSchema
|
|
1224
1573
|
),
|
|
1225
1574
|
abortSignal: options.abortSignal,
|
|
@@ -1233,12 +1582,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1233
1582
|
content.push({ type: "text", text: part.text });
|
|
1234
1583
|
if (part.citations) {
|
|
1235
1584
|
for (const citation of part.citations) {
|
|
1236
|
-
|
|
1585
|
+
const source = createCitationSource(
|
|
1237
1586
|
citation,
|
|
1238
1587
|
citationDocuments,
|
|
1239
|
-
this.generateId
|
|
1240
|
-
(source) => content.push(source)
|
|
1588
|
+
this.generateId
|
|
1241
1589
|
);
|
|
1590
|
+
if (source) {
|
|
1591
|
+
content.push(source);
|
|
1592
|
+
}
|
|
1242
1593
|
}
|
|
1243
1594
|
}
|
|
1244
1595
|
}
|
|
@@ -1444,12 +1795,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1444
1795
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1445
1796
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1446
1797
|
const body = { ...args, stream: true };
|
|
1447
|
-
const { responseHeaders, value: response } = await (0,
|
|
1798
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
|
|
1448
1799
|
url: this.buildRequestUrl(true),
|
|
1449
1800
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1450
1801
|
body: this.transformRequestBody(body),
|
|
1451
1802
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1452
|
-
successfulResponseHandler: (0,
|
|
1803
|
+
successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
|
|
1453
1804
|
anthropicMessagesChunkSchema
|
|
1454
1805
|
),
|
|
1455
1806
|
abortSignal: options.abortSignal,
|
|
@@ -1775,12 +2126,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1775
2126
|
}
|
|
1776
2127
|
case "citations_delta": {
|
|
1777
2128
|
const citation = value.delta.citation;
|
|
1778
|
-
|
|
2129
|
+
const source = createCitationSource(
|
|
1779
2130
|
citation,
|
|
1780
2131
|
citationDocuments,
|
|
1781
|
-
generateId2
|
|
1782
|
-
(source) => controller.enqueue(source)
|
|
2132
|
+
generateId2
|
|
1783
2133
|
);
|
|
2134
|
+
if (source) {
|
|
2135
|
+
controller.enqueue(source);
|
|
2136
|
+
}
|
|
1784
2137
|
return;
|
|
1785
2138
|
}
|
|
1786
2139
|
default: {
|
|
@@ -1851,402 +2204,173 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1851
2204
|
};
|
|
1852
2205
|
}
|
|
1853
2206
|
};
|
|
1854
|
-
var anthropicMessagesResponseSchema = import_v47.z.object({
|
|
1855
|
-
type: import_v47.z.literal("message"),
|
|
1856
|
-
id: import_v47.z.string().nullish(),
|
|
1857
|
-
model: import_v47.z.string().nullish(),
|
|
1858
|
-
content: import_v47.z.array(
|
|
1859
|
-
import_v47.z.discriminatedUnion("type", [
|
|
1860
|
-
import_v47.z.object({
|
|
1861
|
-
type: import_v47.z.literal("text"),
|
|
1862
|
-
text: import_v47.z.string(),
|
|
1863
|
-
citations: import_v47.z.array(citationSchema).optional()
|
|
1864
|
-
}),
|
|
1865
|
-
import_v47.z.object({
|
|
1866
|
-
type: import_v47.z.literal("thinking"),
|
|
1867
|
-
thinking: import_v47.z.string(),
|
|
1868
|
-
signature: import_v47.z.string()
|
|
1869
|
-
}),
|
|
1870
|
-
import_v47.z.object({
|
|
1871
|
-
type: import_v47.z.literal("redacted_thinking"),
|
|
1872
|
-
data: import_v47.z.string()
|
|
1873
|
-
}),
|
|
1874
|
-
import_v47.z.object({
|
|
1875
|
-
type: import_v47.z.literal("tool_use"),
|
|
1876
|
-
id: import_v47.z.string(),
|
|
1877
|
-
name: import_v47.z.string(),
|
|
1878
|
-
input: import_v47.z.unknown()
|
|
1879
|
-
}),
|
|
1880
|
-
import_v47.z.object({
|
|
1881
|
-
type: import_v47.z.literal("server_tool_use"),
|
|
1882
|
-
id: import_v47.z.string(),
|
|
1883
|
-
name: import_v47.z.string(),
|
|
1884
|
-
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1885
|
-
}),
|
|
1886
|
-
import_v47.z.object({
|
|
1887
|
-
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
1888
|
-
tool_use_id: import_v47.z.string(),
|
|
1889
|
-
content: import_v47.z.union([
|
|
1890
|
-
import_v47.z.object({
|
|
1891
|
-
type: import_v47.z.literal("web_fetch_result"),
|
|
1892
|
-
url: import_v47.z.string(),
|
|
1893
|
-
retrieved_at: import_v47.z.string(),
|
|
1894
|
-
content: import_v47.z.object({
|
|
1895
|
-
type: import_v47.z.literal("document"),
|
|
1896
|
-
title: import_v47.z.string().nullable(),
|
|
1897
|
-
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
1898
|
-
source: import_v47.z.object({
|
|
1899
|
-
type: import_v47.z.literal("text"),
|
|
1900
|
-
media_type: import_v47.z.string(),
|
|
1901
|
-
data: import_v47.z.string()
|
|
1902
|
-
})
|
|
1903
|
-
})
|
|
1904
|
-
}),
|
|
1905
|
-
import_v47.z.object({
|
|
1906
|
-
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
1907
|
-
error_code: import_v47.z.string()
|
|
1908
|
-
})
|
|
1909
|
-
])
|
|
1910
|
-
}),
|
|
1911
|
-
import_v47.z.object({
|
|
1912
|
-
type: import_v47.z.literal("web_search_tool_result"),
|
|
1913
|
-
tool_use_id: import_v47.z.string(),
|
|
1914
|
-
content: import_v47.z.union([
|
|
1915
|
-
import_v47.z.array(
|
|
1916
|
-
import_v47.z.object({
|
|
1917
|
-
type: import_v47.z.literal("web_search_result"),
|
|
1918
|
-
url: import_v47.z.string(),
|
|
1919
|
-
title: import_v47.z.string(),
|
|
1920
|
-
encrypted_content: import_v47.z.string(),
|
|
1921
|
-
page_age: import_v47.z.string().nullish()
|
|
1922
|
-
})
|
|
1923
|
-
),
|
|
1924
|
-
import_v47.z.object({
|
|
1925
|
-
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
1926
|
-
error_code: import_v47.z.string()
|
|
1927
|
-
})
|
|
1928
|
-
])
|
|
1929
|
-
}),
|
|
1930
|
-
import_v47.z.object({
|
|
1931
|
-
type: import_v47.z.literal("code_execution_tool_result"),
|
|
1932
|
-
tool_use_id: import_v47.z.string(),
|
|
1933
|
-
content: import_v47.z.union([
|
|
1934
|
-
import_v47.z.object({
|
|
1935
|
-
type: import_v47.z.literal("code_execution_result"),
|
|
1936
|
-
stdout: import_v47.z.string(),
|
|
1937
|
-
stderr: import_v47.z.string(),
|
|
1938
|
-
return_code: import_v47.z.number()
|
|
1939
|
-
}),
|
|
1940
|
-
import_v47.z.object({
|
|
1941
|
-
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
1942
|
-
error_code: import_v47.z.string()
|
|
1943
|
-
})
|
|
1944
|
-
])
|
|
1945
|
-
})
|
|
1946
|
-
])
|
|
1947
|
-
),
|
|
1948
|
-
stop_reason: import_v47.z.string().nullish(),
|
|
1949
|
-
stop_sequence: import_v47.z.string().nullish(),
|
|
1950
|
-
usage: import_v47.z.looseObject({
|
|
1951
|
-
input_tokens: import_v47.z.number(),
|
|
1952
|
-
output_tokens: import_v47.z.number(),
|
|
1953
|
-
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1954
|
-
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1955
|
-
})
|
|
1956
|
-
});
|
|
1957
|
-
var anthropicMessagesChunkSchema = import_v47.z.discriminatedUnion("type", [
|
|
1958
|
-
import_v47.z.object({
|
|
1959
|
-
type: import_v47.z.literal("message_start"),
|
|
1960
|
-
message: import_v47.z.object({
|
|
1961
|
-
id: import_v47.z.string().nullish(),
|
|
1962
|
-
model: import_v47.z.string().nullish(),
|
|
1963
|
-
usage: import_v47.z.looseObject({
|
|
1964
|
-
input_tokens: import_v47.z.number(),
|
|
1965
|
-
cache_creation_input_tokens: import_v47.z.number().nullish(),
|
|
1966
|
-
cache_read_input_tokens: import_v47.z.number().nullish()
|
|
1967
|
-
})
|
|
1968
|
-
})
|
|
1969
|
-
}),
|
|
1970
|
-
import_v47.z.object({
|
|
1971
|
-
type: import_v47.z.literal("content_block_start"),
|
|
1972
|
-
index: import_v47.z.number(),
|
|
1973
|
-
content_block: import_v47.z.discriminatedUnion("type", [
|
|
1974
|
-
import_v47.z.object({
|
|
1975
|
-
type: import_v47.z.literal("text"),
|
|
1976
|
-
text: import_v47.z.string()
|
|
1977
|
-
}),
|
|
1978
|
-
import_v47.z.object({
|
|
1979
|
-
type: import_v47.z.literal("thinking"),
|
|
1980
|
-
thinking: import_v47.z.string()
|
|
1981
|
-
}),
|
|
1982
|
-
import_v47.z.object({
|
|
1983
|
-
type: import_v47.z.literal("tool_use"),
|
|
1984
|
-
id: import_v47.z.string(),
|
|
1985
|
-
name: import_v47.z.string()
|
|
1986
|
-
}),
|
|
1987
|
-
import_v47.z.object({
|
|
1988
|
-
type: import_v47.z.literal("redacted_thinking"),
|
|
1989
|
-
data: import_v47.z.string()
|
|
1990
|
-
}),
|
|
1991
|
-
import_v47.z.object({
|
|
1992
|
-
type: import_v47.z.literal("server_tool_use"),
|
|
1993
|
-
id: import_v47.z.string(),
|
|
1994
|
-
name: import_v47.z.string(),
|
|
1995
|
-
input: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).nullish()
|
|
1996
|
-
}),
|
|
1997
|
-
import_v47.z.object({
|
|
1998
|
-
type: import_v47.z.literal("web_fetch_tool_result"),
|
|
1999
|
-
tool_use_id: import_v47.z.string(),
|
|
2000
|
-
content: import_v47.z.union([
|
|
2001
|
-
import_v47.z.object({
|
|
2002
|
-
type: import_v47.z.literal("web_fetch_result"),
|
|
2003
|
-
url: import_v47.z.string(),
|
|
2004
|
-
retrieved_at: import_v47.z.string(),
|
|
2005
|
-
content: import_v47.z.object({
|
|
2006
|
-
type: import_v47.z.literal("document"),
|
|
2007
|
-
title: import_v47.z.string().nullable(),
|
|
2008
|
-
citations: import_v47.z.object({ enabled: import_v47.z.boolean() }).optional(),
|
|
2009
|
-
source: import_v47.z.object({
|
|
2010
|
-
type: import_v47.z.literal("text"),
|
|
2011
|
-
media_type: import_v47.z.string(),
|
|
2012
|
-
data: import_v47.z.string()
|
|
2013
|
-
})
|
|
2014
|
-
})
|
|
2015
|
-
}),
|
|
2016
|
-
import_v47.z.object({
|
|
2017
|
-
type: import_v47.z.literal("web_fetch_tool_result_error"),
|
|
2018
|
-
error_code: import_v47.z.string()
|
|
2019
|
-
})
|
|
2020
|
-
])
|
|
2021
|
-
}),
|
|
2022
|
-
import_v47.z.object({
|
|
2023
|
-
type: import_v47.z.literal("web_search_tool_result"),
|
|
2024
|
-
tool_use_id: import_v47.z.string(),
|
|
2025
|
-
content: import_v47.z.union([
|
|
2026
|
-
import_v47.z.array(
|
|
2027
|
-
import_v47.z.object({
|
|
2028
|
-
type: import_v47.z.literal("web_search_result"),
|
|
2029
|
-
url: import_v47.z.string(),
|
|
2030
|
-
title: import_v47.z.string(),
|
|
2031
|
-
encrypted_content: import_v47.z.string(),
|
|
2032
|
-
page_age: import_v47.z.string().nullish()
|
|
2033
|
-
})
|
|
2034
|
-
),
|
|
2035
|
-
import_v47.z.object({
|
|
2036
|
-
type: import_v47.z.literal("web_search_tool_result_error"),
|
|
2037
|
-
error_code: import_v47.z.string()
|
|
2038
|
-
})
|
|
2039
|
-
])
|
|
2040
|
-
}),
|
|
2041
|
-
import_v47.z.object({
|
|
2042
|
-
type: import_v47.z.literal("code_execution_tool_result"),
|
|
2043
|
-
tool_use_id: import_v47.z.string(),
|
|
2044
|
-
content: import_v47.z.union([
|
|
2045
|
-
import_v47.z.object({
|
|
2046
|
-
type: import_v47.z.literal("code_execution_result"),
|
|
2047
|
-
stdout: import_v47.z.string(),
|
|
2048
|
-
stderr: import_v47.z.string(),
|
|
2049
|
-
return_code: import_v47.z.number()
|
|
2050
|
-
}),
|
|
2051
|
-
import_v47.z.object({
|
|
2052
|
-
type: import_v47.z.literal("code_execution_tool_result_error"),
|
|
2053
|
-
error_code: import_v47.z.string()
|
|
2054
|
-
})
|
|
2055
|
-
])
|
|
2056
|
-
})
|
|
2057
|
-
])
|
|
2058
|
-
}),
|
|
2059
|
-
import_v47.z.object({
|
|
2060
|
-
type: import_v47.z.literal("content_block_delta"),
|
|
2061
|
-
index: import_v47.z.number(),
|
|
2062
|
-
delta: import_v47.z.discriminatedUnion("type", [
|
|
2063
|
-
import_v47.z.object({
|
|
2064
|
-
type: import_v47.z.literal("input_json_delta"),
|
|
2065
|
-
partial_json: import_v47.z.string()
|
|
2066
|
-
}),
|
|
2067
|
-
import_v47.z.object({
|
|
2068
|
-
type: import_v47.z.literal("text_delta"),
|
|
2069
|
-
text: import_v47.z.string()
|
|
2070
|
-
}),
|
|
2071
|
-
import_v47.z.object({
|
|
2072
|
-
type: import_v47.z.literal("thinking_delta"),
|
|
2073
|
-
thinking: import_v47.z.string()
|
|
2074
|
-
}),
|
|
2075
|
-
import_v47.z.object({
|
|
2076
|
-
type: import_v47.z.literal("signature_delta"),
|
|
2077
|
-
signature: import_v47.z.string()
|
|
2078
|
-
}),
|
|
2079
|
-
import_v47.z.object({
|
|
2080
|
-
type: import_v47.z.literal("citations_delta"),
|
|
2081
|
-
citation: citationSchema
|
|
2082
|
-
})
|
|
2083
|
-
])
|
|
2084
|
-
}),
|
|
2085
|
-
import_v47.z.object({
|
|
2086
|
-
type: import_v47.z.literal("content_block_stop"),
|
|
2087
|
-
index: import_v47.z.number()
|
|
2088
|
-
}),
|
|
2089
|
-
import_v47.z.object({
|
|
2090
|
-
type: import_v47.z.literal("error"),
|
|
2091
|
-
error: import_v47.z.object({
|
|
2092
|
-
type: import_v47.z.string(),
|
|
2093
|
-
message: import_v47.z.string()
|
|
2094
|
-
})
|
|
2095
|
-
}),
|
|
2096
|
-
import_v47.z.object({
|
|
2097
|
-
type: import_v47.z.literal("message_delta"),
|
|
2098
|
-
delta: import_v47.z.object({
|
|
2099
|
-
stop_reason: import_v47.z.string().nullish(),
|
|
2100
|
-
stop_sequence: import_v47.z.string().nullish()
|
|
2101
|
-
}),
|
|
2102
|
-
usage: import_v47.z.looseObject({
|
|
2103
|
-
output_tokens: import_v47.z.number(),
|
|
2104
|
-
cache_creation_input_tokens: import_v47.z.number().nullish()
|
|
2105
|
-
})
|
|
2106
|
-
}),
|
|
2107
|
-
import_v47.z.object({
|
|
2108
|
-
type: import_v47.z.literal("message_stop")
|
|
2109
|
-
}),
|
|
2110
|
-
import_v47.z.object({
|
|
2111
|
-
type: import_v47.z.literal("ping")
|
|
2112
|
-
})
|
|
2113
|
-
]);
|
|
2114
|
-
var anthropicReasoningMetadataSchema = import_v47.z.object({
|
|
2115
|
-
signature: import_v47.z.string().optional(),
|
|
2116
|
-
redactedData: import_v47.z.string().optional()
|
|
2117
|
-
});
|
|
2118
2207
|
|
|
2119
2208
|
// src/tool/bash_20241022.ts
|
|
2120
|
-
var
|
|
2121
|
-
var
|
|
2122
|
-
var
|
|
2209
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2210
|
+
var z8 = __toESM(require("zod/v4"));
|
|
2211
|
+
var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2212
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2213
|
+
z8.object({
|
|
2214
|
+
command: z8.string(),
|
|
2215
|
+
restart: z8.boolean().optional()
|
|
2216
|
+
})
|
|
2217
|
+
)
|
|
2218
|
+
);
|
|
2219
|
+
var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
2123
2220
|
id: "anthropic.bash_20241022",
|
|
2124
2221
|
name: "bash",
|
|
2125
|
-
inputSchema:
|
|
2126
|
-
command: import_v48.default.string(),
|
|
2127
|
-
restart: import_v48.default.boolean().optional()
|
|
2128
|
-
})
|
|
2222
|
+
inputSchema: bash_20241022InputSchema
|
|
2129
2223
|
});
|
|
2130
2224
|
|
|
2131
2225
|
// src/tool/bash_20250124.ts
|
|
2132
|
-
var
|
|
2133
|
-
var
|
|
2134
|
-
var
|
|
2226
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2227
|
+
var z9 = __toESM(require("zod/v4"));
|
|
2228
|
+
var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2229
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2230
|
+
z9.object({
|
|
2231
|
+
command: z9.string(),
|
|
2232
|
+
restart: z9.boolean().optional()
|
|
2233
|
+
})
|
|
2234
|
+
)
|
|
2235
|
+
);
|
|
2236
|
+
var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2135
2237
|
id: "anthropic.bash_20250124",
|
|
2136
2238
|
name: "bash",
|
|
2137
|
-
inputSchema:
|
|
2138
|
-
command: import_v49.default.string(),
|
|
2139
|
-
restart: import_v49.default.boolean().optional()
|
|
2140
|
-
})
|
|
2239
|
+
inputSchema: bash_20250124InputSchema
|
|
2141
2240
|
});
|
|
2142
2241
|
|
|
2143
2242
|
// src/tool/computer_20241022.ts
|
|
2144
|
-
var
|
|
2145
|
-
var
|
|
2146
|
-
var
|
|
2243
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2244
|
+
var z10 = __toESM(require("zod/v4"));
|
|
2245
|
+
var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2246
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2247
|
+
z10.object({
|
|
2248
|
+
action: z10.enum([
|
|
2249
|
+
"key",
|
|
2250
|
+
"type",
|
|
2251
|
+
"mouse_move",
|
|
2252
|
+
"left_click",
|
|
2253
|
+
"left_click_drag",
|
|
2254
|
+
"right_click",
|
|
2255
|
+
"middle_click",
|
|
2256
|
+
"double_click",
|
|
2257
|
+
"screenshot",
|
|
2258
|
+
"cursor_position"
|
|
2259
|
+
]),
|
|
2260
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2261
|
+
text: z10.string().optional()
|
|
2262
|
+
})
|
|
2263
|
+
)
|
|
2264
|
+
);
|
|
2265
|
+
var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2147
2266
|
id: "anthropic.computer_20241022",
|
|
2148
2267
|
name: "computer",
|
|
2149
|
-
inputSchema:
|
|
2150
|
-
action: import_v410.z.enum([
|
|
2151
|
-
"key",
|
|
2152
|
-
"type",
|
|
2153
|
-
"mouse_move",
|
|
2154
|
-
"left_click",
|
|
2155
|
-
"left_click_drag",
|
|
2156
|
-
"right_click",
|
|
2157
|
-
"middle_click",
|
|
2158
|
-
"double_click",
|
|
2159
|
-
"screenshot",
|
|
2160
|
-
"cursor_position"
|
|
2161
|
-
]),
|
|
2162
|
-
coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
|
|
2163
|
-
text: import_v410.z.string().optional()
|
|
2164
|
-
})
|
|
2268
|
+
inputSchema: computer_20241022InputSchema
|
|
2165
2269
|
});
|
|
2166
2270
|
|
|
2167
2271
|
// src/tool/computer_20250124.ts
|
|
2168
|
-
var
|
|
2169
|
-
var
|
|
2170
|
-
var
|
|
2272
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2273
|
+
var z11 = __toESM(require("zod/v4"));
|
|
2274
|
+
var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2275
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2276
|
+
z11.object({
|
|
2277
|
+
action: z11.enum([
|
|
2278
|
+
"key",
|
|
2279
|
+
"hold_key",
|
|
2280
|
+
"type",
|
|
2281
|
+
"cursor_position",
|
|
2282
|
+
"mouse_move",
|
|
2283
|
+
"left_mouse_down",
|
|
2284
|
+
"left_mouse_up",
|
|
2285
|
+
"left_click",
|
|
2286
|
+
"left_click_drag",
|
|
2287
|
+
"right_click",
|
|
2288
|
+
"middle_click",
|
|
2289
|
+
"double_click",
|
|
2290
|
+
"triple_click",
|
|
2291
|
+
"scroll",
|
|
2292
|
+
"wait",
|
|
2293
|
+
"screenshot"
|
|
2294
|
+
]),
|
|
2295
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2296
|
+
duration: z11.number().optional(),
|
|
2297
|
+
scroll_amount: z11.number().optional(),
|
|
2298
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2299
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2300
|
+
text: z11.string().optional()
|
|
2301
|
+
})
|
|
2302
|
+
)
|
|
2303
|
+
);
|
|
2304
|
+
var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2171
2305
|
id: "anthropic.computer_20250124",
|
|
2172
2306
|
name: "computer",
|
|
2173
|
-
inputSchema:
|
|
2174
|
-
action: import_v411.z.enum([
|
|
2175
|
-
"key",
|
|
2176
|
-
"hold_key",
|
|
2177
|
-
"type",
|
|
2178
|
-
"cursor_position",
|
|
2179
|
-
"mouse_move",
|
|
2180
|
-
"left_mouse_down",
|
|
2181
|
-
"left_mouse_up",
|
|
2182
|
-
"left_click",
|
|
2183
|
-
"left_click_drag",
|
|
2184
|
-
"right_click",
|
|
2185
|
-
"middle_click",
|
|
2186
|
-
"double_click",
|
|
2187
|
-
"triple_click",
|
|
2188
|
-
"scroll",
|
|
2189
|
-
"wait",
|
|
2190
|
-
"screenshot"
|
|
2191
|
-
]),
|
|
2192
|
-
coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2193
|
-
duration: import_v411.z.number().optional(),
|
|
2194
|
-
scroll_amount: import_v411.z.number().optional(),
|
|
2195
|
-
scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2196
|
-
start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2197
|
-
text: import_v411.z.string().optional()
|
|
2198
|
-
})
|
|
2307
|
+
inputSchema: computer_20250124InputSchema
|
|
2199
2308
|
});
|
|
2200
2309
|
|
|
2201
2310
|
// src/tool/text-editor_20241022.ts
|
|
2202
|
-
var
|
|
2203
|
-
var
|
|
2204
|
-
var
|
|
2311
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2312
|
+
var z12 = __toESM(require("zod/v4"));
|
|
2313
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2314
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2315
|
+
z12.object({
|
|
2316
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2317
|
+
path: z12.string(),
|
|
2318
|
+
file_text: z12.string().optional(),
|
|
2319
|
+
insert_line: z12.number().int().optional(),
|
|
2320
|
+
new_str: z12.string().optional(),
|
|
2321
|
+
old_str: z12.string().optional(),
|
|
2322
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
2323
|
+
})
|
|
2324
|
+
)
|
|
2325
|
+
);
|
|
2326
|
+
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2205
2327
|
id: "anthropic.text_editor_20241022",
|
|
2206
2328
|
name: "str_replace_editor",
|
|
2207
|
-
inputSchema:
|
|
2208
|
-
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2209
|
-
path: import_v412.z.string(),
|
|
2210
|
-
file_text: import_v412.z.string().optional(),
|
|
2211
|
-
insert_line: import_v412.z.number().int().optional(),
|
|
2212
|
-
new_str: import_v412.z.string().optional(),
|
|
2213
|
-
old_str: import_v412.z.string().optional(),
|
|
2214
|
-
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
2215
|
-
})
|
|
2329
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2216
2330
|
});
|
|
2217
2331
|
|
|
2218
2332
|
// src/tool/text-editor_20250124.ts
|
|
2219
|
-
var
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2333
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2334
|
+
var z13 = __toESM(require("zod/v4"));
|
|
2335
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2336
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
2337
|
+
z13.object({
|
|
2338
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2339
|
+
path: z13.string(),
|
|
2340
|
+
file_text: z13.string().optional(),
|
|
2341
|
+
insert_line: z13.number().int().optional(),
|
|
2342
|
+
new_str: z13.string().optional(),
|
|
2343
|
+
old_str: z13.string().optional(),
|
|
2344
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
2345
|
+
})
|
|
2346
|
+
)
|
|
2347
|
+
);
|
|
2348
|
+
var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2222
2349
|
id: "anthropic.text_editor_20250124",
|
|
2223
2350
|
name: "str_replace_editor",
|
|
2224
|
-
inputSchema:
|
|
2225
|
-
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2226
|
-
path: import_v413.z.string(),
|
|
2227
|
-
file_text: import_v413.z.string().optional(),
|
|
2228
|
-
insert_line: import_v413.z.number().int().optional(),
|
|
2229
|
-
new_str: import_v413.z.string().optional(),
|
|
2230
|
-
old_str: import_v413.z.string().optional(),
|
|
2231
|
-
view_range: import_v413.z.array(import_v413.z.number().int()).optional()
|
|
2232
|
-
})
|
|
2351
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2233
2352
|
});
|
|
2234
2353
|
|
|
2235
2354
|
// src/tool/text-editor_20250429.ts
|
|
2236
|
-
var
|
|
2237
|
-
var
|
|
2238
|
-
var
|
|
2355
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2356
|
+
var z14 = __toESM(require("zod/v4"));
|
|
2357
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2358
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
2359
|
+
z14.object({
|
|
2360
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2361
|
+
path: z14.string(),
|
|
2362
|
+
file_text: z14.string().optional(),
|
|
2363
|
+
insert_line: z14.number().int().optional(),
|
|
2364
|
+
new_str: z14.string().optional(),
|
|
2365
|
+
old_str: z14.string().optional(),
|
|
2366
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2367
|
+
})
|
|
2368
|
+
)
|
|
2369
|
+
);
|
|
2370
|
+
var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2239
2371
|
id: "anthropic.text_editor_20250429",
|
|
2240
2372
|
name: "str_replace_based_edit_tool",
|
|
2241
|
-
inputSchema:
|
|
2242
|
-
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2243
|
-
path: import_v414.z.string(),
|
|
2244
|
-
file_text: import_v414.z.string().optional(),
|
|
2245
|
-
insert_line: import_v414.z.number().int().optional(),
|
|
2246
|
-
new_str: import_v414.z.string().optional(),
|
|
2247
|
-
old_str: import_v414.z.string().optional(),
|
|
2248
|
-
view_range: import_v414.z.array(import_v414.z.number().int()).optional()
|
|
2249
|
-
})
|
|
2373
|
+
inputSchema: textEditor_20250429InputSchema
|
|
2250
2374
|
});
|
|
2251
2375
|
|
|
2252
2376
|
// src/anthropic-tools.ts
|