# `MingaClaudeBridge.Wire.Block`
[🔗](https://github.com/jsmestad/minga-claude-bridge/blob/main/lib/minga_claude_bridge/wire/block.ex#L1)

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.

# `t`

```elixir
@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()}
```

# `tool_result_content`

```elixir
@type tool_result_content() :: String.t() | [t()]
```

Content of a `tool_result` block: a string or nested content blocks.

# `content_from_wire`

```elixir
@spec content_from_wire(term()) :: {:ok, [t()]} | :error
```

Decodes message content. A string is shorthand for one text block, as in the Messages API.

# `from_wire`

```elixir
@spec from_wire(term()) :: {:ok, t()} | :error
```

Decodes one wire content block.

# `to_wire`

```elixir
@spec to_wire(t()) :: MingaClaudeBridge.Wire.Field.json_map()
```

Encodes one content block as a JSON-ready map.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
