Installation
Reuse or create a sandbox
Microsandbox::Sandbox.connect_or_create()
Sandbox.create when name conflicts must remain an error, or explicit replace options when the old identity should be discarded.
SandboxBuilder
builder.connect_or_create()
Microsandbox::Sandbox.connect_or_create.
Sandbox
A live sandbox connection returned bycreate, connect_or_create, start, connect_or_start, or restart.
sandbox.id
sandbox.wait_for_status()
created, starting, running, draining, paused, stopped, or crashed. Returns a refreshed metadata handle. Use Ruby’s Timeout.timeout or an application cancellation mechanism when a deadline is required.
sandbox.stop()
Microsandbox::Error without cancelling the accepted server-side stop, which may still complete afterward. Pass timeout: in seconds to change the observation deadline.
sandbox.restart()
force: true to kill, timeout: in seconds to change how long shutdown can take, or detached: true for a local background start.
On microsandbox cloud, graceful restart is supported, but timeout expiry cannot escalate to force kill. force: true is local-only, and detached: affects only local process ownership.
sandbox.destroy()
SandboxHandle
Obtain a metadata handle without opening the guest-agent connection:handle.id
handle.connect_or_start()
starting, or start it when it is created, stopped, or crashed. draining and paused are rejected. detached: true affects only a required local start; connecting to an already-running sandbox does not change ownership.
handle.wait_for_status()
status, returning a refreshed handle. The method does not have a built-in timeout.
handle.stop()
Sandbox#stop.
handle.restart()
Sandbox#restart.
handle.destroy()
Identity errors
Ruby currently surfaces stale identity protection throughMicrosandbox::Error. The message includes was replaced; unlike Rust, TypeScript, Python, and Go, the Ruby SDK does not yet expose a dedicated SandboxReplacedError subclass.
Live lifecycle example
Runruby examples/lifecycle_convergence.rb from sdk/ruby to exercise sandbox creation and reuse, stable identity, connect, wait, exec, restart, destroy, same-name replacement, and stale-handle rejection against a live microVM.