@ai-sdk/anthropic 4.0.0-beta.4 → 4.0.0-beta.41
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 +305 -4
- package/README.md +2 -0
- package/dist/index.d.ts +83 -58
- package/dist/index.js +2043 -1356
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +85 -58
- package/dist/internal/index.js +1804 -1342
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +116 -13
- package/package.json +14 -15
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +14 -6
- package/src/anthropic-error.ts +1 -1
- package/src/anthropic-files.ts +95 -0
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +263 -78
- package/src/anthropic-message-metadata.ts +1 -4
- package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
- package/src/anthropic-prepare-tools.ts +14 -7
- package/src/anthropic-provider.ts +42 -13
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +190 -149
- package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
- package/src/get-cache-control.ts +5 -2
- package/src/index.ts +1 -1
- package/src/internal/index.ts +11 -2
- package/src/map-anthropic-stop-reason.ts +1 -1
- package/src/sanitize-json-schema.ts +203 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +132 -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 +6 -3
- 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,364 @@
|
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
46
|
+
// src/anthropic-api.ts
|
|
47
|
+
import {
|
|
48
|
+
lazySchema as lazySchema2,
|
|
49
|
+
zodSchema as zodSchema2
|
|
50
|
+
} from "@ai-sdk/provider-utils";
|
|
51
|
+
import { z as z2 } from "zod/v4";
|
|
52
|
+
var anthropicResponseSchema = lazySchema2(
|
|
53
|
+
() => zodSchema2(
|
|
54
|
+
z2.object({
|
|
55
|
+
type: z2.literal("message"),
|
|
56
|
+
id: z2.string().nullish(),
|
|
57
|
+
model: z2.string().nullish(),
|
|
58
|
+
content: z2.array(
|
|
59
|
+
z2.discriminatedUnion("type", [
|
|
60
|
+
z2.object({
|
|
61
|
+
type: z2.literal("text"),
|
|
62
|
+
text: z2.string(),
|
|
63
|
+
citations: z2.array(
|
|
64
|
+
z2.discriminatedUnion("type", [
|
|
65
|
+
z2.object({
|
|
66
|
+
type: z2.literal("web_search_result_location"),
|
|
67
|
+
cited_text: z2.string(),
|
|
68
|
+
url: z2.string(),
|
|
69
|
+
title: z2.string(),
|
|
70
|
+
encrypted_index: z2.string()
|
|
74
71
|
}),
|
|
75
|
-
|
|
76
|
-
type:
|
|
77
|
-
cited_text:
|
|
78
|
-
document_index:
|
|
79
|
-
document_title:
|
|
80
|
-
start_page_number:
|
|
81
|
-
end_page_number:
|
|
72
|
+
z2.object({
|
|
73
|
+
type: z2.literal("page_location"),
|
|
74
|
+
cited_text: z2.string(),
|
|
75
|
+
document_index: z2.number(),
|
|
76
|
+
document_title: z2.string().nullable(),
|
|
77
|
+
start_page_number: z2.number(),
|
|
78
|
+
end_page_number: z2.number()
|
|
82
79
|
}),
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
cited_text:
|
|
86
|
-
document_index:
|
|
87
|
-
document_title:
|
|
88
|
-
start_char_index:
|
|
89
|
-
end_char_index:
|
|
80
|
+
z2.object({
|
|
81
|
+
type: z2.literal("char_location"),
|
|
82
|
+
cited_text: z2.string(),
|
|
83
|
+
document_index: z2.number(),
|
|
84
|
+
document_title: z2.string().nullable(),
|
|
85
|
+
start_char_index: z2.number(),
|
|
86
|
+
end_char_index: z2.number()
|
|
90
87
|
})
|
|
91
88
|
])
|
|
92
89
|
).optional()
|
|
93
90
|
}),
|
|
94
|
-
|
|
95
|
-
type:
|
|
96
|
-
thinking:
|
|
97
|
-
signature:
|
|
91
|
+
z2.object({
|
|
92
|
+
type: z2.literal("thinking"),
|
|
93
|
+
thinking: z2.string(),
|
|
94
|
+
signature: z2.string()
|
|
98
95
|
}),
|
|
99
|
-
|
|
100
|
-
type:
|
|
101
|
-
data:
|
|
96
|
+
z2.object({
|
|
97
|
+
type: z2.literal("redacted_thinking"),
|
|
98
|
+
data: z2.string()
|
|
102
99
|
}),
|
|
103
|
-
|
|
104
|
-
type:
|
|
105
|
-
content:
|
|
100
|
+
z2.object({
|
|
101
|
+
type: z2.literal("compaction"),
|
|
102
|
+
content: z2.string()
|
|
106
103
|
}),
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
id:
|
|
110
|
-
name:
|
|
111
|
-
input:
|
|
104
|
+
z2.object({
|
|
105
|
+
type: z2.literal("tool_use"),
|
|
106
|
+
id: z2.string(),
|
|
107
|
+
name: z2.string(),
|
|
108
|
+
input: z2.unknown(),
|
|
112
109
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
113
|
-
caller:
|
|
114
|
-
|
|
115
|
-
type:
|
|
116
|
-
tool_id:
|
|
110
|
+
caller: z2.union([
|
|
111
|
+
z2.object({
|
|
112
|
+
type: z2.literal("code_execution_20250825"),
|
|
113
|
+
tool_id: z2.string()
|
|
117
114
|
}),
|
|
118
|
-
|
|
119
|
-
type:
|
|
120
|
-
tool_id:
|
|
115
|
+
z2.object({
|
|
116
|
+
type: z2.literal("code_execution_20260120"),
|
|
117
|
+
tool_id: z2.string()
|
|
121
118
|
}),
|
|
122
|
-
|
|
123
|
-
type:
|
|
119
|
+
z2.object({
|
|
120
|
+
type: z2.literal("direct")
|
|
124
121
|
})
|
|
125
122
|
]).optional()
|
|
126
123
|
}),
|
|
127
|
-
|
|
128
|
-
type:
|
|
129
|
-
id:
|
|
130
|
-
name:
|
|
131
|
-
input:
|
|
132
|
-
caller:
|
|
133
|
-
|
|
134
|
-
type:
|
|
135
|
-
tool_id:
|
|
124
|
+
z2.object({
|
|
125
|
+
type: z2.literal("server_tool_use"),
|
|
126
|
+
id: z2.string(),
|
|
127
|
+
name: z2.string(),
|
|
128
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
129
|
+
caller: z2.union([
|
|
130
|
+
z2.object({
|
|
131
|
+
type: z2.literal("code_execution_20260120"),
|
|
132
|
+
tool_id: z2.string()
|
|
136
133
|
}),
|
|
137
|
-
|
|
138
|
-
type:
|
|
134
|
+
z2.object({
|
|
135
|
+
type: z2.literal("direct")
|
|
139
136
|
})
|
|
140
137
|
]).optional()
|
|
141
138
|
}),
|
|
142
|
-
|
|
143
|
-
type:
|
|
144
|
-
id:
|
|
145
|
-
name:
|
|
146
|
-
input:
|
|
147
|
-
server_name:
|
|
139
|
+
z2.object({
|
|
140
|
+
type: z2.literal("mcp_tool_use"),
|
|
141
|
+
id: z2.string(),
|
|
142
|
+
name: z2.string(),
|
|
143
|
+
input: z2.unknown(),
|
|
144
|
+
server_name: z2.string()
|
|
148
145
|
}),
|
|
149
|
-
|
|
150
|
-
type:
|
|
151
|
-
tool_use_id:
|
|
152
|
-
is_error:
|
|
153
|
-
content:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
146
|
+
z2.object({
|
|
147
|
+
type: z2.literal("mcp_tool_result"),
|
|
148
|
+
tool_use_id: z2.string(),
|
|
149
|
+
is_error: z2.boolean(),
|
|
150
|
+
content: z2.array(
|
|
151
|
+
z2.union([
|
|
152
|
+
z2.string(),
|
|
153
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
157
154
|
])
|
|
158
155
|
)
|
|
159
156
|
}),
|
|
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:
|
|
157
|
+
z2.object({
|
|
158
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
159
|
+
tool_use_id: z2.string(),
|
|
160
|
+
content: z2.union([
|
|
161
|
+
z2.object({
|
|
162
|
+
type: z2.literal("web_fetch_result"),
|
|
163
|
+
url: z2.string(),
|
|
164
|
+
retrieved_at: z2.string(),
|
|
165
|
+
content: z2.object({
|
|
166
|
+
type: z2.literal("document"),
|
|
167
|
+
title: z2.string().nullable(),
|
|
168
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
169
|
+
source: z2.union([
|
|
170
|
+
z2.object({
|
|
171
|
+
type: z2.literal("base64"),
|
|
172
|
+
media_type: z2.literal("application/pdf"),
|
|
173
|
+
data: z2.string()
|
|
177
174
|
}),
|
|
178
|
-
|
|
179
|
-
type:
|
|
180
|
-
media_type:
|
|
181
|
-
data:
|
|
175
|
+
z2.object({
|
|
176
|
+
type: z2.literal("text"),
|
|
177
|
+
media_type: z2.literal("text/plain"),
|
|
178
|
+
data: z2.string()
|
|
182
179
|
})
|
|
183
180
|
])
|
|
184
181
|
})
|
|
185
182
|
}),
|
|
186
|
-
|
|
187
|
-
type:
|
|
188
|
-
error_code:
|
|
183
|
+
z2.object({
|
|
184
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
185
|
+
error_code: z2.string()
|
|
189
186
|
})
|
|
190
187
|
])
|
|
191
188
|
}),
|
|
192
|
-
|
|
193
|
-
type:
|
|
194
|
-
tool_use_id:
|
|
195
|
-
content:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
type:
|
|
199
|
-
url:
|
|
200
|
-
title:
|
|
201
|
-
encrypted_content:
|
|
202
|
-
page_age:
|
|
189
|
+
z2.object({
|
|
190
|
+
type: z2.literal("web_search_tool_result"),
|
|
191
|
+
tool_use_id: z2.string(),
|
|
192
|
+
content: z2.union([
|
|
193
|
+
z2.array(
|
|
194
|
+
z2.object({
|
|
195
|
+
type: z2.literal("web_search_result"),
|
|
196
|
+
url: z2.string(),
|
|
197
|
+
title: z2.string(),
|
|
198
|
+
encrypted_content: z2.string(),
|
|
199
|
+
page_age: z2.string().nullish()
|
|
203
200
|
})
|
|
204
201
|
),
|
|
205
|
-
|
|
206
|
-
type:
|
|
207
|
-
error_code:
|
|
202
|
+
z2.object({
|
|
203
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
204
|
+
error_code: z2.string()
|
|
208
205
|
})
|
|
209
206
|
])
|
|
210
207
|
}),
|
|
211
208
|
// 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:
|
|
209
|
+
z2.object({
|
|
210
|
+
type: z2.literal("code_execution_tool_result"),
|
|
211
|
+
tool_use_id: z2.string(),
|
|
212
|
+
content: z2.union([
|
|
213
|
+
z2.object({
|
|
214
|
+
type: z2.literal("code_execution_result"),
|
|
215
|
+
stdout: z2.string(),
|
|
216
|
+
stderr: z2.string(),
|
|
217
|
+
return_code: z2.number(),
|
|
218
|
+
content: z2.array(
|
|
219
|
+
z2.object({
|
|
220
|
+
type: z2.literal("code_execution_output"),
|
|
221
|
+
file_id: z2.string()
|
|
225
222
|
})
|
|
226
223
|
).optional().default([])
|
|
227
224
|
}),
|
|
228
|
-
|
|
229
|
-
type:
|
|
230
|
-
encrypted_stdout:
|
|
231
|
-
stderr:
|
|
232
|
-
return_code:
|
|
233
|
-
content:
|
|
234
|
-
|
|
235
|
-
type:
|
|
236
|
-
file_id:
|
|
225
|
+
z2.object({
|
|
226
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
227
|
+
encrypted_stdout: z2.string(),
|
|
228
|
+
stderr: z2.string(),
|
|
229
|
+
return_code: z2.number(),
|
|
230
|
+
content: z2.array(
|
|
231
|
+
z2.object({
|
|
232
|
+
type: z2.literal("code_execution_output"),
|
|
233
|
+
file_id: z2.string()
|
|
237
234
|
})
|
|
238
235
|
).optional().default([])
|
|
239
236
|
}),
|
|
240
|
-
|
|
241
|
-
type:
|
|
242
|
-
error_code:
|
|
237
|
+
z2.object({
|
|
238
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
239
|
+
error_code: z2.string()
|
|
243
240
|
})
|
|
244
241
|
])
|
|
245
242
|
}),
|
|
246
243
|
// 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:
|
|
244
|
+
z2.object({
|
|
245
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
246
|
+
tool_use_id: z2.string(),
|
|
247
|
+
content: z2.discriminatedUnion("type", [
|
|
248
|
+
z2.object({
|
|
249
|
+
type: z2.literal("bash_code_execution_result"),
|
|
250
|
+
content: z2.array(
|
|
251
|
+
z2.object({
|
|
252
|
+
type: z2.literal("bash_code_execution_output"),
|
|
253
|
+
file_id: z2.string()
|
|
257
254
|
})
|
|
258
255
|
),
|
|
259
|
-
stdout:
|
|
260
|
-
stderr:
|
|
261
|
-
return_code:
|
|
256
|
+
stdout: z2.string(),
|
|
257
|
+
stderr: z2.string(),
|
|
258
|
+
return_code: z2.number()
|
|
262
259
|
}),
|
|
263
|
-
|
|
264
|
-
type:
|
|
265
|
-
error_code:
|
|
260
|
+
z2.object({
|
|
261
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
262
|
+
error_code: z2.string()
|
|
266
263
|
})
|
|
267
264
|
])
|
|
268
265
|
}),
|
|
269
266
|
// 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:
|
|
267
|
+
z2.object({
|
|
268
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
269
|
+
tool_use_id: z2.string(),
|
|
270
|
+
content: z2.discriminatedUnion("type", [
|
|
271
|
+
z2.object({
|
|
272
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
273
|
+
error_code: z2.string()
|
|
277
274
|
}),
|
|
278
|
-
|
|
279
|
-
type:
|
|
280
|
-
content:
|
|
281
|
-
file_type:
|
|
282
|
-
num_lines:
|
|
283
|
-
start_line:
|
|
284
|
-
total_lines:
|
|
275
|
+
z2.object({
|
|
276
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
277
|
+
content: z2.string(),
|
|
278
|
+
file_type: z2.string(),
|
|
279
|
+
num_lines: z2.number().nullable(),
|
|
280
|
+
start_line: z2.number().nullable(),
|
|
281
|
+
total_lines: z2.number().nullable()
|
|
285
282
|
}),
|
|
286
|
-
|
|
287
|
-
type:
|
|
288
|
-
is_file_update:
|
|
283
|
+
z2.object({
|
|
284
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
285
|
+
is_file_update: z2.boolean()
|
|
289
286
|
}),
|
|
290
|
-
|
|
291
|
-
type:
|
|
287
|
+
z2.object({
|
|
288
|
+
type: z2.literal(
|
|
292
289
|
"text_editor_code_execution_str_replace_result"
|
|
293
290
|
),
|
|
294
|
-
lines:
|
|
295
|
-
new_lines:
|
|
296
|
-
new_start:
|
|
297
|
-
old_lines:
|
|
298
|
-
old_start:
|
|
291
|
+
lines: z2.array(z2.string()).nullable(),
|
|
292
|
+
new_lines: z2.number().nullable(),
|
|
293
|
+
new_start: z2.number().nullable(),
|
|
294
|
+
old_lines: z2.number().nullable(),
|
|
295
|
+
old_start: z2.number().nullable()
|
|
299
296
|
})
|
|
300
297
|
])
|
|
301
298
|
}),
|
|
302
299
|
// 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:
|
|
300
|
+
z2.object({
|
|
301
|
+
type: z2.literal("tool_search_tool_result"),
|
|
302
|
+
tool_use_id: z2.string(),
|
|
303
|
+
content: z2.union([
|
|
304
|
+
z2.object({
|
|
305
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
306
|
+
tool_references: z2.array(
|
|
307
|
+
z2.object({
|
|
308
|
+
type: z2.literal("tool_reference"),
|
|
309
|
+
tool_name: z2.string()
|
|
313
310
|
})
|
|
314
311
|
)
|
|
315
312
|
}),
|
|
316
|
-
|
|
317
|
-
type:
|
|
318
|
-
error_code:
|
|
313
|
+
z2.object({
|
|
314
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
315
|
+
error_code: z2.string()
|
|
319
316
|
})
|
|
320
317
|
])
|
|
321
318
|
})
|
|
322
319
|
])
|
|
323
320
|
),
|
|
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:
|
|
321
|
+
stop_reason: z2.string().nullish(),
|
|
322
|
+
stop_sequence: z2.string().nullish(),
|
|
323
|
+
usage: z2.looseObject({
|
|
324
|
+
input_tokens: z2.number(),
|
|
325
|
+
output_tokens: z2.number(),
|
|
326
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
327
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
328
|
+
iterations: z2.array(
|
|
329
|
+
z2.object({
|
|
330
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
331
|
+
input_tokens: z2.number(),
|
|
332
|
+
output_tokens: z2.number()
|
|
336
333
|
})
|
|
337
334
|
).nullish()
|
|
338
335
|
}),
|
|
339
|
-
container:
|
|
340
|
-
expires_at:
|
|
341
|
-
id:
|
|
342
|
-
skills:
|
|
343
|
-
|
|
344
|
-
type:
|
|
345
|
-
skill_id:
|
|
346
|
-
version:
|
|
336
|
+
container: z2.object({
|
|
337
|
+
expires_at: z2.string(),
|
|
338
|
+
id: z2.string(),
|
|
339
|
+
skills: z2.array(
|
|
340
|
+
z2.object({
|
|
341
|
+
type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
|
|
342
|
+
skill_id: z2.string(),
|
|
343
|
+
version: z2.string()
|
|
347
344
|
})
|
|
348
345
|
).nullish()
|
|
349
346
|
}).nullish(),
|
|
350
|
-
context_management:
|
|
351
|
-
applied_edits:
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
type:
|
|
355
|
-
cleared_tool_uses:
|
|
356
|
-
cleared_input_tokens:
|
|
347
|
+
context_management: z2.object({
|
|
348
|
+
applied_edits: z2.array(
|
|
349
|
+
z2.union([
|
|
350
|
+
z2.object({
|
|
351
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
352
|
+
cleared_tool_uses: z2.number(),
|
|
353
|
+
cleared_input_tokens: z2.number()
|
|
357
354
|
}),
|
|
358
|
-
|
|
359
|
-
type:
|
|
360
|
-
cleared_thinking_turns:
|
|
361
|
-
cleared_input_tokens:
|
|
355
|
+
z2.object({
|
|
356
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
357
|
+
cleared_thinking_turns: z2.number(),
|
|
358
|
+
cleared_input_tokens: z2.number()
|
|
362
359
|
}),
|
|
363
|
-
|
|
364
|
-
type:
|
|
360
|
+
z2.object({
|
|
361
|
+
type: z2.literal("compact_20260112")
|
|
365
362
|
})
|
|
366
363
|
])
|
|
367
364
|
)
|
|
@@ -369,457 +366,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
369
366
|
})
|
|
370
367
|
)
|
|
371
368
|
);
|
|
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:
|
|
369
|
+
var anthropicChunkSchema = lazySchema2(
|
|
370
|
+
() => zodSchema2(
|
|
371
|
+
z2.discriminatedUnion("type", [
|
|
372
|
+
z2.object({
|
|
373
|
+
type: z2.literal("message_start"),
|
|
374
|
+
message: z2.object({
|
|
375
|
+
id: z2.string().nullish(),
|
|
376
|
+
model: z2.string().nullish(),
|
|
377
|
+
role: z2.string().nullish(),
|
|
378
|
+
usage: z2.looseObject({
|
|
379
|
+
input_tokens: z2.number(),
|
|
380
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
381
|
+
cache_read_input_tokens: z2.number().nullish()
|
|
385
382
|
}),
|
|
386
383
|
// 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:
|
|
384
|
+
content: z2.array(
|
|
385
|
+
z2.discriminatedUnion("type", [
|
|
386
|
+
z2.object({
|
|
387
|
+
type: z2.literal("tool_use"),
|
|
388
|
+
id: z2.string(),
|
|
389
|
+
name: z2.string(),
|
|
390
|
+
input: z2.unknown(),
|
|
391
|
+
caller: z2.union([
|
|
392
|
+
z2.object({
|
|
393
|
+
type: z2.literal("code_execution_20250825"),
|
|
394
|
+
tool_id: z2.string()
|
|
398
395
|
}),
|
|
399
|
-
|
|
400
|
-
type:
|
|
401
|
-
tool_id:
|
|
396
|
+
z2.object({
|
|
397
|
+
type: z2.literal("code_execution_20260120"),
|
|
398
|
+
tool_id: z2.string()
|
|
402
399
|
}),
|
|
403
|
-
|
|
404
|
-
type:
|
|
400
|
+
z2.object({
|
|
401
|
+
type: z2.literal("direct")
|
|
405
402
|
})
|
|
406
403
|
]).optional()
|
|
407
404
|
})
|
|
408
405
|
])
|
|
409
406
|
).nullish(),
|
|
410
|
-
stop_reason:
|
|
411
|
-
container:
|
|
412
|
-
expires_at:
|
|
413
|
-
id:
|
|
407
|
+
stop_reason: z2.string().nullish(),
|
|
408
|
+
container: z2.object({
|
|
409
|
+
expires_at: z2.string(),
|
|
410
|
+
id: z2.string()
|
|
414
411
|
}).nullish()
|
|
415
412
|
})
|
|
416
413
|
}),
|
|
417
|
-
|
|
418
|
-
type:
|
|
419
|
-
index:
|
|
420
|
-
content_block:
|
|
421
|
-
|
|
422
|
-
type:
|
|
423
|
-
text:
|
|
414
|
+
z2.object({
|
|
415
|
+
type: z2.literal("content_block_start"),
|
|
416
|
+
index: z2.number(),
|
|
417
|
+
content_block: z2.discriminatedUnion("type", [
|
|
418
|
+
z2.object({
|
|
419
|
+
type: z2.literal("text"),
|
|
420
|
+
text: z2.string()
|
|
424
421
|
}),
|
|
425
|
-
|
|
426
|
-
type:
|
|
427
|
-
thinking:
|
|
422
|
+
z2.object({
|
|
423
|
+
type: z2.literal("thinking"),
|
|
424
|
+
thinking: z2.string()
|
|
428
425
|
}),
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
id:
|
|
432
|
-
name:
|
|
426
|
+
z2.object({
|
|
427
|
+
type: z2.literal("tool_use"),
|
|
428
|
+
id: z2.string(),
|
|
429
|
+
name: z2.string(),
|
|
433
430
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
434
|
-
input:
|
|
431
|
+
input: z2.record(z2.string(), z2.unknown()).optional(),
|
|
435
432
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
436
|
-
caller:
|
|
437
|
-
|
|
438
|
-
type:
|
|
439
|
-
tool_id:
|
|
433
|
+
caller: z2.union([
|
|
434
|
+
z2.object({
|
|
435
|
+
type: z2.literal("code_execution_20250825"),
|
|
436
|
+
tool_id: z2.string()
|
|
440
437
|
}),
|
|
441
|
-
|
|
442
|
-
type:
|
|
443
|
-
tool_id:
|
|
438
|
+
z2.object({
|
|
439
|
+
type: z2.literal("code_execution_20260120"),
|
|
440
|
+
tool_id: z2.string()
|
|
444
441
|
}),
|
|
445
|
-
|
|
446
|
-
type:
|
|
442
|
+
z2.object({
|
|
443
|
+
type: z2.literal("direct")
|
|
447
444
|
})
|
|
448
445
|
]).optional()
|
|
449
446
|
}),
|
|
450
|
-
|
|
451
|
-
type:
|
|
452
|
-
data:
|
|
447
|
+
z2.object({
|
|
448
|
+
type: z2.literal("redacted_thinking"),
|
|
449
|
+
data: z2.string()
|
|
453
450
|
}),
|
|
454
|
-
|
|
455
|
-
type:
|
|
456
|
-
content:
|
|
451
|
+
z2.object({
|
|
452
|
+
type: z2.literal("compaction"),
|
|
453
|
+
content: z2.string().nullish()
|
|
457
454
|
}),
|
|
458
|
-
|
|
459
|
-
type:
|
|
460
|
-
id:
|
|
461
|
-
name:
|
|
462
|
-
input:
|
|
463
|
-
caller:
|
|
464
|
-
|
|
465
|
-
type:
|
|
466
|
-
tool_id:
|
|
455
|
+
z2.object({
|
|
456
|
+
type: z2.literal("server_tool_use"),
|
|
457
|
+
id: z2.string(),
|
|
458
|
+
name: z2.string(),
|
|
459
|
+
input: z2.record(z2.string(), z2.unknown()).nullish(),
|
|
460
|
+
caller: z2.union([
|
|
461
|
+
z2.object({
|
|
462
|
+
type: z2.literal("code_execution_20260120"),
|
|
463
|
+
tool_id: z2.string()
|
|
467
464
|
}),
|
|
468
|
-
|
|
469
|
-
type:
|
|
465
|
+
z2.object({
|
|
466
|
+
type: z2.literal("direct")
|
|
470
467
|
})
|
|
471
468
|
]).optional()
|
|
472
469
|
}),
|
|
473
|
-
|
|
474
|
-
type:
|
|
475
|
-
id:
|
|
476
|
-
name:
|
|
477
|
-
input:
|
|
478
|
-
server_name:
|
|
470
|
+
z2.object({
|
|
471
|
+
type: z2.literal("mcp_tool_use"),
|
|
472
|
+
id: z2.string(),
|
|
473
|
+
name: z2.string(),
|
|
474
|
+
input: z2.unknown(),
|
|
475
|
+
server_name: z2.string()
|
|
479
476
|
}),
|
|
480
|
-
|
|
481
|
-
type:
|
|
482
|
-
tool_use_id:
|
|
483
|
-
is_error:
|
|
484
|
-
content:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
477
|
+
z2.object({
|
|
478
|
+
type: z2.literal("mcp_tool_result"),
|
|
479
|
+
tool_use_id: z2.string(),
|
|
480
|
+
is_error: z2.boolean(),
|
|
481
|
+
content: z2.array(
|
|
482
|
+
z2.union([
|
|
483
|
+
z2.string(),
|
|
484
|
+
z2.object({ type: z2.literal("text"), text: z2.string() })
|
|
488
485
|
])
|
|
489
486
|
)
|
|
490
487
|
}),
|
|
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:
|
|
488
|
+
z2.object({
|
|
489
|
+
type: z2.literal("web_fetch_tool_result"),
|
|
490
|
+
tool_use_id: z2.string(),
|
|
491
|
+
content: z2.union([
|
|
492
|
+
z2.object({
|
|
493
|
+
type: z2.literal("web_fetch_result"),
|
|
494
|
+
url: z2.string(),
|
|
495
|
+
retrieved_at: z2.string(),
|
|
496
|
+
content: z2.object({
|
|
497
|
+
type: z2.literal("document"),
|
|
498
|
+
title: z2.string().nullable(),
|
|
499
|
+
citations: z2.object({ enabled: z2.boolean() }).optional(),
|
|
500
|
+
source: z2.union([
|
|
501
|
+
z2.object({
|
|
502
|
+
type: z2.literal("base64"),
|
|
503
|
+
media_type: z2.literal("application/pdf"),
|
|
504
|
+
data: z2.string()
|
|
508
505
|
}),
|
|
509
|
-
|
|
510
|
-
type:
|
|
511
|
-
media_type:
|
|
512
|
-
data:
|
|
506
|
+
z2.object({
|
|
507
|
+
type: z2.literal("text"),
|
|
508
|
+
media_type: z2.literal("text/plain"),
|
|
509
|
+
data: z2.string()
|
|
513
510
|
})
|
|
514
511
|
])
|
|
515
512
|
})
|
|
516
513
|
}),
|
|
517
|
-
|
|
518
|
-
type:
|
|
519
|
-
error_code:
|
|
514
|
+
z2.object({
|
|
515
|
+
type: z2.literal("web_fetch_tool_result_error"),
|
|
516
|
+
error_code: z2.string()
|
|
520
517
|
})
|
|
521
518
|
])
|
|
522
519
|
}),
|
|
523
|
-
|
|
524
|
-
type:
|
|
525
|
-
tool_use_id:
|
|
526
|
-
content:
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
type:
|
|
530
|
-
url:
|
|
531
|
-
title:
|
|
532
|
-
encrypted_content:
|
|
533
|
-
page_age:
|
|
520
|
+
z2.object({
|
|
521
|
+
type: z2.literal("web_search_tool_result"),
|
|
522
|
+
tool_use_id: z2.string(),
|
|
523
|
+
content: z2.union([
|
|
524
|
+
z2.array(
|
|
525
|
+
z2.object({
|
|
526
|
+
type: z2.literal("web_search_result"),
|
|
527
|
+
url: z2.string(),
|
|
528
|
+
title: z2.string(),
|
|
529
|
+
encrypted_content: z2.string(),
|
|
530
|
+
page_age: z2.string().nullish()
|
|
534
531
|
})
|
|
535
532
|
),
|
|
536
|
-
|
|
537
|
-
type:
|
|
538
|
-
error_code:
|
|
533
|
+
z2.object({
|
|
534
|
+
type: z2.literal("web_search_tool_result_error"),
|
|
535
|
+
error_code: z2.string()
|
|
539
536
|
})
|
|
540
537
|
])
|
|
541
538
|
}),
|
|
542
539
|
// 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:
|
|
540
|
+
z2.object({
|
|
541
|
+
type: z2.literal("code_execution_tool_result"),
|
|
542
|
+
tool_use_id: z2.string(),
|
|
543
|
+
content: z2.union([
|
|
544
|
+
z2.object({
|
|
545
|
+
type: z2.literal("code_execution_result"),
|
|
546
|
+
stdout: z2.string(),
|
|
547
|
+
stderr: z2.string(),
|
|
548
|
+
return_code: z2.number(),
|
|
549
|
+
content: z2.array(
|
|
550
|
+
z2.object({
|
|
551
|
+
type: z2.literal("code_execution_output"),
|
|
552
|
+
file_id: z2.string()
|
|
556
553
|
})
|
|
557
554
|
).optional().default([])
|
|
558
555
|
}),
|
|
559
|
-
|
|
560
|
-
type:
|
|
561
|
-
encrypted_stdout:
|
|
562
|
-
stderr:
|
|
563
|
-
return_code:
|
|
564
|
-
content:
|
|
565
|
-
|
|
566
|
-
type:
|
|
567
|
-
file_id:
|
|
556
|
+
z2.object({
|
|
557
|
+
type: z2.literal("encrypted_code_execution_result"),
|
|
558
|
+
encrypted_stdout: z2.string(),
|
|
559
|
+
stderr: z2.string(),
|
|
560
|
+
return_code: z2.number(),
|
|
561
|
+
content: z2.array(
|
|
562
|
+
z2.object({
|
|
563
|
+
type: z2.literal("code_execution_output"),
|
|
564
|
+
file_id: z2.string()
|
|
568
565
|
})
|
|
569
566
|
).optional().default([])
|
|
570
567
|
}),
|
|
571
|
-
|
|
572
|
-
type:
|
|
573
|
-
error_code:
|
|
568
|
+
z2.object({
|
|
569
|
+
type: z2.literal("code_execution_tool_result_error"),
|
|
570
|
+
error_code: z2.string()
|
|
574
571
|
})
|
|
575
572
|
])
|
|
576
573
|
}),
|
|
577
574
|
// 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:
|
|
575
|
+
z2.object({
|
|
576
|
+
type: z2.literal("bash_code_execution_tool_result"),
|
|
577
|
+
tool_use_id: z2.string(),
|
|
578
|
+
content: z2.discriminatedUnion("type", [
|
|
579
|
+
z2.object({
|
|
580
|
+
type: z2.literal("bash_code_execution_result"),
|
|
581
|
+
content: z2.array(
|
|
582
|
+
z2.object({
|
|
583
|
+
type: z2.literal("bash_code_execution_output"),
|
|
584
|
+
file_id: z2.string()
|
|
588
585
|
})
|
|
589
586
|
),
|
|
590
|
-
stdout:
|
|
591
|
-
stderr:
|
|
592
|
-
return_code:
|
|
587
|
+
stdout: z2.string(),
|
|
588
|
+
stderr: z2.string(),
|
|
589
|
+
return_code: z2.number()
|
|
593
590
|
}),
|
|
594
|
-
|
|
595
|
-
type:
|
|
596
|
-
error_code:
|
|
591
|
+
z2.object({
|
|
592
|
+
type: z2.literal("bash_code_execution_tool_result_error"),
|
|
593
|
+
error_code: z2.string()
|
|
597
594
|
})
|
|
598
595
|
])
|
|
599
596
|
}),
|
|
600
597
|
// 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:
|
|
598
|
+
z2.object({
|
|
599
|
+
type: z2.literal("text_editor_code_execution_tool_result"),
|
|
600
|
+
tool_use_id: z2.string(),
|
|
601
|
+
content: z2.discriminatedUnion("type", [
|
|
602
|
+
z2.object({
|
|
603
|
+
type: z2.literal("text_editor_code_execution_tool_result_error"),
|
|
604
|
+
error_code: z2.string()
|
|
608
605
|
}),
|
|
609
|
-
|
|
610
|
-
type:
|
|
611
|
-
content:
|
|
612
|
-
file_type:
|
|
613
|
-
num_lines:
|
|
614
|
-
start_line:
|
|
615
|
-
total_lines:
|
|
606
|
+
z2.object({
|
|
607
|
+
type: z2.literal("text_editor_code_execution_view_result"),
|
|
608
|
+
content: z2.string(),
|
|
609
|
+
file_type: z2.string(),
|
|
610
|
+
num_lines: z2.number().nullable(),
|
|
611
|
+
start_line: z2.number().nullable(),
|
|
612
|
+
total_lines: z2.number().nullable()
|
|
616
613
|
}),
|
|
617
|
-
|
|
618
|
-
type:
|
|
619
|
-
is_file_update:
|
|
614
|
+
z2.object({
|
|
615
|
+
type: z2.literal("text_editor_code_execution_create_result"),
|
|
616
|
+
is_file_update: z2.boolean()
|
|
620
617
|
}),
|
|
621
|
-
|
|
622
|
-
type:
|
|
618
|
+
z2.object({
|
|
619
|
+
type: z2.literal(
|
|
623
620
|
"text_editor_code_execution_str_replace_result"
|
|
624
621
|
),
|
|
625
|
-
lines:
|
|
626
|
-
new_lines:
|
|
627
|
-
new_start:
|
|
628
|
-
old_lines:
|
|
629
|
-
old_start:
|
|
622
|
+
lines: z2.array(z2.string()).nullable(),
|
|
623
|
+
new_lines: z2.number().nullable(),
|
|
624
|
+
new_start: z2.number().nullable(),
|
|
625
|
+
old_lines: z2.number().nullable(),
|
|
626
|
+
old_start: z2.number().nullable()
|
|
630
627
|
})
|
|
631
628
|
])
|
|
632
629
|
}),
|
|
633
630
|
// 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:
|
|
631
|
+
z2.object({
|
|
632
|
+
type: z2.literal("tool_search_tool_result"),
|
|
633
|
+
tool_use_id: z2.string(),
|
|
634
|
+
content: z2.union([
|
|
635
|
+
z2.object({
|
|
636
|
+
type: z2.literal("tool_search_tool_search_result"),
|
|
637
|
+
tool_references: z2.array(
|
|
638
|
+
z2.object({
|
|
639
|
+
type: z2.literal("tool_reference"),
|
|
640
|
+
tool_name: z2.string()
|
|
644
641
|
})
|
|
645
642
|
)
|
|
646
643
|
}),
|
|
647
|
-
|
|
648
|
-
type:
|
|
649
|
-
error_code:
|
|
644
|
+
z2.object({
|
|
645
|
+
type: z2.literal("tool_search_tool_result_error"),
|
|
646
|
+
error_code: z2.string()
|
|
650
647
|
})
|
|
651
648
|
])
|
|
652
649
|
})
|
|
653
650
|
])
|
|
654
651
|
}),
|
|
655
|
-
|
|
656
|
-
type:
|
|
657
|
-
index:
|
|
658
|
-
delta:
|
|
659
|
-
|
|
660
|
-
type:
|
|
661
|
-
partial_json:
|
|
652
|
+
z2.object({
|
|
653
|
+
type: z2.literal("content_block_delta"),
|
|
654
|
+
index: z2.number(),
|
|
655
|
+
delta: z2.discriminatedUnion("type", [
|
|
656
|
+
z2.object({
|
|
657
|
+
type: z2.literal("input_json_delta"),
|
|
658
|
+
partial_json: z2.string()
|
|
662
659
|
}),
|
|
663
|
-
|
|
664
|
-
type:
|
|
665
|
-
text:
|
|
660
|
+
z2.object({
|
|
661
|
+
type: z2.literal("text_delta"),
|
|
662
|
+
text: z2.string()
|
|
666
663
|
}),
|
|
667
|
-
|
|
668
|
-
type:
|
|
669
|
-
thinking:
|
|
664
|
+
z2.object({
|
|
665
|
+
type: z2.literal("thinking_delta"),
|
|
666
|
+
thinking: z2.string()
|
|
670
667
|
}),
|
|
671
|
-
|
|
672
|
-
type:
|
|
673
|
-
signature:
|
|
668
|
+
z2.object({
|
|
669
|
+
type: z2.literal("signature_delta"),
|
|
670
|
+
signature: z2.string()
|
|
674
671
|
}),
|
|
675
|
-
|
|
676
|
-
type:
|
|
677
|
-
content:
|
|
672
|
+
z2.object({
|
|
673
|
+
type: z2.literal("compaction_delta"),
|
|
674
|
+
content: z2.string().nullish()
|
|
678
675
|
}),
|
|
679
|
-
|
|
680
|
-
type:
|
|
681
|
-
citation:
|
|
682
|
-
|
|
683
|
-
type:
|
|
684
|
-
cited_text:
|
|
685
|
-
url:
|
|
686
|
-
title:
|
|
687
|
-
encrypted_index:
|
|
676
|
+
z2.object({
|
|
677
|
+
type: z2.literal("citations_delta"),
|
|
678
|
+
citation: z2.discriminatedUnion("type", [
|
|
679
|
+
z2.object({
|
|
680
|
+
type: z2.literal("web_search_result_location"),
|
|
681
|
+
cited_text: z2.string(),
|
|
682
|
+
url: z2.string(),
|
|
683
|
+
title: z2.string(),
|
|
684
|
+
encrypted_index: z2.string()
|
|
688
685
|
}),
|
|
689
|
-
|
|
690
|
-
type:
|
|
691
|
-
cited_text:
|
|
692
|
-
document_index:
|
|
693
|
-
document_title:
|
|
694
|
-
start_page_number:
|
|
695
|
-
end_page_number:
|
|
686
|
+
z2.object({
|
|
687
|
+
type: z2.literal("page_location"),
|
|
688
|
+
cited_text: z2.string(),
|
|
689
|
+
document_index: z2.number(),
|
|
690
|
+
document_title: z2.string().nullable(),
|
|
691
|
+
start_page_number: z2.number(),
|
|
692
|
+
end_page_number: z2.number()
|
|
696
693
|
}),
|
|
697
|
-
|
|
698
|
-
type:
|
|
699
|
-
cited_text:
|
|
700
|
-
document_index:
|
|
701
|
-
document_title:
|
|
702
|
-
start_char_index:
|
|
703
|
-
end_char_index:
|
|
694
|
+
z2.object({
|
|
695
|
+
type: z2.literal("char_location"),
|
|
696
|
+
cited_text: z2.string(),
|
|
697
|
+
document_index: z2.number(),
|
|
698
|
+
document_title: z2.string().nullable(),
|
|
699
|
+
start_char_index: z2.number(),
|
|
700
|
+
end_char_index: z2.number()
|
|
704
701
|
})
|
|
705
702
|
])
|
|
706
703
|
})
|
|
707
704
|
])
|
|
708
705
|
}),
|
|
709
|
-
|
|
710
|
-
type:
|
|
711
|
-
index:
|
|
706
|
+
z2.object({
|
|
707
|
+
type: z2.literal("content_block_stop"),
|
|
708
|
+
index: z2.number()
|
|
712
709
|
}),
|
|
713
|
-
|
|
714
|
-
type:
|
|
715
|
-
error:
|
|
716
|
-
type:
|
|
717
|
-
message:
|
|
710
|
+
z2.object({
|
|
711
|
+
type: z2.literal("error"),
|
|
712
|
+
error: z2.object({
|
|
713
|
+
type: z2.string(),
|
|
714
|
+
message: z2.string()
|
|
718
715
|
})
|
|
719
716
|
}),
|
|
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
|
-
|
|
717
|
+
z2.object({
|
|
718
|
+
type: z2.literal("message_delta"),
|
|
719
|
+
delta: z2.object({
|
|
720
|
+
stop_reason: z2.string().nullish(),
|
|
721
|
+
stop_sequence: z2.string().nullish(),
|
|
722
|
+
container: z2.object({
|
|
723
|
+
expires_at: z2.string(),
|
|
724
|
+
id: z2.string(),
|
|
725
|
+
skills: z2.array(
|
|
726
|
+
z2.object({
|
|
727
|
+
type: z2.union([
|
|
728
|
+
z2.literal("anthropic"),
|
|
729
|
+
z2.literal("custom")
|
|
733
730
|
]),
|
|
734
|
-
skill_id:
|
|
735
|
-
version:
|
|
731
|
+
skill_id: z2.string(),
|
|
732
|
+
version: z2.string()
|
|
736
733
|
})
|
|
737
734
|
).nullish()
|
|
738
735
|
}).nullish()
|
|
739
736
|
}),
|
|
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:
|
|
737
|
+
usage: z2.looseObject({
|
|
738
|
+
input_tokens: z2.number().nullish(),
|
|
739
|
+
output_tokens: z2.number(),
|
|
740
|
+
cache_creation_input_tokens: z2.number().nullish(),
|
|
741
|
+
cache_read_input_tokens: z2.number().nullish(),
|
|
742
|
+
iterations: z2.array(
|
|
743
|
+
z2.object({
|
|
744
|
+
type: z2.union([z2.literal("compaction"), z2.literal("message")]),
|
|
745
|
+
input_tokens: z2.number(),
|
|
746
|
+
output_tokens: z2.number()
|
|
750
747
|
})
|
|
751
748
|
).nullish()
|
|
752
749
|
}),
|
|
753
|
-
context_management:
|
|
754
|
-
applied_edits:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
type:
|
|
758
|
-
cleared_tool_uses:
|
|
759
|
-
cleared_input_tokens:
|
|
750
|
+
context_management: z2.object({
|
|
751
|
+
applied_edits: z2.array(
|
|
752
|
+
z2.union([
|
|
753
|
+
z2.object({
|
|
754
|
+
type: z2.literal("clear_tool_uses_20250919"),
|
|
755
|
+
cleared_tool_uses: z2.number(),
|
|
756
|
+
cleared_input_tokens: z2.number()
|
|
760
757
|
}),
|
|
761
|
-
|
|
762
|
-
type:
|
|
763
|
-
cleared_thinking_turns:
|
|
764
|
-
cleared_input_tokens:
|
|
758
|
+
z2.object({
|
|
759
|
+
type: z2.literal("clear_thinking_20251015"),
|
|
760
|
+
cleared_thinking_turns: z2.number(),
|
|
761
|
+
cleared_input_tokens: z2.number()
|
|
765
762
|
}),
|
|
766
|
-
|
|
767
|
-
type:
|
|
763
|
+
z2.object({
|
|
764
|
+
type: z2.literal("compact_20260112")
|
|
768
765
|
})
|
|
769
766
|
])
|
|
770
767
|
)
|
|
771
768
|
}).nullish()
|
|
772
769
|
}),
|
|
773
|
-
|
|
774
|
-
type:
|
|
770
|
+
z2.object({
|
|
771
|
+
type: z2.literal("message_stop")
|
|
775
772
|
}),
|
|
776
|
-
|
|
777
|
-
type:
|
|
773
|
+
z2.object({
|
|
774
|
+
type: z2.literal("ping")
|
|
778
775
|
})
|
|
779
776
|
])
|
|
780
777
|
)
|
|
781
778
|
);
|
|
782
|
-
var anthropicReasoningMetadataSchema = (
|
|
783
|
-
() => (
|
|
784
|
-
|
|
785
|
-
signature:
|
|
786
|
-
redactedData:
|
|
779
|
+
var anthropicReasoningMetadataSchema = lazySchema2(
|
|
780
|
+
() => zodSchema2(
|
|
781
|
+
z2.object({
|
|
782
|
+
signature: z2.string().optional(),
|
|
783
|
+
redactedData: z2.string().optional()
|
|
787
784
|
})
|
|
788
785
|
)
|
|
789
786
|
);
|
|
790
787
|
|
|
791
|
-
// src/anthropic-
|
|
792
|
-
|
|
793
|
-
var anthropicFilePartProviderOptions =
|
|
788
|
+
// src/anthropic-options.ts
|
|
789
|
+
import { z as z3 } from "zod/v4";
|
|
790
|
+
var anthropicFilePartProviderOptions = z3.object({
|
|
794
791
|
/**
|
|
795
792
|
* Citation configuration for this document.
|
|
796
793
|
* When enabled, this document will generate citations in the response.
|
|
797
794
|
*/
|
|
798
|
-
citations:
|
|
795
|
+
citations: z3.object({
|
|
799
796
|
/**
|
|
800
797
|
* Enable citations for this document
|
|
801
798
|
*/
|
|
802
|
-
enabled:
|
|
799
|
+
enabled: z3.boolean()
|
|
803
800
|
}).optional(),
|
|
804
801
|
/**
|
|
805
802
|
* Custom title for the document.
|
|
806
803
|
* If not provided, the filename will be used.
|
|
807
804
|
*/
|
|
808
|
-
title:
|
|
805
|
+
title: z3.string().optional(),
|
|
809
806
|
/**
|
|
810
807
|
* Context about the document that will be passed to the model
|
|
811
808
|
* but not used towards cited content.
|
|
812
809
|
* Useful for storing document metadata as text or stringified JSON.
|
|
813
810
|
*/
|
|
814
|
-
context:
|
|
811
|
+
context: z3.string().optional()
|
|
815
812
|
});
|
|
816
|
-
var anthropicLanguageModelOptions =
|
|
813
|
+
var anthropicLanguageModelOptions = z3.object({
|
|
817
814
|
/**
|
|
818
815
|
* Whether to send reasoning to the model.
|
|
819
816
|
*
|
|
820
817
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
821
818
|
*/
|
|
822
|
-
sendReasoning:
|
|
819
|
+
sendReasoning: z3.boolean().optional(),
|
|
823
820
|
/**
|
|
824
821
|
* Determines how structured outputs are generated.
|
|
825
822
|
*
|
|
@@ -827,52 +824,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
827
824
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
828
825
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
829
826
|
*/
|
|
830
|
-
structuredOutputMode:
|
|
827
|
+
structuredOutputMode: z3.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
831
828
|
/**
|
|
832
829
|
* Configuration for enabling Claude's extended thinking.
|
|
833
830
|
*
|
|
834
831
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
835
832
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
836
833
|
*/
|
|
837
|
-
thinking:
|
|
838
|
-
|
|
834
|
+
thinking: z3.discriminatedUnion("type", [
|
|
835
|
+
z3.object({
|
|
839
836
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
840
|
-
type:
|
|
837
|
+
type: z3.literal("adaptive"),
|
|
838
|
+
/**
|
|
839
|
+
* Controls whether thinking content is included in the response.
|
|
840
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
841
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
842
|
+
*/
|
|
843
|
+
display: z3.enum(["omitted", "summarized"]).optional()
|
|
841
844
|
}),
|
|
842
|
-
|
|
845
|
+
z3.object({
|
|
843
846
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
844
|
-
type:
|
|
845
|
-
budgetTokens:
|
|
847
|
+
type: z3.literal("enabled"),
|
|
848
|
+
budgetTokens: z3.number().optional()
|
|
846
849
|
}),
|
|
847
|
-
|
|
848
|
-
type:
|
|
850
|
+
z3.object({
|
|
851
|
+
type: z3.literal("disabled")
|
|
849
852
|
})
|
|
850
853
|
]).optional(),
|
|
851
854
|
/**
|
|
852
855
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
853
856
|
* When set to true, Claude will use at most one tool per response.
|
|
854
857
|
*/
|
|
855
|
-
disableParallelToolUse:
|
|
858
|
+
disableParallelToolUse: z3.boolean().optional(),
|
|
856
859
|
/**
|
|
857
860
|
* Cache control settings for this message.
|
|
858
861
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
859
862
|
*/
|
|
860
|
-
cacheControl:
|
|
861
|
-
type:
|
|
862
|
-
ttl:
|
|
863
|
+
cacheControl: z3.object({
|
|
864
|
+
type: z3.literal("ephemeral"),
|
|
865
|
+
ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
|
|
866
|
+
}).optional(),
|
|
867
|
+
/**
|
|
868
|
+
* Metadata to include with the request.
|
|
869
|
+
*
|
|
870
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
871
|
+
*/
|
|
872
|
+
metadata: z3.object({
|
|
873
|
+
/**
|
|
874
|
+
* An external identifier for the user associated with the request.
|
|
875
|
+
*
|
|
876
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
877
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
878
|
+
*/
|
|
879
|
+
userId: z3.string().optional()
|
|
863
880
|
}).optional(),
|
|
864
881
|
/**
|
|
865
882
|
* MCP servers to be utilized in this request.
|
|
866
883
|
*/
|
|
867
|
-
mcpServers:
|
|
868
|
-
|
|
869
|
-
type:
|
|
870
|
-
name:
|
|
871
|
-
url:
|
|
872
|
-
authorizationToken:
|
|
873
|
-
toolConfiguration:
|
|
874
|
-
enabled:
|
|
875
|
-
allowedTools:
|
|
884
|
+
mcpServers: z3.array(
|
|
885
|
+
z3.object({
|
|
886
|
+
type: z3.literal("url"),
|
|
887
|
+
name: z3.string(),
|
|
888
|
+
url: z3.string(),
|
|
889
|
+
authorizationToken: z3.string().nullish(),
|
|
890
|
+
toolConfiguration: z3.object({
|
|
891
|
+
enabled: z3.boolean().nullish(),
|
|
892
|
+
allowedTools: z3.array(z3.string()).nullish()
|
|
876
893
|
}).nullish()
|
|
877
894
|
})
|
|
878
895
|
).optional(),
|
|
@@ -881,83 +898,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
881
898
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
882
899
|
* Requires code execution tool to be enabled.
|
|
883
900
|
*/
|
|
884
|
-
container:
|
|
885
|
-
id:
|
|
886
|
-
skills:
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
901
|
+
container: z3.object({
|
|
902
|
+
id: z3.string().optional(),
|
|
903
|
+
skills: z3.array(
|
|
904
|
+
z3.discriminatedUnion("type", [
|
|
905
|
+
z3.object({
|
|
906
|
+
type: z3.literal("anthropic"),
|
|
907
|
+
skillId: z3.string(),
|
|
908
|
+
version: z3.string().optional()
|
|
909
|
+
}),
|
|
910
|
+
z3.object({
|
|
911
|
+
type: z3.literal("custom"),
|
|
912
|
+
providerReference: z3.record(z3.string(), z3.string()),
|
|
913
|
+
version: z3.string().optional()
|
|
914
|
+
})
|
|
915
|
+
])
|
|
892
916
|
).optional()
|
|
893
917
|
}).optional(),
|
|
894
918
|
/**
|
|
895
|
-
* Whether to enable
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
919
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
920
|
+
* and structured outputs for every function tool in the request. When
|
|
921
|
+
* true (the default), each function tool receives a default of
|
|
922
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
923
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
899
924
|
*
|
|
900
925
|
* @default true
|
|
901
926
|
*/
|
|
902
|
-
toolStreaming:
|
|
927
|
+
toolStreaming: z3.boolean().optional(),
|
|
903
928
|
/**
|
|
904
929
|
* @default 'high'
|
|
905
930
|
*/
|
|
906
|
-
effort:
|
|
931
|
+
effort: z3.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
932
|
+
/**
|
|
933
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
934
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
935
|
+
* gracefully as the budget is consumed.
|
|
936
|
+
*
|
|
937
|
+
* Advisory only — does not enforce a hard token limit.
|
|
938
|
+
*/
|
|
939
|
+
taskBudget: z3.object({
|
|
940
|
+
type: z3.literal("tokens"),
|
|
941
|
+
total: z3.number().int().min(2e4),
|
|
942
|
+
remaining: z3.number().int().min(0).optional()
|
|
943
|
+
}).optional(),
|
|
907
944
|
/**
|
|
908
945
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
909
946
|
* Only supported with claude-opus-4-6.
|
|
910
947
|
*/
|
|
911
|
-
speed:
|
|
948
|
+
speed: z3.enum(["fast", "standard"]).optional(),
|
|
949
|
+
/**
|
|
950
|
+
* Controls where model inference runs for this request.
|
|
951
|
+
*
|
|
952
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
953
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
954
|
+
*
|
|
955
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
956
|
+
*/
|
|
957
|
+
inferenceGeo: z3.enum(["us", "global"]).optional(),
|
|
912
958
|
/**
|
|
913
959
|
* A set of beta features to enable.
|
|
914
960
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
915
961
|
*/
|
|
916
|
-
anthropicBeta:
|
|
917
|
-
contextManagement:
|
|
918
|
-
edits:
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
type:
|
|
922
|
-
trigger:
|
|
923
|
-
|
|
924
|
-
type:
|
|
925
|
-
value:
|
|
962
|
+
anthropicBeta: z3.array(z3.string()).optional(),
|
|
963
|
+
contextManagement: z3.object({
|
|
964
|
+
edits: z3.array(
|
|
965
|
+
z3.discriminatedUnion("type", [
|
|
966
|
+
z3.object({
|
|
967
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
968
|
+
trigger: z3.discriminatedUnion("type", [
|
|
969
|
+
z3.object({
|
|
970
|
+
type: z3.literal("input_tokens"),
|
|
971
|
+
value: z3.number()
|
|
926
972
|
}),
|
|
927
|
-
|
|
928
|
-
type:
|
|
929
|
-
value:
|
|
973
|
+
z3.object({
|
|
974
|
+
type: z3.literal("tool_uses"),
|
|
975
|
+
value: z3.number()
|
|
930
976
|
})
|
|
931
977
|
]).optional(),
|
|
932
|
-
keep:
|
|
933
|
-
type:
|
|
934
|
-
value:
|
|
978
|
+
keep: z3.object({
|
|
979
|
+
type: z3.literal("tool_uses"),
|
|
980
|
+
value: z3.number()
|
|
935
981
|
}).optional(),
|
|
936
|
-
clearAtLeast:
|
|
937
|
-
type:
|
|
938
|
-
value:
|
|
982
|
+
clearAtLeast: z3.object({
|
|
983
|
+
type: z3.literal("input_tokens"),
|
|
984
|
+
value: z3.number()
|
|
939
985
|
}).optional(),
|
|
940
|
-
clearToolInputs:
|
|
941
|
-
excludeTools:
|
|
986
|
+
clearToolInputs: z3.boolean().optional(),
|
|
987
|
+
excludeTools: z3.array(z3.string()).optional()
|
|
942
988
|
}),
|
|
943
|
-
|
|
944
|
-
type:
|
|
945
|
-
keep:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
type:
|
|
949
|
-
value:
|
|
989
|
+
z3.object({
|
|
990
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
991
|
+
keep: z3.union([
|
|
992
|
+
z3.literal("all"),
|
|
993
|
+
z3.object({
|
|
994
|
+
type: z3.literal("thinking_turns"),
|
|
995
|
+
value: z3.number()
|
|
950
996
|
})
|
|
951
997
|
]).optional()
|
|
952
998
|
}),
|
|
953
|
-
|
|
954
|
-
type:
|
|
955
|
-
trigger:
|
|
956
|
-
type:
|
|
957
|
-
value:
|
|
999
|
+
z3.object({
|
|
1000
|
+
type: z3.literal("compact_20260112"),
|
|
1001
|
+
trigger: z3.object({
|
|
1002
|
+
type: z3.literal("input_tokens"),
|
|
1003
|
+
value: z3.number()
|
|
958
1004
|
}).optional(),
|
|
959
|
-
pauseAfterCompaction:
|
|
960
|
-
instructions:
|
|
1005
|
+
pauseAfterCompaction: z3.boolean().optional(),
|
|
1006
|
+
instructions: z3.string().optional()
|
|
961
1007
|
})
|
|
962
1008
|
])
|
|
963
1009
|
)
|
|
@@ -965,7 +1011,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
965
1011
|
});
|
|
966
1012
|
|
|
967
1013
|
// src/anthropic-prepare-tools.ts
|
|
968
|
-
|
|
1014
|
+
import {
|
|
1015
|
+
UnsupportedFunctionalityError
|
|
1016
|
+
} from "@ai-sdk/provider";
|
|
969
1017
|
|
|
970
1018
|
// src/get-cache-control.ts
|
|
971
1019
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1010,31 +1058,34 @@ var CacheControlValidator = class {
|
|
|
1010
1058
|
};
|
|
1011
1059
|
|
|
1012
1060
|
// src/tool/text-editor_20250728.ts
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1061
|
+
import {
|
|
1062
|
+
createProviderDefinedToolFactory,
|
|
1063
|
+
lazySchema as lazySchema3,
|
|
1064
|
+
zodSchema as zodSchema3
|
|
1065
|
+
} from "@ai-sdk/provider-utils";
|
|
1066
|
+
import { z as z4 } from "zod/v4";
|
|
1067
|
+
var textEditor_20250728ArgsSchema = lazySchema3(
|
|
1068
|
+
() => zodSchema3(
|
|
1069
|
+
z4.object({
|
|
1070
|
+
maxCharacters: z4.number().optional()
|
|
1020
1071
|
})
|
|
1021
1072
|
)
|
|
1022
1073
|
);
|
|
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:
|
|
1074
|
+
var textEditor_20250728InputSchema = lazySchema3(
|
|
1075
|
+
() => zodSchema3(
|
|
1076
|
+
z4.object({
|
|
1077
|
+
command: z4.enum(["view", "create", "str_replace", "insert"]),
|
|
1078
|
+
path: z4.string(),
|
|
1079
|
+
file_text: z4.string().optional(),
|
|
1080
|
+
insert_line: z4.number().int().optional(),
|
|
1081
|
+
new_str: z4.string().optional(),
|
|
1082
|
+
insert_text: z4.string().optional(),
|
|
1083
|
+
old_str: z4.string().optional(),
|
|
1084
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
1034
1085
|
})
|
|
1035
1086
|
)
|
|
1036
1087
|
);
|
|
1037
|
-
var factory = (
|
|
1088
|
+
var factory = createProviderDefinedToolFactory({
|
|
1038
1089
|
id: "anthropic.text_editor_20250728",
|
|
1039
1090
|
inputSchema: textEditor_20250728InputSchema
|
|
1040
1091
|
});
|
|
@@ -1043,45 +1094,49 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1043
1094
|
};
|
|
1044
1095
|
|
|
1045
1096
|
// src/tool/web-search_20260209.ts
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1097
|
+
import {
|
|
1098
|
+
createProviderExecutedToolFactory,
|
|
1099
|
+
lazySchema as lazySchema4,
|
|
1100
|
+
zodSchema as zodSchema4
|
|
1101
|
+
} from "@ai-sdk/provider-utils";
|
|
1102
|
+
import { z as z5 } from "zod/v4";
|
|
1103
|
+
var webSearch_20260209ArgsSchema = lazySchema4(
|
|
1104
|
+
() => zodSchema4(
|
|
1105
|
+
z5.object({
|
|
1106
|
+
maxUses: z5.number().optional(),
|
|
1107
|
+
allowedDomains: z5.array(z5.string()).optional(),
|
|
1108
|
+
blockedDomains: z5.array(z5.string()).optional(),
|
|
1109
|
+
userLocation: z5.object({
|
|
1110
|
+
type: z5.literal("approximate"),
|
|
1111
|
+
city: z5.string().optional(),
|
|
1112
|
+
region: z5.string().optional(),
|
|
1113
|
+
country: z5.string().optional(),
|
|
1114
|
+
timezone: z5.string().optional()
|
|
1060
1115
|
}).optional()
|
|
1061
1116
|
})
|
|
1062
1117
|
)
|
|
1063
1118
|
);
|
|
1064
|
-
var webSearch_20260209OutputSchema = (
|
|
1065
|
-
() => (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
url:
|
|
1069
|
-
title:
|
|
1070
|
-
pageAge:
|
|
1071
|
-
encryptedContent:
|
|
1072
|
-
type:
|
|
1119
|
+
var webSearch_20260209OutputSchema = lazySchema4(
|
|
1120
|
+
() => zodSchema4(
|
|
1121
|
+
z5.array(
|
|
1122
|
+
z5.object({
|
|
1123
|
+
url: z5.string(),
|
|
1124
|
+
title: z5.string().nullable(),
|
|
1125
|
+
pageAge: z5.string().nullable(),
|
|
1126
|
+
encryptedContent: z5.string(),
|
|
1127
|
+
type: z5.literal("web_search_result")
|
|
1073
1128
|
})
|
|
1074
1129
|
)
|
|
1075
1130
|
)
|
|
1076
1131
|
);
|
|
1077
|
-
var webSearch_20260209InputSchema = (
|
|
1078
|
-
() => (
|
|
1079
|
-
|
|
1080
|
-
query:
|
|
1132
|
+
var webSearch_20260209InputSchema = lazySchema4(
|
|
1133
|
+
() => zodSchema4(
|
|
1134
|
+
z5.object({
|
|
1135
|
+
query: z5.string()
|
|
1081
1136
|
})
|
|
1082
1137
|
)
|
|
1083
1138
|
);
|
|
1084
|
-
var factory2 = (
|
|
1139
|
+
var factory2 = createProviderExecutedToolFactory({
|
|
1085
1140
|
id: "anthropic.web_search_20260209",
|
|
1086
1141
|
inputSchema: webSearch_20260209InputSchema,
|
|
1087
1142
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1092,45 +1147,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1092
1147
|
};
|
|
1093
1148
|
|
|
1094
1149
|
// src/tool/web-search_20250305.ts
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1150
|
+
import {
|
|
1151
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
1152
|
+
lazySchema as lazySchema5,
|
|
1153
|
+
zodSchema as zodSchema5
|
|
1154
|
+
} from "@ai-sdk/provider-utils";
|
|
1155
|
+
import { z as z6 } from "zod/v4";
|
|
1156
|
+
var webSearch_20250305ArgsSchema = lazySchema5(
|
|
1157
|
+
() => zodSchema5(
|
|
1158
|
+
z6.object({
|
|
1159
|
+
maxUses: z6.number().optional(),
|
|
1160
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1161
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1162
|
+
userLocation: z6.object({
|
|
1163
|
+
type: z6.literal("approximate"),
|
|
1164
|
+
city: z6.string().optional(),
|
|
1165
|
+
region: z6.string().optional(),
|
|
1166
|
+
country: z6.string().optional(),
|
|
1167
|
+
timezone: z6.string().optional()
|
|
1109
1168
|
}).optional()
|
|
1110
1169
|
})
|
|
1111
1170
|
)
|
|
1112
1171
|
);
|
|
1113
|
-
var webSearch_20250305OutputSchema = (
|
|
1114
|
-
() => (
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
url:
|
|
1118
|
-
title:
|
|
1119
|
-
pageAge:
|
|
1120
|
-
encryptedContent:
|
|
1121
|
-
type:
|
|
1172
|
+
var webSearch_20250305OutputSchema = lazySchema5(
|
|
1173
|
+
() => zodSchema5(
|
|
1174
|
+
z6.array(
|
|
1175
|
+
z6.object({
|
|
1176
|
+
url: z6.string(),
|
|
1177
|
+
title: z6.string().nullable(),
|
|
1178
|
+
pageAge: z6.string().nullable(),
|
|
1179
|
+
encryptedContent: z6.string(),
|
|
1180
|
+
type: z6.literal("web_search_result")
|
|
1122
1181
|
})
|
|
1123
1182
|
)
|
|
1124
1183
|
)
|
|
1125
1184
|
);
|
|
1126
|
-
var webSearch_20250305InputSchema = (
|
|
1127
|
-
() => (
|
|
1128
|
-
|
|
1129
|
-
query:
|
|
1185
|
+
var webSearch_20250305InputSchema = lazySchema5(
|
|
1186
|
+
() => zodSchema5(
|
|
1187
|
+
z6.object({
|
|
1188
|
+
query: z6.string()
|
|
1130
1189
|
})
|
|
1131
1190
|
)
|
|
1132
1191
|
);
|
|
1133
|
-
var factory3 = (
|
|
1192
|
+
var factory3 = createProviderExecutedToolFactory2({
|
|
1134
1193
|
id: "anthropic.web_search_20250305",
|
|
1135
1194
|
inputSchema: webSearch_20250305InputSchema,
|
|
1136
1195
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1141,53 +1200,57 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1141
1200
|
};
|
|
1142
1201
|
|
|
1143
1202
|
// src/tool/web-fetch-20260209.ts
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1203
|
+
import {
|
|
1204
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
1205
|
+
lazySchema as lazySchema6,
|
|
1206
|
+
zodSchema as zodSchema6
|
|
1207
|
+
} from "@ai-sdk/provider-utils";
|
|
1208
|
+
import { z as z7 } from "zod/v4";
|
|
1209
|
+
var webFetch_20260209ArgsSchema = lazySchema6(
|
|
1210
|
+
() => zodSchema6(
|
|
1211
|
+
z7.object({
|
|
1212
|
+
maxUses: z7.number().optional(),
|
|
1213
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1214
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1215
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1216
|
+
maxContentTokens: z7.number().optional()
|
|
1154
1217
|
})
|
|
1155
1218
|
)
|
|
1156
1219
|
);
|
|
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:
|
|
1220
|
+
var webFetch_20260209OutputSchema = lazySchema6(
|
|
1221
|
+
() => zodSchema6(
|
|
1222
|
+
z7.object({
|
|
1223
|
+
type: z7.literal("web_fetch_result"),
|
|
1224
|
+
url: z7.string(),
|
|
1225
|
+
content: z7.object({
|
|
1226
|
+
type: z7.literal("document"),
|
|
1227
|
+
title: z7.string().nullable(),
|
|
1228
|
+
citations: z7.object({ enabled: z7.boolean() }).optional(),
|
|
1229
|
+
source: z7.union([
|
|
1230
|
+
z7.object({
|
|
1231
|
+
type: z7.literal("base64"),
|
|
1232
|
+
mediaType: z7.literal("application/pdf"),
|
|
1233
|
+
data: z7.string()
|
|
1171
1234
|
}),
|
|
1172
|
-
|
|
1173
|
-
type:
|
|
1174
|
-
mediaType:
|
|
1175
|
-
data:
|
|
1235
|
+
z7.object({
|
|
1236
|
+
type: z7.literal("text"),
|
|
1237
|
+
mediaType: z7.literal("text/plain"),
|
|
1238
|
+
data: z7.string()
|
|
1176
1239
|
})
|
|
1177
1240
|
])
|
|
1178
1241
|
}),
|
|
1179
|
-
retrievedAt:
|
|
1242
|
+
retrievedAt: z7.string().nullable()
|
|
1180
1243
|
})
|
|
1181
1244
|
)
|
|
1182
1245
|
);
|
|
1183
|
-
var webFetch_20260209InputSchema = (
|
|
1184
|
-
() => (
|
|
1185
|
-
|
|
1186
|
-
url:
|
|
1246
|
+
var webFetch_20260209InputSchema = lazySchema6(
|
|
1247
|
+
() => zodSchema6(
|
|
1248
|
+
z7.object({
|
|
1249
|
+
url: z7.string()
|
|
1187
1250
|
})
|
|
1188
1251
|
)
|
|
1189
1252
|
);
|
|
1190
|
-
var factory4 = (
|
|
1253
|
+
var factory4 = createProviderExecutedToolFactory3({
|
|
1191
1254
|
id: "anthropic.web_fetch_20260209",
|
|
1192
1255
|
inputSchema: webFetch_20260209InputSchema,
|
|
1193
1256
|
outputSchema: webFetch_20260209OutputSchema,
|
|
@@ -1198,53 +1261,57 @@ var webFetch_20260209 = (args = {}) => {
|
|
|
1198
1261
|
};
|
|
1199
1262
|
|
|
1200
1263
|
// src/tool/web-fetch-20250910.ts
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1264
|
+
import {
|
|
1265
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
1266
|
+
lazySchema as lazySchema7,
|
|
1267
|
+
zodSchema as zodSchema7
|
|
1268
|
+
} from "@ai-sdk/provider-utils";
|
|
1269
|
+
import { z as z8 } from "zod/v4";
|
|
1270
|
+
var webFetch_20250910ArgsSchema = lazySchema7(
|
|
1271
|
+
() => zodSchema7(
|
|
1272
|
+
z8.object({
|
|
1273
|
+
maxUses: z8.number().optional(),
|
|
1274
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1275
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1276
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1277
|
+
maxContentTokens: z8.number().optional()
|
|
1211
1278
|
})
|
|
1212
1279
|
)
|
|
1213
1280
|
);
|
|
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:
|
|
1281
|
+
var webFetch_20250910OutputSchema = lazySchema7(
|
|
1282
|
+
() => zodSchema7(
|
|
1283
|
+
z8.object({
|
|
1284
|
+
type: z8.literal("web_fetch_result"),
|
|
1285
|
+
url: z8.string(),
|
|
1286
|
+
content: z8.object({
|
|
1287
|
+
type: z8.literal("document"),
|
|
1288
|
+
title: z8.string().nullable(),
|
|
1289
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1290
|
+
source: z8.union([
|
|
1291
|
+
z8.object({
|
|
1292
|
+
type: z8.literal("base64"),
|
|
1293
|
+
mediaType: z8.literal("application/pdf"),
|
|
1294
|
+
data: z8.string()
|
|
1228
1295
|
}),
|
|
1229
|
-
|
|
1230
|
-
type:
|
|
1231
|
-
mediaType:
|
|
1232
|
-
data:
|
|
1296
|
+
z8.object({
|
|
1297
|
+
type: z8.literal("text"),
|
|
1298
|
+
mediaType: z8.literal("text/plain"),
|
|
1299
|
+
data: z8.string()
|
|
1233
1300
|
})
|
|
1234
1301
|
])
|
|
1235
1302
|
}),
|
|
1236
|
-
retrievedAt:
|
|
1303
|
+
retrievedAt: z8.string().nullable()
|
|
1237
1304
|
})
|
|
1238
1305
|
)
|
|
1239
1306
|
);
|
|
1240
|
-
var webFetch_20250910InputSchema = (
|
|
1241
|
-
() => (
|
|
1242
|
-
|
|
1243
|
-
url:
|
|
1307
|
+
var webFetch_20250910InputSchema = lazySchema7(
|
|
1308
|
+
() => zodSchema7(
|
|
1309
|
+
z8.object({
|
|
1310
|
+
url: z8.string()
|
|
1244
1311
|
})
|
|
1245
1312
|
)
|
|
1246
1313
|
);
|
|
1247
|
-
var factory5 = (
|
|
1314
|
+
var factory5 = createProviderExecutedToolFactory4({
|
|
1248
1315
|
id: "anthropic.web_fetch_20250910",
|
|
1249
1316
|
inputSchema: webFetch_20250910InputSchema,
|
|
1250
1317
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1255,16 +1322,17 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1255
1322
|
};
|
|
1256
1323
|
|
|
1257
1324
|
// src/anthropic-prepare-tools.ts
|
|
1258
|
-
|
|
1325
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1259
1326
|
async function prepareTools({
|
|
1260
1327
|
tools,
|
|
1261
1328
|
toolChoice,
|
|
1262
1329
|
disableParallelToolUse,
|
|
1263
1330
|
cacheControlValidator,
|
|
1264
1331
|
supportsStructuredOutput,
|
|
1265
|
-
supportsStrictTools
|
|
1332
|
+
supportsStrictTools,
|
|
1333
|
+
defaultEagerInputStreaming = false
|
|
1266
1334
|
}) {
|
|
1267
|
-
var _a;
|
|
1335
|
+
var _a, _b;
|
|
1268
1336
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1269
1337
|
const toolWarnings = [];
|
|
1270
1338
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1281,7 +1349,7 @@ async function prepareTools({
|
|
|
1281
1349
|
canCache: true
|
|
1282
1350
|
});
|
|
1283
1351
|
const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1284
|
-
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1352
|
+
const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
|
|
1285
1353
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1286
1354
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1287
1355
|
if (!supportsStrictTools && tool.strict != null) {
|
|
@@ -1405,7 +1473,7 @@ async function prepareTools({
|
|
|
1405
1473
|
break;
|
|
1406
1474
|
}
|
|
1407
1475
|
case "anthropic.text_editor_20250728": {
|
|
1408
|
-
const args = await
|
|
1476
|
+
const args = await validateTypes({
|
|
1409
1477
|
value: tool.args,
|
|
1410
1478
|
schema: textEditor_20250728ArgsSchema
|
|
1411
1479
|
});
|
|
@@ -1445,7 +1513,7 @@ async function prepareTools({
|
|
|
1445
1513
|
}
|
|
1446
1514
|
case "anthropic.web_fetch_20250910": {
|
|
1447
1515
|
betas.add("web-fetch-2025-09-10");
|
|
1448
|
-
const args = await
|
|
1516
|
+
const args = await validateTypes({
|
|
1449
1517
|
value: tool.args,
|
|
1450
1518
|
schema: webFetch_20250910ArgsSchema
|
|
1451
1519
|
});
|
|
@@ -1463,7 +1531,7 @@ async function prepareTools({
|
|
|
1463
1531
|
}
|
|
1464
1532
|
case "anthropic.web_fetch_20260209": {
|
|
1465
1533
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1466
|
-
const args = await
|
|
1534
|
+
const args = await validateTypes({
|
|
1467
1535
|
value: tool.args,
|
|
1468
1536
|
schema: webFetch_20260209ArgsSchema
|
|
1469
1537
|
});
|
|
@@ -1480,7 +1548,7 @@ async function prepareTools({
|
|
|
1480
1548
|
break;
|
|
1481
1549
|
}
|
|
1482
1550
|
case "anthropic.web_search_20250305": {
|
|
1483
|
-
const args = await
|
|
1551
|
+
const args = await validateTypes({
|
|
1484
1552
|
value: tool.args,
|
|
1485
1553
|
schema: webSearch_20250305ArgsSchema
|
|
1486
1554
|
});
|
|
@@ -1497,7 +1565,7 @@ async function prepareTools({
|
|
|
1497
1565
|
}
|
|
1498
1566
|
case "anthropic.web_search_20260209": {
|
|
1499
1567
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1500
|
-
const args = await
|
|
1568
|
+
const args = await validateTypes({
|
|
1501
1569
|
value: tool.args,
|
|
1502
1570
|
schema: webSearch_20260209ArgsSchema
|
|
1503
1571
|
});
|
|
@@ -1513,7 +1581,6 @@ async function prepareTools({
|
|
|
1513
1581
|
break;
|
|
1514
1582
|
}
|
|
1515
1583
|
case "anthropic.tool_search_regex_20251119": {
|
|
1516
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1517
1584
|
anthropicTools2.push({
|
|
1518
1585
|
type: "tool_search_tool_regex_20251119",
|
|
1519
1586
|
name: "tool_search_tool_regex"
|
|
@@ -1521,7 +1588,6 @@ async function prepareTools({
|
|
|
1521
1588
|
break;
|
|
1522
1589
|
}
|
|
1523
1590
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1591
|
anthropicTools2.push({
|
|
1526
1592
|
type: "tool_search_tool_bm25_20251119",
|
|
1527
1593
|
name: "tool_search_tool_bm25"
|
|
@@ -1592,15 +1658,15 @@ async function prepareTools({
|
|
|
1592
1658
|
};
|
|
1593
1659
|
default: {
|
|
1594
1660
|
const _exhaustiveCheck = type;
|
|
1595
|
-
throw new
|
|
1661
|
+
throw new UnsupportedFunctionalityError({
|
|
1596
1662
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1597
1663
|
});
|
|
1598
1664
|
}
|
|
1599
1665
|
}
|
|
1600
1666
|
}
|
|
1601
1667
|
|
|
1602
|
-
// src/convert-anthropic-
|
|
1603
|
-
function
|
|
1668
|
+
// src/convert-anthropic-usage.ts
|
|
1669
|
+
function convertAnthropicUsage({
|
|
1604
1670
|
usage,
|
|
1605
1671
|
rawUsage
|
|
1606
1672
|
}) {
|
|
@@ -1639,37 +1705,52 @@ function convertAnthropicMessagesUsage({
|
|
|
1639
1705
|
};
|
|
1640
1706
|
}
|
|
1641
1707
|
|
|
1642
|
-
// src/convert-to-anthropic-
|
|
1643
|
-
|
|
1644
|
-
|
|
1708
|
+
// src/convert-to-anthropic-prompt.ts
|
|
1709
|
+
import {
|
|
1710
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1711
|
+
} from "@ai-sdk/provider";
|
|
1712
|
+
import {
|
|
1713
|
+
convertBase64ToUint8Array,
|
|
1714
|
+
convertToBase64,
|
|
1715
|
+
getTopLevelMediaType,
|
|
1716
|
+
parseProviderOptions,
|
|
1717
|
+
resolveFullMediaType,
|
|
1718
|
+
resolveProviderReference,
|
|
1719
|
+
validateTypes as validateTypes2,
|
|
1720
|
+
isNonNullable
|
|
1721
|
+
} from "@ai-sdk/provider-utils";
|
|
1645
1722
|
|
|
1646
1723
|
// src/tool/code-execution_20250522.ts
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1724
|
+
import {
|
|
1725
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
1726
|
+
lazySchema as lazySchema8,
|
|
1727
|
+
zodSchema as zodSchema8
|
|
1728
|
+
} from "@ai-sdk/provider-utils";
|
|
1729
|
+
import { z as z9 } from "zod/v4";
|
|
1730
|
+
var codeExecution_20250522OutputSchema = lazySchema8(
|
|
1731
|
+
() => zodSchema8(
|
|
1732
|
+
z9.object({
|
|
1733
|
+
type: z9.literal("code_execution_result"),
|
|
1734
|
+
stdout: z9.string(),
|
|
1735
|
+
stderr: z9.string(),
|
|
1736
|
+
return_code: z9.number(),
|
|
1737
|
+
content: z9.array(
|
|
1738
|
+
z9.object({
|
|
1739
|
+
type: z9.literal("code_execution_output"),
|
|
1740
|
+
file_id: z9.string()
|
|
1660
1741
|
})
|
|
1661
1742
|
).optional().default([])
|
|
1662
1743
|
})
|
|
1663
1744
|
)
|
|
1664
1745
|
);
|
|
1665
|
-
var codeExecution_20250522InputSchema = (
|
|
1666
|
-
() => (
|
|
1667
|
-
|
|
1668
|
-
code:
|
|
1746
|
+
var codeExecution_20250522InputSchema = lazySchema8(
|
|
1747
|
+
() => zodSchema8(
|
|
1748
|
+
z9.object({
|
|
1749
|
+
code: z9.string()
|
|
1669
1750
|
})
|
|
1670
1751
|
)
|
|
1671
1752
|
);
|
|
1672
|
-
var factory6 = (
|
|
1753
|
+
var factory6 = createProviderExecutedToolFactory5({
|
|
1673
1754
|
id: "anthropic.code_execution_20250522",
|
|
1674
1755
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1675
1756
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1679,102 +1760,106 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1679
1760
|
};
|
|
1680
1761
|
|
|
1681
1762
|
// src/tool/code-execution_20250825.ts
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1763
|
+
import {
|
|
1764
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
1765
|
+
lazySchema as lazySchema9,
|
|
1766
|
+
zodSchema as zodSchema9
|
|
1767
|
+
} from "@ai-sdk/provider-utils";
|
|
1768
|
+
import { z as z10 } from "zod/v4";
|
|
1769
|
+
var codeExecution_20250825OutputSchema = lazySchema9(
|
|
1770
|
+
() => zodSchema9(
|
|
1771
|
+
z10.discriminatedUnion("type", [
|
|
1772
|
+
z10.object({
|
|
1773
|
+
type: z10.literal("code_execution_result"),
|
|
1774
|
+
stdout: z10.string(),
|
|
1775
|
+
stderr: z10.string(),
|
|
1776
|
+
return_code: z10.number(),
|
|
1777
|
+
content: z10.array(
|
|
1778
|
+
z10.object({
|
|
1779
|
+
type: z10.literal("code_execution_output"),
|
|
1780
|
+
file_id: z10.string()
|
|
1696
1781
|
})
|
|
1697
1782
|
).optional().default([])
|
|
1698
1783
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1701
|
-
content:
|
|
1702
|
-
|
|
1703
|
-
type:
|
|
1704
|
-
file_id:
|
|
1784
|
+
z10.object({
|
|
1785
|
+
type: z10.literal("bash_code_execution_result"),
|
|
1786
|
+
content: z10.array(
|
|
1787
|
+
z10.object({
|
|
1788
|
+
type: z10.literal("bash_code_execution_output"),
|
|
1789
|
+
file_id: z10.string()
|
|
1705
1790
|
})
|
|
1706
1791
|
),
|
|
1707
|
-
stdout:
|
|
1708
|
-
stderr:
|
|
1709
|
-
return_code:
|
|
1792
|
+
stdout: z10.string(),
|
|
1793
|
+
stderr: z10.string(),
|
|
1794
|
+
return_code: z10.number()
|
|
1710
1795
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
error_code:
|
|
1796
|
+
z10.object({
|
|
1797
|
+
type: z10.literal("bash_code_execution_tool_result_error"),
|
|
1798
|
+
error_code: z10.string()
|
|
1714
1799
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
error_code:
|
|
1800
|
+
z10.object({
|
|
1801
|
+
type: z10.literal("text_editor_code_execution_tool_result_error"),
|
|
1802
|
+
error_code: z10.string()
|
|
1718
1803
|
}),
|
|
1719
|
-
|
|
1720
|
-
type:
|
|
1721
|
-
content:
|
|
1722
|
-
file_type:
|
|
1723
|
-
num_lines:
|
|
1724
|
-
start_line:
|
|
1725
|
-
total_lines:
|
|
1804
|
+
z10.object({
|
|
1805
|
+
type: z10.literal("text_editor_code_execution_view_result"),
|
|
1806
|
+
content: z10.string(),
|
|
1807
|
+
file_type: z10.string(),
|
|
1808
|
+
num_lines: z10.number().nullable(),
|
|
1809
|
+
start_line: z10.number().nullable(),
|
|
1810
|
+
total_lines: z10.number().nullable()
|
|
1726
1811
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
is_file_update:
|
|
1812
|
+
z10.object({
|
|
1813
|
+
type: z10.literal("text_editor_code_execution_create_result"),
|
|
1814
|
+
is_file_update: z10.boolean()
|
|
1730
1815
|
}),
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
lines:
|
|
1734
|
-
new_lines:
|
|
1735
|
-
new_start:
|
|
1736
|
-
old_lines:
|
|
1737
|
-
old_start:
|
|
1816
|
+
z10.object({
|
|
1817
|
+
type: z10.literal("text_editor_code_execution_str_replace_result"),
|
|
1818
|
+
lines: z10.array(z10.string()).nullable(),
|
|
1819
|
+
new_lines: z10.number().nullable(),
|
|
1820
|
+
new_start: z10.number().nullable(),
|
|
1821
|
+
old_lines: z10.number().nullable(),
|
|
1822
|
+
old_start: z10.number().nullable()
|
|
1738
1823
|
})
|
|
1739
1824
|
])
|
|
1740
1825
|
)
|
|
1741
1826
|
);
|
|
1742
|
-
var codeExecution_20250825InputSchema = (
|
|
1743
|
-
() => (
|
|
1744
|
-
|
|
1827
|
+
var codeExecution_20250825InputSchema = lazySchema9(
|
|
1828
|
+
() => zodSchema9(
|
|
1829
|
+
z10.discriminatedUnion("type", [
|
|
1745
1830
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1746
|
-
|
|
1747
|
-
type:
|
|
1748
|
-
code:
|
|
1831
|
+
z10.object({
|
|
1832
|
+
type: z10.literal("programmatic-tool-call"),
|
|
1833
|
+
code: z10.string()
|
|
1749
1834
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
command:
|
|
1835
|
+
z10.object({
|
|
1836
|
+
type: z10.literal("bash_code_execution"),
|
|
1837
|
+
command: z10.string()
|
|
1753
1838
|
}),
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
command:
|
|
1758
|
-
path:
|
|
1839
|
+
z10.discriminatedUnion("command", [
|
|
1840
|
+
z10.object({
|
|
1841
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1842
|
+
command: z10.literal("view"),
|
|
1843
|
+
path: z10.string()
|
|
1759
1844
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
command:
|
|
1763
|
-
path:
|
|
1764
|
-
file_text:
|
|
1845
|
+
z10.object({
|
|
1846
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1847
|
+
command: z10.literal("create"),
|
|
1848
|
+
path: z10.string(),
|
|
1849
|
+
file_text: z10.string().nullish()
|
|
1765
1850
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
command:
|
|
1769
|
-
path:
|
|
1770
|
-
old_str:
|
|
1771
|
-
new_str:
|
|
1851
|
+
z10.object({
|
|
1852
|
+
type: z10.literal("text_editor_code_execution"),
|
|
1853
|
+
command: z10.literal("str_replace"),
|
|
1854
|
+
path: z10.string(),
|
|
1855
|
+
old_str: z10.string(),
|
|
1856
|
+
new_str: z10.string()
|
|
1772
1857
|
})
|
|
1773
1858
|
])
|
|
1774
1859
|
])
|
|
1775
1860
|
)
|
|
1776
1861
|
);
|
|
1777
|
-
var factory7 = (
|
|
1862
|
+
var factory7 = createProviderExecutedToolFactory6({
|
|
1778
1863
|
id: "anthropic.code_execution_20250825",
|
|
1779
1864
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1780
1865
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1788,113 +1873,117 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1788
1873
|
};
|
|
1789
1874
|
|
|
1790
1875
|
// src/tool/code-execution_20260120.ts
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1876
|
+
import {
|
|
1877
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
1878
|
+
lazySchema as lazySchema10,
|
|
1879
|
+
zodSchema as zodSchema10
|
|
1880
|
+
} from "@ai-sdk/provider-utils";
|
|
1881
|
+
import { z as z11 } from "zod/v4";
|
|
1882
|
+
var codeExecution_20260120OutputSchema = lazySchema10(
|
|
1883
|
+
() => zodSchema10(
|
|
1884
|
+
z11.discriminatedUnion("type", [
|
|
1885
|
+
z11.object({
|
|
1886
|
+
type: z11.literal("code_execution_result"),
|
|
1887
|
+
stdout: z11.string(),
|
|
1888
|
+
stderr: z11.string(),
|
|
1889
|
+
return_code: z11.number(),
|
|
1890
|
+
content: z11.array(
|
|
1891
|
+
z11.object({
|
|
1892
|
+
type: z11.literal("code_execution_output"),
|
|
1893
|
+
file_id: z11.string()
|
|
1805
1894
|
})
|
|
1806
1895
|
).optional().default([])
|
|
1807
1896
|
}),
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
encrypted_stdout:
|
|
1811
|
-
stderr:
|
|
1812
|
-
return_code:
|
|
1813
|
-
content:
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
file_id:
|
|
1897
|
+
z11.object({
|
|
1898
|
+
type: z11.literal("encrypted_code_execution_result"),
|
|
1899
|
+
encrypted_stdout: z11.string(),
|
|
1900
|
+
stderr: z11.string(),
|
|
1901
|
+
return_code: z11.number(),
|
|
1902
|
+
content: z11.array(
|
|
1903
|
+
z11.object({
|
|
1904
|
+
type: z11.literal("code_execution_output"),
|
|
1905
|
+
file_id: z11.string()
|
|
1817
1906
|
})
|
|
1818
1907
|
).optional().default([])
|
|
1819
1908
|
}),
|
|
1820
|
-
|
|
1821
|
-
type:
|
|
1822
|
-
content:
|
|
1823
|
-
|
|
1824
|
-
type:
|
|
1825
|
-
file_id:
|
|
1909
|
+
z11.object({
|
|
1910
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1911
|
+
content: z11.array(
|
|
1912
|
+
z11.object({
|
|
1913
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1914
|
+
file_id: z11.string()
|
|
1826
1915
|
})
|
|
1827
1916
|
),
|
|
1828
|
-
stdout:
|
|
1829
|
-
stderr:
|
|
1830
|
-
return_code:
|
|
1917
|
+
stdout: z11.string(),
|
|
1918
|
+
stderr: z11.string(),
|
|
1919
|
+
return_code: z11.number()
|
|
1831
1920
|
}),
|
|
1832
|
-
|
|
1833
|
-
type:
|
|
1834
|
-
error_code:
|
|
1921
|
+
z11.object({
|
|
1922
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1923
|
+
error_code: z11.string()
|
|
1835
1924
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
1838
|
-
error_code:
|
|
1925
|
+
z11.object({
|
|
1926
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1927
|
+
error_code: z11.string()
|
|
1839
1928
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
content:
|
|
1843
|
-
file_type:
|
|
1844
|
-
num_lines:
|
|
1845
|
-
start_line:
|
|
1846
|
-
total_lines:
|
|
1929
|
+
z11.object({
|
|
1930
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1931
|
+
content: z11.string(),
|
|
1932
|
+
file_type: z11.string(),
|
|
1933
|
+
num_lines: z11.number().nullable(),
|
|
1934
|
+
start_line: z11.number().nullable(),
|
|
1935
|
+
total_lines: z11.number().nullable()
|
|
1847
1936
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
is_file_update:
|
|
1937
|
+
z11.object({
|
|
1938
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1939
|
+
is_file_update: z11.boolean()
|
|
1851
1940
|
}),
|
|
1852
|
-
|
|
1853
|
-
type:
|
|
1854
|
-
lines:
|
|
1855
|
-
new_lines:
|
|
1856
|
-
new_start:
|
|
1857
|
-
old_lines:
|
|
1858
|
-
old_start:
|
|
1941
|
+
z11.object({
|
|
1942
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1943
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1944
|
+
new_lines: z11.number().nullable(),
|
|
1945
|
+
new_start: z11.number().nullable(),
|
|
1946
|
+
old_lines: z11.number().nullable(),
|
|
1947
|
+
old_start: z11.number().nullable()
|
|
1859
1948
|
})
|
|
1860
1949
|
])
|
|
1861
1950
|
)
|
|
1862
1951
|
);
|
|
1863
|
-
var codeExecution_20260120InputSchema = (
|
|
1864
|
-
() => (
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
type:
|
|
1868
|
-
code:
|
|
1952
|
+
var codeExecution_20260120InputSchema = lazySchema10(
|
|
1953
|
+
() => zodSchema10(
|
|
1954
|
+
z11.discriminatedUnion("type", [
|
|
1955
|
+
z11.object({
|
|
1956
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1957
|
+
code: z11.string()
|
|
1869
1958
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1872
|
-
command:
|
|
1959
|
+
z11.object({
|
|
1960
|
+
type: z11.literal("bash_code_execution"),
|
|
1961
|
+
command: z11.string()
|
|
1873
1962
|
}),
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
type:
|
|
1877
|
-
command:
|
|
1878
|
-
path:
|
|
1963
|
+
z11.discriminatedUnion("command", [
|
|
1964
|
+
z11.object({
|
|
1965
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1966
|
+
command: z11.literal("view"),
|
|
1967
|
+
path: z11.string()
|
|
1879
1968
|
}),
|
|
1880
|
-
|
|
1881
|
-
type:
|
|
1882
|
-
command:
|
|
1883
|
-
path:
|
|
1884
|
-
file_text:
|
|
1969
|
+
z11.object({
|
|
1970
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1971
|
+
command: z11.literal("create"),
|
|
1972
|
+
path: z11.string(),
|
|
1973
|
+
file_text: z11.string().nullish()
|
|
1885
1974
|
}),
|
|
1886
|
-
|
|
1887
|
-
type:
|
|
1888
|
-
command:
|
|
1889
|
-
path:
|
|
1890
|
-
old_str:
|
|
1891
|
-
new_str:
|
|
1975
|
+
z11.object({
|
|
1976
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1977
|
+
command: z11.literal("str_replace"),
|
|
1978
|
+
path: z11.string(),
|
|
1979
|
+
old_str: z11.string(),
|
|
1980
|
+
new_str: z11.string()
|
|
1892
1981
|
})
|
|
1893
1982
|
])
|
|
1894
1983
|
])
|
|
1895
1984
|
)
|
|
1896
1985
|
);
|
|
1897
|
-
var factory8 = (
|
|
1986
|
+
var factory8 = createProviderExecutedToolFactory7({
|
|
1898
1987
|
id: "anthropic.code_execution_20260120",
|
|
1899
1988
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1900
1989
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -1905,21 +1994,25 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1905
1994
|
};
|
|
1906
1995
|
|
|
1907
1996
|
// src/tool/tool-search-regex_20251119.ts
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1997
|
+
import {
|
|
1998
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
|
|
1999
|
+
lazySchema as lazySchema11,
|
|
2000
|
+
zodSchema as zodSchema11
|
|
2001
|
+
} from "@ai-sdk/provider-utils";
|
|
2002
|
+
import { z as z12 } from "zod/v4";
|
|
2003
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema11(
|
|
2004
|
+
() => zodSchema11(
|
|
2005
|
+
z12.array(
|
|
2006
|
+
z12.object({
|
|
2007
|
+
type: z12.literal("tool_reference"),
|
|
2008
|
+
toolName: z12.string()
|
|
1916
2009
|
})
|
|
1917
2010
|
)
|
|
1918
2011
|
)
|
|
1919
2012
|
);
|
|
1920
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1921
|
-
() => (
|
|
1922
|
-
|
|
2013
|
+
var toolSearchRegex_20251119InputSchema = lazySchema11(
|
|
2014
|
+
() => zodSchema11(
|
|
2015
|
+
z12.object({
|
|
1923
2016
|
/**
|
|
1924
2017
|
* A regex pattern to search for tools.
|
|
1925
2018
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1930,15 +2023,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1930
2023
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1931
2024
|
* - "(?i)slack" - case-insensitive search
|
|
1932
2025
|
*/
|
|
1933
|
-
pattern:
|
|
2026
|
+
pattern: z12.string(),
|
|
1934
2027
|
/**
|
|
1935
2028
|
* Maximum number of tools to return. Optional.
|
|
1936
2029
|
*/
|
|
1937
|
-
limit:
|
|
2030
|
+
limit: z12.number().optional()
|
|
1938
2031
|
})
|
|
1939
2032
|
)
|
|
1940
2033
|
);
|
|
1941
|
-
var factory9 = (
|
|
2034
|
+
var factory9 = createProviderExecutedToolFactory8({
|
|
1942
2035
|
id: "anthropic.tool_search_regex_20251119",
|
|
1943
2036
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1944
2037
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -1948,40 +2041,21 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1948
2041
|
return factory9(args);
|
|
1949
2042
|
};
|
|
1950
2043
|
|
|
1951
|
-
// src/convert-to-anthropic-
|
|
1952
|
-
function
|
|
2044
|
+
// src/convert-to-anthropic-prompt.ts
|
|
2045
|
+
function convertBytesDataToString(data) {
|
|
1953
2046
|
if (typeof data === "string") {
|
|
1954
|
-
return new TextDecoder().decode(
|
|
1955
|
-
}
|
|
1956
|
-
if (data instanceof Uint8Array) {
|
|
1957
|
-
return new TextDecoder().decode(data);
|
|
1958
|
-
}
|
|
1959
|
-
if (data instanceof URL) {
|
|
1960
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1961
|
-
functionality: "URL-based text documents are not supported for citations"
|
|
1962
|
-
});
|
|
2047
|
+
return new TextDecoder().decode(convertBase64ToUint8Array(data));
|
|
1963
2048
|
}
|
|
1964
|
-
|
|
1965
|
-
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1966
|
-
});
|
|
1967
|
-
}
|
|
1968
|
-
function isUrlData(data) {
|
|
1969
|
-
return data instanceof URL || isUrlString(data);
|
|
2049
|
+
return new TextDecoder().decode(data);
|
|
1970
2050
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
1973
|
-
}
|
|
1974
|
-
function getUrlString(data) {
|
|
1975
|
-
return data instanceof URL ? data.toString() : data;
|
|
1976
|
-
}
|
|
1977
|
-
async function convertToAnthropicMessagesPrompt({
|
|
2051
|
+
async function convertToAnthropicPrompt({
|
|
1978
2052
|
prompt,
|
|
1979
2053
|
sendReasoning,
|
|
1980
2054
|
warnings,
|
|
1981
2055
|
cacheControlValidator,
|
|
1982
2056
|
toolNameMapping
|
|
1983
2057
|
}) {
|
|
1984
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2058
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1985
2059
|
const betas = /* @__PURE__ */ new Set();
|
|
1986
2060
|
const blocks = groupIntoBlocks(prompt);
|
|
1987
2061
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -1989,7 +2063,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1989
2063
|
const messages = [];
|
|
1990
2064
|
async function shouldEnableCitations(providerMetadata) {
|
|
1991
2065
|
var _a2, _b2;
|
|
1992
|
-
const anthropicOptions = await
|
|
2066
|
+
const anthropicOptions = await parseProviderOptions({
|
|
1993
2067
|
provider: "anthropic",
|
|
1994
2068
|
providerOptions: providerMetadata,
|
|
1995
2069
|
schema: anthropicFilePartProviderOptions
|
|
@@ -1997,7 +2071,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1997
2071
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
1998
2072
|
}
|
|
1999
2073
|
async function getDocumentMetadata(providerMetadata) {
|
|
2000
|
-
const anthropicOptions = await
|
|
2074
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2001
2075
|
provider: "anthropic",
|
|
2002
2076
|
providerOptions: providerMetadata,
|
|
2003
2077
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2014,7 +2088,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2014
2088
|
switch (type) {
|
|
2015
2089
|
case "system": {
|
|
2016
2090
|
if (system != null) {
|
|
2017
|
-
throw new
|
|
2091
|
+
throw new UnsupportedFunctionalityError2({
|
|
2018
2092
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2019
2093
|
});
|
|
2020
2094
|
}
|
|
@@ -2054,72 +2128,131 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2054
2128
|
break;
|
|
2055
2129
|
}
|
|
2056
2130
|
case "file": {
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2131
|
+
switch (part.data.type) {
|
|
2132
|
+
case "reference": {
|
|
2133
|
+
const fileId = resolveProviderReference({
|
|
2134
|
+
reference: part.data.reference,
|
|
2135
|
+
provider: "anthropic"
|
|
2136
|
+
});
|
|
2137
|
+
betas.add("files-api-2025-04-14");
|
|
2138
|
+
if (getTopLevelMediaType(part.mediaType) === "image") {
|
|
2139
|
+
anthropicContent.push({
|
|
2140
|
+
type: "image",
|
|
2141
|
+
source: { type: "file", file_id: fileId },
|
|
2142
|
+
cache_control: cacheControl
|
|
2143
|
+
});
|
|
2144
|
+
} else {
|
|
2145
|
+
anthropicContent.push({
|
|
2146
|
+
type: "document",
|
|
2147
|
+
source: { type: "file", file_id: fileId },
|
|
2148
|
+
cache_control: cacheControl
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
break;
|
|
2152
|
+
}
|
|
2153
|
+
case "text": {
|
|
2154
|
+
const enableCitations = await shouldEnableCitations(
|
|
2155
|
+
part.providerOptions
|
|
2156
|
+
);
|
|
2157
|
+
const metadata = await getDocumentMetadata(
|
|
2158
|
+
part.providerOptions
|
|
2159
|
+
);
|
|
2160
|
+
anthropicContent.push({
|
|
2161
|
+
type: "document",
|
|
2162
|
+
source: {
|
|
2163
|
+
type: "text",
|
|
2164
|
+
media_type: "text/plain",
|
|
2165
|
+
data: part.data.text
|
|
2166
|
+
},
|
|
2167
|
+
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2168
|
+
...metadata.context && {
|
|
2169
|
+
context: metadata.context
|
|
2170
|
+
},
|
|
2171
|
+
...enableCitations && {
|
|
2172
|
+
citations: { enabled: true }
|
|
2173
|
+
},
|
|
2174
|
+
cache_control: cacheControl
|
|
2175
|
+
});
|
|
2176
|
+
break;
|
|
2177
|
+
}
|
|
2178
|
+
case "url":
|
|
2179
|
+
case "data": {
|
|
2180
|
+
const topLevel = getTopLevelMediaType(part.mediaType);
|
|
2181
|
+
if (topLevel === "image") {
|
|
2182
|
+
anthropicContent.push({
|
|
2183
|
+
type: "image",
|
|
2184
|
+
source: part.data.type === "url" ? {
|
|
2185
|
+
type: "url",
|
|
2186
|
+
url: part.data.url.toString()
|
|
2187
|
+
} : {
|
|
2188
|
+
type: "base64",
|
|
2189
|
+
media_type: resolveFullMediaType({ part }),
|
|
2190
|
+
data: convertToBase64(part.data.data)
|
|
2191
|
+
},
|
|
2192
|
+
cache_control: cacheControl
|
|
2193
|
+
});
|
|
2194
|
+
} else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
|
|
2195
|
+
betas.add("pdfs-2024-09-25");
|
|
2196
|
+
const enableCitations = await shouldEnableCitations(
|
|
2197
|
+
part.providerOptions
|
|
2198
|
+
);
|
|
2199
|
+
const metadata = await getDocumentMetadata(
|
|
2200
|
+
part.providerOptions
|
|
2201
|
+
);
|
|
2202
|
+
anthropicContent.push({
|
|
2203
|
+
type: "document",
|
|
2204
|
+
source: part.data.type === "url" ? {
|
|
2205
|
+
type: "url",
|
|
2206
|
+
url: part.data.url.toString()
|
|
2207
|
+
} : {
|
|
2208
|
+
type: "base64",
|
|
2209
|
+
media_type: "application/pdf",
|
|
2210
|
+
data: convertToBase64(part.data.data)
|
|
2211
|
+
},
|
|
2212
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
2213
|
+
...metadata.context && {
|
|
2214
|
+
context: metadata.context
|
|
2215
|
+
},
|
|
2216
|
+
...enableCitations && {
|
|
2217
|
+
citations: { enabled: true }
|
|
2218
|
+
},
|
|
2219
|
+
cache_control: cacheControl
|
|
2220
|
+
});
|
|
2221
|
+
} else if (part.mediaType === "text/plain") {
|
|
2222
|
+
const enableCitations = await shouldEnableCitations(
|
|
2223
|
+
part.providerOptions
|
|
2224
|
+
);
|
|
2225
|
+
const metadata = await getDocumentMetadata(
|
|
2226
|
+
part.providerOptions
|
|
2227
|
+
);
|
|
2228
|
+
anthropicContent.push({
|
|
2229
|
+
type: "document",
|
|
2230
|
+
source: part.data.type === "url" ? {
|
|
2231
|
+
type: "url",
|
|
2232
|
+
url: part.data.url.toString()
|
|
2233
|
+
} : {
|
|
2234
|
+
type: "text",
|
|
2235
|
+
media_type: "text/plain",
|
|
2236
|
+
data: convertBytesDataToString(
|
|
2237
|
+
part.data.data
|
|
2238
|
+
)
|
|
2239
|
+
},
|
|
2240
|
+
title: (_d = metadata.title) != null ? _d : part.filename,
|
|
2241
|
+
...metadata.context && {
|
|
2242
|
+
context: metadata.context
|
|
2243
|
+
},
|
|
2244
|
+
...enableCitations && {
|
|
2245
|
+
citations: { enabled: true }
|
|
2246
|
+
},
|
|
2247
|
+
cache_control: cacheControl
|
|
2248
|
+
});
|
|
2249
|
+
} else {
|
|
2250
|
+
throw new UnsupportedFunctionalityError2({
|
|
2251
|
+
functionality: `media type: ${part.mediaType}`
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
break;
|
|
2255
|
+
}
|
|
2123
2256
|
}
|
|
2124
2257
|
break;
|
|
2125
2258
|
}
|
|
@@ -2134,10 +2267,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2134
2267
|
continue;
|
|
2135
2268
|
}
|
|
2136
2269
|
const isLastPart = i2 === content.length - 1;
|
|
2137
|
-
const cacheControl = (
|
|
2270
|
+
const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
|
|
2138
2271
|
type: "tool result part",
|
|
2139
2272
|
canCache: true
|
|
2140
|
-
})) != null ?
|
|
2273
|
+
})) != null ? _e : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
2141
2274
|
type: "tool result message",
|
|
2142
2275
|
canCache: true
|
|
2143
2276
|
}) : void 0;
|
|
@@ -2153,26 +2286,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2153
2286
|
type: "text",
|
|
2154
2287
|
text: contentPart.text
|
|
2155
2288
|
};
|
|
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
2289
|
case "file-url": {
|
|
2290
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2291
|
+
return {
|
|
2292
|
+
type: "image",
|
|
2293
|
+
source: {
|
|
2294
|
+
type: "url",
|
|
2295
|
+
url: contentPart.url
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2176
2299
|
return {
|
|
2177
2300
|
type: "document",
|
|
2178
2301
|
source: {
|
|
@@ -2182,6 +2305,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2182
2305
|
};
|
|
2183
2306
|
}
|
|
2184
2307
|
case "file-data": {
|
|
2308
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2309
|
+
return {
|
|
2310
|
+
type: "image",
|
|
2311
|
+
source: {
|
|
2312
|
+
type: "base64",
|
|
2313
|
+
media_type: contentPart.mediaType,
|
|
2314
|
+
data: contentPart.data
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2185
2318
|
if (contentPart.mediaType === "application/pdf") {
|
|
2186
2319
|
betas.add("pdfs-2024-09-25");
|
|
2187
2320
|
return {
|
|
@@ -2221,14 +2354,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2221
2354
|
return void 0;
|
|
2222
2355
|
}
|
|
2223
2356
|
}
|
|
2224
|
-
}).filter(
|
|
2357
|
+
}).filter(isNonNullable);
|
|
2225
2358
|
break;
|
|
2226
2359
|
case "text":
|
|
2227
2360
|
case "error-text":
|
|
2228
2361
|
contentValue = output.value;
|
|
2229
2362
|
break;
|
|
2230
2363
|
case "execution-denied":
|
|
2231
|
-
contentValue = (
|
|
2364
|
+
contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
|
|
2232
2365
|
break;
|
|
2233
2366
|
case "json":
|
|
2234
2367
|
case "error-json":
|
|
@@ -2265,16 +2398,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2265
2398
|
for (let k = 0; k < content.length; k++) {
|
|
2266
2399
|
const part = content[k];
|
|
2267
2400
|
const isLastContentPart = k === content.length - 1;
|
|
2268
|
-
const cacheControl = (
|
|
2401
|
+
const cacheControl = (_g = validator.getCacheControl(part.providerOptions, {
|
|
2269
2402
|
type: "assistant message part",
|
|
2270
2403
|
canCache: true
|
|
2271
|
-
})) != null ?
|
|
2404
|
+
})) != null ? _g : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
|
|
2272
2405
|
type: "assistant message",
|
|
2273
2406
|
canCache: true
|
|
2274
2407
|
}) : void 0;
|
|
2275
2408
|
switch (part.type) {
|
|
2276
2409
|
case "text": {
|
|
2277
|
-
const textMetadata = (
|
|
2410
|
+
const textMetadata = (_h = part.providerOptions) == null ? void 0 : _h.anthropic;
|
|
2278
2411
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
2279
2412
|
anthropicContent.push({
|
|
2280
2413
|
type: "compaction",
|
|
@@ -2297,7 +2430,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2297
2430
|
}
|
|
2298
2431
|
case "reasoning": {
|
|
2299
2432
|
if (sendReasoning) {
|
|
2300
|
-
const reasoningMetadata = await
|
|
2433
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2301
2434
|
provider: "anthropic",
|
|
2302
2435
|
providerOptions: part.providerOptions,
|
|
2303
2436
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2347,10 +2480,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2347
2480
|
const providerToolName = toolNameMapping.toProviderToolName(
|
|
2348
2481
|
part.toolName
|
|
2349
2482
|
);
|
|
2350
|
-
const isMcpToolUse = ((
|
|
2483
|
+
const isMcpToolUse = ((_j = (_i = part.providerOptions) == null ? void 0 : _i.anthropic) == null ? void 0 : _j.type) === "mcp-tool-use";
|
|
2351
2484
|
if (isMcpToolUse) {
|
|
2352
2485
|
mcpToolUseIds.add(part.toolCallId);
|
|
2353
|
-
const serverName = (
|
|
2486
|
+
const serverName = (_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.serverName;
|
|
2354
2487
|
if (serverName == null || typeof serverName !== "string") {
|
|
2355
2488
|
warnings.push({
|
|
2356
2489
|
type: "other",
|
|
@@ -2418,7 +2551,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2418
2551
|
}
|
|
2419
2552
|
break;
|
|
2420
2553
|
}
|
|
2421
|
-
const callerOptions = (
|
|
2554
|
+
const callerOptions = (_m = part.providerOptions) == null ? void 0 : _m.anthropic;
|
|
2422
2555
|
const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
2423
2556
|
type: callerOptions.caller.type,
|
|
2424
2557
|
tool_id: callerOptions.caller.toolId
|
|
@@ -2471,7 +2604,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2471
2604
|
tool_use_id: part.toolCallId,
|
|
2472
2605
|
content: {
|
|
2473
2606
|
type: "code_execution_tool_result_error",
|
|
2474
|
-
error_code: (
|
|
2607
|
+
error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
|
|
2475
2608
|
},
|
|
2476
2609
|
cache_control: cacheControl
|
|
2477
2610
|
});
|
|
@@ -2482,7 +2615,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2482
2615
|
cache_control: cacheControl,
|
|
2483
2616
|
content: {
|
|
2484
2617
|
type: "bash_code_execution_tool_result_error",
|
|
2485
|
-
error_code: (
|
|
2618
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
2486
2619
|
}
|
|
2487
2620
|
});
|
|
2488
2621
|
}
|
|
@@ -2503,7 +2636,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2503
2636
|
break;
|
|
2504
2637
|
}
|
|
2505
2638
|
if (output.value.type === "code_execution_result") {
|
|
2506
|
-
const codeExecutionOutput = await (
|
|
2639
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2507
2640
|
value: output.value,
|
|
2508
2641
|
schema: codeExecution_20250522OutputSchema
|
|
2509
2642
|
});
|
|
@@ -2515,12 +2648,12 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2515
2648
|
stdout: codeExecutionOutput.stdout,
|
|
2516
2649
|
stderr: codeExecutionOutput.stderr,
|
|
2517
2650
|
return_code: codeExecutionOutput.return_code,
|
|
2518
|
-
content: (
|
|
2651
|
+
content: (_p = codeExecutionOutput.content) != null ? _p : []
|
|
2519
2652
|
},
|
|
2520
2653
|
cache_control: cacheControl
|
|
2521
2654
|
});
|
|
2522
2655
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2523
|
-
const codeExecutionOutput = await (
|
|
2656
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2524
2657
|
value: output.value,
|
|
2525
2658
|
schema: codeExecution_20260120OutputSchema
|
|
2526
2659
|
});
|
|
@@ -2533,13 +2666,13 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2533
2666
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
2534
2667
|
stderr: codeExecutionOutput.stderr,
|
|
2535
2668
|
return_code: codeExecutionOutput.return_code,
|
|
2536
|
-
content: (
|
|
2669
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
2537
2670
|
},
|
|
2538
2671
|
cache_control: cacheControl
|
|
2539
2672
|
});
|
|
2540
2673
|
}
|
|
2541
2674
|
} else {
|
|
2542
|
-
const codeExecutionOutput = await (
|
|
2675
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2543
2676
|
value: output.value,
|
|
2544
2677
|
schema: codeExecution_20250825OutputSchema
|
|
2545
2678
|
});
|
|
@@ -2552,7 +2685,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2552
2685
|
stdout: codeExecutionOutput.stdout,
|
|
2553
2686
|
stderr: codeExecutionOutput.stderr,
|
|
2554
2687
|
return_code: codeExecutionOutput.return_code,
|
|
2555
|
-
content: (
|
|
2688
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
2556
2689
|
},
|
|
2557
2690
|
cache_control: cacheControl
|
|
2558
2691
|
});
|
|
@@ -2585,7 +2718,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2585
2718
|
errorValue = output.value;
|
|
2586
2719
|
}
|
|
2587
2720
|
} catch (e) {
|
|
2588
|
-
const extractedErrorCode = (
|
|
2721
|
+
const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
|
|
2589
2722
|
errorValue = {
|
|
2590
2723
|
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2591
2724
|
};
|
|
@@ -2595,7 +2728,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2595
2728
|
tool_use_id: part.toolCallId,
|
|
2596
2729
|
content: {
|
|
2597
2730
|
type: "web_fetch_tool_result_error",
|
|
2598
|
-
error_code: (
|
|
2731
|
+
error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
|
|
2599
2732
|
},
|
|
2600
2733
|
cache_control: cacheControl
|
|
2601
2734
|
});
|
|
@@ -2608,7 +2741,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2608
2741
|
});
|
|
2609
2742
|
break;
|
|
2610
2743
|
}
|
|
2611
|
-
const webFetchOutput = await (
|
|
2744
|
+
const webFetchOutput = await validateTypes2({
|
|
2612
2745
|
value: output.value,
|
|
2613
2746
|
schema: webFetch_20250910OutputSchema
|
|
2614
2747
|
});
|
|
@@ -2643,7 +2776,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2643
2776
|
});
|
|
2644
2777
|
break;
|
|
2645
2778
|
}
|
|
2646
|
-
const webSearchOutput = await (
|
|
2779
|
+
const webSearchOutput = await validateTypes2({
|
|
2647
2780
|
value: output.value,
|
|
2648
2781
|
schema: webSearch_20250305OutputSchema
|
|
2649
2782
|
});
|
|
@@ -2670,7 +2803,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2670
2803
|
});
|
|
2671
2804
|
break;
|
|
2672
2805
|
}
|
|
2673
|
-
const toolSearchOutput = await (
|
|
2806
|
+
const toolSearchOutput = await validateTypes2({
|
|
2674
2807
|
value: output.value,
|
|
2675
2808
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2676
2809
|
});
|
|
@@ -2783,7 +2916,153 @@ function mapAnthropicStopReason({
|
|
|
2783
2916
|
}
|
|
2784
2917
|
}
|
|
2785
2918
|
|
|
2786
|
-
// src/
|
|
2919
|
+
// src/sanitize-json-schema.ts
|
|
2920
|
+
var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
2921
|
+
"date-time",
|
|
2922
|
+
"time",
|
|
2923
|
+
"date",
|
|
2924
|
+
"duration",
|
|
2925
|
+
"email",
|
|
2926
|
+
"hostname",
|
|
2927
|
+
"uri",
|
|
2928
|
+
"ipv4",
|
|
2929
|
+
"ipv6",
|
|
2930
|
+
"uuid"
|
|
2931
|
+
]);
|
|
2932
|
+
var DESCRIPTION_CONSTRAINT_KEYS = [
|
|
2933
|
+
"minimum",
|
|
2934
|
+
"maximum",
|
|
2935
|
+
"exclusiveMinimum",
|
|
2936
|
+
"exclusiveMaximum",
|
|
2937
|
+
"multipleOf",
|
|
2938
|
+
"minLength",
|
|
2939
|
+
"maxLength",
|
|
2940
|
+
"pattern",
|
|
2941
|
+
"minItems",
|
|
2942
|
+
"maxItems",
|
|
2943
|
+
"uniqueItems",
|
|
2944
|
+
"minProperties",
|
|
2945
|
+
"maxProperties",
|
|
2946
|
+
"not"
|
|
2947
|
+
];
|
|
2948
|
+
function sanitizeJsonSchema(schema) {
|
|
2949
|
+
return sanitizeSchema(schema);
|
|
2950
|
+
}
|
|
2951
|
+
function sanitizeDefinition(definition) {
|
|
2952
|
+
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
2953
|
+
return definition;
|
|
2954
|
+
}
|
|
2955
|
+
return sanitizeSchema(definition);
|
|
2956
|
+
}
|
|
2957
|
+
function sanitizeSchema(schema) {
|
|
2958
|
+
const result = {};
|
|
2959
|
+
const schemaWithDefs = schema;
|
|
2960
|
+
if (schema.$ref != null) {
|
|
2961
|
+
return { $ref: schema.$ref };
|
|
2962
|
+
}
|
|
2963
|
+
if (schema.$schema != null) {
|
|
2964
|
+
result.$schema = schema.$schema;
|
|
2965
|
+
}
|
|
2966
|
+
if (schema.$id != null) {
|
|
2967
|
+
result.$id = schema.$id;
|
|
2968
|
+
}
|
|
2969
|
+
if (schema.title != null) {
|
|
2970
|
+
result.title = schema.title;
|
|
2971
|
+
}
|
|
2972
|
+
if (schema.description != null) {
|
|
2973
|
+
result.description = schema.description;
|
|
2974
|
+
}
|
|
2975
|
+
if (schema.default !== void 0) {
|
|
2976
|
+
result.default = schema.default;
|
|
2977
|
+
}
|
|
2978
|
+
if (schema.const !== void 0) {
|
|
2979
|
+
result.const = schema.const;
|
|
2980
|
+
}
|
|
2981
|
+
if (schema.enum != null) {
|
|
2982
|
+
result.enum = schema.enum;
|
|
2983
|
+
}
|
|
2984
|
+
if (schema.type != null) {
|
|
2985
|
+
result.type = schema.type;
|
|
2986
|
+
}
|
|
2987
|
+
if (schema.anyOf != null) {
|
|
2988
|
+
result.anyOf = schema.anyOf.map(sanitizeDefinition);
|
|
2989
|
+
} else if (schema.oneOf != null) {
|
|
2990
|
+
result.anyOf = schema.oneOf.map(sanitizeDefinition);
|
|
2991
|
+
}
|
|
2992
|
+
if (schema.allOf != null) {
|
|
2993
|
+
result.allOf = schema.allOf.map(sanitizeDefinition);
|
|
2994
|
+
}
|
|
2995
|
+
if (schema.definitions != null) {
|
|
2996
|
+
result.definitions = Object.fromEntries(
|
|
2997
|
+
Object.entries(schema.definitions).map(([name, definition]) => [
|
|
2998
|
+
name,
|
|
2999
|
+
sanitizeDefinition(definition)
|
|
3000
|
+
])
|
|
3001
|
+
);
|
|
3002
|
+
}
|
|
3003
|
+
if (schemaWithDefs.$defs != null) {
|
|
3004
|
+
const resultWithDefs = result;
|
|
3005
|
+
resultWithDefs.$defs = Object.fromEntries(
|
|
3006
|
+
Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
|
|
3007
|
+
name,
|
|
3008
|
+
sanitizeDefinition(definition)
|
|
3009
|
+
])
|
|
3010
|
+
);
|
|
3011
|
+
}
|
|
3012
|
+
if (schema.type === "object" || schema.properties != null) {
|
|
3013
|
+
if (schema.properties != null) {
|
|
3014
|
+
result.properties = Object.fromEntries(
|
|
3015
|
+
Object.entries(schema.properties).map(([name, definition]) => [
|
|
3016
|
+
name,
|
|
3017
|
+
sanitizeDefinition(definition)
|
|
3018
|
+
])
|
|
3019
|
+
);
|
|
3020
|
+
}
|
|
3021
|
+
result.additionalProperties = false;
|
|
3022
|
+
if (schema.required != null) {
|
|
3023
|
+
result.required = schema.required;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
if (schema.items != null) {
|
|
3027
|
+
result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
|
|
3028
|
+
}
|
|
3029
|
+
if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3030
|
+
result.format = schema.format;
|
|
3031
|
+
}
|
|
3032
|
+
const constraintDescription = getConstraintDescription(schema);
|
|
3033
|
+
if (constraintDescription != null) {
|
|
3034
|
+
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
3035
|
+
${constraintDescription}`;
|
|
3036
|
+
}
|
|
3037
|
+
return result;
|
|
3038
|
+
}
|
|
3039
|
+
function getConstraintDescription(schema) {
|
|
3040
|
+
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
3041
|
+
const value = schema[key];
|
|
3042
|
+
if (value == null || value === false) {
|
|
3043
|
+
return [];
|
|
3044
|
+
}
|
|
3045
|
+
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
3046
|
+
});
|
|
3047
|
+
if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3048
|
+
descriptions.push(`format: ${schema.format}`);
|
|
3049
|
+
}
|
|
3050
|
+
return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
|
|
3051
|
+
}
|
|
3052
|
+
function formatConstraintName(key) {
|
|
3053
|
+
return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
|
|
3054
|
+
}
|
|
3055
|
+
function formatConstraintValue(value) {
|
|
3056
|
+
if (typeof value === "string") {
|
|
3057
|
+
return value;
|
|
3058
|
+
}
|
|
3059
|
+
return JSON.stringify(value);
|
|
3060
|
+
}
|
|
3061
|
+
function isPlainObject(value) {
|
|
3062
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// src/anthropic-language-model.ts
|
|
2787
3066
|
function createCitationSource(citation, citationDocuments, generateId2) {
|
|
2788
3067
|
var _a;
|
|
2789
3068
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2828,13 +3107,22 @@ function createCitationSource(citation, citationDocuments, generateId2) {
|
|
|
2828
3107
|
}
|
|
2829
3108
|
};
|
|
2830
3109
|
}
|
|
2831
|
-
var
|
|
3110
|
+
var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
2832
3111
|
constructor(modelId, config) {
|
|
2833
3112
|
this.specificationVersion = "v4";
|
|
2834
3113
|
var _a;
|
|
2835
3114
|
this.modelId = modelId;
|
|
2836
3115
|
this.config = config;
|
|
2837
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3116
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3117
|
+
}
|
|
3118
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3119
|
+
return serializeModelOptions({
|
|
3120
|
+
modelId: model.modelId,
|
|
3121
|
+
config: model.config
|
|
3122
|
+
});
|
|
3123
|
+
}
|
|
3124
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3125
|
+
return new _AnthropicLanguageModel(options.modelId, options.config);
|
|
2838
3126
|
}
|
|
2839
3127
|
supportsUrl(url) {
|
|
2840
3128
|
return url.protocol === "https:";
|
|
@@ -2869,10 +3157,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2869
3157
|
seed,
|
|
2870
3158
|
tools,
|
|
2871
3159
|
toolChoice,
|
|
3160
|
+
reasoning,
|
|
2872
3161
|
providerOptions,
|
|
2873
3162
|
stream
|
|
2874
3163
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3164
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2876
3165
|
const warnings = [];
|
|
2877
3166
|
if (frequencyPenalty != null) {
|
|
2878
3167
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2908,12 +3197,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2908
3197
|
}
|
|
2909
3198
|
}
|
|
2910
3199
|
const providerOptionsName = this.providerOptionsName;
|
|
2911
|
-
const canonicalOptions = await (
|
|
3200
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2912
3201
|
provider: "anthropic",
|
|
2913
3202
|
providerOptions,
|
|
2914
3203
|
schema: anthropicLanguageModelOptions
|
|
2915
3204
|
});
|
|
2916
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3205
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2917
3206
|
provider: providerOptionsName,
|
|
2918
3207
|
providerOptions,
|
|
2919
3208
|
schema: anthropicLanguageModelOptions
|
|
@@ -2927,8 +3216,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
3216
|
const {
|
|
2928
3217
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2929
3218
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3219
|
+
supportsAdaptiveThinking,
|
|
3220
|
+
rejectsSamplingParameters,
|
|
3221
|
+
supportsXhighEffort,
|
|
2930
3222
|
isKnownModel
|
|
2931
3223
|
} = getModelCapabilities(this.modelId);
|
|
3224
|
+
if (rejectsSamplingParameters) {
|
|
3225
|
+
if (temperature != null) {
|
|
3226
|
+
warnings.push({
|
|
3227
|
+
type: "unsupported",
|
|
3228
|
+
feature: "temperature",
|
|
3229
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3230
|
+
});
|
|
3231
|
+
temperature = void 0;
|
|
3232
|
+
}
|
|
3233
|
+
if (topK != null) {
|
|
3234
|
+
warnings.push({
|
|
3235
|
+
type: "unsupported",
|
|
3236
|
+
feature: "topK",
|
|
3237
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3238
|
+
});
|
|
3239
|
+
topK = void 0;
|
|
3240
|
+
}
|
|
3241
|
+
if (topP != null) {
|
|
3242
|
+
warnings.push({
|
|
3243
|
+
type: "unsupported",
|
|
3244
|
+
feature: "topP",
|
|
3245
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3246
|
+
});
|
|
3247
|
+
topP = void 0;
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2932
3251
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
3252
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2934
3253
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -2941,7 +3260,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2941
3260
|
} : void 0;
|
|
2942
3261
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2943
3262
|
const cacheControlValidator = new CacheControlValidator();
|
|
2944
|
-
const toolNameMapping =
|
|
3263
|
+
const toolNameMapping = createToolNameMapping({
|
|
2945
3264
|
tools,
|
|
2946
3265
|
providerToolNames: {
|
|
2947
3266
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2964,16 +3283,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2964
3283
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
2965
3284
|
}
|
|
2966
3285
|
});
|
|
2967
|
-
const { prompt: messagesPrompt, betas } = await
|
|
3286
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
2968
3287
|
prompt,
|
|
2969
3288
|
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2970
3289
|
warnings,
|
|
2971
3290
|
cacheControlValidator,
|
|
2972
3291
|
toolNameMapping
|
|
2973
3292
|
});
|
|
2974
|
-
|
|
3293
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3294
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3295
|
+
reasoning,
|
|
3296
|
+
supportsAdaptiveThinking,
|
|
3297
|
+
supportsXhighEffort,
|
|
3298
|
+
maxOutputTokensForModel,
|
|
3299
|
+
warnings
|
|
3300
|
+
});
|
|
3301
|
+
if (reasoningConfig != null) {
|
|
3302
|
+
if (anthropicOptions.thinking == null) {
|
|
3303
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3304
|
+
}
|
|
3305
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3306
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
2975
3311
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2976
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3312
|
+
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3313
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
2977
3314
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2978
3315
|
const baseArgs = {
|
|
2979
3316
|
// model id:
|
|
@@ -2988,18 +3325,28 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2988
3325
|
...isThinking && {
|
|
2989
3326
|
thinking: {
|
|
2990
3327
|
type: thinkingType,
|
|
2991
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3328
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3329
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2992
3330
|
}
|
|
2993
3331
|
},
|
|
2994
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3332
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2995
3333
|
output_config: {
|
|
2996
3334
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2997
3335
|
effort: anthropicOptions.effort
|
|
2998
3336
|
},
|
|
3337
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3338
|
+
task_budget: {
|
|
3339
|
+
type: anthropicOptions.taskBudget.type,
|
|
3340
|
+
total: anthropicOptions.taskBudget.total,
|
|
3341
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3342
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
},
|
|
2999
3346
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
3000
3347
|
format: {
|
|
3001
3348
|
type: "json_schema",
|
|
3002
|
-
schema: responseFormat.schema
|
|
3349
|
+
schema: sanitizeJsonSchema(responseFormat.schema)
|
|
3003
3350
|
}
|
|
3004
3351
|
}
|
|
3005
3352
|
}
|
|
@@ -3007,9 +3354,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3007
3354
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3008
3355
|
speed: anthropicOptions.speed
|
|
3009
3356
|
},
|
|
3357
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3358
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3359
|
+
},
|
|
3010
3360
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3011
3361
|
cache_control: anthropicOptions.cacheControl
|
|
3012
3362
|
},
|
|
3363
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3364
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3365
|
+
},
|
|
3013
3366
|
// mcp servers:
|
|
3014
3367
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3015
3368
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3031,7 +3384,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3031
3384
|
id: anthropicOptions.container.id,
|
|
3032
3385
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3033
3386
|
type: skill.type,
|
|
3034
|
-
skill_id: skill.
|
|
3387
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3388
|
+
reference: skill.providerReference,
|
|
3389
|
+
provider: "anthropic"
|
|
3390
|
+
}) : skill.skillId,
|
|
3035
3391
|
version: skill.version
|
|
3036
3392
|
}))
|
|
3037
3393
|
}
|
|
@@ -3133,7 +3489,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3133
3489
|
}
|
|
3134
3490
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3135
3491
|
} else {
|
|
3136
|
-
if (topP != null && temperature != null) {
|
|
3492
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3137
3493
|
warnings.push({
|
|
3138
3494
|
type: "unsupported",
|
|
3139
3495
|
feature: "topP",
|
|
@@ -3177,12 +3533,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3177
3533
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3178
3534
|
betas.add("effort-2025-11-24");
|
|
3179
3535
|
}
|
|
3536
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3537
|
+
betas.add("task-budgets-2026-03-13");
|
|
3538
|
+
}
|
|
3180
3539
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3181
3540
|
betas.add("fast-mode-2026-02-01");
|
|
3182
3541
|
}
|
|
3183
|
-
|
|
3184
|
-
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3185
|
-
}
|
|
3542
|
+
const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
|
|
3186
3543
|
const {
|
|
3187
3544
|
tools: anthropicTools2,
|
|
3188
3545
|
toolChoice: anthropicToolChoice,
|
|
@@ -3195,14 +3552,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3195
3552
|
disableParallelToolUse: true,
|
|
3196
3553
|
cacheControlValidator,
|
|
3197
3554
|
supportsStructuredOutput: false,
|
|
3198
|
-
supportsStrictTools
|
|
3555
|
+
supportsStrictTools,
|
|
3556
|
+
defaultEagerInputStreaming
|
|
3199
3557
|
} : {
|
|
3200
3558
|
tools: tools != null ? tools : [],
|
|
3201
3559
|
toolChoice,
|
|
3202
3560
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3203
3561
|
cacheControlValidator,
|
|
3204
3562
|
supportsStructuredOutput,
|
|
3205
|
-
supportsStrictTools
|
|
3563
|
+
supportsStrictTools,
|
|
3564
|
+
defaultEagerInputStreaming
|
|
3206
3565
|
}
|
|
3207
3566
|
);
|
|
3208
3567
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3219,7 +3578,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3219
3578
|
...betas,
|
|
3220
3579
|
...toolsBetas,
|
|
3221
3580
|
...userSuppliedBetas,
|
|
3222
|
-
...(
|
|
3581
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3223
3582
|
]),
|
|
3224
3583
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3225
3584
|
toolNameMapping,
|
|
@@ -3231,16 +3590,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3231
3590
|
betas,
|
|
3232
3591
|
headers
|
|
3233
3592
|
}) {
|
|
3234
|
-
return
|
|
3235
|
-
await
|
|
3593
|
+
return combineHeaders(
|
|
3594
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3236
3595
|
headers,
|
|
3237
3596
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3238
3597
|
);
|
|
3239
3598
|
}
|
|
3240
3599
|
async getBetasFromHeaders(requestHeaders) {
|
|
3241
3600
|
var _a, _b;
|
|
3242
|
-
const configHeaders = await
|
|
3243
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3601
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3602
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3244
3603
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3245
3604
|
return new Set(
|
|
3246
3605
|
[
|
|
@@ -3305,13 +3664,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3305
3664
|
responseHeaders,
|
|
3306
3665
|
value: response,
|
|
3307
3666
|
rawValue: rawResponse
|
|
3308
|
-
} = await
|
|
3667
|
+
} = await postJsonToApi({
|
|
3309
3668
|
url: this.buildRequestUrl(false),
|
|
3310
3669
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3311
3670
|
body: this.transformRequestBody(args, betas),
|
|
3312
3671
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3313
|
-
successfulResponseHandler:
|
|
3314
|
-
|
|
3672
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
3673
|
+
anthropicResponseSchema
|
|
3315
3674
|
),
|
|
3316
3675
|
abortSignal: options.abortSignal,
|
|
3317
3676
|
fetch: this.config.fetch
|
|
@@ -3660,7 +4019,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3660
4019
|
}),
|
|
3661
4020
|
raw: (_e = response.stop_reason) != null ? _e : void 0
|
|
3662
4021
|
},
|
|
3663
|
-
usage:
|
|
4022
|
+
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
3664
4023
|
request: { body: args },
|
|
3665
4024
|
response: {
|
|
3666
4025
|
id: (_f = response.id) != null ? _f : void 0,
|
|
@@ -3670,11 +4029,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3670
4029
|
},
|
|
3671
4030
|
warnings,
|
|
3672
4031
|
providerMetadata: (() => {
|
|
3673
|
-
var _a2, _b2, _c2, _d2
|
|
4032
|
+
var _a2, _b2, _c2, _d2;
|
|
3674
4033
|
const anthropicMetadata = {
|
|
3675
4034
|
usage: response.usage,
|
|
3676
|
-
|
|
3677
|
-
stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
|
|
4035
|
+
stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
|
|
3678
4036
|
iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
|
|
3679
4037
|
type: iter.type,
|
|
3680
4038
|
inputTokens: iter.input_tokens,
|
|
@@ -3683,15 +4041,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3683
4041
|
container: response.container ? {
|
|
3684
4042
|
expiresAt: response.container.expires_at,
|
|
3685
4043
|
id: response.container.id,
|
|
3686
|
-
skills: (
|
|
4044
|
+
skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
|
|
3687
4045
|
type: skill.type,
|
|
3688
4046
|
skillId: skill.skill_id,
|
|
3689
4047
|
version: skill.version
|
|
3690
|
-
}))) != null ?
|
|
4048
|
+
}))) != null ? _c2 : null
|
|
3691
4049
|
} : null,
|
|
3692
|
-
contextManagement: (
|
|
4050
|
+
contextManagement: (_d2 = mapAnthropicResponseContextManagement(
|
|
3693
4051
|
response.context_management
|
|
3694
|
-
)) != null ?
|
|
4052
|
+
)) != null ? _d2 : null
|
|
3695
4053
|
};
|
|
3696
4054
|
const providerMetadata = {
|
|
3697
4055
|
anthropic: anthropicMetadata
|
|
@@ -3704,6 +4062,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3704
4062
|
};
|
|
3705
4063
|
}
|
|
3706
4064
|
async doStream(options) {
|
|
4065
|
+
"use step";
|
|
3707
4066
|
var _a, _b;
|
|
3708
4067
|
const {
|
|
3709
4068
|
args: body,
|
|
@@ -3725,14 +4084,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3725
4084
|
body.tools
|
|
3726
4085
|
);
|
|
3727
4086
|
const url = this.buildRequestUrl(true);
|
|
3728
|
-
const { responseHeaders, value: response } = await
|
|
4087
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3729
4088
|
url,
|
|
3730
4089
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3731
4090
|
body: this.transformRequestBody(body, betas),
|
|
3732
4091
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3733
|
-
successfulResponseHandler: (
|
|
3734
|
-
anthropicMessagesChunkSchema
|
|
3735
|
-
),
|
|
4092
|
+
successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
|
|
3736
4093
|
abortSignal: options.abortSignal,
|
|
3737
4094
|
fetch: this.config.fetch
|
|
3738
4095
|
});
|
|
@@ -3752,7 +4109,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3752
4109
|
const serverToolCalls = {};
|
|
3753
4110
|
let contextManagement = null;
|
|
3754
4111
|
let rawUsage = void 0;
|
|
3755
|
-
let cacheCreationInputTokens = null;
|
|
3756
4112
|
let stopSequence = null;
|
|
3757
4113
|
let container = null;
|
|
3758
4114
|
let isJsonResponseFromTool = false;
|
|
@@ -3764,7 +4120,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3764
4120
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3765
4121
|
},
|
|
3766
4122
|
transform(chunk, controller) {
|
|
3767
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
4123
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3768
4124
|
if (options.includeRawChunks) {
|
|
3769
4125
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3770
4126
|
}
|
|
@@ -4299,7 +4655,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4299
4655
|
rawUsage = {
|
|
4300
4656
|
...value.message.usage
|
|
4301
4657
|
};
|
|
4302
|
-
cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
|
|
4303
4658
|
if (value.message.container != null) {
|
|
4304
4659
|
container = {
|
|
4305
4660
|
expiresAt: value.message.container.expires_at,
|
|
@@ -4318,8 +4673,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4318
4673
|
}
|
|
4319
4674
|
controller.enqueue({
|
|
4320
4675
|
type: "response-metadata",
|
|
4321
|
-
id: (
|
|
4322
|
-
modelId: (
|
|
4676
|
+
id: (_g = value.message.id) != null ? _g : void 0,
|
|
4677
|
+
modelId: (_h = value.message.model) != null ? _h : void 0
|
|
4323
4678
|
});
|
|
4324
4679
|
if (value.message.content != null) {
|
|
4325
4680
|
for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
|
|
@@ -4335,7 +4690,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4335
4690
|
id: part.id,
|
|
4336
4691
|
toolName: part.name
|
|
4337
4692
|
});
|
|
4338
|
-
const inputStr = JSON.stringify((
|
|
4693
|
+
const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
|
|
4339
4694
|
controller.enqueue({
|
|
4340
4695
|
type: "tool-input-delta",
|
|
4341
4696
|
id: part.id,
|
|
@@ -4373,7 +4728,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4373
4728
|
}
|
|
4374
4729
|
if (value.usage.cache_creation_input_tokens != null) {
|
|
4375
4730
|
usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
|
|
4376
|
-
cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
|
|
4377
4731
|
}
|
|
4378
4732
|
if (value.usage.iterations != null) {
|
|
4379
4733
|
usage.iterations = value.usage.iterations;
|
|
@@ -4383,17 +4737,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4383
4737
|
finishReason: value.delta.stop_reason,
|
|
4384
4738
|
isJsonResponseFromTool
|
|
4385
4739
|
}),
|
|
4386
|
-
raw: (
|
|
4740
|
+
raw: (_j = value.delta.stop_reason) != null ? _j : void 0
|
|
4387
4741
|
};
|
|
4388
|
-
stopSequence = (
|
|
4742
|
+
stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
|
|
4389
4743
|
container = value.delta.container != null ? {
|
|
4390
4744
|
expiresAt: value.delta.container.expires_at,
|
|
4391
4745
|
id: value.delta.container.id,
|
|
4392
|
-
skills: (
|
|
4746
|
+
skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
|
|
4393
4747
|
type: skill.type,
|
|
4394
4748
|
skillId: skill.skill_id,
|
|
4395
4749
|
version: skill.version
|
|
4396
|
-
}))) != null ?
|
|
4750
|
+
}))) != null ? _m : null
|
|
4397
4751
|
} : null;
|
|
4398
4752
|
if (value.context_management) {
|
|
4399
4753
|
contextManagement = mapAnthropicResponseContextManagement(
|
|
@@ -4409,7 +4763,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4409
4763
|
case "message_stop": {
|
|
4410
4764
|
const anthropicMetadata = {
|
|
4411
4765
|
usage: rawUsage != null ? rawUsage : null,
|
|
4412
|
-
cacheCreationInputTokens,
|
|
4413
4766
|
stopSequence,
|
|
4414
4767
|
iterations: usage.iterations ? usage.iterations.map((iter) => ({
|
|
4415
4768
|
type: iter.type,
|
|
@@ -4428,7 +4781,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4428
4781
|
controller.enqueue({
|
|
4429
4782
|
type: "finish",
|
|
4430
4783
|
finishReason,
|
|
4431
|
-
usage:
|
|
4784
|
+
usage: convertAnthropicUsage({ usage, rawUsage }),
|
|
4432
4785
|
providerMetadata
|
|
4433
4786
|
});
|
|
4434
4787
|
return;
|
|
@@ -4455,7 +4808,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4455
4808
|
}
|
|
4456
4809
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4457
4810
|
const error = result.value.error;
|
|
4458
|
-
throw new
|
|
4811
|
+
throw new APICallError({
|
|
4459
4812
|
message: error.message,
|
|
4460
4813
|
url,
|
|
4461
4814
|
requestBodyValues: body,
|
|
@@ -4478,46 +4831,76 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4478
4831
|
}
|
|
4479
4832
|
};
|
|
4480
4833
|
function getModelCapabilities(modelId) {
|
|
4481
|
-
if (modelId.includes("claude-
|
|
4834
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4835
|
+
return {
|
|
4836
|
+
maxOutputTokens: 128e3,
|
|
4837
|
+
supportsStructuredOutput: true,
|
|
4838
|
+
supportsAdaptiveThinking: true,
|
|
4839
|
+
rejectsSamplingParameters: true,
|
|
4840
|
+
supportsXhighEffort: true,
|
|
4841
|
+
isKnownModel: true
|
|
4842
|
+
};
|
|
4843
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4482
4844
|
return {
|
|
4483
4845
|
maxOutputTokens: 128e3,
|
|
4484
4846
|
supportsStructuredOutput: true,
|
|
4847
|
+
supportsAdaptiveThinking: true,
|
|
4848
|
+
rejectsSamplingParameters: false,
|
|
4849
|
+
supportsXhighEffort: false,
|
|
4485
4850
|
isKnownModel: true
|
|
4486
4851
|
};
|
|
4487
4852
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4488
4853
|
return {
|
|
4489
4854
|
maxOutputTokens: 64e3,
|
|
4490
4855
|
supportsStructuredOutput: true,
|
|
4856
|
+
supportsAdaptiveThinking: false,
|
|
4857
|
+
rejectsSamplingParameters: false,
|
|
4858
|
+
supportsXhighEffort: false,
|
|
4491
4859
|
isKnownModel: true
|
|
4492
4860
|
};
|
|
4493
4861
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4494
4862
|
return {
|
|
4495
4863
|
maxOutputTokens: 32e3,
|
|
4496
4864
|
supportsStructuredOutput: true,
|
|
4865
|
+
supportsAdaptiveThinking: false,
|
|
4866
|
+
rejectsSamplingParameters: false,
|
|
4867
|
+
supportsXhighEffort: false,
|
|
4497
4868
|
isKnownModel: true
|
|
4498
4869
|
};
|
|
4499
4870
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4500
4871
|
return {
|
|
4501
4872
|
maxOutputTokens: 64e3,
|
|
4502
4873
|
supportsStructuredOutput: false,
|
|
4874
|
+
supportsAdaptiveThinking: false,
|
|
4875
|
+
rejectsSamplingParameters: false,
|
|
4876
|
+
supportsXhighEffort: false,
|
|
4503
4877
|
isKnownModel: true
|
|
4504
4878
|
};
|
|
4505
4879
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4506
4880
|
return {
|
|
4507
4881
|
maxOutputTokens: 32e3,
|
|
4508
4882
|
supportsStructuredOutput: false,
|
|
4883
|
+
supportsAdaptiveThinking: false,
|
|
4884
|
+
rejectsSamplingParameters: false,
|
|
4885
|
+
supportsXhighEffort: false,
|
|
4509
4886
|
isKnownModel: true
|
|
4510
4887
|
};
|
|
4511
4888
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4512
4889
|
return {
|
|
4513
4890
|
maxOutputTokens: 4096,
|
|
4514
4891
|
supportsStructuredOutput: false,
|
|
4892
|
+
supportsAdaptiveThinking: false,
|
|
4893
|
+
rejectsSamplingParameters: false,
|
|
4894
|
+
supportsXhighEffort: false,
|
|
4515
4895
|
isKnownModel: true
|
|
4516
4896
|
};
|
|
4517
4897
|
} else {
|
|
4518
4898
|
return {
|
|
4519
4899
|
maxOutputTokens: 4096,
|
|
4520
4900
|
supportsStructuredOutput: false,
|
|
4901
|
+
supportsAdaptiveThinking: false,
|
|
4902
|
+
rejectsSamplingParameters: false,
|
|
4903
|
+
supportsXhighEffort: false,
|
|
4521
4904
|
isKnownModel: false
|
|
4522
4905
|
};
|
|
4523
4906
|
}
|
|
@@ -4540,6 +4923,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4540
4923
|
}
|
|
4541
4924
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4542
4925
|
}
|
|
4926
|
+
function resolveAnthropicReasoningConfig({
|
|
4927
|
+
reasoning,
|
|
4928
|
+
supportsAdaptiveThinking,
|
|
4929
|
+
supportsXhighEffort,
|
|
4930
|
+
maxOutputTokensForModel,
|
|
4931
|
+
warnings
|
|
4932
|
+
}) {
|
|
4933
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4934
|
+
return void 0;
|
|
4935
|
+
}
|
|
4936
|
+
if (reasoning === "none") {
|
|
4937
|
+
return { thinking: { type: "disabled" } };
|
|
4938
|
+
}
|
|
4939
|
+
if (supportsAdaptiveThinking) {
|
|
4940
|
+
const effort = mapReasoningToProviderEffort({
|
|
4941
|
+
reasoning,
|
|
4942
|
+
effortMap: {
|
|
4943
|
+
minimal: "low",
|
|
4944
|
+
low: "low",
|
|
4945
|
+
medium: "medium",
|
|
4946
|
+
high: "high",
|
|
4947
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
4948
|
+
},
|
|
4949
|
+
warnings
|
|
4950
|
+
});
|
|
4951
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4952
|
+
}
|
|
4953
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4954
|
+
reasoning,
|
|
4955
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4956
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4957
|
+
warnings
|
|
4958
|
+
});
|
|
4959
|
+
if (budgetTokens == null) {
|
|
4960
|
+
return void 0;
|
|
4961
|
+
}
|
|
4962
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4963
|
+
}
|
|
4543
4964
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4544
4965
|
return contextManagement ? {
|
|
4545
4966
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4567,44 +4988,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4567
4988
|
}
|
|
4568
4989
|
|
|
4569
4990
|
// src/tool/bash_20241022.ts
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4991
|
+
import {
|
|
4992
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
4993
|
+
lazySchema as lazySchema12,
|
|
4994
|
+
zodSchema as zodSchema12
|
|
4995
|
+
} from "@ai-sdk/provider-utils";
|
|
4996
|
+
import { z as z13 } from "zod/v4";
|
|
4997
|
+
var bash_20241022InputSchema = lazySchema12(
|
|
4998
|
+
() => zodSchema12(
|
|
4999
|
+
z13.object({
|
|
5000
|
+
command: z13.string(),
|
|
5001
|
+
restart: z13.boolean().optional()
|
|
4577
5002
|
})
|
|
4578
5003
|
)
|
|
4579
5004
|
);
|
|
4580
|
-
var bash_20241022 = (
|
|
5005
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
4581
5006
|
id: "anthropic.bash_20241022",
|
|
4582
5007
|
inputSchema: bash_20241022InputSchema
|
|
4583
5008
|
});
|
|
4584
5009
|
|
|
4585
5010
|
// src/tool/bash_20250124.ts
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
5011
|
+
import {
|
|
5012
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
5013
|
+
lazySchema as lazySchema13,
|
|
5014
|
+
zodSchema as zodSchema13
|
|
5015
|
+
} from "@ai-sdk/provider-utils";
|
|
5016
|
+
import { z as z14 } from "zod/v4";
|
|
5017
|
+
var bash_20250124InputSchema = lazySchema13(
|
|
5018
|
+
() => zodSchema13(
|
|
5019
|
+
z14.object({
|
|
5020
|
+
command: z14.string(),
|
|
5021
|
+
restart: z14.boolean().optional()
|
|
4593
5022
|
})
|
|
4594
5023
|
)
|
|
4595
5024
|
);
|
|
4596
|
-
var bash_20250124 = (
|
|
5025
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
4597
5026
|
id: "anthropic.bash_20250124",
|
|
4598
5027
|
inputSchema: bash_20250124InputSchema
|
|
4599
5028
|
});
|
|
4600
5029
|
|
|
4601
5030
|
// src/tool/computer_20241022.ts
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
5031
|
+
import {
|
|
5032
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
5033
|
+
lazySchema as lazySchema14,
|
|
5034
|
+
zodSchema as zodSchema14
|
|
5035
|
+
} from "@ai-sdk/provider-utils";
|
|
5036
|
+
import { z as z15 } from "zod/v4";
|
|
5037
|
+
var computer_20241022InputSchema = lazySchema14(
|
|
5038
|
+
() => zodSchema14(
|
|
5039
|
+
z15.object({
|
|
5040
|
+
action: z15.enum([
|
|
4608
5041
|
"key",
|
|
4609
5042
|
"type",
|
|
4610
5043
|
"mouse_move",
|
|
@@ -4616,23 +5049,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4616
5049
|
"screenshot",
|
|
4617
5050
|
"cursor_position"
|
|
4618
5051
|
]),
|
|
4619
|
-
coordinate:
|
|
4620
|
-
text:
|
|
5052
|
+
coordinate: z15.array(z15.number().int()).optional(),
|
|
5053
|
+
text: z15.string().optional()
|
|
4621
5054
|
})
|
|
4622
5055
|
)
|
|
4623
5056
|
);
|
|
4624
|
-
var computer_20241022 = (
|
|
5057
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
4625
5058
|
id: "anthropic.computer_20241022",
|
|
4626
5059
|
inputSchema: computer_20241022InputSchema
|
|
4627
5060
|
});
|
|
4628
5061
|
|
|
4629
5062
|
// src/tool/computer_20250124.ts
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
5063
|
+
import {
|
|
5064
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
5065
|
+
lazySchema as lazySchema15,
|
|
5066
|
+
zodSchema as zodSchema15
|
|
5067
|
+
} from "@ai-sdk/provider-utils";
|
|
5068
|
+
import { z as z16 } from "zod/v4";
|
|
5069
|
+
var computer_20250124InputSchema = lazySchema15(
|
|
5070
|
+
() => zodSchema15(
|
|
5071
|
+
z16.object({
|
|
5072
|
+
action: z16.enum([
|
|
4636
5073
|
"key",
|
|
4637
5074
|
"hold_key",
|
|
4638
5075
|
"type",
|
|
@@ -4650,27 +5087,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4650
5087
|
"wait",
|
|
4651
5088
|
"screenshot"
|
|
4652
5089
|
]),
|
|
4653
|
-
coordinate:
|
|
4654
|
-
duration:
|
|
4655
|
-
scroll_amount:
|
|
4656
|
-
scroll_direction:
|
|
4657
|
-
start_coordinate:
|
|
4658
|
-
text:
|
|
5090
|
+
coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
|
|
5091
|
+
duration: z16.number().optional(),
|
|
5092
|
+
scroll_amount: z16.number().optional(),
|
|
5093
|
+
scroll_direction: z16.enum(["up", "down", "left", "right"]).optional(),
|
|
5094
|
+
start_coordinate: z16.tuple([z16.number().int(), z16.number().int()]).optional(),
|
|
5095
|
+
text: z16.string().optional()
|
|
4659
5096
|
})
|
|
4660
5097
|
)
|
|
4661
5098
|
);
|
|
4662
|
-
var computer_20250124 = (
|
|
5099
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
4663
5100
|
id: "anthropic.computer_20250124",
|
|
4664
5101
|
inputSchema: computer_20250124InputSchema
|
|
4665
5102
|
});
|
|
4666
5103
|
|
|
4667
5104
|
// src/tool/computer_20251124.ts
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
5105
|
+
import {
|
|
5106
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
5107
|
+
lazySchema as lazySchema16,
|
|
5108
|
+
zodSchema as zodSchema16
|
|
5109
|
+
} from "@ai-sdk/provider-utils";
|
|
5110
|
+
import { z as z17 } from "zod/v4";
|
|
5111
|
+
var computer_20251124InputSchema = lazySchema16(
|
|
5112
|
+
() => zodSchema16(
|
|
5113
|
+
z17.object({
|
|
5114
|
+
action: z17.enum([
|
|
4674
5115
|
"key",
|
|
4675
5116
|
"hold_key",
|
|
4676
5117
|
"type",
|
|
@@ -4689,166 +5130,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4689
5130
|
"screenshot",
|
|
4690
5131
|
"zoom"
|
|
4691
5132
|
]),
|
|
4692
|
-
coordinate:
|
|
4693
|
-
duration:
|
|
4694
|
-
region:
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
5133
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5134
|
+
duration: z17.number().optional(),
|
|
5135
|
+
region: z17.tuple([
|
|
5136
|
+
z17.number().int(),
|
|
5137
|
+
z17.number().int(),
|
|
5138
|
+
z17.number().int(),
|
|
5139
|
+
z17.number().int()
|
|
4699
5140
|
]).optional(),
|
|
4700
|
-
scroll_amount:
|
|
4701
|
-
scroll_direction:
|
|
4702
|
-
start_coordinate:
|
|
4703
|
-
text:
|
|
5141
|
+
scroll_amount: z17.number().optional(),
|
|
5142
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5143
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5144
|
+
text: z17.string().optional()
|
|
4704
5145
|
})
|
|
4705
5146
|
)
|
|
4706
5147
|
);
|
|
4707
|
-
var computer_20251124 = (
|
|
5148
|
+
var computer_20251124 = createProviderDefinedToolFactory6({
|
|
4708
5149
|
id: "anthropic.computer_20251124",
|
|
4709
5150
|
inputSchema: computer_20251124InputSchema
|
|
4710
5151
|
});
|
|
4711
5152
|
|
|
4712
5153
|
// src/tool/memory_20250818.ts
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
5154
|
+
import {
|
|
5155
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
5156
|
+
lazySchema as lazySchema17,
|
|
5157
|
+
zodSchema as zodSchema17
|
|
5158
|
+
} from "@ai-sdk/provider-utils";
|
|
5159
|
+
import { z as z18 } from "zod/v4";
|
|
5160
|
+
var memory_20250818InputSchema = lazySchema17(
|
|
5161
|
+
() => zodSchema17(
|
|
5162
|
+
z18.discriminatedUnion("command", [
|
|
5163
|
+
z18.object({
|
|
5164
|
+
command: z18.literal("view"),
|
|
5165
|
+
path: z18.string(),
|
|
5166
|
+
view_range: z18.tuple([z18.number(), z18.number()]).optional()
|
|
4722
5167
|
}),
|
|
4723
|
-
|
|
4724
|
-
command:
|
|
4725
|
-
path:
|
|
4726
|
-
file_text:
|
|
5168
|
+
z18.object({
|
|
5169
|
+
command: z18.literal("create"),
|
|
5170
|
+
path: z18.string(),
|
|
5171
|
+
file_text: z18.string()
|
|
4727
5172
|
}),
|
|
4728
|
-
|
|
4729
|
-
command:
|
|
4730
|
-
path:
|
|
4731
|
-
old_str:
|
|
4732
|
-
new_str:
|
|
5173
|
+
z18.object({
|
|
5174
|
+
command: z18.literal("str_replace"),
|
|
5175
|
+
path: z18.string(),
|
|
5176
|
+
old_str: z18.string(),
|
|
5177
|
+
new_str: z18.string()
|
|
4733
5178
|
}),
|
|
4734
|
-
|
|
4735
|
-
command:
|
|
4736
|
-
path:
|
|
4737
|
-
insert_line:
|
|
4738
|
-
insert_text:
|
|
5179
|
+
z18.object({
|
|
5180
|
+
command: z18.literal("insert"),
|
|
5181
|
+
path: z18.string(),
|
|
5182
|
+
insert_line: z18.number(),
|
|
5183
|
+
insert_text: z18.string()
|
|
4739
5184
|
}),
|
|
4740
|
-
|
|
4741
|
-
command:
|
|
4742
|
-
path:
|
|
5185
|
+
z18.object({
|
|
5186
|
+
command: z18.literal("delete"),
|
|
5187
|
+
path: z18.string()
|
|
4743
5188
|
}),
|
|
4744
|
-
|
|
4745
|
-
command:
|
|
4746
|
-
old_path:
|
|
4747
|
-
new_path:
|
|
5189
|
+
z18.object({
|
|
5190
|
+
command: z18.literal("rename"),
|
|
5191
|
+
old_path: z18.string(),
|
|
5192
|
+
new_path: z18.string()
|
|
4748
5193
|
})
|
|
4749
5194
|
])
|
|
4750
5195
|
)
|
|
4751
5196
|
);
|
|
4752
|
-
var memory_20250818 = (
|
|
5197
|
+
var memory_20250818 = createProviderDefinedToolFactory7({
|
|
4753
5198
|
id: "anthropic.memory_20250818",
|
|
4754
5199
|
inputSchema: memory_20250818InputSchema
|
|
4755
5200
|
});
|
|
4756
5201
|
|
|
4757
5202
|
// src/tool/text-editor_20241022.ts
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
5203
|
+
import {
|
|
5204
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
5205
|
+
lazySchema as lazySchema18,
|
|
5206
|
+
zodSchema as zodSchema18
|
|
5207
|
+
} from "@ai-sdk/provider-utils";
|
|
5208
|
+
import { z as z19 } from "zod/v4";
|
|
5209
|
+
var textEditor_20241022InputSchema = lazySchema18(
|
|
5210
|
+
() => zodSchema18(
|
|
5211
|
+
z19.object({
|
|
5212
|
+
command: z19.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5213
|
+
path: z19.string(),
|
|
5214
|
+
file_text: z19.string().optional(),
|
|
5215
|
+
insert_line: z19.number().int().optional(),
|
|
5216
|
+
new_str: z19.string().optional(),
|
|
5217
|
+
insert_text: z19.string().optional(),
|
|
5218
|
+
old_str: z19.string().optional(),
|
|
5219
|
+
view_range: z19.array(z19.number().int()).optional()
|
|
4771
5220
|
})
|
|
4772
5221
|
)
|
|
4773
5222
|
);
|
|
4774
|
-
var textEditor_20241022 = (
|
|
5223
|
+
var textEditor_20241022 = createProviderDefinedToolFactory8({
|
|
4775
5224
|
id: "anthropic.text_editor_20241022",
|
|
4776
5225
|
inputSchema: textEditor_20241022InputSchema
|
|
4777
5226
|
});
|
|
4778
5227
|
|
|
4779
5228
|
// src/tool/text-editor_20250124.ts
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
5229
|
+
import {
|
|
5230
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
5231
|
+
lazySchema as lazySchema19,
|
|
5232
|
+
zodSchema as zodSchema19
|
|
5233
|
+
} from "@ai-sdk/provider-utils";
|
|
5234
|
+
import { z as z20 } from "zod/v4";
|
|
5235
|
+
var textEditor_20250124InputSchema = lazySchema19(
|
|
5236
|
+
() => zodSchema19(
|
|
5237
|
+
z20.object({
|
|
5238
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5239
|
+
path: z20.string(),
|
|
5240
|
+
file_text: z20.string().optional(),
|
|
5241
|
+
insert_line: z20.number().int().optional(),
|
|
5242
|
+
new_str: z20.string().optional(),
|
|
5243
|
+
insert_text: z20.string().optional(),
|
|
5244
|
+
old_str: z20.string().optional(),
|
|
5245
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4793
5246
|
})
|
|
4794
5247
|
)
|
|
4795
5248
|
);
|
|
4796
|
-
var textEditor_20250124 = (
|
|
5249
|
+
var textEditor_20250124 = createProviderDefinedToolFactory9({
|
|
4797
5250
|
id: "anthropic.text_editor_20250124",
|
|
4798
5251
|
inputSchema: textEditor_20250124InputSchema
|
|
4799
5252
|
});
|
|
4800
5253
|
|
|
4801
5254
|
// src/tool/text-editor_20250429.ts
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
5255
|
+
import {
|
|
5256
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
|
|
5257
|
+
lazySchema as lazySchema20,
|
|
5258
|
+
zodSchema as zodSchema20
|
|
5259
|
+
} from "@ai-sdk/provider-utils";
|
|
5260
|
+
import { z as z21 } from "zod/v4";
|
|
5261
|
+
var textEditor_20250429InputSchema = lazySchema20(
|
|
5262
|
+
() => zodSchema20(
|
|
5263
|
+
z21.object({
|
|
5264
|
+
command: z21.enum(["view", "create", "str_replace", "insert"]),
|
|
5265
|
+
path: z21.string(),
|
|
5266
|
+
file_text: z21.string().optional(),
|
|
5267
|
+
insert_line: z21.number().int().optional(),
|
|
5268
|
+
new_str: z21.string().optional(),
|
|
5269
|
+
insert_text: z21.string().optional(),
|
|
5270
|
+
old_str: z21.string().optional(),
|
|
5271
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4815
5272
|
})
|
|
4816
5273
|
)
|
|
4817
5274
|
);
|
|
4818
|
-
var textEditor_20250429 = (
|
|
5275
|
+
var textEditor_20250429 = createProviderDefinedToolFactory10({
|
|
4819
5276
|
id: "anthropic.text_editor_20250429",
|
|
4820
5277
|
inputSchema: textEditor_20250429InputSchema
|
|
4821
5278
|
});
|
|
4822
5279
|
|
|
4823
5280
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
5281
|
+
import {
|
|
5282
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
|
|
5283
|
+
lazySchema as lazySchema21,
|
|
5284
|
+
zodSchema as zodSchema21
|
|
5285
|
+
} from "@ai-sdk/provider-utils";
|
|
5286
|
+
import { z as z22 } from "zod/v4";
|
|
5287
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema21(
|
|
5288
|
+
() => zodSchema21(
|
|
5289
|
+
z22.array(
|
|
5290
|
+
z22.object({
|
|
5291
|
+
type: z22.literal("tool_reference"),
|
|
5292
|
+
toolName: z22.string()
|
|
4832
5293
|
})
|
|
4833
5294
|
)
|
|
4834
5295
|
)
|
|
4835
5296
|
);
|
|
4836
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4837
|
-
() => (
|
|
4838
|
-
|
|
5297
|
+
var toolSearchBm25_20251119InputSchema = lazySchema21(
|
|
5298
|
+
() => zodSchema21(
|
|
5299
|
+
z22.object({
|
|
4839
5300
|
/**
|
|
4840
5301
|
* A natural language query to search for tools.
|
|
4841
5302
|
* Claude will use BM25 text search to find relevant tools.
|
|
4842
5303
|
*/
|
|
4843
|
-
query:
|
|
5304
|
+
query: z22.string(),
|
|
4844
5305
|
/**
|
|
4845
5306
|
* Maximum number of tools to return. Optional.
|
|
4846
5307
|
*/
|
|
4847
|
-
limit:
|
|
5308
|
+
limit: z22.number().optional()
|
|
4848
5309
|
})
|
|
4849
5310
|
)
|
|
4850
5311
|
);
|
|
4851
|
-
var factory10 = (
|
|
5312
|
+
var factory10 = createProviderExecutedToolFactory9({
|
|
4852
5313
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4853
5314
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4854
5315
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5059,10 +5520,11 @@ var anthropicTools = {
|
|
|
5059
5520
|
*/
|
|
5060
5521
|
toolSearchBm25_20251119
|
|
5061
5522
|
};
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
AnthropicMessagesLanguageModel,
|
|
5523
|
+
export {
|
|
5524
|
+
AnthropicLanguageModel,
|
|
5525
|
+
AnthropicLanguageModel as AnthropicMessagesLanguageModel,
|
|
5065
5526
|
anthropicTools,
|
|
5527
|
+
getModelCapabilities,
|
|
5066
5528
|
prepareTools
|
|
5067
|
-
}
|
|
5529
|
+
};
|
|
5068
5530
|
//# sourceMappingURL=index.js.map
|