claude-agent-sdk 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -128,12 +128,23 @@ module ClaudeAgentSDK
128
128
  end
129
129
  end
130
130
 
131
- # Init system message (emitted at session start and after /clear)
131
+ # Init system message (emitted at session start and after /clear).
132
+ #
133
+ # `capabilities` lists the protocol features the CLI supports (e.g.
134
+ # "interrupt_receipt_v1"; an open set, absent before CLI 2.1.205): test it
135
+ # for a feature instead of comparing `claude_code_version`.
136
+ # `plugin_errors` lists plugins that failed to load (`{ plugin:, type:,
137
+ # message:, path: }`; the CLI omits it when none failed, and older CLIs never
138
+ # send it). `terminal_slash_commands` are the entries of `slash_commands`
139
+ # bound to the local terminal (e.g. "exit"), sent only when there are some.
140
+ # `fast_mode_disabled_reason` names the check that keeps fast mode off.
132
141
  class InitMessage < SystemMessage
133
142
  attr_accessor :uuid, :session_id, :agents, :api_key_source, :betas,
134
143
  :claude_code_version, :cwd, :tools, :mcp_servers, :model,
135
- :permission_mode, :slash_commands, :output_style, :skills, :plugins,
136
- :fast_mode_state # "off", "cooldown", or "on"
144
+ :permission_mode, :slash_commands, :terminal_slash_commands,
145
+ :output_style, :skills, :plugins, :plugin_errors,
146
+ :fast_mode_state, # "off", "cooldown", or "on"
147
+ :fast_mode_disabled_reason, :capabilities
137
148
  end
138
149
 
139
150
  # Compact boundary system message (emitted after context compaction completes)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  end
@@ -46,7 +46,7 @@ module ClaudeAgentSDK
46
46
  2. Provide credentials to the CLI, e.g. ANTHROPIC_API_KEY in the environment.
47
47
  3. Review config/initializers/claude_agent_sdk.rb.
48
48
 
49
- Rails guide: https://github.com/ya-luotao/claude-agent-sdk-ruby/blob/main/docs/rails.md
49
+ Rails guide: https://github.com/rubycatco/claude-agent-sdk-ruby/blob/main/docs/rails.md
50
50
  MSG
51
51
  end
52
52
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Claude Agent SDK defaults, merged into every ClaudeAgentSDK.query and
4
4
  # ClaudeAgentSDK::Client session; per-call ClaudeAgentOptions override them.
5
- # Guide: https://github.com/ya-luotao/claude-agent-sdk-ruby/blob/main/docs/rails.md
5
+ # Guide: https://github.com/rubycatco/claude-agent-sdk-ruby/blob/main/docs/rails.md
6
6
 
7
7
  # Uncomment together with `observers:` below (needs the opentelemetry-sdk gem).
8
8
  # require 'claude_agent_sdk/instrumentation'
@@ -31,6 +31,12 @@ module ClaudeAgentSDK
31
31
  | InstructionsLoadedHookInput
32
32
  | CwdChangedHookInput
33
33
  | FileChangedHookInput
34
+ | PostToolBatchHookInput
35
+ | UserPromptExpansionHookInput
36
+ | PreModelSwitchHookInput
37
+ | PostModelSwitchHookInput
38
+ | DirectoryAddedHookInput
39
+ | MessageDisplayHookInput
34
40
  | UnknownHookInput
35
41
 
36
42
  # A *HookSpecificOutput (SyncHookJSONOutput#hook_specific_output).
@@ -46,6 +52,16 @@ module ClaudeAgentSDK
46
52
  | PermissionDeniedHookSpecificOutput
47
53
  | CwdChangedHookSpecificOutput
48
54
  | FileChangedHookSpecificOutput
55
+ | PostToolBatchHookSpecificOutput
56
+ | UserPromptExpansionHookSpecificOutput
57
+ | StopHookSpecificOutput
58
+ | SubagentStopHookSpecificOutput
59
+ | PreModelSwitchHookSpecificOutput
60
+ | PostModelSwitchHookSpecificOutput
61
+ | ElicitationHookSpecificOutput
62
+ | ElicitationResultHookSpecificOutput
63
+ | WorktreeCreateHookSpecificOutput
64
+ | MessageDisplayHookSpecificOutput
49
65
 
