ClaudeCode.Message.System (ClaudeCode v0.1.0)

View Source

Represents a system message from the Claude CLI.

System messages are initialization messages that provide session setup information including available tools, MCP servers, model, and permission mode.

Matches the official SDK schema:

{
  type: "system",
  subtype: "init",
  apiKeySource: string,
  cwd: string,
  session_id: string,
  tools: string[],
  mcp_servers: { name: string, status: string }[],
  model: string,
  permissionMode: "default" | "acceptEdits" | "bypassPermissions" | "plan"
}

Summary

Functions

Creates a new System message from JSON data.

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

Types

t()

@type t() :: %ClaudeCode.Message.System{
  api_key_source: String.t(),
  cwd: String.t(),
  mcp_servers: [ClaudeCode.Types.mcp_server()],
  model: ClaudeCode.Types.model(),
  permission_mode: ClaudeCode.Types.permission_mode(),
  session_id: ClaudeCode.Types.session_id(),
  subtype: :init,
  tools: [String.t()],
  type: :system
}

Functions

new(json)

@spec new(map()) ::
  {:ok, t()} | {:error, :invalid_message_type | {:missing_fields, [atom()]}}

Creates a new System message from JSON data.

Examples

iex> System.new(%{"type" => "system", "subtype" => "init", ...})
{:ok, %System{...}}

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

system_message?(arg1)

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

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