environment

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCapabilityNotSupported = errors.New("capability not supported by environment")
	ErrSessionNotFound        = errors.New("environment: session not found")
	ErrNotActive              = errors.New("environment not in active state")
	ErrUnavailable            = errors.New("environment unavailable")
	ErrSessionLimitReached    = errors.New("session limit reached")
)
View Source
var DaytonaCapabilities = Capabilities{
	Snapshots:         false,
	Rollback:          false,
	Pause:             false,
	TierRouting:       false,
	StreamingProgress: true,
}
View Source
var E2BCapabilities = Capabilities{
	Snapshots:          false,
	Rollback:           false,
	Pause:              true,
	TierRouting:        false,
	StreamingProgress:  true,
	MaxSessionDuration: 24 * time.Hour,
}
View Source
var FlyCapabilities = Capabilities{
	Snapshots:         false,
	Rollback:          false,
	Pause:             true,
	TierRouting:       false,
	StreamingProgress: false,
}
View Source
var LocalCapabilities = Capabilities{
	Snapshots:         false,
	Rollback:          false,
	Pause:             true,
	TierRouting:       false,
	StreamingProgress: true,
}

Functions

func IsFileOp

func IsFileOp(toolName string) bool

IsFileOp returns true for tool names that operate on the filesystem (read, write, edit, grep, glob) and should be dispatched via the environment's filesystem API. All other tools are treated as process operations and dispatched via the command execution API. This is independent of the Tier 1/2 classifier in internal/tools, which is a NativeSandbox-specific concept.

Types

type Capabilities

type Capabilities struct {
	Snapshots          bool
	Rollback           bool
	Pause              bool
	StreamingProgress  bool
	TierRouting        bool
	MaxSessionDuration time.Duration
	ConcurrentSessions int
}

Capabilities describes what an ExecutionEnvironment supports.

type ExecutionEnvironment

type ExecutionEnvironment interface {
	Create(ctx context.Context, config SessionConfig) error
	Pause(ctx context.Context) error
	Resume(ctx context.Context) error
	Destroy(ctx context.Context) error

	ExecuteTool(ctx context.Context, req ToolRequest, onProgress func(ToolProgress)) (*ToolResponse, error)

	State() SessionState
	Capabilities() Capabilities

	CreateSnapshot(ctx context.Context, name string) (*SnapshotInfo, error)
	Rollback(ctx context.Context, snapshotID string) error
}

ExecutionEnvironment is the unified interface for tool execution environments. It covers lifecycle management, tool execution, environment state, and optional capabilities like snapshots and rollback.

type SessionConfig

type SessionConfig struct {
	BaseImage string
	SessionID string
	Labels    map[string]string
	Options   any
}

SessionConfig carries parameters for environment creation.

type SessionState

type SessionState string

SessionState represents lifecycle state for an execution environment.

const (
	StateCreating   SessionState = "creating"
	StateActive     SessionState = "active"
	StatePaused     SessionState = "paused"
	StateDestroying SessionState = "destroying"
	StateDestroyed  SessionState = "destroyed"
	StateFailed     SessionState = "failed"
)

type SnapshotInfo

type SnapshotInfo struct {
	ID        string
	Name      string
	CreatedAt time.Time
	SpaceUsed int64 // bytes; 0 if environment does not track this
}

SnapshotInfo describes a snapshot of the environment state.

type ToolProgress

type ToolProgress = tools.ToolProgress

type ToolRequest

type ToolRequest = tools.ToolRequest

type ToolResponse

type ToolResponse = tools.ToolResponse

Directories

Path Synopsis
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