class JsonRpcStream
SSE stream that wraps each event in a JSON-RPC 2.0 response envelope.
Per the A2A spec, JSON-RPC streaming returns SSE where each data: line
is a full JSON-RPC response: "jsonrpc":"2.0","id":N,"result":{...}
Usage:
stream = A2A::SSE::JsonRpcStream.new(json_rpc_id: 1)
Async do
stream.event("task" => { ... })
stream.finish
end
[200, A2A::SSE::Stream.headers, stream]
Definitions
def event(data, **opts)
Emit an SSE event wrapped in a JSON-RPC envelope.
Implementation
def event(data, **opts)
envelope = {
"jsonrpc" => "2.0",
"id" => @json_rpc_id,
"result" => data.respond_to?(:to_h) ? data.to_h : data,
}
super(envelope, **opts)
end