Raxol.Agent.Protocol (Raxol Agent v2.6.0)

Copy Markdown View Source

Message format for agent-to-agent and pilot-to-agent communication.

All cockpit messages use a typed struct with correlation tracking. Messages route through Events.Dispatcher with topic :agent_messages.

Summary

Functions

Decodes a map into a protocol message.

Encodes a message to a JSON-compatible map.

Creates a new protocol message with auto-generated timestamp and correlation id.

Creates a reply to an existing message, preserving the correlation id.

Types

message_type()

@type message_type() ::
  :directive
  | :observation
  | :query
  | :response
  | :takeover
  | :release
  | :status_update
  | :alert

t()

@type t() :: %Raxol.Agent.Protocol{
  correlation_id: binary(),
  from: atom(),
  payload: term(),
  timestamp: DateTime.t(),
  to: atom() | :broadcast,
  type: message_type()
}

Functions

decode(map)

@spec decode(map()) :: {:ok, t()} | {:error, term()}

Decodes a map into a protocol message.

encode(msg)

@spec encode(t()) :: map()

Encodes a message to a JSON-compatible map.

new(from, to, type, payload)

@spec new(atom(), atom() | :broadcast, message_type(), term()) :: t()

Creates a new protocol message with auto-generated timestamp and correlation id.

reply(original, from, type, payload)

@spec reply(t(), atom(), message_type(), term()) :: t()

Creates a reply to an existing message, preserving the correlation id.