ClaudeCode.Content.ToolUse (ClaudeCode v0.1.0)

View Source

Represents a tool use content block within a Claude message.

Tool use blocks indicate that Claude wants to invoke a specific tool with the given parameters.

Summary

Functions

Creates a new ToolUse content block from JSON data.

Type guard to check if a value is a ToolUse content block.

Types

t()

@type t() :: %ClaudeCode.Content.ToolUse{
  id: String.t(),
  input: map(),
  name: String.t(),
  type: :tool_use
}

Functions

new(data)

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

Creates a new ToolUse content block from JSON data.

Examples

iex> ToolUse.new(%{"type" => "tool_use", "id" => "123", "name" => "Read", "input" => %{}})
{:ok, %ToolUse{type: :tool_use, id: "123", name: "Read", input: %{}}}

iex> ToolUse.new(%{"type" => "text"})
{:error, :invalid_content_type}

tool_use_content?(arg1)

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

Type guard to check if a value is a ToolUse content block.