@ai-sdk/anthropic 2.0.24 → 2.0.26
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 +13 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +693 -579
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +711 -539
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +687 -573
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +710 -538
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -38,74 +28,407 @@ module.exports = __toCommonJS(src_exports);
|
|
|
38
28
|
|
|
39
29
|
// src/anthropic-provider.ts
|
|
40
30
|
var import_provider4 = require("@ai-sdk/provider");
|
|
41
|
-
var
|
|
31
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
42
32
|
|
|
43
33
|
// src/version.ts
|
|
44
|
-
var VERSION = true ? "2.0.
|
|
34
|
+
var VERSION = true ? "2.0.26" : "0.0.0-test";
|
|
45
35
|
|
|
46
36
|
// src/anthropic-messages-language-model.ts
|
|
47
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
48
|
-
var
|
|
49
|
-
var z7 = __toESM(require("zod/v4"));
|
|
38
|
+
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
50
39
|
|
|
51
40
|
// src/anthropic-error.ts
|
|
52
41
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
53
|
-
var
|
|
54
|
-
var anthropicErrorDataSchema =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
var import_v4 = require("zod/v4");
|
|
43
|
+
var anthropicErrorDataSchema = (0, import_provider_utils.lazySchema)(
|
|
44
|
+
() => (0, import_provider_utils.zodSchema)(
|
|
45
|
+
import_v4.z.object({
|
|
46
|
+
type: import_v4.z.literal("error"),
|
|
47
|
+
error: import_v4.z.object({
|
|
48
|
+
type: import_v4.z.string(),
|
|
49
|
+
message: import_v4.z.string()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
);
|
|
61
54
|
var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
62
55
|
errorSchema: anthropicErrorDataSchema,
|
|
63
56
|
errorToMessage: (data) => data.error.message
|
|
64
57
|
});
|
|
65
58
|
|
|
59
|
+
// src/anthropic-messages-api.ts
|
|
60
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
61
|
+
var import_v42 = require("zod/v4");
|
|
62
|
+
var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
63
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
64
|
+
import_v42.z.object({
|
|
65
|
+
type: import_v42.z.literal("message"),
|
|
66
|
+
id: import_v42.z.string().nullish(),
|
|
67
|
+
model: import_v42.z.string().nullish(),
|
|
68
|
+
content: import_v42.z.array(
|
|
69
|
+
import_v42.z.discriminatedUnion("type", [
|
|
70
|
+
import_v42.z.object({
|
|
71
|
+
type: import_v42.z.literal("text"),
|
|
72
|
+
text: import_v42.z.string(),
|
|
73
|
+
citations: import_v42.z.array(
|
|
74
|
+
import_v42.z.discriminatedUnion("type", [
|
|
75
|
+
import_v42.z.object({
|
|
76
|
+
type: import_v42.z.literal("web_search_result_location"),
|
|
77
|
+
cited_text: import_v42.z.string(),
|
|
78
|
+
url: import_v42.z.string(),
|
|
79
|
+
title: import_v42.z.string(),
|
|
80
|
+
encrypted_index: import_v42.z.string()
|
|
81
|
+
}),
|
|
82
|
+
import_v42.z.object({
|
|
83
|
+
type: import_v42.z.literal("page_location"),
|
|
84
|
+
cited_text: import_v42.z.string(),
|
|
85
|
+
document_index: import_v42.z.number(),
|
|
86
|
+
document_title: import_v42.z.string().nullable(),
|
|
87
|
+
start_page_number: import_v42.z.number(),
|
|
88
|
+
end_page_number: import_v42.z.number()
|
|
89
|
+
}),
|
|
90
|
+
import_v42.z.object({
|
|
91
|
+
type: import_v42.z.literal("char_location"),
|
|
92
|
+
cited_text: import_v42.z.string(),
|
|
93
|
+
document_index: import_v42.z.number(),
|
|
94
|
+
document_title: import_v42.z.string().nullable(),
|
|
95
|
+
start_char_index: import_v42.z.number(),
|
|
96
|
+
end_char_index: import_v42.z.number()
|
|
97
|
+
})
|
|
98
|
+
])
|
|
99
|
+
).optional()
|
|
100
|
+
}),
|
|
101
|
+
import_v42.z.object({
|
|
102
|
+
type: import_v42.z.literal("thinking"),
|
|
103
|
+
thinking: import_v42.z.string(),
|
|
104
|
+
signature: import_v42.z.string()
|
|
105
|
+
}),
|
|
106
|
+
import_v42.z.object({
|
|
107
|
+
type: import_v42.z.literal("redacted_thinking"),
|
|
108
|
+
data: import_v42.z.string()
|
|
109
|
+
}),
|
|
110
|
+
import_v42.z.object({
|
|
111
|
+
type: import_v42.z.literal("tool_use"),
|
|
112
|
+
id: import_v42.z.string(),
|
|
113
|
+
name: import_v42.z.string(),
|
|
114
|
+
input: import_v42.z.unknown()
|
|
115
|
+
}),
|
|
116
|
+
import_v42.z.object({
|
|
117
|
+
type: import_v42.z.literal("server_tool_use"),
|
|
118
|
+
id: import_v42.z.string(),
|
|
119
|
+
name: import_v42.z.string(),
|
|
120
|
+
input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish()
|
|
121
|
+
}),
|
|
122
|
+
import_v42.z.object({
|
|
123
|
+
type: import_v42.z.literal("web_fetch_tool_result"),
|
|
124
|
+
tool_use_id: import_v42.z.string(),
|
|
125
|
+
content: import_v42.z.union([
|
|
126
|
+
import_v42.z.object({
|
|
127
|
+
type: import_v42.z.literal("web_fetch_result"),
|
|
128
|
+
url: import_v42.z.string(),
|
|
129
|
+
retrieved_at: import_v42.z.string(),
|
|
130
|
+
content: import_v42.z.object({
|
|
131
|
+
type: import_v42.z.literal("document"),
|
|
132
|
+
title: import_v42.z.string().nullable(),
|
|
133
|
+
citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
|
|
134
|
+
source: import_v42.z.object({
|
|
135
|
+
type: import_v42.z.literal("text"),
|
|
136
|
+
media_type: import_v42.z.string(),
|
|
137
|
+
data: import_v42.z.string()
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
import_v42.z.object({
|
|
142
|
+
type: import_v42.z.literal("web_fetch_tool_result_error"),
|
|
143
|
+
error_code: import_v42.z.string()
|
|
144
|
+
})
|
|
145
|
+
])
|
|
146
|
+
}),
|
|
147
|
+
import_v42.z.object({
|
|
148
|
+
type: import_v42.z.literal("web_search_tool_result"),
|
|
149
|
+
tool_use_id: import_v42.z.string(),
|
|
150
|
+
content: import_v42.z.union([
|
|
151
|
+
import_v42.z.array(
|
|
152
|
+
import_v42.z.object({
|
|
153
|
+
type: import_v42.z.literal("web_search_result"),
|
|
154
|
+
url: import_v42.z.string(),
|
|
155
|
+
title: import_v42.z.string(),
|
|
156
|
+
encrypted_content: import_v42.z.string(),
|
|
157
|
+
page_age: import_v42.z.string().nullish()
|
|
158
|
+
})
|
|
159
|
+
),
|
|
160
|
+
import_v42.z.object({
|
|
161
|
+
type: import_v42.z.literal("web_search_tool_result_error"),
|
|
162
|
+
error_code: import_v42.z.string()
|
|
163
|
+
})
|
|
164
|
+
])
|
|
165
|
+
}),
|
|
166
|
+
import_v42.z.object({
|
|
167
|
+
type: import_v42.z.literal("code_execution_tool_result"),
|
|
168
|
+
tool_use_id: import_v42.z.string(),
|
|
169
|
+
content: import_v42.z.union([
|
|
170
|
+
import_v42.z.object({
|
|
171
|
+
type: import_v42.z.literal("code_execution_result"),
|
|
172
|
+
stdout: import_v42.z.string(),
|
|
173
|
+
stderr: import_v42.z.string(),
|
|
174
|
+
return_code: import_v42.z.number()
|
|
175
|
+
}),
|
|
176
|
+
import_v42.z.object({
|
|
177
|
+
type: import_v42.z.literal("code_execution_tool_result_error"),
|
|
178
|
+
error_code: import_v42.z.string()
|
|
179
|
+
})
|
|
180
|
+
])
|
|
181
|
+
})
|
|
182
|
+
])
|
|
183
|
+
),
|
|
184
|
+
stop_reason: import_v42.z.string().nullish(),
|
|
185
|
+
stop_sequence: import_v42.z.string().nullish(),
|
|
186
|
+
usage: import_v42.z.looseObject({
|
|
187
|
+
input_tokens: import_v42.z.number(),
|
|
188
|
+
output_tokens: import_v42.z.number(),
|
|
189
|
+
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
190
|
+
cache_read_input_tokens: import_v42.z.number().nullish()
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
196
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
197
|
+
import_v42.z.discriminatedUnion("type", [
|
|
198
|
+
import_v42.z.object({
|
|
199
|
+
type: import_v42.z.literal("message_start"),
|
|
200
|
+
message: import_v42.z.object({
|
|
201
|
+
id: import_v42.z.string().nullish(),
|
|
202
|
+
model: import_v42.z.string().nullish(),
|
|
203
|
+
usage: import_v42.z.looseObject({
|
|
204
|
+
input_tokens: import_v42.z.number(),
|
|
205
|
+
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
206
|
+
cache_read_input_tokens: import_v42.z.number().nullish()
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
}),
|
|
210
|
+
import_v42.z.object({
|
|
211
|
+
type: import_v42.z.literal("content_block_start"),
|
|
212
|
+
index: import_v42.z.number(),
|
|
213
|
+
content_block: import_v42.z.discriminatedUnion("type", [
|
|
214
|
+
import_v42.z.object({
|
|
215
|
+
type: import_v42.z.literal("text"),
|
|
216
|
+
text: import_v42.z.string()
|
|
217
|
+
}),
|
|
218
|
+
import_v42.z.object({
|
|
219
|
+
type: import_v42.z.literal("thinking"),
|
|
220
|
+
thinking: import_v42.z.string()
|
|
221
|
+
}),
|
|
222
|
+
import_v42.z.object({
|
|
223
|
+
type: import_v42.z.literal("tool_use"),
|
|
224
|
+
id: import_v42.z.string(),
|
|
225
|
+
name: import_v42.z.string()
|
|
226
|
+
}),
|
|
227
|
+
import_v42.z.object({
|
|
228
|
+
type: import_v42.z.literal("redacted_thinking"),
|
|
229
|
+
data: import_v42.z.string()
|
|
230
|
+
}),
|
|
231
|
+
import_v42.z.object({
|
|
232
|
+
type: import_v42.z.literal("server_tool_use"),
|
|
233
|
+
id: import_v42.z.string(),
|
|
234
|
+
name: import_v42.z.string(),
|
|
235
|
+
input: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).nullish()
|
|
236
|
+
}),
|
|
237
|
+
import_v42.z.object({
|
|
238
|
+
type: import_v42.z.literal("web_fetch_tool_result"),
|
|
239
|
+
tool_use_id: import_v42.z.string(),
|
|
240
|
+
content: import_v42.z.union([
|
|
241
|
+
import_v42.z.object({
|
|
242
|
+
type: import_v42.z.literal("web_fetch_result"),
|
|
243
|
+
url: import_v42.z.string(),
|
|
244
|
+
retrieved_at: import_v42.z.string(),
|
|
245
|
+
content: import_v42.z.object({
|
|
246
|
+
type: import_v42.z.literal("document"),
|
|
247
|
+
title: import_v42.z.string().nullable(),
|
|
248
|
+
citations: import_v42.z.object({ enabled: import_v42.z.boolean() }).optional(),
|
|
249
|
+
source: import_v42.z.object({
|
|
250
|
+
type: import_v42.z.literal("text"),
|
|
251
|
+
media_type: import_v42.z.string(),
|
|
252
|
+
data: import_v42.z.string()
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
}),
|
|
256
|
+
import_v42.z.object({
|
|
257
|
+
type: import_v42.z.literal("web_fetch_tool_result_error"),
|
|
258
|
+
error_code: import_v42.z.string()
|
|
259
|
+
})
|
|
260
|
+
])
|
|
261
|
+
}),
|
|
262
|
+
import_v42.z.object({
|
|
263
|
+
type: import_v42.z.literal("web_search_tool_result"),
|
|
264
|
+
tool_use_id: import_v42.z.string(),
|
|
265
|
+
content: import_v42.z.union([
|
|
266
|
+
import_v42.z.array(
|
|
267
|
+
import_v42.z.object({
|
|
268
|
+
type: import_v42.z.literal("web_search_result"),
|
|
269
|
+
url: import_v42.z.string(),
|
|
270
|
+
title: import_v42.z.string(),
|
|
271
|
+
encrypted_content: import_v42.z.string(),
|
|
272
|
+
page_age: import_v42.z.string().nullish()
|
|
273
|
+
})
|
|
274
|
+
),
|
|
275
|
+
import_v42.z.object({
|
|
276
|
+
type: import_v42.z.literal("web_search_tool_result_error"),
|
|
277
|
+
error_code: import_v42.z.string()
|
|
278
|
+
})
|
|
279
|
+
])
|
|
280
|
+
}),
|
|
281
|
+
import_v42.z.object({
|
|
282
|
+
type: import_v42.z.literal("code_execution_tool_result"),
|
|
283
|
+
tool_use_id: import_v42.z.string(),
|
|
284
|
+
content: import_v42.z.union([
|
|
285
|
+
import_v42.z.object({
|
|
286
|
+
type: import_v42.z.literal("code_execution_result"),
|
|
287
|
+
stdout: import_v42.z.string(),
|
|
288
|
+
stderr: import_v42.z.string(),
|
|
289
|
+
return_code: import_v42.z.number()
|
|
290
|
+
}),
|
|
291
|
+
import_v42.z.object({
|
|
292
|
+
type: import_v42.z.literal("code_execution_tool_result_error"),
|
|
293
|
+
error_code: import_v42.z.string()
|
|
294
|
+
})
|
|
295
|
+
])
|
|
296
|
+
})
|
|
297
|
+
])
|
|
298
|
+
}),
|
|
299
|
+
import_v42.z.object({
|
|
300
|
+
type: import_v42.z.literal("content_block_delta"),
|
|
301
|
+
index: import_v42.z.number(),
|
|
302
|
+
delta: import_v42.z.discriminatedUnion("type", [
|
|
303
|
+
import_v42.z.object({
|
|
304
|
+
type: import_v42.z.literal("input_json_delta"),
|
|
305
|
+
partial_json: import_v42.z.string()
|
|
306
|
+
}),
|
|
307
|
+
import_v42.z.object({
|
|
308
|
+
type: import_v42.z.literal("text_delta"),
|
|
309
|
+
text: import_v42.z.string()
|
|
310
|
+
}),
|
|
311
|
+
import_v42.z.object({
|
|
312
|
+
type: import_v42.z.literal("thinking_delta"),
|
|
313
|
+
thinking: import_v42.z.string()
|
|
314
|
+
}),
|
|
315
|
+
import_v42.z.object({
|
|
316
|
+
type: import_v42.z.literal("signature_delta"),
|
|
317
|
+
signature: import_v42.z.string()
|
|
318
|
+
}),
|
|
319
|
+
import_v42.z.object({
|
|
320
|
+
type: import_v42.z.literal("citations_delta"),
|
|
321
|
+
citation: import_v42.z.discriminatedUnion("type", [
|
|
322
|
+
import_v42.z.object({
|
|
323
|
+
type: import_v42.z.literal("web_search_result_location"),
|
|
324
|
+
cited_text: import_v42.z.string(),
|
|
325
|
+
url: import_v42.z.string(),
|
|
326
|
+
title: import_v42.z.string(),
|
|
327
|
+
encrypted_index: import_v42.z.string()
|
|
328
|
+
}),
|
|
329
|
+
import_v42.z.object({
|
|
330
|
+
type: import_v42.z.literal("page_location"),
|
|
331
|
+
cited_text: import_v42.z.string(),
|
|
332
|
+
document_index: import_v42.z.number(),
|
|
333
|
+
document_title: import_v42.z.string().nullable(),
|
|
334
|
+
start_page_number: import_v42.z.number(),
|
|
335
|
+
end_page_number: import_v42.z.number()
|
|
336
|
+
}),
|
|
337
|
+
import_v42.z.object({
|
|
338
|
+
type: import_v42.z.literal("char_location"),
|
|
339
|
+
cited_text: import_v42.z.string(),
|
|
340
|
+
document_index: import_v42.z.number(),
|
|
341
|
+
document_title: import_v42.z.string().nullable(),
|
|
342
|
+
start_char_index: import_v42.z.number(),
|
|
343
|
+
end_char_index: import_v42.z.number()
|
|
344
|
+
})
|
|
345
|
+
])
|
|
346
|
+
})
|
|
347
|
+
])
|
|
348
|
+
}),
|
|
349
|
+
import_v42.z.object({
|
|
350
|
+
type: import_v42.z.literal("content_block_stop"),
|
|
351
|
+
index: import_v42.z.number()
|
|
352
|
+
}),
|
|
353
|
+
import_v42.z.object({
|
|
354
|
+
type: import_v42.z.literal("error"),
|
|
355
|
+
error: import_v42.z.object({
|
|
356
|
+
type: import_v42.z.string(),
|
|
357
|
+
message: import_v42.z.string()
|
|
358
|
+
})
|
|
359
|
+
}),
|
|
360
|
+
import_v42.z.object({
|
|
361
|
+
type: import_v42.z.literal("message_delta"),
|
|
362
|
+
delta: import_v42.z.object({
|
|
363
|
+
stop_reason: import_v42.z.string().nullish(),
|
|
364
|
+
stop_sequence: import_v42.z.string().nullish()
|
|
365
|
+
}),
|
|
366
|
+
usage: import_v42.z.looseObject({
|
|
367
|
+
output_tokens: import_v42.z.number(),
|
|
368
|
+
cache_creation_input_tokens: import_v42.z.number().nullish()
|
|
369
|
+
})
|
|
370
|
+
}),
|
|
371
|
+
import_v42.z.object({
|
|
372
|
+
type: import_v42.z.literal("message_stop")
|
|
373
|
+
}),
|
|
374
|
+
import_v42.z.object({
|
|
375
|
+
type: import_v42.z.literal("ping")
|
|
376
|
+
})
|
|
377
|
+
])
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
var anthropicReasoningMetadataSchema = (0, import_provider_utils2.lazySchema)(
|
|
381
|
+
() => (0, import_provider_utils2.zodSchema)(
|
|
382
|
+
import_v42.z.object({
|
|
383
|
+
signature: import_v42.z.string().optional(),
|
|
384
|
+
redactedData: import_v42.z.string().optional()
|
|
385
|
+
})
|
|
386
|
+
)
|
|
387
|
+
);
|
|
388
|
+
|
|
66
389
|
// src/anthropic-messages-options.ts
|
|
67
|
-
var
|
|
68
|
-
var anthropicFilePartProviderOptions =
|
|
390
|
+
var import_v43 = require("zod/v4");
|
|
391
|
+
var anthropicFilePartProviderOptions = import_v43.z.object({
|
|
69
392
|
/**
|
|
70
393
|
* Citation configuration for this document.
|
|
71
394
|
* When enabled, this document will generate citations in the response.
|
|
72
395
|
*/
|
|
73
|
-
citations:
|
|
396
|
+
citations: import_v43.z.object({
|
|
74
397
|
/**
|
|
75
398
|
* Enable citations for this document
|
|
76
399
|
*/
|
|
77
|
-
enabled:
|
|
400
|
+
enabled: import_v43.z.boolean()
|
|
78
401
|
}).optional(),
|
|
79
402
|
/**
|
|
80
403
|
* Custom title for the document.
|
|
81
404
|
* If not provided, the filename will be used.
|
|
82
405
|
*/
|
|
83
|
-
title:
|
|
406
|
+
title: import_v43.z.string().optional(),
|
|
84
407
|
/**
|
|
85
408
|
* Context about the document that will be passed to the model
|
|
86
409
|
* but not used towards cited content.
|
|
87
410
|
* Useful for storing document metadata as text or stringified JSON.
|
|
88
411
|
*/
|
|
89
|
-
context:
|
|
412
|
+
context: import_v43.z.string().optional()
|
|
90
413
|
});
|
|
91
|
-
var anthropicProviderOptions =
|
|
92
|
-
sendReasoning:
|
|
93
|
-
thinking:
|
|
94
|
-
type:
|
|
95
|
-
budgetTokens:
|
|
414
|
+
var anthropicProviderOptions = import_v43.z.object({
|
|
415
|
+
sendReasoning: import_v43.z.boolean().optional(),
|
|
416
|
+
thinking: import_v43.z.object({
|
|
417
|
+
type: import_v43.z.union([import_v43.z.literal("enabled"), import_v43.z.literal("disabled")]),
|
|
418
|
+
budgetTokens: import_v43.z.number().optional()
|
|
96
419
|
}).optional(),
|
|
97
420
|
/**
|
|
98
421
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
99
422
|
* When set to true, Claude will use at most one tool per response.
|
|
100
423
|
*/
|
|
101
|
-
disableParallelToolUse:
|
|
424
|
+
disableParallelToolUse: import_v43.z.boolean().optional(),
|
|
102
425
|
/**
|
|
103
426
|
* Cache control settings for this message.
|
|
104
427
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
105
428
|
*/
|
|
106
|
-
cacheControl:
|
|
107
|
-
type:
|
|
108
|
-
ttl:
|
|
429
|
+
cacheControl: import_v43.z.object({
|
|
430
|
+
type: import_v43.z.literal("ephemeral"),
|
|
431
|
+
ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
|
|
109
432
|
}).optional()
|
|
110
433
|
});
|
|
111
434
|
|
|
@@ -121,58 +444,81 @@ function getCacheControl(providerMetadata) {
|
|
|
121
444
|
}
|
|
122
445
|
|
|
123
446
|
// src/tool/text-editor_20250728.ts
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
447
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
448
|
+
var import_v44 = require("zod/v4");
|
|
449
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
450
|
+
var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
|
|
451
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
452
|
+
import_v44.z.object({
|
|
453
|
+
maxCharacters: import_v44.z.number().optional()
|
|
454
|
+
})
|
|
455
|
+
)
|
|
456
|
+
);
|
|
457
|
+
var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
|
|
458
|
+
() => (0, import_provider_utils4.zodSchema)(
|
|
459
|
+
import_v44.z.object({
|
|
460
|
+
command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
|
|
461
|
+
path: import_v44.z.string(),
|
|
462
|
+
file_text: import_v44.z.string().optional(),
|
|
463
|
+
insert_line: import_v44.z.number().int().optional(),
|
|
464
|
+
new_str: import_v44.z.string().optional(),
|
|
465
|
+
old_str: import_v44.z.string().optional(),
|
|
466
|
+
view_range: import_v44.z.array(import_v44.z.number().int()).optional()
|
|
467
|
+
})
|
|
468
|
+
)
|
|
469
|
+
);
|
|
470
|
+
var factory = (0, import_provider_utils3.createProviderDefinedToolFactory)({
|
|
130
471
|
id: "anthropic.text_editor_20250728",
|
|
131
472
|
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
|
-
})
|
|
473
|
+
inputSchema: textEditor_20250728InputSchema
|
|
141
474
|
});
|
|
142
475
|
var textEditor_20250728 = (args = {}) => {
|
|
143
476
|
return factory(args);
|
|
144
477
|
};
|
|
145
478
|
|
|
146
479
|
// 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
|
-
})
|
|
480
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
481
|
+
var import_v45 = require("zod/v4");
|
|
482
|
+
var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
|
|
483
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
484
|
+
import_v45.z.object({
|
|
485
|
+
maxUses: import_v45.z.number().optional(),
|
|
486
|
+
allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
487
|
+
blockedDomains: import_v45.z.array(import_v45.z.string()).optional(),
|
|
488
|
+
userLocation: import_v45.z.object({
|
|
489
|
+
type: import_v45.z.literal("approximate"),
|
|
490
|
+
city: import_v45.z.string().optional(),
|
|
491
|
+
region: import_v45.z.string().optional(),
|
|
492
|
+
country: import_v45.z.string().optional(),
|
|
493
|
+
timezone: import_v45.z.string().optional()
|
|
494
|
+
}).optional()
|
|
495
|
+
})
|
|
496
|
+
)
|
|
169
497
|
);
|
|
170
|
-
var
|
|
498
|
+
var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
|
|
499
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
500
|
+
import_v45.z.array(
|
|
501
|
+
import_v45.z.object({
|
|
502
|
+
url: import_v45.z.string(),
|
|
503
|
+
title: import_v45.z.string(),
|
|
504
|
+
pageAge: import_v45.z.string().nullable(),
|
|
505
|
+
encryptedContent: import_v45.z.string(),
|
|
506
|
+
type: import_v45.z.literal("web_search_result")
|
|
507
|
+
})
|
|
508
|
+
)
|
|
509
|
+
)
|
|
510
|
+
);
|
|
511
|
+
var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
|
|
512
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
513
|
+
import_v45.z.object({
|
|
514
|
+
query: import_v45.z.string()
|
|
515
|
+
})
|
|
516
|
+
)
|
|
517
|
+
);
|
|
518
|
+
var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
171
519
|
id: "anthropic.web_search_20250305",
|
|
172
520
|
name: "web_search",
|
|
173
|
-
inputSchema:
|
|
174
|
-
query: z4.string()
|
|
175
|
-
}),
|
|
521
|
+
inputSchema: webSearch_20250305InputSchema,
|
|
176
522
|
outputSchema: webSearch_20250305OutputSchema
|
|
177
523
|
});
|
|
178
524
|
var webSearch_20250305 = (args = {}) => {
|
|
@@ -180,43 +526,56 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
180
526
|
};
|
|
181
527
|
|
|
182
528
|
// 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
|
-
|
|
529
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
530
|
+
var import_v46 = require("zod/v4");
|
|
531
|
+
var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
532
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
533
|
+
import_v46.z.object({
|
|
534
|
+
maxUses: import_v46.z.number().optional(),
|
|
535
|
+
allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
|
|
536
|
+
blockedDomains: import_v46.z.array(import_v46.z.string()).optional(),
|
|
537
|
+
citations: import_v46.z.object({ enabled: import_v46.z.boolean() }).optional(),
|
|
538
|
+
maxContentTokens: import_v46.z.number().optional()
|
|
539
|
+
})
|
|
540
|
+
)
|
|
541
|
+
);
|
|
542
|
+
var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
543
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
544
|
+
import_v46.z.object({
|
|
545
|
+
type: import_v46.z.literal("web_fetch_result"),
|
|
546
|
+
url: import_v46.z.string(),
|
|
547
|
+
content: import_v46.z.object({
|
|
548
|
+
type: import_v46.z.literal("document"),
|
|
549
|
+
title: import_v46.z.string(),
|
|
550
|
+
citations: import_v46.z.object({ enabled: import_v46.z.boolean() }).optional(),
|
|
551
|
+
source: import_v46.z.union([
|
|
552
|
+
import_v46.z.object({
|
|
553
|
+
type: import_v46.z.literal("base64"),
|
|
554
|
+
mediaType: import_v46.z.literal("application/pdf"),
|
|
555
|
+
data: import_v46.z.string()
|
|
556
|
+
}),
|
|
557
|
+
import_v46.z.object({
|
|
558
|
+
type: import_v46.z.literal("text"),
|
|
559
|
+
mediaType: import_v46.z.literal("text/plain"),
|
|
560
|
+
data: import_v46.z.string()
|
|
561
|
+
})
|
|
562
|
+
])
|
|
204
563
|
}),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
})
|
|
214
|
-
|
|
564
|
+
retrievedAt: import_v46.z.string().nullable()
|
|
565
|
+
})
|
|
566
|
+
)
|
|
567
|
+
);
|
|
568
|
+
var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
|
|
569
|
+
() => (0, import_provider_utils6.zodSchema)(
|
|
570
|
+
import_v46.z.object({
|
|
571
|
+
url: import_v46.z.string()
|
|
572
|
+
})
|
|
573
|
+
)
|
|
574
|
+
);
|
|
575
|
+
var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
215
576
|
id: "anthropic.web_fetch_20250910",
|
|
216
577
|
name: "web_fetch",
|
|
217
|
-
inputSchema:
|
|
218
|
-
url: z5.string()
|
|
219
|
-
}),
|
|
578
|
+
inputSchema: webFetch_20250910InputSchema,
|
|
220
579
|
outputSchema: webFetch_20250910OutputSchema
|
|
221
580
|
});
|
|
222
581
|
var webFetch_20250910 = (args = {}) => {
|
|
@@ -224,7 +583,8 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
224
583
|
};
|
|
225
584
|
|
|
226
585
|
// src/anthropic-prepare-tools.ts
|
|
227
|
-
|
|
586
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
587
|
+
async function prepareTools({
|
|
228
588
|
tools,
|
|
229
589
|
toolChoice,
|
|
230
590
|
disableParallelToolUse
|
|
@@ -305,7 +665,10 @@ function prepareTools({
|
|
|
305
665
|
break;
|
|
306
666
|
}
|
|
307
667
|
case "anthropic.text_editor_20250728": {
|
|
308
|
-
const args =
|
|
668
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
669
|
+
value: tool.args,
|
|
670
|
+
schema: textEditor_20250728ArgsSchema
|
|
671
|
+
});
|
|
309
672
|
anthropicTools2.push({
|
|
310
673
|
name: "str_replace_based_edit_tool",
|
|
311
674
|
type: "text_editor_20250728",
|
|
@@ -331,7 +694,10 @@ function prepareTools({
|
|
|
331
694
|
}
|
|
332
695
|
case "anthropic.web_fetch_20250910": {
|
|
333
696
|
betas.add("web-fetch-2025-09-10");
|
|
334
|
-
const args =
|
|
697
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
698
|
+
value: tool.args,
|
|
699
|
+
schema: webFetch_20250910ArgsSchema
|
|
700
|
+
});
|
|
335
701
|
anthropicTools2.push({
|
|
336
702
|
type: "web_fetch_20250910",
|
|
337
703
|
name: "web_fetch",
|
|
@@ -344,7 +710,10 @@ function prepareTools({
|
|
|
344
710
|
break;
|
|
345
711
|
}
|
|
346
712
|
case "anthropic.web_search_20250305": {
|
|
347
|
-
const args =
|
|
713
|
+
const args = await (0, import_provider_utils7.validateTypes)({
|
|
714
|
+
value: tool.args,
|
|
715
|
+
schema: webSearch_20250305ArgsSchema
|
|
716
|
+
});
|
|
348
717
|
anthropicTools2.push({
|
|
349
718
|
type: "web_search_20250305",
|
|
350
719
|
name: "web_search",
|
|
@@ -422,23 +791,32 @@ function prepareTools({
|
|
|
422
791
|
|
|
423
792
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
424
793
|
var import_provider2 = require("@ai-sdk/provider");
|
|
425
|
-
var
|
|
794
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
426
795
|
|
|
427
796
|
// src/tool/code-execution_20250522.ts
|
|
428
|
-
var
|
|
429
|
-
var
|
|
430
|
-
var codeExecution_20250522OutputSchema =
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
797
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
798
|
+
var import_v47 = require("zod/v4");
|
|
799
|
+
var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
800
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
801
|
+
import_v47.z.object({
|
|
802
|
+
type: import_v47.z.literal("code_execution_result"),
|
|
803
|
+
stdout: import_v47.z.string(),
|
|
804
|
+
stderr: import_v47.z.string(),
|
|
805
|
+
return_code: import_v47.z.number()
|
|
806
|
+
})
|
|
807
|
+
)
|
|
808
|
+
);
|
|
809
|
+
var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
|
|
810
|
+
() => (0, import_provider_utils8.zodSchema)(
|
|
811
|
+
import_v47.z.object({
|
|
812
|
+
code: import_v47.z.string()
|
|
813
|
+
})
|
|
814
|
+
)
|
|
815
|
+
);
|
|
816
|
+
var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
437
817
|
id: "anthropic.code_execution_20250522",
|
|
438
818
|
name: "code_execution",
|
|
439
|
-
inputSchema:
|
|
440
|
-
code: z6.string()
|
|
441
|
-
}),
|
|
819
|
+
inputSchema: codeExecution_20250522InputSchema,
|
|
442
820
|
outputSchema: codeExecution_20250522OutputSchema
|
|
443
821
|
});
|
|
444
822
|
var codeExecution_20250522 = (args = {}) => {
|
|
@@ -474,7 +852,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
474
852
|
const messages = [];
|
|
475
853
|
async function shouldEnableCitations(providerMetadata) {
|
|
476
854
|
var _a2, _b2;
|
|
477
|
-
const anthropicOptions = await (0,
|
|
855
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
478
856
|
provider: "anthropic",
|
|
479
857
|
providerOptions: providerMetadata,
|
|
480
858
|
schema: anthropicFilePartProviderOptions
|
|
@@ -482,7 +860,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
482
860
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
483
861
|
}
|
|
484
862
|
async function getDocumentMetadata(providerMetadata) {
|
|
485
|
-
const anthropicOptions = await (0,
|
|
863
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
486
864
|
provider: "anthropic",
|
|
487
865
|
providerOptions: providerMetadata,
|
|
488
866
|
schema: anthropicFilePartProviderOptions
|
|
@@ -539,7 +917,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
539
917
|
} : {
|
|
540
918
|
type: "base64",
|
|
541
919
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
542
|
-
data: (0,
|
|
920
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
543
921
|
},
|
|
544
922
|
cache_control: cacheControl
|
|
545
923
|
});
|
|
@@ -559,7 +937,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
559
937
|
} : {
|
|
560
938
|
type: "base64",
|
|
561
939
|
media_type: "application/pdf",
|
|
562
|
-
data: (0,
|
|
940
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
563
941
|
},
|
|
564
942
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
565
943
|
...metadata.context && { context: metadata.context },
|
|
@@ -694,7 +1072,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
694
1072
|
}
|
|
695
1073
|
case "reasoning": {
|
|
696
1074
|
if (sendReasoning) {
|
|
697
|
-
const reasoningMetadata = await (0,
|
|
1075
|
+
const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
|
|
698
1076
|
provider: "anthropic",
|
|
699
1077
|
providerOptions: part.providerOptions,
|
|
700
1078
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -770,7 +1148,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
770
1148
|
});
|
|
771
1149
|
break;
|
|
772
1150
|
}
|
|
773
|
-
const codeExecutionOutput =
|
|
1151
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1152
|
+
value: output.value,
|
|
1153
|
+
schema: codeExecution_20250522OutputSchema
|
|
1154
|
+
});
|
|
774
1155
|
anthropicContent.push({
|
|
775
1156
|
type: "code_execution_tool_result",
|
|
776
1157
|
tool_use_id: part.toolCallId,
|
|
@@ -793,9 +1174,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
793
1174
|
});
|
|
794
1175
|
break;
|
|
795
1176
|
}
|
|
796
|
-
const webFetchOutput =
|
|
797
|
-
output.value
|
|
798
|
-
|
|
1177
|
+
const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1178
|
+
value: output.value,
|
|
1179
|
+
schema: webFetch_20250910OutputSchema
|
|
1180
|
+
});
|
|
799
1181
|
anthropicContent.push({
|
|
800
1182
|
type: "web_fetch_tool_result",
|
|
801
1183
|
tool_use_id: part.toolCallId,
|
|
@@ -827,9 +1209,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
827
1209
|
});
|
|
828
1210
|
break;
|
|
829
1211
|
}
|
|
830
|
-
const webSearchOutput =
|
|
831
|
-
output.value
|
|
832
|
-
|
|
1212
|
+
const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1213
|
+
value: output.value,
|
|
1214
|
+
schema: webSearch_20250305OutputSchema
|
|
1215
|
+
});
|
|
833
1216
|
anthropicContent.push({
|
|
834
1217
|
type: "web_search_tool_result",
|
|
835
1218
|
tool_use_id: part.toolCallId,
|
|
@@ -936,67 +1319,15 @@ function mapAnthropicStopReason({
|
|
|
936
1319
|
}
|
|
937
1320
|
|
|
938
1321
|
// 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
1322
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
986
1323
|
var _a;
|
|
1324
|
+
if (citation.type !== "page_location" && citation.type !== "char_location") {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
987
1327
|
const documentInfo = citationDocuments[citation.document_index];
|
|
988
1328
|
if (!documentInfo) {
|
|
989
|
-
return
|
|
1329
|
+
return;
|
|
990
1330
|
}
|
|
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
1331
|
return {
|
|
1001
1332
|
type: "source",
|
|
1002
1333
|
sourceType: "document",
|
|
@@ -1005,7 +1336,15 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
1005
1336
|
title: (_a = citation.document_title) != null ? _a : documentInfo.title,
|
|
1006
1337
|
filename: documentInfo.filename,
|
|
1007
1338
|
providerMetadata: {
|
|
1008
|
-
anthropic:
|
|
1339
|
+
anthropic: citation.type === "page_location" ? {
|
|
1340
|
+
citedText: citation.cited_text,
|
|
1341
|
+
startPageNumber: citation.start_page_number,
|
|
1342
|
+
endPageNumber: citation.end_page_number
|
|
1343
|
+
} : {
|
|
1344
|
+
citedText: citation.cited_text,
|
|
1345
|
+
startCharIndex: citation.start_char_index,
|
|
1346
|
+
endCharIndex: citation.end_char_index
|
|
1347
|
+
}
|
|
1009
1348
|
}
|
|
1010
1349
|
};
|
|
1011
1350
|
}
|
|
@@ -1015,7 +1354,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1015
1354
|
var _a;
|
|
1016
1355
|
this.modelId = modelId;
|
|
1017
1356
|
this.config = config;
|
|
1018
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
1357
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
|
|
1019
1358
|
}
|
|
1020
1359
|
supportsUrl(url) {
|
|
1021
1360
|
return url.protocol === "https:";
|
|
@@ -1084,7 +1423,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1084
1423
|
description: "Respond with a JSON object.",
|
|
1085
1424
|
inputSchema: responseFormat.schema
|
|
1086
1425
|
} : void 0;
|
|
1087
|
-
const anthropicOptions = await (0,
|
|
1426
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
1088
1427
|
provider: "anthropic",
|
|
1089
1428
|
providerOptions,
|
|
1090
1429
|
schema: anthropicProviderOptions
|
|
@@ -1150,7 +1489,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1150
1489
|
toolChoice: anthropicToolChoice,
|
|
1151
1490
|
toolWarnings,
|
|
1152
1491
|
betas: toolsBetas
|
|
1153
|
-
} = prepareTools(
|
|
1492
|
+
} = await prepareTools(
|
|
1154
1493
|
jsonResponseTool != null ? {
|
|
1155
1494
|
tools: [jsonResponseTool],
|
|
1156
1495
|
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
@@ -1176,8 +1515,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1176
1515
|
betas,
|
|
1177
1516
|
headers
|
|
1178
1517
|
}) {
|
|
1179
|
-
return (0,
|
|
1180
|
-
await (0,
|
|
1518
|
+
return (0, import_provider_utils10.combineHeaders)(
|
|
1519
|
+
await (0, import_provider_utils10.resolve)(this.config.headers),
|
|
1181
1520
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
1182
1521
|
headers
|
|
1183
1522
|
);
|
|
@@ -1221,12 +1560,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1221
1560
|
responseHeaders,
|
|
1222
1561
|
value: response,
|
|
1223
1562
|
rawValue: rawResponse
|
|
1224
|
-
} = await (0,
|
|
1563
|
+
} = await (0, import_provider_utils10.postJsonToApi)({
|
|
1225
1564
|
url: this.buildRequestUrl(false),
|
|
1226
1565
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1227
1566
|
body: this.transformRequestBody(args),
|
|
1228
1567
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1229
|
-
successfulResponseHandler: (0,
|
|
1568
|
+
successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
|
|
1230
1569
|
anthropicMessagesResponseSchema
|
|
1231
1570
|
),
|
|
1232
1571
|
abortSignal: options.abortSignal,
|
|
@@ -1240,12 +1579,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1240
1579
|
content.push({ type: "text", text: part.text });
|
|
1241
1580
|
if (part.citations) {
|
|
1242
1581
|
for (const citation of part.citations) {
|
|
1243
|
-
|
|
1582
|
+
const source = createCitationSource(
|
|
1244
1583
|
citation,
|
|
1245
1584
|
citationDocuments,
|
|
1246
|
-
this.generateId
|
|
1247
|
-
(source) => content.push(source)
|
|
1585
|
+
this.generateId
|
|
1248
1586
|
);
|
|
1587
|
+
if (source) {
|
|
1588
|
+
content.push(source);
|
|
1589
|
+
}
|
|
1249
1590
|
}
|
|
1250
1591
|
}
|
|
1251
1592
|
}
|
|
@@ -1451,12 +1792,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1451
1792
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1452
1793
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1453
1794
|
const body = { ...args, stream: true };
|
|
1454
|
-
const { responseHeaders, value: response } = await (0,
|
|
1795
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
|
|
1455
1796
|
url: this.buildRequestUrl(true),
|
|
1456
1797
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1457
1798
|
body: this.transformRequestBody(body),
|
|
1458
1799
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1459
|
-
successfulResponseHandler: (0,
|
|
1800
|
+
successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
|
|
1460
1801
|
anthropicMessagesChunkSchema
|
|
1461
1802
|
),
|
|
1462
1803
|
abortSignal: options.abortSignal,
|
|
@@ -1782,12 +2123,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1782
2123
|
}
|
|
1783
2124
|
case "citations_delta": {
|
|
1784
2125
|
const citation = value.delta.citation;
|
|
1785
|
-
|
|
2126
|
+
const source = createCitationSource(
|
|
1786
2127
|
citation,
|
|
1787
2128
|
citationDocuments,
|
|
1788
|
-
generateId3
|
|
1789
|
-
(source) => controller.enqueue(source)
|
|
2129
|
+
generateId3
|
|
1790
2130
|
);
|
|
2131
|
+
if (source) {
|
|
2132
|
+
controller.enqueue(source);
|
|
2133
|
+
}
|
|
1791
2134
|
return;
|
|
1792
2135
|
}
|
|
1793
2136
|
default: {
|
|
@@ -1858,402 +2201,173 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1858
2201
|
};
|
|
1859
2202
|
}
|
|
1860
2203
|
};
|
|
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
2204
|
|
|
2126
2205
|
// src/tool/bash_20241022.ts
|
|
2127
|
-
var
|
|
2128
|
-
var
|
|
2129
|
-
var
|
|
2206
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
2207
|
+
var import_v48 = require("zod/v4");
|
|
2208
|
+
var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
2209
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
2210
|
+
import_v48.z.object({
|
|
2211
|
+
command: import_v48.z.string(),
|
|
2212
|
+
restart: import_v48.z.boolean().optional()
|
|
2213
|
+
})
|
|
2214
|
+
)
|
|
2215
|
+
);
|
|
2216
|
+
var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
2130
2217
|
id: "anthropic.bash_20241022",
|
|
2131
2218
|
name: "bash",
|
|
2132
|
-
inputSchema:
|
|
2133
|
-
command: import_v4.default.string(),
|
|
2134
|
-
restart: import_v4.default.boolean().optional()
|
|
2135
|
-
})
|
|
2219
|
+
inputSchema: bash_20241022InputSchema
|
|
2136
2220
|
});
|
|
2137
2221
|
|
|
2138
2222
|
// src/tool/bash_20250124.ts
|
|
2139
|
-
var
|
|
2140
|
-
var
|
|
2141
|
-
var
|
|
2223
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2224
|
+
var import_v49 = require("zod/v4");
|
|
2225
|
+
var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
2226
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
2227
|
+
import_v49.z.object({
|
|
2228
|
+
command: import_v49.z.string(),
|
|
2229
|
+
restart: import_v49.z.boolean().optional()
|
|
2230
|
+
})
|
|
2231
|
+
)
|
|
2232
|
+
);
|
|
2233
|
+
var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
2142
2234
|
id: "anthropic.bash_20250124",
|
|
2143
2235
|
name: "bash",
|
|
2144
|
-
inputSchema:
|
|
2145
|
-
command: import_v42.default.string(),
|
|
2146
|
-
restart: import_v42.default.boolean().optional()
|
|
2147
|
-
})
|
|
2236
|
+
inputSchema: bash_20250124InputSchema
|
|
2148
2237
|
});
|
|
2149
2238
|
|
|
2150
2239
|
// src/tool/computer_20241022.ts
|
|
2151
|
-
var
|
|
2152
|
-
var
|
|
2153
|
-
var
|
|
2240
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2241
|
+
var import_v410 = require("zod/v4");
|
|
2242
|
+
var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
2243
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
2244
|
+
import_v410.z.object({
|
|
2245
|
+
action: import_v410.z.enum([
|
|
2246
|
+
"key",
|
|
2247
|
+
"type",
|
|
2248
|
+
"mouse_move",
|
|
2249
|
+
"left_click",
|
|
2250
|
+
"left_click_drag",
|
|
2251
|
+
"right_click",
|
|
2252
|
+
"middle_click",
|
|
2253
|
+
"double_click",
|
|
2254
|
+
"screenshot",
|
|
2255
|
+
"cursor_position"
|
|
2256
|
+
]),
|
|
2257
|
+
coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
|
|
2258
|
+
text: import_v410.z.string().optional()
|
|
2259
|
+
})
|
|
2260
|
+
)
|
|
2261
|
+
);
|
|
2262
|
+
var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
|
|
2154
2263
|
id: "anthropic.computer_20241022",
|
|
2155
2264
|
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
|
-
})
|
|
2265
|
+
inputSchema: computer_20241022InputSchema
|
|
2172
2266
|
});
|
|
2173
2267
|
|
|
2174
2268
|
// src/tool/computer_20250124.ts
|
|
2175
|
-
var
|
|
2176
|
-
var
|
|
2177
|
-
var
|
|
2269
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2270
|
+
var import_v411 = require("zod/v4");
|
|
2271
|
+
var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
2272
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
2273
|
+
import_v411.z.object({
|
|
2274
|
+
action: import_v411.z.enum([
|
|
2275
|
+
"key",
|
|
2276
|
+
"hold_key",
|
|
2277
|
+
"type",
|
|
2278
|
+
"cursor_position",
|
|
2279
|
+
"mouse_move",
|
|
2280
|
+
"left_mouse_down",
|
|
2281
|
+
"left_mouse_up",
|
|
2282
|
+
"left_click",
|
|
2283
|
+
"left_click_drag",
|
|
2284
|
+
"right_click",
|
|
2285
|
+
"middle_click",
|
|
2286
|
+
"double_click",
|
|
2287
|
+
"triple_click",
|
|
2288
|
+
"scroll",
|
|
2289
|
+
"wait",
|
|
2290
|
+
"screenshot"
|
|
2291
|
+
]),
|
|
2292
|
+
coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2293
|
+
duration: import_v411.z.number().optional(),
|
|
2294
|
+
scroll_amount: import_v411.z.number().optional(),
|
|
2295
|
+
scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
|
|
2296
|
+
start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
|
|
2297
|
+
text: import_v411.z.string().optional()
|
|
2298
|
+
})
|
|
2299
|
+
)
|
|
2300
|
+
);
|
|
2301
|
+
var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
2178
2302
|
id: "anthropic.computer_20250124",
|
|
2179
2303
|
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
|
-
})
|
|
2304
|
+
inputSchema: computer_20250124InputSchema
|
|
2206
2305
|
});
|
|
2207
2306
|
|
|
2208
2307
|
// src/tool/text-editor_20241022.ts
|
|
2209
|
-
var
|
|
2210
|
-
var
|
|
2211
|
-
var
|
|
2308
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2309
|
+
var import_v412 = require("zod/v4");
|
|
2310
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
2311
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
2312
|
+
import_v412.z.object({
|
|
2313
|
+
command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2314
|
+
path: import_v412.z.string(),
|
|
2315
|
+
file_text: import_v412.z.string().optional(),
|
|
2316
|
+
insert_line: import_v412.z.number().int().optional(),
|
|
2317
|
+
new_str: import_v412.z.string().optional(),
|
|
2318
|
+
old_str: import_v412.z.string().optional(),
|
|
2319
|
+
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
2320
|
+
})
|
|
2321
|
+
)
|
|
2322
|
+
);
|
|
2323
|
+
var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
2212
2324
|
id: "anthropic.text_editor_20241022",
|
|
2213
2325
|
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
|
-
})
|
|
2326
|
+
inputSchema: textEditor_20241022InputSchema
|
|
2223
2327
|
});
|
|
2224
2328
|
|
|
2225
2329
|
// src/tool/text-editor_20250124.ts
|
|
2226
|
-
var
|
|
2227
|
-
var
|
|
2228
|
-
var
|
|
2330
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2331
|
+
var import_v413 = require("zod/v4");
|
|
2332
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
2333
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
2334
|
+
import_v413.z.object({
|
|
2335
|
+
command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
2336
|
+
path: import_v413.z.string(),
|
|
2337
|
+
file_text: import_v413.z.string().optional(),
|
|
2338
|
+
insert_line: import_v413.z.number().int().optional(),
|
|
2339
|
+
new_str: import_v413.z.string().optional(),
|
|
2340
|
+
old_str: import_v413.z.string().optional(),
|
|
2341
|
+
view_range: import_v413.z.array(import_v413.z.number().int()).optional()
|
|
2342
|
+
})
|
|
2343
|
+
)
|
|
2344
|
+
);
|
|
2345
|
+
var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
2229
2346
|
id: "anthropic.text_editor_20250124",
|
|
2230
2347
|
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
|
-
})
|
|
2348
|
+
inputSchema: textEditor_20250124InputSchema
|
|
2240
2349
|
});
|
|
2241
2350
|
|
|
2242
2351
|
// src/tool/text-editor_20250429.ts
|
|
2243
|
-
var
|
|
2244
|
-
var
|
|
2245
|
-
var
|
|
2352
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
2353
|
+
var import_v414 = require("zod/v4");
|
|
2354
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
2355
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
2356
|
+
import_v414.z.object({
|
|
2357
|
+
command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
|
|
2358
|
+
path: import_v414.z.string(),
|
|
2359
|
+
file_text: import_v414.z.string().optional(),
|
|
2360
|
+
insert_line: import_v414.z.number().int().optional(),
|
|
2361
|
+
new_str: import_v414.z.string().optional(),
|
|
2362
|
+
old_str: import_v414.z.string().optional(),
|
|
2363
|
+
view_range: import_v414.z.array(import_v414.z.number().int()).optional()
|
|
2364
|
+
})
|
|
2365
|
+
)
|
|
2366
|
+
);
|
|
2367
|
+
var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
2246
2368
|
id: "anthropic.text_editor_20250429",
|
|
2247
2369
|
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
|
-
})
|
|
2370
|
+
inputSchema: textEditor_20250429InputSchema
|
|
2257
2371
|
});
|
|
2258
2372
|
|
|
2259
2373
|
// src/anthropic-tools.ts
|
|
@@ -2387,11 +2501,11 @@ var anthropicTools = {
|
|
|
2387
2501
|
// src/anthropic-provider.ts
|
|
2388
2502
|
function createAnthropic(options = {}) {
|
|
2389
2503
|
var _a;
|
|
2390
|
-
const baseURL = (_a = (0,
|
|
2391
|
-
const getHeaders = () => (0,
|
|
2504
|
+
const baseURL = (_a = (0, import_provider_utils18.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
2505
|
+
const getHeaders = () => (0, import_provider_utils18.withUserAgentSuffix)(
|
|
2392
2506
|
{
|
|
2393
2507
|
"anthropic-version": "2023-06-01",
|
|
2394
|
-
"x-api-key": (0,
|
|
2508
|
+
"x-api-key": (0, import_provider_utils18.loadApiKey)({
|
|
2395
2509
|
apiKey: options.apiKey,
|
|
2396
2510
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
2397
2511
|
description: "Anthropic"
|
|
@@ -2407,7 +2521,7 @@ function createAnthropic(options = {}) {
|
|
|
2407
2521
|
baseURL,
|
|
2408
2522
|
headers: getHeaders,
|
|
2409
2523
|
fetch: options.fetch,
|
|
2410
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2524
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils18.generateId,
|
|
2411
2525
|
supportedUrls: () => ({
|
|
2412
2526
|
"image/*": [/^https?:\/\/.*$/]
|
|
2413
2527
|
})
|