Skip to main content

codexwire_protocol/
generated.rs

1// @generated by scripts/gen-codex-protocol from
2// schema/ (codex 0.167.0). Do not edit.
3
4use alloc::collections::BTreeMap;
5
6use serde::{Deserialize, Serialize, de::DeserializeOwned};
7use serde_json::Value;
8
9/// The Codex version this schema came from (`codex --version`).
10pub const CODEX_VERSION: &str = "0.167.0";
11
12/// A client request: its method name and response type.
13pub trait Request: Serialize {
14    const METHOD: &'static str;
15    type Response: DeserializeOwned;
16}
17
18/// A server notification: its method name.
19pub trait Notification: DeserializeOwned {
20    const METHOD: &'static str;
21}
22
23/// A server-to-client request: its method name and response type.
24pub trait ServerRequest: DeserializeOwned {
25    const METHOD: &'static str;
26    type Response: Serialize;
27}
28
29impl Request for InitializeParams {
30    const METHOD: &'static str = "initialize";
31    type Response = InitializeResponse;
32}
33impl Request for ThreadStartParams {
34    const METHOD: &'static str = "thread/start";
35    type Response = ThreadStartResponse;
36}
37impl Request for ThreadResumeParams {
38    const METHOD: &'static str = "thread/resume";
39    type Response = ThreadResumeResponse;
40}
41impl Request for TurnStartParams {
42    const METHOD: &'static str = "turn/start";
43    type Response = TurnStartResponse;
44}
45impl Request for TurnInterruptParams {
46    const METHOD: &'static str = "turn/interrupt";
47    type Response = TurnInterruptResponse;
48}
49impl Notification for ErrorNotification {
50    const METHOD: &'static str = "error";
51}
52impl Notification for ThreadStartedNotification {
53    const METHOD: &'static str = "thread/started";
54}
55impl Notification for TurnStartedNotification {
56    const METHOD: &'static str = "turn/started";
57}
58impl Notification for TurnCompletedNotification {
59    const METHOD: &'static str = "turn/completed";
60}
61impl Notification for ItemStartedNotification {
62    const METHOD: &'static str = "item/started";
63}
64impl Notification for ItemCompletedNotification {
65    const METHOD: &'static str = "item/completed";
66}
67impl Notification for AgentMessageDeltaNotification {
68    const METHOD: &'static str = "item/agentMessage/delta";
69}
70impl Notification for ThreadTokenUsageUpdatedNotification {
71    const METHOD: &'static str = "thread/tokenUsage/updated";
72}
73impl Notification for AccountRateLimitsUpdatedNotification {
74    const METHOD: &'static str = "account/rateLimits/updated";
75}
76impl ServerRequest for CommandExecutionRequestApprovalParams {
77    const METHOD: &'static str = "item/commandExecution/requestApproval";
78    type Response = CommandExecutionRequestApprovalResponse;
79}
80impl ServerRequest for FileChangeRequestApprovalParams {
81    const METHOD: &'static str = "item/fileChange/requestApproval";
82    type Response = FileChangeRequestApprovalResponse;
83}
84impl ServerRequest for McpServerElicitationRequestParams {
85    const METHOD: &'static str = "mcpServer/elicitation/request";
86    type Response = McpServerElicitationRequestResponse;
87}
88
89/// A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).
90///
91/// IMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using \[AbsolutePathBufGuard::new\]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.
92pub type AbsolutePathBuf = String;
93
94/// Sparse rolling rate-limit update.
95///
96/// Clients should merge available values into the most recent `account/rateLimits/read` response or refetch that snapshot. Nullable account metadata may be unavailable in a rolling update and does not clear a previously observed value.
97#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
98pub struct AccountRateLimitsUpdatedNotification {
99    #[serde(rename = "rateLimits")]
100    pub rate_limits: RateLimitSnapshot,
101}
102
103#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
104pub struct AddPatchChangeKind {}
105
106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
107pub enum AgentMessageDelivery {
108    #[serde(rename = "async")]
109    Async,
110    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
111    #[serde(untagged)]
112    Unknown(Value),
113}
114
115#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
116pub struct AgentMessageDeltaNotification {
117    pub delta: String,
118    #[serde(rename = "itemId")]
119    pub item_id: String,
120    #[serde(rename = "threadId")]
121    pub thread_id: String,
122    #[serde(rename = "turnId")]
123    pub turn_id: String,
124}
125
126#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
127pub struct AgentMessageThreadItem {
128    /// Unix timestamp in milliseconds when the item completed, if recorded.
129    #[serde(rename = "completedAtMs")]
130    #[serde(default, skip_serializing_if = "Option::is_none")]
131    pub completed_at_ms: Option<i64>,
132    #[serde(default, skip_serializing_if = "Option::is_none")]
133    pub delivery: Option<AgentMessageDelivery>,
134    pub id: String,
135    #[serde(rename = "memoryCitation")]
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub memory_citation: Option<MemoryCitation>,
138    #[serde(default, skip_serializing_if = "Option::is_none")]
139    pub phase: Option<MessagePhase>,
140    #[serde(default, skip_serializing_if = "Option::is_none")]
141    pub questions: Option<Vec<AsyncUserInputQuestion>>,
142    /// Unix timestamp in milliseconds when the item started, if recorded.
143    #[serde(rename = "startedAtMs")]
144    #[serde(default, skip_serializing_if = "Option::is_none")]
145    pub started_at_ms: Option<i64>,
146    pub text: String,
147}
148
149pub type AgentPath = String;
150
151/// Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.
152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
153pub enum ApprovalsReviewer {
154    #[serde(rename = "user")]
155    User,
156    #[serde(rename = "auto_review")]
157    AutoReview,
158    #[serde(rename = "guardian_subagent")]
159    GuardianSubagent,
160    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
161    #[serde(untagged)]
162    Unknown(Value),
163}
164
165#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
166pub enum AskForApproval {
167    #[serde(rename = "untrusted")]
168    Untrusted,
169    #[serde(rename = "on-request")]
170    OnRequest,
171    #[serde(rename = "never")]
172    Never,
173    #[serde(rename = "granular")]
174    Granular(AskForApprovalGranular),
175    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
176    #[serde(untagged)]
177    Unknown(Value),
178}
179
180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
181pub struct AskForApprovalGranular {
182    pub mcp_elicitations: bool,
183    #[serde(default, skip_serializing_if = "Option::is_none")]
184    pub request_permissions: Option<bool>,
185    pub rules: bool,
186    pub sandbox_approval: bool,
187    #[serde(default, skip_serializing_if = "Option::is_none")]
188    pub skill_approval: Option<bool>,
189}
190
191pub type AsyncUserInputQuestion = Value;
192
193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
194pub struct AudioUserInput {
195    #[serde(rename = "fileId")]
196    #[serde(default, skip_serializing_if = "Option::is_none")]
197    pub file_id: Option<String>,
198    #[serde(default, skip_serializing_if = "Option::is_none")]
199    pub url: Option<String>,
200}
201
202#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
203pub struct ClientInfo {
204    pub name: String,
205    #[serde(default, skip_serializing_if = "Option::is_none")]
206    pub title: Option<String>,
207    pub version: String,
208}
209
210/// This translation layer make sure that we expose codex error code in camel case.
211///
212/// When an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant.
213#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
214pub enum CodexErrorInfo {
215    #[serde(rename = "contextWindowExceeded")]
216    ContextWindowExceeded,
217    #[serde(rename = "sessionBudgetExceeded")]
218    SessionBudgetExceeded,
219    #[serde(rename = "usageLimitExceeded")]
220    UsageLimitExceeded,
221    #[serde(rename = "rateLimitExceeded")]
222    RateLimitExceeded,
223    #[serde(rename = "flexUnavailable")]
224    FlexUnavailable,
225    #[serde(rename = "serverOverloaded")]
226    ServerOverloaded,
227    #[serde(rename = "modelNotFound")]
228    ModelNotFound,
229    #[serde(rename = "policyCapacityUnavailable")]
230    PolicyCapacityUnavailable,
231    #[serde(rename = "cyberPolicy")]
232    CyberPolicy,
233    #[serde(rename = "misalignmentPolicyViolation")]
234    MisalignmentPolicyViolation,
235    #[serde(rename = "tooManyDenials")]
236    TooManyDenials,
237    #[serde(rename = "internalServerError")]
238    InternalServerError,
239    #[serde(rename = "unauthorized")]
240    Unauthorized,
241    #[serde(rename = "badRequest")]
242    BadRequest,
243    #[serde(rename = "threadRollbackFailed")]
244    ThreadRollbackFailed,
245    #[serde(rename = "sandboxError")]
246    SandboxError,
247    #[serde(rename = "other")]
248    Other,
249    #[serde(rename = "httpConnectionFailed")]
250    HttpConnectionFailed(CodexErrorInfoHttpConnectionFailed),
251    /// Failed to connect to the response SSE stream.
252    #[serde(rename = "responseStreamConnectionFailed")]
253    ResponseStreamConnectionFailed(CodexErrorInfoResponseStreamConnectionFailed),
254    /// The response SSE stream disconnected in the middle of a turn before completion.
255    #[serde(rename = "responseStreamDisconnected")]
256    ResponseStreamDisconnected(CodexErrorInfoResponseStreamDisconnected),
257    /// Reached the retry limit for responses.
258    #[serde(rename = "responseTooManyFailedAttempts")]
259    ResponseTooManyFailedAttempts(CodexErrorInfoResponseTooManyFailedAttempts),
260    /// Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.
261    #[serde(rename = "activeTurnNotSteerable")]
262    ActiveTurnNotSteerable(CodexErrorInfoActiveTurnNotSteerable),
263    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
264    #[serde(untagged)]
265    Unknown(Value),
266}
267
268#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
269pub struct CodexErrorInfoActiveTurnNotSteerable {
270    #[serde(rename = "turnKind")]
271    pub turn_kind: NonSteerableTurnKind,
272}
273
274#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
275pub struct CodexErrorInfoHttpConnectionFailed {
276    #[serde(rename = "httpStatusCode")]
277    #[serde(default, skip_serializing_if = "Option::is_none")]
278    pub http_status_code: Option<u64>,
279}
280
281#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
282pub struct CodexErrorInfoResponseStreamConnectionFailed {
283    #[serde(rename = "httpStatusCode")]
284    #[serde(default, skip_serializing_if = "Option::is_none")]
285    pub http_status_code: Option<u64>,
286}
287
288#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
289pub struct CodexErrorInfoResponseStreamDisconnected {
290    #[serde(rename = "httpStatusCode")]
291    #[serde(default, skip_serializing_if = "Option::is_none")]
292    pub http_status_code: Option<u64>,
293}
294
295#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
296pub struct CodexErrorInfoResponseTooManyFailedAttempts {
297    #[serde(rename = "httpStatusCode")]
298    #[serde(default, skip_serializing_if = "Option::is_none")]
299    pub http_status_code: Option<u64>,
300}
301
302pub type CollabAgentState = Value;
303
304#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
305pub enum CollabAgentTool {
306    #[serde(rename = "spawnAgent")]
307    SpawnAgent,
308    #[serde(rename = "sendInput")]
309    SendInput,
310    #[serde(rename = "resumeAgent")]
311    ResumeAgent,
312    #[serde(rename = "wait")]
313    Wait,
314    #[serde(rename = "closeAgent")]
315    CloseAgent,
316    #[serde(rename = "sendMessage")]
317    SendMessage,
318    #[serde(rename = "followupTask")]
319    FollowupTask,
320    #[serde(rename = "interruptAgent")]
321    InterruptAgent,
322    #[serde(rename = "listAgents")]
323    ListAgents,
324    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
325    #[serde(untagged)]
326    Unknown(Value),
327}
328
329#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
330pub enum CollabAgentToolCallStatus {
331    #[serde(rename = "inProgress")]
332    InProgress,
333    #[serde(rename = "completed")]
334    Completed,
335    #[serde(rename = "failed")]
336    Failed,
337    #[serde(rename = "interrupted")]
338    Interrupted,
339    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
340    #[serde(untagged)]
341    Unknown(Value),
342}
343
344#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
345pub struct CollabAgentToolCallThreadItem {
346    /// Last known status of the target agents, when available.
347    #[serde(rename = "agentsStates")]
348    pub agents_states: BTreeMap<String, CollabAgentState>,
349    /// Unix timestamp in milliseconds when the item completed, if recorded.
350    #[serde(rename = "completedAtMs")]
351    #[serde(default, skip_serializing_if = "Option::is_none")]
352    pub completed_at_ms: Option<i64>,
353    /// Unique identifier for this collab tool call.
354    pub id: String,
355    /// Model requested for the spawned agent, when applicable.
356    #[serde(default, skip_serializing_if = "Option::is_none")]
357    pub model: Option<String>,
358    /// Prompt text sent as part of the collab tool call, when available.
359    #[serde(default, skip_serializing_if = "Option::is_none")]
360    pub prompt: Option<String>,
361    /// Reasoning effort requested for the spawned agent, when applicable.
362    #[serde(rename = "reasoningEffort")]
363    #[serde(default, skip_serializing_if = "Option::is_none")]
364    pub reasoning_effort: Option<ReasoningEffort>,
365    /// Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.
366    #[serde(rename = "receiverThreadIds")]
367    pub receiver_thread_ids: Vec<String>,
368    /// Thread ID of the agent issuing the collab request.
369    #[serde(rename = "senderThreadId")]
370    pub sender_thread_id: String,
371    /// Unix timestamp in milliseconds when the item started, if recorded.
372    #[serde(rename = "startedAtMs")]
373    #[serde(default, skip_serializing_if = "Option::is_none")]
374    pub started_at_ms: Option<i64>,
375    /// Current status of the collab tool call.
376    pub status: CollabAgentToolCallStatus,
377    /// Name of the collab tool that was invoked.
378    pub tool: CollabAgentTool,
379}
380
381/// Collaboration mode for a Codex session.
382#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
383pub struct CollaborationMode {
384    pub mode: ModeKind,
385    pub settings: Settings,
386}
387
388pub type CommandAction = Value;
389
390#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
391pub enum CommandExecutionApprovalDecision {
392    /// User approved the command.
393    #[serde(rename = "accept")]
394    Accept,
395    /// User approved the command and future prompts in the same session-scoped approval cache should run without prompting.
396    #[serde(rename = "acceptForSession")]
397    AcceptForSession,
398    /// User approved the command, and wants to apply the proposed execpolicy amendment so future matching commands can run without prompting.
399    #[serde(rename = "acceptWithExecpolicyAmendment")]
400    AcceptWithExecpolicyAmendment(CommandExecutionApprovalDecisionAcceptWithExecpolicyAmendment),
401    /// User chose a persistent network policy rule (allow/deny) for this host.
402    #[serde(rename = "applyNetworkPolicyAmendment")]
403    ApplyNetworkPolicyAmendment(CommandExecutionApprovalDecisionApplyNetworkPolicyAmendment),
404    /// User denied the command. The agent will continue the turn.
405    #[serde(rename = "decline")]
406    Decline,
407    /// User denied the command. The turn will also be immediately interrupted.
408    #[serde(rename = "cancel")]
409    Cancel,
410    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
411    #[serde(untagged)]
412    Unknown(Value),
413}
414
415#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
416pub struct CommandExecutionApprovalDecisionAcceptWithExecpolicyAmendment {
417    pub execpolicy_amendment: Vec<String>,
418}
419
420#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
421pub struct CommandExecutionApprovalDecisionApplyNetworkPolicyAmendment {
422    pub network_policy_amendment: NetworkPolicyAmendment,
423}
424
425/// Distinguishes a command approval from input sent to an existing terminal.
426#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
427pub enum CommandExecutionApprovalKind {
428    #[serde(rename = "command")]
429    Command,
430    #[serde(rename = "writeStdin")]
431    WriteStdin,
432    /// A managed checkpoint requiring a fresh human decision. Only `accept`, `decline`, and `cancel` are valid. Requires the `requiredHumanApproval` initialize capability. This prompt does not itself start a command execution item.
433    #[serde(rename = "humanCommand")]
434    HumanCommand,
435    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
436    #[serde(untagged)]
437    Unknown(Value),
438}
439
440#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
441pub struct CommandExecutionRequestApprovalParams {
442    /// Unique identifier for this specific approval callback.
443    ///
444    /// For regular shell/unified_exec approvals, this is null.
445    ///
446    /// For zsh-exec-bridge subcommand approvals, multiple callbacks can belong to one parent `itemId`, so `approvalId` is a distinct opaque callback id (a UUID) used to disambiguate routing. Stdin approvals also use a distinct callback id; inspect `kind` to distinguish them.
447    #[serde(rename = "approvalId")]
448    #[serde(default, skip_serializing_if = "Option::is_none")]
449    pub approval_id: Option<String>,
450    /// The command to be executed.
451    #[serde(default, skip_serializing_if = "Option::is_none")]
452    pub command: Option<String>,
453    /// Best-effort parsed command actions for friendly display.
454    #[serde(rename = "commandActions")]
455    #[serde(default, skip_serializing_if = "Option::is_none")]
456    pub command_actions: Option<Vec<CommandAction>>,
457    /// The command's working directory.
458    #[serde(default, skip_serializing_if = "Option::is_none")]
459    pub cwd: Option<LegacyAppPathString>,
460    /// Environment in which the command will run.
461    #[serde(rename = "environmentId")]
462    #[serde(default, skip_serializing_if = "Option::is_none")]
463    pub environment_id: Option<String>,
464    #[serde(rename = "itemId")]
465    pub item_id: String,
466    /// Kind of action under review. Defaults to `command` for older servers.
467    #[serde(default, skip_serializing_if = "Option::is_none")]
468    pub kind: Option<CommandExecutionApprovalKind>,
469    /// Optional context for a managed-network approval prompt.
470    #[serde(rename = "networkApprovalContext")]
471    #[serde(default, skip_serializing_if = "Option::is_none")]
472    pub network_approval_context: Option<NetworkApprovalContext>,
473    /// Optional proposed execpolicy amendment to allow similar commands without prompting.
474    #[serde(rename = "proposedExecpolicyAmendment")]
475    #[serde(default, skip_serializing_if = "Option::is_none")]
476    pub proposed_execpolicy_amendment: Option<Vec<String>>,
477    /// Optional proposed network policy amendments (allow/deny host) for future requests.
478    #[serde(rename = "proposedNetworkPolicyAmendments")]
479    #[serde(default, skip_serializing_if = "Option::is_none")]
480    pub proposed_network_policy_amendments: Option<Vec<NetworkPolicyAmendment>>,
481    /// Optional explanatory reason (e.g. request for network access).
482    #[serde(default, skip_serializing_if = "Option::is_none")]
483    pub reason: Option<String>,
484    /// Unix timestamp (in milliseconds) when this approval request started.
485    #[serde(rename = "startedAtMs")]
486    pub started_at_ms: i64,
487    #[serde(rename = "threadId")]
488    pub thread_id: String,
489    #[serde(rename = "turnId")]
490    pub turn_id: String,
491}
492
493#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
494pub struct CommandExecutionRequestApprovalResponse {
495    pub decision: CommandExecutionApprovalDecision,
496}
497
498#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
499pub enum CommandExecutionSource {
500    #[serde(rename = "agent")]
501    Agent,
502    #[serde(rename = "userShell")]
503    UserShell,
504    #[serde(rename = "unifiedExecStartup")]
505    UnifiedExecStartup,
506    #[serde(rename = "unifiedExecInteraction")]
507    UnifiedExecInteraction,
508    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
509    #[serde(untagged)]
510    Unknown(Value),
511}
512
513#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
514pub enum CommandExecutionStatus {
515    #[serde(rename = "inProgress")]
516    InProgress,
517    #[serde(rename = "completed")]
518    Completed,
519    #[serde(rename = "failed")]
520    Failed,
521    #[serde(rename = "declined")]
522    Declined,
523    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
524    #[serde(untagged)]
525    Unknown(Value),
526}
527
528#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
529pub struct CommandExecutionThreadItem {
530    /// The command's output, aggregated from stdout and stderr.
531    #[serde(rename = "aggregatedOutput")]
532    #[serde(default, skip_serializing_if = "Option::is_none")]
533    pub aggregated_output: Option<String>,
534    /// The command to be executed.
535    pub command: String,
536    /// A best-effort parsing of the command to understand the action(s) it will perform. This returns a list of CommandAction objects because a single shell command may be composed of many commands piped together.
537    #[serde(rename = "commandActions")]
538    pub command_actions: Vec<CommandAction>,
539    /// Unix timestamp in milliseconds when the item completed, if recorded.
540    #[serde(rename = "completedAtMs")]
541    #[serde(default, skip_serializing_if = "Option::is_none")]
542    pub completed_at_ms: Option<i64>,
543    /// The command's working directory.
544    pub cwd: LegacyAppPathString,
545    /// The duration of the command execution in milliseconds.
546    #[serde(rename = "durationMs")]
547    #[serde(default, skip_serializing_if = "Option::is_none")]
548    pub duration_ms: Option<i64>,
549    /// The command's exit code.
550    #[serde(rename = "exitCode")]
551    #[serde(default, skip_serializing_if = "Option::is_none")]
552    pub exit_code: Option<i64>,
553    pub id: String,
554    /// Trusted first-party plugin id when this command resolves to one plugin script.
555    #[serde(rename = "pluginId")]
556    #[serde(default, skip_serializing_if = "Option::is_none")]
557    pub plugin_id: Option<String>,
558    /// Identifier for the underlying PTY process (when available).
559    #[serde(rename = "processId")]
560    #[serde(default, skip_serializing_if = "Option::is_none")]
561    pub process_id: Option<String>,
562    /// Safe plugin-relative path when this command resolves to one plugin script.
563    #[serde(rename = "scriptPath")]
564    #[serde(default, skip_serializing_if = "Option::is_none")]
565    pub script_path: Option<String>,
566    #[serde(default, skip_serializing_if = "Option::is_none")]
567    pub source: Option<CommandExecutionSource>,
568    /// Unix timestamp in milliseconds when the item started, if recorded.
569    #[serde(rename = "startedAtMs")]
570    #[serde(default, skip_serializing_if = "Option::is_none")]
571    pub started_at_ms: Option<i64>,
572    pub status: CommandExecutionStatus,
573}
574
575#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
576pub struct ContextCompactionThreadItem {
577    /// Unix timestamp in milliseconds when the item completed, if recorded.
578    #[serde(rename = "completedAtMs")]
579    #[serde(default, skip_serializing_if = "Option::is_none")]
580    pub completed_at_ms: Option<i64>,
581    pub id: String,
582    /// Unix timestamp in milliseconds when the item started, if recorded.
583    #[serde(rename = "startedAtMs")]
584    #[serde(default, skip_serializing_if = "Option::is_none")]
585    pub started_at_ms: Option<i64>,
586}
587
588#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
589pub struct CreditsSnapshot {
590    #[serde(default, skip_serializing_if = "Option::is_none")]
591    pub balance: Option<String>,
592    #[serde(rename = "hasCredits")]
593    pub has_credits: bool,
594    pub unlimited: bool,
595}
596
597#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
598pub struct DeletePatchChangeKind {}
599
600pub type DynamicToolCallOutputContentItem = Value;
601
602#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
603pub enum DynamicToolCallStatus {
604    #[serde(rename = "inProgress")]
605    InProgress,
606    #[serde(rename = "completed")]
607    Completed,
608    #[serde(rename = "failed")]
609    Failed,
610    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
611    #[serde(untagged)]
612    Unknown(Value),
613}
614
615#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
616pub struct DynamicToolCallThreadItem {
617    pub arguments: Value,
618    /// Unix timestamp in milliseconds when the item completed, if recorded.
619    #[serde(rename = "completedAtMs")]
620    #[serde(default, skip_serializing_if = "Option::is_none")]
621    pub completed_at_ms: Option<i64>,
622    #[serde(rename = "contentItems")]
623    #[serde(default, skip_serializing_if = "Option::is_none")]
624    pub content_items: Option<Vec<DynamicToolCallOutputContentItem>>,
625    /// The duration of the dynamic tool call in milliseconds.
626    #[serde(rename = "durationMs")]
627    #[serde(default, skip_serializing_if = "Option::is_none")]
628    pub duration_ms: Option<i64>,
629    pub id: String,
630    #[serde(default, skip_serializing_if = "Option::is_none")]
631    pub namespace: Option<String>,
632    /// Unix timestamp in milliseconds when the item started, if recorded.
633    #[serde(rename = "startedAtMs")]
634    #[serde(default, skip_serializing_if = "Option::is_none")]
635    pub started_at_ms: Option<i64>,
636    pub status: DynamicToolCallStatus,
637    #[serde(default, skip_serializing_if = "Option::is_none")]
638    pub success: Option<bool>,
639    pub tool: String,
640}
641
642#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
643pub struct EnteredReviewModeThreadItem {
644    /// Unix timestamp in milliseconds when the item completed, if recorded.
645    #[serde(rename = "completedAtMs")]
646    #[serde(default, skip_serializing_if = "Option::is_none")]
647    pub completed_at_ms: Option<i64>,
648    pub id: String,
649    pub review: String,
650    /// Unix timestamp in milliseconds when the item started, if recorded.
651    #[serde(rename = "startedAtMs")]
652    #[serde(default, skip_serializing_if = "Option::is_none")]
653    pub started_at_ms: Option<i64>,
654}
655
656#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
657pub struct ErrorNotification {
658    pub error: TurnError,
659    #[serde(rename = "threadId")]
660    pub thread_id: String,
661    #[serde(rename = "turnId")]
662    pub turn_id: String,
663    #[serde(rename = "willRetry")]
664    pub will_retry: bool,
665}
666
667#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
668pub struct ExitedReviewModeThreadItem {
669    /// Unix timestamp in milliseconds when the item completed, if recorded.
670    #[serde(rename = "completedAtMs")]
671    #[serde(default, skip_serializing_if = "Option::is_none")]
672    pub completed_at_ms: Option<i64>,
673    pub id: String,
674    pub review: String,
675    /// Unix timestamp in milliseconds when the item started, if recorded.
676    #[serde(rename = "startedAtMs")]
677    #[serde(default, skip_serializing_if = "Option::is_none")]
678    pub started_at_ms: Option<i64>,
679}
680
681#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
682pub enum FileChangeApprovalDecision {
683    /// User approved the file changes.
684    #[serde(rename = "accept")]
685    Accept,
686    /// User approved the file changes and future changes to the same files should run without prompting.
687    #[serde(rename = "acceptForSession")]
688    AcceptForSession,
689    /// User denied the file changes. The agent will continue the turn.
690    #[serde(rename = "decline")]
691    Decline,
692    /// User denied the file changes. The turn will also be immediately interrupted.
693    #[serde(rename = "cancel")]
694    Cancel,
695    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
696    #[serde(untagged)]
697    Unknown(Value),
698}
699
700#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
701pub struct FileChangeRequestApprovalParams {
702    /// \[UNSTABLE\] When set, the agent is asking the user to allow writes under this root for the remainder of the session (unclear if this is honored today).
703    #[serde(rename = "grantRoot")]
704    #[serde(default, skip_serializing_if = "Option::is_none")]
705    pub grant_root: Option<String>,
706    #[serde(rename = "itemId")]
707    pub item_id: String,
708    /// Optional explanatory reason (e.g. request for extra write access).
709    #[serde(default, skip_serializing_if = "Option::is_none")]
710    pub reason: Option<String>,
711    /// Unix timestamp (in milliseconds) when this approval request started.
712    #[serde(rename = "startedAtMs")]
713    pub started_at_ms: i64,
714    #[serde(rename = "threadId")]
715    pub thread_id: String,
716    #[serde(rename = "turnId")]
717    pub turn_id: String,
718}
719
720#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
721pub struct FileChangeRequestApprovalResponse {
722    pub decision: FileChangeApprovalDecision,
723}
724
725#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
726pub struct FileChangeThreadItem {
727    pub changes: Vec<FileUpdateChange>,
728    /// Unix timestamp in milliseconds when the item completed, if recorded.
729    #[serde(rename = "completedAtMs")]
730    #[serde(default, skip_serializing_if = "Option::is_none")]
731    pub completed_at_ms: Option<i64>,
732    pub id: String,
733    /// Unix timestamp in milliseconds when the item started, if recorded.
734    #[serde(rename = "startedAtMs")]
735    #[serde(default, skip_serializing_if = "Option::is_none")]
736    pub started_at_ms: Option<i64>,
737    pub status: PatchApplyStatus,
738}
739
740#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
741pub struct FileUpdateChange {
742    pub diff: String,
743    pub kind: PatchChangeKind,
744    pub path: String,
745}
746
747pub type FunctionCallOutputBody = Value;
748
749#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
750pub struct FunctionCallOutputThreadItem {
751    /// Unix timestamp in milliseconds when the item completed, if recorded.
752    #[serde(rename = "completedAtMs")]
753    #[serde(default, skip_serializing_if = "Option::is_none")]
754    pub completed_at_ms: Option<i64>,
755    pub id: String,
756    pub name: String,
757    #[serde(default, skip_serializing_if = "Option::is_none")]
758    pub namespace: Option<String>,
759    pub output: FunctionCallOutputBody,
760    /// Unix timestamp in milliseconds when the item started, if recorded.
761    #[serde(rename = "startedAtMs")]
762    #[serde(default, skip_serializing_if = "Option::is_none")]
763    pub started_at_ms: Option<i64>,
764}
765
766pub type GitInfo = Value;
767
768pub type HookPromptFragment = Value;
769
770#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
771pub struct HookPromptThreadItem {
772    /// Unix timestamp in milliseconds when the item completed, if recorded.
773    #[serde(rename = "completedAtMs")]
774    #[serde(default, skip_serializing_if = "Option::is_none")]
775    pub completed_at_ms: Option<i64>,
776    pub fragments: Vec<HookPromptFragment>,
777    pub id: String,
778    /// Unix timestamp in milliseconds when the item started, if recorded.
779    #[serde(rename = "startedAtMs")]
780    #[serde(default, skip_serializing_if = "Option::is_none")]
781    pub started_at_ms: Option<i64>,
782}
783
784#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
785pub enum ImageDetail {
786    #[serde(rename = "auto")]
787    Auto,
788    #[serde(rename = "low")]
789    Low,
790    #[serde(rename = "high")]
791    High,
792    #[serde(rename = "original")]
793    Original,
794    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
795    #[serde(untagged)]
796    Unknown(Value),
797}
798
799#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
800#[serde(tag = "type")]
801pub enum ImageGenerationFailure {
802    #[serde(rename = "usageLimitExceeded")]
803    UsageLimitExceeded(UsageLimitExceededImageGenerationFailure),
804    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
805    #[serde(untagged)]
806    Unknown(Value),
807}
808
809/// A local image file successfully read for this exact image-generation request.
810#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
811pub struct ImageGenerationInputImage {
812    pub path: AbsolutePathBuf,
813    /// Lowercase SHA-256 of the file bytes read before image normalization.
814    pub sha256: String,
815}
816
817#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
818pub struct ImageGenerationThreadItem {
819    /// Unix timestamp in milliseconds when the item completed, if recorded.
820    #[serde(rename = "completedAtMs")]
821    #[serde(default, skip_serializing_if = "Option::is_none")]
822    pub completed_at_ms: Option<i64>,
823    #[serde(default, skip_serializing_if = "Option::is_none")]
824    pub failure: Option<ImageGenerationFailure>,
825    #[serde(rename = "fileId")]
826    #[serde(default, skip_serializing_if = "Option::is_none")]
827    pub file_id: Option<String>,
828    /// Image generation identifier for the generated image, when provided by the image backend.
829    #[serde(rename = "generationId")]
830    #[serde(default, skip_serializing_if = "Option::is_none")]
831    pub generation_id: Option<String>,
832    pub id: String,
833    /// Observed local inputs for a completed generation, absent on older items.
834    #[serde(rename = "inputImages")]
835    #[serde(default, skip_serializing_if = "Option::is_none")]
836    pub input_images: Option<Vec<ImageGenerationInputImage>>,
837    #[serde(default, skip_serializing_if = "Option::is_none")]
838    pub result: Option<String>,
839    #[serde(rename = "revisedPrompt")]
840    #[serde(default, skip_serializing_if = "Option::is_none")]
841    pub revised_prompt: Option<String>,
842    #[serde(rename = "savedPath")]
843    #[serde(default, skip_serializing_if = "Option::is_none")]
844    pub saved_path: Option<AbsolutePathBuf>,
845    /// Unix timestamp in milliseconds when the item started, if recorded.
846    #[serde(rename = "startedAtMs")]
847    #[serde(default, skip_serializing_if = "Option::is_none")]
848    pub started_at_ms: Option<i64>,
849    pub status: String,
850    #[serde(rename = "transparentBackground")]
851    #[serde(default, skip_serializing_if = "Option::is_none")]
852    pub transparent_background: Option<bool>,
853}
854
855#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
856pub struct ImageUserInput {
857    #[serde(default, skip_serializing_if = "Option::is_none")]
858    pub detail: Option<ImageDetail>,
859    #[serde(rename = "fileId")]
860    #[serde(default, skip_serializing_if = "Option::is_none")]
861    pub file_id: Option<String>,
862    #[serde(default, skip_serializing_if = "Option::is_none")]
863    pub url: Option<String>,
864}
865
866#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
867pub struct ImageViewThreadItem {
868    /// Unix timestamp in milliseconds when the item completed, if recorded.
869    #[serde(rename = "completedAtMs")]
870    #[serde(default, skip_serializing_if = "Option::is_none")]
871    pub completed_at_ms: Option<i64>,
872    pub id: String,
873    pub path: LegacyAppPathString,
874    /// Unix timestamp in milliseconds when the item started, if recorded.
875    #[serde(rename = "startedAtMs")]
876    #[serde(default, skip_serializing_if = "Option::is_none")]
877    pub started_at_ms: Option<i64>,
878}
879
880/// Client-declared capabilities negotiated during initialize.
881#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
882pub struct InitializeCapabilities {
883    /// Opt into receiving experimental API methods and fields.
884    #[serde(rename = "experimentalApi")]
885    #[serde(default, skip_serializing_if = "Option::is_none")]
886    pub experimental_api: Option<bool>,
887    /// Use explicit gateway OAuth login instead of automatic browser authorization. Applies to this app-server's gateway runtime; later connections cannot undo it.
888    #[serde(rename = "explicitGatewayOauth")]
889    #[serde(default, skip_serializing_if = "Option::is_none")]
890    pub explicit_gateway_oauth: Option<bool>,
891    /// MCP extension settings declared by the app-server client.
892    #[serde(default, skip_serializing_if = "Option::is_none")]
893    pub extensions: Option<BTreeMap<String, Value>>,
894    /// Legacy opt-in for the `openai/form` MCP extension.
895    ///
896    /// New clients should declare `openai/form` in [`Self::extensions`].
897    #[serde(rename = "mcpServerOpenaiFormElicitation")]
898    #[serde(default, skip_serializing_if = "Option::is_none")]
899    pub mcp_server_openai_form_elicitation: Option<bool>,
900    /// Exact notification method names that should be suppressed for this connection (for example `thread/started`).
901    #[serde(rename = "optOutNotificationMethods")]
902    #[serde(default, skip_serializing_if = "Option::is_none")]
903    pub opt_out_notification_methods: Option<Vec<String>>,
904    /// Opt into `attestation/generate` requests for upstream `x-oai-attestation`.
905    #[serde(rename = "requestAttestation")]
906    #[serde(default, skip_serializing_if = "Option::is_none")]
907    pub request_attestation: Option<bool>,
908    /// Present `humanCommand` approvals to a person and return only a one-time decision. Requires `experimentalApi`. Pending requests can be replayed to compatible clients.
909    #[serde(rename = "requiredHumanApproval")]
910    #[serde(default, skip_serializing_if = "Option::is_none")]
911    pub required_human_approval: Option<bool>,
912}
913
914#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
915pub struct InitializeParams {
916    #[serde(default, skip_serializing_if = "Option::is_none")]
917    pub capabilities: Option<InitializeCapabilities>,
918    #[serde(rename = "clientInfo")]
919    pub client_info: ClientInfo,
920}
921
922#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
923pub struct InitializeResponse {
924    /// Absolute path to the server's $CODEX_HOME directory.
925    #[serde(rename = "codexHome")]
926    pub codex_home: AbsolutePathBuf,
927    /// Platform family for the running app-server target, for example `"unix"` or `"windows"`.
928    #[serde(rename = "platformFamily")]
929    pub platform_family: String,
930    /// Operating system for the running app-server target, for example `"macos"`, `"linux"`, or `"windows"`.
931    #[serde(rename = "platformOs")]
932    pub platform_os: String,
933    #[serde(rename = "userAgent")]
934    pub user_agent: String,
935}
936
937#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
938pub struct ItemCompletedNotification {
939    /// Unix timestamp (in milliseconds) when this item lifecycle completed.
940    #[serde(rename = "completedAtMs")]
941    pub completed_at_ms: i64,
942    pub item: ThreadItem,
943    #[serde(rename = "threadId")]
944    pub thread_id: String,
945    #[serde(rename = "turnId")]
946    pub turn_id: String,
947}
948
949#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
950pub struct ItemStartedNotification {
951    pub item: ThreadItem,
952    /// Unix timestamp (in milliseconds) when this item lifecycle started.
953    #[serde(rename = "startedAtMs")]
954    pub started_at_ms: i64,
955    #[serde(rename = "threadId")]
956    pub thread_id: String,
957    #[serde(rename = "turnId")]
958    pub turn_id: String,
959}
960
961pub type LegacyAppPathString = String;
962
963#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
964pub struct LocalAudioUserInput {
965    pub path: String,
966}
967
968#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
969pub struct LocalImageUserInput {
970    #[serde(default, skip_serializing_if = "Option::is_none")]
971    pub detail: Option<ImageDetail>,
972    pub path: String,
973}
974
975#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
976pub enum McpAppDisplayMode {
977    #[serde(rename = "inline")]
978    Inline,
979    #[serde(rename = "fullscreen")]
980    Fullscreen,
981    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
982    #[serde(untagged)]
983    Unknown(Value),
984}
985
986/// UI resource and display preference for model invocations, captured from the tool descriptor.
987#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
988pub struct McpAppUi {
989    #[serde(rename = "preferredModelDisplayMode")]
990    pub preferred_model_display_mode: McpAppDisplayMode,
991    #[serde(rename = "resourceUri")]
992    pub resource_uri: String,
993}
994
995#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
996pub enum McpServerElicitationAction {
997    #[serde(rename = "accept")]
998    Accept,
999    #[serde(rename = "decline")]
1000    Decline,
1001    #[serde(rename = "cancel")]
1002    Cancel,
1003    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1004    #[serde(untagged)]
1005    Unknown(Value),
1006}
1007
1008pub type McpServerElicitationRequestParams = Value;
1009
1010#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1011pub struct McpServerElicitationRequestResponse {
1012    /// Optional client metadata for form-mode action handling.
1013    #[serde(rename = "_meta")]
1014    #[serde(default, skip_serializing_if = "Option::is_none")]
1015    pub meta: Option<Value>,
1016    pub action: McpServerElicitationAction,
1017    /// Structured user input for accepted elicitations, mirroring RMCP `CreateElicitationResult`.
1018    ///
1019    /// This is nullable because decline/cancel responses have no content.
1020    #[serde(default, skip_serializing_if = "Option::is_none")]
1021    pub content: Option<Value>,
1022}
1023
1024#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1025pub struct McpToolCallAppContext {
1026    #[serde(rename = "actionName")]
1027    #[serde(default, skip_serializing_if = "Option::is_none")]
1028    pub action_name: Option<String>,
1029    #[serde(rename = "appName")]
1030    #[serde(default, skip_serializing_if = "Option::is_none")]
1031    pub app_name: Option<String>,
1032    #[serde(rename = "connectorId")]
1033    pub connector_id: String,
1034    #[serde(rename = "linkId")]
1035    #[serde(default, skip_serializing_if = "Option::is_none")]
1036    pub link_id: Option<String>,
1037    #[serde(rename = "resourceUri")]
1038    #[serde(default, skip_serializing_if = "Option::is_none")]
1039    pub resource_uri: Option<String>,
1040}
1041
1042#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1043pub struct McpToolCallError {
1044    pub message: String,
1045}
1046
1047pub type McpToolCallResult = Value;
1048
1049#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1050pub enum McpToolCallStatus {
1051    #[serde(rename = "inProgress")]
1052    InProgress,
1053    #[serde(rename = "completed")]
1054    Completed,
1055    #[serde(rename = "failed")]
1056    Failed,
1057    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1058    #[serde(untagged)]
1059    Unknown(Value),
1060}
1061
1062#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1063pub struct McpToolCallThreadItem {
1064    #[serde(rename = "appContext")]
1065    #[serde(default, skip_serializing_if = "Option::is_none")]
1066    pub app_context: Option<McpToolCallAppContext>,
1067    pub arguments: Value,
1068    /// Unix timestamp in milliseconds when the item completed, if recorded.
1069    #[serde(rename = "completedAtMs")]
1070    #[serde(default, skip_serializing_if = "Option::is_none")]
1071    pub completed_at_ms: Option<i64>,
1072    /// The duration of the MCP tool call in milliseconds.
1073    #[serde(rename = "durationMs")]
1074    #[serde(default, skip_serializing_if = "Option::is_none")]
1075    pub duration_ms: Option<i64>,
1076    #[serde(default, skip_serializing_if = "Option::is_none")]
1077    pub error: Option<McpToolCallError>,
1078    pub id: String,
1079    /// Legacy compatibility field; prefer `mcpAppUi.resourceUri` when available.
1080    #[serde(rename = "mcpAppResourceUri")]
1081    #[serde(default, skip_serializing_if = "Option::is_none")]
1082    pub mcp_app_resource_uri: Option<String>,
1083    /// Presentation captured from the invoked descriptor; absent in older history.
1084    #[serde(rename = "mcpAppUi")]
1085    #[serde(default, skip_serializing_if = "Option::is_none")]
1086    pub mcp_app_ui: Option<McpAppUi>,
1087    #[serde(rename = "pluginId")]
1088    #[serde(default, skip_serializing_if = "Option::is_none")]
1089    pub plugin_id: Option<String>,
1090    #[serde(rename = "readOnlyHint")]
1091    #[serde(default, skip_serializing_if = "Option::is_none")]
1092    pub read_only_hint: Option<bool>,
1093    #[serde(default, skip_serializing_if = "Option::is_none")]
1094    pub result: Option<McpToolCallResult>,
1095    pub server: String,
1096    /// Unix timestamp in milliseconds when the item started, if recorded.
1097    #[serde(rename = "startedAtMs")]
1098    #[serde(default, skip_serializing_if = "Option::is_none")]
1099    pub started_at_ms: Option<i64>,
1100    pub status: McpToolCallStatus,
1101    pub tool: String,
1102}
1103
1104pub type MemoryCitation = Value;
1105
1106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1107pub struct MentionUserInput {
1108    pub name: String,
1109    pub path: String,
1110}
1111
1112/// Classifies assistant text as commentary, a partial answer, or a terminal answer.
1113///
1114/// Providers do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.
1115#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1116pub enum MessagePhase {
1117    /// Mid-turn assistant text (for example preamble/progress narration).
1118    ///
1119    /// Additional tool calls or assistant output may follow before turn completion.
1120    #[serde(rename = "commentary")]
1121    Commentary,
1122    /// Stable answer text that may be followed by more assistant output or tools.
1123    #[serde(rename = "partial_answer")]
1124    PartialAnswer,
1125    /// The assistant's declared terminal answer text for the current turn.
1126    #[serde(rename = "final_answer")]
1127    FinalAnswer,
1128    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1129    #[serde(untagged)]
1130    Unknown(Value),
1131}
1132
1133#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1134pub struct MisalignmentErrorDetails {
1135    /// A substantive localized explanation is required before offering continuation.
1136    #[serde(rename = "detailedExplanation")]
1137    #[serde(default, skip_serializing_if = "Option::is_none")]
1138    pub detailed_explanation: Option<String>,
1139    /// Open-ended classification; clients must accept categories added by Responses.
1140    #[serde(rename = "errorType")]
1141    #[serde(default, skip_serializing_if = "Option::is_none")]
1142    pub error_type: Option<String>,
1143    /// Opaque server-issued block target. Presence alone does not enable target-based continuation.
1144    #[serde(rename = "reviewTarget")]
1145    #[serde(default, skip_serializing_if = "Option::is_none")]
1146    pub review_target: Option<String>,
1147    /// Instruction to submit as the next turn's user input if continuation is confirmed.
1148    #[serde(default, skip_serializing_if = "Option::is_none")]
1149    pub steer: Option<MisalignmentSteer>,
1150}
1151
1152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1153pub struct MisalignmentSteer {
1154    pub message: String,
1155}
1156
1157/// Initial collaboration mode to use when the TUI starts.
1158#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1159pub enum ModeKind {
1160    #[serde(rename = "plan")]
1161    Plan,
1162    #[serde(rename = "default")]
1163    Default,
1164    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1165    #[serde(untagged)]
1166    Unknown(Value),
1167}
1168
1169#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1170pub struct NetworkApprovalContext {
1171    pub host: String,
1172    pub protocol: NetworkApprovalProtocol,
1173}
1174
1175#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1176pub enum NetworkApprovalProtocol {
1177    #[serde(rename = "http")]
1178    Http,
1179    #[serde(rename = "https")]
1180    Https,
1181    #[serde(rename = "socks5Tcp")]
1182    Socks5Tcp,
1183    #[serde(rename = "socks5Udp")]
1184    Socks5Udp,
1185    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1186    #[serde(untagged)]
1187    Unknown(Value),
1188}
1189
1190pub type NetworkPolicyAmendment = Value;
1191
1192#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1193pub enum NonSteerableTurnKind {
1194    #[serde(rename = "review")]
1195    Review,
1196    #[serde(rename = "compact")]
1197    Compact,
1198    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1199    #[serde(untagged)]
1200    Unknown(Value),
1201}
1202
1203#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1204pub enum PatchApplyStatus {
1205    #[serde(rename = "inProgress")]
1206    InProgress,
1207    #[serde(rename = "completed")]
1208    Completed,
1209    #[serde(rename = "failed")]
1210    Failed,
1211    #[serde(rename = "declined")]
1212    Declined,
1213    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1214    #[serde(untagged)]
1215    Unknown(Value),
1216}
1217
1218#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1219#[serde(tag = "type")]
1220pub enum PatchChangeKind {
1221    #[serde(rename = "add")]
1222    Add(AddPatchChangeKind),
1223    #[serde(rename = "delete")]
1224    Delete(DeletePatchChangeKind),
1225    #[serde(rename = "update")]
1226    Update(UpdatePatchChangeKind),
1227    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1228    #[serde(untagged)]
1229    Unknown(Value),
1230}
1231
1232/// Deprecated: `friendly` and `pragmatic` no longer select a style.
1233#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1234pub enum Personality {
1235    #[serde(rename = "none")]
1236    None,
1237    #[serde(rename = "friendly")]
1238    Friendly,
1239    #[serde(rename = "pragmatic")]
1240    Pragmatic,
1241    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1242    #[serde(untagged)]
1243    Unknown(Value),
1244}
1245
1246#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1247pub struct PlanThreadItem {
1248    /// Unix timestamp in milliseconds when the item completed, if recorded.
1249    #[serde(rename = "completedAtMs")]
1250    #[serde(default, skip_serializing_if = "Option::is_none")]
1251    pub completed_at_ms: Option<i64>,
1252    pub id: String,
1253    /// Unix timestamp in milliseconds when the item started, if recorded.
1254    #[serde(rename = "startedAtMs")]
1255    #[serde(default, skip_serializing_if = "Option::is_none")]
1256    pub started_at_ms: Option<i64>,
1257    pub text: String,
1258}
1259
1260#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1261pub enum PlanType {
1262    #[serde(rename = "free")]
1263    Free,
1264    #[serde(rename = "go")]
1265    Go,
1266    #[serde(rename = "plus")]
1267    Plus,
1268    #[serde(rename = "pro")]
1269    Pro,
1270    #[serde(rename = "prolite")]
1271    Prolite,
1272    #[serde(rename = "promax")]
1273    Promax,
1274    #[serde(rename = "team")]
1275    Team,
1276    #[serde(rename = "self_serve_business_prolite")]
1277    SelfServeBusinessProlite,
1278    #[serde(rename = "self_serve_business_usage_based")]
1279    SelfServeBusinessUsageBased,
1280    #[serde(rename = "business")]
1281    Business,
1282    #[serde(rename = "ent26")]
1283    Ent26,
1284    #[serde(rename = "enterprise_cbp_automation")]
1285    EnterpriseCbpAutomation,
1286    #[serde(rename = "enterprise_cbp_usage_based")]
1287    EnterpriseCbpUsageBased,
1288    #[serde(rename = "enterprise")]
1289    Enterprise,
1290    #[serde(rename = "edu")]
1291    Edu,
1292    #[serde(rename = "edu_plus")]
1293    EduPlus,
1294    #[serde(rename = "edu_pro")]
1295    EduPro,
1296    #[serde(rename = "sci")]
1297    Sci,
1298    #[serde(rename = "sci_plus")]
1299    SciPlus,
1300    #[serde(rename = "unknown")]
1301    Unknown,
1302    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1303    #[serde(untagged)]
1304    UnknownValue(Value),
1305}
1306
1307#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1308pub enum RateLimitReachedType {
1309    #[serde(rename = "rate_limit_reached")]
1310    RateLimitReached,
1311    #[serde(rename = "workspace_owner_credits_depleted")]
1312    WorkspaceOwnerCreditsDepleted,
1313    #[serde(rename = "workspace_member_credits_depleted")]
1314    WorkspaceMemberCreditsDepleted,
1315    #[serde(rename = "workspace_owner_usage_limit_reached")]
1316    WorkspaceOwnerUsageLimitReached,
1317    #[serde(rename = "workspace_member_usage_limit_reached")]
1318    WorkspaceMemberUsageLimitReached,
1319    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1320    #[serde(untagged)]
1321    Unknown(Value),
1322}
1323
1324#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1325pub struct RateLimitSnapshot {
1326    #[serde(default, skip_serializing_if = "Option::is_none")]
1327    pub credits: Option<CreditsSnapshot>,
1328    #[serde(rename = "individualLimit")]
1329    #[serde(default, skip_serializing_if = "Option::is_none")]
1330    pub individual_limit: Option<SpendControlLimitSnapshot>,
1331    #[serde(rename = "limitId")]
1332    #[serde(default, skip_serializing_if = "Option::is_none")]
1333    pub limit_id: Option<String>,
1334    #[serde(rename = "limitName")]
1335    #[serde(default, skip_serializing_if = "Option::is_none")]
1336    pub limit_name: Option<String>,
1337    /// Normal model whose display name and reasoning options describe this quota alias.
1338    #[serde(rename = "normalModelSlug")]
1339    #[serde(default, skip_serializing_if = "Option::is_none")]
1340    pub normal_model_slug: Option<String>,
1341    #[serde(rename = "planType")]
1342    #[serde(default, skip_serializing_if = "Option::is_none")]
1343    pub plan_type: Option<PlanType>,
1344    #[serde(default, skip_serializing_if = "Option::is_none")]
1345    pub primary: Option<RateLimitWindow>,
1346    #[serde(rename = "rateLimitReachedType")]
1347    #[serde(default, skip_serializing_if = "Option::is_none")]
1348    pub rate_limit_reached_type: Option<RateLimitReachedType>,
1349    #[serde(default, skip_serializing_if = "Option::is_none")]
1350    pub secondary: Option<RateLimitWindow>,
1351    /// Backend-reported spend-control state. `None` is unavailable, not a sparse-update recovery.
1352    #[serde(rename = "spendControlReached")]
1353    #[serde(default, skip_serializing_if = "Option::is_none")]
1354    pub spend_control_reached: Option<bool>,
1355}
1356
1357#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1358pub struct RateLimitWindow {
1359    #[serde(rename = "resetsAt")]
1360    #[serde(default, skip_serializing_if = "Option::is_none")]
1361    pub resets_at: Option<i64>,
1362    #[serde(rename = "usedPercent")]
1363    pub used_percent: i64,
1364    #[serde(rename = "windowDurationMins")]
1365    #[serde(default, skip_serializing_if = "Option::is_none")]
1366    pub window_duration_mins: Option<i64>,
1367}
1368
1369/// A non-empty reasoning effort value advertised by the model.
1370pub type ReasoningEffort = String;
1371
1372/// A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. See <https://platform.openai.com/docs/guides/reasoning?api-mode=responses#reasoning-summaries>
1373#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1374pub enum ReasoningSummary {
1375    #[serde(rename = "auto")]
1376    Auto,
1377    #[serde(rename = "concise")]
1378    Concise,
1379    #[serde(rename = "detailed")]
1380    Detailed,
1381    /// Option to disable reasoning summaries.
1382    #[serde(rename = "none")]
1383    None,
1384    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1385    #[serde(untagged)]
1386    Unknown(Value),
1387}
1388
1389#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1390pub struct ReasoningThreadItem {
1391    /// Unix timestamp in milliseconds when the item completed, if recorded.
1392    #[serde(rename = "completedAtMs")]
1393    #[serde(default, skip_serializing_if = "Option::is_none")]
1394    pub completed_at_ms: Option<i64>,
1395    #[serde(default, skip_serializing_if = "Option::is_none")]
1396    pub content: Option<Vec<String>>,
1397    pub id: String,
1398    /// Unix timestamp in milliseconds when the item started, if recorded.
1399    #[serde(rename = "startedAtMs")]
1400    #[serde(default, skip_serializing_if = "Option::is_none")]
1401    pub started_at_ms: Option<i64>,
1402    #[serde(default, skip_serializing_if = "Option::is_none")]
1403    pub summary: Option<Vec<String>>,
1404}
1405
1406#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1407pub enum SandboxMode {
1408    #[serde(rename = "read-only")]
1409    ReadOnly,
1410    #[serde(rename = "workspace-write")]
1411    WorkspaceWrite,
1412    #[serde(rename = "danger-full-access")]
1413    DangerFullAccess,
1414    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1415    #[serde(untagged)]
1416    Unknown(Value),
1417}
1418
1419pub type SandboxPolicy = Value;
1420
1421#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1422pub enum SessionSource {
1423    #[serde(rename = "cli")]
1424    Cli,
1425    #[serde(rename = "vscode")]
1426    Vscode,
1427    #[serde(rename = "exec")]
1428    Exec,
1429    #[serde(rename = "appServer")]
1430    AppServer,
1431    #[serde(rename = "unknown")]
1432    Unknown,
1433    #[serde(rename = "custom")]
1434    Custom(String),
1435    #[serde(rename = "subAgent")]
1436    SubAgent(SubAgentSource),
1437    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1438    #[serde(untagged)]
1439    UnknownValue(Value),
1440}
1441
1442/// Settings for a collaboration mode.
1443#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1444pub struct Settings {
1445    #[serde(default, skip_serializing_if = "Option::is_none")]
1446    pub developer_instructions: Option<String>,
1447    pub model: String,
1448    #[serde(default, skip_serializing_if = "Option::is_none")]
1449    pub reasoning_effort: Option<ReasoningEffort>,
1450}
1451
1452#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1453pub struct SkillUserInput {
1454    pub name: String,
1455    pub path: String,
1456}
1457
1458#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1459pub struct SleepThreadItem {
1460    /// Unix timestamp in milliseconds when the item completed, if recorded.
1461    #[serde(rename = "completedAtMs")]
1462    #[serde(default, skip_serializing_if = "Option::is_none")]
1463    pub completed_at_ms: Option<i64>,
1464    #[serde(rename = "durationMs")]
1465    pub duration_ms: u64,
1466    pub id: String,
1467    /// Unix timestamp in milliseconds when the item started, if recorded.
1468    #[serde(rename = "startedAtMs")]
1469    #[serde(default, skip_serializing_if = "Option::is_none")]
1470    pub started_at_ms: Option<i64>,
1471}
1472
1473#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1474pub struct SpendControlLimitSnapshot {
1475    pub limit: String,
1476    #[serde(rename = "remainingPercent")]
1477    pub remaining_percent: i64,
1478    #[serde(rename = "resetsAt")]
1479    pub resets_at: i64,
1480    pub used: String,
1481}
1482
1483#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1484pub enum SubAgentActivityKind {
1485    #[serde(rename = "started")]
1486    Started,
1487    #[serde(rename = "interacted")]
1488    Interacted,
1489    #[serde(rename = "interrupted")]
1490    Interrupted,
1491    #[serde(rename = "completed")]
1492    Completed,
1493    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1494    #[serde(untagged)]
1495    Unknown(Value),
1496}
1497
1498#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1499pub struct SubAgentActivityThreadItem {
1500    #[serde(rename = "agentPath")]
1501    pub agent_path: String,
1502    #[serde(rename = "agentThreadId")]
1503    pub agent_thread_id: String,
1504    /// Unix timestamp in milliseconds when the item completed, if recorded.
1505    #[serde(rename = "completedAtMs")]
1506    #[serde(default, skip_serializing_if = "Option::is_none")]
1507    pub completed_at_ms: Option<i64>,
1508    pub id: String,
1509    pub kind: SubAgentActivityKind,
1510    /// Resolved model at sub-agent creation; absent from older records and other activities.
1511    #[serde(default, skip_serializing_if = "Option::is_none")]
1512    pub model: Option<String>,
1513    /// Resolved reasoning effort at sub-agent creation, when known.
1514    #[serde(rename = "reasoningEffort")]
1515    #[serde(default, skip_serializing_if = "Option::is_none")]
1516    pub reasoning_effort: Option<ReasoningEffort>,
1517    /// Unix timestamp in milliseconds when the item started, if recorded.
1518    #[serde(rename = "startedAtMs")]
1519    #[serde(default, skip_serializing_if = "Option::is_none")]
1520    pub started_at_ms: Option<i64>,
1521}
1522
1523#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1524pub enum SubAgentSource {
1525    #[serde(rename = "review")]
1526    Review,
1527    #[serde(rename = "compact")]
1528    Compact,
1529    #[serde(rename = "memory_consolidation")]
1530    MemoryConsolidation,
1531    #[serde(rename = "thread_spawn")]
1532    ThreadSpawn(SubAgentSourceThreadSpawn),
1533    #[serde(rename = "other")]
1534    Other(String),
1535    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1536    #[serde(untagged)]
1537    Unknown(Value),
1538}
1539
1540#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1541pub struct SubAgentSourceThreadSpawn {
1542    #[serde(default, skip_serializing_if = "Option::is_none")]
1543    pub agent_nickname: Option<String>,
1544    #[serde(default, skip_serializing_if = "Option::is_none")]
1545    pub agent_path: Option<AgentPath>,
1546    #[serde(default, skip_serializing_if = "Option::is_none")]
1547    pub agent_role: Option<String>,
1548    pub depth: i64,
1549    pub parent_thread_id: ThreadId,
1550}
1551
1552pub type TextElement = Value;
1553
1554#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1555pub struct TextUserInput {
1556    pub text: String,
1557    /// UI-defined spans within `text` used to render or persist special elements.
1558    #[serde(default, skip_serializing_if = "Option::is_none")]
1559    pub text_elements: Option<Vec<TextElement>>,
1560}
1561
1562#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1563pub struct Thread {
1564    /// Optional random unique nickname assigned to an AgentControl-spawned sub-agent.
1565    #[serde(rename = "agentNickname")]
1566    #[serde(default, skip_serializing_if = "Option::is_none")]
1567    pub agent_nickname: Option<String>,
1568    /// Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.
1569    #[serde(rename = "agentRole")]
1570    #[serde(default, skip_serializing_if = "Option::is_none")]
1571    pub agent_role: Option<String>,
1572    /// Version of the CLI that created the thread.
1573    #[serde(rename = "cliVersion")]
1574    pub cli_version: String,
1575    /// Unix timestamp (in seconds) when the thread was created.
1576    #[serde(rename = "createdAt")]
1577    pub created_at: i64,
1578    /// Working directory captured for the thread.
1579    pub cwd: AbsolutePathBuf,
1580    /// Whether the thread is ephemeral and should not be materialized on disk.
1581    pub ephemeral: bool,
1582    /// Source thread id when this thread was created by forking another thread.
1583    #[serde(rename = "forkedFromId")]
1584    #[serde(default, skip_serializing_if = "Option::is_none")]
1585    pub forked_from_id: Option<String>,
1586    /// Optional Git metadata captured when the thread was created.
1587    #[serde(rename = "gitInfo")]
1588    #[serde(default, skip_serializing_if = "Option::is_none")]
1589    pub git_info: Option<GitInfo>,
1590    /// Persisted thread history contract selected when this thread was created.
1591    #[serde(rename = "historyMode")]
1592    #[serde(default, skip_serializing_if = "Option::is_none")]
1593    pub history_mode: Option<ThreadHistoryMode>,
1594    /// Identifier for this thread. Codex-generated thread IDs are UUIDv7.
1595    pub id: String,
1596    /// Current configured model when loaded, otherwise the latest persisted model. Null when unavailable. This is not per-turn execution telemetry.
1597    #[serde(default, skip_serializing_if = "Option::is_none")]
1598    pub model: Option<String>,
1599    /// Model provider used for this thread (for example, 'openai').
1600    #[serde(rename = "modelProvider")]
1601    pub model_provider: String,
1602    /// Optional user-facing thread title.
1603    #[serde(default, skip_serializing_if = "Option::is_none")]
1604    pub name: Option<String>,
1605    /// Originator recorded when the thread was created, independent of its current client or executor. Null when the recorded originator is unavailable.
1606    #[serde(default, skip_serializing_if = "Option::is_none")]
1607    pub originator: Option<String>,
1608    /// The ID of the parent thread. This will only be set if this thread is a subagent.
1609    #[serde(rename = "parentThreadId")]
1610    #[serde(default, skip_serializing_if = "Option::is_none")]
1611    pub parent_thread_id: Option<String>,
1612    /// \[UNSTABLE\] Path to the thread on disk.
1613    #[serde(default, skip_serializing_if = "Option::is_none")]
1614    pub path: Option<String>,
1615    /// Usually the first user message in the thread, if available.
1616    pub preview: String,
1617    /// Canonical project assignment owned by app-server, if any.
1618    #[serde(rename = "projectId")]
1619    #[serde(default, skip_serializing_if = "Option::is_none")]
1620    pub project_id: Option<String>,
1621    /// Current configured reasoning effort when loaded, otherwise the latest persisted effort. Null when unset or unavailable. This is not per-turn execution telemetry.
1622    #[serde(rename = "reasoningEffort")]
1623    #[serde(default, skip_serializing_if = "Option::is_none")]
1624    pub reasoning_effort: Option<ReasoningEffort>,
1625    /// Unix timestamp (in seconds) used for thread recency ordering.
1626    #[serde(rename = "recencyAt")]
1627    #[serde(default, skip_serializing_if = "Option::is_none")]
1628    pub recency_at: Option<i64>,
1629    /// The independently persisted section selected for this thread, if any.
1630    #[serde(default, skip_serializing_if = "Option::is_none")]
1631    pub section: Option<ThreadSection>,
1632    /// Unix timestamp in seconds when the thread entered its current section.
1633    #[serde(rename = "sectionEnteredAt")]
1634    #[serde(default, skip_serializing_if = "Option::is_none")]
1635    pub section_entered_at: Option<i64>,
1636    /// Session id shared by threads that belong to the same session tree.
1637    #[serde(rename = "sessionId")]
1638    pub session_id: String,
1639    /// Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).
1640    pub source: SessionSource,
1641    /// Current runtime status for the thread.
1642    pub status: ThreadStatus,
1643    /// Optional analytics source classification for this thread.
1644    #[serde(rename = "threadSource")]
1645    #[serde(default, skip_serializing_if = "Option::is_none")]
1646    pub thread_source: Option<ThreadSource>,
1647    /// Only populated on `thread/resume`, `thread/fork`, and `thread/read` (when `includeTurns` is true) responses. For all other responses and notifications returning a Thread, the turns field will be an empty list.
1648    pub turns: Vec<Turn>,
1649    /// Unix timestamp (in seconds) when the thread was last updated.
1650    #[serde(rename = "updatedAt")]
1651    pub updated_at: i64,
1652}
1653
1654#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1655pub enum ThreadHistoryMode {
1656    #[serde(rename = "legacy")]
1657    Legacy,
1658    #[serde(rename = "paginated")]
1659    Paginated,
1660    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1661    #[serde(untagged)]
1662    Unknown(Value),
1663}
1664
1665pub type ThreadId = String;
1666
1667/// A thread item and its recorded lifecycle times. The payload stays flat on the wire.
1668#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1669#[serde(tag = "type")]
1670pub enum ThreadItem {
1671    #[serde(rename = "userMessage")]
1672    UserMessage(UserMessageThreadItem),
1673    #[serde(rename = "hookPrompt")]
1674    HookPrompt(HookPromptThreadItem),
1675    #[serde(rename = "agentMessage")]
1676    AgentMessage(AgentMessageThreadItem),
1677    #[serde(rename = "functionCallOutput")]
1678    FunctionCallOutput(FunctionCallOutputThreadItem),
1679    /// EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.
1680    #[serde(rename = "plan")]
1681    Plan(PlanThreadItem),
1682    #[serde(rename = "reasoning")]
1683    Reasoning(ReasoningThreadItem),
1684    #[serde(rename = "commandExecution")]
1685    CommandExecution(CommandExecutionThreadItem),
1686    #[serde(rename = "fileChange")]
1687    FileChange(FileChangeThreadItem),
1688    #[serde(rename = "mcpToolCall")]
1689    McpToolCall(McpToolCallThreadItem),
1690    #[serde(rename = "dynamicToolCall")]
1691    DynamicToolCall(DynamicToolCallThreadItem),
1692    #[serde(rename = "collabAgentToolCall")]
1693    CollabAgentToolCall(CollabAgentToolCallThreadItem),
1694    #[serde(rename = "subAgentActivity")]
1695    SubAgentActivity(SubAgentActivityThreadItem),
1696    #[serde(rename = "webSearch")]
1697    WebSearch(WebSearchThreadItem),
1698    #[serde(rename = "imageView")]
1699    ImageView(ImageViewThreadItem),
1700    /// Display item emitted by the interruptible `clock.sleep` tool.
1701    #[serde(rename = "sleep")]
1702    Sleep(SleepThreadItem),
1703    /// Either inline generated-image data or its durable attachment-store identity.
1704    ///
1705    /// `File` must remain first so rollouts written during the migration, which contain both an empty `result` and a `fileId`, retain the file reference when deserialized.
1706    #[serde(rename = "imageGeneration")]
1707    ImageGeneration(ImageGenerationThreadItem),
1708    #[serde(rename = "enteredReviewMode")]
1709    EnteredReviewMode(EnteredReviewModeThreadItem),
1710    #[serde(rename = "exitedReviewMode")]
1711    ExitedReviewMode(ExitedReviewModeThreadItem),
1712    #[serde(rename = "contextCompaction")]
1713    ContextCompaction(ContextCompactionThreadItem),
1714    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1715    #[serde(untagged)]
1716    Unknown(Value),
1717}
1718
1719/// There are three ways to resume a thread: 1. By thread_id: load the thread from disk by thread_id and resume it. 2. By history: instantiate the thread from memory and resume it. 3. By path: load the thread from disk by path and resume it.
1720///
1721/// For non-running threads, the precedence is: history > non-empty path > thread_id. If using history or a non-empty path for a non-running thread, the thread_id param will be ignored.
1722///
1723/// If thread_id identifies a running thread, app-server rejoins that thread and treats a non-empty path as a consistency check against the active rollout path. Empty string path values are treated as absent.
1724///
1725/// Prefer using thread_id whenever possible.
1726#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1727pub struct ThreadResumeParams {
1728    #[serde(rename = "approvalPolicy")]
1729    #[serde(default, skip_serializing_if = "Option::is_none")]
1730    pub approval_policy: Option<AskForApproval>,
1731    /// Override where approval requests are routed for review on this thread and subsequent turns.
1732    #[serde(rename = "approvalsReviewer")]
1733    #[serde(default, skip_serializing_if = "Option::is_none")]
1734    pub approvals_reviewer: Option<ApprovalsReviewer>,
1735    #[serde(rename = "baseInstructions")]
1736    #[serde(default, skip_serializing_if = "Option::is_none")]
1737    pub base_instructions: Option<String>,
1738    #[serde(default, skip_serializing_if = "Option::is_none")]
1739    pub config: Option<BTreeMap<String, Value>>,
1740    #[serde(default, skip_serializing_if = "Option::is_none")]
1741    pub cwd: Option<String>,
1742    #[serde(rename = "developerInstructions")]
1743    #[serde(default, skip_serializing_if = "Option::is_none")]
1744    pub developer_instructions: Option<String>,
1745    /// When true, return only thread metadata and live-resume state without populating `thread.turns`. This is useful when the client plans to call `thread/turns/list` immediately after resuming. Full-history hydration is deprecated for paginated threads; use this with `thread/turns/list` and `thread/items/list` instead.
1746    #[serde(rename = "excludeTurns")]
1747    #[serde(default, skip_serializing_if = "Option::is_none")]
1748    pub exclude_turns: Option<bool>,
1749    /// Configuration overrides for the resumed thread, if any.
1750    #[serde(default, skip_serializing_if = "Option::is_none")]
1751    pub model: Option<String>,
1752    #[serde(rename = "modelProvider")]
1753    #[serde(default, skip_serializing_if = "Option::is_none")]
1754    pub model_provider: Option<String>,
1755    /// @deprecated `friendly` and `pragmatic` no longer select a style. Changing this does not rewrite the thread's existing instructions.
1756    #[serde(default, skip_serializing_if = "Option::is_none")]
1757    pub personality: Option<Personality>,
1758    #[serde(default, skip_serializing_if = "Option::is_none")]
1759    pub sandbox: Option<SandboxMode>,
1760    #[serde(rename = "serviceTier")]
1761    #[serde(default, skip_serializing_if = "Option::is_none")]
1762    pub service_tier: Option<String>,
1763    #[serde(rename = "threadId")]
1764    pub thread_id: String,
1765}
1766
1767#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1768pub struct ThreadResumeResponse {
1769    #[serde(rename = "approvalPolicy")]
1770    pub approval_policy: AskForApproval,
1771    /// Reviewer currently used for approval requests on this thread.
1772    #[serde(rename = "approvalsReviewer")]
1773    pub approvals_reviewer: ApprovalsReviewer,
1774    /// Effective collaboration mode. Absent when resuming from an older server.
1775    #[serde(rename = "collaborationMode")]
1776    #[serde(default, skip_serializing_if = "Option::is_none")]
1777    pub collaboration_mode: Option<CollaborationMode>,
1778    pub cwd: AbsolutePathBuf,
1779    /// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
1780    #[serde(rename = "disabledPluginIds")]
1781    #[serde(default, skip_serializing_if = "Option::is_none")]
1782    pub disabled_plugin_ids: Option<Vec<String>>,
1783    /// Environment-native paths to instruction source files currently loaded for this thread.
1784    #[serde(rename = "instructionSources")]
1785    #[serde(default, skip_serializing_if = "Option::is_none")]
1786    pub instruction_sources: Option<Vec<LegacyAppPathString>>,
1787    /// Opaque cursor for hydrating paginated items backwards.
1788    ///
1789    /// Pass this as `cursor` to `thread/items/list` with `sortDirection: "desc"`. The first page includes the item identified by the cursor.
1790    #[serde(rename = "itemsBackwardsCursor")]
1791    #[serde(default, skip_serializing_if = "Option::is_none")]
1792    pub items_backwards_cursor: Option<String>,
1793    pub model: String,
1794    #[serde(rename = "modelProvider")]
1795    pub model_provider: String,
1796    #[serde(rename = "reasoningEffort")]
1797    #[serde(default, skip_serializing_if = "Option::is_none")]
1798    pub reasoning_effort: Option<ReasoningEffort>,
1799    /// Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance.
1800    pub sandbox: SandboxPolicy,
1801    #[serde(rename = "serviceTier")]
1802    #[serde(default, skip_serializing_if = "Option::is_none")]
1803    pub service_tier: Option<String>,
1804    pub thread: Thread,
1805    /// Opaque cursor for hydrating paginated turns backwards.
1806    ///
1807    /// Pass this as `cursor` to `thread/turns/list` with `sortDirection: "desc"`. The first page includes the turn identified by the cursor.
1808    #[serde(rename = "turnsBackwardsCursor")]
1809    #[serde(default, skip_serializing_if = "Option::is_none")]
1810    pub turns_backwards_cursor: Option<String>,
1811}
1812
1813/// An independently persisted, user-visible thread section.
1814#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1815pub struct ThreadSection {
1816    /// Optional appearance synchronized across clients.
1817    #[serde(default, skip_serializing_if = "Option::is_none")]
1818    pub appearance: Option<ThreadSectionAppearance>,
1819    /// Opaque UUIDv7 identity that remains stable when the section is renamed.
1820    pub id: String,
1821    /// The current user-visible section name.
1822    pub name: String,
1823}
1824
1825/// Extensible visual presentation for a custom thread section.
1826#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1827pub struct ThreadSectionAppearance {
1828    #[serde(default, skip_serializing_if = "Option::is_none")]
1829    pub color: Option<String>,
1830    #[serde(default, skip_serializing_if = "Option::is_none")]
1831    pub icon: Option<String>,
1832}
1833
1834pub type ThreadSource = String;
1835
1836#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1837pub struct ThreadStartParams {
1838    #[serde(rename = "approvalPolicy")]
1839    #[serde(default, skip_serializing_if = "Option::is_none")]
1840    pub approval_policy: Option<AskForApproval>,
1841    /// Override where approval requests are routed for review on this thread and subsequent turns.
1842    #[serde(rename = "approvalsReviewer")]
1843    #[serde(default, skip_serializing_if = "Option::is_none")]
1844    pub approvals_reviewer: Option<ApprovalsReviewer>,
1845    #[serde(rename = "baseInstructions")]
1846    #[serde(default, skip_serializing_if = "Option::is_none")]
1847    pub base_instructions: Option<String>,
1848    #[serde(default, skip_serializing_if = "Option::is_none")]
1849    pub config: Option<BTreeMap<String, Value>>,
1850    #[serde(default, skip_serializing_if = "Option::is_none")]
1851    pub cwd: Option<String>,
1852    #[serde(rename = "developerInstructions")]
1853    #[serde(default, skip_serializing_if = "Option::is_none")]
1854    pub developer_instructions: Option<String>,
1855    #[serde(default, skip_serializing_if = "Option::is_none")]
1856    pub ephemeral: Option<bool>,
1857    #[serde(default, skip_serializing_if = "Option::is_none")]
1858    pub model: Option<String>,
1859    #[serde(rename = "modelProvider")]
1860    #[serde(default, skip_serializing_if = "Option::is_none")]
1861    pub model_provider: Option<String>,
1862    /// @deprecated `friendly` and `pragmatic` no longer select a style.
1863    #[serde(default, skip_serializing_if = "Option::is_none")]
1864    pub personality: Option<Personality>,
1865    #[serde(default, skip_serializing_if = "Option::is_none")]
1866    pub sandbox: Option<SandboxMode>,
1867    #[serde(rename = "serviceName")]
1868    #[serde(default, skip_serializing_if = "Option::is_none")]
1869    pub service_name: Option<String>,
1870    #[serde(rename = "serviceTier")]
1871    #[serde(default, skip_serializing_if = "Option::is_none")]
1872    pub service_tier: Option<String>,
1873    #[serde(rename = "sessionStartSource")]
1874    #[serde(default, skip_serializing_if = "Option::is_none")]
1875    pub session_start_source: Option<ThreadStartSource>,
1876    /// Optional client-supplied analytics source classification for this thread.
1877    #[serde(rename = "threadSource")]
1878    #[serde(default, skip_serializing_if = "Option::is_none")]
1879    pub thread_source: Option<ThreadSource>,
1880}
1881
1882#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1883pub struct ThreadStartResponse {
1884    #[serde(rename = "approvalPolicy")]
1885    pub approval_policy: AskForApproval,
1886    /// Reviewer currently used for approval requests on this thread.
1887    #[serde(rename = "approvalsReviewer")]
1888    pub approvals_reviewer: ApprovalsReviewer,
1889    pub cwd: AbsolutePathBuf,
1890    /// Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.
1891    #[serde(rename = "disabledPluginIds")]
1892    #[serde(default, skip_serializing_if = "Option::is_none")]
1893    pub disabled_plugin_ids: Option<Vec<String>>,
1894    /// Environment-native paths to instruction source files currently loaded for this thread.
1895    #[serde(rename = "instructionSources")]
1896    #[serde(default, skip_serializing_if = "Option::is_none")]
1897    pub instruction_sources: Option<Vec<LegacyAppPathString>>,
1898    pub model: String,
1899    #[serde(rename = "modelProvider")]
1900    pub model_provider: String,
1901    #[serde(rename = "reasoningEffort")]
1902    #[serde(default, skip_serializing_if = "Option::is_none")]
1903    pub reasoning_effort: Option<ReasoningEffort>,
1904    /// Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance.
1905    pub sandbox: SandboxPolicy,
1906    #[serde(rename = "serviceTier")]
1907    #[serde(default, skip_serializing_if = "Option::is_none")]
1908    pub service_tier: Option<String>,
1909    pub thread: Thread,
1910}
1911
1912#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1913pub enum ThreadStartSource {
1914    #[serde(rename = "startup")]
1915    Startup,
1916    #[serde(rename = "clear")]
1917    Clear,
1918    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
1919    #[serde(untagged)]
1920    Unknown(Value),
1921}
1922
1923#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1924pub struct ThreadStartedNotification {
1925    pub thread: Thread,
1926}
1927
1928pub type ThreadStatus = Value;
1929
1930#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1931pub struct ThreadTokenUsage {
1932    pub last: TokenUsageBreakdown,
1933    #[serde(rename = "modelContextWindow")]
1934    #[serde(default, skip_serializing_if = "Option::is_none")]
1935    pub model_context_window: Option<i64>,
1936    pub total: TokenUsageBreakdown,
1937}
1938
1939#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1940pub struct ThreadTokenUsageUpdatedNotification {
1941    #[serde(rename = "threadId")]
1942    pub thread_id: String,
1943    #[serde(rename = "tokenUsage")]
1944    pub token_usage: ThreadTokenUsage,
1945    #[serde(rename = "turnId")]
1946    pub turn_id: String,
1947}
1948
1949#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
1950pub struct TokenUsageBreakdown {
1951    #[serde(rename = "cacheWriteInputTokens")]
1952    #[serde(default, skip_serializing_if = "Option::is_none")]
1953    pub cache_write_input_tokens: Option<i64>,
1954    #[serde(rename = "cachedInputTokens")]
1955    pub cached_input_tokens: i64,
1956    #[serde(rename = "inputTokens")]
1957    pub input_tokens: i64,
1958    #[serde(rename = "outputTokens")]
1959    pub output_tokens: i64,
1960    #[serde(rename = "reasoningOutputTokens")]
1961    pub reasoning_output_tokens: i64,
1962    #[serde(rename = "totalTokens")]
1963    pub total_tokens: i64,
1964}
1965
1966#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1967pub struct Turn {
1968    /// Unix timestamp (in seconds) when the turn completed.
1969    #[serde(rename = "completedAt")]
1970    #[serde(default, skip_serializing_if = "Option::is_none")]
1971    pub completed_at: Option<i64>,
1972    /// Duration between turn start and completion in milliseconds, if known.
1973    #[serde(rename = "durationMs")]
1974    #[serde(default, skip_serializing_if = "Option::is_none")]
1975    pub duration_ms: Option<i64>,
1976    /// Error associated with a failed or interrupted turn.
1977    #[serde(default, skip_serializing_if = "Option::is_none")]
1978    pub error: Option<TurnError>,
1979    /// Identifier for this turn. Codex-generated turn IDs are UUIDv7.
1980    pub id: String,
1981    /// Thread items currently included in this turn payload.
1982    pub items: Vec<ThreadItem>,
1983    /// Describes how much of `items` has been loaded for this turn.
1984    #[serde(rename = "itemsView")]
1985    #[serde(default, skip_serializing_if = "Option::is_none")]
1986    pub items_view: Option<TurnItemsView>,
1987    /// ID of the first turn in the chain of work that led to this turn. Pass this as `rootTurnId` when starting work on behalf of this turn. May be null in older history or a `review/start` response.
1988    #[serde(rename = "rootTurnId")]
1989    #[serde(default, skip_serializing_if = "Option::is_none")]
1990    pub root_turn_id: Option<String>,
1991    /// Unix timestamp (in seconds) when the turn started.
1992    #[serde(rename = "startedAt")]
1993    #[serde(default, skip_serializing_if = "Option::is_none")]
1994    pub started_at: Option<i64>,
1995    pub status: TurnStatus,
1996}
1997
1998#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1999pub struct TurnCompletedNotification {
2000    #[serde(rename = "threadId")]
2001    pub thread_id: String,
2002    pub turn: Turn,
2003}
2004
2005#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2006pub struct TurnError {
2007    #[serde(rename = "additionalDetails")]
2008    #[serde(default, skip_serializing_if = "Option::is_none")]
2009    pub additional_details: Option<String>,
2010    #[serde(rename = "codexErrorInfo")]
2011    #[serde(default, skip_serializing_if = "Option::is_none")]
2012    pub codex_error_info: Option<CodexErrorInfo>,
2013    pub message: String,
2014    /// Optional public explanation and continuation instruction for a misalignment block.
2015    #[serde(default, skip_serializing_if = "Option::is_none")]
2016    pub misalignment: Option<MisalignmentErrorDetails>,
2017}
2018
2019#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2020pub struct TurnInterruptParams {
2021    #[serde(rename = "threadId")]
2022    pub thread_id: String,
2023    #[serde(rename = "turnId")]
2024    pub turn_id: String,
2025}
2026
2027pub type TurnInterruptResponse = BTreeMap<String, Value>;
2028
2029#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2030pub enum TurnItemsView {
2031    /// `items` was not loaded for this turn. The field is intentionally empty.
2032    #[serde(rename = "notLoaded")]
2033    NotLoaded,
2034    /// `items` contains only a display summary for this turn.
2035    #[serde(rename = "summary")]
2036    Summary,
2037    /// `items` contains every ThreadItem available from persisted app-server history for this turn.
2038    #[serde(rename = "full")]
2039    Full,
2040    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
2041    #[serde(untagged)]
2042    Unknown(Value),
2043}
2044
2045#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2046pub struct TurnStartParams {
2047    /// Override the approval policy for this turn and subsequent turns.
2048    #[serde(rename = "approvalPolicy")]
2049    #[serde(default, skip_serializing_if = "Option::is_none")]
2050    pub approval_policy: Option<AskForApproval>,
2051    /// Override where approval requests are routed for review on this turn and subsequent turns.
2052    #[serde(rename = "approvalsReviewer")]
2053    #[serde(default, skip_serializing_if = "Option::is_none")]
2054    pub approvals_reviewer: Option<ApprovalsReviewer>,
2055    #[serde(rename = "clientUserMessageId")]
2056    #[serde(default, skip_serializing_if = "Option::is_none")]
2057    pub client_user_message_id: Option<String>,
2058    /// Override the working directory for this turn and subsequent turns.
2059    #[serde(default, skip_serializing_if = "Option::is_none")]
2060    pub cwd: Option<String>,
2061    /// Replace this thread's disabled plugin IDs. Omitted/null preserves the list; \[\] clears it.
2062    #[serde(rename = "disabledPluginIds")]
2063    #[serde(default, skip_serializing_if = "Option::is_none")]
2064    pub disabled_plugin_ids: Option<Vec<String>>,
2065    /// Override the reasoning effort for this turn and subsequent turns.
2066    #[serde(default, skip_serializing_if = "Option::is_none")]
2067    pub effort: Option<ReasoningEffort>,
2068    pub input: Vec<UserInput>,
2069    /// Override the model for this turn and subsequent turns.
2070    #[serde(default, skip_serializing_if = "Option::is_none")]
2071    pub model: Option<String>,
2072    /// Optional JSON Schema used to constrain the final assistant message for this turn.
2073    #[serde(rename = "outputSchema")]
2074    #[serde(default, skip_serializing_if = "Option::is_none")]
2075    pub output_schema: Option<Value>,
2076    /// ID of the turn that caused this new turn to start.
2077    ///
2078    /// Set this when starting work on behalf of another turn, such as delegated work in a different thread. Leave unset for work started directly by the user. Ignored when this request adds input to an active turn.
2079    #[serde(rename = "parentTurnId")]
2080    #[serde(default, skip_serializing_if = "Option::is_none")]
2081    pub parent_turn_id: Option<String>,
2082    /// @deprecated `friendly` and `pragmatic` no longer select a style. Changing this does not rewrite the thread's existing instructions.
2083    #[serde(default, skip_serializing_if = "Option::is_none")]
2084    pub personality: Option<Personality>,
2085    /// ID of the first turn in the chain of work that led to this new turn.
2086    ///
2087    /// When setting `parentTurnId`, set this to the parent turn's `rootTurnId` when known. This keeps descendant work attributed to the original turn. If omitted, the new turn becomes its own root. Ignored when this request adds input to an active turn.
2088    #[serde(rename = "rootTurnId")]
2089    #[serde(default, skip_serializing_if = "Option::is_none")]
2090    pub root_turn_id: Option<String>,
2091    /// Override the sandbox policy for this turn and subsequent turns.
2092    #[serde(rename = "sandboxPolicy")]
2093    #[serde(default, skip_serializing_if = "Option::is_none")]
2094    pub sandbox_policy: Option<SandboxPolicy>,
2095    /// Override the service tier for this turn and subsequent turns.
2096    #[serde(rename = "serviceTier")]
2097    #[serde(default, skip_serializing_if = "Option::is_none")]
2098    pub service_tier: Option<String>,
2099    /// Override the service tier only when this request starts a new turn. Use "default" for standard speed. Omitted or null inherits the thread's tier. Does not change the thread's tier or a turn being steered.
2100    #[serde(rename = "serviceTierForTurn")]
2101    #[serde(default, skip_serializing_if = "Option::is_none")]
2102    pub service_tier_for_turn: Option<String>,
2103    /// Override the reasoning summary for this turn and subsequent turns.
2104    #[serde(default, skip_serializing_if = "Option::is_none")]
2105    pub summary: Option<ReasoningSummary>,
2106    #[serde(rename = "threadId")]
2107    pub thread_id: String,
2108    #[serde(rename = "toolOutput")]
2109    #[serde(default, skip_serializing_if = "Option::is_none")]
2110    pub tool_output: Option<TurnToolOutput>,
2111    /// Optional source classification for the caller that starts this turn. Ignored when this request steers an already-active turn.
2112    #[serde(rename = "turnTrigger")]
2113    #[serde(default, skip_serializing_if = "Option::is_none")]
2114    pub turn_trigger: Option<String>,
2115}
2116
2117#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2118pub struct TurnStartResponse {
2119    pub turn: Turn,
2120}
2121
2122#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2123pub struct TurnStartedNotification {
2124    #[serde(rename = "threadId")]
2125    pub thread_id: String,
2126    pub turn: Turn,
2127}
2128
2129#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2130pub enum TurnStatus {
2131    #[serde(rename = "completed")]
2132    Completed,
2133    #[serde(rename = "interrupted")]
2134    Interrupted,
2135    #[serde(rename = "failed")]
2136    Failed,
2137    #[serde(rename = "inProgress")]
2138    InProgress,
2139    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
2140    #[serde(untagged)]
2141    Unknown(Value),
2142}
2143
2144#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2145pub struct TurnToolOutput {
2146    pub name: String,
2147    #[serde(default, skip_serializing_if = "Option::is_none")]
2148    pub namespace: Option<String>,
2149    pub output: FunctionCallOutputBody,
2150    /// Requests retention of this output in the thread's model history.
2151    #[serde(default, skip_serializing_if = "Option::is_none")]
2152    pub retain: Option<bool>,
2153}
2154
2155#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2156pub struct UpdatePatchChangeKind {
2157    #[serde(default, skip_serializing_if = "Option::is_none")]
2158    pub move_path: Option<String>,
2159}
2160
2161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2162pub struct UsageLimitExceededImageGenerationFailure {
2163    #[serde(rename = "limitId")]
2164    pub limit_id: String,
2165    #[serde(rename = "resetsAt")]
2166    #[serde(default, skip_serializing_if = "Option::is_none")]
2167    pub resets_at: Option<i64>,
2168}
2169
2170#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2171#[serde(tag = "type")]
2172pub enum UserInput {
2173    #[serde(rename = "text")]
2174    Text(TextUserInput),
2175    #[serde(rename = "image")]
2176    Image(ImageUserInput),
2177    #[serde(rename = "localImage")]
2178    LocalImage(LocalImageUserInput),
2179    #[serde(rename = "audio")]
2180    Audio(AudioUserInput),
2181    #[serde(rename = "localAudio")]
2182    LocalAudio(LocalAudioUserInput),
2183    #[serde(rename = "skill")]
2184    Skill(SkillUserInput),
2185    #[serde(rename = "mention")]
2186    Mention(MentionUserInput),
2187    /// A value this Codex version doesn't know, or a known one whose body didn't decode.
2188    #[serde(untagged)]
2189    Unknown(Value),
2190}
2191
2192#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2193pub struct UserMessageThreadItem {
2194    #[serde(rename = "clientId")]
2195    #[serde(default, skip_serializing_if = "Option::is_none")]
2196    pub client_id: Option<String>,
2197    /// Unix timestamp in milliseconds when the item completed, if recorded.
2198    #[serde(rename = "completedAtMs")]
2199    #[serde(default, skip_serializing_if = "Option::is_none")]
2200    pub completed_at_ms: Option<i64>,
2201    pub content: Vec<UserInput>,
2202    pub id: String,
2203    /// Unix timestamp in milliseconds when the item started, if recorded.
2204    #[serde(rename = "startedAtMs")]
2205    #[serde(default, skip_serializing_if = "Option::is_none")]
2206    pub started_at_ms: Option<i64>,
2207}
2208
2209pub type WebSearchAction = Value;
2210
2211#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2212pub struct WebSearchThreadItem {
2213    #[serde(default, skip_serializing_if = "Option::is_none")]
2214    pub action: Option<WebSearchAction>,
2215    /// Unix timestamp in milliseconds when the item completed, if recorded.
2216    #[serde(rename = "completedAtMs")]
2217    #[serde(default, skip_serializing_if = "Option::is_none")]
2218    pub completed_at_ms: Option<i64>,
2219    pub id: String,
2220    pub query: String,
2221    /// Structured search results returned out-of-band by standalone web search.
2222    ///
2223    /// These stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.
2224    #[serde(default, skip_serializing_if = "Option::is_none")]
2225    pub results: Option<Vec<Value>>,
2226    /// Unix timestamp in milliseconds when the item started, if recorded.
2227    #[serde(rename = "startedAtMs")]
2228    #[serde(default, skip_serializing_if = "Option::is_none")]
2229    pub started_at_ms: Option<i64>,
2230}