NAME
Claude::Agent::Content - Content block types for Claude Agent SDK
SYNOPSIS
use Claude::Agent::Content;
for my $block (@{$msg->content_blocks}) {
if ($block->isa('Claude::Agent::Content::Text')) {
print $block->text;
}
elsif ($block->isa('Claude::Agent::Content::ToolUse')) {
print "Tool: ", $block->name, "\n";
}
}
DESCRIPTION
This module loads the content block classes that appear inside assistant and user messages and provides the factory that builds them from decoded JSON.
CONTENT TYPES
Claude::Agent::Content::Text - Text response content
Claude::Agent::Content::Thinking - Extended thinking content
Claude::Agent::Content::ToolUse - Tool use request
Claude::Agent::Content::ToolResult - Tool execution result
METHODS
from_json
my $block = Claude::Agent::Content->from_json($data);
Builds the content block object for $data->{type}. A block of a type this module does not know is returned as the hashref it was given. Keys the class does not declare are not lost: the whole hashref is kept in the object's raw attribute. A key whose value is JSON null is treated as absent.
AUTHOR
LNATION, <email at lnation.org>
LICENSE
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under The Artistic License 2.0 (GPL Compatible).