1use serde::{Deserialize, Serialize};
2
3use super::super::{
4 CacheControl, CitationConfig, ClaudeModel, McpToolset, ResponseInclusion, TypedObject,
5};
6use super::{CustomToolType, JsonSchema, ToolCommon, ToolCommonWithoutInputExamples, UserLocation};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9#[serde(untagged)]
10#[non_exhaustive]
11pub enum Tool {
12 WebFetch(WebFetchTool),
13 WebSearch(WebSearchTool),
14 Advisor(AdvisorTool),
15 Computer(ComputerTool),
16 TextEditor(TextEditorTool),
17 Command(CommandTool),
18 McpToolset(McpToolset),
19 Custom(CustomTool),
20 Unknown(TypedObject),
21}
22
23#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
24#[non_exhaustive]
25pub struct CustomTool {
26 pub input_schema: JsonSchema,
27 pub name: String,
28 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
29 pub type_: Option<CustomToolType>,
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub description: Option<String>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub eager_input_streaming: Option<bool>,
34 #[serde(flatten)]
35 pub common: ToolCommon,
36}
37
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39#[serde(untagged)]
40#[non_exhaustive]
41pub enum CommandTool {
42 Bash20241022(BashTool20241022),
43 Bash20250124(BashTool20250124),
44 CodeExecution20250522(CodeExecutionTool20250522),
45 CodeExecution20250825(CodeExecutionTool20250825),
46 CodeExecution20260120(CodeExecutionTool20260120),
47 CodeExecution20260521(CodeExecutionTool20260521),
48 Memory20250818(MemoryTool20250818),
49 ToolSearchBm25(ToolSearchBm25Tool),
50 ToolSearchRegex(ToolSearchRegexTool),
51}
52
53#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
54#[non_exhaustive]
55pub struct BashTool20241022 {
56 pub name: BashToolName,
57 #[serde(rename = "type")]
58 pub type_: BashTool20241022Type,
59 #[serde(flatten)]
60 pub common: ToolCommon,
61}
62
63#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
64#[non_exhaustive]
65pub struct BashTool20250124 {
66 pub name: BashToolName,
67 #[serde(rename = "type")]
68 pub type_: BashTool20250124Type,
69 #[serde(flatten)]
70 pub common: ToolCommon,
71}
72
73#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
74#[non_exhaustive]
75pub struct CodeExecutionTool20250522 {
76 pub name: CodeExecutionToolName,
77 #[serde(rename = "type")]
78 pub type_: CodeExecutionTool20250522Type,
79 #[serde(flatten)]
80 pub common: ToolCommonWithoutInputExamples,
81}
82
83#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
84#[non_exhaustive]
85pub struct CodeExecutionTool20250825 {
86 pub name: CodeExecutionToolName,
87 #[serde(rename = "type")]
88 pub type_: CodeExecutionTool20250825Type,
89 #[serde(flatten)]
90 pub common: ToolCommonWithoutInputExamples,
91}
92
93#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
94#[non_exhaustive]
95pub struct CodeExecutionTool20260120 {
96 pub name: CodeExecutionToolName,
97 #[serde(rename = "type")]
98 pub type_: CodeExecutionTool20260120Type,
99 #[serde(flatten)]
100 pub common: ToolCommonWithoutInputExamples,
101}
102
103#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
104#[non_exhaustive]
105pub struct CodeExecutionTool20260521 {
106 pub name: CodeExecutionToolName,
107 #[serde(rename = "type")]
108 pub type_: CodeExecutionTool20260521Type,
109 #[serde(flatten)]
110 pub common: ToolCommonWithoutInputExamples,
111}
112
113#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
114#[non_exhaustive]
115pub struct MemoryTool20250818 {
116 pub name: MemoryToolName,
117 #[serde(rename = "type")]
118 pub type_: MemoryTool20250818Type,
119 #[serde(flatten)]
120 pub common: ToolCommon,
121}
122
123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
124#[non_exhaustive]
125pub struct ToolSearchBm25Tool {
126 pub name: ToolSearchBm25ToolName,
127 #[serde(rename = "type")]
128 pub type_: ToolSearchBm25ToolType,
129 #[serde(flatten)]
130 pub common: ToolCommonWithoutInputExamples,
131}
132
133#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
134#[non_exhaustive]
135pub struct ToolSearchRegexTool {
136 pub name: ToolSearchRegexToolName,
137 #[serde(rename = "type")]
138 pub type_: ToolSearchRegexToolType,
139 #[serde(flatten)]
140 pub common: ToolCommonWithoutInputExamples,
141}
142
143#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
144#[serde(untagged)]
145#[non_exhaustive]
146pub enum TextEditorTool {
147 TextEditor20241022(TextEditorTool20241022),
148 TextEditor20250124(TextEditorTool20250124),
149 TextEditor20250429(TextEditorTool20250429),
150 TextEditor20250728(TextEditorTool20250728),
151}
152
153#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
154#[non_exhaustive]
155pub struct TextEditorTool20241022 {
156 pub name: StrReplaceEditorToolName,
157 #[serde(rename = "type")]
158 pub type_: TextEditorTool20241022Type,
159 #[serde(flatten)]
160 pub common: ToolCommon,
161}
162
163#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
164#[non_exhaustive]
165pub struct TextEditorTool20250124 {
166 pub name: StrReplaceEditorToolName,
167 #[serde(rename = "type")]
168 pub type_: TextEditorTool20250124Type,
169 #[serde(flatten)]
170 pub common: ToolCommon,
171}
172
173#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
174#[non_exhaustive]
175pub struct TextEditorTool20250429 {
176 pub name: StrReplaceBasedEditToolName,
177 #[serde(rename = "type")]
178 pub type_: TextEditorTool20250429Type,
179 #[serde(flatten)]
180 pub common: ToolCommon,
181}
182
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
184#[non_exhaustive]
185pub struct TextEditorTool20250728 {
186 pub name: StrReplaceBasedEditToolName,
187 #[serde(rename = "type")]
188 pub type_: TextEditorTool20250728Type,
189 #[serde(skip_serializing_if = "Option::is_none")]
190 pub max_characters: Option<u64>,
191 #[serde(flatten)]
192 pub common: ToolCommon,
193}
194
195#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
196#[serde(untagged)]
197#[non_exhaustive]
198pub enum ComputerTool {
199 Computer20241022(ComputerTool20241022),
200 Computer20250124(ComputerTool20250124),
201 Computer20251124(ComputerTool20251124),
202}
203
204#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
205#[non_exhaustive]
206pub struct ComputerTool20241022 {
207 pub display_height_px: u64,
208 pub display_width_px: u64,
209 pub name: ComputerToolName,
210 #[serde(rename = "type")]
211 pub type_: ComputerTool20241022Type,
212 #[serde(skip_serializing_if = "Option::is_none")]
213 pub display_number: Option<u64>,
214 #[serde(flatten)]
215 pub common: ToolCommon,
216}
217
218#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
219#[non_exhaustive]
220pub struct ComputerTool20250124 {
221 pub display_height_px: u64,
222 pub display_width_px: u64,
223 pub name: ComputerToolName,
224 #[serde(rename = "type")]
225 pub type_: ComputerTool20250124Type,
226 #[serde(skip_serializing_if = "Option::is_none")]
227 pub display_number: Option<u64>,
228 #[serde(flatten)]
229 pub common: ToolCommon,
230}
231
232#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
233#[non_exhaustive]
234pub struct ComputerTool20251124 {
235 pub display_height_px: u64,
236 pub display_width_px: u64,
237 pub name: ComputerToolName,
238 #[serde(rename = "type")]
239 pub type_: ComputerTool20251124Type,
240 #[serde(skip_serializing_if = "Option::is_none")]
241 pub display_number: Option<u64>,
242 #[serde(skip_serializing_if = "Option::is_none")]
243 pub enable_zoom: Option<bool>,
244 #[serde(flatten)]
245 pub common: ToolCommon,
246}
247
248#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
249#[serde(untagged)]
250#[non_exhaustive]
251pub enum WebSearchTool {
252 WebSearch20250305(WebSearchTool20250305),
253 WebSearch20260209(WebSearchTool20260209),
254 WebSearch20260318(WebSearchTool20260318),
255}
256
257#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
258#[non_exhaustive]
259pub struct WebSearchTool20250305 {
260 pub name: WebSearchToolName,
261 #[serde(rename = "type")]
262 pub type_: WebSearchTool20250305Type,
263 #[serde(flatten)]
264 pub params: WebSearchToolParams,
265 #[serde(flatten)]
266 pub common: ToolCommonWithoutInputExamples,
267}
268
269#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
270#[non_exhaustive]
271pub struct WebSearchTool20260209 {
272 pub name: WebSearchToolName,
273 #[serde(rename = "type")]
274 pub type_: WebSearchTool20260209Type,
275 #[serde(flatten)]
276 pub params: WebSearchToolParams,
277 #[serde(flatten)]
278 pub common: ToolCommonWithoutInputExamples,
279}
280
281#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
282#[non_exhaustive]
283pub struct WebSearchTool20260318 {
284 pub name: WebSearchToolName,
285 #[serde(rename = "type")]
286 pub type_: WebSearchTool20260318Type,
287 #[serde(flatten)]
288 pub params: WebSearchToolParams,
289 #[serde(skip_serializing_if = "Option::is_none")]
290 pub response_inclusion: Option<ResponseInclusion>,
291 #[serde(flatten)]
292 pub common: ToolCommonWithoutInputExamples,
293}
294
295#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
296#[non_exhaustive]
297pub struct WebSearchToolParams {
298 #[serde(skip_serializing_if = "Option::is_none")]
299 pub allowed_domains: Option<Vec<String>>,
300 #[serde(skip_serializing_if = "Option::is_none")]
301 pub blocked_domains: Option<Vec<String>>,
302 #[serde(skip_serializing_if = "Option::is_none")]
303 pub max_uses: Option<u64>,
304 #[serde(skip_serializing_if = "Option::is_none")]
305 pub user_location: Option<UserLocation>,
306}
307
308#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
309#[serde(untagged)]
310#[non_exhaustive]
311pub enum WebFetchTool {
312 WebFetch20250910(WebFetchTool20250910),
313 WebFetch20260209(WebFetchTool20260209),
314 WebFetch20260309(WebFetchTool20260309),
315 WebFetch20260318(WebFetchTool20260318),
316}
317
318#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
319#[non_exhaustive]
320pub struct WebFetchTool20250910 {
321 pub name: WebFetchToolName,
322 #[serde(rename = "type")]
323 pub type_: WebFetchTool20250910Type,
324 #[serde(flatten)]
325 pub params: WebFetchToolParams,
326 #[serde(flatten)]
327 pub common: ToolCommonWithoutInputExamples,
328}
329
330#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
331#[non_exhaustive]
332pub struct WebFetchTool20260209 {
333 pub name: WebFetchToolName,
334 #[serde(rename = "type")]
335 pub type_: WebFetchTool20260209Type,
336 #[serde(flatten)]
337 pub params: WebFetchToolParams,
338 #[serde(flatten)]
339 pub common: ToolCommonWithoutInputExamples,
340}
341
342#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
343#[non_exhaustive]
344pub struct WebFetchTool20260309 {
345 pub name: WebFetchToolName,
346 #[serde(rename = "type")]
347 pub type_: WebFetchTool20260309Type,
348 #[serde(flatten)]
349 pub params: WebFetchToolParams,
350 #[serde(skip_serializing_if = "Option::is_none")]
351 pub use_cache: Option<bool>,
352 #[serde(flatten)]
353 pub common: ToolCommonWithoutInputExamples,
354}
355
356#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
357#[non_exhaustive]
358pub struct WebFetchTool20260318 {
359 pub name: WebFetchToolName,
360 #[serde(rename = "type")]
361 pub type_: WebFetchTool20260318Type,
362 #[serde(flatten)]
363 pub params: WebFetchToolParams,
364 #[serde(skip_serializing_if = "Option::is_none")]
365 pub response_inclusion: Option<ResponseInclusion>,
366 #[serde(skip_serializing_if = "Option::is_none")]
367 pub use_cache: Option<bool>,
368 #[serde(flatten)]
369 pub common: ToolCommonWithoutInputExamples,
370}
371
372#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
373#[non_exhaustive]
374pub struct WebFetchToolParams {
375 #[serde(skip_serializing_if = "Option::is_none")]
376 pub allowed_domains: Option<Vec<String>>,
377 #[serde(skip_serializing_if = "Option::is_none")]
378 pub blocked_domains: Option<Vec<String>>,
379 #[serde(skip_serializing_if = "Option::is_none")]
380 pub citations: Option<CitationConfig>,
381 #[serde(skip_serializing_if = "Option::is_none")]
382 pub max_content_tokens: Option<u64>,
383 #[serde(skip_serializing_if = "Option::is_none")]
384 pub max_uses: Option<u64>,
385}
386
387#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
388#[non_exhaustive]
389pub struct AdvisorTool {
390 pub model: ClaudeModel,
391 pub name: AdvisorToolName,
392 #[serde(rename = "type")]
393 pub type_: AdvisorTool20260301Type,
394 #[serde(skip_serializing_if = "Option::is_none")]
395 pub caching: Option<CacheControl>,
396 #[serde(skip_serializing_if = "Option::is_none")]
398 pub max_tokens: Option<u64>,
399 #[serde(skip_serializing_if = "Option::is_none")]
400 pub max_uses: Option<u64>,
401 #[serde(flatten)]
402 pub common: ToolCommonWithoutInputExamples,
403}
404
405macro_rules! single_wire_enum {
406 ($name:ident { $variant:ident => $wire:literal }) => {
407 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
408 #[non_exhaustive]
409 pub enum $name {
410 #[serde(rename = $wire)]
411 $variant,
412 }
413 };
414}
415
416single_wire_enum!(BashToolName { Bash => "bash" });
417single_wire_enum!(BashTool20241022Type { Bash20241022 => "bash_20241022" });
418single_wire_enum!(BashTool20250124Type { Bash20250124 => "bash_20250124" });
419single_wire_enum!(CodeExecutionToolName { CodeExecution => "code_execution" });
420single_wire_enum!(CodeExecutionTool20250522Type { CodeExecution20250522 => "code_execution_20250522" });
421single_wire_enum!(CodeExecutionTool20250825Type { CodeExecution20250825 => "code_execution_20250825" });
422single_wire_enum!(CodeExecutionTool20260120Type { CodeExecution20260120 => "code_execution_20260120" });
423single_wire_enum!(CodeExecutionTool20260521Type { CodeExecution20260521 => "code_execution_20260521" });
424single_wire_enum!(MemoryToolName { Memory => "memory" });
425single_wire_enum!(MemoryTool20250818Type { Memory20250818 => "memory_20250818" });
426single_wire_enum!(ToolSearchBm25ToolName { ToolSearchBm25 => "tool_search_tool_bm25" });
427single_wire_enum!(ToolSearchRegexToolName { ToolSearchRegex => "tool_search_tool_regex" });
428single_wire_enum!(StrReplaceEditorToolName { StrReplaceEditor => "str_replace_editor" });
429single_wire_enum!(StrReplaceBasedEditToolName { StrReplaceBasedEditTool => "str_replace_based_edit_tool" });
430single_wire_enum!(TextEditorTool20241022Type { TextEditor20241022 => "text_editor_20241022" });
431single_wire_enum!(TextEditorTool20250124Type { TextEditor20250124 => "text_editor_20250124" });
432single_wire_enum!(TextEditorTool20250429Type { TextEditor20250429 => "text_editor_20250429" });
433single_wire_enum!(TextEditorTool20250728Type { TextEditor20250728 => "text_editor_20250728" });
434single_wire_enum!(ComputerToolName { Computer => "computer" });
435single_wire_enum!(ComputerTool20241022Type { Computer20241022 => "computer_20241022" });
436single_wire_enum!(ComputerTool20250124Type { Computer20250124 => "computer_20250124" });
437single_wire_enum!(ComputerTool20251124Type { Computer20251124 => "computer_20251124" });
438single_wire_enum!(WebSearchToolName { WebSearch => "web_search" });
439single_wire_enum!(WebSearchTool20250305Type { WebSearch20250305 => "web_search_20250305" });
440single_wire_enum!(WebSearchTool20260209Type { WebSearch20260209 => "web_search_20260209" });
441single_wire_enum!(WebSearchTool20260318Type { WebSearch20260318 => "web_search_20260318" });
442single_wire_enum!(WebFetchToolName { WebFetch => "web_fetch" });
443single_wire_enum!(WebFetchTool20250910Type { WebFetch20250910 => "web_fetch_20250910" });
444single_wire_enum!(WebFetchTool20260209Type { WebFetch20260209 => "web_fetch_20260209" });
445single_wire_enum!(WebFetchTool20260309Type { WebFetch20260309 => "web_fetch_20260309" });
446single_wire_enum!(WebFetchTool20260318Type { WebFetch20260318 => "web_fetch_20260318" });
447single_wire_enum!(AdvisorToolName { Advisor => "advisor" });
448single_wire_enum!(AdvisorTool20260301Type { Advisor20260301 => "advisor_20260301" });
449
450#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
451#[non_exhaustive]
452pub enum ToolSearchBm25ToolType {
453 #[serde(rename = "tool_search_tool_bm25_20251119")]
454 ToolSearchBm2520251119,
455 #[serde(rename = "tool_search_tool_bm25")]
456 ToolSearchBm25,
457}
458
459#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
460#[non_exhaustive]
461pub enum ToolSearchRegexToolType {
462 #[serde(rename = "tool_search_tool_regex_20251119")]
463 ToolSearchRegex20251119,
464 #[serde(rename = "tool_search_tool_regex")]
465 ToolSearchRegex,
466}