@ai-sdk/anthropic 3.0.0-beta.15 → 3.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +687 -563
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +705 -533
- 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 +681 -557
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +704 -532
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,74 +38,407 @@ module.exports = __toCommonJS(src_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/anthropic-provider.ts
|
|
40
40
|
var import_provider4 = require("@ai-sdk/provider");
|
|
41
|
-
var
|
|
41
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
42
42
|
|
|
43
43
|
// src/version.ts
|
|
44
|
-
var VERSION = true ? "3.0.0-beta.
|
|
44
|
+
var VERSION = true ? "3.0.0-beta.16" : "0.0.0-test";
|
|
45
45
|
|
|
46
46
|
// src/anthropic-messages-language-model.ts
|
|
47
47
|
var import_provider3 = require("@ai-sdk/provider");
|
|
48
|
-
var
|
|
49
|
-
var z7 = __toESM(require("zod/v4"));
|
|
48
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
50
49
|
|
|
51
50
|
// src/anthropic-error.ts
|
|
52
51
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
53
52
|
var z = __toESM(require("zod/v4"));
|
|
54
|
-
var anthropicErrorDataSchema =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
|
|
54
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
55
|
+
z.object({
|
|
56
|
+
type: z.literal("error"),
|
|
57
|
+
error: z.object({
|
|
58
|
+
type: z.string(),
|
|
59
|
+
message: z.string()
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
)
|
|
63
|
+
);
|
|
61
64
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
62
65
|
errorSchema: anthropicErrorDataSchema,
|
|
63
66
|
errorToMessage: (data) => data.error.message
|
|
64
67
|
});
|
|
65
68
|
|
|
66
|
-
// src/anthropic-messages-
|
|
69
|
+
// src/anthropic-messages-api.ts
|
|
70
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
67
71
|
var z2 = __toESM(require("zod/v4"));
|
|
68
|
-
var
|
|
72
|
+
var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
73
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
74
|
+
z2.object({
|
|
75
|
+
type: z2.literal("message"),
|
|
76
|
+
id: z2.string().nullish(),
|
|
77
|
+
model: z2.string().nullish(),
|
|
78
|
+
content: z2.array(
|
|
79
|
+
z2.discriminatedUnion("type", [
|
|
80
|
+
z2.object({
|
|
81
|
+
type: z2.literal("text"),
|
|
82
|
+
text: z2.string(),
|
|
83
|
+
citations: z2.array(
|
|
84
|
+
z2.discriminatedUnion("type", [
|
|
85
|
+
z2.object({
|
|
86
|
+
type: z2.literal("web_search_result_location"),
|
|
87
|
+
cited_text: z2.string(),
|
|
88
|
+
url: z2.string(),
|
|
89
|
+
title: z2.string(),
|
|
90
|
+
encrypted_index: z2.string()
|
|
91
|
+
}),
|
|
92
|
+
z2.object({
|
|
93
|
+
type: z2.literal("page_location"),
|
|
94
|
+
cited_text: z2.string(),
|
|
95
|
+
document_index: z2.number(),
|
|
96
|
+
document_title: z2.string().nullable(),
|
|
97
|
+
start_page_number: z2.number(),
|
|
98
|
+
end_page_number: z2.number()
|
|
99
|
+
}),
|
|
100
|
+
z2.object({
|
|
101
|
+
type: z2.literal("char_location"),
|
|
102
|
+
cited_text: z2.string(),
|
|
103
|
+
document_index: z2.number(),
|
|
104
|
+
document_title: z2.string().nullable(),
|
|
105
|
+
start_char_index: z2.number(),
|
|
106
|
+
end_char_index: z2.number()
|
|
107
|
+
})
|
|
108
|
+
])
|
|
109
|
+
).optional()
|
|
110
|
+
}),
|
|
111
|
+
z2.object({
|
|
112
|
+
type: z2.literal("thinking"),
|
|
113
|
+
thinking: z2.string(),
|
|
114
|
+
signature: z2.string()
|
|
115
|
+
}),
|
|
116
|
+
z2.object({
|
|
117
|
+
type: z2.literal("redacted_thinking"),
|
|
118
|
+
data: z2.string()
|
|
119
|
+
}),
|
|
120
|
+
z2.object({
|
|
121
|
+
type: z2.literal("tool_use"),
|
|
122
|
+
id: z2.string(),
|
|
123
|
+
name: z2.string(),
|
|
124
|
+
input: z2.unknown()
|
|
125
|
+
}),
|
|
126
|
+
z2.object({
|
|
127
|
+
type: z2.literal("server_tool_use"),
|
|
128
|
+
id: z2.string(),
|
|
129
|
+
name: z2.string(),
|
|
130
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
131
|
+
}),
|
|
132
|
+
z2.object({
|
|
133
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
134
|
+
tool_use_id: z2.string(),
|
|
135
|
+
content: z2.union([
|
|
136
|
+
z2.object({
|
|
137
|
+
type: z2.literal("web_fetch_result"),
|
|
138
|
+
url: z2.string(),
|
|
139
|
+
retrieved_at: z2.string(),
|
|
140
|
+
content: z2.object({
|
|
141
|
+
type: z2.literal("document"),
|
|
142
|
+
title: z2.string().nullable(),
|
|
143
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
144
|
+
source: z2.object({
|
|
145
|
+
type: z2.literal("text"),
|
|
146
|
+
media_type: z2.string(),
|
|
147
|
+
data: z2.string()
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
z2.object({
|
|
152
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
153
|
+
error_code: z2.string()
|
|
154
|
+
})
|
|
155
|
+
])
|
|
156
|
+
}),
|
|
157
|
+
z2.object({
|
|
158
|
+
type: z2.literal("web_search_tool_result"),
|
|
159
|
+
tool_use_id: z2.string(),
|
|
160
|
+
content: z2.union([
|
|
161
|
+
z2.array(
|
|
162
|
+
z2.object({
|
|
163
|
+
type: z2.literal("web_search_result"),
|
|
164
|
+
url: z2.string(),
|
|
165
|
+
title: z2.string(),
|
|
166
|
+
encrypted_content: z2.string(),
|
|
167
|
+
page_age: z2.string().nullish()
|
|
168
|
+
})
|
|
169
|
+
),
|
|
170
|
+
z2.object({
|
|
171
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
172
|
+
error_code: z2.string()
|
|
173
|
+
})
|
|
174
|
+
])
|
|
175
|
+
}),
|
|
176
|
+
z2.object({
|
|
177
|
+
type: z2.literal("code_execution_tool_result"),
|
|
178
|
+
tool_use_id: z2.string(),
|
|
179
|
+
content: z2.union([
|
|
180
|
+
z2.object({
|
|
181
|
+
type: z2.literal("code_execution_result"),
|
|
182
|
+
stdout: z2.string(),
|
|
183
|
+
stderr: z2.string(),
|
|
184
|
+
return_code: z2.number()
|
|
185
|
+
}),
|
|
186
|
+
z2.object({
|
|
187
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
188
|
+
error_code: z2.string()
|
|
189
|
+
})
|
|
190
|
+
])
|
|
191
|
+
})
|
|
192
|
+
])
|
|
193
|
+
),
|
|
194
|
+
stop_reason: z2.string().nullish(),
|
|
195
|
+
stop_sequence: z2.string().nullish(),
|
|
196
|
+
usage: z2.looseObject({
|
|
197
|
+
input_tokens: z2.number(),
|
|
198
|
+
output_tokens: z2.number(),
|
|
199
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
200
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
206
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
207
|
+
z2.discriminatedUnion("type", [
|
|
208
|
+
z2.object({
|
|
209
|
+
type: z2.literal("message_start"),
|
|
210
|
+
message: z2.object({
|
|
211
|
+
id: z2.string().nullish(),
|
|
212
|
+
model: z2.string().nullish(),
|
|
213
|
+
usage: z2.looseObject({
|
|
214
|
+
input_tokens: z2.number(),
|
|
215
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
216
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
z2.object({
|
|
221
|
+
type: z2.literal("content_block_start"),
|
|
222
|
+
index: z2.number(),
|
|
223
|
+
content_block: z2.discriminatedUnion("type", [
|
|
224
|
+
z2.object({
|
|
225
|
+
type: z2.literal("text"),
|
|
226
|
+
text: z2.string()
|
|
227
|
+
}),
|
|
228
|
+
z2.object({
|
|
229
|
+
type: z2.literal("thinking"),
|
|
230
|
+
thinking: z2.string()
|
|
231
|
+
}),
|
|
232
|
+
z2.object({
|
|
233
|
+
type: z2.literal("tool_use"),
|
|
234
|
+
id: z2.string(),
|
|
235
|
+
name: z2.string()
|
|
236
|
+
}),
|
|
237
|
+
z2.object({
|
|
238
|
+
type: z2.literal("redacted_thinking"),
|
|
239
|
+
data: z2.string()
|
|
240
|
+
}),
|
|
241
|
+
z2.object({
|
|
242
|
+
type: z2.literal("server_tool_use"),
|
|
243
|
+
id: z2.string(),
|
|
244
|
+
name: z2.string(),
|
|
245
|
+
input: z2.record(z2.string(), z2.unknown()).nullish()
|
|
246
|
+
}),
|
|
247
|
+
z2.object({
|
|
248
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
249
|
+
tool_use_id: z2.string(),
|
|
250
|
+
content: z2.union([
|
|
251
|
+
z2.object({
|
|
252
|
+
type: z2.literal("web_fetch_result"),
|
|
253
|
+
url: z2.string(),
|
|
254
|
+
retrieved_at: z2.string(),
|
|
255
|
+
content: z2.object({
|
|
256
|
+
type: z2.literal("document"),
|
|
257
|
+
title: z2.string().nullable(),
|
|
258
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
259
|
+
source: z2.object({
|
|
260
|
+
type: z2.literal("text"),
|
|
261
|
+
media_type: z2.string(),
|
|
262
|
+
data: z2.string()
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
}),
|
|
266
|
+
z2.object({
|
|
267
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
268
|
+
error_code: z2.string()
|
|
269
|
+
})
|
|
270
|
+
])
|
|
271
|
+
}),
|
|
272
|
+
z2.object({
|
|
273
|
+
type: z2.literal("web_search_tool_result"),
|
|
274
|
+
tool_use_id: z2.string(),
|
|
275
|
+
content: z2.union([
|
|
276
|
+
z2.array(
|
|
277
|
+
z2.object({
|
|
278
|
+
type: z2.literal("web_search_result"),
|
|
279
|
+
url: z2.string(),
|
|
280
|
+
title: z2.string(),
|
|
281
|
+
encrypted_content: z2.string(),
|
|
282
|
+
page_age: z2.string().nullish()
|
|
283
|
+
})
|
|
284
|
+
),
|
|
285
|
+
z2.object({
|
|
286
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
287
|
+
error_code: z2.string()
|
|
288
|
+
})
|
|
289
|
+
])
|
|
290
|
+
}),
|
|
291
|
+
z2.object({
|
|
292
|
+
type: z2.literal("code_execution_tool_result"),
|
|
293
|
+
tool_use_id: z2.string(),
|
|
294
|
+
content: z2.union([
|
|
295
|
+
z2.object({
|
|
296
|
+
type: z2.literal("code_execution_result"),
|
|
297
|
+
stdout: z2.string(),
|
|
298
|
+
stderr: z2.string(),
|
|
299
|
+
return_code: z2.number()
|
|
300
|
+
}),
|
|
301
|
+
z2.object({
|
|
302
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
303
|
+
error_code: z2.string()
|
|
304
|
+
})
|
|
305
|
+
])
|
|
306
|
+
})
|
|
307
|
+
])
|
|
308
|
+
}),
|
|
309
|
+
z2.object({
|
|
310
|
+
type: z2.literal("content_block_delta"),
|
|
311
|
+
index: z2.number(),
|
|
312
|
+
delta: z2.discriminatedUnion("type", [
|
|
313
|
+
z2.object({
|
|
314
|
+
type: z2.literal("input_json_delta"),
|
|
315
|
+
partial_json: z2.string()
|
|
316
|
+
}),
|
|
317
|
+
z2.object({
|
|
318
|
+
type: z2.literal("text_delta"),
|
|
319
|
+
text: z2.string()
|
|
320
|
+
}),
|
|
321
|
+
z2.object({
|
|
322
|
+
type: z2.literal("thinking_delta"),
|
|
323
|
+
thinking: z2.string()
|
|
324
|
+
}),
|
|
325
|
+
z2.object({
|
|
326
|
+
type: z2.literal("signature_delta"),
|
|
327
|
+
signature: z2.string()
|
|
328
|
+
}),
|
|
329
|
+
z2.object({
|
|
330
|
+
type: z2.literal("citations_delta"),
|
|
331
|
+
citation: z2.discriminatedUnion("type", [
|
|
332
|
+
z2.object({
|
|
333
|
+
type: z2.literal("web_search_result_location"),
|
|
334
|
+
cited_text: z2.string(),
|
|
335
|
+
url: z2.string(),
|
|
336
|
+
title: z2.string(),
|
|
337
|
+
encrypted_index: z2.string()
|
|
338
|
+
}),
|
|
339
|
+
z2.object({
|
|
340
|
+
type: z2.literal("page_location"),
|
|
341
|
+
cited_text: z2.string(),
|
|
342
|
+
document_index: z2.number(),
|
|
343
|
+
document_title: z2.string().nullable(),
|
|
344
|
+
start_page_number: z2.number(),
|
|
345
|
+
end_page_number: z2.number()
|
|
346
|
+
}),
|
|
347
|
+
z2.object({
|
|
348
|
+
type: z2.literal("char_location"),
|
|
349
|
+
cited_text: z2.string(),
|
|
350
|
+
document_index: z2.number(),
|
|
351
|
+
document_title: z2.string().nullable(),
|
|
352
|
+
start_char_index: z2.number(),
|
|
353
|
+
end_char_index: z2.number()
|
|
354
|
+
})
|
|
355
|
+
])
|
|
356
|
+
})
|
|
357
|
+
])
|
|
358
|
+
}),
|
|
359
|
+
z2.object({
|
|
360
|
+
type: z2.literal("content_block_stop"),
|
|
361
|
+
index: z2.number()
|
|
362
|
+
}),
|
|
363
|
+
z2.object({
|
|
364
|
+
type: z2.literal("error"),
|
|
365
|
+
error: z2.object({
|
|
366
|
+
type: z2.string(),
|
|
367
|
+
message: z2.string()
|
|
368
|
+
})
|
|
369
|
+
}),
|
|
370
|
+
z2.object({
|
|
371
|
+
type: z2.literal("message_delta"),
|
|
372
|
+
delta: z2.object({
|
|
373
|
+
stop_reason: z2.string().nullish(),
|
|
374
|
+
stop_sequence: z2.string().nullish()
|
|
375
|
+
}),
|
|
376
|
+
usage: z2.looseObject({
|
|
377
|
+
output_tokens: z2.number(),
|
|
378
|
+
cache_creation_input_tokens: z2.number().nullish()
|
|
379
|
+
})
|
|
380
|
+
}),
|
|
381
|
+
z2.object({
|
|
382
|
+
type: z2.literal("message_stop")
|
|
383
|
+
}),
|
|
384
|
+
z2.object({
|
|
385
|
+
type: z2.literal("ping")
|
|
386
|
+
})
|
|
387
|
+
])
|
|
388
|
+
)
|
|
389
|
+
);
|
|
390
|
+
var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
|
|
391
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
392
|
+
z2.object({
|
|
393
|
+
signature: z2.string().optional(),
|
|
394
|
+
redactedData: z2.string().optional()
|
|
395
|
+
})
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
// src/anthropic-messages-options.ts
|
|
400
|
+
var z3 = __toESM(require("zod/v4"));
|
|
401
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
69
402
|
/**
|
|
70
403
|
* Citation configuration for this document.
|
|
71
404
|
* When enabled, this document will generate citations in the response.
|
|
72
405
|
*/
|
|
73
|
-
citations:
|
|
406
|
+
citations: z3.object({
|
|
74
407
|
/**
|
|
75
408
|
* Enable citations for this document
|
|
76
409
|
*/
|
|
77
|
-
enabled:
|
|
410
|
+
enabled: z3.boolean()
|
|
78
411
|
}).optional(),
|
|
79
412
|
/**
|
|
80
413
|
* Custom title for the document.
|
|
81
414
|
* If not provided, the filename will be used.
|
|
82
415
|
*/
|
|
83
|
-
title:
|
|
416
|
+
title: z3.string().optional(),
|
|
84
417
|
/**
|
|
85
418
|
* Context about the document that will be passed to the model
|
|
86
419
|
* but not used towards cited content.
|
|
87
420
|
* Useful for storing document metadata as text or stringified JSON.
|
|
88
421
|
*/
|
|
89
|
-
context:
|
|
422
|
+
context: z3.string().optional()
|
|
90
423
|
});
|
|
91
|
-
var anthropicProviderOptions =
|
|
92
|
-
sendReasoning:
|
|
93
|
-
thinking:
|
|
94
|
-
type:
|
|
95
|
-
budgetTokens:
|
|
424
|
+
var anthropicProviderOptions = z3.object({
|
|
425
|
+
sendReasoning: z3.boolean().optional(),
|
|
426
|
+
thinking: z3.object({
|
|
427
|
+
type: z3.union([z3.literal("enabled"), z3.literal("disabled")]),
|
|
428
|
+
budgetTokens: z3.number().optional()
|
|
96
429
|
}).optional(),
|
|
97
430
|
/**
|
|
98
431
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
99
432
|
* When set to true, Claude will use at most one tool per response.
|
|
100
433
|
*/
|
|
101
|
-
disableParallelToolUse:
|
|
434
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
102
435
|
/**
|
|
103
436
|
* Cache control settings for this message.
|
|
104
437
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
105
438
|
*/
|
|
106
|
-
cacheControl:
|
|
107
|
-
type:
|
|
108
|
-
ttl:
|
|
439
|
+
cacheControl: z3.object({
|
|
440
|
+
type: z3.literal("ephemeral"),
|
|
441
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
109
442
|
}).optional()
|
|
110
443
|
});
|
|
111
444
|
|
|
@@ -121,58 +454,81 @@ function getCacheControl(providerMetadata) {
|
|
|
121
454
|
}
|
|
122
455
|
|
|
123
456
|
// src/tool/text-editor_20250728.ts
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
457
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
458
|
+
var z4 = __toESM(require("zod/v4"));
|
|
459
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
460
|
+
var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
|
|
461
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
462
|
+
z4.object({
|
|
463
|
+
maxCharacters: z4.number().optional()
|
|
464
|
+
})
|
|
465
|
+
)
|
|
466
|
+
);
|
|
467
|
+
var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
|
|
468
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
469
|
+
z4.object({
|
|
470
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
471
|
+
path: z4.string(),
|
|
472
|
+
file_text: z4.string().optional(),
|
|
473
|
+
insert_line: z4.number().int().optional(),
|
|
474
|
+
new_str: z4.string().optional(),
|
|
475
|
+
old_str: z4.string().optional(),
|
|
476
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
477
|
+
})
|
|
478
|
+
)
|
|
479
|
+
);
|
|
480
|
+
var factory = (0, import_provider_utils3.createProviderDefinedToolFactory)({
|
|
130
481
|
id: "anthropic.text_editor_20250728",
|
|
131
482
|
name: "str_replace_based_edit_tool",
|
|
132
|
-
inputSchema:
|
|
133
|
-
command: z3.enum(["view", "create", "str_replace", "insert"]),
|
|
134
|
-
path: z3.string(),
|
|
135
|
-
file_text: z3.string().optional(),
|
|
136
|
-
insert_line: z3.number().int().optional(),
|
|
137
|
-
new_str: z3.string().optional(),
|
|
138
|
-
old_str: z3.string().optional(),
|
|
139
|
-
view_range: z3.array(z3.number().int()).optional()
|
|
140
|
-
})
|
|
483
|
+
inputSchema: textEditor_20250728InputSchema
|
|
141
484
|
});
|
|
142
485
|
var textEditor_20250728 = (args = {}) => {
|
|
143
486
|
return factory(args);
|
|
144
487
|
};
|
|
145
488
|
|
|
146
489
|
// src/tool/web-search_20250305.ts
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
var webSearch_20250305ArgsSchema =
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
title: z4.string(),
|
|
165
|
-
pageAge: z4.string().nullable(),
|
|
166
|
-
encryptedContent: z4.string(),
|
|
167
|
-
type: z4.literal("web_search_result")
|
|
168
|
-
})
|
|
490
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
491
|
+
var z5 = __toESM(require("zod/v4"));
|
|
492
|
+
var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
|
|
493
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
494
|
+
z5.object({
|
|
495
|
+
maxUses: z5.number().optional(),
|
|
496
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
497
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
498
|
+
userLocation: z5.object({
|
|
499
|
+
type: z5.literal("approximate"),
|
|
500
|
+
city: z5.string().optional(),
|
|
501
|
+
region: z5.string().optional(),
|
|
502
|
+
country: z5.string().optional(),
|
|
503
|
+
timezone: z5.string().optional()
|
|
504
|
+
}).optional()
|
|
505
|
+
})
|
|
506
|
+
)
|
|
169
507
|
);
|
|
170
|
-
var
|
|
508
|
+
var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
|
|
509
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
510
|
+
z5.array(
|
|
511
|
+
z5.object({
|
|
512
|
+
url: z5.string(),
|
|
513
|
+
title: z5.string(),
|
|
514
|
+
pageAge: z5.string().nullable(),
|
|
515
|
+
encryptedContent: z5.string(),
|
|
516
|
+
type: z5.literal("web_search_result")
|
|
517
|
+
})
|
|
518
|
+
)
|
|
519
|
+
)
|
|
520
|
+
);
|
|
521
|
+
var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
|
|
522
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
523
|
+
z5.object({
|
|
524
|
+
query: z5.string()
|
|
525
|
+
})
|
|
526
|
+
)
|
|
527
|
+
);
|
|
528
|
+
var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
171
529
|
id: "anthropic.web_search_20250305",
|
|
172
530
|
name: "web_search",
|
|
173
|
-
inputSchema:
|
|
174
|
-
query: z4.string()
|
|
175
|
-
}),
|
|
531
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
176
532
|
outputSchema: webSearch_20250305OutputSchema
|
|
177
533
|
});
|
|
178
534
|
var webSearch_20250305 = (args = {}) => {
|
|
@@ -180,43 +536,56 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
180
536
|
};
|
|
181
537
|
|
|
182
538
|
// src/tool/web-fetch-20250910.ts
|
|
183
|
-
var
|
|
184
|
-
var
|
|
185
|
-
var webFetch_20250910ArgsSchema =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
539
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
540
|
+
var z6 = __toESM(require("zod/v4"));
|
|
541
|
+
var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
542
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
543
|
+
z6.object({
|
|
544
|
+
maxUses: z6.number().optional(),
|
|
545
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
546
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
547
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
548
|
+
maxContentTokens: z6.number().optional()
|
|
549
|
+
})
|
|
550
|
+
)
|
|
551
|
+
);
|
|
552
|
+
var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
553
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
554
|
+
z6.object({
|
|
555
|
+
type: z6.literal("web_fetch_result"),
|
|
556
|
+
url: z6.string(),
|
|
557
|
+
content: z6.object({
|
|
558
|
+
type: z6.literal("document"),
|
|
559
|
+
title: z6.string(),
|
|
560
|
+
citations: z6.object({ enabled: z6.boolean() }).optional(),
|
|
561
|
+
source: z6.union([
|
|
562
|
+
z6.object({
|
|
563
|
+
type: z6.literal("base64"),
|
|
564
|
+
mediaType: z6.literal("application/pdf"),
|
|
565
|
+
data: z6.string()
|
|
566
|
+
}),
|
|
567
|
+
z6.object({
|
|
568
|
+
type: z6.literal("text"),
|
|
569
|
+
mediaType: z6.literal("text/plain"),
|
|
570
|
+
data: z6.string()
|
|
571
|
+
})
|
|
572
|
+
])
|
|
204
573
|
}),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
})
|
|
214
|
-
|
|
574
|
+
retrievedAt: z6.string().nullable()
|
|
575
|
+
})
|
|
576
|
+
)
|
|
577
|
+
);
|
|
578
|
+
var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
|
|
579
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
580
|
+
z6.object({
|
|
581
|
+
url: z6.string()
|
|
582
|
+
})
|
|
583
|
+
)
|
|
584
|
+
);
|
|
585
|
+
var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
215
586
|
id: "anthropic.web_fetch_20250910",
|
|
216
587
|
name: "web_fetch",
|
|
217
|
-
inputSchema:
|
|
218
|
-
url: z5.string()
|
|
219
|
-
}),
|
|
588
|
+
inputSchema: webFetch_20250910InputSchema,
|
|
220
589
|
outputSchema: webFetch_20250910OutputSchema
|
|
221
590
|
});
|
|
222
591
|
var webFetch_20250910 = (args = {}) => {
|
|
@@ -224,7 +593,8 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
224
593
|
};
|
|
225
594
|
|
|
226
595
|
// src/anthropic-prepare-tools.ts
|
|
227
|
-
|
|
596
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
597
|
+
async function prepareTools({
|
|
228
598
|
tools,
|
|
229
599
|
toolChoice,
|
|
230
600
|
disableParallelToolUse
|
|
@@ -305,7 +675,10 @@ function prepareTools({
|
|
|
305
675
|
break;
|
|
306
676
|
}
|
|
307
677
|
case "anthropic.text_editor_20250728": {
|
|
308
|
-
const args =
|
|
678
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
679
|
+
value: tool.args,
|
|
680
|
+
schema: textEditor_20250728ArgsSchema
|
|
681
|
+
});
|
|
309
682
|
anthropicTools2.push({
|
|
310
683
|
name: "str_replace_based_edit_tool",
|
|
311
684
|
type: "text_editor_20250728",
|
|
@@ -331,7 +704,10 @@ function prepareTools({
|
|
|
331
704
|
}
|
|
332
705
|
case "anthropic.web_fetch_20250910": {
|
|
333
706
|
betas.add("web-fetch-2025-09-10");
|
|
334
|
-
const args =
|
|
707
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
708
|
+
value: tool.args,
|
|
709
|
+
schema: webFetch_20250910ArgsSchema
|
|
710
|
+
});
|
|
335
711
|
anthropicTools2.push({
|
|
336
712
|
type: "web_fetch_20250910",
|
|
337
713
|
name: "web_fetch",
|
|
@@ -344,7 +720,10 @@ function prepareTools({
|
|
|
344
720
|
break;
|
|
345
721
|
}
|
|
346
722
|
case "anthropic.web_search_20250305": {
|
|
347
|
-
const args =
|
|
723
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
724
|
+
value: tool.args,
|
|
725
|
+
schema: webSearch_20250305ArgsSchema
|
|
726
|
+
});
|
|
348
727
|
anthropicTools2.push({
|
|
349
728
|
type: "web_search_20250305",
|
|
350
729
|
name: "web_search",
|
|
@@ -422,23 +801,32 @@ function prepareTools({
|
|
|
422
801
|
|
|
423
802
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
424
803
|
var import_provider2 = require("@ai-sdk/provider");
|
|
425
|
-
var
|
|
804
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
426
805
|
|
|
427
806
|
// src/tool/code-execution_20250522.ts
|
|
428
|
-
var
|
|
429
|
-
var
|
|
430
|
-
var codeExecution_20250522OutputSchema =
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
807
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
808
|
+
var z7 = __toESM(require("zod/v4"));
|
|
809
|
+
var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
810
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
811
|
+
z7.object({
|
|
812
|
+
type: z7.literal("code_execution_result"),
|
|
813
|
+
stdout: z7.string(),
|
|
814
|
+
stderr: z7.string(),
|
|
815
|
+
return_code: z7.number()
|
|
816
|
+
})
|
|
817
|
+
)
|
|
818
|
+
);
|
|
819
|
+
var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
820
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
821
|
+
z7.object({
|
|
822
|
+
code: z7.string()
|
|
823
|
+
})
|
|
824
|
+
)
|
|
825
|
+
);
|
|
826
|
+
var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
437
827
|
id: "anthropic.code_execution_20250522",
|
|
438
828
|
name: "code_execution",
|
|
439
|
-
inputSchema:
|
|
440
|
-
code: z6.string()
|
|
441
|
-
}),
|
|
829
|
+
inputSchema: codeExecution_20250522InputSchema,
|
|
442
830
|
outputSchema: codeExecution_20250522OutputSchema
|
|
443
831
|
});
|
|
444
832
|
var codeExecution_20250522 = (args = {}) => {
|
|
@@ -474,7 +862,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
474
862
|
const messages = [];
|
|
475
863
|
async function shouldEnableCitations(providerMetadata) {
|
|
476
864
|
var _a2, _b2;
|
|
477
|
-
const anthropicOptions = await (0,
|
|
865
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
478
866
|
provider: "anthropic",
|
|
479
867
|
providerOptions: providerMetadata,
|
|
480
868
|
schema: anthropicFilePartProviderOptions
|
|
@@ -482,7 +870,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
482
870
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
483
871
|
}
|
|
484
872
|
async function getDocumentMetadata(providerMetadata) {
|
|
485
|
-
const anthropicOptions = await (0,
|
|
873
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
486
874
|
provider: "anthropic",
|
|
487
875
|
providerOptions: providerMetadata,
|
|
488
876
|
schema: anthropicFilePartProviderOptions
|
|
@@ -539,7 +927,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
539
927
|
} : {
|
|
540
928
|
type: "base64",
|
|
541
929
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
542
|
-
data: (0,
|
|
930
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
543
931
|
},
|
|
544
932
|
cache_control: cacheControl
|
|
545
933
|
});
|
|
@@ -559,7 +947,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
559
947
|
} : {
|
|
560
948
|
type: "base64",
|
|
561
949
|
media_type: "application/pdf",
|
|
562
|
-
data: (0,
|
|
950
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
563
951
|
},
|
|
564
952
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
565
953
|
...metadata.context && { context: metadata.context },
|
|
@@ -697,7 +1085,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
697
1085
|
}
|
|
698
1086
|
case "reasoning": {
|
|
699
1087
|
if (sendReasoning) {
|
|
700
|
-
const reasoningMetadata = await (0,
|
|
1088
|
+
const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
|
|
701
1089
|
provider: "anthropic",
|
|
702
1090
|
providerOptions: part.providerOptions,
|
|
703
1091
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -773,7 +1161,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
773
1161
|
});
|
|
774
1162
|
break;
|
|
775
1163
|
}
|
|
776
|
-
const codeExecutionOutput =
|
|
1164
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1165
|
+
value: output.value,
|
|
1166
|
+
schema: codeExecution_20250522OutputSchema
|
|
1167
|
+
});
|
|
777
1168
|
anthropicContent.push({
|
|
778
1169
|
type: "code_execution_tool_result",
|
|
779
1170
|
tool_use_id: part.toolCallId,
|
|
@@ -796,9 +1187,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
796
1187
|
});
|
|
797
1188
|
break;
|
|
798
1189
|
}
|
|
799
|
-
const webFetchOutput =
|
|
800
|
-
output.value
|
|
801
|
-
|
|
1190
|
+
const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1191
|
+
value: output.value,
|
|
1192
|
+
schema: webFetch_20250910OutputSchema
|
|
1193
|
+
});
|
|
802
1194
|
anthropicContent.push({
|
|
803
1195
|
type: "web_fetch_tool_result",
|
|
804
1196
|
tool_use_id: part.toolCallId,
|
|
@@ -830,9 +1222,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
830
1222
|
});
|
|
831
1223
|
break;
|
|
832
1224
|
}
|
|
833
|
-
const webSearchOutput =
|
|
834
|
-
output.value
|
|
835
|
-
|
|
1225
|
+
const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1226
|
+
value: output.value,
|
|
1227
|
+
schema: webSearch_20250305OutputSchema
|
|
1228
|
+
});
|
|
836
1229
|
anthropicContent.push({
|
|
837
1230
|
type: "web_search_tool_result",
|
|
838
1231
|
tool_use_id: part.toolCallId,
|
|
@@ -939,67 +1332,15 @@ function mapAnthropicStopReason({
|
|
|
939
1332
|
}
|
|
940
1333
|
|
|
941
1334
|
// src/anthropic-messages-language-model.ts
|
|
942
|
-
var citationSchemas = {
|
|
943
|
-
webSearchResult: z7.object({
|
|
944
|
-
type: z7.literal("web_search_result_location"),
|
|
945
|
-
cited_text: z7.string(),
|
|
946
|
-
url: z7.string(),
|
|
947
|
-
title: z7.string(),
|
|
948
|
-
encrypted_index: z7.string()
|
|
949
|
-
}),
|
|
950
|
-
pageLocation: z7.object({
|
|
951
|
-
type: z7.literal("page_location"),
|
|
952
|
-
cited_text: z7.string(),
|
|
953
|
-
document_index: z7.number(),
|
|
954
|
-
document_title: z7.string().nullable(),
|
|
955
|
-
start_page_number: z7.number(),
|
|
956
|
-
end_page_number: z7.number()
|
|
957
|
-
}),
|
|
958
|
-
charLocation: z7.object({
|
|
959
|
-
type: z7.literal("char_location"),
|
|
960
|
-
cited_text: z7.string(),
|
|
961
|
-
document_index: z7.number(),
|
|
962
|
-
document_title: z7.string().nullable(),
|
|
963
|
-
start_char_index: z7.number(),
|
|
964
|
-
end_char_index: z7.number()
|
|
965
|
-
})
|
|
966
|
-
};
|
|
967
|
-
var citationSchema = z7.discriminatedUnion("type", [
|
|
968
|
-
citationSchemas.webSearchResult,
|
|
969
|
-
citationSchemas.pageLocation,
|
|
970
|
-
citationSchemas.charLocation
|
|
971
|
-
]);
|
|
972
|
-
var documentCitationSchema = z7.discriminatedUnion("type", [
|
|
973
|
-
citationSchemas.pageLocation,
|
|
974
|
-
citationSchemas.charLocation
|
|
975
|
-
]);
|
|
976
|
-
function processCitation(citation, citationDocuments, generateId3, onSource) {
|
|
977
|
-
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
978
|
-
const source = createCitationSource(
|
|
979
|
-
citation,
|
|
980
|
-
citationDocuments,
|
|
981
|
-
generateId3
|
|
982
|
-
);
|
|
983
|
-
if (source) {
|
|
984
|
-
onSource(source);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
1335
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
989
1336
|
var _a;
|
|
1337
|
+
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
990
1340
|
const documentInfo = citationDocuments[citation.document_index];
|
|
991
1341
|
if (!documentInfo) {
|
|
992
|
-
return
|
|
1342
|
+
return;
|
|
993
1343
|
}
|
|
994
|
-
const providerMetadata = citation.type === "page_location" ? {
|
|
995
|
-
citedText: citation.cited_text,
|
|
996
|
-
startPageNumber: citation.start_page_number,
|
|
997
|
-
endPageNumber: citation.end_page_number
|
|
998
|
-
} : {
|
|
999
|
-
citedText: citation.cited_text,
|
|
1000
|
-
startCharIndex: citation.start_char_index,
|
|
1001
|
-
endCharIndex: citation.end_char_index
|
|
1002
|
-
};
|
|
1003
1344
|
return {
|
|
1004
1345
|
type: "source",
|
|
1005
1346
|
sourceType: "document",
|
|
@@ -1008,7 +1349,15 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
1008
1349
|
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
1009
1350
|
filename: documentInfo.filename,
|
|
1010
1351
|
providerMetadata: {
|
|
1011
|
-
anthropic:
|
|
1352
|
+
anthropic: citation.type === "page_location" ? {
|
|
1353
|
+
citedText: citation.cited_text,
|
|
1354
|
+
startPageNumber: citation.start_page_number,
|
|
1355
|
+
endPageNumber: citation.end_page_number
|
|
1356
|
+
} : {
|
|
1357
|
+
citedText: citation.cited_text,
|
|
1358
|
+
startCharIndex: citation.start_char_index,
|
|
1359
|
+
endCharIndex: citation.end_char_index
|
|
1360
|
+
}
|
|
1012
1361
|
}
|
|
1013
1362
|
};
|
|
1014
1363
|
}
|
|
@@ -1018,7 +1367,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1018
1367
|
var _a;
|
|
1019
1368
|
this.modelId = modelId;
|
|
1020
1369
|
this.config = config;
|
|
1021
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1370
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
|
|
1022
1371
|
}
|
|
1023
1372
|
supportsUrl(url) {
|
|
1024
1373
|
return url.protocol === "https:";
|
|
@@ -1087,7 +1436,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1087
1436
|
description: "Respond with a JSON object.",
|
|
1088
1437
|
inputSchema: responseFormat.schema
|
|
1089
1438
|
} : void 0;
|
|
1090
|
-
const anthropicOptions = await (0,
|
|
1439
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1091
1440
|
provider: "anthropic",
|
|
1092
1441
|
providerOptions,
|
|
1093
1442
|
schema: anthropicProviderOptions
|
|
@@ -1153,7 +1502,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1153
1502
|
toolChoice: anthropicToolChoice,
|
|
1154
1503
|
toolWarnings,
|
|
1155
1504
|
betas: toolsBetas
|
|
1156
|
-
} = prepareTools(
|
|
1505
|
+
} = await prepareTools(
|
|
1157
1506
|
jsonResponseTool != null ? {
|
|
1158
1507
|
tools: [jsonResponseTool],
|
|
1159
1508
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
@@ -1179,8 +1528,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1179
1528
|
betas,
|
|
1180
1529
|
headers
|
|
1181
1530
|
}) {
|
|
1182
|
-
return (0,
|
|
1183
|
-
await (0,
|
|
1531
|
+
return (0, import_provider_utils10.combineHeaders)(
|
|
1532
|
+
await (0, import_provider_utils10.resolve)(this.config.headers),
|
|
1184
1533
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1185
1534
|
headers
|
|
1186
1535
|
);
|
|
@@ -1224,12 +1573,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1224
1573
|
responseHeaders,
|
|
1225
1574
|
value: response,
|
|
1226
1575
|
rawValue: rawResponse
|
|
1227
|
-
} = await (0,
|
|
1576
|
+
} = await (0, import_provider_utils10.postJsonToApi)({
|
|
1228
1577
|
url: this.buildRequestUrl(false),
|
|
1229
1578
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1230
1579
|
body: this.transformRequestBody(args),
|
|
1231
1580
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1232
|
-
successfulResponseHandler: (0,
|
|
1581
|
+
successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
|
|
1233
1582
|
anthropicMessagesResponseSchema
|
|
1234
1583
|
),
|
|
1235
1584
|
abortSignal: options.abortSignal,
|
|
@@ -1243,12 +1592,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1243
1592
|
content.push({ type: "text", text: part.text });
|
|
1244
1593
|
if (part.citations) {
|
|
1245
1594
|
for (const citation of part.citations) {
|
|
1246
|
-
|
|
1595
|
+
const source = createCitationSource(
|
|
1247
1596
|
citation,
|
|
1248
1597
|
citationDocuments,
|
|
1249
|
-
this.generateId
|
|
1250
|
-
(source) => content.push(source)
|
|
1598
|
+
this.generateId
|
|
1251
1599
|
);
|
|
1600
|
+
if (source) {
|
|
1601
|
+
content.push(source);
|
|
1602
|
+
}
|
|
1252
1603
|
}
|
|
1253
1604
|
}
|
|
1254
1605
|
}
|
|
@@ -1454,12 +1805,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1454
1805
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1455
1806
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1456
1807
|
const body = { ...args, stream: true };
|
|
1457
|
-
const { responseHeaders, value: response } = await (0,
|
|
1808
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
|
|
1458
1809
|
url: this.buildRequestUrl(true),
|
|
1459
1810
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1460
1811
|
body: this.transformRequestBody(body),
|
|
1461
1812
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1462
|
-
successfulResponseHandler: (0,
|
|
1813
|
+
successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
|
|
1463
1814
|
anthropicMessagesChunkSchema
|
|
1464
1815
|
),
|
|
1465
1816
|
abortSignal: options.abortSignal,
|
|
@@ -1785,12 +2136,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1785
2136
|
}
|
|
1786
2137
|
case "citations_delta": {
|
|
1787
2138
|
const citation = value.delta.citation;
|
|
1788
|
-
|
|
2139
|
+
const source = createCitationSource(
|
|
1789
2140
|
citation,
|
|
1790
2141
|
citationDocuments,
|
|
1791
|
-
generateId3
|
|
1792
|
-
(source) => controller.enqueue(source)
|
|
2142
|
+
generateId3
|
|
1793
2143
|
);
|
|
2144
|
+
if (source) {
|
|
2145
|
+
controller.enqueue(source);
|
|
2146
|
+
}
|
|
1794
2147
|
return;
|
|
1795
2148
|
}
|
|
1796
2149
|
default: {
|
|
@@ -1861,402 +2214,173 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1861
2214
|
};
|
|
1862
2215
|
}
|
|
1863
2216
|
};
|
|
1864
|
-
var anthropicMessagesResponseSchema = z7.object({
|
|
1865
|
-
type: z7.literal("message"),
|
|
1866
|
-
id: z7.string().nullish(),
|
|
1867
|
-
model: z7.string().nullish(),
|
|
1868
|
-
content: z7.array(
|
|
1869
|
-
z7.discriminatedUnion("type", [
|
|
1870
|
-
z7.object({
|
|
1871
|
-
type: z7.literal("text"),
|
|
1872
|
-
text: z7.string(),
|
|
1873
|
-
citations: z7.array(citationSchema).optional()
|
|
1874
|
-
}),
|
|
1875
|
-
z7.object({
|
|
1876
|
-
type: z7.literal("thinking"),
|
|
1877
|
-
thinking: z7.string(),
|
|
1878
|
-
signature: z7.string()
|
|
1879
|
-
}),
|
|
1880
|
-
z7.object({
|
|
1881
|
-
type: z7.literal("redacted_thinking"),
|
|
1882
|
-
data: z7.string()
|
|
1883
|
-
}),
|
|
1884
|
-
z7.object({
|
|
1885
|
-
type: z7.literal("tool_use"),
|
|
1886
|
-
id: z7.string(),
|
|
1887
|
-
name: z7.string(),
|
|
1888
|
-
input: z7.unknown()
|
|
1889
|
-
}),
|
|
1890
|
-
z7.object({
|
|
1891
|
-
type: z7.literal("server_tool_use"),
|
|
1892
|
-
id: z7.string(),
|
|
1893
|
-
name: z7.string(),
|
|
1894
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1895
|
-
}),
|
|
1896
|
-
z7.object({
|
|
1897
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
1898
|
-
tool_use_id: z7.string(),
|
|
1899
|
-
content: z7.union([
|
|
1900
|
-
z7.object({
|
|
1901
|
-
type: z7.literal("web_fetch_result"),
|
|
1902
|
-
url: z7.string(),
|
|
1903
|
-
retrieved_at: z7.string(),
|
|
1904
|
-
content: z7.object({
|
|
1905
|
-
type: z7.literal("document"),
|
|
1906
|
-
title: z7.string().nullable(),
|
|
1907
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1908
|
-
source: z7.object({
|
|
1909
|
-
type: z7.literal("text"),
|
|
1910
|
-
media_type: z7.string(),
|
|
1911
|
-
data: z7.string()
|
|
1912
|
-
})
|
|
1913
|
-
})
|
|
1914
|
-
}),
|
|
1915
|
-
z7.object({
|
|
1916
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
1917
|
-
error_code: z7.string()
|
|
1918
|
-
})
|
|
1919
|
-
])
|
|
1920
|
-
}),
|
|
1921
|
-
z7.object({
|
|
1922
|
-
type: z7.literal("web_search_tool_result"),
|
|
1923
|
-
tool_use_id: z7.string(),
|
|
1924
|
-
content: z7.union([
|
|
1925
|
-
z7.array(
|
|
1926
|
-
z7.object({
|
|
1927
|
-
type: z7.literal("web_search_result"),
|
|
1928
|
-
url: z7.string(),
|
|
1929
|
-
title: z7.string(),
|
|
1930
|
-
encrypted_content: z7.string(),
|
|
1931
|
-
page_age: z7.string().nullish()
|
|
1932
|
-
})
|
|
1933
|
-
),
|
|
1934
|
-
z7.object({
|
|
1935
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
1936
|
-
error_code: z7.string()
|
|
1937
|
-
})
|
|
1938
|
-
])
|
|
1939
|
-
}),
|
|
1940
|
-
z7.object({
|
|
1941
|
-
type: z7.literal("code_execution_tool_result"),
|
|
1942
|
-
tool_use_id: z7.string(),
|
|
1943
|
-
content: z7.union([
|
|
1944
|
-
z7.object({
|
|
1945
|
-
type: z7.literal("code_execution_result"),
|
|
1946
|
-
stdout: z7.string(),
|
|
1947
|
-
stderr: z7.string(),
|
|
1948
|
-
return_code: z7.number()
|
|
1949
|
-
}),
|
|
1950
|
-
z7.object({
|
|
1951
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
1952
|
-
error_code: z7.string()
|
|
1953
|
-
})
|
|
1954
|
-
])
|
|
1955
|
-
})
|
|
1956
|
-
])
|
|
1957
|
-
),
|
|
1958
|
-
stop_reason: z7.string().nullish(),
|
|
1959
|
-
stop_sequence: z7.string().nullish(),
|
|
1960
|
-
usage: z7.looseObject({
|
|
1961
|
-
input_tokens: z7.number(),
|
|
1962
|
-
output_tokens: z7.number(),
|
|
1963
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1964
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1965
|
-
})
|
|
1966
|
-
});
|
|
1967
|
-
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1968
|
-
z7.object({
|
|
1969
|
-
type: z7.literal("message_start"),
|
|
1970
|
-
message: z7.object({
|
|
1971
|
-
id: z7.string().nullish(),
|
|
1972
|
-
model: z7.string().nullish(),
|
|
1973
|
-
usage: z7.looseObject({
|
|
1974
|
-
input_tokens: z7.number(),
|
|
1975
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1976
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1977
|
-
})
|
|
1978
|
-
})
|
|
1979
|
-
}),
|
|
1980
|
-
z7.object({
|
|
1981
|
-
type: z7.literal("content_block_start"),
|
|
1982
|
-
index: z7.number(),
|
|
1983
|
-
content_block: z7.discriminatedUnion("type", [
|
|
1984
|
-
z7.object({
|
|
1985
|
-
type: z7.literal("text"),
|
|
1986
|
-
text: z7.string()
|
|
1987
|
-
}),
|
|
1988
|
-
z7.object({
|
|
1989
|
-
type: z7.literal("thinking"),
|
|
1990
|
-
thinking: z7.string()
|
|
1991
|
-
}),
|
|
1992
|
-
z7.object({
|
|
1993
|
-
type: z7.literal("tool_use"),
|
|
1994
|
-
id: z7.string(),
|
|
1995
|
-
name: z7.string()
|
|
1996
|
-
}),
|
|
1997
|
-
z7.object({
|
|
1998
|
-
type: z7.literal("redacted_thinking"),
|
|
1999
|
-
data: z7.string()
|
|
2000
|
-
}),
|
|
2001
|
-
z7.object({
|
|
2002
|
-
type: z7.literal("server_tool_use"),
|
|
2003
|
-
id: z7.string(),
|
|
2004
|
-
name: z7.string(),
|
|
2005
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
2006
|
-
}),
|
|
2007
|
-
z7.object({
|
|
2008
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
2009
|
-
tool_use_id: z7.string(),
|
|
2010
|
-
content: z7.union([
|
|
2011
|
-
z7.object({
|
|
2012
|
-
type: z7.literal("web_fetch_result"),
|
|
2013
|
-
url: z7.string(),
|
|
2014
|
-
retrieved_at: z7.string(),
|
|
2015
|
-
content: z7.object({
|
|
2016
|
-
type: z7.literal("document"),
|
|
2017
|
-
title: z7.string().nullable(),
|
|
2018
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
2019
|
-
source: z7.object({
|
|
2020
|
-
type: z7.literal("text"),
|
|
2021
|
-
media_type: z7.string(),
|
|
2022
|
-
data: z7.string()
|
|
2023
|
-
})
|
|
2024
|
-
})
|
|
2025
|
-
}),
|
|
2026
|
-
z7.object({
|
|
2027
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
2028
|
-
error_code: z7.string()
|
|
2029
|
-
})
|
|
2030
|
-
])
|
|
2031
|
-
}),
|
|
2032
|
-
z7.object({
|
|
2033
|
-
type: z7.literal("web_search_tool_result"),
|
|
2034
|
-
tool_use_id: z7.string(),
|
|
2035
|
-
content: z7.union([
|
|
2036
|
-
z7.array(
|
|
2037
|
-
z7.object({
|
|
2038
|
-
type: z7.literal("web_search_result"),
|
|
2039
|
-
url: z7.string(),
|
|
2040
|
-
title: z7.string(),
|
|
2041
|
-
encrypted_content: z7.string(),
|
|
2042
|
-
page_age: z7.string().nullish()
|
|
2043
|
-
})
|
|
2044
|
-
),
|
|
2045
|
-
z7.object({
|
|
2046
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
2047
|
-
error_code: z7.string()
|
|
2048
|
-
})
|
|
2049
|
-
])
|
|
2050
|
-
}),
|
|
2051
|
-
z7.object({
|
|
2052
|
-
type: z7.literal("code_execution_tool_result"),
|
|
2053
|
-
tool_use_id: z7.string(),
|
|
2054
|
-
content: z7.union([
|
|
2055
|
-
z7.object({
|
|
2056
|
-
type: z7.literal("code_execution_result"),
|
|
2057
|
-
stdout: z7.string(),
|
|
2058
|
-
stderr: z7.string(),
|
|
2059
|
-
return_code: z7.number()
|
|
2060
|
-
}),
|
|
2061
|
-
z7.object({
|
|
2062
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
2063
|
-
error_code: z7.string()
|
|
2064
|
-
})
|
|
2065
|
-
])
|
|
2066
|
-
})
|
|
2067
|
-
])
|
|
2068
|
-
}),
|
|
2069
|
-
z7.object({
|
|
2070
|
-
type: z7.literal("content_block_delta"),
|
|
2071
|
-
index: z7.number(),
|
|
2072
|
-
delta: z7.discriminatedUnion("type", [
|
|
2073
|
-
z7.object({
|
|
2074
|
-
type: z7.literal("input_json_delta"),
|
|
2075
|
-
partial_json: z7.string()
|
|
2076
|
-
}),
|
|
2077
|
-
z7.object({
|
|
2078
|
-
type: z7.literal("text_delta"),
|
|
2079
|
-
text: z7.string()
|
|
2080
|
-
}),
|
|
2081
|
-
z7.object({
|
|
2082
|
-
type: z7.literal("thinking_delta"),
|
|
2083
|
-
thinking: z7.string()
|
|
2084
|
-
}),
|
|
2085
|
-
z7.object({
|
|
2086
|
-
type: z7.literal("signature_delta"),
|
|
2087
|
-
signature: z7.string()
|
|
2088
|
-
}),
|
|
2089
|
-
z7.object({
|
|
2090
|
-
type: z7.literal("citations_delta"),
|
|
2091
|
-
citation: citationSchema
|
|
2092
|
-
})
|
|
2093
|
-
])
|
|
2094
|
-
}),
|
|
2095
|
-
z7.object({
|
|
2096
|
-
type: z7.literal("content_block_stop"),
|
|
2097
|
-
index: z7.number()
|
|
2098
|
-
}),
|
|
2099
|
-
z7.object({
|
|
2100
|
-
type: z7.literal("error"),
|
|
2101
|
-
error: z7.object({
|
|
2102
|
-
type: z7.string(),
|
|
2103
|
-
message: z7.string()
|
|
2104
|
-
})
|
|
2105
|
-
}),
|
|
2106
|
-
z7.object({
|
|
2107
|
-
type: z7.literal("message_delta"),
|
|
2108
|
-
delta: z7.object({
|
|
2109
|
-
stop_reason: z7.string().nullish(),
|
|
2110
|
-
stop_sequence: z7.string().nullish()
|
|
2111
|
-
}),
|
|
2112
|
-
usage: z7.looseObject({
|
|
2113
|
-
output_tokens: z7.number(),
|
|
2114
|
-
cache_creation_input_tokens: z7.number().nullish()
|
|
2115
|
-
})
|
|
2116
|
-
}),
|
|
2117
|
-
z7.object({
|
|
2118
|
-
type: z7.literal("message_stop")
|
|
2119
|
-
}),
|
|
2120
|
-
z7.object({
|
|
2121
|
-
type: z7.literal("ping")
|
|
2122
|
-
})
|
|
2123
|
-
]);
|
|
2124
|
-
var anthropicReasoningMetadataSchema = z7.object({
|
|
2125
|
-
signature: z7.string().optional(),
|
|
2126
|
-
redactedData: z7.string().optional()
|
|
2127
|
-
});
|
|
2128
2217
|
|
|
2129
2218
|
// src/tool/bash_20241022.ts
|
|
2130
|
-
var
|
|
2131
|
-
var
|
|
2132
|
-
var
|
|
2219
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2220
|
+
var z8 = __toESM(require("zod/v4"));
|
|
2221
|
+
var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2222
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2223
|
+
z8.object({
|
|
2224
|
+
command: z8.string(),
|
|
2225
|
+
restart: z8.boolean().optional()
|
|
2226
|
+
})
|
|
2227
|
+
)
|
|
2228
|
+
);
|
|
2229
|
+
var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
2133
2230
|
id: "anthropic.bash_20241022",
|
|
2134
2231
|
name: "bash",
|
|
2135
|
-
inputSchema:
|
|
2136
|
-
command: import_v4.default.string(),
|
|
2137
|
-
restart: import_v4.default.boolean().optional()
|
|
2138
|
-
})
|
|
2232
|
+
inputSchema: bash_20241022InputSchema
|
|
2139
2233
|
});
|
|
2140
2234
|
|
|
2141
2235
|
// src/tool/bash_20250124.ts
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2236
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2237
|
+
var z9 = __toESM(require("zod/v4"));
|
|
2238
|
+
var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2239
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2240
|
+
z9.object({
|
|
2241
|
+
command: z9.string(),
|
|
2242
|
+
restart: z9.boolean().optional()
|
|
2243
|
+
})
|
|
2244
|
+
)
|
|
2245
|
+
);
|
|
2246
|
+
var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2145
2247
|
id: "anthropic.bash_20250124",
|
|
2146
2248
|
name: "bash",
|
|
2147
|
-
inputSchema:
|
|
2148
|
-
command: import_v42.default.string(),
|
|
2149
|
-
restart: import_v42.default.boolean().optional()
|
|
2150
|
-
})
|
|
2249
|
+
inputSchema: bash_20250124InputSchema
|
|
2151
2250
|
});
|
|
2152
2251
|
|
|
2153
2252
|
// src/tool/computer_20241022.ts
|
|
2154
|
-
var
|
|
2253
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2155
2254
|
var z10 = __toESM(require("zod/v4"));
|
|
2156
|
-
var
|
|
2255
|
+
var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2256
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2257
|
+
z10.object({
|
|
2258
|
+
action: z10.enum([
|
|
2259
|
+
"key",
|
|
2260
|
+
"type",
|
|
2261
|
+
"mouse_move",
|
|
2262
|
+
"left_click",
|
|
2263
|
+
"left_click_drag",
|
|
2264
|
+
"right_click",
|
|
2265
|
+
"middle_click",
|
|
2266
|
+
"double_click",
|
|
2267
|
+
"screenshot",
|
|
2268
|
+
"cursor_position"
|
|
2269
|
+
]),
|
|
2270
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2271
|
+
text: z10.string().optional()
|
|
2272
|
+
})
|
|
2273
|
+
)
|
|
2274
|
+
);
|
|
2275
|
+
var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2157
2276
|
id: "anthropic.computer_20241022",
|
|
2158
2277
|
name: "computer",
|
|
2159
|
-
inputSchema:
|
|
2160
|
-
action: z10.enum([
|
|
2161
|
-
"key",
|
|
2162
|
-
"type",
|
|
2163
|
-
"mouse_move",
|
|
2164
|
-
"left_click",
|
|
2165
|
-
"left_click_drag",
|
|
2166
|
-
"right_click",
|
|
2167
|
-
"middle_click",
|
|
2168
|
-
"double_click",
|
|
2169
|
-
"screenshot",
|
|
2170
|
-
"cursor_position"
|
|
2171
|
-
]),
|
|
2172
|
-
coordinate: z10.array(z10.number().int()).optional(),
|
|
2173
|
-
text: z10.string().optional()
|
|
2174
|
-
})
|
|
2278
|
+
inputSchema: computer_20241022InputSchema
|
|
2175
2279
|
});
|
|
2176
2280
|
|
|
2177
2281
|
// src/tool/computer_20250124.ts
|
|
2178
|
-
var
|
|
2282
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2179
2283
|
var z11 = __toESM(require("zod/v4"));
|
|
2180
|
-
var
|
|
2284
|
+
var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2285
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2286
|
+
z11.object({
|
|
2287
|
+
action: z11.enum([
|
|
2288
|
+
"key",
|
|
2289
|
+
"hold_key",
|
|
2290
|
+
"type",
|
|
2291
|
+
"cursor_position",
|
|
2292
|
+
"mouse_move",
|
|
2293
|
+
"left_mouse_down",
|
|
2294
|
+
"left_mouse_up",
|
|
2295
|
+
"left_click",
|
|
2296
|
+
"left_click_drag",
|
|
2297
|
+
"right_click",
|
|
2298
|
+
"middle_click",
|
|
2299
|
+
"double_click",
|
|
2300
|
+
"triple_click",
|
|
2301
|
+
"scroll",
|
|
2302
|
+
"wait",
|
|
2303
|
+
"screenshot"
|
|
2304
|
+
]),
|
|
2305
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2306
|
+
duration: z11.number().optional(),
|
|
2307
|
+
scroll_amount: z11.number().optional(),
|
|
2308
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2309
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2310
|
+
text: z11.string().optional()
|
|
2311
|
+
})
|
|
2312
|
+
)
|
|
2313
|
+
);
|
|
2314
|
+
var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2181
2315
|
id: "anthropic.computer_20250124",
|
|
2182
2316
|
name: "computer",
|
|
2183
|
-
inputSchema:
|
|
2184
|
-
action: z11.enum([
|
|
2185
|
-
"key",
|
|
2186
|
-
"hold_key",
|
|
2187
|
-
"type",
|
|
2188
|
-
"cursor_position",
|
|
2189
|
-
"mouse_move",
|
|
2190
|
-
"left_mouse_down",
|
|
2191
|
-
"left_mouse_up",
|
|
2192
|
-
"left_click",
|
|
2193
|
-
"left_click_drag",
|
|
2194
|
-
"right_click",
|
|
2195
|
-
"middle_click",
|
|
2196
|
-
"double_click",
|
|
2197
|
-
"triple_click",
|
|
2198
|
-
"scroll",
|
|
2199
|
-
"wait",
|
|
2200
|
-
"screenshot"
|
|
2201
|
-
]),
|
|
2202
|
-
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2203
|
-
duration: z11.number().optional(),
|
|
2204
|
-
scroll_amount: z11.number().optional(),
|
|
2205
|
-
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2206
|
-
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2207
|
-
text: z11.string().optional()
|
|
2208
|
-
})
|
|
2317
|
+
inputSchema: computer_20250124InputSchema
|
|
2209
2318
|
});
|
|
2210
2319
|
|
|
2211
2320
|
// src/tool/text-editor_20241022.ts
|
|
2212
|
-
var
|
|
2321
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2213
2322
|
var z12 = __toESM(require("zod/v4"));
|
|
2214
|
-
var
|
|
2323
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2324
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2325
|
+
z12.object({
|
|
2326
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2327
|
+
path: z12.string(),
|
|
2328
|
+
file_text: z12.string().optional(),
|
|
2329
|
+
insert_line: z12.number().int().optional(),
|
|
2330
|
+
new_str: z12.string().optional(),
|
|
2331
|
+
old_str: z12.string().optional(),
|
|
2332
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
2333
|
+
})
|
|
2334
|
+
)
|
|
2335
|
+
);
|
|
2336
|
+
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2215
2337
|
id: "anthropic.text_editor_20241022",
|
|
2216
2338
|
name: "str_replace_editor",
|
|
2217
|
-
inputSchema:
|
|
2218
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2219
|
-
path: z12.string(),
|
|
2220
|
-
file_text: z12.string().optional(),
|
|
2221
|
-
insert_line: z12.number().int().optional(),
|
|
2222
|
-
new_str: z12.string().optional(),
|
|
2223
|
-
old_str: z12.string().optional(),
|
|
2224
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2225
|
-
})
|
|
2339
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2226
2340
|
});
|
|
2227
2341
|
|
|
2228
2342
|
// src/tool/text-editor_20250124.ts
|
|
2229
|
-
var
|
|
2343
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2230
2344
|
var z13 = __toESM(require("zod/v4"));
|
|
2231
|
-
var
|
|
2345
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2346
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
2347
|
+
z13.object({
|
|
2348
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2349
|
+
path: z13.string(),
|
|
2350
|
+
file_text: z13.string().optional(),
|
|
2351
|
+
insert_line: z13.number().int().optional(),
|
|
2352
|
+
new_str: z13.string().optional(),
|
|
2353
|
+
old_str: z13.string().optional(),
|
|
2354
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
2355
|
+
})
|
|
2356
|
+
)
|
|
2357
|
+
);
|
|
2358
|
+
var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2232
2359
|
id: "anthropic.text_editor_20250124",
|
|
2233
2360
|
name: "str_replace_editor",
|
|
2234
|
-
inputSchema:
|
|
2235
|
-
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2236
|
-
path: z13.string(),
|
|
2237
|
-
file_text: z13.string().optional(),
|
|
2238
|
-
insert_line: z13.number().int().optional(),
|
|
2239
|
-
new_str: z13.string().optional(),
|
|
2240
|
-
old_str: z13.string().optional(),
|
|
2241
|
-
view_range: z13.array(z13.number().int()).optional()
|
|
2242
|
-
})
|
|
2361
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2243
2362
|
});
|
|
2244
2363
|
|
|
2245
2364
|
// src/tool/text-editor_20250429.ts
|
|
2246
|
-
var
|
|
2365
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2247
2366
|
var z14 = __toESM(require("zod/v4"));
|
|
2248
|
-
var
|
|
2367
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2368
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
2369
|
+
z14.object({
|
|
2370
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2371
|
+
path: z14.string(),
|
|
2372
|
+
file_text: z14.string().optional(),
|
|
2373
|
+
insert_line: z14.number().int().optional(),
|
|
2374
|
+
new_str: z14.string().optional(),
|
|
2375
|
+
old_str: z14.string().optional(),
|
|
2376
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2377
|
+
})
|
|
2378
|
+
)
|
|
2379
|
+
);
|
|
2380
|
+
var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2249
2381
|
id: "anthropic.text_editor_20250429",
|
|
2250
2382
|
name: "str_replace_based_edit_tool",
|
|
2251
|
-
inputSchema:
|
|
2252
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2253
|
-
path: z14.string(),
|
|
2254
|
-
file_text: z14.string().optional(),
|
|
2255
|
-
insert_line: z14.number().int().optional(),
|
|
2256
|
-
new_str: z14.string().optional(),
|
|
2257
|
-
old_str: z14.string().optional(),
|
|
2258
|
-
view_range: z14.array(z14.number().int()).optional()
|
|
2259
|
-
})
|
|
2383
|
+
inputSchema: textEditor_20250429InputSchema
|
|
2260
2384
|
});
|
|
2261
2385
|
|
|
2262
2386
|
// src/anthropic-tools.ts
|
|
@@ -2390,11 +2514,11 @@ var anthropicTools = {
|
|
|
2390
2514
|
// src/anthropic-provider.ts
|
|
2391
2515
|
function createAnthropic(options = {}) {
|
|
2392
2516
|
var _a;
|
|
2393
|
-
const baseURL = (_a = (0,
|
|
2394
|
-
const getHeaders = () => (0,
|
|
2517
|
+
const baseURL = (_a = (0, import_provider_utils18.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2518
|
+
const getHeaders = () => (0, import_provider_utils18.withUserAgentSuffix)(
|
|
2395
2519
|
{
|
|
2396
2520
|
"anthropic-version": "2023-06-01",
|
|
2397
|
-
"x-api-key": (0,
|
|
2521
|
+
"x-api-key": (0, import_provider_utils18.loadApiKey)({
|
|
2398
2522
|
apiKey: options.apiKey,
|
|
2399
2523
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2400
2524
|
description: "Anthropic"
|
|
@@ -2410,7 +2534,7 @@ function createAnthropic(options = {}) {
|
|
|
2410
2534
|
baseURL,
|
|
2411
2535
|
headers: getHeaders,
|
|
2412
2536
|
fetch: options.fetch,
|
|
2413
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2537
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils18.generateId,
|
|
2414
2538
|
supportedUrls: () => ({
|
|
2415
2539
|
"image/*": [/^https?:\/\/.*$/]
|
|
2416
2540
|
})
|