toWire function
Maps a live AgentEvent stream onto the wire. Unknown event kinds cannot occur here — the engine only emits native events.
Implementation
Stream<Map<String, dynamic>> toWire(
Stream<AgentEvent> events, {
AgentWireProtocol? protocol,
}) {
final wire = protocol ?? AgentWireProtocol();
return events.map(wire.encodeEvent);
}