Class: ClaudeAgentSDK::SandboxSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Sandbox settings for isolated command execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: nil, auto_allow_bash_if_sandboxed: nil, excluded_commands: nil, allow_unsandboxed_commands: nil, network: nil, ignore_violations: nil, enable_weaker_nested_sandbox: nil) ⇒ SandboxSettings

Returns a new instance of SandboxSettings.



709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
# File 'lib/claude_agent_sdk/types.rb', line 709

def initialize(
  enabled: nil,
  auto_allow_bash_if_sandboxed: nil,
  excluded_commands: nil,
  allow_unsandboxed_commands: nil,
  network: nil,
  ignore_violations: nil,
  enable_weaker_nested_sandbox: nil
)
  @enabled = enabled
  @auto_allow_bash_if_sandboxed = auto_allow_bash_if_sandboxed
  @excluded_commands = excluded_commands # Array of commands to exclude
  @allow_unsandboxed_commands = allow_unsandboxed_commands
  @network = network # SandboxNetworkConfig instance
  @ignore_violations = ignore_violations # SandboxIgnoreViolations instance
  @enable_weaker_nested_sandbox = enable_weaker_nested_sandbox
end

Instance Attribute Details

#allow_unsandboxed_commandsObject

Returns the value of attribute allow_unsandboxed_commands.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def allow_unsandboxed_commands
  @allow_unsandboxed_commands
end

#auto_allow_bash_if_sandboxedObject

Returns the value of attribute auto_allow_bash_if_sandboxed.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def auto_allow_bash_if_sandboxed
  @auto_allow_bash_if_sandboxed
end

#enable_weaker_nested_sandboxObject

Returns the value of attribute enable_weaker_nested_sandbox.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def enable_weaker_nested_sandbox
  @enable_weaker_nested_sandbox
end

#enabledObject

Returns the value of attribute enabled.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def enabled
  @enabled
end

#excluded_commandsObject

Returns the value of attribute excluded_commands.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def excluded_commands
  @excluded_commands
end

#ignore_violationsObject

Returns the value of attribute ignore_violations.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def ignore_violations
  @ignore_violations
end

#networkObject

Returns the value of attribute network.



705
706
707
# File 'lib/claude_agent_sdk/types.rb', line 705

def network
  @network
end

Instance Method Details

#to_hObject



727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File 'lib/claude_agent_sdk/types.rb', line 727

def to_h
  result = {}
  result[:enabled] = @enabled unless @enabled.nil?
  result[:autoAllowBashIfSandboxed] = @auto_allow_bash_if_sandboxed unless @auto_allow_bash_if_sandboxed.nil?
  result[:excludedCommands] = @excluded_commands if @excluded_commands
  result[:allowUnsandboxedCommands] = @allow_unsandboxed_commands unless @allow_unsandboxed_commands.nil?
  if @network
    result[:network] = @network.is_a?(SandboxNetworkConfig) ? @network.to_h : @network
  end
  if @ignore_violations
    result[:ignoreViolations] = @ignore_violations.is_a?(SandboxIgnoreViolations) ? @ignore_violations.to_h : @ignore_violations
  end
  result[:enableWeakerNestedSandbox] = @enable_weaker_nested_sandbox unless @enable_weaker_nested_sandbox.nil?
  result
end