codex_app_server_sdk/protocol/
notifications.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::protocol::responses::{ThreadSummary, Turn};
5use crate::protocol::shared::RequestId;
6
7macro_rules! opaque_struct {
8 ($name:ident) => {
9 #[derive(Debug, Clone, Serialize, Deserialize, Default)]
10 #[serde(rename_all = "camelCase")]
11 pub struct $name {
12 #[serde(flatten)]
13 pub extra: serde_json::Map<String, Value>,
14 }
15 };
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, Default)]
19#[serde(rename_all = "camelCase")]
20pub struct ErrorNotification {
21 pub error: super::responses::TurnError,
22 #[serde(flatten)]
23 pub extra: serde_json::Map<String, Value>,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize, Default)]
27#[serde(rename_all = "camelCase")]
28pub struct ThreadStartedNotification {
29 pub thread: ThreadSummary,
30 #[serde(flatten)]
31 pub extra: serde_json::Map<String, Value>,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize, Default)]
35#[serde(rename_all = "camelCase")]
36pub struct ThreadNameUpdatedNotification {
37 pub thread_id: String,
38 pub name: String,
39 #[serde(flatten)]
40 pub extra: serde_json::Map<String, Value>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, Default)]
44#[serde(rename_all = "camelCase")]
45pub struct ThreadLifecycleNotification {
46 pub thread_id: String,
47 #[serde(flatten)]
48 pub extra: serde_json::Map<String, Value>,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize, Default)]
52#[serde(rename_all = "camelCase")]
53pub struct ThreadStatusValue {
54 #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
55 pub status_type: Option<String>,
56 #[serde(default)]
57 pub active_flags: Vec<String>,
58 #[serde(flatten)]
59 pub extra: serde_json::Map<String, Value>,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize, Default)]
63#[serde(rename_all = "camelCase")]
64pub struct ThreadStatusChangedNotification {
65 pub thread_id: String,
66 #[serde(default, skip_serializing_if = "Option::is_none")]
67 pub status: Option<ThreadStatusValue>,
68 #[serde(flatten)]
69 pub extra: serde_json::Map<String, Value>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, Default)]
73#[serde(rename_all = "camelCase")]
74pub struct ThreadTokenUsageUpdatedNotification {
75 #[serde(default, skip_serializing_if = "Option::is_none")]
76 pub thread_id: Option<String>,
77 #[serde(default, skip_serializing_if = "Option::is_none")]
78 pub usage: Option<Value>,
79 #[serde(flatten)]
80 pub extra: serde_json::Map<String, Value>,
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize, Default)]
84#[serde(rename_all = "camelCase")]
85pub struct TurnStartedNotification {
86 pub turn: Turn,
87 #[serde(flatten)]
88 pub extra: serde_json::Map<String, Value>,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize, Default)]
92#[serde(rename_all = "camelCase")]
93pub struct TurnCompletedNotification {
94 pub turn: Turn,
95 #[serde(flatten)]
96 pub extra: serde_json::Map<String, Value>,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize, Default)]
100#[serde(rename_all = "camelCase")]
101pub struct TurnDiffUpdatedNotification {
102 pub thread_id: String,
103 pub turn_id: String,
104 #[serde(default, skip_serializing_if = "Option::is_none")]
105 pub diff: Option<String>,
106 #[serde(flatten)]
107 pub extra: serde_json::Map<String, Value>,
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize, Default)]
111#[serde(rename_all = "camelCase")]
112pub struct PlanStep {
113 pub step: String,
114 pub status: String,
115 #[serde(flatten)]
116 pub extra: serde_json::Map<String, Value>,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize, Default)]
120#[serde(rename_all = "camelCase")]
121pub struct TurnPlanUpdatedNotification {
122 pub turn_id: String,
123 #[serde(default, skip_serializing_if = "Option::is_none")]
124 pub explanation: Option<String>,
125 #[serde(default)]
126 pub plan: Vec<PlanStep>,
127 #[serde(flatten)]
128 pub extra: serde_json::Map<String, Value>,
129}
130
131#[derive(Debug, Clone, Serialize, Deserialize, Default)]
132#[serde(rename_all = "camelCase")]
133pub struct ItemLifecycleNotification {
134 #[serde(default)]
135 pub item: Value,
136 #[serde(flatten)]
137 pub extra: serde_json::Map<String, Value>,
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize, Default)]
141#[serde(rename_all = "camelCase")]
142pub struct DeltaNotification {
143 #[serde(default, skip_serializing_if = "Option::is_none")]
144 pub item_id: Option<String>,
145 #[serde(default, skip_serializing_if = "Option::is_none")]
146 pub delta: Option<String>,
147 #[serde(default, skip_serializing_if = "Option::is_none")]
148 pub text: Option<String>,
149 #[serde(default, skip_serializing_if = "Option::is_none")]
150 pub summary_index: Option<u64>,
151 #[serde(flatten)]
152 pub extra: serde_json::Map<String, Value>,
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(rename_all = "camelCase")]
157pub struct ServerRequestResolvedNotification {
158 #[serde(default, skip_serializing_if = "Option::is_none")]
159 pub thread_id: Option<String>,
160 pub request_id: RequestId,
161 #[serde(flatten)]
162 pub extra: serde_json::Map<String, Value>,
163}
164
165opaque_struct!(McpServerOauthLoginCompletedNotification);
166opaque_struct!(AccountUpdatedNotification);
167opaque_struct!(AccountRateLimitsUpdatedNotification);
168opaque_struct!(AppListUpdatedNotification);
169opaque_struct!(DeprecationNoticeNotification);
170opaque_struct!(ConfigWarningNotification);
171opaque_struct!(WindowsWorldWritableWarningNotification);
172opaque_struct!(WindowsSandboxSetupCompletedNotification);
173opaque_struct!(AccountLoginCompletedNotification);
174opaque_struct!(AuthStatusChangeNotification);
175opaque_struct!(LoginChatGptCompleteNotification);
176opaque_struct!(SessionConfiguredNotification);
177opaque_struct!(RawResponseItemCompletedNotification);
178opaque_struct!(FuzzyFileSearchSessionUpdatedNotification);
179opaque_struct!(FuzzyFileSearchSessionCompletedNotification);