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, fail_if_unavailable: nil, auto_allow_bash_if_sandboxed: nil, excluded_commands: nil, allow_unsandboxed_commands: nil, network: nil, filesystem: nil, ignore_violations: nil, enable_weaker_nested_sandbox: nil, enable_weaker_network_isolation: nil, ripgrep: nil) ⇒ SandboxSettings

Returns a new instance of SandboxSettings.



1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
# File 'lib/claude_agent_sdk/types.rb', line 1661

def initialize(
  enabled: nil,
  fail_if_unavailable: nil,
  auto_allow_bash_if_sandboxed: nil,
  excluded_commands: nil,
  allow_unsandboxed_commands: nil,
  network: nil,
  filesystem: nil,
  ignore_violations: nil,
  enable_weaker_nested_sandbox: nil,
  enable_weaker_network_isolation: nil,
  ripgrep: nil
)
  @enabled = enabled
  @fail_if_unavailable = fail_if_unavailable
  @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
  @filesystem = filesystem # SandboxFilesystemConfig instance
  @ignore_violations = ignore_violations # Hash of { category => [patterns] }
  @enable_weaker_nested_sandbox = enable_weaker_nested_sandbox
  @enable_weaker_network_isolation = enable_weaker_network_isolation # macOS only
  @ripgrep = ripgrep # Hash with :command and optional :args
end

Instance Attribute Details

#allow_unsandboxed_commandsObject

Returns the value of attribute allow_unsandboxed_commands.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def allow_unsandboxed_commands
  @allow_unsandboxed_commands
end

#auto_allow_bash_if_sandboxedObject

Returns the value of attribute auto_allow_bash_if_sandboxed.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

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.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def enable_weaker_nested_sandbox
  @enable_weaker_nested_sandbox
end

#enable_weaker_network_isolationObject

Returns the value of attribute enable_weaker_network_isolation.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def enable_weaker_network_isolation
  @enable_weaker_network_isolation
end

#enabledObject

Returns the value of attribute enabled.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def enabled
  @enabled
end

#excluded_commandsObject

Returns the value of attribute excluded_commands.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def excluded_commands
  @excluded_commands
end

#fail_if_unavailableObject

Returns the value of attribute fail_if_unavailable.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def fail_if_unavailable
  @fail_if_unavailable
end

#filesystemObject

Returns the value of attribute filesystem.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def filesystem
  @filesystem
end

#ignore_violationsObject

Returns the value of attribute ignore_violations.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def ignore_violations
  @ignore_violations
end

#networkObject

Returns the value of attribute network.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def network
  @network
end

#ripgrepObject

Returns the value of attribute ripgrep.



1656
1657
1658
# File 'lib/claude_agent_sdk/types.rb', line 1656

def ripgrep
  @ripgrep
end

Instance Method Details

#to_hObject



1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
# File 'lib/claude_agent_sdk/types.rb', line 1687

def to_h
  result = {}
  result[:enabled] = @enabled unless @enabled.nil?
  result[:failIfUnavailable] = @fail_if_unavailable unless @fail_if_unavailable.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?
  result[:network] = @network.is_a?(SandboxNetworkConfig) ? @network.to_h : @network if @network
  result[:filesystem] = @filesystem.is_a?(SandboxFilesystemConfig) ? @filesystem.to_h : @filesystem if @filesystem
  result[:ignoreViolations] = @ignore_violations if @ignore_violations
  result[:enableWeakerNestedSandbox] = @enable_weaker_nested_sandbox unless @enable_weaker_nested_sandbox.nil?
  result[:enableWeakerNetworkIsolation] = @enable_weaker_network_isolation unless @enable_weaker_network_isolation.nil?
  result[:ripgrep] = @ripgrep if @ripgrep
  result
end