wip event updates

This commit is contained in:
Owen Lin
2025-11-13 15:38:54 -08:00
parent f946f2b3bb
commit baa1cbedec
5 changed files with 16 additions and 8 deletions

View File

@@ -666,9 +666,10 @@ pub enum ThreadItem {
CommandExecution {
id: String,
command: String,
aggregated_output: String,
exit_code: Option<i32>,
status: CommandExecutionStatus,
is_user_shell_command: bool,
aggregated_output: Option<String>,
exit_code: Option<i32>,
duration_ms: Option<i64>,
},
FileChange {
@@ -916,7 +917,6 @@ pub struct FileChangeRequestApprovalResponse {
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct CommandExecutionRequest {
pub call_id: String,
pub command: Vec<String>,
pub cwd: PathBuf,
/// Optional explanatory reason (e.g. request for network access).
@@ -929,7 +929,6 @@ pub struct CommandExecutionRequest {
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct FileChangeRequest {
pub call_id: String,
pub file_changes: HashMap<PathBuf, FileChange>,
/// Optional explanatory reason (e.g. request for extra write access).
pub reason: Option<String>,

View File

@@ -2696,8 +2696,10 @@ async fn apply_bespoke_event_handling(
});
}
ApiVersion::V2 => {
// TODO: 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 {
call_id,
file_changes: changes
.into_iter()
.map(|(path, change)| (path, V2FileChange::from(change)))
@@ -2709,7 +2711,7 @@ async fn apply_bespoke_event_handling(
thread_id: conversation_id.to_string(),
// TODO: use the actual IDs once we have them
turn_id: "placeholder_turn_id".to_string(),
item_id: "placeholder_item_id".to_string(),
item_id,
request,
};
let rx = outgoing
@@ -2747,7 +2749,6 @@ async fn apply_bespoke_event_handling(
}
ApiVersion::V2 => {
let request = CommandExecutionRequest {
call_id,
command,
cwd,
reason,
@@ -2758,7 +2759,9 @@ async fn apply_bespoke_event_handling(
thread_id: conversation_id.to_string(),
// TODO: use the actual IDs once we have them
turn_id: "placeholder_turn_id".to_string(),
item_id: "placeholder_item_id".to_string(),
// TODO: 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,
};
let rx = outgoing

View File

@@ -77,6 +77,7 @@ impl SessionTask for UserShellCommandTask {
turn_context.as_ref(),
EventMsg::ExecCommandBegin(ExecCommandBeginEvent {
call_id: call_id.clone(),
turn_id: turn_context.sub_id.clone(),
command: shell_invocation.clone(),
cwd: turn_context.cwd.clone(),
parsed_cmd,

View File

@@ -67,6 +67,7 @@ pub(crate) async fn emit_exec_command_begin(
ctx.turn,
EventMsg::ExecCommandBegin(ExecCommandBeginEvent {
call_id: ctx.call_id.to_string(),
turn_id: ctx.turn.sub_id.clone(),
command: command.to_vec(),
cwd: cwd.to_path_buf(),
parsed_cmd: parse_command(command),

View File

@@ -1207,6 +1207,10 @@ pub struct ReviewLineRange {
pub struct ExecCommandBeginEvent {
/// Identifier so this can be paired with the ExecCommandEnd event.
pub call_id: String,
/// Turn ID that this command belongs to.
/// Use `#[serde(default)]` for backwards compatibility.
#[serde(default)]
pub turn_id: String,
/// The command to be executed.
pub command: Vec<String>,
/// The command's working directory if not the default cwd for the agent.