Class: Ask::Sandbox::Daytona
Overview
Executes commands in a Daytona sandbox via the official daytona gem.
The daytona gem is loaded lazily (inside #call). If the gem is not installed, a clear LoadError is raised with installation instructions.
Instance Method Summary collapse
-
#call(command, timeout: @default_timeout, workdir: nil, env: {}, stdin: nil) ⇒ Ask::Sandbox::Result
Execute a command in the sandbox.
-
#initialize(api_key: nil, server_url: nil, image: nil, timeout: 120) ⇒ Daytona
constructor
A new instance of Daytona.
Constructor Details
#initialize(api_key: nil, server_url: nil, image: nil, timeout: 120) ⇒ Daytona
Returns a new instance of Daytona.
25 26 27 28 29 30 |
# File 'lib/ask/sandbox/daytona.rb', line 25 def initialize(api_key: nil, server_url: nil, image: nil, timeout: 120) @api_key = api_key @server_url = server_url @image = image @default_timeout = timeout end |
Instance Method Details
#call(command, timeout: @default_timeout, workdir: nil, env: {}, stdin: nil) ⇒ Ask::Sandbox::Result
Execute a command in the sandbox.
Lazily loads the daytona gem on first call.
35 36 37 38 39 40 41 42 |
# File 'lib/ask/sandbox/daytona.rb', line 35 def call(command, timeout: @default_timeout, workdir: nil, env: {}, stdin: nil) raise ArgumentError, "command must not be nil" if command.nil? raise ArgumentError, "command must not be empty" if command.respond_to?(:empty?) && command.empty? api_key = resolve_api_key ensure_daytona_gem! execute_on_daytona(command, api_key, timeout) end |