The wire vocabulary of the deck protocol: building the envelope of a server event and validating a client message.
Pure. A malformed message is an error value, never an exception, because the bytes come from a socket and any of them may be garbage.
Summary
Types
@type client_message() :: {:prompt_send, %{client_message_id: String.t(), text: String.t()}} | {:permission_respond, %{request_id: String.t(), option_id: String.t()}} | {:choice_respond, %{request_id: String.t(), option_id: String.t()}} | {:tool_call_cancel, %{tool_call_id: String.t()}} | {:session_resume, %{last_sequence: non_neg_integer(), device_id: String.t() | nil}} | {:permission_forget, %{tool: String.t()}} | {:policy_set, %{level: :ask_always | :ask_for_risky | :allow_all}}
@type decode_error() ::
:too_large | :not_json | :not_object | :unknown_type | :invalid_payload
Functions
@spec decode_client(term()) :: {:ok, client_message()} | {:error, decode_error()}
@spec envelope(non_neg_integer() | nil, String.t(), String.t(), map(), DateTime.t()) :: map()
@spec maximum_frame_bytes() :: pos_integer()
The largest client frame accepted, in bytes.
@spec server_event_types() :: [String.t()]
The names of every event the server sends.