Skip to content

Commit b140bf2

Browse files
committed
split into two methods
1 parent 94d51cc commit b140bf2

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

codex-rs/app-server-protocol/src/protocol/common.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,29 @@ impl TryFrom<JSONRPCRequest> for ServerRequest {
427427

428428
server_request_definitions! {
429429
/// NEW APIs
430-
/// Sent when approval is requested for a specific item (e.g. file edit, command execution).
431-
ItemRequestApproval => "item/requestApproval" {
432-
params: v2::ItemRequestApprovalParams,
433-
response: v2::ItemRequestApprovalResponse,
430+
/// Sent when approval is requested for a specific command execution.
431+
/// This request is used when calling turn/start instead of the legacy APIs (i.e. SendUserTurn, SendUserMessage).
432+
CommandExecutionRequestApproval => "item/commandExecution/requestApproval" {
433+
params: v2::CommandExecutionRequestApprovalParams,
434+
response: v2::CommandExecutionRequestApprovalResponse,
435+
},
436+
437+
/// Sent when approval is requested for a specific file change.
438+
/// This request is used when calling turn/start instead of the legacy APIs (i.e. SendUserTurn, SendUserMessage).
439+
FileChangeRequestApproval => "item/fileChange/requestApproval" {
440+
params: v2::FileChangeRequestApprovalParams,
441+
response: v2::FileChangeRequestApprovalResponse,
434442
},
435443

436444
/// DEPRECATED APIs below
437445
/// Request to approve a patch.
446+
/// This request is used only when calling the legacy APIs (i.e. SendUserTurn, SendUserMessage).
438447
ApplyPatchApproval {
439448
params: v1::ApplyPatchApprovalParams,
440449
response: v1::ApplyPatchApprovalResponse,
441450
},
442451
/// Request to exec a command.
452+
/// This request is used only when calling the legacy APIs (i.e. SendUserTurn, SendUserMessage).
443453
ExecCommandApproval {
444454
params: v1::ExecCommandApprovalParams,
445455
response: v1::ExecCommandApprovalResponse,

codex-rs/app-server-protocol/src/protocol/v2.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -803,20 +803,33 @@ pub struct McpToolCallProgressNotification {
803803
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
804804
#[serde(rename_all = "camelCase")]
805805
#[ts(export_to = "v2/")]
806-
pub struct ItemRequestApprovalParams {
806+
pub struct CommandExecutionRequestApprovalParams {
807807
pub thread_id: String,
808808
pub turn_id: String,
809809
pub item_id: String,
810-
pub request: ItemApprovalRequest,
810+
pub request: CommandExecutionRequest,
811+
}
812+
813+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
814+
#[ts(export_to = "v2/")]
815+
pub struct CommandExecutionRequestApprovalResponse {
816+
pub decision: ReviewDecision,
817+
}
818+
819+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
820+
#[serde(rename_all = "camelCase")]
821+
#[ts(export_to = "v2/")]
822+
pub struct FileChangeRequestApprovalParams {
823+
pub thread_id: String,
824+
pub turn_id: String,
825+
pub item_id: String,
826+
pub request: FileChangeRequest,
811827
}
812828

813829
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
814-
#[serde(tag = "type", rename_all = "camelCase")]
815-
#[ts(tag = "type")]
816830
#[ts(export_to = "v2/")]
817-
pub enum ItemApprovalRequest {
818-
CommandExecution(CommandExecutionRequest),
819-
FileEdit(FileEditRequest),
831+
pub struct FileChangeRequestApprovalResponse {
832+
pub decision: ReviewDecision,
820833
}
821834

822835
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
@@ -835,21 +848,14 @@ pub struct CommandExecutionRequest {
835848
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
836849
#[serde(rename_all = "camelCase")]
837850
#[ts(export_to = "v2/")]
838-
pub struct FileEditRequest {
851+
pub struct FileChangeRequest {
839852
pub call_id: String,
840853
pub file_changes: HashMap<PathBuf, FileChange>,
841854
/// Optional explanatory reason (e.g. request for extra write access).
842855
pub reason: Option<String>,
843856
pub grant_root: Option<PathBuf>,
844857
}
845858

846-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
847-
#[serde(rename_all = "camelCase")]
848-
#[ts(export_to = "v2/")]
849-
pub struct ItemRequestApprovalResponse {
850-
pub decision: ReviewDecision,
851-
}
852-
853859
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
854860
#[serde(rename_all = "camelCase")]
855861
#[ts(export_to = "v2/")]

0 commit comments

Comments
 (0)