1pub use crate::protocol_generated::types::*;
23
24pub mod methods {
29 pub const INITIALIZE: &str = "initialize";
31 pub const INITIALIZED: &str = "initialized";
32 pub const THREAD_START: &str = "thread/start";
33 pub const THREAD_ARCHIVE: &str = "thread/archive";
34 pub const THREAD_DELETE: &str = "thread/delete";
35 pub const TURN_START: &str = "turn/start";
36 pub const TURN_INTERRUPT: &str = "turn/interrupt";
37 pub const TURN_STEER: &str = "turn/steer";
38 pub const THREAD_RESUME: &str = "thread/resume";
39 pub const THREAD_FORK: &str = "thread/fork";
40 pub const THREAD_UNSUBSCRIBE: &str = "thread/unsubscribe";
41 pub const THREAD_NAME_SET: &str = "thread/name/set";
42 pub const THREAD_METADATA_UPDATE: &str = "thread/metadata/update";
43 pub const THREAD_ATTACHMENT_ADD: &str = "thread/attachment/add";
44 pub const THREAD_ATTACHMENT_LIST: &str = "thread/attachment/list";
45 pub const THREAD_ATTACHMENT_REMOVE: &str = "thread/attachment/remove";
46 pub const THREAD_UNARCHIVE: &str = "thread/unarchive";
47 pub const THREAD_COMPACT_START: &str = "thread/compact/start";
48 pub const THREAD_SHELLCOMMAND: &str = "thread/shellCommand";
49 pub const THREAD_APPROVEGUARDIANDENIEDACTION: &str = "thread/approveGuardianDeniedAction";
50 pub const THREAD_LIST: &str = "thread/list";
51 pub const THREAD_LOADED_LIST: &str = "thread/loaded/list";
52 pub const THREAD_READ: &str = "thread/read";
53 pub const THREAD_INJECT_ITEMS: &str = "thread/inject_items";
54 pub const THREAD_ITEMS_LIST: &str = "thread/items/list";
55 pub const THREAD_TURNS_LIST: &str = "thread/turns/list";
56 pub const THREAD_REVERT: &str = "thread/revert";
57 pub const SKILLS_LIST: &str = "skills/list";
58 pub const HOOKS_LIST: &str = "hooks/list";
59 pub const MARKETPLACE_ADD: &str = "marketplace/add";
60 pub const MARKETPLACE_REMOVE: &str = "marketplace/remove";
61 pub const MARKETPLACE_UPGRADE: &str = "marketplace/upgrade";
62 pub const PLUGIN_LIST: &str = "plugin/list";
63 pub const PLUGIN_READ: &str = "plugin/read";
64 pub const PLUGIN_SKILL_READ: &str = "plugin/skill/read";
65 pub const PLUGIN_SHARE_SAVE: &str = "plugin/share/save";
66 pub const PLUGIN_SHARE_UPDATETARGETS: &str = "plugin/share/updateTargets";
67 pub const PLUGIN_SHARE_LIST: &str = "plugin/share/list";
68 pub const PLUGIN_SHARE_CHECKOUT: &str = "plugin/share/checkout";
69 pub const PLUGIN_SHARE_DELETE: &str = "plugin/share/delete";
70 pub const APP_LIST: &str = "app/list";
71 pub const APP_READ: &str = "app/read";
72 pub const APP_INSTALLED: &str = "app/installed";
73 pub const FS_READFILE: &str = "fs/readFile";
74 pub const FS_WRITEFILE: &str = "fs/writeFile";
75 pub const FS_CREATEDIRECTORY: &str = "fs/createDirectory";
76 pub const FS_GETMETADATA: &str = "fs/getMetadata";
77 pub const FS_READDIRECTORY: &str = "fs/readDirectory";
78 pub const FS_REMOVE: &str = "fs/remove";
79 pub const FS_COPY: &str = "fs/copy";
80 pub const FS_WATCH: &str = "fs/watch";
81 pub const FS_UNWATCH: &str = "fs/unwatch";
82 pub const SKILLS_CONFIG_WRITE: &str = "skills/config/write";
83 pub const PLUGIN_INSTALL: &str = "plugin/install";
84 pub const PLUGIN_UNINSTALL: &str = "plugin/uninstall";
85 pub const REVIEW_START: &str = "review/start";
86 pub const MODEL_LIST: &str = "model/list";
87 pub const ACCOUNT_GATEWAYOAUTH_READ: &str = "account/gatewayOAuth/read";
88 pub const ACCOUNT_GATEWAYOAUTH_LOGIN: &str = "account/gatewayOAuth/login";
89 pub const ACCOUNT_GATEWAYOAUTH_CANCEL: &str = "account/gatewayOAuth/cancel";
90 pub const MODELPROVIDER_CAPABILITIES_READ: &str = "modelProvider/capabilities/read";
91 pub const EXPERIMENTALFEATURE_LIST: &str = "experimentalFeature/list";
92 pub const EXPERIMENTALFEATURE_ENABLEMENT_SET: &str = "experimentalFeature/enablement/set";
93 pub const MCPSERVER_OAUTH_LOGIN: &str = "mcpServer/oauth/login";
94 pub const CONFIG_MCPSERVER_RELOAD: &str = "config/mcpServer/reload";
95 pub const MCPSERVERSTATUS_LIST: &str = "mcpServerStatus/list";
96 pub const MCPSERVER_RESOURCE_READ: &str = "mcpServer/resource/read";
97 pub const MCPSERVER_TOOL_CALL: &str = "mcpServer/tool/call";
98 pub const WINDOWSSANDBOX_SETUPSTART: &str = "windowsSandbox/setupStart";
99 pub const WINDOWSSANDBOX_READINESS: &str = "windowsSandbox/readiness";
100 pub const ACCOUNT_LOGIN_START: &str = "account/login/start";
101 pub const ACCOUNT_LOGIN_CANCEL: &str = "account/login/cancel";
102 pub const ACCOUNT_LOGOUT: &str = "account/logout";
103 pub const ACCOUNT_RATELIMITS_READ: &str = "account/rateLimits/read";
104 pub const ACCOUNT_SENDADDCREDITSNUDGEEMAIL: &str = "account/sendAddCreditsNudgeEmail";
105 pub const FEEDBACK_UPLOAD: &str = "feedback/upload";
106 pub const COMMAND_EXEC: &str = "command/exec";
107 pub const COMMAND_EXEC_WRITE: &str = "command/exec/write";
108 pub const COMMAND_EXEC_TERMINATE: &str = "command/exec/terminate";
109 pub const COMMAND_EXEC_RESIZE: &str = "command/exec/resize";
110 pub const CONFIG_READ: &str = "config/read";
111 pub const EXTERNALAGENTCONFIG_DETECT: &str = "externalAgentConfig/detect";
112 pub const EXTERNALAGENTCONFIG_IMPORT: &str = "externalAgentConfig/import";
113 pub const CONFIG_VALUE_WRITE: &str = "config/value/write";
114 pub const CONFIG_BATCHWRITE: &str = "config/batchWrite";
115 pub const CONFIGREQUIREMENTS_READ: &str = "configRequirements/read";
116 pub const ACCOUNT_READ: &str = "account/read";
117 pub const FUZZYFILESEARCH: &str = "fuzzyFileSearch";
118 pub const ACCOUNT_USAGE_READ: &str = "account/usage/read";
119 pub const PERMISSION_PROFILE_LIST: &str = "permissionProfile/list";
120 pub const PLUGIN_INSTALLED: &str = "plugin/installed";
121 pub const PLUGIN_RECONCILE: &str = "plugin/reconcile";
122 pub const SKILLS_EXTRA_ROOTS_SET: &str = "skills/extraRoots/set";
123 pub const THREAD_GOAL_GET: &str = "thread/goal/get";
124 pub const THREAD_GOAL_SET: &str = "thread/goal/set";
125 pub const THREAD_GOAL_CLEAR: &str = "thread/goal/clear";
126 pub const THREADSECTION_LIST: &str = "threadSection/list";
127 pub const THREADSECTION_CREATE: &str = "threadSection/create";
128 pub const THREADSECTION_UPDATE: &str = "threadSection/update";
129 pub const THREADSECTION_DELETE: &str = "threadSection/delete";
130 pub const THREAD_SECTION_MOVE: &str = "thread/section/move";
131 pub const ACCOUNT_RATELIMITRESETCREDIT_CONSUME: &str = "account/rateLimitResetCredit/consume";
132 pub const ACCOUNT_WORKSPACEMESSAGES_READ: &str = "account/workspaceMessages/read";
133 pub const EXTERNALAGENTCONFIG_IMPORT_READHISTORIES: &str =
134 "externalAgentConfig/import/readHistories";
135 pub const EXTERNALAGENTCONFIG_IMPORT_RECORDHISTORY: &str =
136 "externalAgentConfig/import/recordHistory";
137
138 pub const THREAD_STARTED: &str = "thread/started";
140 pub const STRICT_REVIEW_REQUIRED: &str = "autoApprovalReview/strictReviewRequired";
141 pub const PROJECT_CHANGED: &str = "project/changed";
142 pub const THREAD_PROJECT_UPDATED: &str = "thread/project/updated";
143 pub const THREAD_QUEUE_CHANGED: &str = "thread/queue/changed";
144 pub const THREAD_REVERTED: &str = "thread/reverted";
145 pub const THREAD_PREDICTION_UPDATED: &str = "thread/prediction/updated";
146 pub const MCP_SERVER_EVENT_STREAM: &str = "mcpServer/event/stream/notification";
147 pub const THREAD_STATUS_CHANGED: &str = "thread/status/changed";
148 pub const THREAD_TOKEN_USAGE_UPDATED: &str = "thread/tokenUsage/updated";
149 pub const TURN_STARTED: &str = "turn/started";
150 pub const TURN_COMPLETED: &str = "turn/completed";
151 pub const ITEM_STARTED: &str = "item/started";
152 pub const ITEM_COMPLETED: &str = "item/completed";
153 pub const AGENT_MESSAGE_DELTA: &str = "item/agentMessage/delta";
154 pub const CMD_OUTPUT_DELTA: &str = "item/commandExecution/outputDelta";
155 pub const FILE_CHANGE_OUTPUT_DELTA: &str = "item/fileChange/outputDelta";
156 pub const REASONING_DELTA: &str = "item/reasoning/summaryTextDelta";
157 pub const ERROR: &str = "error";
158 pub const ACCOUNT_RATE_LIMITS_UPDATED: &str = "account/rateLimits/updated";
159 pub const MCP_SERVER_STARTUP_STATUS_UPDATED: &str = "mcpServer/startupStatus/updated";
160 pub const MCP_SERVER_OAUTH_LOGIN_COMPLETED: &str = "mcpServer/oauthLogin/completed";
161 pub const REMOTE_CONTROL_STATUS_CHANGED: &str = "remoteControl/status/changed";
162 pub const FILE_CHANGE_PATCH_UPDATED: &str = "item/fileChange/patchUpdated";
163 pub const PLAN_DELTA: &str = "item/plan/delta";
164 pub const TURN_PLAN_UPDATED: &str = "turn/plan/updated";
165 pub const TURN_DIFF_UPDATED: &str = "turn/diff/updated";
166 pub const REASONING_SUMMARY_PART_ADDED: &str = "item/reasoning/summaryPartAdded";
167 pub const REASONING_TEXT_DELTA: &str = "item/reasoning/textDelta";
168 pub const ACCOUNT_LOGIN_COMPLETED: &str = "account/login/completed";
169 pub const DEPRECATION_NOTICE: &str = "deprecationNotice";
170 pub const GUARDIAN_WARNING: &str = "guardianWarning";
171 pub const WARNING: &str = "warning";
172 pub const THREAD_ARCHIVED: &str = "thread/archived";
173 pub const THREAD_CLOSED: &str = "thread/closed";
174 pub const THREAD_DELETED: &str = "thread/deleted";
175 pub const THREAD_UNARCHIVED: &str = "thread/unarchived";
176 pub const THREAD_GOAL_CLEARED: &str = "thread/goal/cleared";
177 pub const THREAD_NAME_UPDATED: &str = "thread/name/updated";
178 pub const THREAD_ATTACHMENT_UPDATED: &str = "thread/attachment/updated";
179 pub const SKILLS_CHANGED: &str = "skills/changed";
180 pub const FS_CHANGED: &str = "fs/changed";
181 pub const CONFIG_WARNING: &str = "configWarning";
182 pub const ACCOUNT_UPDATED: &str = "account/updated";
183 pub const ACCOUNT_GATEWAY_OAUTH_CHANGED: &str = "account/gatewayOAuth/changed";
184 pub const APP_LIST_UPDATED: &str = "app/list/updated";
185 pub const COMMAND_EXEC_OUTPUT_DELTA: &str = "command/exec/outputDelta";
186 pub const EXTERNAL_AGENT_CONFIG_IMPORT_COMPLETED: &str = "externalAgentConfig/import/completed";
187 pub const FUZZY_FILE_SEARCH_SESSION_COMPLETED: &str = "fuzzyFileSearch/sessionCompleted";
188 pub const FUZZY_FILE_SEARCH_SESSION_UPDATED: &str = "fuzzyFileSearch/sessionUpdated";
189 pub const HOOK_COMPLETED: &str = "hook/completed";
190 pub const HOOK_STARTED: &str = "hook/started";
191 pub const ITEM_AUTO_APPROVAL_REVIEW_COMPLETED: &str = "item/autoApprovalReview/completed";
192 pub const ITEM_AUTO_APPROVAL_REVIEW_STARTED: &str = "item/autoApprovalReview/started";
193 pub const ITEM_COMMAND_EXEC_TERMINAL_INTERACTION: &str =
194 "item/commandExecution/terminalInteraction";
195 pub const ITEM_MCP_TOOL_CALL_PROGRESS: &str = "item/mcpToolCall/progress";
196 pub const MODEL_REROUTED: &str = "model/rerouted";
197 pub const MODEL_VERIFICATION: &str = "model/verification";
198 pub const PROCESS_EXITED: &str = "process/exited";
199 pub const PROCESS_OUTPUT_DELTA: &str = "process/outputDelta";
200 pub const SERVER_REQUEST_RESOLVED: &str = "serverRequest/resolved";
201 pub const THREAD_COMPACTED: &str = "thread/compacted";
202 pub const THREAD_GOAL_UPDATED: &str = "thread/goal/updated";
203 pub const THREAD_REALTIME_CLOSED: &str = "thread/realtime/closed";
204 pub const THREAD_REALTIME_ERROR: &str = "thread/realtime/error";
205 pub const THREAD_REALTIME_ITEM_ADDED: &str = "thread/realtime/itemAdded";
206 pub const THREAD_REALTIME_OUTPUT_AUDIO_DELTA: &str = "thread/realtime/outputAudio/delta";
207 pub const THREAD_REALTIME_SDP: &str = "thread/realtime/sdp";
208 pub const THREAD_REALTIME_STARTED: &str = "thread/realtime/started";
209 pub const THREAD_REALTIME_TRANSCRIPT_DELTA: &str = "thread/realtime/transcript/delta";
210 pub const THREAD_REALTIME_TRANSCRIPT_DONE: &str = "thread/realtime/transcript/done";
211 pub const THREAD_REALTIME_ITEM_STARTED: &str = "thread/realtime/item/started";
212 pub const THREAD_REALTIME_ITEM_COMPLETED: &str = "thread/realtime/item/completed";
213 pub const THREAD_REALTIME_ITEM_TRANSCRIPT_DELTA: &str = "thread/realtime/item/transcript/delta";
214 pub const MODEL_PROVIDER_AUTH_RECOVERY_STARTED: &str = "modelProvider/authRecoveryStarted";
215 pub const MODEL_PROVIDER_AUTH_RECOVERY_COMPLETED: &str = "modelProvider/authRecoveryCompleted";
216 pub const WINDOWS_WORLD_WRITABLE_WARNING: &str = "windows/worldWritableWarning";
217 pub const WINDOWS_SANDBOX_SETUP_COMPLETED: &str = "windowsSandbox/setupCompleted";
218 pub const THREAD_SETTINGS_UPDATED: &str = "thread/settings/updated";
219 pub const TURN_MODERATION_METADATA: &str = "turn/moderationMetadata";
220 pub const EXTERNAL_AGENT_CONFIG_IMPORT_PROGRESS: &str = "externalAgentConfig/import/progress";
221 pub const MODEL_SAFETY_BUFFERING_UPDATED: &str = "model/safetyBuffering/updated";
222 pub const THREAD_ENVIRONMENT_CONNECTED: &str = "thread/environment/connected";
223 pub const THREAD_ENVIRONMENT_DISCONNECTED: &str = "thread/environment/disconnected";
224
225 pub const CMD_EXEC_APPROVAL: &str = "item/commandExecution/requestApproval";
227 pub const FILE_CHANGE_APPROVAL: &str = "item/fileChange/requestApproval";
228 pub const TOOL_REQUEST_USER_INPUT: &str = "item/tool/requestUserInput";
229 pub const MCP_SERVER_ELICITATION_REQUEST: &str = "mcpServer/elicitation/request";
230 pub const PERMISSIONS_REQUEST_APPROVAL: &str = "item/permissions/requestApproval";
231 pub const ITEM_TOOL_CALL: &str = "item/tool/call";
232 pub const CHATGPT_AUTH_TOKENS_REFRESH: &str = "account/chatgptAuthTokens/refresh";
233 pub const ATTESTATION_GENERATE: &str = "attestation/generate";
234 pub const APPLY_PATCH_APPROVAL: &str = "applyPatchApproval";
235 pub const EXEC_COMMAND_APPROVAL: &str = "execCommandApproval";
236}
237
238impl FileChangeRequestApprovalResponse {
252 pub fn accept() -> Self {
254 Self {
255 decision: FileChangeApprovalDecision::Accept,
256 }
257 }
258
259 pub fn accept_for_session() -> Self {
261 Self {
262 decision: FileChangeApprovalDecision::AcceptForSession,
263 }
264 }
265
266 pub fn decline() -> Self {
268 Self {
269 decision: FileChangeApprovalDecision::Decline,
270 }
271 }
272
273 pub fn cancel() -> Self {
275 Self {
276 decision: FileChangeApprovalDecision::Cancel,
277 }
278 }
279}
280
281impl CommandExecutionRequestApprovalResponse {
282 pub fn accept() -> Self {
284 Self {
285 decision: CommandExecutionApprovalDecision::Accept,
286 }
287 }
288
289 pub fn accept_for_session() -> Self {
291 Self {
292 decision: CommandExecutionApprovalDecision::AcceptForSession,
293 }
294 }
295
296 pub fn decline() -> Self {
298 Self {
299 decision: CommandExecutionApprovalDecision::Decline,
300 }
301 }
302
303 pub fn cancel() -> Self {
305 Self {
306 decision: CommandExecutionApprovalDecision::Cancel,
307 }
308 }
309}
310
311impl ExecCommandApprovalResponse {
312 pub fn approved() -> Self {
314 Self {
315 decision: ReviewDecision::Approved,
316 }
317 }
318
319 pub fn approved_for_session() -> Self {
321 Self {
322 decision: ReviewDecision::ApprovedForSession,
323 }
324 }
325
326 pub fn denied(rejection: impl Into<String>) -> Self {
328 Self {
329 decision: ReviewDecision::Denied {
330 rejection: rejection.into(),
331 },
332 }
333 }
334
335 pub fn abort() -> Self {
337 Self {
338 decision: ReviewDecision::Abort,
339 }
340 }
341}
342
343impl ApplyPatchApprovalResponse {
344 pub fn approved() -> Self {
346 Self {
347 decision: ReviewDecision::Approved,
348 }
349 }
350
351 pub fn approved_for_session() -> Self {
353 Self {
354 decision: ReviewDecision::ApprovedForSession,
355 }
356 }
357
358 pub fn denied(rejection: impl Into<String>) -> Self {
360 Self {
361 decision: ReviewDecision::Denied {
362 rejection: rejection.into(),
363 },
364 }
365 }
366
367 pub fn abort() -> Self {
369 Self {
370 decision: ReviewDecision::Abort,
371 }
372 }
373}
374
375#[cfg(test)]
376mod tests {
377 use super::*;
378
379 #[test]
380 fn thread_start_params_default_is_empty_object() {
381 let p = ThreadStartParams::default();
382 assert_eq!(serde_json::to_value(&p).unwrap(), serde_json::json!({}));
383 }
384
385 #[test]
386 fn turn_start_params_default_round_trips() {
387 let p = TurnStartParams::default();
388 let v = serde_json::to_value(&p).unwrap();
389 assert_eq!(v["threadId"], "");
391 assert_eq!(v["input"], serde_json::json!([]));
392 }
393
394 #[test]
395 fn thread_resume_and_fork_params_default() {
396 let _ = ThreadResumeParams::default();
397 let _ = ThreadForkParams::default();
398 }
399
400 #[test]
401 fn file_change_approval_response_wire_shape() {
402 assert_eq!(
403 serde_json::to_value(FileChangeRequestApprovalResponse::accept()).unwrap(),
404 serde_json::json!({"decision": "accept"})
405 );
406 assert_eq!(
407 serde_json::to_value(FileChangeRequestApprovalResponse::decline()).unwrap(),
408 serde_json::json!({"decision": "decline"})
409 );
410 }
411
412 #[test]
413 fn command_execution_approval_response_wire_shape() {
414 assert_eq!(
415 serde_json::to_value(CommandExecutionRequestApprovalResponse::accept()).unwrap(),
416 serde_json::json!({"decision": "accept"})
417 );
418 assert_eq!(
419 serde_json::to_value(CommandExecutionRequestApprovalResponse::cancel()).unwrap(),
420 serde_json::json!({"decision": "cancel"})
421 );
422 }
423
424 #[test]
425 fn exec_and_apply_patch_approval_response_wire_shape() {
426 assert_eq!(
427 serde_json::to_value(ExecCommandApprovalResponse::approved()).unwrap(),
428 serde_json::json!({"decision": "approved"})
429 );
430 assert_eq!(
431 serde_json::to_value(ApplyPatchApprovalResponse::denied("keep the original file"))
432 .unwrap(),
433 serde_json::json!({"decision": {"denied": {"rejection": "keep the original file"}}})
434 );
435 }
436}