pub struct AcpBridge { /* private fields */ }Expand description
An EventSink that translates agent events into ACP session/update
JSON-RPC notification Values and pushes them into an mpsc channel.
The receiver half is drained by the server’s dispatch after each
session/prompt completes.
Buffering contract: text deltas are buffered internally; all
notifications (chunks + final) are emitted only when
AgentEvent::TurnFinished arrives, so every chunk can carry the
stable, content-derived messageId.
Implementations§
Source§impl AcpBridge
impl AcpBridge
Sourcepub fn new(
session_id: String,
kind_map: HashMap<String, ToolKind>,
turn: u64,
tool_call_notifications_enabled: bool,
) -> (Arc<Self>, UnboundedReceiver<Value>)
pub fn new( session_id: String, kind_map: HashMap<String, ToolKind>, turn: u64, tool_call_notifications_enabled: bool, ) -> (Arc<Self>, UnboundedReceiver<Value>)
Create a new bridge and return it together with the receiver half.
kind_map maps tool registry names to their ACP ToolKind values,
populated from ToolRegistry::build_kind_map() at bridge construction
time (S3-C4).
Sourcepub async fn synthesize_cancelled_tool_results(&self)
pub async fn synthesize_cancelled_tool_results(&self)
Emit synthetic tool_call_update notifications for every in-flight
tool call, marking each as failed with a cancellation message.
Called by handle_session_cancel after firing the session’s
CancellationToken, to ensure Invariant #8 is preserved: every
Role::Assistant message with non-empty tool_calls has a
corresponding tool_result.
This method:
- Locks
pending_callsand drains all entries. - For each pending call, sends a
tool_call_updatenotification with status"failed"and a content block explaining cancellation. - Sets the
cancelledflag so subsequentToolResultevents for already-cancelled calls are suppressed.