AgentEventMapping
Category: Acp
Source: agent_event_mapping.dart
Maps Glue's current [AgentEvent] vocabulary into ACP session/update payloads.
This is the translation the ACP server uses today, while the proposed [SessionEvent] hierarchy in glue_core is wired through the harness. Once the harness emits [SessionEvent] directly, this mapper can be retired in favour of event_mapping.dart's SessionEvent variant.
Tool-call events here only carry the visible side of the loop — the server is responsible for synthesising tool-call status updates (pending → in_progress → completed/failed) around its own permission gate and execution.
Functions
SessionUpdate? agentEventToAcpUpdate(AgentEvent event)
Maps a single [AgentEvent] to a [SessionUpdate], or returns null when the event has no session/update representation today (the server handles tool-call status separately).
List<AcpToolCallContent> toolResultContent(ToolResult result)
Builds the content[] array for a tool_call_update notification from an [AgentEvent]-era [ToolResult].
Priority order:
result.metadata['diff'](path/old_text/new_text) — emit adiffcontent block so editors render a real diff view.result.contentParts— multimodal output (text, images, resource links) flows through unchanged.- Fallback: a single
textblock derived from [ToolResult.summary] or [ToolResult.content].
(1) and (2) compose: a write_file result whose contentParts include e.g. a confirmation TextPart still gets the diff block first, then the text parts after.
ToolCallKind toolNameToAcpKind(String toolName)
Maps Glue's [Tool] kind heuristic (by tool name) onto ACP's [ToolCallKind] enum. Falls back to [ToolCallKind.other] for unknown tools.