Content blocks of Anthropic messages, as a tagged sum type.
Blocks appear in assistant and user message content and in content_block_start stream events. Known block types decode to a tagged tuple. Any other block type, such as image or server_tool_use, decodes to {:other, map} and encodes back unchanged, so the bridge can pass blocks through without understanding them.
In content_block_start, a tool_use block carries an empty input; the arguments follow as input_json_delta fragments. A thinking block there carries an empty thinking and the text follows as thinking_delta fragments.
Summary
Functions
Decodes message content. A string is shorthand for one text block, as in the Messages API.
Decodes one wire content block.
Encodes one content block as a JSON-ready map.
Types
@type t() :: {:text, text :: String.t()} | {:thinking, thinking :: String.t(), signature :: String.t() | nil} | {:redacted_thinking, data :: String.t()} | {:tool_use, id :: String.t(), name :: String.t(), input :: map()} | {:tool_result, tool_use_id :: String.t(), content :: tool_result_content(), is_error :: boolean()} | {:other, MingaClaudeBridge.Wire.Field.json_map()}
Content of a tool_result block: a string or nested content blocks.
Functions
Decodes message content. A string is shorthand for one text block, as in the Messages API.
Decodes one wire content block.
@spec to_wire(t()) :: MingaClaudeBridge.Wire.Field.json_map()
Encodes one content block as a JSON-ready map.