Skip to content

v0.16.6

Choose a tag to compare

@ya-luotao ya-luotao released this 29 Apr 10:21
· 686 commits to main since this release

Added

  • Type classes now accept hash construction with mixed key shapes — symbols or strings, snake_case or camelCase — and support bracket access (obj[:field], obj['field']). UserMessage.new({"sessionId" => "abc"}) works the same as UserMessage.new(session_id: "abc"). Type.from_hash(nil) and Type.wrap(nil) are nil-safe.
  • ClaudeAgentOptions.new(nil) is accepted and yields an options object populated with configured defaults.

Changed

  • Discriminator fields on type classes (type on SystemPromptFile/McpStdioServerConfig/etc., behavior on PermissionResultAllow/Deny, hook_event_name on every hook input/output) are now attr_reader-only, set authoritatively in initialize. They cannot be overwritten externally.
  • ClaudeAgentOptions continues to raise ArgumentError on unknown keys (constructor, dup_with, and []=); other type subclasses silently drop unknown keys for forward-compatibility with newer CLI output.

Internal

  • Unified ~50 type classes (messages, hook inputs/outputs, MCP configs, system prompt configs, sandbox settings) under a shared Type base class. lib/claude_agent_sdk/types.rb shrank from 1510 to 588 lines; MessageParser's system-message dispatch went from 215 lines to a 14-entry lookup table.

What's changed

Full Changelog: v0.16.5...v0.16.6


gem install claude-agent-sdk -v 0.16.6