Raxol.AgentClientProtocol.Schema.ContentBlock (Raxol Agent Client Protocol v0.1.0)

Copy Markdown View Source

Content blocks represent displayable information in ACP: a tagged union discriminated by a "type" wire key (text | image | audio | resource_link | resource). Named ContentBlock both upstream and here (all other structs ported from content.ex -- Role, Annotations, TextContent, ImageContent, AudioContent, TextResourceContents, BlobResourceContents, EmbeddedResourceResource, EmbeddedResource, ResourceLink -- are separate, bare Schema.* modules, not nested under this one).

Ported from the MIT f1729/agent_client_protocol (c) 2025 f1729; see NOTICE.md.

Summary

Functions

Total: never raises. An unrecognized/missing "type", or a variant body that fails to decode, returns {:error, _} (a content block has no documented default variant, unlike e.g. ToolCall.ToolKind).

Convenience: create a text content block from a plain string.

Types

Functions

audio(audio_content)

from_json(map)

@spec from_json(term()) :: {:ok, t()} | {:error, term()}

Total: never raises. An unrecognized/missing "type", or a variant body that fails to decode, returns {:error, _} (a content block has no documented default variant, unlike e.g. ToolCall.ToolKind).

from_string(text)

@spec from_string(String.t()) :: t()

Convenience: create a text content block from a plain string.

image(image_content)

resource(er)

resource_link(rl)

text(text_content)

to_json(arg)

@spec to_json(t()) :: map()