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.



718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/claude_agent_sdk/types.rb', line 718

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.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def allow_unsandboxed_commands
  @allow_unsandboxed_commands
end

#auto_allow_bash_if_sandboxedObject

Returns the value of attribute auto_allow_bash_if_sandboxed.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

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.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def enable_weaker_nested_sandbox
  @enable_weaker_nested_sandbox
end

#enabledObject

Returns the value of attribute enabled.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def enabled
  @enabled
end

#excluded_commandsObject

Returns the value of attribute excluded_commands.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def excluded_commands
  @excluded_commands
end

#ignore_violationsObject

Returns the value of attribute ignore_violations.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def ignore_violations
  @ignore_violations
end

#networkObject

Returns the value of attribute network.



714
715
716
# File 'lib/claude_agent_sdk/types.rb', line 714

def network
  @network
end

Instance Method Details

#to_hObject



736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File 'lib/claude_agent_sdk/types.rb', line 736

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