| 1 | pub const CONTRACT_NAME: &str = "codewhale-codex-app-server-v2"; |
| 2 | pub const CONTRACT_VERSION: u32 = 1; |
| 3 | pub const CODEX_PROTOCOL_TAG: &str = "rust-v0.166.0"; |
| 4 | pub const CODEX_PROTOCOL_COMMIT: &str = "6ff1e1ca3b30fc8b914720681fcf5fe62e95f856"; |
| 5 | |
| 6 | pub mod error_code { |
| 7 | pub const PARSE_ERROR: i64 = -32700; |
| 8 | pub const INVALID_REQUEST: i64 = -32600; |
| 9 | pub const METHOD_NOT_FOUND: i64 = -32601; |
| 10 | pub const INVALID_PARAMS: i64 = -32602; |
| 11 | pub const INTERNAL_ERROR: i64 = -32603; |
| 12 | pub const OVERLOADED: i64 = -32001; |
| 13 | pub const THREAD_NOT_FOUND: i64 = -32004; |
| 14 | pub const RUNTIME_UNAVAILABLE: i64 = -32005; |
| 15 | pub const CAPABILITY_UNSUPPORTED: i64 = -32020; |
| 16 | } |
| 17 | |
| 18 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 19 | pub enum Tier { |
| 20 | A, |
| 21 | B, |
| 22 | } |
| 23 | |
| 24 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 25 | pub enum Disposition { |
| 26 | Selected(Tier), |
| 27 | C, |
| 28 | Undecided, |
| 29 | } |
| 30 | |
| 31 | impl Disposition { |
| 32 | pub const fn selected(self) -> bool { |
| 33 | matches!(self, Self::Selected(_)) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
| 38 | pub enum ClientRequestMethod { |
| 39 | Initialize, |
| 40 | ThreadStart, |
| 41 | ThreadResume, |
| 42 | ThreadFork, |
| 43 | ThreadArchive, |
| 44 | ThreadDelete, |
| 45 | ThreadUnsubscribe, |
| 46 | ThreadSetName, |
| 47 | ThreadGoalSet, |
| 48 | ThreadGoalGet, |
| 49 | ThreadGoalClear, |
| 50 | ThreadUnarchive, |
| 51 | ThreadCompactStart, |
| 52 | ThreadShellCommand, |
| 53 | ThreadRevert, |
| 54 | ThreadList, |
| 55 | ThreadLoadedList, |
| 56 | ThreadRead, |
| 57 | ThreadTurnsList, |
| 58 | ThreadItemsList, |
| 59 | SkillsList, |
| 60 | HooksList, |
| 61 | FsReadFile, |
| 62 | FsWriteFile, |
| 63 | FsCreateDirectory, |
| 64 | FsGetMetadata, |
| 65 | FsReadDirectory, |
| 66 | FsRemove, |
| 67 | FsCopy, |
| 68 | FsWatch, |
| 69 | FsUnwatch, |
| 70 | TurnStart, |
| 71 | TurnSteer, |
| 72 | TurnInterrupt, |
| 73 | ReviewStart, |
| 74 | ModelList, |
| 75 | McpServerStatusList, |
| 76 | OneOffCommandExec, |
| 77 | CommandExecWrite, |
| 78 | CommandExecTerminate, |
| 79 | CommandExecResize, |
| 80 | ConfigRead, |
| 81 | ConfigValueWrite, |
| 82 | ConfigBatchWrite, |
| 83 | } |
| 84 | |
| 85 | impl ClientRequestMethod { |
| 86 | pub const ALL: &'static [Self] = &[ |
| 87 | Self::Initialize, |
| 88 | Self::ThreadStart, |
| 89 | Self::ThreadResume, |
| 90 | Self::ThreadFork, |
| 91 | Self::ThreadArchive, |
| 92 | Self::ThreadDelete, |
| 93 | Self::ThreadUnsubscribe, |
| 94 | Self::ThreadSetName, |
| 95 | Self::ThreadGoalSet, |
| 96 | Self::ThreadGoalGet, |
| 97 | Self::ThreadGoalClear, |
| 98 | Self::ThreadUnarchive, |
| 99 | Self::ThreadCompactStart, |
| 100 | Self::ThreadShellCommand, |
| 101 | Self::ThreadRevert, |
| 102 | Self::ThreadList, |
| 103 | Self::ThreadLoadedList, |
| 104 | Self::ThreadRead, |
| 105 | Self::ThreadTurnsList, |
| 106 | Self::ThreadItemsList, |
| 107 | Self::SkillsList, |
| 108 | Self::HooksList, |
| 109 | Self::FsReadFile, |
| 110 | Self::FsWriteFile, |
| 111 | Self::FsCreateDirectory, |
| 112 | Self::FsGetMetadata, |
| 113 | Self::FsReadDirectory, |
| 114 | Self::FsRemove, |
| 115 | Self::FsCopy, |
| 116 | Self::FsWatch, |
| 117 | Self::FsUnwatch, |
| 118 | Self::TurnStart, |
| 119 | Self::TurnSteer, |
| 120 | Self::TurnInterrupt, |
| 121 | Self::ReviewStart, |
| 122 | Self::ModelList, |
| 123 | Self::McpServerStatusList, |
| 124 | Self::OneOffCommandExec, |
| 125 | Self::CommandExecWrite, |
| 126 | Self::CommandExecTerminate, |
| 127 | Self::CommandExecResize, |
| 128 | Self::ConfigRead, |
| 129 | Self::ConfigValueWrite, |
| 130 | Self::ConfigBatchWrite, |
| 131 | ]; |
| 132 | |
| 133 | pub const fn method(self) -> &'static str { |
| 134 | match self { |
| 135 | Self::Initialize => "initialize", |
| 136 | Self::ThreadStart => "thread/start", |
| 137 | Self::ThreadResume => "thread/resume", |
| 138 | Self::ThreadFork => "thread/fork", |
| 139 | Self::ThreadArchive => "thread/archive", |
| 140 | Self::ThreadDelete => "thread/delete", |
| 141 | Self::ThreadUnsubscribe => "thread/unsubscribe", |
| 142 | Self::ThreadSetName => "thread/name/set", |
| 143 | Self::ThreadGoalSet => "thread/goal/set", |
| 144 | Self::ThreadGoalGet => "thread/goal/get", |
| 145 | Self::ThreadGoalClear => "thread/goal/clear", |
| 146 | Self::ThreadUnarchive => "thread/unarchive", |
| 147 | Self::ThreadCompactStart => "thread/compact/start", |
| 148 | Self::ThreadShellCommand => "thread/shellCommand", |
| 149 | Self::ThreadRevert => "thread/revert", |
| 150 | Self::ThreadList => "thread/list", |
| 151 | Self::ThreadLoadedList => "thread/loaded/list", |
| 152 | Self::ThreadRead => "thread/read", |
| 153 | Self::ThreadTurnsList => "thread/turns/list", |
| 154 | Self::ThreadItemsList => "thread/items/list", |
| 155 | Self::SkillsList => "skills/list", |
| 156 | Self::HooksList => "hooks/list", |
| 157 | Self::FsReadFile => "fs/readFile", |
| 158 | Self::FsWriteFile => "fs/writeFile", |
| 159 | Self::FsCreateDirectory => "fs/createDirectory", |
| 160 | Self::FsGetMetadata => "fs/getMetadata", |
| 161 | Self::FsReadDirectory => "fs/readDirectory", |
| 162 | Self::FsRemove => "fs/remove", |
| 163 | Self::FsCopy => "fs/copy", |
| 164 | Self::FsWatch => "fs/watch", |
| 165 | Self::FsUnwatch => "fs/unwatch", |
| 166 | Self::TurnStart => "turn/start", |
| 167 | Self::TurnSteer => "turn/steer", |
| 168 | Self::TurnInterrupt => "turn/interrupt", |
| 169 | Self::ReviewStart => "review/start", |
| 170 | Self::ModelList => "model/list", |
| 171 | Self::McpServerStatusList => "mcpServerStatus/list", |
| 172 | Self::OneOffCommandExec => "command/exec", |
| 173 | Self::CommandExecWrite => "command/exec/write", |
| 174 | Self::CommandExecTerminate => "command/exec/terminate", |
| 175 | Self::CommandExecResize => "command/exec/resize", |
| 176 | Self::ConfigRead => "config/read", |
| 177 | Self::ConfigValueWrite => "config/value/write", |
| 178 | Self::ConfigBatchWrite => "config/batchWrite", |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | pub const fn tier(self) -> Tier { |
| 183 | match self { |
| 184 | Self::Initialize => Tier::A, |
| 185 | Self::ThreadStart => Tier::A, |
| 186 | Self::ThreadResume => Tier::A, |
| 187 | Self::ThreadFork => Tier::A, |
| 188 | Self::ThreadArchive => Tier::A, |
| 189 | Self::ThreadDelete => Tier::B, |
| 190 | Self::ThreadUnsubscribe => Tier::A, |
| 191 | Self::ThreadSetName => Tier::A, |
| 192 | Self::ThreadGoalSet => Tier::A, |
| 193 | Self::ThreadGoalGet => Tier::A, |
| 194 | Self::ThreadGoalClear => Tier::A, |
| 195 | Self::ThreadUnarchive => Tier::A, |
| 196 | Self::ThreadCompactStart => Tier::B, |
| 197 | Self::ThreadShellCommand => Tier::B, |
| 198 | Self::ThreadRevert => Tier::B, |
| 199 | Self::ThreadList => Tier::A, |
| 200 | Self::ThreadLoadedList => Tier::A, |
| 201 | Self::ThreadRead => Tier::A, |
| 202 | Self::ThreadTurnsList => Tier::A, |
| 203 | Self::ThreadItemsList => Tier::A, |
| 204 | Self::SkillsList => Tier::B, |
| 205 | Self::HooksList => Tier::B, |
| 206 | Self::FsReadFile => Tier::B, |
| 207 | Self::FsWriteFile => Tier::B, |
| 208 | Self::FsCreateDirectory => Tier::B, |
| 209 | Self::FsGetMetadata => Tier::B, |
| 210 | Self::FsReadDirectory => Tier::B, |
| 211 | Self::FsRemove => Tier::B, |
| 212 | Self::FsCopy => Tier::B, |
| 213 | Self::FsWatch => Tier::B, |
| 214 | Self::FsUnwatch => Tier::B, |
| 215 | Self::TurnStart => Tier::A, |
| 216 | Self::TurnSteer => Tier::A, |
| 217 | Self::TurnInterrupt => Tier::A, |
| 218 | Self::ReviewStart => Tier::B, |
| 219 | Self::ModelList => Tier::B, |
| 220 | Self::McpServerStatusList => Tier::B, |
| 221 | Self::OneOffCommandExec => Tier::B, |
| 222 | Self::CommandExecWrite => Tier::B, |
| 223 | Self::CommandExecTerminate => Tier::B, |
| 224 | Self::CommandExecResize => Tier::B, |
| 225 | Self::ConfigRead => Tier::B, |
| 226 | Self::ConfigValueWrite => Tier::B, |
| 227 | Self::ConfigBatchWrite => Tier::B, |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | pub const fn params_type(self) -> Option<&'static str> { |
| 232 | match self { |
| 233 | Self::Initialize => Some("InitializeParams"), |
| 234 | Self::ThreadStart => Some("ThreadStartParams"), |
| 235 | Self::ThreadResume => Some("ThreadResumeParams"), |
| 236 | Self::ThreadFork => Some("ThreadForkParams"), |
| 237 | Self::ThreadArchive => Some("ThreadArchiveParams"), |
| 238 | Self::ThreadDelete => Some("ThreadDeleteParams"), |
| 239 | Self::ThreadUnsubscribe => Some("ThreadUnsubscribeParams"), |
| 240 | Self::ThreadSetName => Some("ThreadSetNameParams"), |
| 241 | Self::ThreadGoalSet => Some("ThreadGoalSetParams"), |
| 242 | Self::ThreadGoalGet => Some("ThreadGoalGetParams"), |
| 243 | Self::ThreadGoalClear => Some("ThreadGoalClearParams"), |
| 244 | Self::ThreadUnarchive => Some("ThreadUnarchiveParams"), |
| 245 | Self::ThreadCompactStart => Some("ThreadCompactStartParams"), |
| 246 | Self::ThreadShellCommand => Some("ThreadShellCommandParams"), |
| 247 | Self::ThreadRevert => Some("ThreadRevertParams"), |
| 248 | Self::ThreadList => Some("ThreadListParams"), |
| 249 | Self::ThreadLoadedList => Some("ThreadLoadedListParams"), |
| 250 | Self::ThreadRead => Some("ThreadReadParams"), |
| 251 | Self::ThreadTurnsList => Some("ThreadTurnsListParams"), |
| 252 | Self::ThreadItemsList => Some("ThreadItemsListParams"), |
| 253 | Self::SkillsList => Some("SkillsListParams"), |
| 254 | Self::HooksList => Some("HooksListParams"), |
| 255 | Self::FsReadFile => Some("FsReadFileParams"), |
| 256 | Self::FsWriteFile => Some("FsWriteFileParams"), |
| 257 | Self::FsCreateDirectory => Some("FsCreateDirectoryParams"), |
| 258 | Self::FsGetMetadata => Some("FsGetMetadataParams"), |
| 259 | Self::FsReadDirectory => Some("FsReadDirectoryParams"), |
| 260 | Self::FsRemove => Some("FsRemoveParams"), |
| 261 | Self::FsCopy => Some("FsCopyParams"), |
| 262 | Self::FsWatch => Some("FsWatchParams"), |
| 263 | Self::FsUnwatch => Some("FsUnwatchParams"), |
| 264 | Self::TurnStart => Some("TurnStartParams"), |
| 265 | Self::TurnSteer => Some("TurnSteerParams"), |
| 266 | Self::TurnInterrupt => Some("TurnInterruptParams"), |
| 267 | Self::ReviewStart => Some("ReviewStartParams"), |
| 268 | Self::ModelList => Some("ModelListParams"), |
| 269 | Self::McpServerStatusList => Some("ListMcpServerStatusParams"), |
| 270 | Self::OneOffCommandExec => Some("CommandExecParams"), |
| 271 | Self::CommandExecWrite => Some("CommandExecWriteParams"), |
| 272 | Self::CommandExecTerminate => Some("CommandExecTerminateParams"), |
| 273 | Self::CommandExecResize => Some("CommandExecResizeParams"), |
| 274 | Self::ConfigRead => Some("ConfigReadParams"), |
| 275 | Self::ConfigValueWrite => Some("ConfigValueWriteParams"), |
| 276 | Self::ConfigBatchWrite => Some("ConfigBatchWriteParams"), |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | pub const fn response_type(self) -> &'static str { |
| 281 | match self { |
| 282 | Self::Initialize => "InitializeResponse", |
| 283 | Self::ThreadStart => "ThreadStartResponse", |
| 284 | Self::ThreadResume => "ThreadResumeResponse", |
| 285 | Self::ThreadFork => "ThreadForkResponse", |
| 286 | Self::ThreadArchive => "ThreadArchiveResponse", |
| 287 | Self::ThreadDelete => "ThreadDeleteResponse", |
| 288 | Self::ThreadUnsubscribe => "ThreadUnsubscribeResponse", |
| 289 | Self::ThreadSetName => "ThreadSetNameResponse", |
| 290 | Self::ThreadGoalSet => "ThreadGoalSetResponse", |
| 291 | Self::ThreadGoalGet => "ThreadGoalGetResponse", |
| 292 | Self::ThreadGoalClear => "ThreadGoalClearResponse", |
| 293 | Self::ThreadUnarchive => "ThreadUnarchiveResponse", |
| 294 | Self::ThreadCompactStart => "ThreadCompactStartResponse", |
| 295 | Self::ThreadShellCommand => "ThreadShellCommandResponse", |
| 296 | Self::ThreadRevert => "ThreadRevertResponse", |
| 297 | Self::ThreadList => "ThreadListResponse", |
| 298 | Self::ThreadLoadedList => "ThreadLoadedListResponse", |
| 299 | Self::ThreadRead => "ThreadReadResponse", |
| 300 | Self::ThreadTurnsList => "ThreadTurnsListResponse", |
| 301 | Self::ThreadItemsList => "ThreadItemsListResponse", |
| 302 | Self::SkillsList => "SkillsListResponse", |
| 303 | Self::HooksList => "HooksListResponse", |
| 304 | Self::FsReadFile => "FsReadFileResponse", |
| 305 | Self::FsWriteFile => "FsWriteFileResponse", |
| 306 | Self::FsCreateDirectory => "FsCreateDirectoryResponse", |
| 307 | Self::FsGetMetadata => "FsGetMetadataResponse", |
| 308 | Self::FsReadDirectory => "FsReadDirectoryResponse", |
| 309 | Self::FsRemove => "FsRemoveResponse", |
| 310 | Self::FsCopy => "FsCopyResponse", |
| 311 | Self::FsWatch => "FsWatchResponse", |
| 312 | Self::FsUnwatch => "FsUnwatchResponse", |
| 313 | Self::TurnStart => "TurnStartResponse", |
| 314 | Self::TurnSteer => "TurnSteerResponse", |
| 315 | Self::TurnInterrupt => "TurnInterruptResponse", |
| 316 | Self::ReviewStart => "ReviewStartResponse", |
| 317 | Self::ModelList => "ModelListResponse", |
| 318 | Self::McpServerStatusList => "ListMcpServerStatusResponse", |
| 319 | Self::OneOffCommandExec => "CommandExecResponse", |
| 320 | Self::CommandExecWrite => "CommandExecWriteResponse", |
| 321 | Self::CommandExecTerminate => "CommandExecTerminateResponse", |
| 322 | Self::CommandExecResize => "CommandExecResizeResponse", |
| 323 | Self::ConfigRead => "ConfigReadResponse", |
| 324 | Self::ConfigValueWrite => "ConfigWriteResponse", |
| 325 | Self::ConfigBatchWrite => "ConfigWriteResponse", |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | pub fn from_method(method: &str) -> Option<Self> { |
| 330 | match method { |
| 331 | "initialize" => Some(Self::Initialize), |
| 332 | "thread/start" => Some(Self::ThreadStart), |
| 333 | "thread/resume" => Some(Self::ThreadResume), |
| 334 | "thread/fork" => Some(Self::ThreadFork), |
| 335 | "thread/archive" => Some(Self::ThreadArchive), |
| 336 | "thread/delete" => Some(Self::ThreadDelete), |
| 337 | "thread/unsubscribe" => Some(Self::ThreadUnsubscribe), |
| 338 | "thread/name/set" => Some(Self::ThreadSetName), |
| 339 | "thread/goal/set" => Some(Self::ThreadGoalSet), |
| 340 | "thread/goal/get" => Some(Self::ThreadGoalGet), |
| 341 | "thread/goal/clear" => Some(Self::ThreadGoalClear), |
| 342 | "thread/unarchive" => Some(Self::ThreadUnarchive), |
| 343 | "thread/compact/start" => Some(Self::ThreadCompactStart), |
| 344 | "thread/shellCommand" => Some(Self::ThreadShellCommand), |
| 345 | "thread/revert" => Some(Self::ThreadRevert), |
| 346 | "thread/list" => Some(Self::ThreadList), |
| 347 | "thread/loaded/list" => Some(Self::ThreadLoadedList), |
| 348 | "thread/read" => Some(Self::ThreadRead), |
| 349 | "thread/turns/list" => Some(Self::ThreadTurnsList), |
| 350 | "thread/items/list" => Some(Self::ThreadItemsList), |
| 351 | "skills/list" => Some(Self::SkillsList), |
| 352 | "hooks/list" => Some(Self::HooksList), |
| 353 | "fs/readFile" => Some(Self::FsReadFile), |
| 354 | "fs/writeFile" => Some(Self::FsWriteFile), |
| 355 | "fs/createDirectory" => Some(Self::FsCreateDirectory), |
| 356 | "fs/getMetadata" => Some(Self::FsGetMetadata), |
| 357 | "fs/readDirectory" => Some(Self::FsReadDirectory), |
| 358 | "fs/remove" => Some(Self::FsRemove), |
| 359 | "fs/copy" => Some(Self::FsCopy), |
| 360 | "fs/watch" => Some(Self::FsWatch), |
| 361 | "fs/unwatch" => Some(Self::FsUnwatch), |
| 362 | "turn/start" => Some(Self::TurnStart), |
| 363 | "turn/steer" => Some(Self::TurnSteer), |
| 364 | "turn/interrupt" => Some(Self::TurnInterrupt), |
| 365 | "review/start" => Some(Self::ReviewStart), |
| 366 | "model/list" => Some(Self::ModelList), |
| 367 | "mcpServerStatus/list" => Some(Self::McpServerStatusList), |
| 368 | "command/exec" => Some(Self::OneOffCommandExec), |
| 369 | "command/exec/write" => Some(Self::CommandExecWrite), |
| 370 | "command/exec/terminate" => Some(Self::CommandExecTerminate), |
| 371 | "command/exec/resize" => Some(Self::CommandExecResize), |
| 372 | "config/read" => Some(Self::ConfigRead), |
| 373 | "config/value/write" => Some(Self::ConfigValueWrite), |
| 374 | "config/batchWrite" => Some(Self::ConfigBatchWrite), |
| 375 | _ => None, |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | impl std::fmt::Display for ClientRequestMethod { |
| 381 | fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 382 | formatter.write_str(self.method()) |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | impl serde::Serialize for ClientRequestMethod { |
| 387 | fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
| 388 | serializer.serialize_str(self.method()) |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | impl<'de> serde::Deserialize<'de> for ClientRequestMethod { |
| 393 | fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
| 394 | let method = <std::borrow::Cow<'de, str>>::deserialize(deserializer)?; |
| 395 | Self::from_method(&method) |
| 396 | .ok_or_else(|| serde::de::Error::custom(format!("unknown method: {method}"))) |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
| 401 | pub enum ClientNotificationMethod { |
| 402 | Initialized, |
| 403 | } |
| 404 | |
| 405 | impl ClientNotificationMethod { |
| 406 | pub const ALL: &'static [Self] = &[ |
| 407 | Self::Initialized, |
| 408 | ]; |
| 409 | |
| 410 | pub const fn method(self) -> &'static str { |
| 411 | match self { |
| 412 | Self::Initialized => "initialized", |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | pub const fn tier(self) -> Tier { |
| 417 | match self { |
| 418 | Self::Initialized => Tier::A, |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | pub const fn params_type(self) -> Option<&'static str> { |
| 423 | match self { |
| 424 | Self::Initialized => None, |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | pub fn from_method(method: &str) -> Option<Self> { |
| 429 | match method { |
| 430 | "initialized" => Some(Self::Initialized), |
| 431 | _ => None, |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | impl std::fmt::Display for ClientNotificationMethod { |
| 437 | fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 438 | formatter.write_str(self.method()) |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | impl serde::Serialize for ClientNotificationMethod { |
| 443 | fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
| 444 | serializer.serialize_str(self.method()) |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | impl<'de> serde::Deserialize<'de> for ClientNotificationMethod { |
| 449 | fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
| 450 | let method = <std::borrow::Cow<'de, str>>::deserialize(deserializer)?; |
| 451 | Self::from_method(&method) |
| 452 | .ok_or_else(|| serde::de::Error::custom(format!("unknown method: {method}"))) |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
| 457 | pub enum ServerRequestMethod { |
| 458 | CommandExecutionRequestApproval, |
| 459 | FileChangeRequestApproval, |
| 460 | ToolRequestUserInput, |
| 461 | PermissionsRequestApproval, |
| 462 | DynamicToolCall, |
| 463 | } |
| 464 | |
| 465 | impl ServerRequestMethod { |
| 466 | pub const ALL: &'static [Self] = &[ |
| 467 | Self::CommandExecutionRequestApproval, |
| 468 | Self::FileChangeRequestApproval, |
| 469 | Self::ToolRequestUserInput, |
| 470 | Self::PermissionsRequestApproval, |
| 471 | Self::DynamicToolCall, |
| 472 | ]; |
| 473 | |
| 474 | pub const fn method(self) -> &'static str { |
| 475 | match self { |
| 476 | Self::CommandExecutionRequestApproval => "item/commandExecution/requestApproval", |
| 477 | Self::FileChangeRequestApproval => "item/fileChange/requestApproval", |
| 478 | Self::ToolRequestUserInput => "item/tool/requestUserInput", |
| 479 | Self::PermissionsRequestApproval => "item/permissions/requestApproval", |
| 480 | Self::DynamicToolCall => "item/tool/call", |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | pub const fn tier(self) -> Tier { |
| 485 | match self { |
| 486 | Self::CommandExecutionRequestApproval => Tier::A, |
| 487 | Self::FileChangeRequestApproval => Tier::A, |
| 488 | Self::ToolRequestUserInput => Tier::A, |
| 489 | Self::PermissionsRequestApproval => Tier::A, |
| 490 | Self::DynamicToolCall => Tier::A, |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | pub const fn params_type(self) -> Option<&'static str> { |
| 495 | match self { |
| 496 | Self::CommandExecutionRequestApproval => Some("CommandExecutionRequestApprovalParams"), |
| 497 | Self::FileChangeRequestApproval => Some("FileChangeRequestApprovalParams"), |
| 498 | Self::ToolRequestUserInput => Some("ToolRequestUserInputParams"), |
| 499 | Self::PermissionsRequestApproval => Some("PermissionsRequestApprovalParams"), |
| 500 | Self::DynamicToolCall => Some("DynamicToolCallParams"), |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | pub const fn response_type(self) -> &'static str { |
| 505 | match self { |
| 506 | Self::CommandExecutionRequestApproval => "CommandExecutionRequestApprovalResponse", |
| 507 | Self::FileChangeRequestApproval => "FileChangeRequestApprovalResponse", |
| 508 | Self::ToolRequestUserInput => "ToolRequestUserInputResponse", |
| 509 | Self::PermissionsRequestApproval => "PermissionsRequestApprovalResponse", |
| 510 | Self::DynamicToolCall => "DynamicToolCallResponse", |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | pub fn from_method(method: &str) -> Option<Self> { |
| 515 | match method { |
| 516 | "item/commandExecution/requestApproval" => Some(Self::CommandExecutionRequestApproval), |
| 517 | "item/fileChange/requestApproval" => Some(Self::FileChangeRequestApproval), |
| 518 | "item/tool/requestUserInput" => Some(Self::ToolRequestUserInput), |
| 519 | "item/permissions/requestApproval" => Some(Self::PermissionsRequestApproval), |
| 520 | "item/tool/call" => Some(Self::DynamicToolCall), |
| 521 | _ => None, |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | impl std::fmt::Display for ServerRequestMethod { |
| 527 | fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 528 | formatter.write_str(self.method()) |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | impl serde::Serialize for ServerRequestMethod { |
| 533 | fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
| 534 | serializer.serialize_str(self.method()) |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | impl<'de> serde::Deserialize<'de> for ServerRequestMethod { |
| 539 | fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
| 540 | let method = <std::borrow::Cow<'de, str>>::deserialize(deserializer)?; |
| 541 | Self::from_method(&method) |
| 542 | .ok_or_else(|| serde::de::Error::custom(format!("unknown method: {method}"))) |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] |
| 547 | pub enum ServerNotificationMethod { |
| 548 | Error, |
| 549 | ThreadStarted, |
| 550 | ThreadStatusChanged, |
| 551 | ThreadArchived, |
| 552 | ThreadDeleted, |
| 553 | ThreadUnarchived, |
| 554 | ThreadClosed, |
| 555 | ThreadReverted, |
| 556 | SkillsChanged, |
| 557 | ThreadNameUpdated, |
| 558 | ThreadGoalUpdated, |
| 559 | ThreadGoalCleared, |
| 560 | ThreadTokenUsageUpdated, |
| 561 | TurnStarted, |
| 562 | TurnCompleted, |
| 563 | TurnDiffUpdated, |
| 564 | TurnPlanUpdated, |
| 565 | ItemStarted, |
| 566 | ItemCompleted, |
| 567 | AgentMessageDelta, |
| 568 | PlanDelta, |
| 569 | CommandExecOutputDelta, |
| 570 | CommandExecutionOutputDelta, |
| 571 | TerminalInteraction, |
| 572 | FileChangeOutputDelta, |
| 573 | FileChangePatchUpdated, |
| 574 | ServerRequestResolved, |
| 575 | McpToolCallProgress, |
| 576 | FsChanged, |
| 577 | ReasoningSummaryTextDelta, |
| 578 | ReasoningSummaryPartAdded, |
| 579 | ReasoningTextDelta, |
| 580 | ContextCompacted, |
| 581 | } |
| 582 | |
| 583 | impl ServerNotificationMethod { |
| 584 | pub const ALL: &'static [Self] = &[ |
| 585 | Self::Error, |
| 586 | Self::ThreadStarted, |
| 587 | Self::ThreadStatusChanged, |
| 588 | Self::ThreadArchived, |
| 589 | Self::ThreadDeleted, |
| 590 | Self::ThreadUnarchived, |
| 591 | Self::ThreadClosed, |
| 592 | Self::ThreadReverted, |
| 593 | Self::SkillsChanged, |
| 594 | Self::ThreadNameUpdated, |
| 595 | Self::ThreadGoalUpdated, |
| 596 | Self::ThreadGoalCleared, |
| 597 | Self::ThreadTokenUsageUpdated, |
| 598 | Self::TurnStarted, |
| 599 | Self::TurnCompleted, |
| 600 | Self::TurnDiffUpdated, |
| 601 | Self::TurnPlanUpdated, |
| 602 | Self::ItemStarted, |
| 603 | Self::ItemCompleted, |
| 604 | Self::AgentMessageDelta, |
| 605 | Self::PlanDelta, |
| 606 | Self::CommandExecOutputDelta, |
| 607 | Self::CommandExecutionOutputDelta, |
| 608 | Self::TerminalInteraction, |
| 609 | Self::FileChangeOutputDelta, |
| 610 | Self::FileChangePatchUpdated, |
| 611 | Self::ServerRequestResolved, |
| 612 | Self::McpToolCallProgress, |
| 613 | Self::FsChanged, |
| 614 | Self::ReasoningSummaryTextDelta, |
| 615 | Self::ReasoningSummaryPartAdded, |
| 616 | Self::ReasoningTextDelta, |
| 617 | Self::ContextCompacted, |
| 618 | ]; |
| 619 | |
| 620 | pub const fn method(self) -> &'static str { |
| 621 | match self { |
| 622 | Self::Error => "error", |
| 623 | Self::ThreadStarted => "thread/started", |
| 624 | Self::ThreadStatusChanged => "thread/status/changed", |
| 625 | Self::ThreadArchived => "thread/archived", |
| 626 | Self::ThreadDeleted => "thread/deleted", |
| 627 | Self::ThreadUnarchived => "thread/unarchived", |
| 628 | Self::ThreadClosed => "thread/closed", |
| 629 | Self::ThreadReverted => "thread/reverted", |
| 630 | Self::SkillsChanged => "skills/changed", |
| 631 | Self::ThreadNameUpdated => "thread/name/updated", |
| 632 | Self::ThreadGoalUpdated => "thread/goal/updated", |
| 633 | Self::ThreadGoalCleared => "thread/goal/cleared", |
| 634 | Self::ThreadTokenUsageUpdated => "thread/tokenUsage/updated", |
| 635 | Self::TurnStarted => "turn/started", |
| 636 | Self::TurnCompleted => "turn/completed", |
| 637 | Self::TurnDiffUpdated => "turn/diff/updated", |
| 638 | Self::TurnPlanUpdated => "turn/plan/updated", |
| 639 | Self::ItemStarted => "item/started", |
| 640 | Self::ItemCompleted => "item/completed", |
| 641 | Self::AgentMessageDelta => "item/agentMessage/delta", |
| 642 | Self::PlanDelta => "item/plan/delta", |
| 643 | Self::CommandExecOutputDelta => "command/exec/outputDelta", |
| 644 | Self::CommandExecutionOutputDelta => "item/commandExecution/outputDelta", |
| 645 | Self::TerminalInteraction => "item/commandExecution/terminalInteraction", |
| 646 | Self::FileChangeOutputDelta => "item/fileChange/outputDelta", |
| 647 | Self::FileChangePatchUpdated => "item/fileChange/patchUpdated", |
| 648 | Self::ServerRequestResolved => "serverRequest/resolved", |
| 649 | Self::McpToolCallProgress => "item/mcpToolCall/progress", |
| 650 | Self::FsChanged => "fs/changed", |
| 651 | Self::ReasoningSummaryTextDelta => "item/reasoning/summaryTextDelta", |
| 652 | Self::ReasoningSummaryPartAdded => "item/reasoning/summaryPartAdded", |
| 653 | Self::ReasoningTextDelta => "item/reasoning/textDelta", |
| 654 | Self::ContextCompacted => "thread/compacted", |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | pub const fn tier(self) -> Tier { |
| 659 | match self { |
| 660 | Self::Error => Tier::A, |
| 661 | Self::ThreadStarted => Tier::A, |
| 662 | Self::ThreadStatusChanged => Tier::A, |
| 663 | Self::ThreadArchived => Tier::A, |
| 664 | Self::ThreadDeleted => Tier::B, |
| 665 | Self::ThreadUnarchived => Tier::A, |
| 666 | Self::ThreadClosed => Tier::A, |
| 667 | Self::ThreadReverted => Tier::B, |
| 668 | Self::SkillsChanged => Tier::B, |
| 669 | Self::ThreadNameUpdated => Tier::A, |
| 670 | Self::ThreadGoalUpdated => Tier::A, |
| 671 | Self::ThreadGoalCleared => Tier::A, |
| 672 | Self::ThreadTokenUsageUpdated => Tier::A, |
| 673 | Self::TurnStarted => Tier::A, |
| 674 | Self::TurnCompleted => Tier::A, |
| 675 | Self::TurnDiffUpdated => Tier::A, |
| 676 | Self::TurnPlanUpdated => Tier::A, |
| 677 | Self::ItemStarted => Tier::A, |
| 678 | Self::ItemCompleted => Tier::A, |
| 679 | Self::AgentMessageDelta => Tier::A, |
| 680 | Self::PlanDelta => Tier::A, |
| 681 | Self::CommandExecOutputDelta => Tier::B, |
| 682 | Self::CommandExecutionOutputDelta => Tier::A, |
| 683 | Self::TerminalInteraction => Tier::A, |
| 684 | Self::FileChangeOutputDelta => Tier::A, |
| 685 | Self::FileChangePatchUpdated => Tier::A, |
| 686 | Self::ServerRequestResolved => Tier::A, |
| 687 | Self::McpToolCallProgress => Tier::A, |
| 688 | Self::FsChanged => Tier::B, |
| 689 | Self::ReasoningSummaryTextDelta => Tier::A, |
| 690 | Self::ReasoningSummaryPartAdded => Tier::A, |
| 691 | Self::ReasoningTextDelta => Tier::A, |
| 692 | Self::ContextCompacted => Tier::B, |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | pub const fn params_type(self) -> Option<&'static str> { |
| 697 | match self { |
| 698 | Self::Error => Some("ErrorNotification"), |
| 699 | Self::ThreadStarted => Some("ThreadStartedNotification"), |
| 700 | Self::ThreadStatusChanged => Some("ThreadStatusChangedNotification"), |
| 701 | Self::ThreadArchived => Some("ThreadArchivedNotification"), |
| 702 | Self::ThreadDeleted => Some("ThreadDeletedNotification"), |
| 703 | Self::ThreadUnarchived => Some("ThreadUnarchivedNotification"), |
| 704 | Self::ThreadClosed => Some("ThreadClosedNotification"), |
| 705 | Self::ThreadReverted => Some("ThreadRevertedNotification"), |
| 706 | Self::SkillsChanged => Some("SkillsChangedNotification"), |
| 707 | Self::ThreadNameUpdated => Some("ThreadNameUpdatedNotification"), |
| 708 | Self::ThreadGoalUpdated => Some("ThreadGoalUpdatedNotification"), |
| 709 | Self::ThreadGoalCleared => Some("ThreadGoalClearedNotification"), |
| 710 | Self::ThreadTokenUsageUpdated => Some("ThreadTokenUsageUpdatedNotification"), |
| 711 | Self::TurnStarted => Some("TurnStartedNotification"), |
| 712 | Self::TurnCompleted => Some("TurnCompletedNotification"), |
| 713 | Self::TurnDiffUpdated => Some("TurnDiffUpdatedNotification"), |
| 714 | Self::TurnPlanUpdated => Some("TurnPlanUpdatedNotification"), |
| 715 | Self::ItemStarted => Some("ItemStartedNotification"), |
| 716 | Self::ItemCompleted => Some("ItemCompletedNotification"), |
| 717 | Self::AgentMessageDelta => Some("AgentMessageDeltaNotification"), |
| 718 | Self::PlanDelta => Some("PlanDeltaNotification"), |
| 719 | Self::CommandExecOutputDelta => Some("CommandExecOutputDeltaNotification"), |
| 720 | Self::CommandExecutionOutputDelta => Some("CommandExecutionOutputDeltaNotification"), |
| 721 | Self::TerminalInteraction => Some("TerminalInteractionNotification"), |
| 722 | Self::FileChangeOutputDelta => Some("FileChangeOutputDeltaNotification"), |
| 723 | Self::FileChangePatchUpdated => Some("FileChangePatchUpdatedNotification"), |
| 724 | Self::ServerRequestResolved => Some("ServerRequestResolvedNotification"), |
| 725 | Self::McpToolCallProgress => Some("McpToolCallProgressNotification"), |
| 726 | Self::FsChanged => Some("FsChangedNotification"), |
| 727 | Self::ReasoningSummaryTextDelta => Some("ReasoningSummaryTextDeltaNotification"), |
| 728 | Self::ReasoningSummaryPartAdded => Some("ReasoningSummaryPartAddedNotification"), |
| 729 | Self::ReasoningTextDelta => Some("ReasoningTextDeltaNotification"), |
| 730 | Self::ContextCompacted => Some("ContextCompactedNotification"), |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | pub fn from_method(method: &str) -> Option<Self> { |
| 735 | match method { |
| 736 | "error" => Some(Self::Error), |
| 737 | "thread/started" => Some(Self::ThreadStarted), |
| 738 | "thread/status/changed" => Some(Self::ThreadStatusChanged), |
| 739 | "thread/archived" => Some(Self::ThreadArchived), |
| 740 | "thread/deleted" => Some(Self::ThreadDeleted), |
| 741 | "thread/unarchived" => Some(Self::ThreadUnarchived), |
| 742 | "thread/closed" => Some(Self::ThreadClosed), |
| 743 | "thread/reverted" => Some(Self::ThreadReverted), |
| 744 | "skills/changed" => Some(Self::SkillsChanged), |
| 745 | "thread/name/updated" => Some(Self::ThreadNameUpdated), |
| 746 | "thread/goal/updated" => Some(Self::ThreadGoalUpdated), |
| 747 | "thread/goal/cleared" => Some(Self::ThreadGoalCleared), |
| 748 | "thread/tokenUsage/updated" => Some(Self::ThreadTokenUsageUpdated), |
| 749 | "turn/started" => Some(Self::TurnStarted), |
| 750 | "turn/completed" => Some(Self::TurnCompleted), |
| 751 | "turn/diff/updated" => Some(Self::TurnDiffUpdated), |
| 752 | "turn/plan/updated" => Some(Self::TurnPlanUpdated), |
| 753 | "item/started" => Some(Self::ItemStarted), |
| 754 | "item/completed" => Some(Self::ItemCompleted), |
| 755 | "item/agentMessage/delta" => Some(Self::AgentMessageDelta), |
| 756 | "item/plan/delta" => Some(Self::PlanDelta), |
| 757 | "command/exec/outputDelta" => Some(Self::CommandExecOutputDelta), |
| 758 | "item/commandExecution/outputDelta" => Some(Self::CommandExecutionOutputDelta), |
| 759 | "item/commandExecution/terminalInteraction" => Some(Self::TerminalInteraction), |
| 760 | "item/fileChange/outputDelta" => Some(Self::FileChangeOutputDelta), |
| 761 | "item/fileChange/patchUpdated" => Some(Self::FileChangePatchUpdated), |
| 762 | "serverRequest/resolved" => Some(Self::ServerRequestResolved), |
| 763 | "item/mcpToolCall/progress" => Some(Self::McpToolCallProgress), |
| 764 | "fs/changed" => Some(Self::FsChanged), |
| 765 | "item/reasoning/summaryTextDelta" => Some(Self::ReasoningSummaryTextDelta), |
| 766 | "item/reasoning/summaryPartAdded" => Some(Self::ReasoningSummaryPartAdded), |
| 767 | "item/reasoning/textDelta" => Some(Self::ReasoningTextDelta), |
| 768 | "thread/compacted" => Some(Self::ContextCompacted), |
| 769 | _ => None, |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | impl std::fmt::Display for ServerNotificationMethod { |
| 775 | fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 776 | formatter.write_str(self.method()) |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | impl serde::Serialize for ServerNotificationMethod { |
| 781 | fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
| 782 | serializer.serialize_str(self.method()) |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | impl<'de> serde::Deserialize<'de> for ServerNotificationMethod { |
| 787 | fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
| 788 | let method = <std::borrow::Cow<'de, str>>::deserialize(deserializer)?; |
| 789 | Self::from_method(&method) |
| 790 | .ok_or_else(|| serde::de::Error::custom(format!("unknown method: {method}"))) |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | pub const CLIENT_REQUESTS: &[(&str, Disposition)] = &[ |
| 795 | ("initialize", Disposition::Selected(Tier::A)), |
| 796 | ("thread/start", Disposition::Selected(Tier::A)), |
| 797 | ("thread/resume", Disposition::Selected(Tier::A)), |
| 798 | ("thread/fork", Disposition::Selected(Tier::A)), |
| 799 | ("thread/archive", Disposition::Selected(Tier::A)), |
| 800 | ("thread/delete", Disposition::Selected(Tier::B)), |
| 801 | ("thread/unsubscribe", Disposition::Selected(Tier::A)), |
| 802 | ("thread/name/set", Disposition::Selected(Tier::A)), |
| 803 | ("thread/goal/set", Disposition::Selected(Tier::A)), |
| 804 | ("thread/goal/get", Disposition::Selected(Tier::A)), |
| 805 | ("thread/goal/clear", Disposition::Selected(Tier::A)), |
| 806 | ("thread/metadata/update", Disposition::Undecided), |
| 807 | ("thread/attachment/add", Disposition::Undecided), |
| 808 | ("thread/attachment/list", Disposition::Undecided), |
| 809 | ("thread/attachmentOwner/list", Disposition::Undecided), |
| 810 | ("thread/attachment/remove", Disposition::Undecided), |
| 811 | ("thread/section/move", Disposition::Undecided), |
| 812 | ("thread/unarchive", Disposition::Selected(Tier::A)), |
| 813 | ("thread/compact/start", Disposition::Selected(Tier::B)), |
| 814 | ("thread/shellCommand", Disposition::Selected(Tier::B)), |
| 815 | ("thread/approveGuardianDeniedAction", Disposition::Undecided), |
| 816 | ("thread/revert", Disposition::Selected(Tier::B)), |
| 817 | ("thread/list", Disposition::Selected(Tier::A)), |
| 818 | ("threadSection/list", Disposition::Undecided), |
| 819 | ("threadSection/create", Disposition::Undecided), |
| 820 | ("threadSection/update", Disposition::Undecided), |
| 821 | ("threadSection/delete", Disposition::Undecided), |
| 822 | ("thread/loaded/list", Disposition::Selected(Tier::A)), |
| 823 | ("thread/read", Disposition::Selected(Tier::A)), |
| 824 | ("thread/turns/list", Disposition::Selected(Tier::A)), |
| 825 | ("thread/items/list", Disposition::Selected(Tier::A)), |
| 826 | ("thread/inject_items", Disposition::Undecided), |
| 827 | ("skills/list", Disposition::Selected(Tier::B)), |
| 828 | ("skills/extraRoots/set", Disposition::Undecided), |
| 829 | ("hooks/list", Disposition::Selected(Tier::B)), |
| 830 | ("marketplace/add", Disposition::Undecided), |
| 831 | ("marketplace/remove", Disposition::Undecided), |
| 832 | ("marketplace/upgrade", Disposition::Undecided), |
| 833 | ("plugin/list", Disposition::Undecided), |
| 834 | ("plugin/installed", Disposition::Undecided), |
| 835 | ("plugin/reconcile", Disposition::Undecided), |
| 836 | ("plugin/read", Disposition::Undecided), |
| 837 | ("plugin/skill/read", Disposition::Undecided), |
| 838 | ("plugin/share/save", Disposition::C), |
| 839 | ("plugin/share/updateTargets", Disposition::C), |
| 840 | ("plugin/share/list", Disposition::C), |
| 841 | ("plugin/share/checkout", Disposition::C), |
| 842 | ("plugin/share/delete", Disposition::C), |
| 843 | ("app/read", Disposition::C), |
| 844 | ("app/list", Disposition::C), |
| 845 | ("app/installed", Disposition::C), |
| 846 | ("fs/readFile", Disposition::Selected(Tier::B)), |
| 847 | ("fs/writeFile", Disposition::Selected(Tier::B)), |
| 848 | ("fs/createDirectory", Disposition::Selected(Tier::B)), |
| 849 | ("fs/getMetadata", Disposition::Selected(Tier::B)), |
| 850 | ("fs/readDirectory", Disposition::Selected(Tier::B)), |
| 851 | ("fs/remove", Disposition::Selected(Tier::B)), |
| 852 | ("fs/copy", Disposition::Selected(Tier::B)), |
| 853 | ("fs/watch", Disposition::Selected(Tier::B)), |
| 854 | ("fs/unwatch", Disposition::Selected(Tier::B)), |
| 855 | ("skills/config/write", Disposition::Undecided), |
| 856 | ("plugin/install", Disposition::Undecided), |
| 857 | ("plugin/uninstall", Disposition::Undecided), |
| 858 | ("turn/start", Disposition::Selected(Tier::A)), |
| 859 | ("turn/steer", Disposition::Selected(Tier::A)), |
| 860 | ("turn/interrupt", Disposition::Selected(Tier::A)), |
| 861 | ("review/start", Disposition::Selected(Tier::B)), |
| 862 | ("model/list", Disposition::Selected(Tier::B)), |
| 863 | ("account/gatewayOAuth/read", Disposition::C), |
| 864 | ("account/gatewayOAuth/login", Disposition::C), |
| 865 | ("account/gatewayOAuth/cancel", Disposition::C), |
| 866 | ("modelProvider/capabilities/read", Disposition::Undecided), |
| 867 | ("experimentalFeature/list", Disposition::Undecided), |
| 868 | ("permissionProfile/list", Disposition::Undecided), |
| 869 | ("experimentalFeature/enablement/set", Disposition::Undecided), |
| 870 | ("mcpServer/oauth/login", Disposition::Undecided), |
| 871 | ("config/mcpServer/reload", Disposition::Undecided), |
| 872 | ("mcpServerStatus/list", Disposition::Selected(Tier::B)), |
| 873 | ("mcpServer/resource/read", Disposition::Undecided), |
| 874 | ("mcpServer/tool/call", Disposition::Undecided), |
| 875 | ("windowsSandbox/setupStart", Disposition::Undecided), |
| 876 | ("windowsSandbox/readiness", Disposition::Undecided), |
| 877 | ("account/login/start", Disposition::Undecided), |
| 878 | ("account/login/cancel", Disposition::Undecided), |
| 879 | ("account/logout", Disposition::Undecided), |
| 880 | ("account/rateLimits/read", Disposition::Undecided), |
| 881 | ("account/rateLimitResetCredit/consume", Disposition::C), |
| 882 | ("account/usage/read", Disposition::Undecided), |
| 883 | ("account/workspaceMessages/read", Disposition::C), |
| 884 | ("account/sendAddCreditsNudgeEmail", Disposition::C), |
| 885 | ("feedback/upload", Disposition::C), |
| 886 | ("feedback/save", Disposition::C), |
| 887 | ("command/exec", Disposition::Selected(Tier::B)), |
| 888 | ("command/exec/write", Disposition::Selected(Tier::B)), |
| 889 | ("command/exec/terminate", Disposition::Selected(Tier::B)), |
| 890 | ("command/exec/resize", Disposition::Selected(Tier::B)), |
| 891 | ("config/read", Disposition::Selected(Tier::B)), |
| 892 | ("externalAgentConfig/detect", Disposition::Undecided), |
| 893 | ("externalAgentConfig/import", Disposition::Undecided), |
| 894 | ("externalAgentConfig/import/recordHistory", Disposition::Undecided), |
| 895 | ("externalAgentConfig/import/readHistories", Disposition::Undecided), |
| 896 | ("config/value/write", Disposition::Selected(Tier::B)), |
| 897 | ("config/batchWrite", Disposition::Selected(Tier::B)), |
| 898 | ("configRequirements/read", Disposition::Undecided), |
| 899 | ("account/read", Disposition::Undecided), |
| 900 | ("getConversationSummary", Disposition::C), |
| 901 | ("gitDiffToRemote", Disposition::C), |
| 902 | ("getAuthStatus", Disposition::C), |
| 903 | ("fuzzyFileSearch", Disposition::Undecided), |
| 904 | ]; |
| 905 | |
| 906 | pub const CLIENT_NOTIFICATIONS: &[(&str, Disposition)] = &[ |
| 907 | ("initialized", Disposition::Selected(Tier::A)), |
| 908 | ]; |
| 909 | |
| 910 | pub const SERVER_REQUESTS: &[(&str, Disposition)] = &[ |
| 911 | ("item/commandExecution/requestApproval", Disposition::Selected(Tier::A)), |
| 912 | ("item/fileChange/requestApproval", Disposition::Selected(Tier::A)), |
| 913 | ("item/tool/requestUserInput", Disposition::Selected(Tier::A)), |
| 914 | ("mcpServer/elicitation/request", Disposition::Undecided), |
| 915 | ("item/permissions/requestApproval", Disposition::Selected(Tier::A)), |
| 916 | ("item/tool/call", Disposition::Selected(Tier::A)), |
| 917 | ("account/chatgptAuthTokens/refresh", Disposition::C), |
| 918 | ("attestation/generate", Disposition::C), |
| 919 | ("applyPatchApproval", Disposition::C), |
| 920 | ("execCommandApproval", Disposition::C), |
| 921 | ]; |
| 922 | |
| 923 | pub const SERVER_NOTIFICATIONS: &[(&str, Disposition)] = &[ |
| 924 | ("error", Disposition::Selected(Tier::A)), |
| 925 | ("thread/started", Disposition::Selected(Tier::A)), |
| 926 | ("thread/status/changed", Disposition::Selected(Tier::A)), |
| 927 | ("thread/readState/changed", Disposition::Undecided), |
| 928 | ("thread/archived", Disposition::Selected(Tier::A)), |
| 929 | ("thread/deleted", Disposition::Selected(Tier::B)), |
| 930 | ("thread/unarchived", Disposition::Selected(Tier::A)), |
| 931 | ("thread/closed", Disposition::Selected(Tier::A)), |
| 932 | ("thread/reverted", Disposition::Selected(Tier::B)), |
| 933 | ("skills/changed", Disposition::Selected(Tier::B)), |
| 934 | ("thread/name/updated", Disposition::Selected(Tier::A)), |
| 935 | ("thread/attachment/updated", Disposition::Undecided), |
| 936 | ("thread/goal/updated", Disposition::Selected(Tier::A)), |
| 937 | ("thread/prediction/updated", Disposition::Undecided), |
| 938 | ("thread/goal/cleared", Disposition::Selected(Tier::A)), |
| 939 | ("thread/queue/changed", Disposition::Undecided), |
| 940 | ("project/changed", Disposition::Undecided), |
| 941 | ("thread/project/updated", Disposition::Undecided), |
| 942 | ("thread/environment/connected", Disposition::Undecided), |
| 943 | ("thread/environment/disconnected", Disposition::Undecided), |
| 944 | ("thread/settings/updated", Disposition::Undecided), |
| 945 | ("thread/tokenUsage/updated", Disposition::Selected(Tier::A)), |
| 946 | ("turn/started", Disposition::Selected(Tier::A)), |
| 947 | ("hook/started", Disposition::Undecided), |
| 948 | ("turn/completed", Disposition::Selected(Tier::A)), |
| 949 | ("hook/completed", Disposition::Undecided), |
| 950 | ("turn/diff/updated", Disposition::Selected(Tier::A)), |
| 951 | ("turn/plan/updated", Disposition::Selected(Tier::A)), |
| 952 | ("item/started", Disposition::Selected(Tier::A)), |
| 953 | ("item/autoApprovalReview/started", Disposition::Undecided), |
| 954 | ("item/autoApprovalReview/completed", Disposition::Undecided), |
| 955 | ("autoApprovalReview/strictReviewRequired", Disposition::Undecided), |
| 956 | ("item/completed", Disposition::Selected(Tier::A)), |
| 957 | ("rawResponseItem/completed", Disposition::C), |
| 958 | ("rawResponse/completed", Disposition::C), |
| 959 | ("item/agentMessage/delta", Disposition::Selected(Tier::A)), |
| 960 | ("item/plan/delta", Disposition::Selected(Tier::A)), |
| 961 | ("command/exec/outputDelta", Disposition::Selected(Tier::B)), |
| 962 | ("process/outputDelta", Disposition::Undecided), |
| 963 | ("process/exited", Disposition::Undecided), |
| 964 | ("item/commandExecution/outputDelta", Disposition::Selected(Tier::A)), |
| 965 | ("item/commandExecution/terminalInteraction", Disposition::Selected(Tier::A)), |
| 966 | ("item/fileChange/outputDelta", Disposition::Selected(Tier::A)), |
| 967 | ("item/fileChange/patchUpdated", Disposition::Selected(Tier::A)), |
| 968 | ("serverRequest/resolved", Disposition::Selected(Tier::A)), |
| 969 | ("item/mcpToolCall/progress", Disposition::Selected(Tier::A)), |
| 970 | ("mcpServer/oauthLogin/completed", Disposition::Undecided), |
| 971 | ("mcpServer/startupStatus/updated", Disposition::Undecided), |
| 972 | ("mcpServer/event/stream/notification", Disposition::Undecided), |
| 973 | ("account/updated", Disposition::Undecided), |
| 974 | ("account/gatewayOAuth/changed", Disposition::C), |
| 975 | ("account/rateLimits/updated", Disposition::Undecided), |
| 976 | ("app/list/updated", Disposition::C), |
| 977 | ("remoteControl/status/changed", Disposition::Undecided), |
| 978 | ("externalAgentConfig/import/progress", Disposition::Undecided), |
| 979 | ("externalAgentConfig/import/completed", Disposition::Undecided), |
| 980 | ("fs/changed", Disposition::Selected(Tier::B)), |
| 981 | ("item/reasoning/summaryTextDelta", Disposition::Selected(Tier::A)), |
| 982 | ("item/reasoning/summaryPartAdded", Disposition::Selected(Tier::A)), |
| 983 | ("item/reasoning/textDelta", Disposition::Selected(Tier::A)), |
| 984 | ("thread/compacted", Disposition::Selected(Tier::B)), |
| 985 | ("model/rerouted", Disposition::Undecided), |
| 986 | ("model/verification", Disposition::Undecided), |
| 987 | ("modelProvider/authRecoveryStarted", Disposition::Undecided), |
| 988 | ("modelProvider/authRecoveryCompleted", Disposition::Undecided), |
| 989 | ("turn/moderationMetadata", Disposition::Undecided), |
| 990 | ("model/safetyBuffering/updated", Disposition::Undecided), |
| 991 | ("warning", Disposition::Undecided), |
| 992 | ("guardianWarning", Disposition::Undecided), |
| 993 | ("deprecationNotice", Disposition::Undecided), |
| 994 | ("configWarning", Disposition::Undecided), |
| 995 | ("fuzzyFileSearch/sessionUpdated", Disposition::Undecided), |
| 996 | ("fuzzyFileSearch/sessionCompleted", Disposition::Undecided), |
| 997 | ("thread/realtime/started", Disposition::Undecided), |
| 998 | ("thread/realtime/itemAdded", Disposition::Undecided), |
| 999 | ("thread/realtime/item/started", Disposition::Undecided), |
| 1000 | ("thread/realtime/item/transcript/delta", Disposition::Undecided), |
| 1001 | ("thread/realtime/item/completed", Disposition::Undecided), |
| 1002 | ("thread/realtime/transcript/delta", Disposition::Undecided), |
| 1003 | ("thread/realtime/transcript/done", Disposition::Undecided), |
| 1004 | ("thread/realtime/outputAudio/delta", Disposition::Undecided), |
| 1005 | ("thread/realtime/sdp", Disposition::Undecided), |
| 1006 | ("thread/realtime/error", Disposition::Undecided), |
| 1007 | ("thread/realtime/closed", Disposition::Undecided), |
| 1008 | ("windows/worldWritableWarning", Disposition::Undecided), |
| 1009 | ("windowsSandbox/setupCompleted", Disposition::Undecided), |
| 1010 | ("account/login/completed", Disposition::Undecided), |
| 1011 | ]; |
| 1012 | |
| 1013 | fn lookup(table: &[(&str, Disposition)], method: &str) -> Option<Disposition> { |
| 1014 | table |
| 1015 | .iter() |
| 1016 | .find(|(name, _)| *name == method) |
| 1017 | .map(|(_, disposition)| *disposition) |
| 1018 | } |
| 1019 | |
| 1020 | pub fn client_request_disposition(method: &str) -> Option<Disposition> { |
| 1021 | lookup(CLIENT_REQUESTS, method) |
| 1022 | } |
| 1023 | |
| 1024 | pub fn client_notification_disposition(method: &str) -> Option<Disposition> { |
| 1025 | lookup(CLIENT_NOTIFICATIONS, method) |
| 1026 | } |
| 1027 | |
| 1028 | pub fn server_request_disposition(method: &str) -> Option<Disposition> { |
| 1029 | lookup(SERVER_REQUESTS, method) |
| 1030 | } |
| 1031 | |
| 1032 | pub fn server_notification_disposition(method: &str) -> Option<Disposition> { |
| 1033 | lookup(SERVER_NOTIFICATIONS, method) |
| 1034 | } |
| 1035 | |
| 1036 | pub fn unselected_request_error(method: &str) -> Option<i64> { |
| 1037 | match client_request_disposition(method) { |
| 1038 | Some(Disposition::Selected(_)) => None, |
| 1039 | _ => Some(error_code::METHOD_NOT_FOUND), |
| 1040 | } |
| 1041 | } |
| 1042 |