50
66
  # What a hook callback returns: a Hash (Symbol or String keys, snake_case
51
67
  # or camelCase, also inside hook_specific_output), a typed output, or nil
@@ -91,6 +107,18 @@ module ClaudeAgentSDK
91
107
 
92
108
  attr_accessor permission_mode: String?
93
109
 
110
+ # UUID of the user prompt being processed (the prompt.id of the CLI's
111
+ # OpenTelemetry events); nil before the first prompt.
112
+ attr_accessor prompt_id: String?
113
+
114
+ # Reasoning effort in effect for the turn, e.g. { level: "high" }; sent
115
+ # on models that support effort.
116
+ attr_accessor effort: wire_hash?
117
+
118
+ # The payload exactly as the CLI sent it (Symbol keys), including fields
119
+ # this SDK does not model.
120
+ attr_accessor raw_input: Hash[Symbol | String, untyped]?
121
+
94
122
  # The event name, fixed by the subclass (read-only).
95
123
  attr_reader hook_event_name: String?
96
124
  end
@@ -119,10 +147,17 @@ module ClaudeAgentSDK
119
147
  attr_accessor agent_id: String?
120
148
 
121
149
  attr_accessor agent_type: String?
150
+
151
+ # Tool execution time, without permission prompts and hooks.
152
+ attr_accessor duration_ms: Integer?
122
153
  end
123
154
 
124
155
  class UserPromptSubmitHookInput < BaseHookInput
125
156
  attr_accessor prompt: String?
157
+
158
+ attr_accessor session_title: String?
159
+
160
+ attr_accessor source: String?
126
161
  end
127
162
 
128
163
  class StopHookInput < BaseHookInput
@@ -165,6 +200,9 @@ module ClaudeAgentSDK
165
200
  attr_accessor agent_id: String?
166
201
 
167
202
  attr_accessor agent_type: String?
203
+
204
+ # Tool execution time, without permission prompts and hooks.
205
+ attr_accessor duration_ms: Integer?
168
206
  end
169
207
 
170
208
  class NotificationHookInput < BaseHookInput
@@ -205,6 +243,18 @@ module ClaudeAgentSDK
205
243
  attr_accessor agent_type: String?
206
244
 
207
245
  attr_accessor model: String?
246
+
247
+ attr_accessor session_title: String?
248
+
249
+ # resume/fork: seconds since the transcript's last assistant response.
250
+ attr_accessor seconds_since_last_response: Numeric?
251
+
252
+ # resume/fork: whether that exceeds the prompt-cache TTL.
253
+ attr_accessor prompt_cache_likely_expired: bool?
254
+
255
+ attr_accessor context_tokens: Integer?
256
+
257
+ attr_accessor estimated_cache_write_usd: Numeric?
208
258
  end
209
259
 
210
260
  class SessionEndHookInput < BaseHookInput
@@ -325,6 +375,8 @@ module ClaudeAgentSDK
325
375
  attr_accessor globs: Array[String]?
326
376
 
327
377
  attr_accessor trigger_file_path: String?
378
+
379
+ attr_accessor parent_file_path: String?
328
380
  end
329
381
 
330
382
  class CwdChangedHookInput < BaseHookInput
@@ -339,8 +391,90 @@ module ClaudeAgentSDK
339
391
  attr_accessor event: String?
340
392
  end
341
393
 
394
+ class PostToolBatchHookInput < BaseHookInput
395
+ # { tool_name:, tool_input:, tool_use_id:, tool_response: } wire_hashes.
396
+ attr_accessor tool_calls: Array[wire_hash]?
397
+ end
398
+
399
+ class UserPromptExpansionHookInput < BaseHookInput
400
+ # "slash_command" or "mcp_prompt".
401
+ attr_accessor expansion_type: String?
402
+
403
+ attr_accessor command_name: String?
404
+
405
+ attr_accessor command_args: String?
406
+
407
+ attr_accessor command_source: String?
408
+
409
+ attr_accessor prompt: String?
410
+ end
411
+
412
+ class PreModelSwitchHookInput < BaseHookInput
413
+ attr_accessor from_model: String?
414
+
415
+ attr_accessor to_model: String?
416
+
417
+ # An alias, a full id, or nil for the default.
418
+ attr_accessor requested_model: String?
419
+
420
+ attr_accessor source: String?
421
+
422
+ attr_accessor context_tokens: Integer?
423
+
424
+ attr_accessor prompt_cache_warm: bool?
425
+
426
+ # "5m" or "1h".
427
+ attr_accessor cache_ttl: String?
428
+
429
+ attr_accessor estimated_cache_write_usd: Numeric?
430
+
431
+ # The rate the estimate used: "configured", "catalog" or "default".
432
+ attr_accessor pricing: String?
433
+ end
434
+
435
+ class PostModelSwitchHookInput < BaseHookInput
436
+ attr_accessor from_model: String?
437
+
438
+ attr_accessor to_model: String?
439
+
440
+ # An alias, a full id, or nil for the default.
441
+ attr_accessor requested_model: String?
442
+
443
+ attr_accessor source: String?
444
+
445
+ attr_accessor context_tokens: Integer?
446
+
447
+ attr_accessor prompt_cache_warm: bool?
448
+
449
+ # "5m" or "1h".
450
+ attr_accessor cache_ttl: String?
451
+
452
+ attr_accessor estimated_cache_write_usd: Numeric?
453
+
454
+ # The rate the estimate used: "configured", "catalog" or "default".
455
+ attr_accessor pricing: String?
456
+ end
457
+
458
+ class DirectoryAddedHookInput < BaseHookInput
459
+ attr_accessor directory: String?
460
+
461
+ # "slash_command" or "register_repo_root".
462
+ attr_accessor source: String?
463
+ end
464
+
465
+ class MessageDisplayHookInput < BaseHookInput
466
+ attr_accessor turn_id: String?
467
+
468
+ attr_accessor message_id: String?
469
+
470
+ attr_accessor index: Integer?
471
+
472
+ attr_accessor final: bool?
473
+
474
+ attr_accessor delta: String?
475
+ end
476
+
342
477
  class UnknownHookInput < BaseHookInput
343
- attr_accessor raw_input: Hash[Symbol | String, untyped]?
344
478
  end
345
479
 
346
480
  # Hook outputs are built by the caller: keyword constructors (the Hash
@@ -402,11 +536,16 @@ module ClaudeAgentSDK
402
536
  end
403
537
 
404
538
  class UserPromptSubmitHookSpecificOutput < Type
405
- def initialize: (?additional_context: String?) -> void
539
+ def initialize: (?additional_context: String?, ?session_title: String?, ?suppress_original_prompt: bool?) -> void
406
540
  | (Hash[Symbol | String, untyped]? attributes) -> void
407
541
 
408
542
  attr_accessor additional_context: String?
409
543
 
544
+ attr_accessor session_title: String?
545
+
546
+ # With decision "block": leave the prompt out of the block message.
547
+ attr_accessor suppress_original_prompt: bool?
548
+
410
549
  attr_reader hook_event_name: String
411
550
 
412
551
  def to_h: () -> Hash[Symbol, untyped]
@@ -446,11 +585,23 @@ module ClaudeAgentSDK
446
585
  end
447
586
 
448
587
  class SessionStartHookSpecificOutput < Type
449
- def initialize: (?additional_context: String?) -> void
588
+ def initialize: (?additional_context: String?, ?initial_user_message: String?, ?session_title: String?, ?watch_paths: Array[String]?, ?reload_skills: bool?) -> void
450
589
  | (Hash[Symbol | String, untyped]? attributes) -> void
451
590
 
452
591
  attr_accessor additional_context: String?
453
592
 
593
+ # Becomes the session's first user message.
594
+ attr_accessor initial_user_message: String?
595
+
596
+ # Ignored when the session starts from "clear" or "compact".
597
+ attr_accessor session_title: String?
598
+
599
+ # Absolute paths to watch for FileChanged events.
600
+ attr_accessor watch_paths: Array[String]?
601
+
602
+ # Re-scan skill and command directories once SessionStart hooks finish.
603
+ attr_accessor reload_skills: bool?
604
+
454
605
  attr_reader hook_event_name: String
455
606
 
456
607
  def to_h: () -> Hash[Symbol, untyped]
@@ -460,6 +611,7 @@ module ClaudeAgentSDK
460
611
  def initialize: (?retry: bool?) -> void
461
612
  | (Hash[Symbol | String, untyped]? attributes) -> void
462
613
 
