split into two methods

This commit is contained in:
Owen Lin
2025-11-10 16:23:53 -08:00
parent b9944d8d0a
commit 7c5cb8d4db
2 changed files with 35 additions and 19 deletions

View File

@@ -427,19 +427,29 @@ impl TryFrom<JSONRPCRequest> for ServerRequest {
server_request_definitions! {
/// NEW APIs
/// Sent when approval is requested for a specific item (e.g. file edit, command execution).
ItemRequestApproval => "item/requestApproval" {
params: v2::ItemRequestApprovalParams,
response: v2::ItemRequestApprovalResponse,
/// Sent when approval is requested for a specific command execution.
/// This request is used when calling turn/start instead of the legacy APIs (i.e. SendUserTurn, SendUserMessage).
CommandExecutionRequestApproval => "item/commandExecution/requestApproval" {
params: v2::CommandExecutionRequestApprovalParams,
response: v2::CommandExecutionRequestApprovalResponse,
},
/// Sent when approval is requested for a specific file change.
/// This request is used when calling turn/start instead of the legacy APIs (i.e. SendUserTurn, SendUserMessage).
FileChangeRequestApproval => "item/fileChange/requestApproval" {
params: v2::FileChangeRequestApprovalParams,
response: v2::FileChangeRequestApprovalResponse,
},
/// DEPRECATED APIs below
/// Request to approve a patch.
/// This request is used only when calling the legacy APIs (i.e. SendUserTurn, SendUserMessage).
ApplyPatchApproval {
params: v1::ApplyPatchApprovalParams,
response: v1::ApplyPatchApprovalResponse,
},
/// Request to exec a command.
/// This request is used only when calling the legacy APIs (i.e. SendUserTurn, SendUserMessage).
ExecCommandApproval {
params: v1::ExecCommandApprovalParams,
response: v1::ExecCommandApprovalResponse,

View File

@@ -883,20 +883,33 @@ pub struct McpToolCallProgressNotification {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ItemRequestApprovalParams {
pub struct CommandExecutionRequestApprovalParams {
pub thread_id: String,
pub turn_id: String,
pub item_id: String,
pub request: ItemApprovalRequest,
pub request: CommandExecutionRequest,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(tag = "type", rename_all = "camelCase")]
#[ts(tag = "type")]
#[ts(export_to = "v2/")]
pub enum ItemApprovalRequest {
CommandExecution(CommandExecutionRequest),
FileEdit(FileEditRequest),
pub struct CommandExecutionRequestApprovalResponse {
pub decision: ReviewDecision,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct FileChangeRequestApprovalParams {
pub thread_id: String,
pub turn_id: String,
pub item_id: String,
pub request: FileChangeRequest,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[ts(export_to = "v2/")]
pub struct FileChangeRequestApprovalResponse {
pub decision: ReviewDecision,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
@@ -915,7 +928,7 @@ pub struct CommandExecutionRequest {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct FileEditRequest {
pub struct FileChangeRequest {
pub call_id: String,
pub file_changes: HashMap<PathBuf, FileChange>,
/// Optional explanatory reason (e.g. request for extra write access).
@@ -923,13 +936,6 @@ pub struct FileEditRequest {
pub grant_root: Option<PathBuf>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ItemRequestApprovalResponse {
pub decision: ReviewDecision,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]