Expand description
ACP EventSink bridge: translates AgentEvents into session/update
notifications pushed through an mpsc channel.
The server creates one AcpBridge per session turn, injects it as the
EventSink for that session’s [AgentRuntime], and drains the
receiver after each session/prompt call to write notifications to
stdout.
§MessageId strategy (S2-C6, S2-C8)
The bridge buffers AgentEvent::PartialToken deltas internally.
When AgentEvent::TurnFinished arrives, it computes a content-hash
messageId (SHA-256 first 12 hex chars of the full accumulated text)
and emits every buffered chunk with the same messageId. The final
notification carries stopReason, messageId, and the completed
message content. This satisfies:
- S2-C6: all chunks share one
messageId. - S2-C8:
messageIdis a stable content hash. - S2-C7: the final notification includes the completed message.
§Tool call notifications (Sprint 3)
Tool calls follow the lifecycle:
tool_callwith statuspending(inc. locations)tool_call_updatewith statusin_progress(synthesised by bridge)tool_call_updatewith statuscompletedorfailed(on ToolResult)
Per-call state tracking supports concurrent tool calls arriving and completing out-of-order (S3-C7).
Structs§
- AcpBridge
- An
EventSinkthat translates agent events into ACPsession/updateJSON-RPC notificationValues and pushes them into an mpsc channel.
Functions§
- extract_
locations - Extract
ToolCallLocationentries from tool arguments. - sha256_
first_ 12 - Compute the SHA-256 hash of
textand return the first 12 hex characters. This is stable: identical input always produces the same output.