@ai-sdk/anthropic 2.0.24 → 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 +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 ? "2.0.
|
|
44
|
+
var VERSION = true ? "2.0.25" : "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 },
|
|
@@ -694,7 +1082,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
694
1082
|
}
|
|
695
1083
|
case "reasoning": {
|
|
696
1084
|
if (sendReasoning) {
|
|
697
|
-
const reasoningMetadata = await (0,
|
|
1085
|
+
const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
|
|
698
1086
|
provider: "anthropic",
|
|
699
1087
|
providerOptions: part.providerOptions,
|
|
700
1088
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -770,7 +1158,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
770
1158
|
});
|
|
771
1159
|
break;
|
|
772
1160
|
}
|
|
773
|
-
const codeExecutionOutput =
|
|
1161
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1162
|
+
value: output.value,
|
|
1163
|
+
schema: codeExecution_20250522OutputSchema
|
|
1164
|
+
});
|
|
774
1165
|
anthropicContent.push({
|
|
775
1166
|
type: "code_execution_tool_result",
|
|
776
1167
|
tool_use_id: part.toolCallId,
|
|
@@ -793,9 +1184,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
793
1184
|
});
|
|
794
1185
|
break;
|
|
795
1186
|
}
|
|
796
|
-
const webFetchOutput =
|
|
797
|
-
output.value
|
|
798
|
-
|
|
1187
|
+
const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1188
|
+
value: output.value,
|
|
1189
|
+
schema: webFetch_20250910OutputSchema
|
|
1190
|
+
});
|
|
799
1191
|
anthropicContent.push({
|
|
800
1192
|
type: "web_fetch_tool_result",
|
|
801
1193
|
tool_use_id: part.toolCallId,
|
|
@@ -827,9 +1219,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
827
1219
|
});
|
|
828
1220
|
break;
|
|
829
1221
|
}
|
|
830
|
-
const webSearchOutput =
|
|
831
|
-
output.value
|
|
832
|
-
|
|
1222
|
+
const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1223
|
+
value: output.value,
|
|
1224
|
+
schema: webSearch_20250305OutputSchema
|
|
1225
|
+
});
|
|
833
1226
|
anthropicContent.push({
|
|
834
1227
|
type: "web_search_tool_result",
|
|
835
1228
|
tool_use_id: part.toolCallId,
|
|
@@ -936,67 +1329,15 @@ function mapAnthropicStopReason({
|
|
|
936
1329
|
}
|
|
937
1330
|
|
|
938
1331
|
// src/anthropic-messages-language-model.ts
|
|
939
|
-
var citationSchemas = {
|
|
940
|
-
webSearchResult: z7.object({
|
|
941
|
-
type: z7.literal("web_search_result_location"),
|
|
942
|
-
cited_text: z7.string(),
|
|
943
|
-
url: z7.string(),
|
|
944
|
-
title: z7.string(),
|
|
945
|
-
encrypted_index: z7.string()
|
|
946
|
-
}),
|
|
947
|
-
pageLocation: z7.object({
|
|
948
|
-
type: z7.literal("page_location"),
|
|
949
|
-
cited_text: z7.string(),
|
|
950
|
-
document_index: z7.number(),
|
|
951
|
-
document_title: z7.string().nullable(),
|
|
952
|
-
start_page_number: z7.number(),
|
|
953
|
-
end_page_number: z7.number()
|
|
954
|
-
}),
|
|
955
|
-
charLocation: z7.object({
|
|
956
|
-
type: z7.literal("char_location"),
|
|
957
|
-
cited_text: z7.string(),
|
|
958
|
-
document_index: z7.number(),
|
|
959
|
-
document_title: z7.string().nullable(),
|
|
960
|
-
start_char_index: z7.number(),
|
|
961
|
-
end_char_index: z7.number()
|
|
962
|
-
})
|
|
963
|
-
};
|
|
964
|
-
var citationSchema = z7.discriminatedUnion("type", [
|
|
965
|
-
citationSchemas.webSearchResult,
|
|
966
|
-
citationSchemas.pageLocation,
|
|
967
|
-
citationSchemas.charLocation
|
|
968
|
-
]);
|
|
969
|
-
var documentCitationSchema = z7.discriminatedUnion("type", [
|
|
970
|
-
citationSchemas.pageLocation,
|
|
971
|
-
citationSchemas.charLocation
|
|
972
|
-
]);
|
|
973
|
-
function processCitation(citation, citationDocuments, generateId3, onSource) {
|
|
974
|
-
if (citation.type === "page_location" || citation.type === "char_location") {
|
|
975
|
-
const source = createCitationSource(
|
|
976
|
-
citation,
|
|
977
|
-
citationDocuments,
|
|
978
|
-
generateId3
|
|
979
|
-
);
|
|
980
|
-
if (source) {
|
|
981
|
-
onSource(source);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
1332
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
986
1333
|
var _a;
|
|
1334
|
+
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
987
1337
|
const documentInfo = citationDocuments[citation.document_index];
|
|
988
1338
|
if (!documentInfo) {
|
|
989
|
-
return
|
|
1339
|
+
return;
|
|
990
1340
|
}
|
|
991
|
-
const providerMetadata = citation.type === "page_location" ? {
|
|
992
|
-
citedText: citation.cited_text,
|
|
993
|
-
startPageNumber: citation.start_page_number,
|
|
994
|
-
endPageNumber: citation.end_page_number
|
|
995
|
-
} : {
|
|
996
|
-
citedText: citation.cited_text,
|
|
997
|
-
startCharIndex: citation.start_char_index,
|
|
998
|
-
endCharIndex: citation.end_char_index
|
|
999
|
-
};
|
|
1000
1341
|
return {
|
|
1001
1342
|
type: "source",
|
|
1002
1343
|
sourceType: "document",
|
|
@@ -1005,7 +1346,15 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
1005
1346
|
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
1006
1347
|
filename: documentInfo.filename,
|
|
1007
1348
|
providerMetadata: {
|
|
1008
|
-
anthropic:
|
|
1349
|
+
anthropic: citation.type === "page_location" ? {
|
|
1350
|
+
citedText: citation.cited_text,
|
|
1351
|
+
startPageNumber: citation.start_page_number,
|
|
1352
|
+
endPageNumber: citation.end_page_number
|
|
1353
|
+
} : {
|
|
1354
|
+
citedText: citation.cited_text,
|
|
1355
|
+
startCharIndex: citation.start_char_index,
|
|
1356
|
+
endCharIndex: citation.end_char_index
|
|
1357
|
+
}
|
|
1009
1358
|
}
|
|
1010
1359
|
};
|
|
1011
1360
|
}
|
|
@@ -1015,7 +1364,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1015
1364
|
var _a;
|
|
1016
1365
|
this.modelId = modelId;
|
|
1017
1366
|
this.config = config;
|
|
1018
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1367
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
|
|
1019
1368
|
}
|
|
1020
1369
|
supportsUrl(url) {
|
|
1021
1370
|
return url.protocol === "https:";
|
|
@@ -1084,7 +1433,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1084
1433
|
description: "Respond with a JSON object.",
|
|
1085
1434
|
inputSchema: responseFormat.schema
|
|
1086
1435
|
} : void 0;
|
|
1087
|
-
const anthropicOptions = await (0,
|
|
1436
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1088
1437
|
provider: "anthropic",
|
|
1089
1438
|
providerOptions,
|
|
1090
1439
|
schema: anthropicProviderOptions
|
|
@@ -1150,7 +1499,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1150
1499
|
toolChoice: anthropicToolChoice,
|
|
1151
1500
|
toolWarnings,
|
|
1152
1501
|
betas: toolsBetas
|
|
1153
|
-
} = prepareTools(
|
|
1502
|
+
} = await prepareTools(
|
|
1154
1503
|
jsonResponseTool != null ? {
|
|
1155
1504
|
tools: [jsonResponseTool],
|
|
1156
1505
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
@@ -1176,8 +1525,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1176
1525
|
betas,
|
|
1177
1526
|
headers
|
|
1178
1527
|
}) {
|
|
1179
|
-
return (0,
|
|
1180
|
-
await (0,
|
|
1528
|
+
return (0, import_provider_utils10.combineHeaders)(
|
|
1529
|
+
await (0, import_provider_utils10.resolve)(this.config.headers),
|
|
1181
1530
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1182
1531
|
headers
|
|
1183
1532
|
);
|
|
@@ -1221,12 +1570,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1221
1570
|
responseHeaders,
|
|
1222
1571
|
value: response,
|
|
1223
1572
|
rawValue: rawResponse
|
|
1224
|
-
} = await (0,
|
|
1573
|
+
} = await (0, import_provider_utils10.postJsonToApi)({
|
|
1225
1574
|
url: this.buildRequestUrl(false),
|
|
1226
1575
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1227
1576
|
body: this.transformRequestBody(args),
|
|
1228
1577
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1229
|
-
successfulResponseHandler: (0,
|
|
1578
|
+
successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
|
|
1230
1579
|
anthropicMessagesResponseSchema
|
|
1231
1580
|
),
|
|
1232
1581
|
abortSignal: options.abortSignal,
|
|
@@ -1240,12 +1589,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1240
1589
|
content.push({ type: "text", text: part.text });
|
|
1241
1590
|
if (part.citations) {
|
|
1242
1591
|
for (const citation of part.citations) {
|
|
1243
|
-
|
|
1592
|
+
const source = createCitationSource(
|
|
1244
1593
|
citation,
|
|
1245
1594
|
citationDocuments,
|
|
1246
|
-
this.generateId
|
|
1247
|
-
(source) => content.push(source)
|
|
1595
|
+
this.generateId
|
|
1248
1596
|
);
|
|
1597
|
+
if (source) {
|
|
1598
|
+
content.push(source);
|
|
1599
|
+
}
|
|
1249
1600
|
}
|
|
1250
1601
|
}
|
|
1251
1602
|
}
|
|
@@ -1451,12 +1802,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1451
1802
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1452
1803
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1453
1804
|
const body = { ...args, stream: true };
|
|
1454
|
-
const { responseHeaders, value: response } = await (0,
|
|
1805
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
|
|
1455
1806
|
url: this.buildRequestUrl(true),
|
|
1456
1807
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1457
1808
|
body: this.transformRequestBody(body),
|
|
1458
1809
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1459
|
-
successfulResponseHandler: (0,
|
|
1810
|
+
successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
|
|
1460
1811
|
anthropicMessagesChunkSchema
|
|
1461
1812
|
),
|
|
1462
1813
|
abortSignal: options.abortSignal,
|
|
@@ -1782,12 +2133,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1782
2133
|
}
|
|
1783
2134
|
case "citations_delta": {
|
|
1784
2135
|
const citation = value.delta.citation;
|
|
1785
|
-
|
|
2136
|
+
const source = createCitationSource(
|
|
1786
2137
|
citation,
|
|
1787
2138
|
citationDocuments,
|
|
1788
|
-
generateId3
|
|
1789
|
-
(source) => controller.enqueue(source)
|
|
2139
|
+
generateId3
|
|
1790
2140
|
);
|
|
2141
|
+
if (source) {
|
|
2142
|
+
controller.enqueue(source);
|
|
2143
|
+
}
|
|
1791
2144
|
return;
|
|
1792
2145
|
}
|
|
1793
2146
|
default: {
|
|
@@ -1858,402 +2211,173 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1858
2211
|
};
|
|
1859
2212
|
}
|
|
1860
2213
|
};
|
|
1861
|
-
var anthropicMessagesResponseSchema = z7.object({
|
|
1862
|
-
type: z7.literal("message"),
|
|
1863
|
-
id: z7.string().nullish(),
|
|
1864
|
-
model: z7.string().nullish(),
|
|
1865
|
-
content: z7.array(
|
|
1866
|
-
z7.discriminatedUnion("type", [
|
|
1867
|
-
z7.object({
|
|
1868
|
-
type: z7.literal("text"),
|
|
1869
|
-
text: z7.string(),
|
|
1870
|
-
citations: z7.array(citationSchema).optional()
|
|
1871
|
-
}),
|
|
1872
|
-
z7.object({
|
|
1873
|
-
type: z7.literal("thinking"),
|
|
1874
|
-
thinking: z7.string(),
|
|
1875
|
-
signature: z7.string()
|
|
1876
|
-
}),
|
|
1877
|
-
z7.object({
|
|
1878
|
-
type: z7.literal("redacted_thinking"),
|
|
1879
|
-
data: z7.string()
|
|
1880
|
-
}),
|
|
1881
|
-
z7.object({
|
|
1882
|
-
type: z7.literal("tool_use"),
|
|
1883
|
-
id: z7.string(),
|
|
1884
|
-
name: z7.string(),
|
|
1885
|
-
input: z7.unknown()
|
|
1886
|
-
}),
|
|
1887
|
-
z7.object({
|
|
1888
|
-
type: z7.literal("server_tool_use"),
|
|
1889
|
-
id: z7.string(),
|
|
1890
|
-
name: z7.string(),
|
|
1891
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
1892
|
-
}),
|
|
1893
|
-
z7.object({
|
|
1894
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
1895
|
-
tool_use_id: z7.string(),
|
|
1896
|
-
content: z7.union([
|
|
1897
|
-
z7.object({
|
|
1898
|
-
type: z7.literal("web_fetch_result"),
|
|
1899
|
-
url: z7.string(),
|
|
1900
|
-
retrieved_at: z7.string(),
|
|
1901
|
-
content: z7.object({
|
|
1902
|
-
type: z7.literal("document"),
|
|
1903
|
-
title: z7.string().nullable(),
|
|
1904
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1905
|
-
source: z7.object({
|
|
1906
|
-
type: z7.literal("text"),
|
|
1907
|
-
media_type: z7.string(),
|
|
1908
|
-
data: z7.string()
|
|
1909
|
-
})
|
|
1910
|
-
})
|
|
1911
|
-
}),
|
|
1912
|
-
z7.object({
|
|
1913
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
1914
|
-
error_code: z7.string()
|
|
1915
|
-
})
|
|
1916
|
-
])
|
|
1917
|
-
}),
|
|
1918
|
-
z7.object({
|
|
1919
|
-
type: z7.literal("web_search_tool_result"),
|
|
1920
|
-
tool_use_id: z7.string(),
|
|
1921
|
-
content: z7.union([
|
|
1922
|
-
z7.array(
|
|
1923
|
-
z7.object({
|
|
1924
|
-
type: z7.literal("web_search_result"),
|
|
1925
|
-
url: z7.string(),
|
|
1926
|
-
title: z7.string(),
|
|
1927
|
-
encrypted_content: z7.string(),
|
|
1928
|
-
page_age: z7.string().nullish()
|
|
1929
|
-
})
|
|
1930
|
-
),
|
|
1931
|
-
z7.object({
|
|
1932
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
1933
|
-
error_code: z7.string()
|
|
1934
|
-
})
|
|
1935
|
-
])
|
|
1936
|
-
}),
|
|
1937
|
-
z7.object({
|
|
1938
|
-
type: z7.literal("code_execution_tool_result"),
|
|
1939
|
-
tool_use_id: z7.string(),
|
|
1940
|
-
content: z7.union([
|
|
1941
|
-
z7.object({
|
|
1942
|
-
type: z7.literal("code_execution_result"),
|
|
1943
|
-
stdout: z7.string(),
|
|
1944
|
-
stderr: z7.string(),
|
|
1945
|
-
return_code: z7.number()
|
|
1946
|
-
}),
|
|
1947
|
-
z7.object({
|
|
1948
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
1949
|
-
error_code: z7.string()
|
|
1950
|
-
})
|
|
1951
|
-
])
|
|
1952
|
-
})
|
|
1953
|
-
])
|
|
1954
|
-
),
|
|
1955
|
-
stop_reason: z7.string().nullish(),
|
|
1956
|
-
stop_sequence: z7.string().nullish(),
|
|
1957
|
-
usage: z7.looseObject({
|
|
1958
|
-
input_tokens: z7.number(),
|
|
1959
|
-
output_tokens: z7.number(),
|
|
1960
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1961
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1962
|
-
})
|
|
1963
|
-
});
|
|
1964
|
-
var anthropicMessagesChunkSchema = z7.discriminatedUnion("type", [
|
|
1965
|
-
z7.object({
|
|
1966
|
-
type: z7.literal("message_start"),
|
|
1967
|
-
message: z7.object({
|
|
1968
|
-
id: z7.string().nullish(),
|
|
1969
|
-
model: z7.string().nullish(),
|
|
1970
|
-
usage: z7.looseObject({
|
|
1971
|
-
input_tokens: z7.number(),
|
|
1972
|
-
cache_creation_input_tokens: z7.number().nullish(),
|
|
1973
|
-
cache_read_input_tokens: z7.number().nullish()
|
|
1974
|
-
})
|
|
1975
|
-
})
|
|
1976
|
-
}),
|
|
1977
|
-
z7.object({
|
|
1978
|
-
type: z7.literal("content_block_start"),
|
|
1979
|
-
index: z7.number(),
|
|
1980
|
-
content_block: z7.discriminatedUnion("type", [
|
|
1981
|
-
z7.object({
|
|
1982
|
-
type: z7.literal("text"),
|
|
1983
|
-
text: z7.string()
|
|
1984
|
-
}),
|
|
1985
|
-
z7.object({
|
|
1986
|
-
type: z7.literal("thinking"),
|
|
1987
|
-
thinking: z7.string()
|
|
1988
|
-
}),
|
|
1989
|
-
z7.object({
|
|
1990
|
-
type: z7.literal("tool_use"),
|
|
1991
|
-
id: z7.string(),
|
|
1992
|
-
name: z7.string()
|
|
1993
|
-
}),
|
|
1994
|
-
z7.object({
|
|
1995
|
-
type: z7.literal("redacted_thinking"),
|
|
1996
|
-
data: z7.string()
|
|
1997
|
-
}),
|
|
1998
|
-
z7.object({
|
|
1999
|
-
type: z7.literal("server_tool_use"),
|
|
2000
|
-
id: z7.string(),
|
|
2001
|
-
name: z7.string(),
|
|
2002
|
-
input: z7.record(z7.string(), z7.unknown()).nullish()
|
|
2003
|
-
}),
|
|
2004
|
-
z7.object({
|
|
2005
|
-
type: z7.literal("web_fetch_tool_result"),
|
|
2006
|
-
tool_use_id: z7.string(),
|
|
2007
|
-
content: z7.union([
|
|
2008
|
-
z7.object({
|
|
2009
|
-
type: z7.literal("web_fetch_result"),
|
|
2010
|
-
url: z7.string(),
|
|
2011
|
-
retrieved_at: z7.string(),
|
|
2012
|
-
content: z7.object({
|
|
2013
|
-
type: z7.literal("document"),
|
|
2014
|
-
title: z7.string().nullable(),
|
|
2015
|
-
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
2016
|
-
source: z7.object({
|
|
2017
|
-
type: z7.literal("text"),
|
|
2018
|
-
media_type: z7.string(),
|
|
2019
|
-
data: z7.string()
|
|
2020
|
-
})
|
|
2021
|
-
})
|
|
2022
|
-
}),
|
|
2023
|
-
z7.object({
|
|
2024
|
-
type: z7.literal("web_fetch_tool_result_error"),
|
|
2025
|
-
error_code: z7.string()
|
|
2026
|
-
})
|
|
2027
|
-
])
|
|
2028
|
-
}),
|
|
2029
|
-
z7.object({
|
|
2030
|
-
type: z7.literal("web_search_tool_result"),
|
|
2031
|
-
tool_use_id: z7.string(),
|
|
2032
|
-
content: z7.union([
|
|
2033
|
-
z7.array(
|
|
2034
|
-
z7.object({
|
|
2035
|
-
type: z7.literal("web_search_result"),
|
|
2036
|
-
url: z7.string(),
|
|
2037
|
-
title: z7.string(),
|
|
2038
|
-
encrypted_content: z7.string(),
|
|
2039
|
-
page_age: z7.string().nullish()
|
|
2040
|
-
})
|
|
2041
|
-
),
|
|
2042
|
-
z7.object({
|
|
2043
|
-
type: z7.literal("web_search_tool_result_error"),
|
|
2044
|
-
error_code: z7.string()
|
|
2045
|
-
})
|
|
2046
|
-
])
|
|
2047
|
-
}),
|
|
2048
|
-
z7.object({
|
|
2049
|
-
type: z7.literal("code_execution_tool_result"),
|
|
2050
|
-
tool_use_id: z7.string(),
|
|
2051
|
-
content: z7.union([
|
|
2052
|
-
z7.object({
|
|
2053
|
-
type: z7.literal("code_execution_result"),
|
|
2054
|
-
stdout: z7.string(),
|
|
2055
|
-
stderr: z7.string(),
|
|
2056
|
-
return_code: z7.number()
|
|
2057
|
-
}),
|
|
2058
|
-
z7.object({
|
|
2059
|
-
type: z7.literal("code_execution_tool_result_error"),
|
|
2060
|
-
error_code: z7.string()
|
|
2061
|
-
})
|
|
2062
|
-
])
|
|
2063
|
-
})
|
|
2064
|
-
])
|
|
2065
|
-
}),
|
|
2066
|
-
z7.object({
|
|
2067
|
-
type: z7.literal("content_block_delta"),
|
|
2068
|
-
index: z7.number(),
|
|
2069
|
-
delta: z7.discriminatedUnion("type", [
|
|
2070
|
-
z7.object({
|
|
2071
|
-
type: z7.literal("input_json_delta"),
|
|
2072
|
-
partial_json: z7.string()
|
|
2073
|
-
}),
|
|
2074
|
-
z7.object({
|
|
2075
|
-
type: z7.literal("text_delta"),
|
|
2076
|
-
text: z7.string()
|
|
2077
|
-
}),
|
|
2078
|
-
z7.object({
|
|
2079
|
-
type: z7.literal("thinking_delta"),
|
|
2080
|
-
thinking: z7.string()
|
|
2081
|
-
}),
|
|
2082
|
-
z7.object({
|
|
2083
|
-
type: z7.literal("signature_delta"),
|
|
2084
|
-
signature: z7.string()
|
|
2085
|
-
}),
|
|
2086
|
-
z7.object({
|
|
2087
|
-
type: z7.literal("citations_delta"),
|
|
2088
|
-
citation: citationSchema
|
|
2089
|
-
})
|
|
2090
|
-
])
|
|
2091
|
-
}),
|
|
2092
|
-
z7.object({
|
|
2093
|
-
type: z7.literal("content_block_stop"),
|
|
2094
|
-
index: z7.number()
|
|
2095
|
-
}),
|
|
2096
|
-
z7.object({
|
|
2097
|
-
type: z7.literal("error"),
|
|
2098
|
-
error: z7.object({
|
|
2099
|
-
type: z7.string(),
|
|
2100
|
-
message: z7.string()
|
|
2101
|
-
})
|
|
2102
|
-
}),
|
|
2103
|
-
z7.object({
|
|
2104
|
-
type: z7.literal("message_delta"),
|
|
2105
|
-
delta: z7.object({
|
|
2106
|
-
stop_reason: z7.string().nullish(),
|
|
2107
|
-
stop_sequence: z7.string().nullish()
|
|
2108
|
-
}),
|
|
2109
|
-
usage: z7.looseObject({
|
|
2110
|
-
output_tokens: z7.number(),
|
|
2111
|
-
cache_creation_input_tokens: z7.number().nullish()
|
|
2112
|
-
})
|
|
2113
|
-
}),
|
|
2114
|
-
z7.object({
|
|
2115
|
-
type: z7.literal("message_stop")
|
|
2116
|
-
}),
|
|
2117
|
-
z7.object({
|
|
2118
|
-
type: z7.literal("ping")
|
|
2119
|
-
})
|
|
2120
|
-
]);
|
|
2121
|
-
var anthropicReasoningMetadataSchema = z7.object({
|
|
2122
|
-
signature: z7.string().optional(),
|
|
2123
|
-
redactedData: z7.string().optional()
|
|
2124
|
-
});
|
|
2125
2214
|
|
|
2126
2215
|
// src/tool/bash_20241022.ts
|
|
2127
|
-
var
|
|
2128
|
-
var
|
|
2129
|
-
var
|
|
2216
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2217
|
+
var z8 = __toESM(require("zod/v4"));
|
|
2218
|
+
var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2219
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2220
|
+
z8.object({
|
|
2221
|
+
command: z8.string(),
|
|
2222
|
+
restart: z8.boolean().optional()
|
|
2223
|
+
})
|
|
2224
|
+
)
|
|
2225
|
+
);
|
|
2226
|
+
var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
2130
2227
|
id: "anthropic.bash_20241022",
|
|
2131
2228
|
name: "bash",
|
|
2132
|
-
inputSchema:
|
|
2133
|
-
command: import_v4.default.string(),
|
|
2134
|
-
restart: import_v4.default.boolean().optional()
|
|
2135
|
-
})
|
|
2229
|
+
inputSchema: bash_20241022InputSchema
|
|
2136
2230
|
});
|
|
2137
2231
|
|
|
2138
2232
|
// src/tool/bash_20250124.ts
|
|
2139
|
-
var
|
|
2140
|
-
var
|
|
2141
|
-
var
|
|
2233
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2234
|
+
var z9 = __toESM(require("zod/v4"));
|
|
2235
|
+
var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2236
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2237
|
+
z9.object({
|
|
2238
|
+
command: z9.string(),
|
|
2239
|
+
restart: z9.boolean().optional()
|
|
2240
|
+
})
|
|
2241
|
+
)
|
|
2242
|
+
);
|
|
2243
|
+
var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2142
2244
|
id: "anthropic.bash_20250124",
|
|
2143
2245
|
name: "bash",
|
|
2144
|
-
inputSchema:
|
|
2145
|
-
command: import_v42.default.string(),
|
|
2146
|
-
restart: import_v42.default.boolean().optional()
|
|
2147
|
-
})
|
|
2246
|
+
inputSchema: bash_20250124InputSchema
|
|
2148
2247
|
});
|
|
2149
2248
|
|
|
2150
2249
|
// src/tool/computer_20241022.ts
|
|
2151
|
-
var
|
|
2250
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2152
2251
|
var z10 = __toESM(require("zod/v4"));
|
|
2153
|
-
var
|
|
2252
|
+
var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2253
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2254
|
+
z10.object({
|
|
2255
|
+
action: z10.enum([
|
|
2256
|
+
"key",
|
|
2257
|
+
"type",
|
|
2258
|
+
"mouse_move",
|
|
2259
|
+
"left_click",
|
|
2260
|
+
"left_click_drag",
|
|
2261
|
+
"right_click",
|
|
2262
|
+
"middle_click",
|
|
2263
|
+
"double_click",
|
|
2264
|
+
"screenshot",
|
|
2265
|
+
"cursor_position"
|
|
2266
|
+
]),
|
|
2267
|
+
coordinate: z10.array(z10.number().int()).optional(),
|
|
2268
|
+
text: z10.string().optional()
|
|
2269
|
+
})
|
|
2270
|
+
)
|
|
2271
|
+
);
|
|
2272
|
+
var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2154
2273
|
id: "anthropic.computer_20241022",
|
|
2155
2274
|
name: "computer",
|
|
2156
|
-
inputSchema:
|
|
2157
|
-
action: z10.enum([
|
|
2158
|
-
"key",
|
|
2159
|
-
"type",
|
|
2160
|
-
"mouse_move",
|
|
2161
|
-
"left_click",
|
|
2162
|
-
"left_click_drag",
|
|
2163
|
-
"right_click",
|
|
2164
|
-
"middle_click",
|
|
2165
|
-
"double_click",
|
|
2166
|
-
"screenshot",
|
|
2167
|
-
"cursor_position"
|
|
2168
|
-
]),
|
|
2169
|
-
coordinate: z10.array(z10.number().int()).optional(),
|
|
2170
|
-
text: z10.string().optional()
|
|
2171
|
-
})
|
|
2275
|
+
inputSchema: computer_20241022InputSchema
|
|
2172
2276
|
});
|
|
2173
2277
|
|
|
2174
2278
|
// src/tool/computer_20250124.ts
|
|
2175
|
-
var
|
|
2279
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2176
2280
|
var z11 = __toESM(require("zod/v4"));
|
|
2177
|
-
var
|
|
2281
|
+
var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2282
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2283
|
+
z11.object({
|
|
2284
|
+
action: z11.enum([
|
|
2285
|
+
"key",
|
|
2286
|
+
"hold_key",
|
|
2287
|
+
"type",
|
|
2288
|
+
"cursor_position",
|
|
2289
|
+
"mouse_move",
|
|
2290
|
+
"left_mouse_down",
|
|
2291
|
+
"left_mouse_up",
|
|
2292
|
+
"left_click",
|
|
2293
|
+
"left_click_drag",
|
|
2294
|
+
"right_click",
|
|
2295
|
+
"middle_click",
|
|
2296
|
+
"double_click",
|
|
2297
|
+
"triple_click",
|
|
2298
|
+
"scroll",
|
|
2299
|
+
"wait",
|
|
2300
|
+
"screenshot"
|
|
2301
|
+
]),
|
|
2302
|
+
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2303
|
+
duration: z11.number().optional(),
|
|
2304
|
+
scroll_amount: z11.number().optional(),
|
|
2305
|
+
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2306
|
+
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2307
|
+
text: z11.string().optional()
|
|
2308
|
+
})
|
|
2309
|
+
)
|
|
2310
|
+
);
|
|
2311
|
+
var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2178
2312
|
id: "anthropic.computer_20250124",
|
|
2179
2313
|
name: "computer",
|
|
2180
|
-
inputSchema:
|
|
2181
|
-
action: z11.enum([
|
|
2182
|
-
"key",
|
|
2183
|
-
"hold_key",
|
|
2184
|
-
"type",
|
|
2185
|
-
"cursor_position",
|
|
2186
|
-
"mouse_move",
|
|
2187
|
-
"left_mouse_down",
|
|
2188
|
-
"left_mouse_up",
|
|
2189
|
-
"left_click",
|
|
2190
|
-
"left_click_drag",
|
|
2191
|
-
"right_click",
|
|
2192
|
-
"middle_click",
|
|
2193
|
-
"double_click",
|
|
2194
|
-
"triple_click",
|
|
2195
|
-
"scroll",
|
|
2196
|
-
"wait",
|
|
2197
|
-
"screenshot"
|
|
2198
|
-
]),
|
|
2199
|
-
coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2200
|
-
duration: z11.number().optional(),
|
|
2201
|
-
scroll_amount: z11.number().optional(),
|
|
2202
|
-
scroll_direction: z11.enum(["up", "down", "left", "right"]).optional(),
|
|
2203
|
-
start_coordinate: z11.tuple([z11.number().int(), z11.number().int()]).optional(),
|
|
2204
|
-
text: z11.string().optional()
|
|
2205
|
-
})
|
|
2314
|
+
inputSchema: computer_20250124InputSchema
|
|
2206
2315
|
});
|
|
2207
2316
|
|
|
2208
2317
|
// src/tool/text-editor_20241022.ts
|
|
2209
|
-
var
|
|
2318
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2210
2319
|
var z12 = __toESM(require("zod/v4"));
|
|
2211
|
-
var
|
|
2320
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2321
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2322
|
+
z12.object({
|
|
2323
|
+
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2324
|
+
path: z12.string(),
|
|
2325
|
+
file_text: z12.string().optional(),
|
|
2326
|
+
insert_line: z12.number().int().optional(),
|
|
2327
|
+
new_str: z12.string().optional(),
|
|
2328
|
+
old_str: z12.string().optional(),
|
|
2329
|
+
view_range: z12.array(z12.number().int()).optional()
|
|
2330
|
+
})
|
|
2331
|
+
)
|
|
2332
|
+
);
|
|
2333
|
+
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2212
2334
|
id: "anthropic.text_editor_20241022",
|
|
2213
2335
|
name: "str_replace_editor",
|
|
2214
|
-
inputSchema:
|
|
2215
|
-
command: z12.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2216
|
-
path: z12.string(),
|
|
2217
|
-
file_text: z12.string().optional(),
|
|
2218
|
-
insert_line: z12.number().int().optional(),
|
|
2219
|
-
new_str: z12.string().optional(),
|
|
2220
|
-
old_str: z12.string().optional(),
|
|
2221
|
-
view_range: z12.array(z12.number().int()).optional()
|
|
2222
|
-
})
|
|
2336
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2223
2337
|
});
|
|
2224
2338
|
|
|
2225
2339
|
// src/tool/text-editor_20250124.ts
|
|
2226
|
-
var
|
|
2340
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2227
2341
|
var z13 = __toESM(require("zod/v4"));
|
|
2228
|
-
var
|
|
2342
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2343
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
2344
|
+
z13.object({
|
|
2345
|
+
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2346
|
+
path: z13.string(),
|
|
2347
|
+
file_text: z13.string().optional(),
|
|
2348
|
+
insert_line: z13.number().int().optional(),
|
|
2349
|
+
new_str: z13.string().optional(),
|
|
2350
|
+
old_str: z13.string().optional(),
|
|
2351
|
+
view_range: z13.array(z13.number().int()).optional()
|
|
2352
|
+
})
|
|
2353
|
+
)
|
|
2354
|
+
);
|
|
2355
|
+
var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2229
2356
|
id: "anthropic.text_editor_20250124",
|
|
2230
2357
|
name: "str_replace_editor",
|
|
2231
|
-
inputSchema:
|
|
2232
|
-
command: z13.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2233
|
-
path: z13.string(),
|
|
2234
|
-
file_text: z13.string().optional(),
|
|
2235
|
-
insert_line: z13.number().int().optional(),
|
|
2236
|
-
new_str: z13.string().optional(),
|
|
2237
|
-
old_str: z13.string().optional(),
|
|
2238
|
-
view_range: z13.array(z13.number().int()).optional()
|
|
2239
|
-
})
|
|
2358
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2240
2359
|
});
|
|
2241
2360
|
|
|
2242
2361
|
// src/tool/text-editor_20250429.ts
|
|
2243
|
-
var
|
|
2362
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2244
2363
|
var z14 = __toESM(require("zod/v4"));
|
|
2245
|
-
var
|
|
2364
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2365
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
2366
|
+
z14.object({
|
|
2367
|
+
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2368
|
+
path: z14.string(),
|
|
2369
|
+
file_text: z14.string().optional(),
|
|
2370
|
+
insert_line: z14.number().int().optional(),
|
|
2371
|
+
new_str: z14.string().optional(),
|
|
2372
|
+
old_str: z14.string().optional(),
|
|
2373
|
+
view_range: z14.array(z14.number().int()).optional()
|
|
2374
|
+
})
|
|
2375
|
+
)
|
|
2376
|
+
);
|
|
2377
|
+
var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2246
2378
|
id: "anthropic.text_editor_20250429",
|
|
2247
2379
|
name: "str_replace_based_edit_tool",
|
|
2248
|
-
inputSchema:
|
|
2249
|
-
command: z14.enum(["view", "create", "str_replace", "insert"]),
|
|
2250
|
-
path: z14.string(),
|
|
2251
|
-
file_text: z14.string().optional(),
|
|
2252
|
-
insert_line: z14.number().int().optional(),
|
|
2253
|
-
new_str: z14.string().optional(),
|
|
2254
|
-
old_str: z14.string().optional(),
|
|
2255
|
-
view_range: z14.array(z14.number().int()).optional()
|
|
2256
|
-
})
|
|
2380
|
+
inputSchema: textEditor_20250429InputSchema
|
|
2257
2381
|
});
|
|
2258
2382
|
|
|
2259
2383
|
// src/anthropic-tools.ts
|
|
@@ -2387,11 +2511,11 @@ var anthropicTools = {
|
|
|
2387
2511
|
// src/anthropic-provider.ts
|
|
2388
2512
|
function createAnthropic(options = {}) {
|
|
2389
2513
|
var _a;
|
|
2390
|
-
const baseURL = (_a = (0,
|
|
2391
|
-
const getHeaders = () => (0,
|
|
2514
|
+
const baseURL = (_a = (0, import_provider_utils18.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2515
|
+
const getHeaders = () => (0, import_provider_utils18.withUserAgentSuffix)(
|
|
2392
2516
|
{
|
|
2393
2517
|
"anthropic-version": "2023-06-01",
|
|
2394
|
-
"x-api-key": (0,
|
|
2518
|
+
"x-api-key": (0, import_provider_utils18.loadApiKey)({
|
|
2395
2519
|
apiKey: options.apiKey,
|
|
2396
2520
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2397
2521
|
description: "Anthropic"
|
|
@@ -2407,7 +2531,7 @@ function createAnthropic(options = {}) {
|
|
|
2407
2531
|
baseURL,
|
|
2408
2532
|
headers: getHeaders,
|
|
2409
2533
|
fetch: options.fetch,
|
|
2410
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2534
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils18.generateId,
|
|
2411
2535
|
supportedUrls: () => ({
|
|
2412
2536
|
"image/*": [/^https?:\/\/.*$/]
|
|
2413
2537
|
})
|