feat: stream exec stdout events (#1786)

## Summary
- stream command stdout as `ExecCommandStdout` events
- forward streamed stdout to clients and ignore in human output
processor
- adjust call sites for new streaming API
This commit is contained in:
aibrahim-oai authored and GitHub committed 2025-08-01 13:04:34 -07:00
1 parent 8360c6a3ec
commit bc7beddaa2
11 files changed
+238 -5

No files matched your search

+25
View File
@@ -13,6 +13,7 @@ use std::time::Duration;
use mcp_types::CallToolResult;
use serde::Deserialize;
use serde::Serialize;
use serde_bytes::ByteBuf;
use strum_macros::Display;
use uuid::Uuid;
@@ -323,6 +324,12 @@ pub enum EventMsg {
/// Notification that the server is about to execute a command.
ExecCommandBegin(ExecCommandBeginEvent),
/// Incremental chunk of stdout from a running command.
ExecCommandStdoutDelta(ExecCommandStdoutDeltaEvent),
/// Incremental chunk of stderr from a running command.
ExecCommandStderrDelta(ExecCommandStderrDeltaEvent),
ExecCommandEnd(ExecCommandEndEvent),
ExecApprovalRequest(ExecApprovalRequestEvent),
@@ -476,6 +483,24 @@ pub struct ExecCommandEndEvent {
pub exit_code: i32,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExecCommandStdoutDeltaEvent {
/// Identifier for the ExecCommandBegin that produced this chunk.
pub call_id: String,
/// Raw stdout bytes (may not be valid UTF-8).
#[serde(with = "serde_bytes")]
pub chunk: ByteBuf,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExecCommandStderrDeltaEvent {
/// Identifier for the ExecCommandBegin that produced this chunk.
pub call_id: String,
/// Raw stderr bytes (may not be valid UTF-8).
#[serde(with = "serde_bytes")]
pub chunk: ByteBuf,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ExecApprovalRequestEvent {
/// Identifier for the associated exec call, if available.