Repository navigation
v0.16.0
Added
#texton every message type that carries content. No more hand-rolling aselect { TextBlock }.map(&:text).joinin every consumer.AssistantMessage#text— joins text acrossTextBlocks in the content array.UserMessage#text— handles both String content (plain prompt) and Array-of-blocks content.SessionMessage#text— joins text across parsed content blocks from a historical transcript.#to_son each message type is aliased to#text, soputs messageand string interpolation just work.- Non-text blocks (
ToolUseBlock,ThinkingBlock,ToolResultBlock,UnknownBlock) intentionally do not answer#text— onlyTextBlockis textual. The message helpers useArray#grep(TextBlock)to select text blocks.
SessionMessage#content_blocksreturns typed block objects (TextBlock,ThinkingBlock,ToolUseBlock,ToolResultBlock,UnknownBlock) instead of the raw hash blocks from the JSONL transcript. Unknown block types becomeUnknownBlockfor forward compatibility with newer CLI versions.
Changed
- Rails Integration / Quick Start / Observability / File Checkpointing README examples dropped the
content.select { is_a?(TextBlock) }.map(&:text).joindance in favor ofmessage.text.
Usage
ClaudeAgentSDK.query(prompt: "Hello Claude") do |message|
puts message.text if message.is_a?(ClaudeAgentSDK::AssistantMessage)
endWorks the same on UserMessage, and on SessionMessage returned by get_session_messages — one contract across live and historical transcripts. Consumers carrying an extract_text(message) / assistant_text(message) helper can delete it.
What's changed
Full Changelog: v0.15.1...v0.16.0
gem install claude-agent-sdk -v 0.16.0