The underlying tagged union. Public so callers that prefer std.sumtype.match can pattern-match directly over the per-kind structs.
The shared annotations value (any kind may carry it).
A deep copy of this content block.
Decode an embedded resource content block's resource payload into a typed ResourceContents. For the embeddedResource kind this is ResourceContents.fromJson of the raw resource() object (giving typed uri/mimeType/text/blob access instead of the untyped Json); for any other kind it returns a default ResourceContents.
Return a copy of this content block projected for the negotiated protocol version so the wire output stays in-schema for the peer. Two things are projected:
Which content kind this block holds.
The shared _meta value (any kind may carry it).
Attach optional annotations (audience/priority/lastModified) to this content block. Returns a copy so calls can be chained, e.g. Content.makeText("hi").withAnnotations(a). Valid on every kind.
Attach an optional _meta object to this content block. Per the MCP schema every content kind may carry _meta. Returns a copy.
Attach an optional description to a resource_link content block, per the MCP ResourceLink shape (it extends Resource). Returns a copy so calls can be chained. Only valid for the resourceLink kind.
Mark a tool_result content block as an error (sampling). Returns a copy. Only valid for the toolResult kind.
Attach an optional size (bytes) to a resource_link content block, per the MCP ResourceLink shape. Returns a copy. Only valid for the resourceLink kind.
Attach an optional structuredContent object to a tool_result content block (sampling). Returns a copy. Only valid for the toolResult kind.
Attach an optional human-readable title to a resource_link content block (ResourceLink extends Resource/BaseMetadata). Returns a copy. Only valid for the resourceLink kind.
A tool_result content block (sampling): the result of a tool call, answering the tool_use whose id is toolUseId. content is the nested result content blocks. Per ToolResultContent in the 2025-11-25 / draft schema.
A tool_use content block (sampling): the model's request to call a tool. id is the model-assigned call id, name the tool name, and input the arguments object. Per ToolUseContent in the 2025-11-25 / draft schema.
A content block as used in tool results, prompt messages, and sampling.
Modeled as a tagged union over the per-kind content structs above (TextContent, ImageContent, AudioContent, ResourceLink, EmbeddedResource, ToolUseContent, ToolResultContent). Each kind stores only the fields that are meaningful for it, so there are no meaningless-per-kind fields. Construct via the make* factories; the chainable with* setters apply only on the kinds where the field is valid.