sandbox

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound       = errors.New("sandbox: session not found")
	ErrSessionExists         = errors.New("sandbox: session already exists")
	ErrSessionPaused         = errors.New("sandbox: session is paused")
	ErrSessionDestroying     = errors.New("sandbox: session is destroying")
	ErrProcessNotFound       = errors.New("sandbox: process not found")
	ErrRollbackInProgress    = errors.New("sandbox: rollback in progress")
	ErrInvalidState          = errors.New("sandbox: invalid session state")
	ErrMaxSessionsReached    = errors.New("sandbox: max sessions reached")
	ErrToolsInFlight         = errors.New("sandbox: tools in flight")
	ErrSnapshotsNotAvailable = errors.New("sandbox: snapshots not available (requires ZFS storage backend)")
)

Functions

func ValidateSessionID

func ValidateSessionID(sessionID string) error

ValidateSessionID validates session ids used in filesystem-backed storage.

Types

type ContainerRuntime

type ContainerRuntime string

ContainerRuntime identifies the runtime for Tier 2 tool execution.

const (
	ContainerRuntimeGVisor ContainerRuntime = "gvisor"
	ContainerRuntimeNone   ContainerRuntime = "none"
)

type CreateSessionRequest

type CreateSessionRequest struct {
	BaseSnapshot string
	SessionID    string
	Quota        int64
	Labels       map[string]string
}

type ExecuteToolRequest

type ExecuteToolRequest struct {
	SessionID  string
	ToolName   string
	ToolCallID string
	Params     map[string]any
	Resources  *gvisor.ResourceSpec
	OnProgress func(content string, isError bool)
}

type ExecuteToolResponse

type ExecuteToolResponse struct {
	Content       string
	ContentBlocks []ai.ContentBlock
	ExitCode      *int
	SnapshotID    string
	Duration      time.Duration
	Tier          int
}

type GetProcessStatusRequest

type GetProcessStatusRequest struct {
	SessionID string
	ProcessID string
}

type GetProcessStatusResponse

type GetProcessStatusResponse struct {
	Status   ProcessStatus
	ExitCode *int
}

type HealthStatus

type HealthStatus struct {
	Status       string
	PoolState    zfs.PoolState
	PoolSpace    zfs.PoolSpace
	SessionCount int
	ActiveTools  int
	Uptime       time.Duration
	Errors       []string
}

type KillProcessRequest

type KillProcessRequest struct {
	SessionID string
	ProcessID string
	Signal    int
}

type LaunchProcessRequest

type LaunchProcessRequest struct {
	SessionID  string
	Binary     string
	Args       []string
	Env        map[string]string
	ExposePort int
}

type LaunchProcessResponse

type LaunchProcessResponse struct {
	ProcessID string
	Address   string
	Status    ProcessStatus
}

type ManagedProcess

type ManagedProcess struct {
	// contains filtered or unexported fields
}

type ProcessStatus

type ProcessStatus string
const (
	ProcessStatusStarting ProcessStatus = "starting"
	ProcessStatusRunning  ProcessStatus = "running"
	ProcessStatusExited   ProcessStatus = "exited"
)

type SandboxHostService

type SandboxHostService struct {
	// contains filtered or unexported fields
}

func NewSandboxHostService

func NewSandboxHostService(cfg ServiceConfig, z zfs.ZFSManager, g gvisor.GVisorManager, logger *slog.Logger) (*SandboxHostService, error)

func (*SandboxHostService) Capabilities

func (svc *SandboxHostService) Capabilities() environment.Capabilities

Capabilities returns host capabilities derived from configured backends.

func (*SandboxHostService) CreateSession

func (svc *SandboxHostService) CreateSession(ctx context.Context, req CreateSessionRequest) (*SessionInfo, error)

func (*SandboxHostService) CreateSnapshot

func (svc *SandboxHostService) CreateSnapshot(ctx context.Context, sessionID string, name string) (*SnapshotResult, error)

func (*SandboxHostService) DestroySession

func (svc *SandboxHostService) DestroySession(ctx context.Context, sessionID string) error

func (*SandboxHostService) ExecuteTool

func (*SandboxHostService) GetProcessStatus

func (*SandboxHostService) GetSession

func (svc *SandboxHostService) GetSession(_ context.Context, sessionID string) (*SessionInfo, error)

func (*SandboxHostService) HealthCheck

func (svc *SandboxHostService) HealthCheck(ctx context.Context) (*HealthStatus, error)

func (*SandboxHostService) KillProcess

func (svc *SandboxHostService) KillProcess(_ context.Context, req KillProcessRequest) error

func (*SandboxHostService) LaunchProcess

func (*SandboxHostService) ListSessions

func (svc *SandboxHostService) ListSessions(_ context.Context) ([]SessionInfo, error)

