Class: Insika::Sandbox::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/insika/sandbox.rb

Overview

The per-agent sandbox environment: composes an FS boundary with an exec provider and the default limits. Delegates the boundary surface (resolve / relative / inside?) and adds exec. Immutable, safely shared across turns.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(boundary:, provider:, timeout:, max_output:) ⇒ Env

Returns a new instance of Env.



64
65
66
67
68
69
70
# File 'lib/insika/sandbox.rb', line 64

def initialize(boundary:, provider:, timeout:, max_output:)
  @boundary   = boundary
  @provider   = provider
  @root       = boundary.root
  @timeout    = timeout
  @max_output = max_output
end

Instance Attribute Details

#boundaryObject (readonly)

Returns the value of attribute boundary.



62
63
64
# File 'lib/insika/sandbox.rb', line 62

def boundary
  @boundary
end

#max_outputObject (readonly)

Returns the value of attribute max_output.



62
63
64
# File 'lib/insika/sandbox.rb', line 62

def max_output
  @max_output
end

#providerObject (readonly)

Returns the value of attribute provider.



62
63
64
# File 'lib/insika/sandbox.rb', line 62

def provider
  @provider
end

#rootObject (readonly)

Returns the value of attribute root.



62
63
64
# File 'lib/insika/sandbox.rb', line 62

def root
  @root
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



62
63
64
# File 'lib/insika/sandbox.rb', line 62

def timeout
  @timeout
end

Instance Method Details

#exec(command, timeout: @timeout, max_output: @max_output) ⇒ Object

--- command exec (via the provider) -> Result ---



78
79
80
# File 'lib/insika/sandbox.rb', line 78

def exec(command, timeout: @timeout, max_output: @max_output)
  @provider.exec(command, root: @root, timeout: timeout, max_output: max_output)
end

#inside?(abs) ⇒ Boolean

Returns:

  • (Boolean)


74
# File 'lib/insika/sandbox.rb', line 74

def inside?(abs) = @boundary.inside?(abs)

#relative(abs) ⇒ Object



75
# File 'lib/insika/sandbox.rb', line 75

def relative(abs) = @boundary.relative(abs)

#resolve(path, for_write: false) ⇒ Object

--- FS boundary (host-side, always on) ---



73
# File 'lib/insika/sandbox.rb', line 73

def resolve(path, for_write: false) = @boundary.resolve(path, for_write: for_write)

#to_sObject



82
# File 'lib/insika/sandbox.rb', line 82

def to_s = "Sandbox(#{@provider}, root=#{@root})"