Class: KairosMcp::Daemon::RestrictedShell::SandboxContext

Inherits:
Object
  • Object
show all
Defined in:
lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb

Overview

SandboxContext — holds sandbox-wrapped command + cleanup handle.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd:, driver: :none, tmpdir: nil) ⇒ SandboxContext

Returns a new instance of SandboxContext.



12
13
14
15
16
# File 'lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb', line 12

def initialize(cmd:, driver: :none, tmpdir: nil)
  @cmd = cmd
  @driver = driver
  @tmpdir = tmpdir
end

Instance Attribute Details

#cmdObject (readonly)

Returns the value of attribute cmd.



10
11
12
# File 'lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb', line 10

def cmd
  @cmd
end

#driverObject (readonly)

Returns the value of attribute driver.



10
11
12
# File 'lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb', line 10

def driver
  @driver
end

Instance Method Details

#cleanup!Object



18
19
20
21
22
# File 'lib/kairos_mcp/daemon/restricted_shell/sandbox_context.rb', line 18

def cleanup!
  FileUtils.rm_rf(@tmpdir) if @tmpdir && Dir.exist?(@tmpdir)
rescue StandardError
  # best-effort
end