Raxol. AgentClientProtocol. Rpc. Message
(Raxol Agent Client Protocol v0.1.0)
Copy Markdown
View Source
Wraps a Request, Notification, or Response with the required
"jsonrpc": "2.0" field, and decodes a raw wire frame into whichever of
the three it turns out to be.
decode/1 is TOTAL:
- malformed JSON (the bytes don't parse at all) ->
{:error, :parse_error} - well-formed JSON that isn't a valid JSON-RPC 2.0 frame (wrong
jsonrpcversion, not an object, or missing the fields needed to classify it as a Request/Response/Notification) ->{:error, :invalid_request}(or the more specific{:error, :invalid_jsonrpc_version}when thejsonrpcfield is present but not"2.0")
It never raises.
Ported from the MIT f1729/agent_client_protocol (c) 2025 f1729; see NOTICE.md.
Summary
Functions
Decode a JSON string into the inner Request, Notification, or Response. See moduledoc.
Encode to a JSON string (newline-delimited framing is the transport's concern).
Types
@type inner() :: Raxol.AgentClientProtocol.Rpc.Request.t() | Raxol.AgentClientProtocol.Rpc.Notification.t() | Raxol.AgentClientProtocol.Rpc.Response.t() | map()
@type t() :: %Raxol.AgentClientProtocol.Rpc.Message{message: inner()}
Functions
@spec decode(term()) :: {:ok, Raxol.AgentClientProtocol.Rpc.Request.t() | Raxol.AgentClientProtocol.Rpc.Notification.t() | Raxol.AgentClientProtocol.Rpc.Response.t()} | {:error, :parse_error | :invalid_request | :invalid_jsonrpc_version}
Decode a JSON string into the inner Request, Notification, or Response. See moduledoc.
Encode to a JSON string (newline-delimited framing is the transport's concern).