claude-agent-sdk 0.17.0 → 0.18.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.
@@ -525,7 +525,16 @@ module ClaudeAgentSDK
525
525
 
526
526
  # Permission update configuration
527
527
  class PermissionUpdate < Type
528
- attr_accessor :type, :rules, :behavior, :mode, :directories, :destination
528
+ attr_accessor :type, :behavior, :mode, :directories, :destination
529
+ attr_reader :rules
530
+
531
+ # Wire-format parity with Python PermissionUpdate.from_dict (#920): the CLI
532
+ # sends rules as camelCase hashes ({toolName:, ruleContent:}); hydrate them
533
+ # into PermissionRuleValue (Type#assign_attribute normalizes the camelCase
534
+ # keys). Already-typed PermissionRuleValue entries pass through unchanged.
535
+ def rules=(value)
536
+ @rules = value&.map { |rule| rule.is_a?(Hash) ? PermissionRuleValue.new(rule) : rule }
537
+ end
529
538
 
530
539
  def to_h
531
540
  result = { type: @type }
@@ -888,6 +897,22 @@ module ClaudeAgentSDK
888
897
  end
889
898
  end
890
899
 
900
+ # Fallback for hook events the SDK does not yet model. Carries the wire
901
+ # event name and the complete raw payload so no fields are lost (Python
902
+ # passes hook input through as a raw dict, so unknown events lose
903
+ # nothing there).
904
+ class UnknownHookInput < BaseHookInput
905
+ attr_accessor :raw_input
906
+
907
+ def initialize(attributes = {})
908
+ super
909
+ # Direct assignment: BaseHookInput exposes hook_event_name as
910
+ # attr_reader only, and Type#assign_attribute silently drops keys
911
+ # without public setters.
912
+ @hook_event_name = attributes[:hook_event_name] || attributes['hook_event_name']
913
+ end
914
+ end
915
+
891
916
  # Setup hook specific output
892
917
  class SetupHookSpecificOutput < Type
893
918
  attr_accessor :additional_context
@@ -1480,10 +1505,10 @@ module ClaudeAgentSDK
1480
1505
  :model, :permission_prompt_tool_name, :cwd, :cli_path, :settings,
1481
1506
  :add_dirs, :env, :extra_args, :max_buffer_size, :stderr,
1482
1507
  :can_use_tool, :hooks, :user,
1483
- :agents, :setting_sources,
1508
+ :agents, :setting_sources, :skills,
1484
1509
  :output_format, :max_budget_usd, :max_thinking_tokens,
1485
1510
  :fallback_model, :plugins, :debug_stderr,
1486
- :betas, :tools, :sandbox, :append_allowed_tools,
1511
+ :betas, :tools, :sandbox,
1487
1512
  :thinking, :effort, :observers, :task_budget,
1488
1513
  :session_store, :session_store_flush, :load_timeout_ms
1489
1514
  attr_reader :bare, :fork_session, :enable_file_checkpointing,
@@ -1596,8 +1621,11 @@ module ClaudeAgentSDK
1596
1621
  defaults = ClaudeAgentSDK.default_options
1597
1622
  return attributes unless defaults.any?
1598
1623
 
1599
- # Start from configured defaults (deep dup hashes to prevent mutation)
1600
- result = defaults.transform_values { |v| v.is_a?(Hash) ? v.dup : v }
1624
+ # Start from configured defaults. Container values are recursively
1625
+ # duped so per-instance mutation (options.allowed_tools << 'Bash')
1626
+ # can never corrupt the global defaults; non-container leaves
1627
+ # (Strings, Procs, SdkMcpServer instances) intentionally keep identity.
1628
+ result = deep_dup_containers(defaults)
1601
1629
  attributes.each do |key, value|
1602
1630
  default_val = result[key]
1603
1631
  result[key] = if value.nil?
@@ -1610,6 +1638,16 @@ module ClaudeAgentSDK
1610
1638
  end
1611
1639
  result
1612
1640
  end
1641
+
1642
+ # Recurse ONLY into Hash/Array; leaves keep object identity (observer
1643
+ # factories, callbacks, SDK MCP server instances must not be duped).
1644
+ def deep_dup_containers(value)
1645
+ case value
1646
+ when Hash then value.to_h { |k, v| [k, deep_dup_containers(v)] }
1647
+ when Array then value.map { |v| deep_dup_containers(v) }
1648
+ else value
1649
+ end
1650
+ end
1613
1651
  end
1614
1652
 
1615
1653
  # SDK MCP Tool definition
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end