Skip to main content

gproxy_protocol/wire/openai/responses/
input.rs

1//! Native OpenAI Responses input, output items, tool and configuration shapes.
2//!
3//! The request uses the same native input and tool shapes as Responses.  The
4//! types here deliberately remain OpenAI-shaped; they are not a shared IR.
5//!
6//! Shapes follow `Get input token counts.md`, including native history items.
7//! Known structures are typed; `rest` retains only unknown extension fields.
8use super::tools::*;
9use crate::Rest;
10use serde::{Deserialize, Serialize};
11
12/// Deserialize a present non-null optional field; a missing field uses serde default.
13pub(in crate::wire::openai) fn present_optional<'de, D, T>(
14    deserializer: D,
15) -> Result<Option<T>, D::Error>
16where
17    D: serde::Deserializer<'de>,
18    T: Deserialize<'de>,
19{
20    T::deserialize(deserializer).map(Some)
21}
22
23/// A field which is required on the wire but explicitly permits JSON null.
24/// `deserialize_with` preserves the distinction between a missing field
25/// (serde reports an error) and a present null (returns `None`).
26pub(in crate::wire::openai) fn required_nullable<'de, D, T>(
27    deserializer: D,
28) -> Result<Option<T>, D::Error>
29where
30    D: serde::Deserializer<'de>,
31    T: Deserialize<'de>,
32{
33    Option::<T>::deserialize(deserializer)
34}
35
36pub(in crate::wire::openai) fn present_nullable<'de, D, T>(
37    deserializer: D,
38) -> Result<Option<Option<T>>, D::Error>
39where
40    D: serde::Deserializer<'de>,
41    T: Deserialize<'de>,
42{
43    Option::<T>::deserialize(deserializer).map(Some)
44}
45
46#[derive(
47    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
48)]
49#[serde(rename_all = "snake_case")]
50#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
51#[derive(gproxy_protocol_macros::DeclaredFields)]
52pub struct ResponseConversationParam {
53    pub id: String,
54    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
55    pub rest: Rest,
56}
57
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59#[serde(untagged)]
60#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
61#[derive(gproxy_protocol_macros::DeclaredFields)]
62pub enum ConversationParam {
63    Id(String),
64    Object(ResponseConversationParam),
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
68#[serde(untagged)]
69#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
70#[derive(gproxy_protocol_macros::DeclaredFields)]
71pub enum Input {
72    Text(String),
73    Items(Vec<InputItem>),
74}
75
76#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
77#[serde(untagged)]
78#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
79#[derive(gproxy_protocol_macros::DeclaredFields)]
80pub enum MessageContent {
81    Text(String),
82    Parts(Vec<InputContent>),
83}
84
85#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
86#[serde(untagged)]
87#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
88#[derive(gproxy_protocol_macros::DeclaredFields)]
89pub enum InputContent {
90    #[serde(rename = "input_text")]
91    Text(ResponseInputText),
92    #[serde(rename = "input_image")]
93    Image(ResponseInputImage),
94    #[serde(rename = "input_file")]
95    File(ResponseInputFile),
96}
97
98#[derive(
99    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
100)]
101#[serde(rename_all = "snake_case")]
102#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
103#[derive(gproxy_protocol_macros::DeclaredFields)]
104pub struct ResponseInputText {
105    #[serde(rename = "type")]
106    pub type_: ResponseInputTextType,
107    pub text: String,
108    #[serde(
109        default,
110        deserialize_with = "present_optional",
111        skip_serializing_if = "Option::is_none"
112    )]
113    pub prompt_cache_breakpoint: Option<PromptCacheBreakpoint>,
114    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
115    pub rest: Rest,
116}
117
118#[derive(
119    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
120)]
121#[serde(rename_all = "snake_case")]
122#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
123#[derive(gproxy_protocol_macros::DeclaredFields)]
124pub struct ResponseInputImage {
125    #[serde(rename = "type")]
126    pub type_: ResponseInputImageType,
127    pub detail: ImageDetail,
128    #[serde(
129        default,
130        deserialize_with = "present_nullable",
131        skip_serializing_if = "Option::is_none"
132    )]
133    pub file_id: Option<Option<String>>,
134    #[serde(
135        default,
136        deserialize_with = "present_nullable",
137        skip_serializing_if = "Option::is_none"
138    )]
139    pub image_url: Option<Option<String>>,
140    #[serde(
141        default,
142        deserialize_with = "present_optional",
143        skip_serializing_if = "Option::is_none"
144    )]
145    pub prompt_cache_breakpoint: Option<PromptCacheBreakpoint>,
146    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
147    pub rest: Rest,
148}
149
150#[derive(
151    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
152)]
153#[serde(rename_all = "snake_case")]
154#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
155#[derive(gproxy_protocol_macros::DeclaredFields)]
156pub struct ResponseInputFile {
157    #[serde(rename = "type")]
158    pub type_: ResponseInputFileType,
159    #[serde(
160        default,
161        deserialize_with = "present_optional",
162        skip_serializing_if = "Option::is_none"
163    )]
164    pub detail: Option<FileDetail>,
165    #[serde(
166        default,
167        deserialize_with = "present_optional",
168        skip_serializing_if = "Option::is_none"
169    )]
170    pub file_data: Option<String>,
171    #[serde(
172        default,
173        deserialize_with = "present_nullable",
174        skip_serializing_if = "Option::is_none"
175    )]
176    pub file_id: Option<Option<String>>,
177    #[serde(
178        default,
179        deserialize_with = "present_optional",
180        skip_serializing_if = "Option::is_none"
181    )]
182    pub file_url: Option<String>,
183    #[serde(
184        default,
185        deserialize_with = "present_optional",
186        skip_serializing_if = "Option::is_none"
187    )]
188    pub filename: Option<String>,
189    #[serde(
190        default,
191        deserialize_with = "present_optional",
192        skip_serializing_if = "Option::is_none"
193    )]
194    pub prompt_cache_breakpoint: Option<PromptCacheBreakpoint>,
195    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
196    pub rest: Rest,
197}
198
199#[derive(
200    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
201)]
202#[serde(rename_all = "snake_case")]
203#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
204#[derive(gproxy_protocol_macros::DeclaredFields)]
205pub struct PromptCacheBreakpoint {
206    pub mode: PromptCacheMode,
207    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
208    pub rest: Rest,
209}
210
211#[derive(
212    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
213)]
214#[serde(rename_all = "snake_case")]
215#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
216#[derive(gproxy_protocol_macros::DeclaredFields)]
217pub struct EasyInputMessage {
218    #[serde(
219        default,
220        deserialize_with = "present_nullable",
221        skip_serializing_if = "Option::is_none"
222    )]
223    pub agent: Option<Option<super::multi_agent::Agent>>,
224    pub content: MessageContent,
225    pub role: MessageRole,
226    #[serde(
227        default,
228        deserialize_with = "present_nullable",
229        skip_serializing_if = "Option::is_none"
230    )]
231    pub phase: Option<Option<MessagePhase>>,
232    #[serde(
233        rename = "type",
234        default,
235        deserialize_with = "present_optional",
236        skip_serializing_if = "Option::is_none"
237    )]
238    pub type_: Option<MessageType>,
239    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
240    pub rest: Rest,
241}
242
243#[derive(
244    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
245)]
246#[serde(rename_all = "snake_case")]
247#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
248#[derive(gproxy_protocol_macros::DeclaredFields)]
249pub struct InputMessage {
250    #[serde(
251        default,
252        deserialize_with = "present_nullable",
253        skip_serializing_if = "Option::is_none"
254    )]
255    pub agent: Option<Option<super::multi_agent::Agent>>,
256    pub content: Vec<InputContent>,
257    pub role: InputMessageRole,
258    #[serde(
259        default,
260        deserialize_with = "present_optional",
261        skip_serializing_if = "Option::is_none"
262    )]
263    pub status: Option<OutputMessageStatus>,
264    #[serde(
265        rename = "type",
266        default,
267        deserialize_with = "present_optional",
268        skip_serializing_if = "Option::is_none"
269    )]
270    pub type_: Option<MessageType>,
271    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
272    pub rest: Rest,
273}
274
275#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
276#[serde(untagged)]
277#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
278#[derive(gproxy_protocol_macros::DeclaredFields)]
279pub enum InputItem {
280    MultiAgentCall(super::multi_agent::MultiAgentCall),
281    MultiAgentCallOutput(super::multi_agent::MultiAgentCallOutput),
282    AgentMessage(super::multi_agent::AgentMessage),
283    ConfigurationUpdate(ConfigurationUpdate),
284    OutputMessage(
285        #[serde(
286            deserialize_with = "output_message_history",
287            serialize_with = "serialize_history_item"
288        )]
289        ResponseOutputMessage,
290    ),
291    Message(InputMessage),
292    Easy(EasyInputMessage),
293    FunctionCall(FunctionCall),
294    FunctionCallOutput(FunctionCallOutput),
295    Reasoning(
296        #[serde(
297            deserialize_with = "history_item",
298            serialize_with = "serialize_history_item"
299        )]
300        ReasoningItem,
301    ),
302    ItemReference(ItemReference),
303    Compaction(Compaction),
304    ComputerCall(ComputerCall),
305    ComputerCallOutput(ComputerCallOutput),
306    WebSearchCall(WebSearchCall),
307    FileSearchCall(FileSearchCall),
308    ImageGenerationCall(ImageGenerationCall),
309    CodeInterpreterCall(CodeInterpreterCall),
310    CustomToolCall(CustomToolCall),
311    CustomToolCallOutput(CustomToolCallOutput),
312    ToolSearchCall(ToolSearchCall),
313    ToolSearchOutput(ToolSearchOutput),
314    AdditionalTools(AdditionalTools),
315    LocalShellCall(
316        #[serde(
317            deserialize_with = "history_item",
318            serialize_with = "serialize_history_item"
319        )]
320        LocalShellCall,
321    ),
322    LocalShellCallOutput(LocalShellCallOutput),
323    ShellCall(ShellCall),
324    ShellCallOutput(ShellCallOutput),
325    ApplyPatchCall(ApplyPatchCall),
326    ApplyPatchCallOutput(ApplyPatchCallOutput),
327    McpListTools(McpListTools),
328    McpApprovalRequest(McpApprovalRequest),
329    McpApprovalResponse(McpApprovalResponse),
330    McpCall(McpCall),
331    CompactionTrigger(CompactionTrigger),
332    Program(Program),
333    ProgramOutput(ProgramOutput),
334}
335
336// Missing history IDs use an internal empty sentinel, omitted again on the wire.
337// Live output items still deserialize through their strict native types.
338fn history_item<'de, D, T>(deserializer: D) -> Result<T, D::Error>
339where
340    D: serde::Deserializer<'de>,
341    T: serde::de::DeserializeOwned,
342{
343    let mut value = serde_json::Value::deserialize(deserializer)?;
344    if let Some(object) = value.as_object_mut() {
345        object.entry("id").or_insert_with(|| "".into());
346    }
347    serde_json::from_value(value).map_err(serde::de::Error::custom)
348}
349
350fn serialize_history_item<S, T>(item: &T, serializer: S) -> Result<S::Ok, S::Error>
351where
352    S: serde::Serializer,
353    T: Serialize,
354{
355    let mut value = serde_json::to_value(item).map_err(serde::ser::Error::custom)?;
356    if value.get("id").and_then(serde_json::Value::as_str) == Some("") {
357        value.as_object_mut().expect("history object").remove("id");
358    }
359    value.serialize(serializer)
360}
361
362/// Codex replays assistant history without output-only ID/status/annotation
363/// bookkeeping. Accept that compact request form without relaxing live
364/// response parsing or dropping its output_text content.
365fn output_message_history<'de, D>(deserializer: D) -> Result<ResponseOutputMessage, D::Error>
366where
367    D: serde::Deserializer<'de>,
368{
369    let mut value = serde_json::Value::deserialize(deserializer)?;
370    if value.get("role").and_then(serde_json::Value::as_str) == Some("assistant")
371        && (value.get("type").is_none()
372            || value.get("type").and_then(serde_json::Value::as_str) == Some("message"))
373    {
374        let object = value.as_object_mut().expect("message object");
375        object.entry("type").or_insert_with(|| "message".into());
376        object.entry("id").or_insert_with(|| "".into());
377        object.entry("status").or_insert_with(|| "completed".into());
378        if let Some(parts) = object
379            .get_mut("content")
380            .and_then(serde_json::Value::as_array_mut)
381        {
382            for part in parts {
383                if part.get("type").and_then(serde_json::Value::as_str) == Some("output_text") {
384                    let part = part.as_object_mut().expect("text object");
385                    part.entry("annotations")
386                        .or_insert_with(|| serde_json::json!([]));
387                    part.entry("logprobs")
388                        .or_insert_with(|| serde_json::json!([]));
389                }
390            }
391        }
392    }
393    serde_json::from_value(value).map_err(serde::de::Error::custom)
394}
395
396#[derive(
397    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
398)]
399#[serde(rename_all = "snake_case")]
400#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
401#[derive(gproxy_protocol_macros::DeclaredFields)]
402pub struct ResponseOutputText {
403    #[serde(rename = "type")]
404    pub type_: ResponseOutputTextType,
405    pub text: String,
406    pub annotations: Vec<OutputAnnotation>,
407    pub logprobs: Vec<OutputLogprob>,
408    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
409    pub rest: Rest,
410}
411#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
412#[serde(untagged)]
413#[derive(gproxy_protocol_macros::DeclaredFields)]
414pub enum OutputAnnotation {
415    File(FileCitation),
416    Url(UrlCitation),
417    ContainerFile(ContainerFileCitation),
418    Path(FilePath),
419}
420macro_rules! citation { ($name:ident { $($field:tt)* }) => { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)] #[serde(rename_all = "snake_case")] #[derive(gproxy_protocol_macros::DeclaredFields)]
421pub struct $name { $($field)* #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")] pub rest: Rest } }; }
422citation!(FileCitation { pub file_id: String, pub filename: String, pub index: i64, #[serde(rename = "type")] pub type_: FileCitationType, });
423citation!(UrlCitation { pub end_index: i64, pub start_index: i64, pub title: String, pub url: String, #[serde(rename = "type")] pub type_: UrlCitationType, });
424citation!(ContainerFileCitation { pub container_id: String, pub end_index: i64, pub file_id: String, pub filename: String, pub start_index: i64, #[serde(rename = "type")] pub type_: ContainerFileCitationType, });
425citation!(FilePath { pub file_id: String, pub index: i64, #[serde(rename = "type")] pub type_: FilePathType, });
426#[derive(
427    Debug,
428    Clone,
429    Copy,
430    PartialEq,
431    Eq,
432    Serialize,
433    Deserialize,
434    gproxy_protocol_macros::DeclaredFields,
435)]
436pub enum FileCitationType {
437    #[serde(rename = "file_citation")]
438    FileCitation,
439}
440#[derive(
441    Debug,
442    Clone,
443    Copy,
444    PartialEq,
445    Eq,
446    Serialize,
447    Deserialize,
448    gproxy_protocol_macros::DeclaredFields,
449)]
450pub enum UrlCitationType {
451    #[serde(rename = "url_citation")]
452    UrlCitation,
453}
454#[derive(
455    Debug,
456    Clone,
457    Copy,
458    PartialEq,
459    Eq,
460    Serialize,
461    Deserialize,
462    gproxy_protocol_macros::DeclaredFields,
463)]
464pub enum ContainerFileCitationType {
465    #[serde(rename = "container_file_citation")]
466    ContainerFileCitation,
467}
468#[derive(
469    Debug,
470    Clone,
471    Copy,
472    PartialEq,
473    Eq,
474    Serialize,
475    Deserialize,
476    gproxy_protocol_macros::DeclaredFields,
477)]
478pub enum FilePathType {
479    #[serde(rename = "file_path")]
480    FilePath,
481}
482#[derive(
483    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
484)]
485#[serde(rename_all = "snake_case")]
486#[derive(gproxy_protocol_macros::DeclaredFields)]
487pub struct OutputLogprob {
488    pub token: String,
489    pub bytes: Vec<i64>,
490    pub logprob: serde_json::Number,
491    pub top_logprobs: Vec<TopLogprob>,
492    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
493    pub rest: Rest,
494}
495#[derive(
496    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
497)]
498#[serde(rename_all = "snake_case")]
499#[derive(gproxy_protocol_macros::DeclaredFields)]
500pub struct TopLogprob {
501    pub token: String,
502    pub bytes: Vec<i64>,
503    pub logprob: serde_json::Number,
504    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
505    pub rest: Rest,
506}
507#[derive(
508    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
509)]
510#[serde(rename_all = "snake_case")]
511#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
512#[derive(gproxy_protocol_macros::DeclaredFields)]
513pub struct ResponseOutputRefusal {
514    #[serde(rename = "type")]
515    pub type_: ResponseOutputRefusalType,
516    pub refusal: String,
517    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
518    pub rest: Rest,
519}
520#[derive(
521    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
522)]
523#[serde(rename_all = "snake_case")]
524#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
525#[derive(gproxy_protocol_macros::DeclaredFields)]
526pub struct FunctionCall {
527    #[serde(
528        default,
529        deserialize_with = "present_nullable",
530        skip_serializing_if = "Option::is_none"
531    )]
532    pub agent: Option<Option<super::multi_agent::Agent>>,
533    #[serde(rename = "async", skip_serializing_if = "Option::is_none")]
534    pub async_: Option<bool>,
535
536    #[serde(rename = "type")]
537    pub type_: FunctionCallType,
538    pub arguments: String,
539    pub call_id: String,
540    pub name: String,
541    #[serde(
542        default,
543        deserialize_with = "present_optional",
544        skip_serializing_if = "Option::is_none"
545    )]
546    pub id: Option<String>,
547    #[serde(
548        default,
549        deserialize_with = "present_optional",
550        skip_serializing_if = "Option::is_none"
551    )]
552    pub namespace: Option<String>,
553    #[serde(
554        default,
555        deserialize_with = "present_nullable",
556        skip_serializing_if = "Option::is_none"
557    )]
558    pub caller: Option<Option<Caller>>,
559    #[serde(
560        default,
561        deserialize_with = "present_optional",
562        skip_serializing_if = "Option::is_none"
563    )]
564    pub status: Option<ItemStatus>,
565    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
566    pub rest: Rest,
567}
568#[derive(
569    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
570)]
571#[serde(rename_all = "snake_case")]
572#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
573#[derive(gproxy_protocol_macros::DeclaredFields)]
574pub struct FunctionCallOutput {
575    #[serde(
576        default,
577        deserialize_with = "present_nullable",
578        skip_serializing_if = "Option::is_none"
579    )]
580    pub agent: Option<Option<super::multi_agent::Agent>>,
581    #[serde(rename = "type")]
582    pub type_: FunctionCallOutputType,
583    pub call_id: String,
584    pub output: FunctionOutput,
585    #[serde(
586        default,
587        deserialize_with = "present_nullable",
588        skip_serializing_if = "Option::is_none"
589    )]
590    pub id: Option<Option<String>>,
591    #[serde(
592        default,
593        deserialize_with = "present_nullable",
594        skip_serializing_if = "Option::is_none"
595    )]
596    pub name: Option<Option<String>>,
597    #[serde(
598        default,
599        deserialize_with = "present_nullable",
600        skip_serializing_if = "Option::is_none"
601    )]
602    pub namespace: Option<Option<String>>,
603    #[serde(
604        default,
605        deserialize_with = "present_nullable",
606        skip_serializing_if = "Option::is_none"
607    )]
608    pub caller: Option<Option<Caller>>,
609    #[serde(
610        default,
611        deserialize_with = "present_nullable",
612        skip_serializing_if = "Option::is_none"
613    )]
614    pub status: Option<Option<ItemStatus>>,
615    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
616    pub rest: Rest,
617}
618#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
619#[serde(untagged)]
620#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
621#[derive(gproxy_protocol_macros::DeclaredFields)]
622pub enum FunctionOutput {
623    Text(String),
624    Content(Vec<FunctionOutputContent>),
625}
626#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
627#[serde(untagged)]
628#[derive(gproxy_protocol_macros::DeclaredFields)]
629pub enum FunctionOutputContent {
630    Text(FunctionOutputText),
631    Image(FunctionOutputImage),
632    File(FunctionOutputFile),
633}
634#[derive(
635    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
636)]
637#[serde(rename_all = "snake_case")]
638#[derive(gproxy_protocol_macros::DeclaredFields)]
639pub struct FunctionOutputImage {
640    #[serde(rename = "type")]
641    pub type_: ResponseInputImageType,
642    #[serde(
643        default,
644        deserialize_with = "present_nullable",
645        skip_serializing_if = "Option::is_none"
646    )]
647    pub detail: Option<Option<ImageDetail>>,
648    #[serde(
649        default,
650        deserialize_with = "present_nullable",
651        skip_serializing_if = "Option::is_none"
652    )]
653    pub file_id: Option<Option<String>>,
654    #[serde(
655        default,
656        deserialize_with = "present_nullable",
657        skip_serializing_if = "Option::is_none"
658    )]
659    pub image_url: Option<Option<String>>,
660    #[serde(
661        default,
662        deserialize_with = "present_nullable",
663        skip_serializing_if = "Option::is_none"
664    )]
665    pub prompt_cache_breakpoint: Option<Option<PromptCacheBreakpoint>>,
666    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
667    pub rest: Rest,
668}
669#[derive(
670    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
671)]
672#[serde(rename_all = "snake_case")]
673#[derive(gproxy_protocol_macros::DeclaredFields)]
674pub struct FunctionOutputFile {
675    #[serde(rename = "type")]
676    pub type_: ResponseInputFileType,
677    #[serde(
678        default,
679        deserialize_with = "present_nullable",
680        skip_serializing_if = "Option::is_none"
681    )]
682    pub file_data: Option<Option<String>>,
683    #[serde(
684        default,
685        deserialize_with = "present_nullable",
686        skip_serializing_if = "Option::is_none"
687    )]
688    pub file_id: Option<Option<String>>,
689    #[serde(
690        default,
691        deserialize_with = "present_nullable",
692        skip_serializing_if = "Option::is_none"
693    )]
694    pub file_url: Option<Option<String>>,
695    #[serde(
696        default,
697        deserialize_with = "present_nullable",
698        skip_serializing_if = "Option::is_none"
699    )]
700    pub prompt_cache_breakpoint: Option<Option<PromptCacheBreakpoint>>,
701    #[serde(
702        default,
703        deserialize_with = "present_optional",
704        skip_serializing_if = "Option::is_none"
705    )]
706    pub detail: Option<FileDetail>,
707    #[serde(
708        default,
709        deserialize_with = "present_nullable",
710        skip_serializing_if = "Option::is_none"
711    )]
712    pub filename: Option<Option<String>>,
713    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
714    pub rest: Rest,
715}
716
717#[derive(
718    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
719)]
720#[serde(rename_all = "snake_case")]
721#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
722#[derive(gproxy_protocol_macros::DeclaredFields)]
723pub struct ReasoningConfig {
724    #[serde(
725        default,
726        deserialize_with = "present_nullable",
727        skip_serializing_if = "Option::is_none"
728    )]
729    pub effort: Option<Option<ReasoningEffort>>,
730    #[serde(
731        default,
732        deserialize_with = "present_nullable",
733        skip_serializing_if = "Option::is_none"
734    )]
735    pub generate_summary: Option<Option<ReasoningSummary>>,
736    #[serde(
737        default,
738        deserialize_with = "present_optional",
739        skip_serializing_if = "Option::is_none"
740    )]
741    pub mode: Option<String>,
742    #[serde(
743        default,
744        deserialize_with = "present_nullable",
745        skip_serializing_if = "Option::is_none"
746    )]
747    pub summary: Option<Option<ReasoningSummary>>,
748    #[serde(
749        default,
750        deserialize_with = "present_nullable",
751        skip_serializing_if = "Option::is_none"
752    )]
753    pub context: Option<Option<ReasoningContext>>,
754    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
755    pub rest: Rest,
756}
757#[derive(
758    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
759)]
760#[serde(rename_all = "snake_case")]
761#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
762#[derive(gproxy_protocol_macros::DeclaredFields)]
763pub struct ReasoningItem {
764    #[serde(
765        default,
766        deserialize_with = "present_nullable",
767        skip_serializing_if = "Option::is_none"
768    )]
769    pub agent: Option<Option<super::multi_agent::Agent>>,
770    #[serde(rename = "type")]
771    pub type_: ReasoningItemType,
772    pub id: String,
773    pub summary: Vec<SummaryText>,
774    #[serde(
775        default,
776        deserialize_with = "present_optional",
777        skip_serializing_if = "Option::is_none"
778    )]
779    pub content: Option<Vec<ReasoningContent>>,
780    #[serde(
781        default,
782        deserialize_with = "present_optional",
783        skip_serializing_if = "Option::is_none"
784    )]
785    pub status: Option<ReasoningStatus>,
786    #[serde(
787        default,
788        deserialize_with = "present_nullable",
789        skip_serializing_if = "Option::is_none"
790    )]
791    pub encrypted_content: Option<Option<String>>,
792    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
793    pub rest: Rest,
794}
795#[derive(
796    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
797)]
798#[serde(rename_all = "snake_case")]
799#[derive(gproxy_protocol_macros::DeclaredFields)]
800pub struct ReasoningContent {
801    #[serde(rename = "type")]
802    pub type_: ReasoningTextType,
803    pub text: String,
804    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
805    pub rest: Rest,
806}
807#[derive(
808    Debug,
809    Clone,
810    Copy,
811    PartialEq,
812    Eq,
813    Serialize,
814    Deserialize,
815    gproxy_protocol_macros::DeclaredFields,
816)]
817pub enum ReasoningTextType {
818    #[serde(rename = "reasoning_text")]
819    ReasoningText,
820}
821#[derive(
822    Debug,
823    Clone,
824    Copy,
825    PartialEq,
826    Eq,
827    Serialize,
828    Deserialize,
829    gproxy_protocol_macros::DeclaredFields,
830)]
831pub enum ReasoningStatus {
832    #[serde(rename = "in_progress")]
833    InProgress,
834    #[serde(rename = "completed")]
835    Completed,
836    #[serde(rename = "incomplete")]
837    Incomplete,
838}
839#[derive(
840    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
841)]
842#[serde(rename_all = "snake_case")]
843#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
844#[derive(gproxy_protocol_macros::DeclaredFields)]
845pub struct SummaryText {
846    #[serde(rename = "type")]
847    pub type_: SummaryTextType,
848    pub text: String,
849    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
850    pub rest: Rest,
851}
852#[derive(
853    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
854)]
855#[serde(rename_all = "snake_case")]
856#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
857#[derive(gproxy_protocol_macros::DeclaredFields)]
858pub struct ItemReference {
859    #[serde(
860        default,
861        deserialize_with = "present_nullable",
862        skip_serializing_if = "Option::is_none"
863    )]
864    pub agent: Option<Option<super::multi_agent::Agent>>,
865    #[serde(
866        rename = "type",
867        default,
868        deserialize_with = "present_nullable",
869        skip_serializing_if = "Option::is_none"
870    )]
871    pub type_: Option<Option<ItemReferenceType>>,
872    pub id: String,
873    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
874    pub rest: Rest,
875}
876#[derive(
877    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
878)]
879#[serde(rename_all = "snake_case")]
880#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
881#[derive(gproxy_protocol_macros::DeclaredFields)]
882pub struct Compaction {
883    #[serde(
884        default,
885        deserialize_with = "present_nullable",
886        skip_serializing_if = "Option::is_none"
887    )]
888    pub agent: Option<Option<super::multi_agent::Agent>>,
889    #[serde(rename = "type")]
890    pub type_: CompactionType,
891    pub encrypted_content: String,
892    #[serde(
893        default,
894        deserialize_with = "present_nullable",
895        skip_serializing_if = "Option::is_none"
896    )]
897    pub id: Option<Option<String>>,
898    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
899    pub rest: Rest,
900}
901
902#[derive(
903    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
904)]
905#[serde(rename_all = "snake_case")]
906#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
907#[derive(gproxy_protocol_macros::DeclaredFields)]
908pub struct PendingSafetyCheck {
909    pub id: String,
910    #[serde(
911        default,
912        deserialize_with = "present_nullable",
913        skip_serializing_if = "Option::is_none"
914    )]
915    pub code: Option<Option<String>>,
916    #[serde(
917        default,
918        deserialize_with = "present_nullable",
919        skip_serializing_if = "Option::is_none"
920    )]
921    pub message: Option<Option<String>>,
922    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
923    pub rest: Rest,
924}
925
926#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
927#[serde(tag = "type")]
928#[derive(gproxy_protocol_macros::DeclaredFields)]
929pub enum Caller {
930    #[serde(rename = "direct")]
931    Direct(DirectCaller),
932    #[serde(rename = "program")]
933    Program(ProgramCaller),
934}
935#[derive(
936    Debug,
937    Clone,
938    PartialEq,
939    Eq,
940    Serialize,
941    Deserialize,
942    gproxy_protocol_macros::WireBuilder,
943    gproxy_protocol_macros::DeclaredFields,
944)]
945pub struct DirectCaller {
946    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
947    pub rest: Rest,
948}
949#[derive(
950    Debug,
951    Clone,
952    PartialEq,
953    Eq,
954    Serialize,
955    Deserialize,
956    gproxy_protocol_macros::WireBuilder,
957    gproxy_protocol_macros::DeclaredFields,
958)]
959pub struct ProgramCaller {
960    pub caller_id: String,
961    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
962    pub rest: Rest,
963}
964
965#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
966#[serde(tag = "type")]
967#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
968#[derive(gproxy_protocol_macros::DeclaredFields)]
969pub enum ComputerAction {
970    #[serde(rename = "click")]
971    Click(ClickAction),
972    #[serde(rename = "double_click")]
973    DoubleClick(DoubleClickAction),
974    #[serde(rename = "drag")]
975    Drag(DragAction),
976    #[serde(rename = "keypress")]
977    Keypress(KeypressAction),
978    #[serde(rename = "move")]
979    Move(MoveAction),
980    #[serde(rename = "screenshot")]
981    Screenshot(ScreenshotAction),
982    #[serde(rename = "scroll")]
983    Scroll(ScrollAction),
984    #[serde(rename = "type")]
985    Type(TypeAction),
986    #[serde(rename = "wait")]
987    Wait(WaitAction),
988}
989#[derive(
990    Debug,
991    Clone,
992    Copy,
993    PartialEq,
994    Eq,
995    Serialize,
996    Deserialize,
997    gproxy_protocol_macros::DeclaredFields,
998)]
999pub enum ComputerScreenshotType {
1000    #[serde(rename = "computer_screenshot")]
1001    ComputerScreenshot,
1002}
1003macro_rules! action_struct { ($name:ident { $($field:tt)* }) => { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)] #[serde(rename_all = "snake_case")] #[cfg_attr(not(feature = "exhaustive"), non_exhaustive)] #[derive(gproxy_protocol_macros::DeclaredFields)]
1004pub struct $name { $($field)* #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")] pub rest: Rest } }; }
1005action_struct!(ClickAction { pub button: ClickButton, pub x: i64, pub y: i64, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub keys: Option<Option<Vec<String>>>, });
1006action_struct!(DoubleClickAction { pub x: i64, pub y: i64, #[wire(required)] #[serde(deserialize_with = "required_nullable")] pub keys: Option<Vec<String>>, });
1007action_struct!(DragAction { pub path: Vec<Coordinate>, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub keys: Option<Option<Vec<String>>>, });
1008action_struct!(KeypressAction { pub keys: Vec<String>, });
1009action_struct!(MoveAction { pub x: i64, pub y: i64, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub keys: Option<Option<Vec<String>>>, });
1010action_struct!(ScreenshotAction {});
1011action_struct!(ScrollAction { pub scroll_x: i64, pub scroll_y: i64, pub x: i64, pub y: i64, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub keys: Option<Option<Vec<String>>>, });
1012action_struct!(TypeAction { pub text: String, });
1013action_struct!(WaitAction {});
1014action_struct!(Coordinate { pub x: i64, pub y: i64, });
1015
1016pub type ComputerToolCallOutput = ComputerScreenshot;
1017#[derive(
1018    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1019)]
1020#[serde(rename_all = "snake_case")]
1021#[derive(gproxy_protocol_macros::DeclaredFields)]
1022pub struct ComputerScreenshot {
1023    #[serde(rename = "type")]
1024    pub type_: ComputerScreenshotType,
1025    #[serde(
1026        default,
1027        deserialize_with = "present_optional",
1028        skip_serializing_if = "Option::is_none"
1029    )]
1030    pub file_id: Option<String>,
1031    #[serde(
1032        default,
1033        deserialize_with = "present_optional",
1034        skip_serializing_if = "Option::is_none"
1035    )]
1036    pub image_url: Option<String>,
1037    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1038    pub rest: Rest,
1039}
1040#[derive(
1041    Debug,
1042    Clone,
1043    Copy,
1044    PartialEq,
1045    Eq,
1046    Serialize,
1047    Deserialize,
1048    gproxy_protocol_macros::DeclaredFields,
1049)]
1050pub enum ClickButton {
1051    #[serde(rename = "left")]
1052    Left,
1053    #[serde(rename = "right")]
1054    Right,
1055    #[serde(rename = "wheel")]
1056    Wheel,
1057    #[serde(rename = "back")]
1058    Back,
1059    #[serde(rename = "forward")]
1060    Forward,
1061}
1062
1063#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1064#[serde(tag = "type")]
1065#[derive(gproxy_protocol_macros::DeclaredFields)]
1066pub enum WebSearchAction {
1067    #[serde(rename = "search")]
1068    Search(WebSearchQuery),
1069    #[serde(rename = "open_page")]
1070    OpenPage(WebSearchOpenPage),
1071    #[serde(rename = "find_in_page")]
1072    FindInPage(WebSearchFindInPage),
1073}
1074action_struct!(WebSearchQuery { #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub queries: Option<Vec<String>>, #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub query: Option<String>, #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub sources: Option<Vec<WebSearchSource>>, });
1075action_struct!(WebSearchSource { #[serde(rename = "type")] pub type_: WebSearchSourceType, pub url: String, });
1076#[derive(
1077    Debug,
1078    Clone,
1079    Copy,
1080    PartialEq,
1081    Eq,
1082    Serialize,
1083    Deserialize,
1084    gproxy_protocol_macros::DeclaredFields,
1085)]
1086pub enum WebSearchSourceType {
1087    #[serde(rename = "url")]
1088    Url,
1089}
1090action_struct!(WebSearchOpenPage { #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub url: Option<Option<String>>, });
1091action_struct!(WebSearchFindInPage { pub pattern: String, pub url: String, });
1092#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1093#[serde(tag = "type")]
1094#[derive(gproxy_protocol_macros::DeclaredFields)]
1095pub enum CodeInterpreterOutput {
1096    #[serde(rename = "logs")]
1097    Logs(CodeLogs),
1098    #[serde(rename = "image")]
1099    Image(CodeImage),
1100}
1101action_struct!(CodeLogs { pub logs: String, });
1102action_struct!(CodeImage { pub url: String, });
1103
1104#[derive(
1105    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1106)]
1107#[serde(rename_all = "snake_case")]
1108#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1109#[derive(gproxy_protocol_macros::DeclaredFields)]
1110pub struct ComputerCall {
1111    #[serde(
1112        default,
1113        deserialize_with = "present_nullable",
1114        skip_serializing_if = "Option::is_none"
1115    )]
1116    pub agent: Option<Option<super::multi_agent::Agent>>,
1117    #[serde(rename = "type")]
1118    pub type_: ComputerCallType,
1119    pub id: String,
1120    pub call_id: String,
1121    #[serde(
1122        default,
1123        deserialize_with = "present_optional",
1124        skip_serializing_if = "Option::is_none"
1125    )]
1126    pub action: Option<ComputerAction>,
1127    #[serde(
1128        default,
1129        deserialize_with = "present_optional",
1130        skip_serializing_if = "Option::is_none"
1131    )]
1132    pub actions: Option<Vec<ComputerAction>>,
1133    pub pending_safety_checks: Vec<PendingSafetyCheck>,
1134    pub status: ItemStatus,
1135    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1136    pub rest: Rest,
1137}
1138#[derive(
1139    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1140)]
1141#[serde(rename_all = "snake_case")]
1142#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1143#[derive(gproxy_protocol_macros::DeclaredFields)]
1144pub struct ComputerCallOutput {
1145    #[serde(
1146        default,
1147        deserialize_with = "present_nullable",
1148        skip_serializing_if = "Option::is_none"
1149    )]
1150    pub agent: Option<Option<super::multi_agent::Agent>>,
1151    #[serde(rename = "type")]
1152    pub type_: ComputerCallOutputType,
1153    pub call_id: String,
1154    pub output: ComputerToolCallOutput,
1155    #[serde(
1156        default,
1157        deserialize_with = "present_nullable",
1158        skip_serializing_if = "Option::is_none"
1159    )]
1160    pub id: Option<Option<String>>,
1161    #[serde(
1162        default,
1163        deserialize_with = "present_nullable",
1164        skip_serializing_if = "Option::is_none"
1165    )]
1166    pub acknowledged_safety_checks: Option<Option<Vec<PendingSafetyCheck>>>,
1167    #[serde(
1168        default,
1169        deserialize_with = "present_nullable",
1170        skip_serializing_if = "Option::is_none"
1171    )]
1172    pub status: Option<Option<ItemStatus>>,
1173    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1174    pub rest: Rest,
1175}
1176#[derive(
1177    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1178)]
1179#[serde(rename_all = "snake_case")]
1180#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1181#[derive(gproxy_protocol_macros::DeclaredFields)]
1182pub struct WebSearchCall {
1183    #[serde(
1184        default,
1185        deserialize_with = "present_nullable",
1186        skip_serializing_if = "Option::is_none"
1187    )]
1188    pub agent: Option<Option<super::multi_agent::Agent>>,
1189    #[serde(rename = "type")]
1190    pub type_: WebSearchCallType,
1191    pub id: String,
1192    /// The initial in-progress stream item precedes its search action.
1193    #[serde(
1194        default,
1195        deserialize_with = "present_optional",
1196        skip_serializing_if = "Option::is_none"
1197    )]
1198    pub action: Option<WebSearchAction>,
1199    pub status: WebSearchStatus,
1200    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1201    pub rest: Rest,
1202}
1203#[derive(
1204    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1205)]
1206#[serde(rename_all = "snake_case")]
1207#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1208#[derive(gproxy_protocol_macros::DeclaredFields)]
1209pub struct FileSearchCall {
1210    #[serde(
1211        default,
1212        deserialize_with = "present_nullable",
1213        skip_serializing_if = "Option::is_none"
1214    )]
1215    pub agent: Option<Option<super::multi_agent::Agent>>,
1216    #[serde(rename = "type")]
1217    pub type_: FileSearchCallType,
1218    pub id: String,
1219    pub queries: Vec<String>,
1220    pub status: FileSearchStatus,
1221    #[serde(
1222        default,
1223        deserialize_with = "present_nullable",
1224        skip_serializing_if = "Option::is_none"
1225    )]
1226    pub results: Option<Option<Vec<FileSearchResult>>>,
1227    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1228    pub rest: Rest,
1229}
1230#[derive(
1231    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1232)]
1233#[serde(rename_all = "snake_case")]
1234#[derive(gproxy_protocol_macros::DeclaredFields)]
1235pub struct FileSearchResult {
1236    #[serde(
1237        default,
1238        deserialize_with = "present_nullable",
1239        skip_serializing_if = "Option::is_none"
1240    )]
1241    pub attributes: Option<Option<std::collections::BTreeMap<String, FileAttributeValue>>>,
1242    #[serde(
1243        default,
1244        deserialize_with = "present_optional",
1245        skip_serializing_if = "Option::is_none"
1246    )]
1247    pub file_id: Option<String>,
1248    #[serde(
1249        default,
1250        deserialize_with = "present_optional",
1251        skip_serializing_if = "Option::is_none"
1252    )]
1253    pub filename: Option<String>,
1254    #[serde(
1255        default,
1256        deserialize_with = "present_optional",
1257        skip_serializing_if = "Option::is_none"
1258    )]
1259    pub score: Option<serde_json::Number>,
1260    #[serde(
1261        default,
1262        deserialize_with = "present_optional",
1263        skip_serializing_if = "Option::is_none"
1264    )]
1265    pub text: Option<String>,
1266    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1267    pub rest: Rest,
1268}
1269#[derive(
1270    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1271)]
1272#[serde(rename_all = "snake_case")]
1273#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1274#[derive(gproxy_protocol_macros::DeclaredFields)]
1275pub struct ImageGenerationCall {
1276    #[serde(
1277        default,
1278        deserialize_with = "present_nullable",
1279        skip_serializing_if = "Option::is_none"
1280    )]
1281    pub agent: Option<Option<super::multi_agent::Agent>>,
1282    #[serde(
1283        default,
1284        deserialize_with = "present_nullable",
1285        skip_serializing_if = "Option::is_none"
1286    )]
1287    pub action: Option<Option<ImageAction>>,
1288    #[serde(
1289        default,
1290        deserialize_with = "present_nullable",
1291        skip_serializing_if = "Option::is_none"
1292    )]
1293    pub background: Option<Option<ImageBackground>>,
1294    #[serde(
1295        default,
1296        deserialize_with = "present_nullable",
1297        skip_serializing_if = "Option::is_none"
1298    )]
1299    pub output_format: Option<Option<ImageOutputFormat>>,
1300    #[serde(
1301        default,
1302        deserialize_with = "present_nullable",
1303        skip_serializing_if = "Option::is_none"
1304    )]
1305    pub quality: Option<Option<ImageQuality>>,
1306    #[serde(
1307        default,
1308        deserialize_with = "present_nullable",
1309        skip_serializing_if = "Option::is_none"
1310    )]
1311    pub revised_prompt: Option<Option<String>>,
1312    #[serde(
1313        default,
1314        deserialize_with = "present_nullable",
1315        skip_serializing_if = "Option::is_none"
1316    )]
1317    pub size: Option<Option<String>>,
1318
1319    #[serde(rename = "type")]
1320    pub type_: ImageGenerationCallType,
1321    pub id: String,
1322    #[wire(required)]
1323    #[serde(deserialize_with = "required_nullable")]
1324    pub result: Option<String>,
1325    pub status: ImageGenerationStatus,
1326    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1327    pub rest: Rest,
1328}
1329#[derive(
1330    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1331)]
1332#[serde(rename_all = "snake_case")]
1333#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1334#[derive(gproxy_protocol_macros::DeclaredFields)]
1335pub struct CodeInterpreterCall {
1336    #[serde(
1337        default,
1338        deserialize_with = "present_nullable",
1339        skip_serializing_if = "Option::is_none"
1340    )]
1341    pub agent: Option<Option<super::multi_agent::Agent>>,
1342    #[serde(rename = "type")]
1343    pub type_: CodeInterpreterCallType,
1344    pub id: String,
1345    #[wire(required)]
1346    #[serde(deserialize_with = "required_nullable")]
1347    pub code: Option<String>,
1348    pub container_id: String,
1349    #[wire(required)]
1350    #[serde(deserialize_with = "required_nullable")]
1351    pub outputs: Option<Vec<CodeInterpreterOutput>>,
1352    pub status: CodeInterpreterStatus,
1353    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1354    pub rest: Rest,
1355}
1356#[derive(
1357    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1358)]
1359#[serde(rename_all = "snake_case")]
1360#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1361#[derive(gproxy_protocol_macros::DeclaredFields)]
1362pub struct CustomToolCall {
1363    #[serde(
1364        default,
1365        deserialize_with = "present_nullable",
1366        skip_serializing_if = "Option::is_none"
1367    )]
1368    pub agent: Option<Option<super::multi_agent::Agent>>,
1369    #[serde(rename = "async", skip_serializing_if = "Option::is_none")]
1370    pub async_: Option<bool>,
1371
1372    #[serde(rename = "type")]
1373    pub type_: CustomToolCallType,
1374    pub call_id: String,
1375    pub input: String,
1376    pub name: String,
1377    #[serde(
1378        default,
1379        deserialize_with = "present_optional",
1380        skip_serializing_if = "Option::is_none"
1381    )]
1382    pub id: Option<String>,
1383    #[serde(
1384        default,
1385        deserialize_with = "present_nullable",
1386        skip_serializing_if = "Option::is_none"
1387    )]
1388    pub caller: Option<Option<Caller>>,
1389    #[serde(
1390        default,
1391        deserialize_with = "present_optional",
1392        skip_serializing_if = "Option::is_none"
1393    )]
1394    pub namespace: Option<String>,
1395    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1396    pub rest: Rest,
1397}
1398#[derive(
1399    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1400)]
1401#[serde(rename_all = "snake_case")]
1402#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1403#[derive(gproxy_protocol_macros::DeclaredFields)]
1404pub struct CustomToolCallOutput {
1405    #[serde(
1406        default,
1407        deserialize_with = "present_nullable",
1408        skip_serializing_if = "Option::is_none"
1409    )]
1410    pub agent: Option<Option<super::multi_agent::Agent>>,
1411    #[serde(rename = "type")]
1412    pub type_: CustomToolCallOutputType,
1413    pub call_id: String,
1414    pub output: CustomOutput,
1415    #[serde(
1416        default,
1417        deserialize_with = "present_optional",
1418        skip_serializing_if = "Option::is_none"
1419    )]
1420    pub id: Option<String>,
1421    #[serde(
1422        default,
1423        deserialize_with = "present_nullable",
1424        skip_serializing_if = "Option::is_none"
1425    )]
1426    pub caller: Option<Option<Caller>>,
1427    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1428    pub rest: Rest,
1429}
1430
1431#[derive(
1432    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1433)]
1434#[serde(rename_all = "snake_case")]
1435#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1436#[derive(gproxy_protocol_macros::DeclaredFields)]
1437pub struct ResponseOutputMessage {
1438    #[serde(
1439        default,
1440        deserialize_with = "present_nullable",
1441        skip_serializing_if = "Option::is_none"
1442    )]
1443    pub agent: Option<Option<super::multi_agent::Agent>>,
1444    pub id: String,
1445    pub content: Vec<OutputContent>,
1446    pub role: OutputMessageRole,
1447    pub status: OutputMessageStatus,
1448    #[serde(
1449        default,
1450        deserialize_with = "present_nullable",
1451        skip_serializing_if = "Option::is_none"
1452    )]
1453    pub phase: Option<Option<MessagePhase>>,
1454    #[serde(rename = "type")]
1455    pub type_: MessageType,
1456    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1457    pub rest: Rest,
1458}
1459
1460#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1461#[serde(untagged)]
1462#[derive(gproxy_protocol_macros::DeclaredFields)]
1463pub enum OutputContent {
1464    Text(ResponseOutputText),
1465    Refusal(ResponseOutputRefusal),
1466}
1467
1468#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1469#[serde(rename_all = "snake_case")]
1470#[derive(gproxy_protocol_macros::DeclaredFields)]
1471pub enum OutputMessageRole {
1472    #[serde(rename = "assistant")]
1473    Assistant,
1474}
1475#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1476#[serde(rename_all = "snake_case")]
1477#[derive(gproxy_protocol_macros::DeclaredFields)]
1478pub enum OutputMessageStatus {
1479    #[serde(rename = "in_progress")]
1480    InProgress,
1481    #[serde(rename = "completed")]
1482    Completed,
1483    #[serde(rename = "incomplete")]
1484    Incomplete,
1485}
1486
1487macro_rules! simple_item {
1488    ($name:ident { $($field:tt)* }) => {
1489        #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
1490        #[serde(rename_all = "snake_case")]
1491        #[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1492        #[derive(gproxy_protocol_macros::DeclaredFields)]
1493pub struct $name { #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub agent: Option<Option<super::multi_agent::Agent>>, $($field)* #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")] pub rest: Rest }
1494    };
1495}
1496
1497simple_item!(ToolSearchCall {
1498    #[serde(rename = "type")] pub type_: ToolSearchCallType,
1499    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1500    // Get input token counts.md:1183 explicitly declares arbitrary unknown JSON.
1501    pub arguments: serde_json::Value,
1502    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub call_id: Option<Option<String>>,
1503    #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub execution: Option<ToolExecution>,
1504    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub status: Option<Option<ItemStatus>>,
1505});
1506simple_item!(ToolSearchOutput {
1507    #[serde(rename = "type")] pub type_: ToolSearchOutputType,
1508    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1509    pub tools: Vec<Tool>,
1510    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub call_id: Option<Option<String>>,
1511    #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub execution: Option<ToolExecution>,
1512    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub status: Option<Option<ItemStatus>>,
1513});
1514simple_item!(AdditionalTools {
1515    #[serde(rename = "type")] pub type_: AdditionalToolsType,
1516    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1517    pub role: AdditionalToolsRole, pub tools: Vec<Tool>,
1518});
1519simple_item!(LocalShellCall {
1520    #[serde(rename = "type")] pub type_: LocalShellCallType,
1521    pub id: String, pub call_id: String, pub action: LocalShellAction,
1522    pub status: ItemStatus,
1523});
1524simple_item!(LocalShellCallOutput {
1525    #[serde(rename = "type")] pub type_: LocalShellCallOutputType,
1526    pub id: String, pub output: String, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub status: Option<Option<ItemStatus>>,
1527});
1528simple_item!(ShellCall {
1529    #[serde(rename = "type")] pub type_: ShellCallType,
1530    pub call_id: String, pub action: ShellAction,
1531    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub caller: Option<Option<Caller>>,
1532    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub environment: Option<Option<ShellCallEnvironment>>,
1533    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1534    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub status: Option<Option<ItemStatus>>,
1535});
1536simple_item!(ShellCallOutput {
1537    #[serde(rename = "type")] pub type_: ShellCallOutputType,
1538    pub call_id: String, pub output: Vec<ShellOutputContent>,
1539    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub caller: Option<Option<Caller>>,
1540    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub max_output_length: Option<Option<i64>>,
1541    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1542    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub status: Option<Option<ItemStatus>>,
1543});
1544simple_item!(ApplyPatchCall {
1545    #[serde(rename = "type")] pub type_: ApplyPatchCallType,
1546    pub call_id: String, pub operation: ApplyPatchOperation, pub status: ApplyPatchStatus,
1547    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub caller: Option<Option<Caller>>,
1548    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1549});
1550simple_item!(ApplyPatchCallOutput {
1551    #[serde(rename = "type")] pub type_: ApplyPatchCallOutputType,
1552    pub call_id: String, pub status: ApplyPatchOutputStatus, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub output: Option<Option<String>>,
1553    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub caller: Option<Option<Caller>>,
1554    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1555});
1556simple_item!(McpListTools {
1557    #[serde(rename = "type")] pub type_: McpListToolsType,
1558    pub id: String, pub server_label: String, pub tools: Vec<McpToolDefinition>, #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub error: Option<Option<String>>,
1559});
1560simple_item!(McpApprovalRequest {
1561    #[serde(rename = "type")] pub type_: McpApprovalRequestType,
1562    pub id: String, pub arguments: String, pub name: String, pub server_label: String,
1563});
1564simple_item!(McpApprovalResponse {
1565    #[serde(rename = "type")] pub type_: McpApprovalResponseType,
1566    pub approval_request_id: String, pub approve: bool,
1567    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub id: Option<Option<String>>,
1568    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub reason: Option<Option<String>>,
1569});
1570simple_item!(McpCall {
1571    #[serde(rename = "type")] pub type_: McpCallType,
1572    pub id: String, pub arguments: String, pub name: String, pub server_label: String,
1573    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub approval_request_id: Option<Option<String>>,
1574    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub error: Option<Option<String>>,
1575    #[serde(default, deserialize_with = "present_nullable", skip_serializing_if = "Option::is_none")] pub output: Option<Option<String>>,
1576    #[serde(default, deserialize_with = "present_optional", skip_serializing_if = "Option::is_none")] pub status: Option<McpCallStatus>,
1577});
1578simple_item!(CompactionTrigger { #[serde(rename = "type")] pub type_: CompactionTriggerType, });
1579simple_item!(Program {
1580    #[serde(rename = "type")] pub type_: ProgramType,
1581    pub id: String, pub call_id: String, pub code: String, pub fingerprint: String,
1582});
1583simple_item!(ProgramOutput {
1584    #[serde(rename = "type")] pub type_: ProgramOutputType,
1585    pub id: String, pub call_id: String, pub result: String, pub status: ProgramOutputStatus,
1586});
1587
1588#[derive(
1589    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1590)]
1591#[serde(rename_all = "snake_case")]
1592#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1593#[derive(gproxy_protocol_macros::DeclaredFields)]
1594pub struct McpToolDefinition {
1595    pub name: String,
1596    // Get input token counts.md:3757: unknown schema, not a fixed wire object.
1597    pub input_schema: serde_json::Value,
1598    #[serde(
1599        default,
1600        deserialize_with = "present_nullable",
1601        skip_serializing_if = "Option::is_none"
1602    )]
1603    // Get input token counts.md:3765 permits arbitrary annotations JSON or null.
1604    pub annotations: Option<Option<serde_json::Value>>,
1605    #[serde(
1606        default,
1607        deserialize_with = "present_nullable",
1608        skip_serializing_if = "Option::is_none"
1609    )]
1610    pub description: Option<Option<String>>,
1611    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1612    pub rest: Rest,
1613}
1614
1615#[derive(
1616    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1617)]
1618#[serde(rename_all = "snake_case")]
1619#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1620#[derive(gproxy_protocol_macros::DeclaredFields)]
1621pub struct LocalShellAction {
1622    pub command: Vec<String>,
1623    pub env: std::collections::BTreeMap<String, String>,
1624    #[serde(rename = "type")]
1625    pub type_: LocalShellActionType,
1626    #[serde(
1627        default,
1628        deserialize_with = "present_nullable",
1629        skip_serializing_if = "Option::is_none"
1630    )]
1631    pub timeout_ms: Option<Option<i64>>,
1632    #[serde(
1633        default,
1634        deserialize_with = "present_nullable",
1635        skip_serializing_if = "Option::is_none"
1636    )]
1637    pub user: Option<Option<String>>,
1638    #[serde(
1639        default,
1640        deserialize_with = "present_nullable",
1641        skip_serializing_if = "Option::is_none"
1642    )]
1643    pub working_directory: Option<Option<String>>,
1644    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1645    pub rest: Rest,
1646}
1647#[derive(
1648    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1649)]
1650#[serde(rename_all = "snake_case")]
1651#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1652#[derive(gproxy_protocol_macros::DeclaredFields)]
1653pub struct ShellAction {
1654    pub commands: Vec<String>,
1655    #[serde(
1656        default,
1657        deserialize_with = "present_nullable",
1658        skip_serializing_if = "Option::is_none"
1659    )]
1660    pub timeout_ms: Option<Option<i64>>,
1661    #[serde(
1662        default,
1663        deserialize_with = "present_nullable",
1664        skip_serializing_if = "Option::is_none"
1665    )]
1666    pub max_output_length: Option<Option<i64>>,
1667    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1668    pub rest: Rest,
1669}
1670#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1671#[serde(tag = "type")]
1672#[derive(gproxy_protocol_macros::DeclaredFields)]
1673pub enum ApplyPatchOperation {
1674    #[serde(rename = "create_file")]
1675    Create(ApplyPatchCreate),
1676    #[serde(rename = "delete_file")]
1677    Delete(ApplyPatchDelete),
1678    #[serde(rename = "update_file")]
1679    Update(ApplyPatchUpdate),
1680}
1681action_struct!(ApplyPatchCreate { pub path: String, pub diff: String, });
1682action_struct!(ApplyPatchDelete { pub path: String, });
1683action_struct!(ApplyPatchUpdate { pub path: String, pub diff: String, });
1684#[derive(
1685    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1686)]
1687#[serde(rename_all = "snake_case")]
1688#[derive(gproxy_protocol_macros::DeclaredFields)]
1689pub struct ShellOutputContent {
1690    pub stdout: String,
1691    pub stderr: String,
1692    pub outcome: ShellOutputOutcome,
1693    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1694    pub rest: Rest,
1695}
1696#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1697#[serde(tag = "type")]
1698#[derive(gproxy_protocol_macros::DeclaredFields)]
1699pub enum ShellOutputOutcome {
1700    #[serde(rename = "timeout")]
1701    Timeout(ShellTimeout),
1702    #[serde(rename = "exit")]
1703    Exit(ShellExit),
1704}
1705action_struct!(ShellTimeout {});
1706action_struct!(ShellExit { pub exit_code: i64, });
1707
1708#[derive(
1709    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1710)]
1711#[serde(rename_all = "snake_case")]
1712#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1713#[derive(gproxy_protocol_macros::DeclaredFields)]
1714pub struct TextConfig {
1715    #[serde(
1716        default,
1717        deserialize_with = "present_optional",
1718        skip_serializing_if = "Option::is_none"
1719    )]
1720    pub format: Option<TextFormat>,
1721    #[serde(
1722        default,
1723        deserialize_with = "present_nullable",
1724        skip_serializing_if = "Option::is_none"
1725    )]
1726    pub verbosity: Option<Option<TextVerbosity>>,
1727    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1728    pub rest: Rest,
1729}
1730#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1731#[serde(tag = "type")]
1732#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1733#[derive(gproxy_protocol_macros::DeclaredFields)]
1734pub enum TextFormat {
1735    #[serde(rename = "text")]
1736    Text(TextFormatText),
1737    #[serde(rename = "json_schema")]
1738    JsonSchema(TextFormatJsonSchema),
1739    #[serde(rename = "json_object")]
1740    JsonObject(TextFormatJsonObject),
1741}
1742#[derive(
1743    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1744)]
1745#[serde(rename_all = "snake_case")]
1746#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1747#[derive(gproxy_protocol_macros::DeclaredFields)]
1748pub struct TextFormatText {
1749    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1750    pub rest: Rest,
1751}
1752#[derive(
1753    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1754)]
1755#[serde(rename_all = "snake_case")]
1756#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1757#[derive(gproxy_protocol_macros::DeclaredFields)]
1758pub struct TextFormatJsonSchema {
1759    pub name: String,
1760    // Get input token counts.md:4246: user-provided map[unknown] JSON Schema.
1761    pub schema: Rest,
1762    #[serde(
1763        default,
1764        deserialize_with = "present_optional",
1765        skip_serializing_if = "Option::is_none"
1766    )]
1767    pub description: Option<String>,
1768    #[serde(
1769        default,
1770        deserialize_with = "present_nullable",
1771        skip_serializing_if = "Option::is_none"
1772    )]
1773    pub strict: Option<Option<bool>>,
1774    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1775    pub rest: Rest,
1776}
1777#[derive(
1778    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1779)]
1780#[serde(rename_all = "snake_case")]
1781#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1782#[derive(gproxy_protocol_macros::DeclaredFields)]
1783pub struct TextFormatJsonObject {
1784    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1785    pub rest: Rest,
1786}
1787
1788#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1789#[serde(untagged)]
1790#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1791#[derive(gproxy_protocol_macros::DeclaredFields)]
1792pub enum ToolChoice {
1793    Mode(ToolChoiceMode),
1794    Allowed(ToolChoiceAllowed),
1795    Hosted(ToolChoiceHosted),
1796    Function(ToolChoiceFunction),
1797    Mcp(ToolChoiceMcp),
1798    Custom(ToolChoiceCustom),
1799    Programmatic(ToolChoiceProgrammatic),
1800    ApplyPatch(ToolChoiceApplyPatch),
1801    Shell(ToolChoiceShell),
1802}
1803
1804#[derive(
1805    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1806)]
1807#[serde(rename_all = "snake_case")]
1808#[derive(gproxy_protocol_macros::DeclaredFields)]
1809pub struct ToolChoiceHosted {
1810    #[serde(rename = "type")]
1811    pub type_: ToolChoiceHostedType,
1812    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1813    pub rest: Rest,
1814}
1815
1816#[derive(
1817    Debug,
1818    Clone,
1819    Copy,
1820    PartialEq,
1821    Eq,
1822    Serialize,
1823    Deserialize,
1824    gproxy_protocol_macros::DeclaredFields,
1825)]
1826pub enum ToolChoiceHostedType {
1827    #[serde(rename = "file_search")]
1828    FileSearch,
1829    #[serde(rename = "web_search_preview")]
1830    WebSearchPreview,
1831    #[serde(rename = "computer")]
1832    Computer,
1833    #[serde(rename = "computer_use_preview")]
1834    ComputerUsePreview,
1835    #[serde(rename = "computer_use")]
1836    ComputerUse,
1837    #[serde(rename = "code_interpreter")]
1838    CodeInterpreter,
1839    #[serde(rename = "image_generation")]
1840    ImageGeneration,
1841    #[serde(rename = "web_search_preview_2025_03_11")]
1842    WebSearchPreview20250311,
1843}
1844#[derive(
1845    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1846)]
1847#[serde(rename_all = "snake_case")]
1848#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1849#[derive(gproxy_protocol_macros::DeclaredFields)]
1850pub struct ToolChoiceAllowed {
1851    #[serde(rename = "type")]
1852    pub type_: ToolChoiceAllowedType,
1853    pub mode: AllowedToolChoiceMode,
1854    // Get input token counts.md:4334 declares array of map[unknown].
1855    pub tools: Vec<Rest>,
1856    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1857    pub rest: Rest,
1858}
1859
1860#[derive(
1861    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1862)]
1863#[serde(rename_all = "snake_case")]
1864#[derive(gproxy_protocol_macros::DeclaredFields)]
1865pub struct ToolChoiceFunction {
1866    #[serde(rename = "type")]
1867    pub type_: ToolChoiceFunctionType,
1868    pub name: String,
1869    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1870    pub rest: Rest,
1871}
1872#[derive(
1873    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1874)]
1875#[serde(rename_all = "snake_case")]
1876#[derive(gproxy_protocol_macros::DeclaredFields)]
1877pub struct ToolChoiceMcp {
1878    #[serde(rename = "type")]
1879    pub type_: ToolChoiceMcpType,
1880    pub server_label: String,
1881    #[serde(
1882        default,
1883        deserialize_with = "present_nullable",
1884        skip_serializing_if = "Option::is_none"
1885    )]
1886    pub name: Option<Option<String>>,
1887    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1888    pub rest: Rest,
1889}
1890#[derive(
1891    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
1892)]
1893#[serde(rename_all = "snake_case")]
1894#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1895#[derive(gproxy_protocol_macros::DeclaredFields)]
1896pub struct ToolChoiceCustom {
1897    #[serde(rename = "type")]
1898    pub type_: ToolChoiceCustomType,
1899    pub name: String,
1900    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
1901    pub rest: Rest,
1902}
1903
1904#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1905#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1906#[derive(gproxy_protocol_macros::DeclaredFields)]
1907pub enum ResponseInputTextType {
1908    #[serde(rename = "input_text")]
1909    ResponseInputText,
1910}
1911
1912#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1913#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1914#[derive(gproxy_protocol_macros::DeclaredFields)]
1915pub enum ResponseInputImageType {
1916    #[serde(rename = "input_image")]
1917    ResponseInputImage,
1918}
1919
1920#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1921#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1922#[derive(gproxy_protocol_macros::DeclaredFields)]
1923pub enum ResponseInputFileType {
1924    #[serde(rename = "input_file")]
1925    ResponseInputFile,
1926}
1927
1928#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1929#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1930#[derive(gproxy_protocol_macros::DeclaredFields)]
1931pub enum FunctionCallType {
1932    #[serde(rename = "function_call")]
1933    FunctionCall,
1934}
1935
1936#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1937#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1938#[derive(gproxy_protocol_macros::DeclaredFields)]
1939pub enum FunctionCallOutputType {
1940    #[serde(rename = "function_call_output")]
1941    FunctionCallOutput,
1942}
1943
1944#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1945#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1946#[derive(gproxy_protocol_macros::DeclaredFields)]
1947pub enum ReasoningItemType {
1948    #[serde(rename = "reasoning")]
1949    ReasoningItem,
1950}
1951
1952#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1953#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1954#[derive(gproxy_protocol_macros::DeclaredFields)]
1955pub enum ItemReferenceType {
1956    #[serde(rename = "item_reference")]
1957    ItemReference,
1958}
1959
1960#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1961#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1962#[derive(gproxy_protocol_macros::DeclaredFields)]
1963pub enum CompactionType {
1964    #[serde(rename = "compaction")]
1965    Compaction,
1966}
1967
1968#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1969#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1970#[derive(gproxy_protocol_macros::DeclaredFields)]
1971pub enum ComputerCallType {
1972    #[serde(rename = "computer_call")]
1973    ComputerCall,
1974}
1975
1976#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1977#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1978#[derive(gproxy_protocol_macros::DeclaredFields)]
1979pub enum ComputerCallOutputType {
1980    #[serde(rename = "computer_call_output")]
1981    ComputerCallOutput,
1982}
1983
1984#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1985#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1986#[derive(gproxy_protocol_macros::DeclaredFields)]
1987pub enum WebSearchCallType {
1988    #[serde(rename = "web_search_call")]
1989    WebSearchCall,
1990}
1991
1992#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1993#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
1994#[derive(gproxy_protocol_macros::DeclaredFields)]
1995pub enum FileSearchCallType {
1996    #[serde(rename = "file_search_call")]
1997    FileSearchCall,
1998}
1999
2000#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2001#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2002#[derive(gproxy_protocol_macros::DeclaredFields)]
2003pub enum ImageGenerationCallType {
2004    #[serde(rename = "image_generation_call")]
2005    ImageGenerationCall,
2006}
2007
2008#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2009#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2010#[derive(gproxy_protocol_macros::DeclaredFields)]
2011pub enum CodeInterpreterCallType {
2012    #[serde(rename = "code_interpreter_call")]
2013    CodeInterpreterCall,
2014}
2015
2016#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2017#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2018#[derive(gproxy_protocol_macros::DeclaredFields)]
2019pub enum CustomToolCallType {
2020    #[serde(rename = "custom_tool_call")]
2021    CustomToolCall,
2022}
2023
2024#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2025#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2026#[derive(gproxy_protocol_macros::DeclaredFields)]
2027pub enum CustomToolCallOutputType {
2028    #[serde(rename = "custom_tool_call_output")]
2029    CustomToolCallOutput,
2030}
2031
2032#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2033#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2034#[derive(gproxy_protocol_macros::DeclaredFields)]
2035pub enum SummaryTextType {
2036    #[serde(rename = "summary_text")]
2037    SummaryText,
2038}
2039
2040#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2041#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2042#[derive(gproxy_protocol_macros::DeclaredFields)]
2043pub enum ResponseOutputTextType {
2044    #[serde(rename = "output_text")]
2045    ResponseOutputText,
2046}
2047
2048#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2049#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2050#[derive(gproxy_protocol_macros::DeclaredFields)]
2051pub enum ResponseOutputRefusalType {
2052    #[serde(rename = "refusal")]
2053    ResponseOutputRefusal,
2054}
2055
2056#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2057#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2058#[derive(gproxy_protocol_macros::DeclaredFields)]
2059pub enum ToolChoiceAllowedType {
2060    #[serde(rename = "allowed_tools")]
2061    ToolChoiceAllowed,
2062}
2063
2064#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2065#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2066#[derive(gproxy_protocol_macros::DeclaredFields)]
2067pub enum ToolChoiceFunctionType {
2068    #[serde(rename = "function")]
2069    ToolChoiceFunction,
2070}
2071
2072#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2073#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2074#[derive(gproxy_protocol_macros::DeclaredFields)]
2075pub enum ToolChoiceMcpType {
2076    #[serde(rename = "mcp")]
2077    ToolChoiceMcp,
2078}
2079
2080#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2081#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2082#[derive(gproxy_protocol_macros::DeclaredFields)]
2083pub enum ToolChoiceCustomType {
2084    #[serde(rename = "custom")]
2085    ToolChoiceCustom,
2086}
2087
2088macro_rules! item_tag {
2089    ($name:ident, $variant:ident, $wire:literal) => {
2090        #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2091        #[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2092        #[derive(gproxy_protocol_macros::DeclaredFields)]
2093        pub enum $name {
2094            #[serde(rename = $wire)]
2095            $variant,
2096        }
2097    };
2098}
2099item_tag!(ToolSearchCallType, ToolSearchCall, "tool_search_call");
2100item_tag!(ToolSearchOutputType, ToolSearchOutput, "tool_search_output");
2101item_tag!(AdditionalToolsType, AdditionalTools, "additional_tools");
2102item_tag!(LocalShellCallType, LocalShellCall, "local_shell_call");
2103item_tag!(
2104    LocalShellCallOutputType,
2105    LocalShellCallOutput,
2106    "local_shell_call_output"
2107);
2108item_tag!(ShellCallType, ShellCall, "shell_call");
2109item_tag!(ShellCallOutputType, ShellCallOutput, "shell_call_output");
2110item_tag!(ApplyPatchCallType, ApplyPatchCall, "apply_patch_call");
2111item_tag!(
2112    ApplyPatchCallOutputType,
2113    ApplyPatchCallOutput,
2114    "apply_patch_call_output"
2115);
2116item_tag!(McpListToolsType, McpListTools, "mcp_list_tools");
2117item_tag!(
2118    McpApprovalRequestType,
2119    McpApprovalRequest,
2120    "mcp_approval_request"
2121);
2122item_tag!(
2123    McpApprovalResponseType,
2124    McpApprovalResponse,
2125    "mcp_approval_response"
2126);
2127item_tag!(McpCallType, McpCall, "mcp_call");
2128item_tag!(
2129    CompactionTriggerType,
2130    CompactionTrigger,
2131    "compaction_trigger"
2132);
2133item_tag!(ProgramType, Program, "program");
2134item_tag!(ProgramOutputType, ProgramOutput, "program_output");
2135item_tag!(LocalShellActionType, Exec, "exec");
2136#[derive(
2137    Debug,
2138    Clone,
2139    Copy,
2140    PartialEq,
2141    Eq,
2142    Serialize,
2143    Deserialize,
2144    gproxy_protocol_macros::DeclaredFields,
2145)]
2146pub enum ProgramOutputStatus {
2147    #[serde(rename = "completed")]
2148    Completed,
2149    #[serde(rename = "incomplete")]
2150    Incomplete,
2151}
2152#[derive(
2153    Debug,
2154    Clone,
2155    Copy,
2156    PartialEq,
2157    Eq,
2158    Serialize,
2159    Deserialize,
2160    gproxy_protocol_macros::DeclaredFields,
2161)]
2162pub enum ItemStatus {
2163    #[serde(rename = "in_progress")]
2164    InProgress,
2165    #[serde(rename = "completed")]
2166    Completed,
2167    #[serde(rename = "incomplete")]
2168    Incomplete,
2169}
2170
2171#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2172#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2173#[derive(gproxy_protocol_macros::DeclaredFields)]
2174pub enum MessageType {
2175    #[serde(rename = "message")]
2176    Message,
2177}
2178
2179#[derive(
2180    Debug,
2181    Clone,
2182    Copy,
2183    PartialEq,
2184    Eq,
2185    Serialize,
2186    Deserialize,
2187    gproxy_protocol_macros::DeclaredFields,
2188)]
2189pub enum MessagePhase {
2190    #[serde(rename = "commentary")]
2191    Commentary,
2192    #[serde(rename = "final_answer")]
2193    FinalAnswer,
2194}
2195
2196#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2197#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2198#[derive(gproxy_protocol_macros::DeclaredFields)]
2199pub enum MessageRole {
2200    #[serde(rename = "user")]
2201    User,
2202    #[serde(rename = "system")]
2203    System,
2204    #[serde(rename = "developer")]
2205    Developer,
2206    #[serde(rename = "assistant")]
2207    Assistant,
2208}
2209
2210#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2211#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2212#[derive(gproxy_protocol_macros::DeclaredFields)]
2213pub enum InputMessageRole {
2214    #[serde(rename = "user")]
2215    User,
2216    #[serde(rename = "system")]
2217    System,
2218    #[serde(rename = "developer")]
2219    Developer,
2220}
2221#[derive(
2222    Debug,
2223    Clone,
2224    Copy,
2225    PartialEq,
2226    Eq,
2227    Serialize,
2228    Deserialize,
2229    gproxy_protocol_macros::DeclaredFields,
2230)]
2231pub enum AdditionalToolsRole {
2232    #[serde(rename = "developer")]
2233    Developer,
2234}
2235
2236#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2237#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2238#[derive(gproxy_protocol_macros::DeclaredFields)]
2239pub enum ToolChoiceMode {
2240    #[serde(rename = "none")]
2241    None,
2242    #[serde(rename = "auto")]
2243    Auto,
2244    #[serde(rename = "required")]
2245    Required,
2246}
2247
2248#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2249#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2250#[derive(gproxy_protocol_macros::DeclaredFields)]
2251pub enum AllowedToolChoiceMode {
2252    #[serde(rename = "auto")]
2253    Auto,
2254    #[serde(rename = "required")]
2255    Required,
2256}
2257
2258#[derive(
2259    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
2260)]
2261#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2262#[derive(gproxy_protocol_macros::DeclaredFields)]
2263pub struct ToolChoiceProgrammatic {
2264    #[serde(rename = "type")]
2265    pub type_: ToolChoiceProgrammaticType,
2266    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2267    pub rest: Rest,
2268}
2269
2270#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2271#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2272#[derive(gproxy_protocol_macros::DeclaredFields)]
2273pub enum ToolChoiceProgrammaticType {
2274    #[serde(rename = "programmatic_tool_calling")]
2275    Tag,
2276}
2277
2278#[derive(
2279    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
2280)]
2281#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2282#[derive(gproxy_protocol_macros::DeclaredFields)]
2283pub struct ToolChoiceApplyPatch {
2284    #[serde(rename = "type")]
2285    pub type_: ToolChoiceApplyPatchType,
2286    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2287    pub rest: Rest,
2288}
2289
2290#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2291#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2292#[derive(gproxy_protocol_macros::DeclaredFields)]
2293pub enum ToolChoiceApplyPatchType {
2294    #[serde(rename = "apply_patch")]
2295    Tag,
2296}
2297
2298#[derive(
2299    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
2300)]
2301#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2302#[derive(gproxy_protocol_macros::DeclaredFields)]
2303pub struct ToolChoiceShell {
2304    #[serde(rename = "type")]
2305    pub type_: ToolChoiceShellType,
2306    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2307    pub rest: Rest,
2308}
2309
2310#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2311#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2312#[derive(gproxy_protocol_macros::DeclaredFields)]
2313pub enum ToolChoiceShellType {
2314    #[serde(rename = "shell")]
2315    Tag,
2316}
2317
2318// Get input token counts.md:1019-1037 differs from ordinary input text:
2319// the function-output cache breakpoint explicitly permits null.
2320#[derive(
2321    Debug,
2322    Clone,
2323    PartialEq,
2324    Eq,
2325    Serialize,
2326    Deserialize,
2327    gproxy_protocol_macros::WireBuilder,
2328    gproxy_protocol_macros::DeclaredFields,
2329)]
2330pub struct FunctionOutputText {
2331    #[serde(rename = "type")]
2332    pub type_: ResponseInputTextType,
2333    pub text: String,
2334    #[serde(
2335        default,
2336        deserialize_with = "present_nullable",
2337        skip_serializing_if = "Option::is_none"
2338    )]
2339    pub prompt_cache_breakpoint: Option<Option<PromptCacheBreakpoint>>,
2340    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2341    pub rest: Rest,
2342}
2343// D:3896-3917 uses ordinary input content rather than the function-output variants.
2344#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2345#[serde(untagged)]
2346#[derive(gproxy_protocol_macros::DeclaredFields)]
2347pub enum CustomOutput {
2348    Text(String),
2349    Content(Vec<InputContent>),
2350}
2351// D:3469-3475: input shell calls accept local/reference, never container_auto.
2352#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2353#[serde(untagged)]
2354#[derive(gproxy_protocol_macros::DeclaredFields)]
2355pub enum ShellCallEnvironment {
2356    Local(ShellLocalEnvironment),
2357    Reference(ShellContainerReference),
2358}
2359// D:466-478: file attributes are scalar values, not arbitrary JSON.
2360#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2361#[serde(untagged)]
2362#[derive(gproxy_protocol_macros::DeclaredFields)]
2363pub enum FileAttributeValue {
2364    Text(String),
2365    Number(serde_json::Number),
2366    Boolean(bool),
2367}
2368
2369#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2370#[serde(rename_all = "snake_case")]
2371#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2372#[derive(gproxy_protocol_macros::DeclaredFields)]
2373pub enum ImageDetail {
2374    Low,
2375    High,
2376    Auto,
2377    Original,
2378}
2379
2380#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2381#[serde(rename_all = "snake_case")]
2382#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2383#[derive(gproxy_protocol_macros::DeclaredFields)]
2384pub enum FileDetail {
2385    Auto,
2386    Low,
2387    High,
2388}
2389
2390#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2391#[serde(rename_all = "snake_case")]
2392#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2393#[derive(gproxy_protocol_macros::DeclaredFields)]
2394pub enum PromptCacheMode {
2395    Explicit,
2396}
2397
2398#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2399#[serde(rename_all = "snake_case")]
2400#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2401#[derive(gproxy_protocol_macros::DeclaredFields)]
2402pub enum WebSearchStatus {
2403    InProgress,
2404    Searching,
2405    Completed,
2406    Failed,
2407}
2408
2409#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2410#[serde(rename_all = "snake_case")]
2411#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2412#[derive(gproxy_protocol_macros::DeclaredFields)]
2413pub enum FileSearchStatus {
2414    InProgress,
2415    Searching,
2416    Completed,
2417    Incomplete,
2418    Failed,
2419}
2420
2421#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2422#[serde(rename_all = "snake_case")]
2423#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2424#[derive(gproxy_protocol_macros::DeclaredFields)]
2425pub enum ImageGenerationStatus {
2426    InProgress,
2427    Completed,
2428    Generating,
2429    Failed,
2430}
2431
2432#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2433#[serde(rename_all = "snake_case")]
2434#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2435#[derive(gproxy_protocol_macros::DeclaredFields)]
2436pub enum CodeInterpreterStatus {
2437    InProgress,
2438    Completed,
2439    Incomplete,
2440    Interpreting,
2441    Failed,
2442}
2443
2444#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2445#[serde(rename_all = "snake_case")]
2446#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2447#[derive(gproxy_protocol_macros::DeclaredFields)]
2448pub enum ApplyPatchStatus {
2449    InProgress,
2450    Completed,
2451}
2452
2453#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2454#[serde(rename_all = "snake_case")]
2455#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2456#[derive(gproxy_protocol_macros::DeclaredFields)]
2457pub enum ApplyPatchOutputStatus {
2458    Completed,
2459    Failed,
2460}
2461
2462#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2463#[serde(rename_all = "snake_case")]
2464#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2465#[derive(gproxy_protocol_macros::DeclaredFields)]
2466pub enum McpCallStatus {
2467    InProgress,
2468    Completed,
2469    Incomplete,
2470    Calling,
2471    Failed,
2472}
2473
2474#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2475#[serde(rename_all = "snake_case")]
2476#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2477#[derive(gproxy_protocol_macros::DeclaredFields)]
2478pub enum ReasoningEffort {
2479    None,
2480    Minimal,
2481    Low,
2482    Medium,
2483    High,
2484    Xhigh,
2485    Max,
2486    /// Codex custom effort is serialized as an unsigned JSON integer.
2487    #[serde(untagged)]
2488    Numeric(u64),
2489}
2490
2491#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2492#[serde(rename_all = "snake_case")]
2493#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2494#[derive(gproxy_protocol_macros::DeclaredFields)]
2495pub enum ReasoningSummary {
2496    Auto,
2497    Concise,
2498    Detailed,
2499}
2500
2501#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2502#[serde(rename_all = "snake_case")]
2503#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2504#[derive(gproxy_protocol_macros::DeclaredFields)]
2505pub enum ReasoningContext {
2506    Auto,
2507    CurrentTurn,
2508    AllTurns,
2509}
2510
2511#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
2512#[serde(rename_all = "snake_case")]
2513#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2514#[derive(gproxy_protocol_macros::DeclaredFields)]
2515pub enum TextVerbosity {
2516    Low,
2517    Medium,
2518    High,
2519}
2520
2521#[derive(
2522    Debug,
2523    Clone,
2524    Copy,
2525    PartialEq,
2526    Eq,
2527    Serialize,
2528    Deserialize,
2529    gproxy_protocol_macros::DeclaredFields,
2530)]
2531#[serde(rename_all = "snake_case")]
2532#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2533pub enum ConfigurationUpdateType {
2534    ConfigurationUpdate,
2535}
2536
2537#[derive(
2538    Debug,
2539    Clone,
2540    PartialEq,
2541    Eq,
2542    Serialize,
2543    Deserialize,
2544    gproxy_protocol_macros::WireBuilder,
2545    gproxy_protocol_macros::DeclaredFields,
2546)]
2547#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2548pub struct ConfigurationUpdate {
2549    #[serde(
2550        default,
2551        deserialize_with = "present_nullable",
2552        skip_serializing_if = "Option::is_none"
2553    )]
2554    pub agent: Option<Option<super::multi_agent::Agent>>,
2555    #[serde(rename = "type")]
2556    pub type_: ConfigurationUpdateType,
2557    #[serde(
2558        default,
2559        deserialize_with = "present_nullable",
2560        skip_serializing_if = "Option::is_none"
2561    )]
2562    pub id: Option<Option<String>>,
2563    #[serde(skip_serializing_if = "Option::is_none")]
2564    pub reasoning: Option<ConfigurationReasoning>,
2565    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2566    pub rest: Rest,
2567}
2568
2569#[derive(
2570    Debug,
2571    Clone,
2572    PartialEq,
2573    Eq,
2574    Serialize,
2575    Deserialize,
2576    gproxy_protocol_macros::WireBuilder,
2577    gproxy_protocol_macros::DeclaredFields,
2578)]
2579#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
2580pub struct ConfigurationReasoning {
2581    #[serde(
2582        default,
2583        deserialize_with = "present_nullable",
2584        skip_serializing_if = "Option::is_none"
2585    )]
2586    pub effort: Option<Option<ReasoningEffort>>,
2587    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
2588    pub rest: Rest,
2589}
2590
2591impl InputItem {
2592    pub fn agent(&self) -> Option<&super::multi_agent::Agent> {
2593        match self {
2594            Self::ConfigurationUpdate(v) => v.agent.as_ref().and_then(Option::as_ref),
2595            Self::OutputMessage(v) => v.agent.as_ref().and_then(Option::as_ref),
2596            Self::Message(v) => v.agent.as_ref().and_then(Option::as_ref),
2597            Self::Easy(v) => v.agent.as_ref().and_then(Option::as_ref),
2598            Self::FunctionCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2599            Self::FunctionCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2600            Self::Reasoning(v) => v.agent.as_ref().and_then(Option::as_ref),
2601            Self::ItemReference(v) => v.agent.as_ref().and_then(Option::as_ref),
2602            Self::Compaction(v) => v.agent.as_ref().and_then(Option::as_ref),
2603            Self::ComputerCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2604            Self::ComputerCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2605            Self::WebSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2606            Self::FileSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2607            Self::ImageGenerationCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2608            Self::CodeInterpreterCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2609            Self::CustomToolCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2610            Self::CustomToolCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2611            Self::ToolSearchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2612            Self::ToolSearchOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2613            Self::AdditionalTools(v) => v.agent.as_ref().and_then(Option::as_ref),
2614            Self::LocalShellCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2615            Self::LocalShellCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2616            Self::ShellCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2617            Self::ShellCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2618            Self::ApplyPatchCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2619            Self::ApplyPatchCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2620            Self::McpListTools(v) => v.agent.as_ref().and_then(Option::as_ref),
2621            Self::McpApprovalRequest(v) => v.agent.as_ref().and_then(Option::as_ref),
2622            Self::McpApprovalResponse(v) => v.agent.as_ref().and_then(Option::as_ref),
2623            Self::McpCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2624            Self::CompactionTrigger(v) => v.agent.as_ref().and_then(Option::as_ref),
2625            Self::Program(v) => v.agent.as_ref().and_then(Option::as_ref),
2626            Self::ProgramOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2627            Self::MultiAgentCall(v) => v.agent.as_ref().and_then(Option::as_ref),
2628            Self::MultiAgentCallOutput(v) => v.agent.as_ref().and_then(Option::as_ref),
2629            Self::AgentMessage(v) => v.agent.as_ref().and_then(Option::as_ref),
2630        }
2631    }
2632}