@ai-sdk/anthropic 4.0.0-beta.4 → 4.0.0-beta.40
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 +293 -4
- package/README.md +2 -0
- package/dist/index.d.ts +83 -58
- package/dist/index.js +1918 -1259
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +85 -58
- package/dist/internal/index.js +1679 -1245
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +115 -12
- package/package.json +14 -15
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +8 -4
- package/src/anthropic-files.ts +96 -0
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +239 -54
- package/src/anthropic-message-metadata.ts +0 -3
- package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
- package/src/anthropic-prepare-tools.ts +12 -5
- package/src/anthropic-provider.ts +39 -10
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +3 -3
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +51 -28
- package/src/get-cache-control.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal/index.ts +11 -2
- package/src/sanitize-json-schema.ts +203 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +136 -0
- package/src/tool/bash_20241022.ts +2 -2
- package/src/tool/bash_20250124.ts +2 -2
- package/src/tool/code-execution_20250522.ts +2 -2
- package/src/tool/code-execution_20250825.ts +2 -2
- package/src/tool/code-execution_20260120.ts +2 -2
- package/src/tool/computer_20241022.ts +2 -2
- package/src/tool/computer_20250124.ts +2 -2
- package/src/tool/computer_20251124.ts +2 -2
- package/src/tool/memory_20250818.ts +2 -2
- package/src/tool/text-editor_20241022.ts +2 -2
- package/src/tool/text-editor_20250124.ts +2 -2
- package/src/tool/text-editor_20250429.ts +2 -2
- package/src/tool/text-editor_20250728.ts +2 -2
- package/src/tool/tool-search-bm25_20251119.ts +2 -2
- package/src/tool/tool-search-regex_20251119.ts +2 -2
- package/src/tool/web-fetch-20250910.ts +2 -2
- package/src/tool/web-fetch-20260209.ts +2 -2
- package/src/tool/web-search_20250305.ts +2 -2
- package/src/tool/web-search_20260209.ts +2 -2
- package/dist/index.d.mts +0 -1090
- package/dist/index.mjs +0 -5244
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -969
- package/dist/internal/index.mjs +0 -5136
- package/dist/internal/index.mjs.map +0 -1
package/dist/internal/index.js
CHANGED
|
@@ -1,367 +1,361 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
AnthropicMessagesLanguageModel: () => AnthropicMessagesLanguageModel,
|
|
24
|
-
anthropicTools: () => anthropicTools,
|
|
25
|
-
prepareTools: () => prepareTools
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
|
|
29
|
-
// src/anthropic-messages-language-model.ts
|
|
30
|
-
var import_provider3 = require("@ai-sdk/provider");
|
|
31
|
-
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
1
|
+
// src/anthropic-language-model.ts
|
|
2
|
+
import {
|
|
3
|
+
APICallError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
combineHeaders,
|
|
7
|
+
createEventSourceResponseHandler,
|
|
8
|
+
createJsonResponseHandler,
|
|
9
|
+
createToolNameMapping,
|
|
10
|
+
generateId,
|
|
11
|
+
isCustomReasoning,
|
|
12
|
+
mapReasoningToProviderBudget,
|
|
13
|
+
mapReasoningToProviderEffort,
|
|
14
|
+
parseProviderOptions as parseProviderOptions2,
|
|
15
|
+
postJsonToApi,
|
|
16
|
+
resolve,
|
|
17
|
+
resolveProviderReference as resolveProviderReference2,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE
|
|
21
|
+
} from "@ai-sdk/provider-utils";
|
|
32
22
|
|
|
33
23
|
// src/anthropic-error.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
import {
|
|
25
|
+
createJsonErrorResponseHandler,
|
|
26
|
+
lazySchema,
|
|
27
|
+
zodSchema
|
|
28
|
+
} from "@ai-sdk/provider-utils";
|
|
29
|
+
import { z } from "zod/v4";
|
|
30
|
+
var anthropicErrorDataSchema = lazySchema(
|
|
31
|
+
() => zodSchema(
|
|
32
|
+
z.object({
|
|
33
|
+
type: z.literal("error"),
|
|
34
|
+
error: z.object({
|
|
35
|
+
type: z.string(),
|
|
36
|
+
message: z.string()
|
|
43
37
|
})
|
|
44
38
|
})
|
|
45
39
|
)
|
|
46
40
|
);
|
|
47
|
-
var anthropicFailedResponseHandler =
|
|
41
|
+
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
48
42
|
errorSchema: anthropicErrorDataSchema,
|
|
49
43
|
errorToMessage: (data) => data.error.message
|
|
50
44
|
});
|
|
51
45
|
|
|
52
|
-
// src/anthropic-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
() => (
|
|
57
|
-
|
|
58
|
-
type:
|
|
59
|
-
id:
|
|
60
|
-
model:
|
|
61
|
-
content:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type:
|
|
65
|
-
text:
|
|
66
|
-
citations:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
type:
|
|
70
|
-
cited_text:
|
|
71
|
-
url:
|
|
72
|
-
title:
|
|
73
|
-
encrypted_index:
|
|
46
|
+
// src/anthropic-api.ts
|
|
47
|
+
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
48
|
+
import { z as z2 } from "zod/v4";
|
|
49
|
+
var anthropicResponseSchema = lazySchema2(
|
|
50
|
+
() => zodSchema2(
|
|
51
|
+
z2.object({
|
|
52
|
+
type: z2.literal("message"),
|
|
53
|
+
id: z2.string().nullish(),
|
|
54
|
+
model: z2.string().nullish(),
|
|
55
|
+
content: z2.array(
|
|
56
|
+
z2.discriminatedUnion("type", [
|
|
57
|
+
z2.object({
|
|
58
|
+
type: z2.literal("text"),
|
|
59
|
+
text: z2.string(),
|
|
60
|
+
citations: z2.array(
|
|
61
|
+
z2.discriminatedUnion("type", [
|
|
62
|
+
z2.object({
|
|
63
|
+
type: z2.literal("web_search_result_location"),
|
|
64
|
+
cited_text: z2.string(),
|
|
65
|
+
url: z2.string(),
|
|
66
|
+
title: z2.string(),
|
|
67
|
+
encrypted_index: z2.string()
|
|
74
68
|
}),
|
|
75
|
-
|
|
76
|
-
type:
|
|
77
|
-
cited_text:
|
|
78
|
-
document_index:
|
|
79
|
-
document_title:
|
|
80
|
-
start_page_number:
|
|
81
|
-
end_page_number:
|
|
69
|
+
z2.object({
|
|
70
|
+
type: z2.literal("page_location"),
|
|
71
|
+
cited_text: z2.string(),
|
|
72
|
+
document_index: z2.number(),
|
|
73
|
+
document_title: z2.string().nullable(),
|
|
74
|
+
start_page_number: z2.number(),
|
|
75
|
+
end_page_number: z2.number()
|
|
82
76
|
}),
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
cited_text:
|
|
86
|
-
document_index:
|
|
87
|
-
document_title:
|
|
88
|
-
start_char_index:
|
|
89
|
-
end_char_index:
|
|
77
|
+
z2.object({
|
|
78
|
+
type: z2.literal("char_location"),
|
|
79
|
+
cited_text: z2.string(),
|
|
80
|
+
document_index: z2.number(),
|
|
81
|
+
document_title: z2.string().nullable(),
|
|
82
|
+
start_char_index: z2.number(),
|
|
83
|
+
end_char_index: z2.number()
|
|
90
84
|
})
|
|
91
85
|
])
|
|
92
86
|
).optional()
|
|
93
87
|
}),
|
|
94
|
-
|
|
95
|
-
type:
|
|
96
|
-
thinking:
|
|
97
|
-
signature:
|
|
88
|
+
z2.object({
|
|
89
|
+
type: z2.literal("thinking"),
|
|
90
|
+
thinking: z2.string(),
|
|
91
|
+
signature: z2.string()
|
|
98
92
|
}),
|
|
99
|
-
|
|
100
|
-
type:
|
|
101
|
-
data:
|
|
93
|
+
z2.object({
|
|
94
|
+
type: z2.literal("redacted_thinking"),
|
|
95
|
+
data: z2.string()
|
|
102
96
|
}),
|
|
103
|
-
|
|
104
|
-
type:
|
|
105
|
-
content:
|
|
97
|
+
z2.object({
|
|
98
|
+
type: z2.literal("compaction"),
|
|
99
|
+
content: z2.string()
|
|
106
100
|
}),
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
id:
|
|
110
|
-
name:
|
|
111
|
-
input:
|
|
101
|
+
z2.object({
|
|
102
|
+
type: z2.literal("tool_use"),
|
|
103
|
+
id: z2.string(),
|
|
104
|
+
name: z2.string(),
|
|
105
|
+
input: z2.unknown(),
|
|
112
106
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
113
|
-
caller:
|
|
114
|
-
|
|
115
|
-
type:
|
|
116
|
-
tool_id:
|
|
107
|
+
caller: z2.union([
|
|
108
|
+
z2.object({
|
|
109
|
+
type: z2.literal("code_execution_20250825"),
|
|
110
|
+
tool_id: z2.string()
|
|
117
111
|
}),
|
|
118
|
-
|
|
119
|
-
type:
|
|
120
|
-
tool_id:
|
|
112
|
+
z2.object({
|
|
113
|
+
type: z2.literal("code_execution_20260120"),
|
|
114
|
+
tool_id: z2.string()
|
|
121
115
|
}),
|
|
122
|
-
|
|
123
|
-
type:
|
|
116
|
+
z2.object({
|
|
117
|
+
type: z2.literal("direct")
|
|
124
118
|
})
|
|
125
119
|
]).optional()
|
|
126
120
|
}),
|
|
127
|
-
|
|
128
|
-
type:
|
|
129
|
-
id:
|
|
130
|
-
name:
|
|
131
|
-
input:
|
|
132
|
-
caller:
|
|
133
|
-
|
|
134
|
-
type:
|
|
135
|
-
tool_id:
|
|
121
|
+
z2.object({
|
|
122
|
+
type: z2.literal("server_tool_use"),
|
|
123
|
+
id: z2.string(),
|
|
124
|
+
name: z2.string(),
|
|
125
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
126
|
+
caller: z2.union([
|
|
127
|
+
z2.object({
|
|
128
|
+
type: z2.literal("code_execution_20260120"),
|
|
129
|
+
tool_id: z2.string()
|
|
136
130
|
}),
|
|
137
|
-
|
|
138
|
-
type:
|
|
131
|
+
z2.object({
|
|
132
|
+
type: z2.literal("direct")
|
|
139
133
|
})
|
|
140
134
|
]).optional()
|
|
141
135
|
}),
|
|
142
|
-
|
|
143
|
-
type:
|
|
144
|
-
id:
|
|
145
|
-
name:
|
|
146
|
-
input:
|
|
147
|
-
server_name:
|
|
136
|
+
z2.object({
|
|
137
|
+
type: z2.literal("mcp_tool_use"),
|
|
138
|
+
id: z2.string(),
|
|
139
|
+
name: z2.string(),
|
|
140
|
+
input: z2.unknown(),
|
|
141
|
+
server_name: z2.string()
|
|
148
142
|
}),
|
|
149
|
-
|
|
150
|
-
type:
|
|
151
|
-
tool_use_id:
|
|
152
|
-
is_error:
|
|
153
|
-
content:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
z2.object({
|
|
144
|
+
type: z2.literal("mcp_tool_result"),
|
|
145
|
+
tool_use_id: z2.string(),
|
|
146
|
+
is_error: z2.boolean(),
|
|
147
|
+
content: z2.array(
|
|
148
|
+
z2.union([
|
|
149
|
+
z2.string(),
|
|
150
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
157
151
|
])
|
|
158
152
|
)
|
|
159
153
|
}),
|
|
160
|
-
|
|
161
|
-
type:
|
|
162
|
-
tool_use_id:
|
|
163
|
-
content:
|
|
164
|
-
|
|
165
|
-
type:
|
|
166
|
-
url:
|
|
167
|
-
retrieved_at:
|
|
168
|
-
content:
|
|
169
|
-
type:
|
|
170
|
-
title:
|
|
171
|
-
citations:
|
|
172
|
-
source:
|
|
173
|
-
|
|
174
|
-
type:
|
|
175
|
-
media_type:
|
|
176
|
-
data:
|
|
154
|
+
z2.object({
|
|
155
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
156
|
+
tool_use_id: z2.string(),
|
|
157
|
+
content: z2.union([
|
|
158
|
+
z2.object({
|
|
159
|
+
type: z2.literal("web_fetch_result"),
|
|
160
|
+
url: z2.string(),
|
|
161
|
+
retrieved_at: z2.string(),
|
|
162
|
+
content: z2.object({
|
|
163
|
+
type: z2.literal("document"),
|
|
164
|
+
title: z2.string().nullable(),
|
|
165
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
166
|
+
source: z2.union([
|
|
167
|
+
z2.object({
|
|
168
|
+
type: z2.literal("base64"),
|
|
169
|
+
media_type: z2.literal("application/pdf"),
|
|
170
|
+
data: z2.string()
|
|
177
171
|
}),
|
|
178
|
-
|
|
179
|
-
type:
|
|
180
|
-
media_type:
|
|
181
|
-
data:
|
|
172
|
+
z2.object({
|
|
173
|
+
type: z2.literal("text"),
|
|
174
|
+
media_type: z2.literal("text/plain"),
|
|
175
|
+
data: z2.string()
|
|
182
176
|
})
|
|
183
177
|
])
|
|
184
178
|
})
|
|
185
179
|
}),
|
|
186
|
-
|
|
187
|
-
type:
|
|
188
|
-
error_code:
|
|
180
|
+
z2.object({
|
|
181
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
182
|
+
error_code: z2.string()
|
|
189
183
|
})
|
|
190
184
|
])
|
|
191
185
|
}),
|
|
192
|
-
|
|
193
|
-
type:
|
|
194
|
-
tool_use_id:
|
|
195
|
-
content:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
type:
|
|
199
|
-
url:
|
|
200
|
-
title:
|
|
201
|
-
encrypted_content:
|
|
202
|
-
page_age:
|
|
186
|
+
z2.object({
|
|
187
|
+
type: z2.literal("web_search_tool_result"),
|
|
188
|
+
tool_use_id: z2.string(),
|
|
189
|
+
content: z2.union([
|
|
190
|
+
z2.array(
|
|
191
|
+
z2.object({
|
|
192
|
+
type: z2.literal("web_search_result"),
|
|
193
|
+
url: z2.string(),
|
|
194
|
+
title: z2.string(),
|
|
195
|
+
encrypted_content: z2.string(),
|
|
196
|
+
page_age: z2.string().nullish()
|
|
203
197
|
})
|
|
204
198
|
),
|
|
205
|
-
|
|
206
|
-
type:
|
|
207
|
-
error_code:
|
|
199
|
+
z2.object({
|
|
200
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
201
|
+
error_code: z2.string()
|
|
208
202
|
})
|
|
209
203
|
])
|
|
210
204
|
}),
|
|
211
205
|
// code execution results for code_execution_20250522 tool:
|
|
212
|
-
|
|
213
|
-
type:
|
|
214
|
-
tool_use_id:
|
|
215
|
-
content:
|
|
216
|
-
|
|
217
|
-
type:
|
|
218
|
-
stdout:
|
|
219
|
-
stderr:
|
|
220
|
-
return_code:
|
|
221
|
-
content:
|
|
222
|
-
|
|
223
|
-
type:
|
|
224
|
-
file_id:
|
|
206
|
+
z2.object({
|
|
207
|
+
type: z2.literal("code_execution_tool_result"),
|
|
208
|
+
tool_use_id: z2.string(),
|
|
209
|
+
content: z2.union([
|
|
210
|
+
z2.object({
|
|
211
|
+
type: z2.literal("code_execution_result"),
|
|
212
|
+
stdout: z2.string(),
|
|
213
|
+
stderr: z2.string(),
|
|
214
|
+
return_code: z2.number(),
|
|
215
|
+
content: z2.array(
|
|
216
|
+
z2.object({
|
|
217
|
+
type: z2.literal("code_execution_output"),
|
|
218
|
+
file_id: z2.string()
|
|
225
219
|
})
|
|
226
220
|
).optional().default([])
|
|
227
221
|
}),
|
|
228
|
-
|
|
229
|
-
type:
|
|
230
|
-
encrypted_stdout:
|
|
231
|
-
stderr:
|
|
232
|
-
return_code:
|
|
233
|
-
content:
|
|
234
|
-
|
|
235
|
-
type:
|
|
236
|
-
file_id:
|
|
222
|
+
z2.object({
|
|
223
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
224
|
+
encrypted_stdout: z2.string(),
|
|
225
|
+
stderr: z2.string(),
|
|
226
|
+
return_code: z2.number(),
|
|
227
|
+
content: z2.array(
|
|
228
|
+
z2.object({
|
|
229
|
+
type: z2.literal("code_execution_output"),
|
|
230
|
+
file_id: z2.string()
|
|
237
231
|
})
|
|
238
232
|
).optional().default([])
|
|
239
233
|
}),
|
|
240
|
-
|
|
241
|
-
type:
|
|
242
|
-
error_code:
|
|
234
|
+
z2.object({
|
|
235
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
236
|
+
error_code: z2.string()
|
|
243
237
|
})
|
|
244
238
|
])
|
|
245
239
|
}),
|
|
246
240
|
// bash code execution results for code_execution_20250825 tool:
|
|
247
|
-
|
|
248
|
-
type:
|
|
249
|
-
tool_use_id:
|
|
250
|
-
content:
|
|
251
|
-
|
|
252
|
-
type:
|
|
253
|
-
content:
|
|
254
|
-
|
|
255
|
-
type:
|
|
256
|
-
file_id:
|
|
241
|
+
z2.object({
|
|
242
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
243
|
+
tool_use_id: z2.string(),
|
|
244
|
+
content: z2.discriminatedUnion("type", [
|
|
245
|
+
z2.object({
|
|
246
|
+
type: z2.literal("bash_code_execution_result"),
|
|
247
|
+
content: z2.array(
|
|
248
|
+
z2.object({
|
|
249
|
+
type: z2.literal("bash_code_execution_output"),
|
|
250
|
+
file_id: z2.string()
|
|
257
251
|
})
|
|
258
252
|
),
|
|
259
|
-
stdout:
|
|
260
|
-
stderr:
|
|
261
|
-
return_code:
|
|
253
|
+
stdout: z2.string(),
|
|
254
|
+
stderr: z2.string(),
|
|
255
|
+
return_code: z2.number()
|
|
262
256
|
}),
|
|
263
|
-
|
|
264
|
-
type:
|
|
265
|
-
error_code:
|
|
257
|
+
z2.object({
|
|
258
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
259
|
+
error_code: z2.string()
|
|
266
260
|
})
|
|
267
261
|
])
|
|
268
262
|
}),
|
|
269
263
|
// text editor code execution results for code_execution_20250825 tool:
|
|
270
|
-
|
|
271
|
-
type:
|
|
272
|
-
tool_use_id:
|
|
273
|
-
content:
|
|
274
|
-
|
|
275
|
-
type:
|
|
276
|
-
error_code:
|
|
264
|
+
z2.object({
|
|
265
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
266
|
+
tool_use_id: z2.string(),
|
|
267
|
+
content: z2.discriminatedUnion("type", [
|
|
268
|
+
z2.object({
|
|
269
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
270
|
+
error_code: z2.string()
|
|
277
271
|
}),
|
|
278
|
-
|
|
279
|
-
type:
|
|
280
|
-
content:
|
|
281
|
-
file_type:
|
|
282
|
-
num_lines:
|
|
283
|
-
start_line:
|
|
284
|
-
total_lines:
|
|
272
|
+
z2.object({
|
|
273
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
274
|
+
content: z2.string(),
|
|
275
|
+
file_type: z2.string(),
|
|
276
|
+
num_lines: z2.number().nullable(),
|
|
277
|
+
start_line: z2.number().nullable(),
|
|
278
|
+
total_lines: z2.number().nullable()
|
|
285
279
|
}),
|
|
286
|
-
|
|
287
|
-
type:
|
|
288
|
-
is_file_update:
|
|
280
|
+
z2.object({
|
|
281
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
282
|
+
is_file_update: z2.boolean()
|
|
289
283
|
}),
|
|
290
|
-
|
|
291
|
-
type:
|
|
284
|
+
z2.object({
|
|
285
|
+
type: z2.literal(
|
|
292
286
|
"text_editor_code_execution_str_replace_result"
|
|
293
287
|
),
|
|
294
|
-
lines:
|
|
295
|
-
new_lines:
|
|
296
|
-
new_start:
|
|
297
|
-
old_lines:
|
|
298
|
-
old_start:
|
|
288
|
+
lines: z2.array(z2.string()).nullable(),
|
|
289
|
+
new_lines: z2.number().nullable(),
|
|
290
|
+
new_start: z2.number().nullable(),
|
|
291
|
+
old_lines: z2.number().nullable(),
|
|
292
|
+
old_start: z2.number().nullable()
|
|
299
293
|
})
|
|
300
294
|
])
|
|
301
295
|
}),
|
|
302
296
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
303
|
-
|
|
304
|
-
type:
|
|
305
|
-
tool_use_id:
|
|
306
|
-
content:
|
|
307
|
-
|
|
308
|
-
type:
|
|
309
|
-
tool_references:
|
|
310
|
-
|
|
311
|
-
type:
|
|
312
|
-
tool_name:
|
|
297
|
+
z2.object({
|
|
298
|
+
type: z2.literal("tool_search_tool_result"),
|
|
299
|
+
tool_use_id: z2.string(),
|
|
300
|
+
content: z2.union([
|
|
301
|
+
z2.object({
|
|
302
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
303
|
+
tool_references: z2.array(
|
|
304
|
+
z2.object({
|
|
305
|
+
type: z2.literal("tool_reference"),
|
|
306
|
+
tool_name: z2.string()
|
|
313
307
|
})
|
|
314
308
|
)
|
|
315
309
|
}),
|
|
316
|
-
|
|
317
|
-
type:
|
|
318
|
-
error_code:
|
|
310
|
+
z2.object({
|
|
311
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
312
|
+
error_code: z2.string()
|
|
319
313
|
})
|
|
320
314
|
])
|
|
321
315
|
})
|
|
322
316
|
])
|
|
323
317
|
),
|
|
324
|
-
stop_reason:
|
|
325
|
-
stop_sequence:
|
|
326
|
-
usage:
|
|
327
|
-
input_tokens:
|
|
328
|
-
output_tokens:
|
|
329
|
-
cache_creation_input_tokens:
|
|
330
|
-
cache_read_input_tokens:
|
|
331
|
-
iterations:
|
|
332
|
-
|
|
333
|
-
type:
|
|
334
|
-
input_tokens:
|
|
335
|
-
output_tokens:
|
|
318
|
+
stop_reason: z2.string().nullish(),
|
|
319
|
+
stop_sequence: z2.string().nullish(),
|
|
320
|
+
usage: z2.looseObject({
|
|
321
|
+
input_tokens: z2.number(),
|
|
322
|
+
output_tokens: z2.number(),
|
|
323
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
324
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
325
|
+
iterations: z2.array(
|
|
326
|
+
z2.object({
|
|
327
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
328
|
+
input_tokens: z2.number(),
|
|
329
|
+
output_tokens: z2.number()
|
|
336
330
|
})
|
|
337
331
|
).nullish()
|
|
338
332
|
}),
|
|
339
|
-
container:
|
|
340
|
-
expires_at:
|
|
341
|
-
id:
|
|
342
|
-
skills:
|
|
343
|
-
|
|
344
|
-
type:
|
|
345
|
-
skill_id:
|
|
346
|
-
version:
|
|
333
|
+
container: z2.object({
|
|
334
|
+
expires_at: z2.string(),
|
|
335
|
+
id: z2.string(),
|
|
336
|
+
skills: z2.array(
|
|
337
|
+
z2.object({
|
|
338
|
+
type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
|
|
339
|
+
skill_id: z2.string(),
|
|
340
|
+
version: z2.string()
|
|
347
341
|
})
|
|
348
342
|
).nullish()
|
|
349
343
|
}).nullish(),
|
|
350
|
-
context_management:
|
|
351
|
-
applied_edits:
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
type:
|
|
355
|
-
cleared_tool_uses:
|
|
356
|
-
cleared_input_tokens:
|
|
344
|
+
context_management: z2.object({
|
|
345
|
+
applied_edits: z2.array(
|
|
346
|
+
z2.union([
|
|
347
|
+
z2.object({
|
|
348
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
349
|
+
cleared_tool_uses: z2.number(),
|
|
350
|
+
cleared_input_tokens: z2.number()
|
|
357
351
|
}),
|
|
358
|
-
|
|
359
|
-
type:
|
|
360
|
-
cleared_thinking_turns:
|
|
361
|
-
cleared_input_tokens:
|
|
352
|
+
z2.object({
|
|
353
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
354
|
+
cleared_thinking_turns: z2.number(),
|
|
355
|
+
cleared_input_tokens: z2.number()
|
|
362
356
|
}),
|
|
363
|
-
|
|
364
|
-
type:
|
|
357
|
+
z2.object({
|
|
358
|
+
type: z2.literal("compact_20260112")
|
|
365
359
|
})
|
|
366
360
|
])
|
|
367
361
|
)
|
|
@@ -369,457 +363,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
369
363
|
})
|
|
370
364
|
)
|
|
371
365
|
);
|
|
372
|
-
var
|
|
373
|
-
() => (
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
type:
|
|
377
|
-
message:
|
|
378
|
-
id:
|
|
379
|
-
model:
|
|
380
|
-
role:
|
|
381
|
-
usage:
|
|
382
|
-
input_tokens:
|
|
383
|
-
cache_creation_input_tokens:
|
|
384
|
-
cache_read_input_tokens:
|
|
366
|
+
var anthropicChunkSchema = lazySchema2(
|
|
367
|
+
() => zodSchema2(
|
|
368
|
+
z2.discriminatedUnion("type", [
|
|
369
|
+
z2.object({
|
|
370
|
+
type: z2.literal("message_start"),
|
|
371
|
+
message: z2.object({
|
|
372
|
+
id: z2.string().nullish(),
|
|
373
|
+
model: z2.string().nullish(),
|
|
374
|
+
role: z2.string().nullish(),
|
|
375
|
+
usage: z2.looseObject({
|
|
376
|
+
input_tokens: z2.number(),
|
|
377
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
378
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
385
379
|
}),
|
|
386
380
|
// Programmatic tool calling: content may be pre-populated for deferred tool calls
|
|
387
|
-
content:
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
type:
|
|
391
|
-
id:
|
|
392
|
-
name:
|
|
393
|
-
input:
|
|
394
|
-
caller:
|
|
395
|
-
|
|
396
|
-
type:
|
|
397
|
-
tool_id:
|
|
381
|
+
content: z2.array(
|
|
382
|
+
z2.discriminatedUnion("type", [
|
|
383
|
+
z2.object({
|
|
384
|
+
type: z2.literal("tool_use"),
|
|
385
|
+
id: z2.string(),
|
|
386
|
+
name: z2.string(),
|
|
387
|
+
input: z2.unknown(),
|
|
388
|
+
caller: z2.union([
|
|
389
|
+
z2.object({
|
|
390
|
+
type: z2.literal("code_execution_20250825"),
|
|
391
|
+
tool_id: z2.string()
|
|
398
392
|
}),
|
|
399
|
-
|
|
400
|
-
type:
|
|
401
|
-
tool_id:
|
|
393
|
+
z2.object({
|
|
394
|
+
type: z2.literal("code_execution_20260120"),
|
|
395
|
+
tool_id: z2.string()
|
|
402
396
|
}),
|
|
403
|
-
|
|
404
|
-
type:
|
|
397
|
+
z2.object({
|
|
398
|
+
type: z2.literal("direct")
|
|
405
399
|
})
|
|
406
400
|
]).optional()
|
|
407
401
|
})
|
|
408
402
|
])
|
|
409
403
|
).nullish(),
|
|
410
|
-
stop_reason:
|
|
411
|
-
container:
|
|
412
|
-
expires_at:
|
|
413
|
-
id:
|
|
404
|
+
stop_reason: z2.string().nullish(),
|
|
405
|
+
container: z2.object({
|
|
406
|
+
expires_at: z2.string(),
|
|
407
|
+
id: z2.string()
|
|
414
408
|
}).nullish()
|
|
415
409
|
})
|
|
416
410
|
}),
|
|
417
|
-
|
|
418
|
-
type:
|
|
419
|
-
index:
|
|
420
|
-
content_block:
|
|
421
|
-
|
|
422
|
-
type:
|
|
423
|
-
text:
|
|
411
|
+
z2.object({
|
|
412
|
+
type: z2.literal("content_block_start"),
|
|
413
|
+
index: z2.number(),
|
|
414
|
+
content_block: z2.discriminatedUnion("type", [
|
|
415
|
+
z2.object({
|
|
416
|
+
type: z2.literal("text"),
|
|
417
|
+
text: z2.string()
|
|
424
418
|
}),
|
|
425
|
-
|
|
426
|
-
type:
|
|
427
|
-
thinking:
|
|
419
|
+
z2.object({
|
|
420
|
+
type: z2.literal("thinking"),
|
|
421
|
+
thinking: z2.string()
|
|
428
422
|
}),
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
id:
|
|
432
|
-
name:
|
|
423
|
+
z2.object({
|
|
424
|
+
type: z2.literal("tool_use"),
|
|
425
|
+
id: z2.string(),
|
|
426
|
+
name: z2.string(),
|
|
433
427
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
434
|
-
input:
|
|
428
|
+
input: z2.record(z2.string(), z2.unknown()).optional(),
|
|
435
429
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
436
|
-
caller:
|
|
437
|
-
|
|
438
|
-
type:
|
|
439
|
-
tool_id:
|
|
430
|
+
caller: z2.union([
|
|
431
|
+
z2.object({
|
|
432
|
+
type: z2.literal("code_execution_20250825"),
|
|
433
|
+
tool_id: z2.string()
|
|
440
434
|
}),
|
|
441
|
-
|
|
442
|
-
type:
|
|
443
|
-
tool_id:
|
|
435
|
+
z2.object({
|
|
436
|
+
type: z2.literal("code_execution_20260120"),
|
|
437
|
+
tool_id: z2.string()
|
|
444
438
|
}),
|
|
445
|
-
|
|
446
|
-
type:
|
|
439
|
+
z2.object({
|
|
440
|
+
type: z2.literal("direct")
|
|
447
441
|
})
|
|
448
442
|
]).optional()
|
|
449
443
|
}),
|
|
450
|
-
|
|
451
|
-
type:
|
|
452
|
-
data:
|
|
444
|
+
z2.object({
|
|
445
|
+
type: z2.literal("redacted_thinking"),
|
|
446
|
+
data: z2.string()
|
|
453
447
|
}),
|
|
454
|
-
|
|
455
|
-
type:
|
|
456
|
-
content:
|
|
448
|
+
z2.object({
|
|
449
|
+
type: z2.literal("compaction"),
|
|
450
|
+
content: z2.string().nullish()
|
|
457
451
|
}),
|
|
458
|
-
|
|
459
|
-
type:
|
|
460
|
-
id:
|
|
461
|
-
name:
|
|
462
|
-
input:
|
|
463
|
-
caller:
|
|
464
|
-
|
|
465
|
-
type:
|
|
466
|
-
tool_id:
|
|
452
|
+
z2.object({
|
|
453
|
+
type: z2.literal("server_tool_use"),
|
|
454
|
+
id: z2.string(),
|
|
455
|
+
name: z2.string(),
|
|
456
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
457
|
+
caller: z2.union([
|
|
458
|
+
z2.object({
|
|
459
|
+
type: z2.literal("code_execution_20260120"),
|
|
460
|
+
tool_id: z2.string()
|
|
467
461
|
}),
|
|
468
|
-
|
|
469
|
-
type:
|
|
462
|
+
z2.object({
|
|
463
|
+
type: z2.literal("direct")
|
|
470
464
|
})
|
|
471
465
|
]).optional()
|
|
472
466
|
}),
|
|
473
|
-
|
|
474
|
-
type:
|
|
475
|
-
id:
|
|
476
|
-
name:
|
|
477
|
-
input:
|
|
478
|
-
server_name:
|
|
467
|
+
z2.object({
|
|
468
|
+
type: z2.literal("mcp_tool_use"),
|
|
469
|
+
id: z2.string(),
|
|
470
|
+
name: z2.string(),
|
|
471
|
+
input: z2.unknown(),
|
|
472
|
+
server_name: z2.string()
|
|
479
473
|
}),
|
|
480
|
-
|
|
481
|
-
type:
|
|
482
|
-
tool_use_id:
|
|
483
|
-
is_error:
|
|
484
|
-
content:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
474
|
+
z2.object({
|
|
475
|
+
type: z2.literal("mcp_tool_result"),
|
|
476
|
+
tool_use_id: z2.string(),
|
|
477
|
+
is_error: z2.boolean(),
|
|
478
|
+
content: z2.array(
|
|
479
|
+
z2.union([
|
|
480
|
+
z2.string(),
|
|
481
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
488
482
|
])
|
|
489
483
|
)
|
|
490
484
|
}),
|
|
491
|
-
|
|
492
|
-
type:
|
|
493
|
-
tool_use_id:
|
|
494
|
-
content:
|
|
495
|
-
|
|
496
|
-
type:
|
|
497
|
-
url:
|
|
498
|
-
retrieved_at:
|
|
499
|
-
content:
|
|
500
|
-
type:
|
|
501
|
-
title:
|
|
502
|
-
citations:
|
|
503
|
-
source:
|
|
504
|
-
|
|
505
|
-
type:
|
|
506
|
-
media_type:
|
|
507
|
-
data:
|
|
485
|
+
z2.object({
|
|
486
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
487
|
+
tool_use_id: z2.string(),
|
|
488
|
+
content: z2.union([
|
|
489
|
+
z2.object({
|
|
490
|
+
type: z2.literal("web_fetch_result"),
|
|
491
|
+
url: z2.string(),
|
|
492
|
+
retrieved_at: z2.string(),
|
|
493
|
+
content: z2.object({
|
|
494
|
+
type: z2.literal("document"),
|
|
495
|
+
title: z2.string().nullable(),
|
|
496
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
497
|
+
source: z2.union([
|
|
498
|
+
z2.object({
|
|
499
|
+
type: z2.literal("base64"),
|
|
500
|
+
media_type: z2.literal("application/pdf"),
|
|
501
|
+
data: z2.string()
|
|
508
502
|
}),
|
|
509
|
-
|
|
510
|
-
type:
|
|
511
|
-
media_type:
|
|
512
|
-
data:
|
|
503
|
+
z2.object({
|
|
504
|
+
type: z2.literal("text"),
|
|
505
|
+
media_type: z2.literal("text/plain"),
|
|
506
|
+
data: z2.string()
|
|
513
507
|
})
|
|
514
508
|
])
|
|
515
509
|
})
|
|
516
510
|
}),
|
|
517
|
-
|
|
518
|
-
type:
|
|
519
|
-
error_code:
|
|
511
|
+
z2.object({
|
|
512
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
513
|
+
error_code: z2.string()
|
|
520
514
|
})
|
|
521
515
|
])
|
|
522
516
|
}),
|
|
523
|
-
|
|
524
|
-
type:
|
|
525
|
-
tool_use_id:
|
|
526
|
-
content:
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
type:
|
|
530
|
-
url:
|
|
531
|
-
title:
|
|
532
|
-
encrypted_content:
|
|
533
|
-
page_age:
|
|
517
|
+
z2.object({
|
|
518
|
+
type: z2.literal("web_search_tool_result"),
|
|
519
|
+
tool_use_id: z2.string(),
|
|
520
|
+
content: z2.union([
|
|
521
|
+
z2.array(
|
|
522
|
+
z2.object({
|
|
523
|
+
type: z2.literal("web_search_result"),
|
|
524
|
+
url: z2.string(),
|
|
525
|
+
title: z2.string(),
|
|
526
|
+
encrypted_content: z2.string(),
|
|
527
|
+
page_age: z2.string().nullish()
|
|
534
528
|
})
|
|
535
529
|
),
|
|
536
|
-
|
|
537
|
-
type:
|
|
538
|
-
error_code:
|
|
530
|
+
z2.object({
|
|
531
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
532
|
+
error_code: z2.string()
|
|
539
533
|
})
|
|
540
534
|
])
|
|
541
535
|
}),
|
|
542
536
|
// code execution results for code_execution_20250522 tool:
|
|
543
|
-
|
|
544
|
-
type:
|
|
545
|
-
tool_use_id:
|
|
546
|
-
content:
|
|
547
|
-
|
|
548
|
-
type:
|
|
549
|
-
stdout:
|
|
550
|
-
stderr:
|
|
551
|
-
return_code:
|
|
552
|
-
content:
|
|
553
|
-
|
|
554
|
-
type:
|
|
555
|
-
file_id:
|
|
537
|
+
z2.object({
|
|
538
|
+
type: z2.literal("code_execution_tool_result"),
|
|
539
|
+
tool_use_id: z2.string(),
|
|
540
|
+
content: z2.union([
|
|
541
|
+
z2.object({
|
|
542
|
+
type: z2.literal("code_execution_result"),
|
|
543
|
+
stdout: z2.string(),
|
|
544
|
+
stderr: z2.string(),
|
|
545
|
+
return_code: z2.number(),
|
|
546
|
+
content: z2.array(
|
|
547
|
+
z2.object({
|
|
548
|
+
type: z2.literal("code_execution_output"),
|
|
549
|
+
file_id: z2.string()
|
|
556
550
|
})
|
|
557
551
|
).optional().default([])
|
|
558
552
|
}),
|
|
559
|
-
|
|
560
|
-
type:
|
|
561
|
-
encrypted_stdout:
|
|
562
|
-
stderr:
|
|
563
|
-
return_code:
|
|
564
|
-
content:
|
|
565
|
-
|
|
566
|
-
type:
|
|
567
|
-
file_id:
|
|
553
|
+
z2.object({
|
|
554
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
555
|
+
encrypted_stdout: z2.string(),
|
|
556
|
+
stderr: z2.string(),
|
|
557
|
+
return_code: z2.number(),
|
|
558
|
+
content: z2.array(
|
|
559
|
+
z2.object({
|
|
560
|
+
type: z2.literal("code_execution_output"),
|
|
561
|
+
file_id: z2.string()
|
|
568
562
|
})
|
|
569
563
|
).optional().default([])
|
|
570
564
|
}),
|
|
571
|
-
|
|
572
|
-
type:
|
|
573
|
-
error_code:
|
|
565
|
+
z2.object({
|
|
566
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
567
|
+
error_code: z2.string()
|
|
574
568
|
})
|
|
575
569
|
])
|
|
576
570
|
}),
|
|
577
571
|
// bash code execution results for code_execution_20250825 tool:
|
|
578
|
-
|
|
579
|
-
type:
|
|
580
|
-
tool_use_id:
|
|
581
|
-
content:
|
|
582
|
-
|
|
583
|
-
type:
|
|
584
|
-
content:
|
|
585
|
-
|
|
586
|
-
type:
|
|
587
|
-
file_id:
|
|
572
|
+
z2.object({
|
|
573
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
574
|
+
tool_use_id: z2.string(),
|
|
575
|
+
content: z2.discriminatedUnion("type", [
|
|
576
|
+
z2.object({
|
|
577
|
+
type: z2.literal("bash_code_execution_result"),
|
|
578
|
+
content: z2.array(
|
|
579
|
+
z2.object({
|
|
580
|
+
type: z2.literal("bash_code_execution_output"),
|
|
581
|
+
file_id: z2.string()
|
|
588
582
|
})
|
|
589
583
|
),
|
|
590
|
-
stdout:
|
|
591
|
-
stderr:
|
|
592
|
-
return_code:
|
|
584
|
+
stdout: z2.string(),
|
|
585
|
+
stderr: z2.string(),
|
|
586
|
+
return_code: z2.number()
|
|
593
587
|
}),
|
|
594
|
-
|
|
595
|
-
type:
|
|
596
|
-
error_code:
|
|
588
|
+
z2.object({
|
|
589
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
590
|
+
error_code: z2.string()
|
|
597
591
|
})
|
|
598
592
|
])
|
|
599
593
|
}),
|
|
600
594
|
// text editor code execution results for code_execution_20250825 tool:
|
|
601
|
-
|
|
602
|
-
type:
|
|
603
|
-
tool_use_id:
|
|
604
|
-
content:
|
|
605
|
-
|
|
606
|
-
type:
|
|
607
|
-
error_code:
|
|
595
|
+
z2.object({
|
|
596
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
597
|
+
tool_use_id: z2.string(),
|
|
598
|
+
content: z2.discriminatedUnion("type", [
|
|
599
|
+
z2.object({
|
|
600
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
601
|
+
error_code: z2.string()
|
|
608
602
|
}),
|
|
609
|
-
|
|
610
|
-
type:
|
|
611
|
-
content:
|
|
612
|
-
file_type:
|
|
613
|
-
num_lines:
|
|
614
|
-
start_line:
|
|
615
|
-
total_lines:
|
|
603
|
+
z2.object({
|
|
604
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
605
|
+
content: z2.string(),
|
|
606
|
+
file_type: z2.string(),
|
|
607
|
+
num_lines: z2.number().nullable(),
|
|
608
|
+
start_line: z2.number().nullable(),
|
|
609
|
+
total_lines: z2.number().nullable()
|
|
616
610
|
}),
|
|
617
|
-
|
|
618
|
-
type:
|
|
619
|
-
is_file_update:
|
|
611
|
+
z2.object({
|
|
612
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
613
|
+
is_file_update: z2.boolean()
|
|
620
614
|
}),
|
|
621
|
-
|
|
622
|
-
type:
|
|
615
|
+
z2.object({
|
|
616
|
+
type: z2.literal(
|
|
623
617
|
"text_editor_code_execution_str_replace_result"
|
|
624
618
|
),
|
|
625
|
-
lines:
|
|
626
|
-
new_lines:
|
|
627
|
-
new_start:
|
|
628
|
-
old_lines:
|
|
629
|
-
old_start:
|
|
619
|
+
lines: z2.array(z2.string()).nullable(),
|
|
620
|
+
new_lines: z2.number().nullable(),
|
|
621
|
+
new_start: z2.number().nullable(),
|
|
622
|
+
old_lines: z2.number().nullable(),
|
|
623
|
+
old_start: z2.number().nullable()
|
|
630
624
|
})
|
|
631
625
|
])
|
|
632
626
|
}),
|
|
633
627
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
634
|
-
|
|
635
|
-
type:
|
|
636
|
-
tool_use_id:
|
|
637
|
-
content:
|
|
638
|
-
|
|
639
|
-
type:
|
|
640
|
-
tool_references:
|
|
641
|
-
|
|
642
|
-
type:
|
|
643
|
-
tool_name:
|
|
628
|
+
z2.object({
|
|
629
|
+
type: z2.literal("tool_search_tool_result"),
|
|
630
|
+
tool_use_id: z2.string(),
|
|
631
|
+
content: z2.union([
|
|
632
|
+
z2.object({
|
|
633
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
634
|
+
tool_references: z2.array(
|
|
635
|
+
z2.object({
|
|
636
|
+
type: z2.literal("tool_reference"),
|
|
637
|
+
tool_name: z2.string()
|
|
644
638
|
})
|
|
645
639
|
)
|
|
646
640
|
}),
|
|
647
|
-
|
|
648
|
-
type:
|
|
649
|
-
error_code:
|
|
641
|
+
z2.object({
|
|
642
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
643
|
+
error_code: z2.string()
|
|
650
644
|
})
|
|
651
645
|
])
|
|
652
646
|
})
|
|
653
647
|
])
|
|
654
648
|
}),
|
|
655
|
-
|
|
656
|
-
type:
|
|
657
|
-
index:
|
|
658
|
-
delta:
|
|
659
|
-
|
|
660
|
-
type:
|
|
661
|
-
partial_json:
|
|
649
|
+
z2.object({
|
|
650
|
+
type: z2.literal("content_block_delta"),
|
|
651
|
+
index: z2.number(),
|
|
652
|
+
delta: z2.discriminatedUnion("type", [
|
|
653
|
+
z2.object({
|
|
654
|
+
type: z2.literal("input_json_delta"),
|
|
655
|
+
partial_json: z2.string()
|
|
662
656
|
}),
|
|
663
|
-
|
|
664
|
-
type:
|
|
665
|
-
text:
|
|
657
|
+
z2.object({
|
|
658
|
+
type: z2.literal("text_delta"),
|
|
659
|
+
text: z2.string()
|
|
666
660
|
}),
|
|
667
|
-
|
|
668
|
-
type:
|
|
669
|
-
thinking:
|
|
661
|
+
z2.object({
|
|
662
|
+
type: z2.literal("thinking_delta"),
|
|
663
|
+
thinking: z2.string()
|
|
670
664
|
}),
|
|
671
|
-
|
|
672
|
-
type:
|
|
673
|
-
signature:
|
|
665
|
+
z2.object({
|
|
666
|
+
type: z2.literal("signature_delta"),
|
|
667
|
+
signature: z2.string()
|
|
674
668
|
}),
|
|
675
|
-
|
|
676
|
-
type:
|
|
677
|
-
content:
|
|
669
|
+
z2.object({
|
|
670
|
+
type: z2.literal("compaction_delta"),
|
|
671
|
+
content: z2.string().nullish()
|
|
678
672
|
}),
|
|
679
|
-
|
|
680
|
-
type:
|
|
681
|
-
citation:
|
|
682
|
-
|
|
683
|
-
type:
|
|
684
|
-
cited_text:
|
|
685
|
-
url:
|
|
686
|
-
title:
|
|
687
|
-
encrypted_index:
|
|
673
|
+
z2.object({
|
|
674
|
+
type: z2.literal("citations_delta"),
|
|
675
|
+
citation: z2.discriminatedUnion("type", [
|
|
676
|
+
z2.object({
|
|
677
|
+
type: z2.literal("web_search_result_location"),
|
|
678
|
+
cited_text: z2.string(),
|
|
679
|
+
url: z2.string(),
|
|
680
|
+
title: z2.string(),
|
|
681
|
+
encrypted_index: z2.string()
|
|
688
682
|
}),
|
|
689
|
-
|
|
690
|
-
type:
|
|
691
|
-
cited_text:
|
|
692
|
-
document_index:
|
|
693
|
-
document_title:
|
|
694
|
-
start_page_number:
|
|
695
|
-
end_page_number:
|
|
683
|
+
z2.object({
|
|
684
|
+
type: z2.literal("page_location"),
|
|
685
|
+
cited_text: z2.string(),
|
|
686
|
+
document_index: z2.number(),
|
|
687
|
+
document_title: z2.string().nullable(),
|
|
688
|
+
start_page_number: z2.number(),
|
|
689
|
+
end_page_number: z2.number()
|
|
696
690
|
}),
|
|
697
|
-
|
|
698
|
-
type:
|
|
699
|
-
cited_text:
|
|
700
|
-
document_index:
|
|
701
|
-
document_title:
|
|
702
|
-
start_char_index:
|
|
703
|
-
end_char_index:
|
|
691
|
+
z2.object({
|
|
692
|
+
type: z2.literal("char_location"),
|
|
693
|
+
cited_text: z2.string(),
|
|
694
|
+
document_index: z2.number(),
|
|
695
|
+
document_title: z2.string().nullable(),
|
|
696
|
+
start_char_index: z2.number(),
|
|
697
|
+
end_char_index: z2.number()
|
|
704
698
|
})
|
|
705
699
|
])
|
|
706
700
|
})
|
|
707
701
|
])
|
|
708
702
|
}),
|
|
709
|
-
|
|
710
|
-
type:
|
|
711
|
-
index:
|
|
703
|
+
z2.object({
|
|
704
|
+
type: z2.literal("content_block_stop"),
|
|
705
|
+
index: z2.number()
|
|
712
706
|
}),
|
|
713
|
-
|
|
714
|
-
type:
|
|
715
|
-
error:
|
|
716
|
-
type:
|
|
717
|
-
message:
|
|
707
|
+
z2.object({
|
|
708
|
+
type: z2.literal("error"),
|
|
709
|
+
error: z2.object({
|
|
710
|
+
type: z2.string(),
|
|
711
|
+
message: z2.string()
|
|
718
712
|
})
|
|
719
713
|
}),
|
|
720
|
-
|
|
721
|
-
type:
|
|
722
|
-
delta:
|
|
723
|
-
stop_reason:
|
|
724
|
-
stop_sequence:
|
|
725
|
-
container:
|
|
726
|
-
expires_at:
|
|
727
|
-
id:
|
|
728
|
-
skills:
|
|
729
|
-
|
|
730
|
-
type:
|
|
731
|
-
|
|
732
|
-
|
|
714
|
+
z2.object({
|
|
715
|
+
type: z2.literal("message_delta"),
|
|
716
|
+
delta: z2.object({
|
|
717
|
+
stop_reason: z2.string().nullish(),
|
|
718
|
+
stop_sequence: z2.string().nullish(),
|
|
719
|
+
container: z2.object({
|
|
720
|
+
expires_at: z2.string(),
|
|
721
|
+
id: z2.string(),
|
|
722
|
+
skills: z2.array(
|
|
723
|
+
z2.object({
|
|
724
|
+
type: z2.union([
|
|
725
|
+
z2.literal("anthropic"),
|
|
726
|
+
z2.literal("custom")
|
|
733
727
|
]),
|
|
734
|
-
skill_id:
|
|
735
|
-
version:
|
|
728
|
+
skill_id: z2.string(),
|
|
729
|
+
version: z2.string()
|
|
736
730
|
})
|
|
737
731
|
).nullish()
|
|
738
732
|
}).nullish()
|
|
739
733
|
}),
|
|
740
|
-
usage:
|
|
741
|
-
input_tokens:
|
|
742
|
-
output_tokens:
|
|
743
|
-
cache_creation_input_tokens:
|
|
744
|
-
cache_read_input_tokens:
|
|
745
|
-
iterations:
|
|
746
|
-
|
|
747
|
-
type:
|
|
748
|
-
input_tokens:
|
|
749
|
-
output_tokens:
|
|
734
|
+
usage: z2.looseObject({
|
|
735
|
+
input_tokens: z2.number().nullish(),
|
|
736
|
+
output_tokens: z2.number(),
|
|
737
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
738
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
739
|
+
iterations: z2.array(
|
|
740
|
+
z2.object({
|
|
741
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
742
|
+
input_tokens: z2.number(),
|
|
743
|
+
output_tokens: z2.number()
|
|
750
744
|
})
|
|
751
745
|
).nullish()
|
|
752
746
|
}),
|
|
753
|
-
context_management:
|
|
754
|
-
applied_edits:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
type:
|
|
758
|
-
cleared_tool_uses:
|
|
759
|
-
cleared_input_tokens:
|
|
747
|
+
context_management: z2.object({
|
|
748
|
+
applied_edits: z2.array(
|
|
749
|
+
z2.union([
|
|
750
|
+
z2.object({
|
|
751
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
752
|
+
cleared_tool_uses: z2.number(),
|
|
753
|
+
cleared_input_tokens: z2.number()
|
|
760
754
|
}),
|
|
761
|
-
|
|
762
|
-
type:
|
|
763
|
-
cleared_thinking_turns:
|
|
764
|
-
cleared_input_tokens:
|
|
755
|
+
z2.object({
|
|
756
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
757
|
+
cleared_thinking_turns: z2.number(),
|
|
758
|
+
cleared_input_tokens: z2.number()
|
|
765
759
|
}),
|
|
766
|
-
|
|
767
|
-
type:
|
|
760
|
+
z2.object({
|
|
761
|
+
type: z2.literal("compact_20260112")
|
|
768
762
|
})
|
|
769
763
|
])
|
|
770
764
|
)
|
|
771
765
|
}).nullish()
|
|
772
766
|
}),
|
|
773
|
-
|
|
774
|
-
type:
|
|
767
|
+
z2.object({
|
|
768
|
+
type: z2.literal("message_stop")
|
|
775
769
|
}),
|
|
776
|
-
|
|
777
|
-
type:
|
|
770
|
+
z2.object({
|
|
771
|
+
type: z2.literal("ping")
|
|
778
772
|
})
|
|
779
773
|
])
|
|
780
774
|
)
|
|
781
775
|
);
|
|
782
|
-
var anthropicReasoningMetadataSchema = (
|
|
783
|
-
() => (
|
|
784
|
-
|
|
785
|
-
signature:
|
|
786
|
-
redactedData:
|
|
776
|
+
var anthropicReasoningMetadataSchema = lazySchema2(
|
|
777
|
+
() => zodSchema2(
|
|
778
|
+
z2.object({
|
|
779
|
+
signature: z2.string().optional(),
|
|
780
|
+
redactedData: z2.string().optional()
|
|
787
781
|
})
|
|
788
782
|
)
|
|
789
783
|
);
|
|
790
784
|
|
|
791
|
-
// src/anthropic-
|
|
792
|
-
|
|
793
|
-
var anthropicFilePartProviderOptions =
|
|
785
|
+
// src/anthropic-options.ts
|
|
786
|
+
import { z as z3 } from "zod/v4";
|
|
787
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
794
788
|
/**
|
|
795
789
|
* Citation configuration for this document.
|
|
796
790
|
* When enabled, this document will generate citations in the response.
|
|
797
791
|
*/
|
|
798
|
-
citations:
|
|
792
|
+
citations: z3.object({
|
|
799
793
|
/**
|
|
800
794
|
* Enable citations for this document
|
|
801
795
|
*/
|
|
802
|
-
enabled:
|
|
796
|
+
enabled: z3.boolean()
|
|
803
797
|
}).optional(),
|
|
804
798
|
/**
|
|
805
799
|
* Custom title for the document.
|
|
806
800
|
* If not provided, the filename will be used.
|
|
807
801
|
*/
|
|
808
|
-
title:
|
|
802
|
+
title: z3.string().optional(),
|
|
809
803
|
/**
|
|
810
804
|
* Context about the document that will be passed to the model
|
|
811
805
|
* but not used towards cited content.
|
|
812
806
|
* Useful for storing document metadata as text or stringified JSON.
|
|
813
807
|
*/
|
|
814
|
-
context:
|
|
808
|
+
context: z3.string().optional()
|
|
815
809
|
});
|
|
816
|
-
var anthropicLanguageModelOptions =
|
|
810
|
+
var anthropicLanguageModelOptions = z3.object({
|
|
817
811
|
/**
|
|
818
812
|
* Whether to send reasoning to the model.
|
|
819
813
|
*
|
|
820
814
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
821
815
|
*/
|
|
822
|
-
sendReasoning:
|
|
816
|
+
sendReasoning: z3.boolean().optional(),
|
|
823
817
|
/**
|
|
824
818
|
* Determines how structured outputs are generated.
|
|
825
819
|
*
|
|
@@ -827,52 +821,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
827
821
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
828
822
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
829
823
|
*/
|
|
830
|
-
structuredOutputMode:
|
|
824
|
+
structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
831
825
|
/**
|
|
832
826
|
* Configuration for enabling Claude's extended thinking.
|
|
833
827
|
*
|
|
834
828
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
835
829
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
836
830
|
*/
|
|
837
|
-
thinking:
|
|
838
|
-
|
|
831
|
+
thinking: z3.discriminatedUnion("type", [
|
|
832
|
+
z3.object({
|
|
839
833
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
840
|
-
type:
|
|
834
|
+
type: z3.literal("adaptive"),
|
|
835
|
+
/**
|
|
836
|
+
* Controls whether thinking content is included in the response.
|
|
837
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
838
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
839
|
+
*/
|
|
840
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
841
841
|
}),
|
|
842
|
-
|
|
842
|
+
z3.object({
|
|
843
843
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
844
|
-
type:
|
|
845
|
-
budgetTokens:
|
|
844
|
+
type: z3.literal("enabled"),
|
|
845
|
+
budgetTokens: z3.number().optional()
|
|
846
846
|
}),
|
|
847
|
-
|
|
848
|
-
type:
|
|
847
|
+
z3.object({
|
|
848
|
+
type: z3.literal("disabled")
|
|
849
849
|
})
|
|
850
850
|
]).optional(),
|
|
851
851
|
/**
|
|
852
852
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
853
853
|
* When set to true, Claude will use at most one tool per response.
|
|
854
854
|
*/
|
|
855
|
-
disableParallelToolUse:
|
|
855
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
856
856
|
/**
|
|
857
857
|
* Cache control settings for this message.
|
|
858
858
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
859
859
|
*/
|
|
860
|
-
cacheControl:
|
|
861
|
-
type:
|
|
862
|
-
ttl:
|
|
860
|
+
cacheControl: z3.object({
|
|
861
|
+
type: z3.literal("ephemeral"),
|
|
862
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
863
|
+
}).optional(),
|
|
864
|
+
/**
|
|
865
|
+
* Metadata to include with the request.
|
|
866
|
+
*
|
|
867
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
868
|
+
*/
|
|
869
|
+
metadata: z3.object({
|
|
870
|
+
/**
|
|
871
|
+
* An external identifier for the user associated with the request.
|
|
872
|
+
*
|
|
873
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
874
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
875
|
+
*/
|
|
876
|
+
userId: z3.string().optional()
|
|
863
877
|
}).optional(),
|
|
864
878
|
/**
|
|
865
879
|
* MCP servers to be utilized in this request.
|
|
866
880
|
*/
|
|
867
|
-
mcpServers:
|
|
868
|
-
|
|
869
|
-
type:
|
|
870
|
-
name:
|
|
871
|
-
url:
|
|
872
|
-
authorizationToken:
|
|
873
|
-
toolConfiguration:
|
|
874
|
-
enabled:
|
|
875
|
-
allowedTools:
|
|
881
|
+
mcpServers: z3.array(
|
|
882
|
+
z3.object({
|
|
883
|
+
type: z3.literal("url"),
|
|
884
|
+
name: z3.string(),
|
|
885
|
+
url: z3.string(),
|
|
886
|
+
authorizationToken: z3.string().nullish(),
|
|
887
|
+
toolConfiguration: z3.object({
|
|
888
|
+
enabled: z3.boolean().nullish(),
|
|
889
|
+
allowedTools: z3.array(z3.string()).nullish()
|
|
876
890
|
}).nullish()
|
|
877
891
|
})
|
|
878
892
|
).optional(),
|
|
@@ -881,83 +895,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
881
895
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
882
896
|
* Requires code execution tool to be enabled.
|
|
883
897
|
*/
|
|
884
|
-
container:
|
|
885
|
-
id:
|
|
886
|
-
skills:
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
898
|
+
container: z3.object({
|
|
899
|
+
id: z3.string().optional(),
|
|
900
|
+
skills: z3.array(
|
|
901
|
+
z3.discriminatedUnion("type", [
|
|
902
|
+
z3.object({
|
|
903
|
+
type: z3.literal("anthropic"),
|
|
904
|
+
skillId: z3.string(),
|
|
905
|
+
version: z3.string().optional()
|
|
906
|
+
}),
|
|
907
|
+
z3.object({
|
|
908
|
+
type: z3.literal("custom"),
|
|
909
|
+
providerReference: z3.record(z3.string(), z3.string()),
|
|
910
|
+
version: z3.string().optional()
|
|
911
|
+
})
|
|
912
|
+
])
|
|
892
913
|
).optional()
|
|
893
914
|
}).optional(),
|
|
894
915
|
/**
|
|
895
|
-
* Whether to enable
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
916
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
917
|
+
* and structured outputs for every function tool in the request. When
|
|
918
|
+
* true (the default), each function tool receives a default of
|
|
919
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
920
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
899
921
|
*
|
|
900
922
|
* @default true
|
|
901
923
|
*/
|
|
902
|
-
toolStreaming:
|
|
924
|
+
toolStreaming: z3.boolean().optional(),
|
|
903
925
|
/**
|
|
904
926
|
* @default 'high'
|
|
905
927
|
*/
|
|
906
|
-
effort:
|
|
928
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
929
|
+
/**
|
|
930
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
931
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
932
|
+
* gracefully as the budget is consumed.
|
|
933
|
+
*
|
|
934
|
+
* Advisory only — does not enforce a hard token limit.
|
|
935
|
+
*/
|
|
936
|
+
taskBudget: z3.object({
|
|
937
|
+
type: z3.literal("tokens"),
|
|
938
|
+
total: z3.number().int().min(2e4),
|
|
939
|
+
remaining: z3.number().int().min(0).optional()
|
|
940
|
+
}).optional(),
|
|
907
941
|
/**
|
|
908
942
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
909
943
|
* Only supported with claude-opus-4-6.
|
|
910
944
|
*/
|
|
911
|
-
speed:
|
|
945
|
+
speed: z3.enum(["fast", "standard"]).optional(),
|
|
946
|
+
/**
|
|
947
|
+
* Controls where model inference runs for this request.
|
|
948
|
+
*
|
|
949
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
950
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
951
|
+
*
|
|
952
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
953
|
+
*/
|
|
954
|
+
inferenceGeo: z3.enum(["us", "global"]).optional(),
|
|
912
955
|
/**
|
|
913
956
|
* A set of beta features to enable.
|
|
914
957
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
915
958
|
*/
|
|
916
|
-
anthropicBeta:
|
|
917
|
-
contextManagement:
|
|
918
|
-
edits:
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
type:
|
|
922
|
-
trigger:
|
|
923
|
-
|
|
924
|
-
type:
|
|
925
|
-
value:
|
|
959
|
+
anthropicBeta: z3.array(z3.string()).optional(),
|
|
960
|
+
contextManagement: z3.object({
|
|
961
|
+
edits: z3.array(
|
|
962
|
+
z3.discriminatedUnion("type", [
|
|
963
|
+
z3.object({
|
|
964
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
965
|
+
trigger: z3.discriminatedUnion("type", [
|
|
966
|
+
z3.object({
|
|
967
|
+
type: z3.literal("input_tokens"),
|
|
968
|
+
value: z3.number()
|
|
926
969
|
}),
|
|
927
|
-
|
|
928
|
-
type:
|
|
929
|
-
value:
|
|
970
|
+
z3.object({
|
|
971
|
+
type: z3.literal("tool_uses"),
|
|
972
|
+
value: z3.number()
|
|
930
973
|
})
|
|
931
974
|
]).optional(),
|
|
932
|
-
keep:
|
|
933
|
-
type:
|
|
934
|
-
value:
|
|
975
|
+
keep: z3.object({
|
|
976
|
+
type: z3.literal("tool_uses"),
|
|
977
|
+
value: z3.number()
|
|
935
978
|
}).optional(),
|
|
936
|
-
clearAtLeast:
|
|
937
|
-
type:
|
|
938
|
-
value:
|
|
979
|
+
clearAtLeast: z3.object({
|
|
980
|
+
type: z3.literal("input_tokens"),
|
|
981
|
+
value: z3.number()
|
|
939
982
|
}).optional(),
|
|
940
|
-
clearToolInputs:
|
|
941
|
-
excludeTools:
|
|
983
|
+
clearToolInputs: z3.boolean().optional(),
|
|
984
|
+
excludeTools: z3.array(z3.string()).optional()
|
|
942
985
|
}),
|
|
943
|
-
|
|
944
|
-
type:
|
|
945
|
-
keep:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
type:
|
|
949
|
-
value:
|
|
986
|
+
z3.object({
|
|
987
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
988
|
+
keep: z3.union([
|
|
989
|
+
z3.literal("all"),
|
|
990
|
+
z3.object({
|
|
991
|
+
type: z3.literal("thinking_turns"),
|
|
992
|
+
value: z3.number()
|
|
950
993
|
})
|
|
951
994
|
]).optional()
|
|
952
995
|
}),
|
|
953
|
-
|
|
954
|
-
type:
|
|
955
|
-
trigger:
|
|
956
|
-
type:
|
|
957
|
-
value:
|
|
996
|
+
z3.object({
|
|
997
|
+
type: z3.literal("compact_20260112"),
|
|
998
|
+
trigger: z3.object({
|
|
999
|
+
type: z3.literal("input_tokens"),
|
|
1000
|
+
value: z3.number()
|
|
958
1001
|
}).optional(),
|
|
959
|
-
pauseAfterCompaction:
|
|
960
|
-
instructions:
|
|
1002
|
+
pauseAfterCompaction: z3.boolean().optional(),
|
|
1003
|
+
instructions: z3.string().optional()
|
|
961
1004
|
})
|
|
962
1005
|
])
|
|
963
1006
|
)
|
|
@@ -965,7 +1008,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
965
1008
|
});
|
|
966
1009
|
|
|
967
1010
|
// src/anthropic-prepare-tools.ts
|
|
968
|
-
|
|
1011
|
+
import {
|
|
1012
|
+
UnsupportedFunctionalityError
|
|
1013
|
+
} from "@ai-sdk/provider";
|
|
969
1014
|
|
|
970
1015
|
// src/get-cache-control.ts
|
|
971
1016
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1010,31 +1055,31 @@ var CacheControlValidator = class {
|
|
|
1010
1055
|
};
|
|
1011
1056
|
|
|
1012
1057
|
// src/tool/text-editor_20250728.ts
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
var textEditor_20250728ArgsSchema = (
|
|
1017
|
-
() => (
|
|
1018
|
-
|
|
1019
|
-
maxCharacters:
|
|
1058
|
+
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
1059
|
+
import { z as z4 } from "zod/v4";
|
|
1060
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
1061
|
+
var textEditor_20250728ArgsSchema = lazySchema3(
|
|
1062
|
+
() => zodSchema3(
|
|
1063
|
+
z4.object({
|
|
1064
|
+
maxCharacters: z4.number().optional()
|
|
1020
1065
|
})
|
|
1021
1066
|
)
|
|
1022
1067
|
);
|
|
1023
|
-
var textEditor_20250728InputSchema = (
|
|
1024
|
-
() => (
|
|
1025
|
-
|
|
1026
|
-
command:
|
|
1027
|
-
path:
|
|
1028
|
-
file_text:
|
|
1029
|
-
insert_line:
|
|
1030
|
-
new_str:
|
|
1031
|
-
insert_text:
|
|
1032
|
-
old_str:
|
|
1033
|
-
view_range:
|
|
1068
|
+
var textEditor_20250728InputSchema = lazySchema3(
|
|
1069
|
+
() => zodSchema3(
|
|
1070
|
+
z4.object({
|
|
1071
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
1072
|
+
path: z4.string(),
|
|
1073
|
+
file_text: z4.string().optional(),
|
|
1074
|
+
insert_line: z4.number().int().optional(),
|
|
1075
|
+
new_str: z4.string().optional(),
|
|
1076
|
+
insert_text: z4.string().optional(),
|
|
1077
|
+
old_str: z4.string().optional(),
|
|
1078
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
1034
1079
|
})
|
|
1035
1080
|
)
|
|
1036
1081
|
);
|
|
1037
|
-
var factory = (
|
|
1082
|
+
var factory = createProviderDefinedToolFactory({
|
|
1038
1083
|
id: "anthropic.text_editor_20250728",
|
|
1039
1084
|
inputSchema: textEditor_20250728InputSchema
|
|
1040
1085
|
});
|
|
@@ -1043,45 +1088,49 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1043
1088
|
};
|
|
1044
1089
|
|
|
1045
1090
|
// src/tool/web-search_20260209.ts
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1091
|
+
import {
|
|
1092
|
+
createProviderExecutedToolFactory,
|
|
1093
|
+
lazySchema as lazySchema4,
|
|
1094
|
+
zodSchema as zodSchema4
|
|
1095
|
+
} from "@ai-sdk/provider-utils";
|
|
1096
|
+
import { z as z5 } from "zod/v4";
|
|
1097
|
+
var webSearch_20260209ArgsSchema = lazySchema4(
|
|
1098
|
+
() => zodSchema4(
|
|
1099
|
+
z5.object({
|
|
1100
|
+
maxUses: z5.number().optional(),
|
|
1101
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
1102
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
1103
|
+
userLocation: z5.object({
|
|
1104
|
+
type: z5.literal("approximate"),
|
|
1105
|
+
city: z5.string().optional(),
|
|
1106
|
+
region: z5.string().optional(),
|
|
1107
|
+
country: z5.string().optional(),
|
|
1108
|
+
timezone: z5.string().optional()
|
|
1060
1109
|
}).optional()
|
|
1061
1110
|
})
|
|
1062
1111
|
)
|
|
1063
1112
|
);
|
|
1064
|
-
var webSearch_20260209OutputSchema = (
|
|
1065
|
-
() => (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
url:
|
|
1069
|
-
title:
|
|
1070
|
-
pageAge:
|
|
1071
|
-
encryptedContent:
|
|
1072
|
-
type:
|
|
1113
|
+
var webSearch_20260209OutputSchema = lazySchema4(
|
|
1114
|
+
() => zodSchema4(
|
|
1115
|
+
z5.array(
|
|
1116
|
+
z5.object({
|
|
1117
|
+
url: z5.string(),
|
|
1118
|
+
title: z5.string().nullable(),
|
|
1119
|
+
pageAge: z5.string().nullable(),
|
|
1120
|
+
encryptedContent: z5.string(),
|
|
1121
|
+
type: z5.literal("web_search_result")
|
|
1073
1122
|
})
|
|
1074
1123
|
)
|
|
1075
1124
|
)
|
|
1076
1125
|
);
|
|
1077
|
-
var webSearch_20260209InputSchema = (
|
|
1078
|
-
() => (
|
|
1079
|
-
|
|
1080
|
-
query:
|
|
1126
|
+
var webSearch_20260209InputSchema = lazySchema4(
|
|
1127
|
+
() => zodSchema4(
|
|
1128
|
+
z5.object({
|
|
1129
|
+
query: z5.string()
|
|
1081
1130
|
})
|
|
1082
1131
|
)
|
|
1083
1132
|
);
|
|
1084
|
-
var factory2 = (
|
|
1133
|
+
var factory2 = createProviderExecutedToolFactory({
|
|
1085
1134
|
id: "anthropic.web_search_20260209",
|
|
1086
1135
|
inputSchema: webSearch_20260209InputSchema,
|
|
1087
1136
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1092,45 +1141,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1092
1141
|
};
|
|
1093
1142
|
|
|
1094
1143
|
// src/tool/web-search_20250305.ts
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1144
|
+
import {
|
|
1145
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
1146
|
+
lazySchema as lazySchema5,
|
|
1147
|
+
zodSchema as zodSchema5
|
|
1148
|
+
} from "@ai-sdk/provider-utils";
|
|
1149
|
+
import { z as z6 } from "zod/v4";
|
|
1150
|
+
var webSearch_20250305ArgsSchema = lazySchema5(
|
|
1151
|
+
() => zodSchema5(
|
|
1152
|
+
z6.object({
|
|
1153
|
+
maxUses: z6.number().optional(),
|
|
1154
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1155
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1156
|
+
userLocation: z6.object({
|
|
1157
|
+
type: z6.literal("approximate"),
|
|
1158
|
+
city: z6.string().optional(),
|
|
1159
|
+
region: z6.string().optional(),
|
|
1160
|
+
country: z6.string().optional(),
|
|
1161
|
+
timezone: z6.string().optional()
|
|
1109
1162
|
}).optional()
|
|
1110
1163
|
})
|
|
1111
1164
|
)
|
|
1112
1165
|
);
|
|
1113
|
-
var webSearch_20250305OutputSchema = (
|
|
1114
|
-
() => (
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
url:
|
|
1118
|
-
title:
|
|
1119
|
-
pageAge:
|
|
1120
|
-
encryptedContent:
|
|
1121
|
-
type:
|
|
1166
|
+
var webSearch_20250305OutputSchema = lazySchema5(
|
|
1167
|
+
() => zodSchema5(
|
|
1168
|
+
z6.array(
|
|
1169
|
+
z6.object({
|
|
1170
|
+
url: z6.string(),
|
|
1171
|
+
title: z6.string().nullable(),
|
|
1172
|
+
pageAge: z6.string().nullable(),
|
|
1173
|
+
encryptedContent: z6.string(),
|
|
1174
|
+
type: z6.literal("web_search_result")
|
|
1122
1175
|
})
|
|
1123
1176
|
)
|
|
1124
1177
|
)
|
|
1125
1178
|
);
|
|
1126
|
-
var webSearch_20250305InputSchema = (
|
|
1127
|
-
() => (
|
|
1128
|
-
|
|
1129
|
-
query:
|
|
1179
|
+
var webSearch_20250305InputSchema = lazySchema5(
|
|
1180
|
+
() => zodSchema5(
|
|
1181
|
+
z6.object({
|
|
1182
|
+
query: z6.string()
|
|
1130
1183
|
})
|
|
1131
1184
|
)
|
|
1132
1185
|
);
|
|
1133
|
-
var factory3 = (
|
|
1186
|
+
var factory3 = createProviderExecutedToolFactory2({
|
|
1134
1187
|
id: "anthropic.web_search_20250305",
|
|
1135
1188
|
inputSchema: webSearch_20250305InputSchema,
|
|
1136
1189
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1141,53 +1194,57 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1141
1194
|
};
|
|
1142
1195
|
|
|
1143
1196
|
// src/tool/web-fetch-20260209.ts
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1197
|
+
import {
|
|
1198
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
1199
|
+
lazySchema as lazySchema6,
|
|
1200
|
+
zodSchema as zodSchema6
|
|
1201
|
+
} from "@ai-sdk/provider-utils";
|
|
1202
|
+
import { z as z7 } from "zod/v4";
|
|
1203
|
+
var webFetch_20260209ArgsSchema = lazySchema6(
|
|
1204
|
+
() => zodSchema6(
|
|
1205
|
+
z7.object({
|
|
1206
|
+
maxUses: z7.number().optional(),
|
|
1207
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1208
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1209
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1210
|
+
maxContentTokens: z7.number().optional()
|
|
1154
1211
|
})
|
|
1155
1212
|
)
|
|
1156
1213
|
);
|
|
1157
|
-
var webFetch_20260209OutputSchema = (
|
|
1158
|
-
() => (
|
|
1159
|
-
|
|
1160
|
-
type:
|
|
1161
|
-
url:
|
|
1162
|
-
content:
|
|
1163
|
-
type:
|
|
1164
|
-
title:
|
|
1165
|
-
citations:
|
|
1166
|
-
source:
|
|
1167
|
-
|
|
1168
|
-
type:
|
|
1169
|
-
mediaType:
|
|
1170
|
-
data:
|
|
1214
|
+
var webFetch_20260209OutputSchema = lazySchema6(
|
|
1215
|
+
() => zodSchema6(
|
|
1216
|
+
z7.object({
|
|
1217
|
+
type: z7.literal("web_fetch_result"),
|
|
1218
|
+
url: z7.string(),
|
|
1219
|
+
content: z7.object({
|
|
1220
|
+
type: z7.literal("document"),
|
|
1221
|
+
title: z7.string().nullable(),
|
|
1222
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1223
|
+
source: z7.union([
|
|
1224
|
+
z7.object({
|
|
1225
|
+
type: z7.literal("base64"),
|
|
1226
|
+
mediaType: z7.literal("application/pdf"),
|
|
1227
|
+
data: z7.string()
|
|
1171
1228
|
}),
|
|
1172
|
-
|
|
1173
|
-
type:
|
|
1174
|
-
mediaType:
|
|
1175
|
-
data:
|
|
1229
|
+
z7.object({
|
|
1230
|
+
type: z7.literal("text"),
|
|
1231
|
+
mediaType: z7.literal("text/plain"),
|
|
1232
|
+
data: z7.string()
|
|
1176
1233
|
})
|
|
1177
1234
|
])
|
|
1178
1235
|
}),
|
|
1179
|
-
retrievedAt:
|
|
1236
|
+
retrievedAt: z7.string().nullable()
|
|
1180
1237
|
})
|
|
1181
1238
|
)
|
|
1182
1239
|
);
|
|
1183
|
-
var webFetch_20260209InputSchema = (
|
|
1184
|
-
() => (
|
|
1185
|
-
|
|
1186
|
-
url:
|
|
1240
|
+
var webFetch_20260209InputSchema = lazySchema6(
|
|
1241
|
+
() => zodSchema6(
|
|
1242
|
+
z7.object({
|
|
1243
|
+
url: z7.string()
|
|
1187
1244
|
})
|
|
1188
1245
|
)
|
|
1189
1246
|
);
|
|
1190
|
-
var factory4 = (
|
|
1247
|
+
var factory4 = createProviderExecutedToolFactory3({
|
|
1191
1248
|
id: "anthropic.web_fetch_20260209",
|
|
1192
1249
|
inputSchema: webFetch_20260209InputSchema,
|
|
1193
1250
|
outputSchema: webFetch_20260209OutputSchema,
|
|
@@ -1198,53 +1255,57 @@ var webFetch_20260209 = (args = {}) => {
|
|
|
1198
1255
|
};
|
|
1199
1256
|
|
|
1200
1257
|
// src/tool/web-fetch-20250910.ts
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1258
|
+
import {
|
|
1259
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
1260
|
+
lazySchema as lazySchema7,
|
|
1261
|
+
zodSchema as zodSchema7
|
|
1262
|
+
} from "@ai-sdk/provider-utils";
|
|
1263
|
+
import { z as z8 } from "zod/v4";
|
|
1264
|
+
var webFetch_20250910ArgsSchema = lazySchema7(
|
|
1265
|
+
() => zodSchema7(
|
|
1266
|
+
z8.object({
|
|
1267
|
+
maxUses: z8.number().optional(),
|
|
1268
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1269
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1270
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1271
|
+
maxContentTokens: z8.number().optional()
|
|
1211
1272
|
})
|
|
1212
1273
|
)
|
|
1213
1274
|
);
|
|
1214
|
-
var webFetch_20250910OutputSchema = (
|
|
1215
|
-
() => (
|
|
1216
|
-
|
|
1217
|
-
type:
|
|
1218
|
-
url:
|
|
1219
|
-
content:
|
|
1220
|
-
type:
|
|
1221
|
-
title:
|
|
1222
|
-
citations:
|
|
1223
|
-
source:
|
|
1224
|
-
|
|
1225
|
-
type:
|
|
1226
|
-
mediaType:
|
|
1227
|
-
data:
|
|
1275
|
+
var webFetch_20250910OutputSchema = lazySchema7(
|
|
1276
|
+
() => zodSchema7(
|
|
1277
|
+
z8.object({
|
|
1278
|
+
type: z8.literal("web_fetch_result"),
|
|
1279
|
+
url: z8.string(),
|
|
1280
|
+
content: z8.object({
|
|
1281
|
+
type: z8.literal("document"),
|
|
1282
|
+
title: z8.string().nullable(),
|
|
1283
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1284
|
+
source: z8.union([
|
|
1285
|
+
z8.object({
|
|
1286
|
+
type: z8.literal("base64"),
|
|
1287
|
+
mediaType: z8.literal("application/pdf"),
|
|
1288
|
+
data: z8.string()
|
|
1228
1289
|
}),
|
|
1229
|
-
|
|
1230
|
-
type:
|
|
1231
|
-
mediaType:
|
|
1232
|
-
data:
|
|
1290
|
+
z8.object({
|
|
1291
|
+
type: z8.literal("text"),
|
|
1292
|
+
mediaType: z8.literal("text/plain"),
|
|
1293
|
+
data: z8.string()
|
|
1233
1294
|
})
|
|
1234
1295
|
])
|
|
1235
1296
|
}),
|
|
1236
|
-
retrievedAt:
|
|
1297
|
+
retrievedAt: z8.string().nullable()
|
|
1237
1298
|
})
|
|
1238
1299
|
)
|
|
1239
1300
|
);
|
|
1240
|
-
var webFetch_20250910InputSchema = (
|
|
1241
|
-
() => (
|
|
1242
|
-
|
|
1243
|
-
url:
|
|
1301
|
+
var webFetch_20250910InputSchema = lazySchema7(
|
|
1302
|
+
() => zodSchema7(
|
|
1303
|
+
z8.object({
|
|
1304
|
+
url: z8.string()
|
|
1244
1305
|
})
|
|
1245
1306
|
)
|
|
1246
1307
|
);
|
|
1247
|
-
var factory5 = (
|
|
1308
|
+
var factory5 = createProviderExecutedToolFactory4({
|
|
1248
1309
|
id: "anthropic.web_fetch_20250910",
|
|
1249
1310
|
inputSchema: webFetch_20250910InputSchema,
|
|
1250
1311
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1255,16 +1316,17 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1255
1316
|
};
|
|
1256
1317
|
|
|
1257
1318
|
// src/anthropic-prepare-tools.ts
|
|
1258
|
-
|
|
1319
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1259
1320
|
async function prepareTools({
|
|
1260
1321
|
tools,
|
|
1261
1322
|
toolChoice,
|
|
1262
1323
|
disableParallelToolUse,
|
|
1263
1324
|
cacheControlValidator,
|
|
1264
1325
|
supportsStructuredOutput,
|
|
1265
|
-
supportsStrictTools
|
|
1326
|
+
supportsStrictTools,
|
|
1327
|
+
defaultEagerInputStreaming = false
|
|
1266
1328
|
}) {
|
|
1267
|
-
var _a;
|
|
1329
|
+
var _a, _b;
|
|
1268
1330
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1269
1331
|
const toolWarnings = [];
|
|
1270
1332
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1281,7 +1343,7 @@ async function prepareTools({
|
|
|
1281
1343
|
canCache: true
|
|
1282
1344
|
});
|
|
1283
1345
|
const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1284
|
-
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1346
|
+
const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
|
|
1285
1347
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1286
1348
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1287
1349
|
if (!supportsStrictTools && tool.strict != null) {
|
|
@@ -1405,7 +1467,7 @@ async function prepareTools({
|
|
|
1405
1467
|
break;
|
|
1406
1468
|
}
|
|
1407
1469
|
case "anthropic.text_editor_20250728": {
|
|
1408
|
-
const args = await
|
|
1470
|
+
const args = await validateTypes({
|
|
1409
1471
|
value: tool.args,
|
|
1410
1472
|
schema: textEditor_20250728ArgsSchema
|
|
1411
1473
|
});
|
|
@@ -1445,7 +1507,7 @@ async function prepareTools({
|
|
|
1445
1507
|
}
|
|
1446
1508
|
case "anthropic.web_fetch_20250910": {
|
|
1447
1509
|
betas.add("web-fetch-2025-09-10");
|
|
1448
|
-
const args = await
|
|
1510
|
+
const args = await validateTypes({
|
|
1449
1511
|
value: tool.args,
|
|
1450
1512
|
schema: webFetch_20250910ArgsSchema
|
|
1451
1513
|
});
|
|
@@ -1463,7 +1525,7 @@ async function prepareTools({
|
|
|
1463
1525
|
}
|
|
1464
1526
|
case "anthropic.web_fetch_20260209": {
|
|
1465
1527
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1466
|
-
const args = await
|
|
1528
|
+
const args = await validateTypes({
|
|
1467
1529
|
value: tool.args,
|
|
1468
1530
|
schema: webFetch_20260209ArgsSchema
|
|
1469
1531
|
});
|
|
@@ -1480,7 +1542,7 @@ async function prepareTools({
|
|
|
1480
1542
|
break;
|
|
1481
1543
|
}
|
|
1482
1544
|
case "anthropic.web_search_20250305": {
|
|
1483
|
-
const args = await
|
|
1545
|
+
const args = await validateTypes({
|
|
1484
1546
|
value: tool.args,
|
|
1485
1547
|
schema: webSearch_20250305ArgsSchema
|
|
1486
1548
|
});
|
|
@@ -1497,7 +1559,7 @@ async function prepareTools({
|
|
|
1497
1559
|
}
|
|
1498
1560
|
case "anthropic.web_search_20260209": {
|
|
1499
1561
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1500
|
-
const args = await
|
|
1562
|
+
const args = await validateTypes({
|
|
1501
1563
|
value: tool.args,
|
|
1502
1564
|
schema: webSearch_20260209ArgsSchema
|
|
1503
1565
|
});
|
|
@@ -1513,7 +1575,6 @@ async function prepareTools({
|
|
|
1513
1575
|
break;
|
|
1514
1576
|
}
|
|
1515
1577
|
case "anthropic.tool_search_regex_20251119": {
|
|
1516
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1517
1578
|
anthropicTools2.push({
|
|
1518
1579
|
type: "tool_search_tool_regex_20251119",
|
|
1519
1580
|
name: "tool_search_tool_regex"
|
|
@@ -1521,7 +1582,6 @@ async function prepareTools({
|
|
|
1521
1582
|
break;
|
|
1522
1583
|
}
|
|
1523
1584
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1585
|
anthropicTools2.push({
|
|
1526
1586
|
type: "tool_search_tool_bm25_20251119",
|
|
1527
1587
|
name: "tool_search_tool_bm25"
|
|
@@ -1592,15 +1652,15 @@ async function prepareTools({
|
|
|
1592
1652
|
};
|
|
1593
1653
|
default: {
|
|
1594
1654
|
const _exhaustiveCheck = type;
|
|
1595
|
-
throw new
|
|
1655
|
+
throw new UnsupportedFunctionalityError({
|
|
1596
1656
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1597
1657
|
});
|
|
1598
1658
|
}
|
|
1599
1659
|
}
|
|
1600
1660
|
}
|
|
1601
1661
|
|
|
1602
|
-
// src/convert-anthropic-
|
|
1603
|
-
function
|
|
1662
|
+
// src/convert-anthropic-usage.ts
|
|
1663
|
+
function convertAnthropicUsage({
|
|
1604
1664
|
usage,
|
|
1605
1665
|
rawUsage
|
|
1606
1666
|
}) {
|
|
@@ -1639,37 +1699,51 @@ function convertAnthropicMessagesUsage({
|
|
|
1639
1699
|
};
|
|
1640
1700
|
}
|
|
1641
1701
|
|
|
1642
|
-
// src/convert-to-anthropic-
|
|
1643
|
-
|
|
1644
|
-
|
|
1702
|
+
// src/convert-to-anthropic-prompt.ts
|
|
1703
|
+
import {
|
|
1704
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1705
|
+
} from "@ai-sdk/provider";
|
|
1706
|
+
import {
|
|
1707
|
+
convertBase64ToUint8Array,
|
|
1708
|
+
convertToBase64,
|
|
1709
|
+
isProviderReference,
|
|
1710
|
+
parseProviderOptions,
|
|
1711
|
+
resolveProviderReference,
|
|
1712
|
+
validateTypes as validateTypes2,
|
|
1713
|
+
isNonNullable
|
|
1714
|
+
} from "@ai-sdk/provider-utils";
|
|
1645
1715
|
|
|
1646
1716
|
// src/tool/code-execution_20250522.ts
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1717
|
+
import {
|
|
1718
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
1719
|
+
lazySchema as lazySchema8,
|
|
1720
|
+
zodSchema as zodSchema8
|
|
1721
|
+
} from "@ai-sdk/provider-utils";
|
|
1722
|
+
import { z as z9 } from "zod/v4";
|
|
1723
|
+
var codeExecution_20250522OutputSchema = lazySchema8(
|
|
1724
|
+
() => zodSchema8(
|
|
1725
|
+
z9.object({
|
|
1726
|
+
type: z9.literal("code_execution_result"),
|
|
1727
|
+
stdout: z9.string(),
|
|
1728
|
+
stderr: z9.string(),
|
|
1729
|
+
return_code: z9.number(),
|
|
1730
|
+
content: z9.array(
|
|
1731
|
+
z9.object({
|
|
1732
|
+
type: z9.literal("code_execution_output"),
|
|
1733
|
+
file_id: z9.string()
|
|
1660
1734
|
})
|
|
1661
1735
|
).optional().default([])
|
|
1662
1736
|
})
|
|
1663
1737
|
)
|
|
1664
1738
|
);
|
|
1665
|
-
var codeExecution_20250522InputSchema = (
|
|
1666
|
-
() => (
|
|
1667
|
-
|
|
1668
|
-
code:
|
|
1739
|
+
var codeExecution_20250522InputSchema = lazySchema8(
|
|
1740
|
+
() => zodSchema8(
|
|
1741
|
+
z9.object({
|
|
1742
|
+
code: z9.string()
|
|
1669
1743
|
})
|
|
1670
1744
|
)
|
|
1671
1745
|
);
|
|
1672
|
-
var factory6 = (
|
|
1746
|
+
var factory6 = createProviderExecutedToolFactory5({
|
|
1673
1747
|
id: "anthropic.code_execution_20250522",
|
|
1674
1748
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1675
1749
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1679,102 +1753,106 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1679
1753
|
};
|
|
1680
1754
|
|
|
1681
1755
|
// src/tool/code-execution_20250825.ts
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1756
|
+
import {
|
|
1757
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
1758
|
+
lazySchema as lazySchema9,
|
|
1759
|
+
zodSchema as zodSchema9
|
|
1760
|
+
} from "@ai-sdk/provider-utils";
|
|
1761
|
+
import { z as z10 } from "zod/v4";
|
|
1762
|
+
var codeExecution_20250825OutputSchema = lazySchema9(
|
|
1763
|
+
() => zodSchema9(
|
|
1764
|
+
z10.discriminatedUnion("type", [
|
|
1765
|
+
z10.object({
|
|
1766
|
+
type: z10.literal("code_execution_result"),
|
|
1767
|
+
stdout: z10.string(),
|
|
1768
|
+
stderr: z10.string(),
|
|
1769
|
+
return_code: z10.number(),
|
|
1770
|
+
content: z10.array(
|
|
1771
|
+
z10.object({
|
|
1772
|
+
type: z10.literal("code_execution_output"),
|
|
1773
|
+
file_id: z10.string()
|
|
1696
1774
|
})
|
|
1697
1775
|
).optional().default([])
|
|
1698
1776
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1701
|
-
content:
|
|
1702
|
-
|
|
1703
|
-
type:
|
|
1704
|
-
file_id:
|
|
1777
|
+
z10.object({
|
|
1778
|
+
type: z10.literal("bash_code_execution_result"),
|
|
1779
|
+
content: z10.array(
|
|
1780
|
+
z10.object({
|
|
1781
|
+
type: z10.literal("bash_code_execution_output"),
|
|
1782
|
+
file_id: z10.string()
|
|
1705
1783
|
})
|
|
1706
1784
|
),
|
|
1707
|
-
stdout:
|
|
1708
|
-
stderr:
|
|
1709
|
-
return_code:
|
|
1785
|
+
stdout: z10.string(),
|
|
1786
|
+
stderr: z10.string(),
|
|
1787
|
+
return_code: z10.number()
|
|
1710
1788
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
error_code:
|
|
1789
|
+
z10.object({
|
|
1790
|
+
type: z10.literal("bash_code_execution_tool_result_error"),
|
|
1791
|
+
error_code: z10.string()
|
|
1714
1792
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
error_code:
|
|
1793
|
+
z10.object({
|
|
1794
|
+
type: z10.literal("text_editor_code_execution_tool_result_error"),
|
|
1795
|
+
error_code: z10.string()
|
|
1718
1796
|
}),
|
|
1719
|
-
|
|
1720
|
-
type:
|
|
1721
|
-
content:
|
|
1722
|
-
file_type:
|
|
1723
|
-
num_lines:
|
|
1724
|
-
start_line:
|
|
1725
|
-
total_lines:
|
|
1797
|
+
z10.object({
|
|
1798
|
+
type: z10.literal("text_editor_code_execution_view_result"),
|
|
1799
|
+
content: z10.string(),
|
|
1800
|
+
file_type: z10.string(),
|
|
1801
|
+
num_lines: z10.number().nullable(),
|
|
1802
|
+
start_line: z10.number().nullable(),
|
|
1803
|
+
total_lines: z10.number().nullable()
|
|
1726
1804
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
is_file_update:
|
|
1805
|
+
z10.object({
|
|
1806
|
+
type: z10.literal("text_editor_code_execution_create_result"),
|
|
1807
|
+
is_file_update: z10.boolean()
|
|
1730
1808
|
}),
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
lines:
|
|
1734
|
-
new_lines:
|
|
1735
|
-
new_start:
|
|
1736
|
-
old_lines:
|
|
1737
|
-
old_start:
|
|
1809
|
+
z10.object({
|
|
1810
|
+
type: z10.literal("text_editor_code_execution_str_replace_result"),
|
|
1811
|
+
lines: z10.array(z10.string()).nullable(),
|
|
1812
|
+
new_lines: z10.number().nullable(),
|
|
1813
|
+
new_start: z10.number().nullable(),
|
|
1814
|
+
old_lines: z10.number().nullable(),
|
|
1815
|
+
old_start: z10.number().nullable()
|
|
1738
1816
|
})
|
|
1739
1817
|
])
|
|
1740
1818
|
)
|
|
1741
1819
|
);
|
|
1742
|
-
var codeExecution_20250825InputSchema = (
|
|
1743
|
-
() => (
|
|
1744
|
-
|
|
1820
|
+
var codeExecution_20250825InputSchema = lazySchema9(
|
|
1821
|
+
() => zodSchema9(
|
|
1822
|
+
z10.discriminatedUnion("type", [
|
|
1745
1823
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1746
|
-
|
|
1747
|
-
type:
|
|
1748
|
-
code:
|
|
1824
|
+
z10.object({
|
|
1825
|
+
type: z10.literal("programmatic-tool-call"),
|
|
1826
|
+
code: z10.string()
|
|
1749
1827
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
command:
|
|
1828
|
+
z10.object({
|
|
1829
|
+
type: z10.literal("bash_code_execution"),
|
|
1830
|
+
command: z10.string()
|
|
1753
1831
|
}),
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
command:
|
|
1758
|
-
path:
|
|
1832
|
+
z10.discriminatedUnion("command", [
|
|
1833
|
+
z10.object({
|
|
1834
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1835
|
+
command: z10.literal("view"),
|
|
1836
|
+
path: z10.string()
|
|
1759
1837
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
command:
|
|
1763
|
-
path:
|
|
1764
|
-
file_text:
|
|
1838
|
+
z10.object({
|
|
1839
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1840
|
+
command: z10.literal("create"),
|
|
1841
|
+
path: z10.string(),
|
|
1842
|
+
file_text: z10.string().nullish()
|
|
1765
1843
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
command:
|
|
1769
|
-
path:
|
|
1770
|
-
old_str:
|
|
1771
|
-
new_str:
|
|
1844
|
+
z10.object({
|
|
1845
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1846
|
+
command: z10.literal("str_replace"),
|
|
1847
|
+
path: z10.string(),
|
|
1848
|
+
old_str: z10.string(),
|
|
1849
|
+
new_str: z10.string()
|
|
1772
1850
|
})
|
|
1773
1851
|
])
|
|
1774
1852
|
])
|
|
1775
1853
|
)
|
|
1776
1854
|
);
|
|
1777
|
-
var factory7 = (
|
|
1855
|
+
var factory7 = createProviderExecutedToolFactory6({
|
|
1778
1856
|
id: "anthropic.code_execution_20250825",
|
|
1779
1857
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1780
1858
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1788,113 +1866,117 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1788
1866
|
};
|
|
1789
1867
|
|
|
1790
1868
|
// src/tool/code-execution_20260120.ts
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1869
|
+
import {
|
|
1870
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
1871
|
+
lazySchema as lazySchema10,
|
|
1872
|
+
zodSchema as zodSchema10
|
|
1873
|
+
} from "@ai-sdk/provider-utils";
|
|
1874
|
+
import { z as z11 } from "zod/v4";
|
|
1875
|
+
var codeExecution_20260120OutputSchema = lazySchema10(
|
|
1876
|
+
() => zodSchema10(
|
|
1877
|
+
z11.discriminatedUnion("type", [
|
|
1878
|
+
z11.object({
|
|
1879
|
+
type: z11.literal("code_execution_result"),
|
|
1880
|
+
stdout: z11.string(),
|
|
1881
|
+
stderr: z11.string(),
|
|
1882
|
+
return_code: z11.number(),
|
|
1883
|
+
content: z11.array(
|
|
1884
|
+
z11.object({
|
|
1885
|
+
type: z11.literal("code_execution_output"),
|
|
1886
|
+
file_id: z11.string()
|
|
1805
1887
|
})
|
|
1806
1888
|
).optional().default([])
|
|
1807
1889
|
}),
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
encrypted_stdout:
|
|
1811
|
-
stderr:
|
|
1812
|
-
return_code:
|
|
1813
|
-
content:
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
file_id:
|
|
1890
|
+
z11.object({
|
|
1891
|
+
type: z11.literal("encrypted_code_execution_result"),
|
|
1892
|
+
encrypted_stdout: z11.string(),
|
|
1893
|
+
stderr: z11.string(),
|
|
1894
|
+
return_code: z11.number(),
|
|
1895
|
+
content: z11.array(
|
|
1896
|
+
z11.object({
|
|
1897
|
+
type: z11.literal("code_execution_output"),
|
|
1898
|
+
file_id: z11.string()
|
|
1817
1899
|
})
|
|
1818
1900
|
).optional().default([])
|
|
1819
1901
|
}),
|
|
1820
|
-
|
|
1821
|
-
type:
|
|
1822
|
-
content:
|
|
1823
|
-
|
|
1824
|
-
type:
|
|
1825
|
-
file_id:
|
|
1902
|
+
z11.object({
|
|
1903
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1904
|
+
content: z11.array(
|
|
1905
|
+
z11.object({
|
|
1906
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1907
|
+
file_id: z11.string()
|
|
1826
1908
|
})
|
|
1827
1909
|
),
|
|
1828
|
-
stdout:
|
|
1829
|
-
stderr:
|
|
1830
|
-
return_code:
|
|
1910
|
+
stdout: z11.string(),
|
|
1911
|
+
stderr: z11.string(),
|
|
1912
|
+
return_code: z11.number()
|
|
1831
1913
|
}),
|
|
1832
|
-
|
|
1833
|
-
type:
|
|
1834
|
-
error_code:
|
|
1914
|
+
z11.object({
|
|
1915
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1916
|
+
error_code: z11.string()
|
|
1835
1917
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
1838
|
-
error_code:
|
|
1918
|
+
z11.object({
|
|
1919
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1920
|
+
error_code: z11.string()
|
|
1839
1921
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
content:
|
|
1843
|
-
file_type:
|
|
1844
|
-
num_lines:
|
|
1845
|
-
start_line:
|
|
1846
|
-
total_lines:
|
|
1922
|
+
z11.object({
|
|
1923
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1924
|
+
content: z11.string(),
|
|
1925
|
+
file_type: z11.string(),
|
|
1926
|
+
num_lines: z11.number().nullable(),
|
|
1927
|
+
start_line: z11.number().nullable(),
|
|
1928
|
+
total_lines: z11.number().nullable()
|
|
1847
1929
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
is_file_update:
|
|
1930
|
+
z11.object({
|
|
1931
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1932
|
+
is_file_update: z11.boolean()
|
|
1851
1933
|
}),
|
|
1852
|
-
|
|
1853
|
-
type:
|
|
1854
|
-
lines:
|
|
1855
|
-
new_lines:
|
|
1856
|
-
new_start:
|
|
1857
|
-
old_lines:
|
|
1858
|
-
old_start:
|
|
1934
|
+
z11.object({
|
|
1935
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1936
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1937
|
+
new_lines: z11.number().nullable(),
|
|
1938
|
+
new_start: z11.number().nullable(),
|
|
1939
|
+
old_lines: z11.number().nullable(),
|
|
1940
|
+
old_start: z11.number().nullable()
|
|
1859
1941
|
})
|
|
1860
1942
|
])
|
|
1861
1943
|
)
|
|
1862
1944
|
);
|
|
1863
|
-
var codeExecution_20260120InputSchema = (
|
|
1864
|
-
() => (
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
type:
|
|
1868
|
-
code:
|
|
1945
|
+
var codeExecution_20260120InputSchema = lazySchema10(
|
|
1946
|
+
() => zodSchema10(
|
|
1947
|
+
z11.discriminatedUnion("type", [
|
|
1948
|
+
z11.object({
|
|
1949
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1950
|
+
code: z11.string()
|
|
1869
1951
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1872
|
-
command:
|
|
1952
|
+
z11.object({
|
|
1953
|
+
type: z11.literal("bash_code_execution"),
|
|
1954
|
+
command: z11.string()
|
|
1873
1955
|
}),
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
type:
|
|
1877
|
-
command:
|
|
1878
|
-
path:
|
|
1956
|
+
z11.discriminatedUnion("command", [
|
|
1957
|
+
z11.object({
|
|
1958
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1959
|
+
command: z11.literal("view"),
|
|
1960
|
+
path: z11.string()
|
|
1879
1961
|
}),
|
|
1880
|
-
|
|
1881
|
-
type:
|
|
1882
|
-
command:
|
|
1883
|
-
path:
|
|
1884
|
-
file_text:
|
|
1962
|
+
z11.object({
|
|
1963
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1964
|
+
command: z11.literal("create"),
|
|
1965
|
+
path: z11.string(),
|
|
1966
|
+
file_text: z11.string().nullish()
|
|
1885
1967
|
}),
|
|
1886
|
-
|
|
1887
|
-
type:
|
|
1888
|
-
command:
|
|
1889
|
-
path:
|
|
1890
|
-
old_str:
|
|
1891
|
-
new_str:
|
|
1968
|
+
z11.object({
|
|
1969
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1970
|
+
command: z11.literal("str_replace"),
|
|
1971
|
+
path: z11.string(),
|
|
1972
|
+
old_str: z11.string(),
|
|
1973
|
+
new_str: z11.string()
|
|
1892
1974
|
})
|
|
1893
1975
|
])
|
|
1894
1976
|
])
|
|
1895
1977
|
)
|
|
1896
1978
|
);
|
|
1897
|
-
var factory8 = (
|
|
1979
|
+
var factory8 = createProviderExecutedToolFactory7({
|
|
1898
1980
|
id: "anthropic.code_execution_20260120",
|
|
1899
1981
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1900
1982
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -1905,21 +1987,25 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1905
1987
|
};
|
|
1906
1988
|
|
|
1907
1989
|
// src/tool/tool-search-regex_20251119.ts
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1990
|
+
import {
|
|
1991
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
|
|
1992
|
+
lazySchema as lazySchema11,
|
|
1993
|
+
zodSchema as zodSchema11
|
|
1994
|
+
} from "@ai-sdk/provider-utils";
|
|
1995
|
+
import { z as z12 } from "zod/v4";
|
|
1996
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema11(
|
|
1997
|
+
() => zodSchema11(
|
|
1998
|
+
z12.array(
|
|
1999
|
+
z12.object({
|
|
2000
|
+
type: z12.literal("tool_reference"),
|
|
2001
|
+
toolName: z12.string()
|
|
1916
2002
|
})
|
|
1917
2003
|
)
|
|
1918
2004
|
)
|
|
1919
2005
|
);
|
|
1920
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1921
|
-
() => (
|
|
1922
|
-
|
|
2006
|
+
var toolSearchRegex_20251119InputSchema = lazySchema11(
|
|
2007
|
+
() => zodSchema11(
|
|
2008
|
+
z12.object({
|
|
1923
2009
|
/**
|
|
1924
2010
|
* A regex pattern to search for tools.
|
|
1925
2011
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1930,15 +2016,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1930
2016
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1931
2017
|
* - "(?i)slack" - case-insensitive search
|
|
1932
2018
|
*/
|
|
1933
|
-
pattern:
|
|
2019
|
+
pattern: z12.string(),
|
|
1934
2020
|
/**
|
|
1935
2021
|
* Maximum number of tools to return. Optional.
|
|
1936
2022
|
*/
|
|
1937
|
-
limit:
|
|
2023
|
+
limit: z12.number().optional()
|
|
1938
2024
|
})
|
|
1939
2025
|
)
|
|
1940
2026
|
);
|
|
1941
|
-
var factory9 = (
|
|
2027
|
+
var factory9 = createProviderExecutedToolFactory8({
|
|
1942
2028
|
id: "anthropic.tool_search_regex_20251119",
|
|
1943
2029
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1944
2030
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -1948,20 +2034,20 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1948
2034
|
return factory9(args);
|
|
1949
2035
|
};
|
|
1950
2036
|
|
|
1951
|
-
// src/convert-to-anthropic-
|
|
2037
|
+
// src/convert-to-anthropic-prompt.ts
|
|
1952
2038
|
function convertToString(data) {
|
|
1953
2039
|
if (typeof data === "string") {
|
|
1954
|
-
return new TextDecoder().decode(
|
|
2040
|
+
return new TextDecoder().decode(convertBase64ToUint8Array(data));
|
|
1955
2041
|
}
|
|
1956
2042
|
if (data instanceof Uint8Array) {
|
|
1957
2043
|
return new TextDecoder().decode(data);
|
|
1958
2044
|
}
|
|
1959
2045
|
if (data instanceof URL) {
|
|
1960
|
-
throw new
|
|
2046
|
+
throw new UnsupportedFunctionalityError2({
|
|
1961
2047
|
functionality: "URL-based text documents are not supported for citations"
|
|
1962
2048
|
});
|
|
1963
2049
|
}
|
|
1964
|
-
throw new
|
|
2050
|
+
throw new UnsupportedFunctionalityError2({
|
|
1965
2051
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1966
2052
|
});
|
|
1967
2053
|
}
|
|
@@ -1974,7 +2060,7 @@ function isUrlString(data) {
|
|
|
1974
2060
|
function getUrlString(data) {
|
|
1975
2061
|
return data instanceof URL ? data.toString() : data;
|
|
1976
2062
|
}
|
|
1977
|
-
async function
|
|
2063
|
+
async function convertToAnthropicPrompt({
|
|
1978
2064
|
prompt,
|
|
1979
2065
|
sendReasoning,
|
|
1980
2066
|
warnings,
|
|
@@ -1989,7 +2075,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1989
2075
|
const messages = [];
|
|
1990
2076
|
async function shouldEnableCitations(providerMetadata) {
|
|
1991
2077
|
var _a2, _b2;
|
|
1992
|
-
const anthropicOptions = await
|
|
2078
|
+
const anthropicOptions = await parseProviderOptions({
|
|
1993
2079
|
provider: "anthropic",
|
|
1994
2080
|
providerOptions: providerMetadata,
|
|
1995
2081
|
schema: anthropicFilePartProviderOptions
|
|
@@ -1997,7 +2083,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1997
2083
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
1998
2084
|
}
|
|
1999
2085
|
async function getDocumentMetadata(providerMetadata) {
|
|
2000
|
-
const anthropicOptions = await
|
|
2086
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2001
2087
|
provider: "anthropic",
|
|
2002
2088
|
providerOptions: providerMetadata,
|
|
2003
2089
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2014,7 +2100,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2014
2100
|
switch (type) {
|
|
2015
2101
|
case "system": {
|
|
2016
2102
|
if (system != null) {
|
|
2017
|
-
throw new
|
|
2103
|
+
throw new UnsupportedFunctionalityError2({
|
|
2018
2104
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2019
2105
|
});
|
|
2020
2106
|
}
|
|
@@ -2054,7 +2140,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2054
2140
|
break;
|
|
2055
2141
|
}
|
|
2056
2142
|
case "file": {
|
|
2057
|
-
if (part.
|
|
2143
|
+
if (isProviderReference(part.data)) {
|
|
2144
|
+
const fileId = resolveProviderReference({
|
|
2145
|
+
reference: part.data,
|
|
2146
|
+
provider: "anthropic"
|
|
2147
|
+
});
|
|
2148
|
+
betas.add("files-api-2025-04-14");
|
|
2149
|
+
if (part.mediaType.startsWith("image/")) {
|
|
2150
|
+
anthropicContent.push({
|
|
2151
|
+
type: "image",
|
|
2152
|
+
source: { type: "file", file_id: fileId },
|
|
2153
|
+
cache_control: cacheControl
|
|
2154
|
+
});
|
|
2155
|
+
} else {
|
|
2156
|
+
anthropicContent.push({
|
|
2157
|
+
type: "document",
|
|
2158
|
+
source: { type: "file", file_id: fileId },
|
|
2159
|
+
cache_control: cacheControl
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
} else if (part.mediaType.startsWith("image/")) {
|
|
2058
2163
|
anthropicContent.push({
|
|
2059
2164
|
type: "image",
|
|
2060
2165
|
source: isUrlData(part.data) ? {
|
|
@@ -2063,7 +2168,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2063
2168
|
} : {
|
|
2064
2169
|
type: "base64",
|
|
2065
2170
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
2066
|
-
data:
|
|
2171
|
+
data: convertToBase64(part.data)
|
|
2067
2172
|
},
|
|
2068
2173
|
cache_control: cacheControl
|
|
2069
2174
|
});
|
|
@@ -2083,7 +2188,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2083
2188
|
} : {
|
|
2084
2189
|
type: "base64",
|
|
2085
2190
|
media_type: "application/pdf",
|
|
2086
|
-
data:
|
|
2191
|
+
data: convertToBase64(part.data)
|
|
2087
2192
|
},
|
|
2088
2193
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2089
2194
|
...metadata.context && { context: metadata.context },
|
|
@@ -2117,7 +2222,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2117
2222
|
cache_control: cacheControl
|
|
2118
2223
|
});
|
|
2119
2224
|
} else {
|
|
2120
|
-
throw new
|
|
2225
|
+
throw new UnsupportedFunctionalityError2({
|
|
2121
2226
|
functionality: `media type: ${part.mediaType}`
|
|
2122
2227
|
});
|
|
2123
2228
|
}
|
|
@@ -2153,26 +2258,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2153
2258
|
type: "text",
|
|
2154
2259
|
text: contentPart.text
|
|
2155
2260
|
};
|
|
2156
|
-
case "image-data": {
|
|
2157
|
-
return {
|
|
2158
|
-
type: "image",
|
|
2159
|
-
source: {
|
|
2160
|
-
type: "base64",
|
|
2161
|
-
media_type: contentPart.mediaType,
|
|
2162
|
-
data: contentPart.data
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
}
|
|
2166
|
-
case "image-url": {
|
|
2167
|
-
return {
|
|
2168
|
-
type: "image",
|
|
2169
|
-
source: {
|
|
2170
|
-
type: "url",
|
|
2171
|
-
url: contentPart.url
|
|
2172
|
-
}
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
2175
2261
|
case "file-url": {
|
|
2262
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2263
|
+
return {
|
|
2264
|
+
type: "image",
|
|
2265
|
+
source: {
|
|
2266
|
+
type: "url",
|
|
2267
|
+
url: contentPart.url
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2176
2271
|
return {
|
|
2177
2272
|
type: "document",
|
|
2178
2273
|
source: {
|
|
@@ -2182,6 +2277,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2182
2277
|
};
|
|
2183
2278
|
}
|
|
2184
2279
|
case "file-data": {
|
|
2280
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2281
|
+
return {
|
|
2282
|
+
type: "image",
|
|
2283
|
+
source: {
|
|
2284
|
+
type: "base64",
|
|
2285
|
+
media_type: contentPart.mediaType,
|
|
2286
|
+
data: contentPart.data
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2185
2290
|
if (contentPart.mediaType === "application/pdf") {
|
|
2186
2291
|
betas.add("pdfs-2024-09-25");
|
|
2187
2292
|
return {
|
|
@@ -2221,14 +2326,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2221
2326
|
return void 0;
|
|
2222
2327
|
}
|
|
2223
2328
|
}
|
|
2224
|
-
}).filter(
|
|
2329
|
+
}).filter(isNonNullable);
|
|
2225
2330
|
break;
|
|
2226
2331
|
case "text":
|
|
2227
2332
|
case "error-text":
|
|
2228
2333
|
contentValue = output.value;
|
|
2229
2334
|
break;
|
|
2230
2335
|
case "execution-denied":
|
|
2231
|
-
contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
|
|
2336
|
+
contentValue = (_e = output.reason) != null ? _e : "Tool call execution denied.";
|
|
2232
2337
|
break;
|
|
2233
2338
|
case "json":
|
|
2234
2339
|
case "error-json":
|
|
@@ -2297,7 +2402,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2297
2402
|
}
|
|
2298
2403
|
case "reasoning": {
|
|
2299
2404
|
if (sendReasoning) {
|
|
2300
|
-
const reasoningMetadata = await
|
|
2405
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2301
2406
|
provider: "anthropic",
|
|
2302
2407
|
providerOptions: part.providerOptions,
|
|
2303
2408
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2503,7 +2608,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2503
2608
|
break;
|
|
2504
2609
|
}
|
|
2505
2610
|
if (output.value.type === "code_execution_result") {
|
|
2506
|
-
const codeExecutionOutput = await (
|
|
2611
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2507
2612
|
value: output.value,
|
|
2508
2613
|
schema: codeExecution_20250522OutputSchema
|
|
2509
2614
|
});
|
|
@@ -2520,7 +2625,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2520
2625
|
cache_control: cacheControl
|
|
2521
2626
|
});
|
|
2522
2627
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2523
|
-
const codeExecutionOutput = await (
|
|
2628
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2524
2629
|
value: output.value,
|
|
2525
2630
|
schema: codeExecution_20260120OutputSchema
|
|
2526
2631
|
});
|
|
@@ -2539,7 +2644,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2539
2644
|
});
|
|
2540
2645
|
}
|
|
2541
2646
|
} else {
|
|
2542
|
-
const codeExecutionOutput = await (
|
|
2647
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2543
2648
|
value: output.value,
|
|
2544
2649
|
schema: codeExecution_20250825OutputSchema
|
|
2545
2650
|
});
|
|
@@ -2608,7 +2713,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2608
2713
|
});
|
|
2609
2714
|
break;
|
|
2610
2715
|
}
|
|
2611
|
-
const webFetchOutput = await (
|
|
2716
|
+
const webFetchOutput = await validateTypes2({
|
|
2612
2717
|
value: output.value,
|
|
2613
2718
|
schema: webFetch_20250910OutputSchema
|
|
2614
2719
|
});
|
|
@@ -2643,7 +2748,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2643
2748
|
});
|
|
2644
2749
|
break;
|
|
2645
2750
|
}
|
|
2646
|
-
const webSearchOutput = await (
|
|
2751
|
+
const webSearchOutput = await validateTypes2({
|
|
2647
2752
|
value: output.value,
|
|
2648
2753
|
schema: webSearch_20250305OutputSchema
|
|
2649
2754
|
});
|
|
@@ -2670,7 +2775,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2670
2775
|
});
|
|
2671
2776
|
break;
|
|
2672
2777
|
}
|
|
2673
|
-
const toolSearchOutput = await (
|
|
2778
|
+
const toolSearchOutput = await validateTypes2({
|
|
2674
2779
|
value: output.value,
|
|
2675
2780
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2676
2781
|
});
|
|
@@ -2783,7 +2888,153 @@ function mapAnthropicStopReason({
|
|
|
2783
2888
|
}
|
|
2784
2889
|
}
|
|
2785
2890
|
|
|
2786
|
-
// src/
|
|
2891
|
+
// src/sanitize-json-schema.ts
|
|
2892
|
+
var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
2893
|
+
"date-time",
|
|
2894
|
+
"time",
|
|
2895
|
+
"date",
|
|
2896
|
+
"duration",
|
|
2897
|
+
"email",
|
|
2898
|
+
"hostname",
|
|
2899
|
+
"uri",
|
|
2900
|
+
"ipv4",
|
|
2901
|
+
"ipv6",
|
|
2902
|
+
"uuid"
|
|
2903
|
+
]);
|
|
2904
|
+
var DESCRIPTION_CONSTRAINT_KEYS = [
|
|
2905
|
+
"minimum",
|
|
2906
|
+
"maximum",
|
|
2907
|
+
"exclusiveMinimum",
|
|
2908
|
+
"exclusiveMaximum",
|
|
2909
|
+
"multipleOf",
|
|
2910
|
+
"minLength",
|
|
2911
|
+
"maxLength",
|
|
2912
|
+
"pattern",
|
|
2913
|
+
"minItems",
|
|
2914
|
+
"maxItems",
|
|
2915
|
+
"uniqueItems",
|
|
2916
|
+
"minProperties",
|
|
2917
|
+
"maxProperties",
|
|
2918
|
+
"not"
|
|
2919
|
+
];
|
|
2920
|
+
function sanitizeJsonSchema(schema) {
|
|
2921
|
+
return sanitizeSchema(schema);
|
|
2922
|
+
}
|
|
2923
|
+
function sanitizeDefinition(definition) {
|
|
2924
|
+
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
2925
|
+
return definition;
|
|
2926
|
+
}
|
|
2927
|
+
return sanitizeSchema(definition);
|
|
2928
|
+
}
|
|
2929
|
+
function sanitizeSchema(schema) {
|
|
2930
|
+
const result = {};
|
|
2931
|
+
const schemaWithDefs = schema;
|
|
2932
|
+
if (schema.$ref != null) {
|
|
2933
|
+
return { $ref: schema.$ref };
|
|
2934
|
+
}
|
|
2935
|
+
if (schema.$schema != null) {
|
|
2936
|
+
result.$schema = schema.$schema;
|
|
2937
|
+
}
|
|
2938
|
+
if (schema.$id != null) {
|
|
2939
|
+
result.$id = schema.$id;
|
|
2940
|
+
}
|
|
2941
|
+
if (schema.title != null) {
|
|
2942
|
+
result.title = schema.title;
|
|
2943
|
+
}
|
|
2944
|
+
if (schema.description != null) {
|
|
2945
|
+
result.description = schema.description;
|
|
2946
|
+
}
|
|
2947
|
+
if (schema.default !== void 0) {
|
|
2948
|
+
result.default = schema.default;
|
|
2949
|
+
}
|
|
2950
|
+
if (schema.const !== void 0) {
|
|
2951
|
+
result.const = schema.const;
|
|
2952
|
+
}
|
|
2953
|
+
if (schema.enum != null) {
|
|
2954
|
+
result.enum = schema.enum;
|
|
2955
|
+
}
|
|
2956
|
+
if (schema.type != null) {
|
|
2957
|
+
result.type = schema.type;
|
|
2958
|
+
}
|
|
2959
|
+
if (schema.anyOf != null) {
|
|
2960
|
+
result.anyOf = schema.anyOf.map(sanitizeDefinition);
|
|
2961
|
+
} else if (schema.oneOf != null) {
|
|
2962
|
+
result.anyOf = schema.oneOf.map(sanitizeDefinition);
|
|
2963
|
+
}
|
|
2964
|
+
if (schema.allOf != null) {
|
|
2965
|
+
result.allOf = schema.allOf.map(sanitizeDefinition);
|
|
2966
|
+
}
|
|
2967
|
+
if (schema.definitions != null) {
|
|
2968
|
+
result.definitions = Object.fromEntries(
|
|
2969
|
+
Object.entries(schema.definitions).map(([name, definition]) => [
|
|
2970
|
+
name,
|
|
2971
|
+
sanitizeDefinition(definition)
|
|
2972
|
+
])
|
|
2973
|
+
);
|
|
2974
|
+
}
|
|
2975
|
+
if (schemaWithDefs.$defs != null) {
|
|
2976
|
+
const resultWithDefs = result;
|
|
2977
|
+
resultWithDefs.$defs = Object.fromEntries(
|
|
2978
|
+
Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
|
|
2979
|
+
name,
|
|
2980
|
+
sanitizeDefinition(definition)
|
|
2981
|
+
])
|
|
2982
|
+
);
|
|
2983
|
+
}
|
|
2984
|
+
if (schema.type === "object" || schema.properties != null) {
|
|
2985
|
+
if (schema.properties != null) {
|
|
2986
|
+
result.properties = Object.fromEntries(
|
|
2987
|
+
Object.entries(schema.properties).map(([name, definition]) => [
|
|
2988
|
+
name,
|
|
2989
|
+
sanitizeDefinition(definition)
|
|
2990
|
+
])
|
|
2991
|
+
);
|
|
2992
|
+
}
|
|
2993
|
+
result.additionalProperties = false;
|
|
2994
|
+
if (schema.required != null) {
|
|
2995
|
+
result.required = schema.required;
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
if (schema.items != null) {
|
|
2999
|
+
result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
|
|
3000
|
+
}
|
|
3001
|
+
if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3002
|
+
result.format = schema.format;
|
|
3003
|
+
}
|
|
3004
|
+
const constraintDescription = getConstraintDescription(schema);
|
|
3005
|
+
if (constraintDescription != null) {
|
|
3006
|
+
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
3007
|
+
${constraintDescription}`;
|
|
3008
|
+
}
|
|
3009
|
+
return result;
|
|
3010
|
+
}
|
|
3011
|
+
function getConstraintDescription(schema) {
|
|
3012
|
+
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
3013
|
+
const value = schema[key];
|
|
3014
|
+
if (value == null || value === false) {
|
|
3015
|
+
return [];
|
|
3016
|
+
}
|
|
3017
|
+
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
3018
|
+
});
|
|
3019
|
+
if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3020
|
+
descriptions.push(`format: ${schema.format}`);
|
|
3021
|
+
}
|
|
3022
|
+
return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
|
|
3023
|
+
}
|
|
3024
|
+
function formatConstraintName(key) {
|
|
3025
|
+
return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
|
|
3026
|
+
}
|
|
3027
|
+
function formatConstraintValue(value) {
|
|
3028
|
+
if (typeof value === "string") {
|
|
3029
|
+
return value;
|
|
3030
|
+
}
|
|
3031
|
+
return JSON.stringify(value);
|
|
3032
|
+
}
|
|
3033
|
+
function isPlainObject(value) {
|
|
3034
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
// src/anthropic-language-model.ts
|
|
2787
3038
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
2788
3039
|
var _a;
|
|
2789
3040
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2828,13 +3079,22 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
2828
3079
|
}
|
|
2829
3080
|
};
|
|
2830
3081
|
}
|
|
2831
|
-
var
|
|
3082
|
+
var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
2832
3083
|
constructor(modelId, config) {
|
|
2833
3084
|
this.specificationVersion = "v4";
|
|
2834
3085
|
var _a;
|
|
2835
3086
|
this.modelId = modelId;
|
|
2836
3087
|
this.config = config;
|
|
2837
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3088
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3089
|
+
}
|
|
3090
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3091
|
+
return serializeModelOptions({
|
|
3092
|
+
modelId: model.modelId,
|
|
3093
|
+
config: model.config
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3097
|
+
return new _AnthropicLanguageModel(options.modelId, options.config);
|
|
2838
3098
|
}
|
|
2839
3099
|
supportsUrl(url) {
|
|
2840
3100
|
return url.protocol === "https:";
|
|
@@ -2869,10 +3129,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2869
3129
|
seed,
|
|
2870
3130
|
tools,
|
|
2871
3131
|
toolChoice,
|
|
3132
|
+
reasoning,
|
|
2872
3133
|
providerOptions,
|
|
2873
3134
|
stream
|
|
2874
3135
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2876
3137
|
const warnings = [];
|
|
2877
3138
|
if (frequencyPenalty != null) {
|
|
2878
3139
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2908,12 +3169,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2908
3169
|
}
|
|
2909
3170
|
}
|
|
2910
3171
|
const providerOptionsName = this.providerOptionsName;
|
|
2911
|
-
const canonicalOptions = await (
|
|
3172
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2912
3173
|
provider: "anthropic",
|
|
2913
3174
|
providerOptions,
|
|
2914
3175
|
schema: anthropicLanguageModelOptions
|
|
2915
3176
|
});
|
|
2916
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3177
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2917
3178
|
provider: providerOptionsName,
|
|
2918
3179
|
providerOptions,
|
|
2919
3180
|
schema: anthropicLanguageModelOptions
|
|
@@ -2927,8 +3188,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
3188
|
const {
|
|
2928
3189
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2929
3190
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3191
|
+
supportsAdaptiveThinking,
|
|
3192
|
+
rejectsSamplingParameters,
|
|
3193
|
+
supportsXhighEffort,
|
|
2930
3194
|
isKnownModel
|
|
2931
3195
|
} = getModelCapabilities(this.modelId);
|
|
3196
|
+
if (rejectsSamplingParameters) {
|
|
3197
|
+
if (temperature != null) {
|
|
3198
|
+
warnings.push({
|
|
3199
|
+
type: "unsupported",
|
|
3200
|
+
feature: "temperature",
|
|
3201
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3202
|
+
});
|
|
3203
|
+
temperature = void 0;
|
|
3204
|
+
}
|
|
3205
|
+
if (topK != null) {
|
|
3206
|
+
warnings.push({
|
|
3207
|
+
type: "unsupported",
|
|
3208
|
+
feature: "topK",
|
|
3209
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3210
|
+
});
|
|
3211
|
+
topK = void 0;
|
|
3212
|
+
}
|
|
3213
|
+
if (topP != null) {
|
|
3214
|
+
warnings.push({
|
|
3215
|
+
type: "unsupported",
|
|
3216
|
+
feature: "topP",
|
|
3217
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3218
|
+
});
|
|
3219
|
+
topP = void 0;
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2932
3223
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
3224
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2934
3225
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -2941,7 +3232,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2941
3232
|
} : void 0;
|
|
2942
3233
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2943
3234
|
const cacheControlValidator = new CacheControlValidator();
|
|
2944
|
-
const toolNameMapping =
|
|
3235
|
+
const toolNameMapping = createToolNameMapping({
|
|
2945
3236
|
tools,
|
|
2946
3237
|
providerToolNames: {
|
|
2947
3238
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2964,16 +3255,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2964
3255
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
2965
3256
|
}
|
|
2966
3257
|
});
|
|
2967
|
-
const { prompt: messagesPrompt, betas } = await
|
|
3258
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
2968
3259
|
prompt,
|
|
2969
3260
|
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2970
3261
|
warnings,
|
|
2971
3262
|
cacheControlValidator,
|
|
2972
3263
|
toolNameMapping
|
|
2973
3264
|
});
|
|
2974
|
-
|
|
3265
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3266
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3267
|
+
reasoning,
|
|
3268
|
+
supportsAdaptiveThinking,
|
|
3269
|
+
supportsXhighEffort,
|
|
3270
|
+
maxOutputTokensForModel,
|
|
3271
|
+
warnings
|
|
3272
|
+
});
|
|
3273
|
+
if (reasoningConfig != null) {
|
|
3274
|
+
if (anthropicOptions.thinking == null) {
|
|
3275
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3276
|
+
}
|
|
3277
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3278
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
2975
3283
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2976
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3284
|
+
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3285
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
2977
3286
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2978
3287
|
const baseArgs = {
|
|
2979
3288
|
// model id:
|
|
@@ -2988,18 +3297,28 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2988
3297
|
...isThinking && {
|
|
2989
3298
|
thinking: {
|
|
2990
3299
|
type: thinkingType,
|
|
2991
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3300
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3301
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2992
3302
|
}
|
|
2993
3303
|
},
|
|
2994
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3304
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2995
3305
|
output_config: {
|
|
2996
3306
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2997
3307
|
effort: anthropicOptions.effort
|
|
2998
3308
|
},
|
|
3309
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3310
|
+
task_budget: {
|
|
3311
|
+
type: anthropicOptions.taskBudget.type,
|
|
3312
|
+
total: anthropicOptions.taskBudget.total,
|
|
3313
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3314
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
},
|
|
2999
3318
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
3000
3319
|
format: {
|
|
3001
3320
|
type: "json_schema",
|
|
3002
|
-
schema: responseFormat.schema
|
|
3321
|
+
schema: sanitizeJsonSchema(responseFormat.schema)
|
|
3003
3322
|
}
|
|
3004
3323
|
}
|
|
3005
3324
|
}
|
|
@@ -3007,9 +3326,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3007
3326
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3008
3327
|
speed: anthropicOptions.speed
|
|
3009
3328
|
},
|
|
3329
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3330
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3331
|
+
},
|
|
3010
3332
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3011
3333
|
cache_control: anthropicOptions.cacheControl
|
|
3012
3334
|
},
|
|
3335
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3336
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3337
|
+
},
|
|
3013
3338
|
// mcp servers:
|
|
3014
3339
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3015
3340
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3031,7 +3356,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3031
3356
|
id: anthropicOptions.container.id,
|
|
3032
3357
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3033
3358
|
type: skill.type,
|
|
3034
|
-
skill_id: skill.
|
|
3359
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3360
|
+
reference: skill.providerReference,
|
|
3361
|
+
provider: "anthropic"
|
|
3362
|
+
}) : skill.skillId,
|
|
3035
3363
|
version: skill.version
|
|
3036
3364
|
}))
|
|
3037
3365
|
}
|
|
@@ -3133,7 +3461,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3133
3461
|
}
|
|
3134
3462
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3135
3463
|
} else {
|
|
3136
|
-
if (topP != null && temperature != null) {
|
|
3464
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3137
3465
|
warnings.push({
|
|
3138
3466
|
type: "unsupported",
|
|
3139
3467
|
feature: "topP",
|
|
@@ -3177,12 +3505,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3177
3505
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3178
3506
|
betas.add("effort-2025-11-24");
|
|
3179
3507
|
}
|
|
3508
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3509
|
+
betas.add("task-budgets-2026-03-13");
|
|
3510
|
+
}
|
|
3180
3511
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3181
3512
|
betas.add("fast-mode-2026-02-01");
|
|
3182
3513
|
}
|
|
3183
|
-
|
|
3184
|
-
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3185
|
-
}
|
|
3514
|
+
const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
|
|
3186
3515
|
const {
|
|
3187
3516
|
tools: anthropicTools2,
|
|
3188
3517
|
toolChoice: anthropicToolChoice,
|
|
@@ -3195,14 +3524,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3195
3524
|
disableParallelToolUse: true,
|
|
3196
3525
|
cacheControlValidator,
|
|
3197
3526
|
supportsStructuredOutput: false,
|
|
3198
|
-
supportsStrictTools
|
|
3527
|
+
supportsStrictTools,
|
|
3528
|
+
defaultEagerInputStreaming
|
|
3199
3529
|
} : {
|
|
3200
3530
|
tools: tools != null ? tools : [],
|
|
3201
3531
|
toolChoice,
|
|
3202
3532
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3203
3533
|
cacheControlValidator,
|
|
3204
3534
|
supportsStructuredOutput,
|
|
3205
|
-
supportsStrictTools
|
|
3535
|
+
supportsStrictTools,
|
|
3536
|
+
defaultEagerInputStreaming
|
|
3206
3537
|
}
|
|
3207
3538
|
);
|
|
3208
3539
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3219,7 +3550,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3219
3550
|
...betas,
|
|
3220
3551
|
...toolsBetas,
|
|
3221
3552
|
...userSuppliedBetas,
|
|
3222
|
-
...(
|
|
3553
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3223
3554
|
]),
|
|
3224
3555
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3225
3556
|
toolNameMapping,
|
|
@@ -3231,16 +3562,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3231
3562
|
betas,
|
|
3232
3563
|
headers
|
|
3233
3564
|
}) {
|
|
3234
|
-
return
|
|
3235
|
-
await
|
|
3565
|
+
return combineHeaders(
|
|
3566
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3236
3567
|
headers,
|
|
3237
3568
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3238
3569
|
);
|
|
3239
3570
|
}
|
|
3240
3571
|
async getBetasFromHeaders(requestHeaders) {
|
|
3241
3572
|
var _a, _b;
|
|
3242
|
-
const configHeaders = await
|
|
3243
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3573
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3574
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3244
3575
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3245
3576
|
return new Set(
|
|
3246
3577
|
[
|
|
@@ -3305,13 +3636,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3305
3636
|
responseHeaders,
|
|
3306
3637
|
value: response,
|
|
3307
3638
|
rawValue: rawResponse
|
|
3308
|
-
} = await
|
|
3639
|
+
} = await postJsonToApi({
|
|
3309
3640
|
url: this.buildRequestUrl(false),
|
|
3310
3641
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3311
3642
|
body: this.transformRequestBody(args, betas),
|
|
3312
3643
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3313
|
-
successfulResponseHandler:
|
|
3314
|
-
|
|
3644
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
3645
|
+
anthropicResponseSchema
|
|
3315
3646
|
),
|
|
3316
3647
|
abortSignal: options.abortSignal,
|
|
3317
3648
|
fetch: this.config.fetch
|
|
@@ -3660,7 +3991,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3660
3991
|
}),
|
|
3661
3992
|
raw: (_e = response.stop_reason) != null ? _e : void 0
|
|
3662
3993
|
},
|
|
3663
|
-
usage:
|
|
3994
|
+
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
3664
3995
|
request: { body: args },
|
|
3665
3996
|
response: {
|
|
3666
3997
|
id: (_f = response.id) != null ? _f : void 0,
|
|
@@ -3670,11 +4001,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3670
4001
|
},
|
|
3671
4002
|
warnings,
|
|
3672
4003
|
providerMetadata: (() => {
|
|
3673
|
-
var _a2, _b2, _c2, _d2
|
|
4004
|
+
var _a2, _b2, _c2, _d2;
|
|
3674
4005
|
const anthropicMetadata = {
|
|
3675
4006
|
usage: response.usage,
|
|
3676
|
-
|
|
3677
|
-
stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
|
|
4007
|
+
stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
|
|
3678
4008
|
iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
|
|
3679
4009
|
type: iter.type,
|
|
3680
4010
|
inputTokens: iter.input_tokens,
|
|
@@ -3683,15 +4013,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3683
4013
|
container: response.container ? {
|
|
3684
4014
|
expiresAt: response.container.expires_at,
|
|
3685
4015
|
id: response.container.id,
|
|
3686
|
-
skills: (
|
|
4016
|
+
skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
|
|
3687
4017
|
type: skill.type,
|
|
3688
4018
|
skillId: skill.skill_id,
|
|
3689
4019
|
version: skill.version
|
|
3690
|
-
}))) != null ?
|
|
4020
|
+
}))) != null ? _c2 : null
|
|
3691
4021
|
} : null,
|
|
3692
|
-
contextManagement: (
|
|
4022
|
+
contextManagement: (_d2 = mapAnthropicResponseContextManagement(
|
|
3693
4023
|
response.context_management
|
|
3694
|
-
)) != null ?
|
|
4024
|
+
)) != null ? _d2 : null
|
|
3695
4025
|
};
|
|
3696
4026
|
const providerMetadata = {
|
|
3697
4027
|
anthropic: anthropicMetadata
|
|
@@ -3704,6 +4034,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3704
4034
|
};
|
|
3705
4035
|
}
|
|
3706
4036
|
async doStream(options) {
|
|
4037
|
+
"use step";
|
|
3707
4038
|
var _a, _b;
|
|
3708
4039
|
const {
|
|
3709
4040
|
args: body,
|
|
@@ -3725,14 +4056,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3725
4056
|
body.tools
|
|
3726
4057
|
);
|
|
3727
4058
|
const url = this.buildRequestUrl(true);
|
|
3728
|
-
const { responseHeaders, value: response } = await
|
|
4059
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3729
4060
|
url,
|
|
3730
4061
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3731
4062
|
body: this.transformRequestBody(body, betas),
|
|
3732
4063
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3733
|
-
successfulResponseHandler: (
|
|
3734
|
-
anthropicMessagesChunkSchema
|
|
3735
|
-
),
|
|
4064
|
+
successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
|
|
3736
4065
|
abortSignal: options.abortSignal,
|
|
3737
4066
|
fetch: this.config.fetch
|
|
3738
4067
|
});
|
|
@@ -3752,7 +4081,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3752
4081
|
const serverToolCalls = {};
|
|
3753
4082
|
let contextManagement = null;
|
|
3754
4083
|
let rawUsage = void 0;
|
|
3755
|
-
let cacheCreationInputTokens = null;
|
|
3756
4084
|
let stopSequence = null;
|
|
3757
4085
|
let container = null;
|
|
3758
4086
|
let isJsonResponseFromTool = false;
|
|
@@ -3764,7 +4092,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3764
4092
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3765
4093
|
},
|
|
3766
4094
|
transform(chunk, controller) {
|
|
3767
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
4095
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3768
4096
|
if (options.includeRawChunks) {
|
|
3769
4097
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3770
4098
|
}
|
|
@@ -4299,7 +4627,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4299
4627
|
rawUsage = {
|
|
4300
4628
|
...value.message.usage
|
|
4301
4629
|
};
|
|
4302
|
-
cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
|
|
4303
4630
|
if (value.message.container != null) {
|
|
4304
4631
|
container = {
|
|
4305
4632
|
expiresAt: value.message.container.expires_at,
|
|
@@ -4318,8 +4645,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4318
4645
|
}
|
|
4319
4646
|
controller.enqueue({
|
|
4320
4647
|
type: "response-metadata",
|
|
4321
|
-
id: (
|
|
4322
|
-
modelId: (
|
|
4648
|
+
id: (_g = value.message.id) != null ? _g : void 0,
|
|
4649
|
+
modelId: (_h = value.message.model) != null ? _h : void 0
|
|
4323
4650
|
});
|
|
4324
4651
|
if (value.message.content != null) {
|
|
4325
4652
|
for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
|
|
@@ -4335,7 +4662,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4335
4662
|
id: part.id,
|
|
4336
4663
|
toolName: part.name
|
|
4337
4664
|
});
|
|
4338
|
-
const inputStr = JSON.stringify((
|
|
4665
|
+
const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
|
|
4339
4666
|
controller.enqueue({
|
|
4340
4667
|
type: "tool-input-delta",
|
|
4341
4668
|
id: part.id,
|
|
@@ -4373,7 +4700,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4373
4700
|
}
|
|
4374
4701
|
if (value.usage.cache_creation_input_tokens != null) {
|
|
4375
4702
|
usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
|
|
4376
|
-
cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
|
|
4377
4703
|
}
|
|
4378
4704
|
if (value.usage.iterations != null) {
|
|
4379
4705
|
usage.iterations = value.usage.iterations;
|
|
@@ -4383,17 +4709,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4383
4709
|
finishReason: value.delta.stop_reason,
|
|
4384
4710
|
isJsonResponseFromTool
|
|
4385
4711
|
}),
|
|
4386
|
-
raw: (
|
|
4712
|
+
raw: (_j = value.delta.stop_reason) != null ? _j : void 0
|
|
4387
4713
|
};
|
|
4388
|
-
stopSequence = (
|
|
4714
|
+
stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
|
|
4389
4715
|
container = value.delta.container != null ? {
|
|
4390
4716
|
expiresAt: value.delta.container.expires_at,
|
|
4391
4717
|
id: value.delta.container.id,
|
|
4392
|
-
skills: (
|
|
4718
|
+
skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
|
|
4393
4719
|
type: skill.type,
|
|
4394
4720
|
skillId: skill.skill_id,
|
|
4395
4721
|
version: skill.version
|
|
4396
|
-
}))) != null ?
|
|
4722
|
+
}))) != null ? _m : null
|
|
4397
4723
|
} : null;
|
|
4398
4724
|
if (value.context_management) {
|
|
4399
4725
|
contextManagement = mapAnthropicResponseContextManagement(
|
|
@@ -4409,7 +4735,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4409
4735
|
case "message_stop": {
|
|
4410
4736
|
const anthropicMetadata = {
|
|
4411
4737
|
usage: rawUsage != null ? rawUsage : null,
|
|
4412
|
-
cacheCreationInputTokens,
|
|
4413
4738
|
stopSequence,
|
|
4414
4739
|
iterations: usage.iterations ? usage.iterations.map((iter) => ({
|
|
4415
4740
|
type: iter.type,
|
|
@@ -4428,7 +4753,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4428
4753
|
controller.enqueue({
|
|
4429
4754
|
type: "finish",
|
|
4430
4755
|
finishReason,
|
|
4431
|
-
usage:
|
|
4756
|
+
usage: convertAnthropicUsage({ usage, rawUsage }),
|
|
4432
4757
|
providerMetadata
|
|
4433
4758
|
});
|
|
4434
4759
|
return;
|
|
@@ -4455,7 +4780,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4455
4780
|
}
|
|
4456
4781
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4457
4782
|
const error = result.value.error;
|
|
4458
|
-
throw new
|
|
4783
|
+
throw new APICallError({
|
|
4459
4784
|
message: error.message,
|
|
4460
4785
|
url,
|
|
4461
4786
|
requestBodyValues: body,
|
|
@@ -4478,46 +4803,76 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4478
4803
|
}
|
|
4479
4804
|
};
|
|
4480
4805
|
function getModelCapabilities(modelId) {
|
|
4481
|
-
if (modelId.includes("claude-
|
|
4806
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4482
4807
|
return {
|
|
4483
4808
|
maxOutputTokens: 128e3,
|
|
4484
4809
|
supportsStructuredOutput: true,
|
|
4810
|
+
supportsAdaptiveThinking: true,
|
|
4811
|
+
rejectsSamplingParameters: true,
|
|
4812
|
+
supportsXhighEffort: true,
|
|
4813
|
+
isKnownModel: true
|
|
4814
|
+
};
|
|
4815
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4816
|
+
return {
|
|
4817
|
+
maxOutputTokens: 128e3,
|
|
4818
|
+
supportsStructuredOutput: true,
|
|
4819
|
+
supportsAdaptiveThinking: true,
|
|
4820
|
+
rejectsSamplingParameters: false,
|
|
4821
|
+
supportsXhighEffort: false,
|
|
4485
4822
|
isKnownModel: true
|
|
4486
4823
|
};
|
|
4487
4824
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4488
4825
|
return {
|
|
4489
4826
|
maxOutputTokens: 64e3,
|
|
4490
4827
|
supportsStructuredOutput: true,
|
|
4828
|
+
supportsAdaptiveThinking: false,
|
|
4829
|
+
rejectsSamplingParameters: false,
|
|
4830
|
+
supportsXhighEffort: false,
|
|
4491
4831
|
isKnownModel: true
|
|
4492
4832
|
};
|
|
4493
4833
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4494
4834
|
return {
|
|
4495
4835
|
maxOutputTokens: 32e3,
|
|
4496
4836
|
supportsStructuredOutput: true,
|
|
4837
|
+
supportsAdaptiveThinking: false,
|
|
4838
|
+
rejectsSamplingParameters: false,
|
|
4839
|
+
supportsXhighEffort: false,
|
|
4497
4840
|
isKnownModel: true
|
|
4498
4841
|
};
|
|
4499
4842
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4500
4843
|
return {
|
|
4501
4844
|
maxOutputTokens: 64e3,
|
|
4502
4845
|
supportsStructuredOutput: false,
|
|
4846
|
+
supportsAdaptiveThinking: false,
|
|
4847
|
+
rejectsSamplingParameters: false,
|
|
4848
|
+
supportsXhighEffort: false,
|
|
4503
4849
|
isKnownModel: true
|
|
4504
4850
|
};
|
|
4505
4851
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4506
4852
|
return {
|
|
4507
4853
|
maxOutputTokens: 32e3,
|
|
4508
4854
|
supportsStructuredOutput: false,
|
|
4855
|
+
supportsAdaptiveThinking: false,
|
|
4856
|
+
rejectsSamplingParameters: false,
|
|
4857
|
+
supportsXhighEffort: false,
|
|
4509
4858
|
isKnownModel: true
|
|
4510
4859
|
};
|
|
4511
4860
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4512
4861
|
return {
|
|
4513
4862
|
maxOutputTokens: 4096,
|
|
4514
4863
|
supportsStructuredOutput: false,
|
|
4864
|
+
supportsAdaptiveThinking: false,
|
|
4865
|
+
rejectsSamplingParameters: false,
|
|
4866
|
+
supportsXhighEffort: false,
|
|
4515
4867
|
isKnownModel: true
|
|
4516
4868
|
};
|
|
4517
4869
|
} else {
|
|
4518
4870
|
return {
|
|
4519
4871
|
maxOutputTokens: 4096,
|
|
4520
4872
|
supportsStructuredOutput: false,
|
|
4873
|
+
supportsAdaptiveThinking: false,
|
|
4874
|
+
rejectsSamplingParameters: false,
|
|
4875
|
+
supportsXhighEffort: false,
|
|
4521
4876
|
isKnownModel: false
|
|
4522
4877
|
};
|
|
4523
4878
|
}
|
|
@@ -4540,6 +4895,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4540
4895
|
}
|
|
4541
4896
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4542
4897
|
}
|
|
4898
|
+
function resolveAnthropicReasoningConfig({
|
|
4899
|
+
reasoning,
|
|
4900
|
+
supportsAdaptiveThinking,
|
|
4901
|
+
supportsXhighEffort,
|
|
4902
|
+
maxOutputTokensForModel,
|
|
4903
|
+
warnings
|
|
4904
|
+
}) {
|
|
4905
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4906
|
+
return void 0;
|
|
4907
|
+
}
|
|
4908
|
+
if (reasoning === "none") {
|
|
4909
|
+
return { thinking: { type: "disabled" } };
|
|
4910
|
+
}
|
|
4911
|
+
if (supportsAdaptiveThinking) {
|
|
4912
|
+
const effort = mapReasoningToProviderEffort({
|
|
4913
|
+
reasoning,
|
|
4914
|
+
effortMap: {
|
|
4915
|
+
minimal: "low",
|
|
4916
|
+
low: "low",
|
|
4917
|
+
medium: "medium",
|
|
4918
|
+
high: "high",
|
|
4919
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
4920
|
+
},
|
|
4921
|
+
warnings
|
|
4922
|
+
});
|
|
4923
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4924
|
+
}
|
|
4925
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4926
|
+
reasoning,
|
|
4927
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4928
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4929
|
+
warnings
|
|
4930
|
+
});
|
|
4931
|
+
if (budgetTokens == null) {
|
|
4932
|
+
return void 0;
|
|
4933
|
+
}
|
|
4934
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4935
|
+
}
|
|
4543
4936
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4544
4937
|
return contextManagement ? {
|
|
4545
4938
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4567,44 +4960,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4567
4960
|
}
|
|
4568
4961
|
|
|
4569
4962
|
// src/tool/bash_20241022.ts
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4963
|
+
import {
|
|
4964
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
4965
|
+
lazySchema as lazySchema12,
|
|
4966
|
+
zodSchema as zodSchema12
|
|
4967
|
+
} from "@ai-sdk/provider-utils";
|
|
4968
|
+
import { z as z13 } from "zod/v4";
|
|
4969
|
+
var bash_20241022InputSchema = lazySchema12(
|
|
4970
|
+
() => zodSchema12(
|
|
4971
|
+
z13.object({
|
|
4972
|
+
command: z13.string(),
|
|
4973
|
+
restart: z13.boolean().optional()
|
|
4577
4974
|
})
|
|
4578
4975
|
)
|
|
4579
4976
|
);
|
|
4580
|
-
var bash_20241022 = (
|
|
4977
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
4581
4978
|
id: "anthropic.bash_20241022",
|
|
4582
4979
|
inputSchema: bash_20241022InputSchema
|
|
4583
4980
|
});
|
|
4584
4981
|
|
|
4585
4982
|
// src/tool/bash_20250124.ts
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4983
|
+
import {
|
|
4984
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
4985
|
+
lazySchema as lazySchema13,
|
|
4986
|
+
zodSchema as zodSchema13
|
|
4987
|
+
} from "@ai-sdk/provider-utils";
|
|
4988
|
+
import { z as z14 } from "zod/v4";
|
|
4989
|
+
var bash_20250124InputSchema = lazySchema13(
|
|
4990
|
+
() => zodSchema13(
|
|
4991
|
+
z14.object({
|
|
4992
|
+
command: z14.string(),
|
|
4993
|
+
restart: z14.boolean().optional()
|
|
4593
4994
|
})
|
|
4594
4995
|
)
|
|
4595
4996
|
);
|
|
4596
|
-
var bash_20250124 = (
|
|
4997
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
4597
4998
|
id: "anthropic.bash_20250124",
|
|
4598
4999
|
inputSchema: bash_20250124InputSchema
|
|
4599
5000
|
});
|
|
4600
5001
|
|
|
4601
5002
|
// src/tool/computer_20241022.ts
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
5003
|
+
import {
|
|
5004
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
5005
|
+
lazySchema as lazySchema14,
|
|
5006
|
+
zodSchema as zodSchema14
|
|
5007
|
+
} from "@ai-sdk/provider-utils";
|
|
5008
|
+
import { z as z15 } from "zod/v4";
|
|
5009
|
+
var computer_20241022InputSchema = lazySchema14(
|
|
5010
|
+
() => zodSchema14(
|
|
5011
|
+
z15.object({
|
|
5012
|
+
action: z15.enum([
|
|
4608
5013
|
"key",
|
|
4609
5014
|
"type",
|
|
4610
5015
|
"mouse_move",
|
|
@@ -4616,23 +5021,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4616
5021
|
"screenshot",
|
|
4617
5022
|
"cursor_position"
|
|
4618
5023
|
]),
|
|
4619
|
-
coordinate:
|
|
4620
|
-
text:
|
|
5024
|
+
coordinate: z15.array(z15.number().int()).optional(),
|
|
5025
|
+
text: z15.string().optional()
|
|
4621
5026
|
})
|
|
4622
5027
|
)
|
|
4623
5028
|
);
|
|
4624
|
-
var computer_20241022 = (
|
|
5029
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
4625
5030
|
id: "anthropic.computer_20241022",
|
|
4626
5031
|
inputSchema: computer_20241022InputSchema
|
|
4627
5032
|
});
|
|
4628
5033
|
|
|
4629
5034
|
// src/tool/computer_20250124.ts
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
5035
|
+
import {
|
|
5036
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
5037
|
+
lazySchema as lazySchema15,
|
|
5038
|
+
zodSchema as zodSchema15
|
|
5039
|
+
} from "@ai-sdk/provider-utils";
|
|
5040
|
+
import { z as z16 } from "zod/v4";
|
|
5041
|
+
var computer_20250124InputSchema = lazySchema15(
|
|
5042
|
+
() => zodSchema15(
|
|
5043
|
+
z16.object({
|
|
5044
|
+
action: z16.enum([
|
|
4636
5045
|
"key",
|
|
4637
5046
|
"hold_key",
|
|
4638
5047
|
"type",
|
|
@@ -4650,27 +5059,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4650
5059
|
"wait",
|
|
4651
5060
|
"screenshot"
|
|
4652
5061
|
]),
|
|
4653
|
-
coordinate:
|
|
4654
|
-
duration:
|
|
4655
|
-
scroll_amount:
|
|
4656
|
-
scroll_direction:
|
|
4657
|
-
start_coordinate:
|
|
4658
|
-
text:
|
|
5062
|
+
coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
|
|
5063
|
+
duration: z16.number().optional(),
|
|
5064
|
+
scroll_amount: z16.number().optional(),
|
|
5065
|
+
scroll_direction: z16.enum(["up", "down", "left", "right"]).optional(),
|
|
5066
|
+
start_coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
|
|
5067
|
+
text: z16.string().optional()
|
|
4659
5068
|
})
|
|
4660
5069
|
)
|
|
4661
5070
|
);
|
|
4662
|
-
var computer_20250124 = (
|
|
5071
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
4663
5072
|
id: "anthropic.computer_20250124",
|
|
4664
5073
|
inputSchema: computer_20250124InputSchema
|
|
4665
5074
|
});
|
|
4666
5075
|
|
|
4667
5076
|
// src/tool/computer_20251124.ts
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
5077
|
+
import {
|
|
5078
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
5079
|
+
lazySchema as lazySchema16,
|
|
5080
|
+
zodSchema as zodSchema16
|
|
5081
|
+
} from "@ai-sdk/provider-utils";
|
|
5082
|
+
import { z as z17 } from "zod/v4";
|
|
5083
|
+
var computer_20251124InputSchema = lazySchema16(
|
|
5084
|
+
() => zodSchema16(
|
|
5085
|
+
z17.object({
|
|
5086
|
+
action: z17.enum([
|
|
4674
5087
|
"key",
|
|
4675
5088
|
"hold_key",
|
|
4676
5089
|
"type",
|
|
@@ -4689,166 +5102,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4689
5102
|
"screenshot",
|
|
4690
5103
|
"zoom"
|
|
4691
5104
|
]),
|
|
4692
|
-
coordinate:
|
|
4693
|
-
duration:
|
|
4694
|
-
region:
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
5105
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5106
|
+
duration: z17.number().optional(),
|
|
5107
|
+
region: z17.tuple([
|
|
5108
|
+
z17.number().int(),
|
|
5109
|
+
z17.number().int(),
|
|
5110
|
+
z17.number().int(),
|
|
5111
|
+
z17.number().int()
|
|
4699
5112
|
]).optional(),
|
|
4700
|
-
scroll_amount:
|
|
4701
|
-
scroll_direction:
|
|
4702
|
-
start_coordinate:
|
|
4703
|
-
text:
|
|
5113
|
+
scroll_amount: z17.number().optional(),
|
|
5114
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5115
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5116
|
+
text: z17.string().optional()
|
|
4704
5117
|
})
|
|
4705
5118
|
)
|
|
4706
5119
|
);
|
|
4707
|
-
var computer_20251124 = (
|
|
5120
|
+
var computer_20251124 = createProviderDefinedToolFactory6({
|
|
4708
5121
|
id: "anthropic.computer_20251124",
|
|
4709
5122
|
inputSchema: computer_20251124InputSchema
|
|
4710
5123
|
});
|
|
4711
5124
|
|
|
4712
5125
|
// src/tool/memory_20250818.ts
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
5126
|
+
import {
|
|
5127
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
5128
|
+
lazySchema as lazySchema17,
|
|
5129
|
+
zodSchema as zodSchema17
|
|
5130
|
+
} from "@ai-sdk/provider-utils";
|
|
5131
|
+
import { z as z18 } from "zod/v4";
|
|
5132
|
+
var memory_20250818InputSchema = lazySchema17(
|
|
5133
|
+
() => zodSchema17(
|
|
5134
|
+
z18.discriminatedUnion("command", [
|
|
5135
|
+
z18.object({
|
|
5136
|
+
command: z18.literal("view"),
|
|
5137
|
+
path: z18.string(),
|
|
5138
|
+
view_range: z18.tuple([z18.number(), z18.number()]).optional()
|
|
4722
5139
|
}),
|
|
4723
|
-
|
|
4724
|
-
command:
|
|
4725
|
-
path:
|
|
4726
|
-
file_text:
|
|
5140
|
+
z18.object({
|
|
5141
|
+
command: z18.literal("create"),
|
|
5142
|
+
path: z18.string(),
|
|
5143
|
+
file_text: z18.string()
|
|
4727
5144
|
}),
|
|
4728
|
-
|
|
4729
|
-
command:
|
|
4730
|
-
path:
|
|
4731
|
-
old_str:
|
|
4732
|
-
new_str:
|
|
5145
|
+
z18.object({
|
|
5146
|
+
command: z18.literal("str_replace"),
|
|
5147
|
+
path: z18.string(),
|
|
5148
|
+
old_str: z18.string(),
|
|
5149
|
+
new_str: z18.string()
|
|
4733
5150
|
}),
|
|
4734
|
-
|
|
4735
|
-
command:
|
|
4736
|
-
path:
|
|
4737
|
-
insert_line:
|
|
4738
|
-
insert_text:
|
|
5151
|
+
z18.object({
|
|
5152
|
+
command: z18.literal("insert"),
|
|
5153
|
+
path: z18.string(),
|
|
5154
|
+
insert_line: z18.number(),
|
|
5155
|
+
insert_text: z18.string()
|
|
4739
5156
|
}),
|
|
4740
|
-
|
|
4741
|
-
command:
|
|
4742
|
-
path:
|
|
5157
|
+
z18.object({
|
|
5158
|
+
command: z18.literal("delete"),
|
|
5159
|
+
path: z18.string()
|
|
4743
5160
|
}),
|
|
4744
|
-
|
|
4745
|
-
command:
|
|
4746
|
-
old_path:
|
|
4747
|
-
new_path:
|
|
5161
|
+
z18.object({
|
|
5162
|
+
command: z18.literal("rename"),
|
|
5163
|
+
old_path: z18.string(),
|
|
5164
|
+
new_path: z18.string()
|
|
4748
5165
|
})
|
|
4749
5166
|
])
|
|
4750
5167
|
)
|
|
4751
5168
|
);
|
|
4752
|
-
var memory_20250818 = (
|
|
5169
|
+
var memory_20250818 = createProviderDefinedToolFactory7({
|
|
4753
5170
|
id: "anthropic.memory_20250818",
|
|
4754
5171
|
inputSchema: memory_20250818InputSchema
|
|
4755
5172
|
});
|
|
4756
5173
|
|
|
4757
5174
|
// src/tool/text-editor_20241022.ts
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
5175
|
+
import {
|
|
5176
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
5177
|
+
lazySchema as lazySchema18,
|
|
5178
|
+
zodSchema as zodSchema18
|
|
5179
|
+
} from "@ai-sdk/provider-utils";
|
|
5180
|
+
import { z as z19 } from "zod/v4";
|
|
5181
|
+
var textEditor_20241022InputSchema = lazySchema18(
|
|
5182
|
+
() => zodSchema18(
|
|
5183
|
+
z19.object({
|
|
5184
|
+
command: z19.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5185
|
+
path: z19.string(),
|
|
5186
|
+
file_text: z19.string().optional(),
|
|
5187
|
+
insert_line: z19.number().int().optional(),
|
|
5188
|
+
new_str: z19.string().optional(),
|
|
5189
|
+
insert_text: z19.string().optional(),
|
|
5190
|
+
old_str: z19.string().optional(),
|
|
5191
|
+
view_range: z19.array(z19.number().int()).optional()
|
|
4771
5192
|
})
|
|
4772
5193
|
)
|
|
4773
5194
|
);
|
|
4774
|
-
var textEditor_20241022 = (
|
|
5195
|
+
var textEditor_20241022 = createProviderDefinedToolFactory8({
|
|
4775
5196
|
id: "anthropic.text_editor_20241022",
|
|
4776
5197
|
inputSchema: textEditor_20241022InputSchema
|
|
4777
5198
|
});
|
|
4778
5199
|
|
|
4779
5200
|
// src/tool/text-editor_20250124.ts
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
5201
|
+
import {
|
|
5202
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
5203
|
+
lazySchema as lazySchema19,
|
|
5204
|
+
zodSchema as zodSchema19
|
|
5205
|
+
} from "@ai-sdk/provider-utils";
|
|
5206
|
+
import { z as z20 } from "zod/v4";
|
|
5207
|
+
var textEditor_20250124InputSchema = lazySchema19(
|
|
5208
|
+
() => zodSchema19(
|
|
5209
|
+
z20.object({
|
|
5210
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5211
|
+
path: z20.string(),
|
|
5212
|
+
file_text: z20.string().optional(),
|
|
5213
|
+
insert_line: z20.number().int().optional(),
|
|
5214
|
+
new_str: z20.string().optional(),
|
|
5215
|
+
insert_text: z20.string().optional(),
|
|
5216
|
+
old_str: z20.string().optional(),
|
|
5217
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4793
5218
|
})
|
|
4794
5219
|
)
|
|
4795
5220
|
);
|
|
4796
|
-
var textEditor_20250124 = (
|
|
5221
|
+
var textEditor_20250124 = createProviderDefinedToolFactory9({
|
|
4797
5222
|
id: "anthropic.text_editor_20250124",
|
|
4798
5223
|
inputSchema: textEditor_20250124InputSchema
|
|
4799
5224
|
});
|
|
4800
5225
|
|
|
4801
5226
|
// src/tool/text-editor_20250429.ts
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
5227
|
+
import {
|
|
5228
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
|
|
5229
|
+
lazySchema as lazySchema20,
|
|
5230
|
+
zodSchema as zodSchema20
|
|
5231
|
+
} from "@ai-sdk/provider-utils";
|
|
5232
|
+
import { z as z21 } from "zod/v4";
|
|
5233
|
+
var textEditor_20250429InputSchema = lazySchema20(
|
|
5234
|
+
() => zodSchema20(
|
|
5235
|
+
z21.object({
|
|
5236
|
+
command: z21.enum(["view", "create", "str_replace", "insert"]),
|
|
5237
|
+
path: z21.string(),
|
|
5238
|
+
file_text: z21.string().optional(),
|
|
5239
|
+
insert_line: z21.number().int().optional(),
|
|
5240
|
+
new_str: z21.string().optional(),
|
|
5241
|
+
insert_text: z21.string().optional(),
|
|
5242
|
+
old_str: z21.string().optional(),
|
|
5243
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4815
5244
|
})
|
|
4816
5245
|
)
|
|
4817
5246
|
);
|
|
4818
|
-
var textEditor_20250429 = (
|
|
5247
|
+
var textEditor_20250429 = createProviderDefinedToolFactory10({
|
|
4819
5248
|
id: "anthropic.text_editor_20250429",
|
|
4820
5249
|
inputSchema: textEditor_20250429InputSchema
|
|
4821
5250
|
});
|
|
4822
5251
|
|
|
4823
5252
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
5253
|
+
import {
|
|
5254
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
|
|
5255
|
+
lazySchema as lazySchema21,
|
|
5256
|
+
zodSchema as zodSchema21
|
|
5257
|
+
} from "@ai-sdk/provider-utils";
|
|
5258
|
+
import { z as z22 } from "zod/v4";
|
|
5259
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema21(
|
|
5260
|
+
() => zodSchema21(
|
|
5261
|
+
z22.array(
|
|
5262
|
+
z22.object({
|
|
5263
|
+
type: z22.literal("tool_reference"),
|
|
5264
|
+
toolName: z22.string()
|
|
4832
5265
|
})
|
|
4833
5266
|
)
|
|
4834
5267
|
)
|
|
4835
5268
|
);
|
|
4836
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4837
|
-
() => (
|
|
4838
|
-
|
|
5269
|
+
var toolSearchBm25_20251119InputSchema = lazySchema21(
|
|
5270
|
+
() => zodSchema21(
|
|
5271
|
+
z22.object({
|
|
4839
5272
|
/**
|
|
4840
5273
|
* A natural language query to search for tools.
|
|
4841
5274
|
* Claude will use BM25 text search to find relevant tools.
|
|
4842
5275
|
*/
|
|
4843
|
-
query:
|
|
5276
|
+
query: z22.string(),
|
|
4844
5277
|
/**
|
|
4845
5278
|
* Maximum number of tools to return. Optional.
|
|
4846
5279
|
*/
|
|
4847
|
-
limit:
|
|
5280
|
+
limit: z22.number().optional()
|
|
4848
5281
|
})
|
|
4849
5282
|
)
|
|
4850
5283
|
);
|
|
4851
|
-
var factory10 = (
|
|
5284
|
+
var factory10 = createProviderExecutedToolFactory9({
|
|
4852
5285
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4853
5286
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4854
5287
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5059,10 +5492,11 @@ var anthropicTools = {
|
|
|
5059
5492
|
*/
|
|
5060
5493
|
toolSearchBm25_20251119
|
|
5061
5494
|
};
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
AnthropicMessagesLanguageModel,
|
|
5495
|
+
export {
|
|
5496
|
+
AnthropicLanguageModel,
|
|
5497
|
+
AnthropicLanguageModel as AnthropicMessagesLanguageModel,
|
|
5065
5498
|
anthropicTools,
|
|
5499
|
+
getModelCapabilities,
|
|
5066
5500
|
prepareTools
|
|
5067
|
-
}
|
|
5501
|
+
};
|
|
5068
5502
|
//# sourceMappingURL=index.js.map
|