ReqManagedAgents.AgentCore.EventStream (ReqManagedAgents v0.1.0)

Copy Markdown View Source

Adapter from aws_event_stream's classified frames to the Converse envelope ReqManagedAgents.AgentCore.Converse.parse/1 consumes.

Framing, CRC verification, header parsing, :message-type classification, and Bedrock payload unwrap all live in AWSEventStream (the published binary vnd.amazon.eventstream codec). This module owns only the AgentCore-specific shaping of the classified frames:

  • {:event, type, payload} -> %{type => payload} (the Converse envelope), or payload as-is when the frame carries no :event-type.
  • {:exception, type, payload} / {:error, code, message} -> %{"__stream_error__" => %{"type" => …, "message" => …}}, so a server-side close (e.g. a ConverseStream ValidationException) surfaces as a distinct error rather than a silent terminal. ReqManagedAgents.AgentCore's stream_error/1 reads this shape.
  • malformed frames / payloads -> dropped (the prior recovery posture).

decode/1's {[map()], binary()} contract and incremental (chunked-buffer) semantics are preserved exactly — AWSEventStream.JSON.decode/1 is itself incremental, buffering an incomplete trailing frame as remainder.

Summary

Functions

decode(buffer)

@spec decode(binary()) :: {[map()], binary()}