ClaudeCode.Message.User (ClaudeCode v0.1.0)

View Source

Represents a user message from the Claude CLI.

User messages typically contain tool results in response to Claude's tool use requests.

Matches the official SDK schema:

{
  type: "user",
  message: MessageParam,  # from Anthropic SDK
  session_id: string
}

Summary

Functions

Creates a new User message from JSON data.

Type guard to check if a value is a User message.

Types

t()

@type t() :: %ClaudeCode.Message.User{
  message: ClaudeCode.Types.message_param(),
  session_id: ClaudeCode.Types.session_id(),
  type: :user
}

Functions

new(json)

@spec new(map()) :: {:ok, t()} | {:error, atom() | tuple()}

Creates a new User message from JSON data.

Examples

iex> User.new(%{"type" => "user", "message" => %{...}})
{:ok, %User{...}}

iex> User.new(%{"type" => "assistant"})
{:error, :invalid_message_type}

user_message?(arg1)

@spec user_message?(any()) :: boolean()

Type guard to check if a value is a User message.