ClaudeCode.Message.Assistant (ClaudeCode v0.1.0)

View Source

Represents an assistant message from the Claude CLI.

Assistant messages contain Claude's responses, which can include text, tool use requests, or a combination of both.

Matches the official SDK schema:

{
  type: "assistant",
  message: { ... },  # Anthropic SDK Message type
  session_id: string
}

Summary

Functions

Type guard to check if a value is an Assistant message.

Creates a new Assistant message from JSON data.

Types

t()

@type t() :: %ClaudeCode.Message.Assistant{
  message: ClaudeCode.Types.message(),
  session_id: String.t(),
  type: :assistant
}

Functions

assistant_message?(arg1)

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

Type guard to check if a value is an Assistant message.

new(json)

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

Creates a new Assistant message from JSON data.

Examples

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

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