This commit is contained in:
Owen Lin
2025-11-13 16:23:48 -08:00
parent b417dccb23
commit 14590ce9fd
2 changed files with 18 additions and 11 deletions

View File

@@ -665,11 +665,20 @@ pub enum ThreadItem {
},
CommandExecution {
id: String,
/// The command to be executed.
command: String,
/// The command's working directory if not the default cwd for the agent.
cwd: PathBuf,
status: CommandExecutionStatus,
/// A best-effort parsing of the command to identify the type of command and its arguments.
parsed_cmd: Vec<ParsedCommand>,
/// True when this exec was initiated directly by the user (e.g. bang command),
/// not by the agent/model.
is_user_shell_command: bool,
aggregated_output: Option<String>,
/// The command's exit code.
exit_code: Option<i32>,
/// The duration of the command execution in milliseconds.
duration_ms: Option<i64>,
},
FileChange {
@@ -888,7 +897,7 @@ pub struct CommandExecutionRequestApprovalParams {
pub thread_id: String,
pub turn_id: String,
pub item_id: String,
pub request: CommandExecutionRequest,
pub metadata: CommandExecutionMetadata,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
@@ -916,12 +925,12 @@ pub struct FileChangeRequestApprovalResponse {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct CommandExecutionRequest {
pub command: Vec<String>,
pub cwd: PathBuf,
pub struct CommandExecutionMetadata {
/// Optional explanatory reason (e.g. request for network access).
pub reason: Option<String>,
/// Optional model-provided risk assessment describing the blocked command.
pub risk: Option<SandboxCommandAssessment>,
/// A best-effort parsing of the command to identify the type of command and its arguments.
pub parsed_cmd: Vec<ParsedCommand>,
}

View File

@@ -23,7 +23,7 @@ use codex_app_server_protocol::CancelLoginAccountParams;
use codex_app_server_protocol::CancelLoginAccountResponse;
use codex_app_server_protocol::CancelLoginChatGptResponse;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::CommandExecutionRequest;
use codex_app_server_protocol::CommandExecutionMetadata;
use codex_app_server_protocol::CommandExecutionRequestApprovalParams;
use codex_app_server_protocol::CommandExecutionRequestApprovalResponse;
use codex_app_server_protocol::ConversationGitInfo;
@@ -2696,7 +2696,7 @@ async fn apply_bespoke_event_handling(
});
}
ApiVersion::V2 => {
// TODO: Until we migrate the core to be aware of a first class FileChangeItem
// Until we migrate the core to be aware of a first class FileChangeItem
// and emit the corresponding EventMsg, we repurpose the call_id as the item_id.
let item_id = call_id.clone();
let request = FileChangeRequest {
@@ -2749,9 +2749,7 @@ async fn apply_bespoke_event_handling(
});
}
ApiVersion::V2 => {
let request = CommandExecutionRequest {
command,
cwd,
let metadata = CommandExecutionMetadata {
reason,
risk: risk.map(V2SandboxCommandAssessment::from),
parsed_cmd: parsed_cmd.into_iter().map(V2ParsedCommand::from).collect(),
@@ -2759,10 +2757,10 @@ async fn apply_bespoke_event_handling(
let params = CommandExecutionRequestApprovalParams {
thread_id: conversation_id.to_string(),
turn_id: turn_id.clone(),
// TODO: Until we migrate the core to be aware of a first class CommandExecutionItem
// Until we migrate the core to be aware of a first class CommandExecutionItem
// and emit the corresponding EventMsg, we repurpose the call_id as the item_id.
item_id: call_id.clone(),
request,
metadata,
};
let rx = outgoing
.send_request(ServerRequestPayload::CommandExecutionRequestApproval(