Skip to main content

codex/cli/
debug.rs

1use crate::CliOverridesPatch;
2
3/// Request for `codex debug`.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct DebugCommandRequest {
6    /// Per-call CLI overrides layered on top of the builder.
7    pub overrides: CliOverridesPatch,
8}
9
10impl DebugCommandRequest {
11    pub fn new() -> Self {
12        Self {
13            overrides: CliOverridesPatch::default(),
14        }
15    }
16
17    /// Replaces the default CLI overrides for this request.
18    pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
19        self.overrides = overrides;
20        self
21    }
22}
23
24impl Default for DebugCommandRequest {
25    fn default() -> Self {
26        Self::new()
27    }
28}
29
30/// Request for `codex debug help [COMMAND]...`.
31#[derive(Clone, Debug, Eq, PartialEq)]
32pub struct DebugHelpRequest {
33    /// Optional command tokens passed after `help` (variadic).
34    pub command: Vec<String>,
35    /// Per-call CLI overrides layered on top of the builder.
36    pub overrides: CliOverridesPatch,
37}
38
39impl DebugHelpRequest {
40    pub fn new() -> Self {
41        Self {
42            command: Vec::new(),
43            overrides: CliOverridesPatch::default(),
44        }
45    }
46
47    /// Sets the optional `COMMAND` tokens.
48    pub fn command(mut self, command: impl IntoIterator<Item = impl Into<String>>) -> Self {
49        self.command = command.into_iter().map(Into::into).collect();
50        self
51    }
52
53    /// Replaces the default CLI overrides for this request.
54    pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
55        self.overrides = overrides;
56        self
57    }
58}
59
60impl Default for DebugHelpRequest {
61    fn default() -> Self {
62        Self::new()
63    }
64}
65
66/// Request for `codex debug app-server`.
67#[derive(Clone, Debug, Eq, PartialEq)]
68pub struct DebugAppServerRequest {
69    /// Per-call CLI overrides layered on top of the builder.
70    pub overrides: CliOverridesPatch,
71}
72
73impl DebugAppServerRequest {
74    pub fn new() -> Self {
75        Self {
76            overrides: CliOverridesPatch::default(),
77        }
78    }
79
80    /// Replaces the default CLI overrides for this request.
81    pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
82        self.overrides = overrides;
83        self
84    }
85}
86
87impl Default for DebugAppServerRequest {
88    fn default() -> Self {
89        Self::new()
90    }
91}
92
93/// Request for `codex debug app-server help [COMMAND]...`.
94#[derive(Clone, Debug, Eq, PartialEq)]
95pub struct DebugAppServerHelpRequest {
96    /// Optional command tokens passed after `help` (variadic).
97    pub command: Vec<String>,
98    /// Per-call CLI overrides layered on top of the builder.
99    pub overrides: CliOverridesPatch,
100}
101
102impl DebugAppServerHelpRequest {
103    pub fn new() -> Self {
104        Self {
105            command: Vec::new(),
106            overrides: CliOverridesPatch::default(),
107        }
108    }
109
110    /// Sets the optional `COMMAND` tokens.
111    pub fn command(mut self, command: impl IntoIterator<Item = impl Into<String>>) -> Self {
112        self.command = command.into_iter().map(Into::into).collect();
113        self
114    }
115
116    /// Replaces the default CLI overrides for this request.
117    pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
118        self.overrides = overrides;
119        self
120    }
121}
122
123impl Default for DebugAppServerHelpRequest {
124    fn default() -> Self {
125        Self::new()
126    }
127}
128
129/// Request for `codex debug app-server send-message-v2 <USER_MESSAGE>`.
130#[derive(Clone, Debug, Eq, PartialEq)]
131pub struct DebugAppServerSendMessageV2Request {
132    /// Message payload sent to the app-server debug shim.
133    pub user_message: String,
134    /// Per-call CLI overrides layered on top of the builder.
135    pub overrides: CliOverridesPatch,
136}
137
138impl DebugAppServerSendMessageV2Request {
139    pub fn new(user_message: impl Into<String>) -> Self {
140        Self {
141            user_message: user_message.into(),
142            overrides: CliOverridesPatch::default(),
143        }
144    }
145
146    /// Replaces the default CLI overrides for this request.
147    pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
148        self.overrides = overrides;
149        self
150    }
151}