614
+ # nil (the default) sends no key, which the CLI reads as false.
463
615
  attr_accessor retry: bool?
464
616
 
465
617
  attr_reader hook_event_name: String
@@ -489,6 +641,137 @@ module ClaudeAgentSDK
489
641
  def to_h: () -> Hash[Symbol, untyped]
490
642
  end
491
643
 
644
+ class PostToolBatchHookSpecificOutput < Type
645
+ def initialize: (?additional_context: String?) -> void
646
+ | (Hash[Symbol | String, untyped]? attributes) -> void
647
+
648
+ attr_accessor additional_context: String?
649
+
650
+ attr_reader hook_event_name: String
651
+
652
+ def to_h: () -> Hash[Symbol, untyped]
653
+ end
654
+
655
+ class UserPromptExpansionHookSpecificOutput < Type
656
+ def initialize: (?additional_context: String?, ?suppress_original_prompt: bool?) -> void
657
+ | (Hash[Symbol | String, untyped]? attributes) -> void
658
+
659
+ attr_accessor additional_context: String?
660
+
661
+ # With decision "block": leave the prompt out of the block message.
662
+ attr_accessor suppress_original_prompt: bool?
663
+
664
+ attr_reader hook_event_name: String
665
+
666
+ def to_h: () -> Hash[Symbol, untyped]
667
+ end
668
+
669
+ # additional_context is feedback for the model; the conversation continues.
670
+ class StopHookSpecificOutput < Type
671
+ def initialize: (?additional_context: String?) -> void
672
+ | (Hash[Symbol | String, untyped]? attributes) -> void
673
+
674
+ attr_accessor additional_context: String?
675
+
676
+ attr_reader hook_event_name: String
677
+
678
+ def to_h: () -> Hash[Symbol, untyped]
679
+ end
680
+
681
+ # additional_context is feedback for the subagent; it continues.
682
+ class SubagentStopHookSpecificOutput < Type
683
+ def initialize: (?additional_context: String?) -> void
684
+ | (Hash[Symbol | String, untyped]? attributes) -> void
685
+
686
+ attr_accessor additional_context: String?
687
+
688
+ attr_reader hook_event_name: String
689
+
690
+ def to_h: () -> Hash[Symbol, untyped]
691
+ end
692
+
693
+ class PreModelSwitchHookSpecificOutput < Type
694
+ def initialize: (?permission_decision: String?, ?permission_decision_reason: String?) -> void
695
+ | (Hash[Symbol | String, untyped]? attributes) -> void
696
+
697
+ # "allow" proceeds, "deny" cancels; "ask" refuses outside an interactive session.
698
+ attr_accessor permission_decision: String?
699
+
700
+ attr_accessor permission_decision_reason: String?
701
+
702
+ attr_reader hook_event_name: String
703
+
704
+ def to_h: () -> Hash[Symbol, untyped]
705
+ end
706
+
707
+ class PostModelSwitchHookSpecificOutput < Type
708
+ def initialize: (?additional_context: String?) -> void
709
+ | (Hash[Symbol | String, untyped]? attributes) -> void
710
+
711
+ # Reaches the model with the next request the new model serves.
712
+ attr_accessor additional_context: String?
713
+
714
+ attr_reader hook_event_name: String
715
+
716
+ def to_h: () -> Hash[Symbol, untyped]
717
+ end
718
+
719
+ # Answers an MCP elicitation request.
720
+ class ElicitationHookSpecificOutput < Type
721
+ def initialize: (?action: String?, ?content: Hash[Symbol | String, untyped]?) -> void
722
+ | (Hash[Symbol | String, untyped]? attributes) -> void
723
+
724
+ # "accept", "decline" or "cancel".
725
+ attr_accessor action: String?
726
+
727
+ # Form values to submit with "accept".
728
+ attr_accessor content: Hash[Symbol | String, untyped]?
729
+
730
+ attr_reader hook_event_name: String
731
+
732
+ def to_h: () -> Hash[Symbol, untyped]
733
+ end
734
+
735
+ # Overrides the action or content before the response reaches the MCP server.
736
+ class ElicitationResultHookSpecificOutput < Type
737
+ def initialize: (?action: String?, ?content: Hash[Symbol | String, untyped]?) -> void
738
+ | (Hash[Symbol | String, untyped]? attributes) -> void
739
+
740
+ # "accept", "decline" or "cancel".
741
+ attr_accessor action: String?
742
+
743
+ attr_accessor content: Hash[Symbol | String, untyped]?
744
+
745
+ attr_reader hook_event_name: String
746
+
747
+ def to_h: () -> Hash[Symbol, untyped]
748
+ end
749
+
750
+ class WorktreeCreateHookSpecificOutput < Type
751
+ def initialize: (?worktree_path: String?) -> void
752
+ | (Hash[Symbol | String, untyped]? attributes) -> void
753
+
754
+ # Absolute path of the created worktree.
755
+ attr_accessor worktree_path: String?
756
+
757
+ attr_reader hook_event_name: String
758
+
759
+ def to_h: () -> Hash[Symbol, untyped]
760
+ end
761
+
762
+ # Display only: the stored message and what the model sees are unchanged.
763
+ class MessageDisplayHookSpecificOutput < Type
764
+ def initialize: (?display_content: String?) -> void
765
+ | (Hash[Symbol | String, untyped]? attributes) -> void
766
+
767
+ # Shown in place of the text; nil shows the original.
768
+ attr_accessor display_content: String?
769
+
770
+ attr_reader hook_event_name: String
771
+
772
+ def to_h: () -> Hash[Symbol, untyped]
773
+ end
774
+
492
775
  # Defers the hook's decision (async: true by default).
