Repository navigation
v1.3.0
Added
- Every hook input carries
raw_input, the payload exactly as the CLI sent it. It used to be onUnknownHookInputonly; a typed input copied the fields its class names and dropped the rest, so a field a newer CLI added was out of reach until the SDK learned it. Hook inputs are now built from the whole payload (every field the class declares, read from the same key as before).#inspectshows it on anUnknownHookInputonly: a typed input already prints those fields as attributes. - Hook input fields the CLI already sends (Python SDK #1331, plus the schemas of Claude Code 2.1.295):
prompt_idandefforton every hook input;duration_msonPostToolUseHookInputandPostToolUseFailureHookInput;session_titleandsourceonUserPromptSubmitHookInput;session_title,seconds_since_last_response,prompt_cache_likely_expired,context_tokensandestimated_cache_write_usdonSessionStartHookInput;parent_file_pathonInstructionsLoadedHookInput. - Typed inputs for the hook events
PostToolBatch,UserPromptExpansion,PreModelSwitch,PostModelSwitch,DirectoryAddedandMessageDisplay(PostToolBatchHookInput, ...), which used to arrive asUnknownHookInput.HOOK_EVENTSlists them, so it now has the CLI's 33 events. - Hook-specific outputs from Python SDK #1331:
PostToolBatchHookSpecificOutput,UserPromptExpansionHookSpecificOutput,StopHookSpecificOutput,SubagentStopHookSpecificOutput,PreModelSwitchHookSpecificOutput,PostModelSwitchHookSpecificOutput,ElicitationHookSpecificOutput,ElicitationResultHookSpecificOutput,WorktreeCreateHookSpecificOutputandMessageDisplayHookSpecificOutput;session_titleandsuppress_original_promptonUserPromptSubmitHookSpecificOutput;initial_user_message,session_title,watch_pathsandreload_skillsonSessionStartHookSpecificOutput. A Hash return value could already send these keys; the typed classes rejected them withArgumentError.docs/hooks-and-permissions.mdnow lists every output class and its fields. InitMessage#capabilities,#plugin_errors,#terminal_slash_commandsand#fast_mode_disabled_reason, the init fields of Python SDK #1332 (SystemInitData) thatInitMessagedid not read. Testcapabilities(for example for"interrupt_receipt_v1") instead of comparingclaude_code_version.
Changed
- The repository moves to the rubycatco GitHub organization:
github.com/rubycatco/claude-agent-sdk-ruby. The oldya-luotao/...URL redirects, and the gem on rubygems.org is unaffected; gem metadata, docs, templates and issue links now point at the new home. PermissionDeniedHookSpecificOutput#retrydefaults toniland is then left out of the output, as in Python; it used to default tofalseand always sendretry: false, which the CLI reads the same way. Code that reads#retryback from a fresh instance getsnil.- The
*HookSpecificOutputclasses are declared from one table of wire keys (HookOutputKeys::HOOK_SPECIFIC) instead of each writing its own#to_h. Each class still sends the same keys, except that a field set tofalseis now sent (onlynilis left out); before, most fields also droppedfalse. CLIInstaller::PINNED_CLI_VERSIONmoves from 2.1.288 to 2.1.295, following the CLI the Python SDK bundles.CLIInstaller.install_pinnedinstalls it. See the Claude Code changelog.
Usage
hook = lambda do |input, _tool_use_id, _context|
input.prompt_id # new on every hook input
input.raw_input[:scratchpad_dir] # a field this SDK version has no reader for
ClaudeAgentSDK::SyncHookJSONOutput.new(
hook_specific_output: ClaudeAgentSDK::UserPromptSubmitHookSpecificOutput.new(session_title: 'Staging rollout')
)
end
options = ClaudeAgentSDK::ClaudeAgentOptions.new(
hooks: { 'UserPromptSubmit' => [ClaudeAgentSDK::HookMatcher.new(hooks: [hook])] }
)What's changed
- #166 Bump PINNED_CLI_VERSION to 2.1.289 — @github-actions
- #170 Bump PINNED_CLI_VERSION to 2.1.291 — @github-actions
- #171 Bump PINNED_CLI_VERSION to 2.1.293 — @github-actions
- #172 Bump PINNED_CLI_VERSION to 2.1.295 — @github-actions
- #173 Move repository references to the rubycatco organization — @ya-luotao
- #174 Follow Python SDK #1331/#1332: hook types, raw hook input, init fields — @ya-luotao
Full Changelog: v1.2.1...v1.3.0
gem install claude-agent-sdk -v 1.3.0