Skip to content

Commit 0fb16c7

Browse files
committed
move old server requests to v1.rs
1 parent fb4695f commit 0fb16c7

File tree

2 files changed

+49
-44
lines changed

2 files changed

+49
-44
lines changed

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

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -469,55 +469,16 @@ server_request_definitions! {
469469
/// DEPRECATED APIs below
470470
/// Request to approve a patch.
471471
ApplyPatchApproval {
472-
params: ApplyPatchApprovalParams,
473-
response: ApplyPatchApprovalResponse,
472+
params: v1::ApplyPatchApprovalParams,
473+
response: v1::ApplyPatchApprovalResponse,
474474
},
475475
/// Request to exec a command.
476476
ExecCommandApproval {
477-
params: ExecCommandApprovalParams,
478-
response: ExecCommandApprovalResponse,
477+
params: v1::ExecCommandApprovalParams,
478+
response: v1::ExecCommandApprovalResponse,
479479
},
480480
}
481481

482-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
483-
#[serde(rename_all = "camelCase")]
484-
pub struct ApplyPatchApprovalParams {
485-
pub conversation_id: ConversationId,
486-
/// Use to correlate this with [codex_core::protocol::PatchApplyBeginEvent]
487-
/// and [codex_core::protocol::PatchApplyEndEvent].
488-
pub call_id: String,
489-
pub file_changes: HashMap<PathBuf, FileChange>,
490-
/// Optional explanatory reason (e.g. request for extra write access).
491-
pub reason: Option<String>,
492-
/// When set, the agent is asking the user to allow writes under this root
493-
/// for the remainder of the session (unclear if this is honored today).
494-
pub grant_root: Option<PathBuf>,
495-
}
496-
497-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
498-
#[serde(rename_all = "camelCase")]
499-
pub struct ExecCommandApprovalParams {
500-
pub conversation_id: ConversationId,
501-
/// Use to correlate this with [codex_core::protocol::ExecCommandBeginEvent]
502-
/// and [codex_core::protocol::ExecCommandEndEvent].
503-
pub call_id: String,
504-
pub command: Vec<String>,
505-
pub cwd: PathBuf,
506-
pub reason: Option<String>,
507-
pub risk: Option<SandboxCommandAssessment>,
508-
pub parsed_cmd: Vec<ParsedCommand>,
509-
}
510-
511-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
512-
pub struct ExecCommandApprovalResponse {
513-
pub decision: ReviewDecision,
514-
}
515-
516-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
517-
pub struct ApplyPatchApprovalResponse {
518-
pub decision: ReviewDecision,
519-
}
520-
521482
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
522483
#[serde(rename_all = "camelCase")]
523484
#[ts(rename_all = "camelCase")]
@@ -660,7 +621,7 @@ mod tests {
660621
#[test]
661622
fn serialize_server_request() -> Result<()> {
662623
let conversation_id = ConversationId::from_string("67e55044-10b1-426f-9247-bb680e5fe0c8")?;
663-
let params = ExecCommandApprovalParams {
624+
let params = v1::ExecCommandApprovalParams {
664625
conversation_id,
665626
call_id: "call-42".to_string(),
666627
command: vec!["echo".to_string(), "hello".to_string()],

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ use codex_protocol::config_types::ReasoningSummary;
88
use codex_protocol::config_types::SandboxMode;
99
use codex_protocol::config_types::Verbosity;
1010
use codex_protocol::models::ResponseItem;
11+
use codex_protocol::parse_command::ParsedCommand;
1112
use codex_protocol::protocol::AskForApproval;
1213
use codex_protocol::protocol::EventMsg;
14+
use codex_protocol::protocol::FileChange;
15+
use codex_protocol::protocol::ReviewDecision;
16+
use codex_protocol::protocol::SandboxCommandAssessment;
1317
use codex_protocol::protocol::SandboxPolicy;
1418
use codex_protocol::protocol::SessionSource;
1519
use codex_protocol::protocol::TurnAbortReason;
@@ -191,6 +195,46 @@ pub struct GitDiffToRemoteResponse {
191195
pub diff: String,
192196
}
193197

198+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
199+
#[serde(rename_all = "camelCase")]
200+
pub struct ApplyPatchApprovalParams {
201+
pub conversation_id: ConversationId,
202+
/// Use to correlate this with [codex_core::protocol::PatchApplyBeginEvent]
203+
/// and [codex_core::protocol::PatchApplyEndEvent].
204+
pub call_id: String,
205+
pub file_changes: HashMap<PathBuf, FileChange>,
206+
/// Optional explanatory reason (e.g. request for extra write access).
207+
pub reason: Option<String>,
208+
/// When set, the agent is asking the user to allow writes under this root
209+
/// for the remainder of the session (unclear if this is honored today).
210+
pub grant_root: Option<PathBuf>,
211+
}
212+
213+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
214+
#[serde(rename_all = "camelCase")]
215+
pub struct ApplyPatchApprovalResponse {
216+
pub decision: ReviewDecision,
217+
}
218+
219+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
220+
#[serde(rename_all = "camelCase")]
221+
pub struct ExecCommandApprovalParams {
222+
pub conversation_id: ConversationId,
223+
/// Use to correlate this with [codex_core::protocol::ExecCommandBeginEvent]
224+
/// and [codex_core::protocol::ExecCommandEndEvent].
225+
pub call_id: String,
226+
pub command: Vec<String>,
227+
pub cwd: PathBuf,
228+
pub reason: Option<String>,
229+
pub risk: Option<SandboxCommandAssessment>,
230+
pub parsed_cmd: Vec<ParsedCommand>,
231+
}
232+
233+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
234+
pub struct ExecCommandApprovalResponse {
235+
pub decision: ReviewDecision,
236+
}
237+
194238
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
195239
#[serde(rename_all = "camelCase")]
196240
pub struct CancelLoginChatGptParams {

0 commit comments

Comments
 (0)