493
776
  class AsyncHookJSONOutput < Type
494
777
  def initialize: (?async: bool?, ?async_timeout: Integer?) -> void
@@ -106,6 +106,10 @@ module ClaudeAgentSDK
106
106
 
107
107
  attr_accessor slash_commands: Array[String]?
108
108
 
109
+ # The entries of slash_commands bound to the local terminal (e.g. "exit");
110
+ # sent only when there are some.
111
+ attr_accessor terminal_slash_commands: Array[String]?
112
+
109
113
  attr_accessor output_style: String?
110
114
 
111
115
  attr_accessor skills: Array[String]?
@@ -113,8 +117,19 @@ module ClaudeAgentSDK
113
117
  # { name:, path: } wire_hashes.
114
118
  attr_accessor plugins: Array[wire_hash]?
115
119
 
120
+ # Plugins that failed to load: { plugin:, type:, message:, path: }
121
+ # wire_hashes. Omitted when none failed (and by older CLIs).
122
+ attr_accessor plugin_errors: Array[wire_hash]?
123
+
116
124
  # "off", "cooldown" or "on".
117
125
  attr_accessor fast_mode_state: String?
126
+
127
+ # The check that keeps fast mode off (e.g. "not_first_party"); an open set.
128
+ attr_accessor fast_mode_disabled_reason: String?
129
+
130
+ # Protocol features the CLI supports (e.g. "interrupt_receipt_v1"); an
131
+ # open set, absent before CLI 2.1.205.
132
+ attr_accessor capabilities: Array[String]?
118
133
  end
119
134
 
120
135
  # Emitted after context compaction completes.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude-agent-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ya-luotao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-06 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -201,13 +201,13 @@ files:
201
201
  - sig/claude_agent_sdk/types/permissions.rbs
202
202
  - sig/claude_agent_sdk/types/sessions.rbs
203
203
  - sig/manifest.yaml
204
- homepage: https://github.com/ya-luotao/claude-agent-sdk-ruby
204
+ homepage: https://github.com/rubycatco/claude-agent-sdk-ruby
205
205
  licenses:
206
206
  - MIT
207
207
  metadata:
208
- homepage_uri: https://github.com/ya-luotao/claude-agent-sdk-ruby
209
- source_code_uri: https://github.com/ya-luotao/claude-agent-sdk-ruby
210
- changelog_uri: https://github.com/ya-luotao/claude-agent-sdk-ruby/blob/main/CHANGELOG.md
208
+ homepage_uri: https://github.com/rubycatco/claude-agent-sdk-ruby
209
+ source_code_uri: https://github.com/rubycatco/claude-agent-sdk-ruby
210
+ changelog_uri: https://github.com/rubycatco/claude-agent-sdk-ruby/blob/main/CHANGELOG.md
211
211
  documentation_uri: https://rubydoc.info/gems/claude-agent-sdk
212
212
  allowed_push_host: https://rubygems.org
213
213
  post_install_message: