# `Raxol.AgentClientProtocol.Rpc.Message`
[🔗](https://github.com/DROOdotFOO/raxol-agent/blob/raxol_agent_client_protocol-v0.1.0/packages/raxol_agent_client_protocol/lib/raxol/agent_client_protocol/rpc.ex#L237)

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
    `jsonrpc` version, 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 the
    `jsonrpc` field is present but not `"2.0"`)

It never raises.

Ported from the MIT `f1729/agent_client_protocol` (c) 2025 f1729; see NOTICE.md.

# `inner`

```elixir
@type inner() ::
  Raxol.AgentClientProtocol.Rpc.Request.t()
  | Raxol.AgentClientProtocol.Rpc.Notification.t()
  | Raxol.AgentClientProtocol.Rpc.Response.t()
  | map()
```

# `t`

```elixir
@type t() :: %Raxol.AgentClientProtocol.Rpc.Message{message: inner()}
```

# `decode`

```elixir
@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!`

```elixir
@spec encode!(t()) :: String.t()
```

Encode to a JSON string (newline-delimited framing is the transport's concern).

# `to_json`

```elixir
@spec to_json(t()) :: map()
```

# `wrap`

```elixir
@spec wrap(inner()) :: t()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