func (*SandboxHostService) ListSnapshots

func (svc *SandboxHostService) ListSnapshots(ctx context.Context, sessionID string) ([]zfs.SnapshotInfo, error)

func (*SandboxHostService) PauseSession

func (svc *SandboxHostService) PauseSession(ctx context.Context, sessionID string) error

func (*SandboxHostService) ResumeSession

func (svc *SandboxHostService) ResumeSession(_ context.Context, sessionID string) error

func (*SandboxHostService) RollbackSession

func (svc *SandboxHostService) RollbackSession(ctx context.Context, sessionID string, snapshotID string) error

func (*SandboxHostService) Shutdown

func (svc *SandboxHostService) Shutdown(ctx context.Context) error

func (*SandboxHostService) Start

func (svc *SandboxHostService) Start(ctx context.Context)

func (*SandboxHostService) TurnComplete

func (svc *SandboxHostService) TurnComplete(ctx context.Context, sessionID string) (*SnapshotResult, error)

type ServiceConfig

type ServiceConfig struct {
	StorageBackend   StorageBackend
	ContainerRuntime ContainerRuntime

	AdvertiseAddr string

	PoolName               string
	BasesDataset           string
	SessionsDataset        string
	SessionsRootDir        string
	MaxSessions            int
	DefaultSessionQuota    int64
	SnapshotPrefix         string
	MaxSnapshotsPerSession int
	DefaultResources       gvisor.ResourceSpec
	ToolTimeout            time.Duration
	PoolSpaceWarnThreshold float64
	PoolSpaceCritThreshold float64
	HealthCheckInterval    time.Duration
	PauseDrainTimeout      time.Duration
	ShutdownTimeout        time.Duration
	PerToolSnapshots       bool
}

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) Info

func (s *Session) Info() SessionInfo

type SessionInfo

type SessionInfo struct {
	ID         string
	State      SessionState
	Mountpoint string
	TurnCount  int
	SnapCount  int
	Created    time.Time
	Labels     map[string]string
	SpaceUsed  int64
}

type SessionState

type SessionState string
const (
	SessionCreating   SessionState = "creating"
	SessionActive     SessionState = "active"
	SessionPaused     SessionState = "paused"
	SessionDestroying SessionState = "destroying"
	SessionFailed     SessionState = "failed"
)

type SnapshotEntry

type SnapshotEntry struct {
	Name           string
	IsTurnSnapshot bool
}

type SnapshotResult

type SnapshotResult struct {
	SnapshotID string
	TurnNumber int
	SpaceUsed  int64
}

type StorageBackend

type StorageBackend string

StorageBackend identifies the session storage mechanism.

const (
	StorageBackendZFS       StorageBackend = "zfs"
	StorageBackendLocalDisk StorageBackend = "local-disk"
)

Directories

Path Synopsis
Package control defines the SandboxControl interface for orchestrator-level sandbox lifecycle management.
Package control defines the SandboxControl interface for orchestrator-level sandbox lifecycle management.
cloud
Package cloud provides placeholder stubs for cloud-based SandboxControl providers (E2B, Daytona, Fly).
Package cloud provides placeholder stubs for cloud-based SandboxControl providers (E2B, Daytona, Fly).
direct
Package direct implements DirectSandboxControl, which manages raw EC2 instances as agent execution environments.
Package direct implements DirectSandboxControl, which manages raw EC2 instances as agent execution environments.
fleet
Package fleet implements FleetSandboxControl, a SandboxControl adapter that manages a fleet of sandbox-host instances with auto-scaling, health monitoring, warm pool maintenance, and capacity-aware routing.
Package fleet implements FleetSandboxControl, a SandboxControl adapter that manages a fleet of sandbox-host instances with auto-scaling, health monitoring, warm pool maintenance, and capacity-aware routing.
fleet/ec2
Package ec2 implements the instance.InstanceProvisioner interface using the AWS EC2 API (SDK v2).
Package ec2 implements the instance.InstanceProvisioner interface using the AWS EC2 API (SDK v2).
instance
Package instance defines the InstanceProvisioner interface and associated types for cloud instance lifecycle management.
Package instance defines the InstanceProvisioner interface and associated types for cloud instance lifecycle management.
node
Package node implements NodeSandboxControl, which wraps our sandbox-host RPC service to satisfy the SandboxControl interface.
Package node implements NodeSandboxControl, which wraps our sandbox-host RPC service to satisfy the SandboxControl interface.
e2b
fly
restapi
Package restapi provides shared HTTP/JSON helpers for remote ExecutionEnvironment providers (E2B, Daytona, Fly).
Package restapi provides shared HTTP/JSON helpers for remote ExecutionEnvironment providers (E2B, Daytona, Fly).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL