e2b

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Code generated by contractgen; DO NOT EDIT.

Package e2b adapts the official SDK helper to managed compute operations.

Index

Constants

View Source
const MaxCommandInputBytes = sandbox.MaxCommandInputBytes
View Source
const MaxCredentialReferences = 32
View Source
const MaxObservationReferences = runtimeobs.MaxBatchTargets
View Source
const MaxOutputBytes = 1024 * 1024
View Source
const MaxRequestBytes = 72 * 1024 * 1024
View Source
const MaxResponseBytes = 16 * 1024 * 1024
View Source
const OfficialAPIURL = "https://api.e2b.app"
View Source
const OfficialDomain = "e2b.app"
View Source
const ProtocolVersion = 1

This adapter-private boundary is documented in tools/e2b-provider/README.md.

View Source
const SDKVersion = "2.51.0"

Variables

View Source
var ErrEndpoint = errors.New("invalid E2B endpoint")

Functions

func HelperErrors

func HelperErrors() []string

HelperErrors are sanitized wire outcomes; an empty code denotes success.

func HelperOperations

func HelperOperations() []string

HelperOperations declares the complete set of one-shot helper operations.

func InstalledPaths

func InstalledPaths(paths sandbox.ProcessPaths) (string, string, error)

InstalledPaths resolves the adapter's fixed distribution layout.

func NormalizeEndpoint

func NormalizeEndpoint(apiURL, domain string) (string, string, error)

NormalizeEndpoint returns the two SDK routing selectors. Both must be set together for a compatible service; omission selects the official cloud.

func NormalizeSelection

func NormalizeSelection(s sandbox.Selection) (sandbox.Selection, error)

NormalizeSelection accepts omitted candidate resources only until live build discovery. Persistence requires ValidateSpecification after preparation.

func Operations

func Operations() providercontract.Operations

Operations is this adapter's complete authored resource contract.

func Policy

func Policy() sandbox.DeploymentPolicy

func ResolveChange

func ResolveChange(next, previous sandbox.Selection) sandbox.Selection

func ValidateConfiguration

func ValidateConfiguration(c *DeploymentConfiguration) error

func ValidateResources

func ValidateResources(r sandbox.Resources) error

func ValidateSpecification

func ValidateSpecification(s sandbox.DeploymentSpec) error

func WithTemplateBuild

func WithTemplateBuild(input sandbox.Selection, build *DeploymentBuild) sandbox.Selection

Types

type Caller

type Caller interface {
	Call(context.Context, Request) (Response, error)
}

type Config

type Config struct {
	Binary, StateDir, InstallationID, APIKey, Template, APIURL, Domain string
	TimeoutSeconds                                                     int
	Resources                                                          *sandbox.Resources
}

Config contains trusted deployment configuration; APIKey travels only on stdin.

func (Config) Validate

func (c Config) Validate() error

type ConfigurationAdapter

type ConfigurationAdapter struct{}

func (ConfigurationAdapter) Decode

func (ConfigurationAdapter) DecodeInput

func (ConfigurationAdapter) DecodeInput(public, secret json.RawMessage) (sandbox.Configuration, error)

func (ConfigurationAdapter) DiscoverConfiguration

func (ConfigurationAdapter) Encode

func (ConfigurationAdapter) Equal

func (ConfigurationAdapter) Normalize

func (ConfigurationAdapter) Requirements

func (ConfigurationAdapter) ResolveChange

func (a ConfigurationAdapter) ResolveChange(next, previous sandbox.Selection) (sandbox.Selection, error)

func (ConfigurationAdapter) WithCredential

func (ConfigurationAdapter) WithCredential(owner, candidate sandbox.Configuration) (sandbox.Configuration, error)

type DeploymentBuild

type DeploymentBuild struct {
	Status          string
	CPUs, MemoryMiB int32
	RootDiskMiB     *int32
}

DeploymentBuild is the fixed build as read by the validation that admitted a selection. RootDiskMiB is nil when E2B does not report it.

type DeploymentConfiguration

type DeploymentConfiguration struct {
	CredentialSupplied bool             `json:"-"`
	APIKey             string           `json:"-"`
	APIURL             string           `json:"api_url,omitempty"`
	Domain             string           `json:"domain,omitempty"`
	Template           string           `json:"template"`
	TemplateBuild      *DeploymentBuild `json:"-"`
	// contains filtered or unexported fields
}

APIKey is internal configuration. HTTP requests use a write-only DTO. DeploymentBuild is set only by Core after it validates the candidate.

func (*DeploymentConfiguration) HasCredential

func (c *DeploymentConfiguration) HasCredential() bool

func (*DeploymentConfiguration) MarshalJSON

func (*DeploymentConfiguration) MarshalJSON() ([]byte, error)

MarshalJSON blocks accidental serialization; ConfigurationAdapter.Encode owns the public projection.

func (*DeploymentConfiguration) ReplacesCredential

func (c *DeploymentConfiguration) ReplacesCredential() bool

func (*DeploymentConfiguration) String

func (c *DeploymentConfiguration) String() string

type Observation

type Observation struct {
	sandbox.Reference
	Status                string
	ObservedAt, StartedAt *time.Time `json:",omitempty"`
	CPUCount, CPUUsedPct  *float64   `json:",omitempty"`
	MemUsed, MemTotal     *uint64    `json:",omitempty"`
	DiskUsed, DiskTotal   *uint64    `json:",omitempty"`
}

Observation is one allocation's latest E2B metrics point. Status is observed, not_running, unavailable or ownership; only observed carries values. A malformed E2B point is unavailable for its row only. Values keep E2B's units: CPUUsedPct is a percentage of all CPUCount cores, and memory and disk are in bytes.

type ProcessCaller

type ProcessCaller struct{ Fence *sandbox.CallFence }

func (*ProcessCaller) Call

func (p *ProcessCaller) Call(ctx context.Context, q Request) (Response, error)

type Provider

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

func New

func New(c Config) (*Provider, error)

func NewWithCaller

func NewWithCaller(c Config, caller Caller) (*Provider, error)

func (*Provider) Create

func (p *Provider) Create(ctx context.Context, b sandbox.Bootstrap) (sandbox.Info, error)

func (*Provider) DeleteSnapshot

func (*Provider) DiscoverSelection

func (p *Provider) DiscoverSelection(ctx context.Context, s sandbox.Selection) (sandbox.Selection, error)

DiscoverSelection checks the immutable native build without allocating compute.

func (*Provider) GetInfo

func (p *Provider) GetInfo(ctx context.Context, r sandbox.Reference) (sandbox.Info, error)

func (*Provider) Initial

func (*Provider) Kill

func (p *Provider) Kill(ctx context.Context, r sandbox.Reference) error

func (*Provider) KillCompute

func (*Provider) ObservationProviderType

func (*Provider) ObservationProviderType() string

func (*Provider) Observe

func (p *Provider) Observe(ctx context.Context, target runtimeobs.Target) (runtimeobs.Sample, error)

Observe reads one allocation through the same helper request as ObserveBatch.

func (*Provider) ObserveBatch

func (p *Provider) ObserveBatch(ctx context.Context, targets []runtimeobs.Target) ([]runtimeobs.BatchResult, error)

ObserveBatch reads up to runtimeobs.MaxBatchTargets allocations with one helper request. The helper takes sandbox IDs from its private receipts, confirms each running sandbox by its allocation labels and reads E2B's batch metrics once. It never connects to, renews or changes a sandbox.

func (*Provider) ProviderOperations

func (*Provider) ProviderOperations() providercontract.Operations

func (*Provider) Renew

func (p *Provider) Renew(ctx context.Context, r sandbox.Reference) (sandbox.Info, error)

func (*Provider) ResolveObservationSource

func (p *Provider) ResolveObservationSource(context.Context) (runtimeobs.Source, error)

func (*Provider) Resume

func (*Provider) RunCommand

func (*Provider) Suspend

func (*Provider) ValidateDeployment

func (p *Provider) ValidateDeployment(ctx context.Context) (TemplateBuild, error)

ValidateDeployment verifies team ownership and reads the exact immutable build without creating compute or allocation receipts. Candidate configuration remains unpublished until it passes. It returns the build as read. Without configured Resources it only requires a ready build, whose CPU and memory the caller then adopts as the selection.

func (*Provider) VerifyCredential

func (p *Provider) VerifyCredential(ctx context.Context, refs []sandbox.Reference) error

VerifyCredential is read-only and bounded. A public readable template alone does not prove team ownership. References are one bounded Core-owned page.

type ReadyBuild

type ReadyBuild struct {
	ID        string `json:"id"`
	CPUs      uint32 `json:"cpus"`
	MemoryMiB uint32 `json:"memory_mib"`
}

type Request

type Request struct {
	Version   int
	Operation string
	Config    Config
	Reference sandbox.Reference
	// References lists the allocations of one read-only observe request.
	References       []sandbox.Reference          `json:",omitempty"`
	Bootstrap        *sandbox.Bootstrap           `json:",omitempty"`
	RuntimeBootstrap *runtimebootstrap.Connection `json:",omitempty"`
	Command          *sandbox.Command             `json:",omitempty"`
	Deadline         time.Time
}

func (Request) Validate

func (q Request) Validate() error

Validate checks the operation envelope before the helper can start. Native configuration and operation outcomes retain their existing adapter validation.

type Response

type Response struct {
	Version         int
	Info            *sandbox.Info          `json:",omitempty"`
	Command         *sandbox.CommandResult `json:",omitempty"`
	ErrorCode       string
	DeploymentValid bool              `json:",omitempty"`
	TemplateBuild   *TemplateBuild    `json:",omitempty"`
	Templates       []TemplateSummary `json:",omitempty"`
	Builds          []ReadyBuild      `json:",omitempty"`
	Observations    []Observation     `json:",omitempty"`
}

func Discover

func Discover(ctx context.Context, caller Caller, binary, apiKey, apiURL, domain, template string) (Response, error)

Discover uses the same pinned SDK helper without requiring a saved deployment. Its credential is passed only to the helper on stdin.

func (Response) Validate

func (r Response) Validate() error

type TemplateBuild

type TemplateBuild struct {
	Status          string
	CPUs, MemoryMiB uint32
	RootDiskMiB     *uint32
}

TemplateBuild is the fixed build as read by deployment validation. RootDiskMiB is nil when E2B does not report the build's disk size.

type TemplateSummary

type TemplateSummary struct {
	ID    string   `json:"id"`
	Names []string `json:"names"`
}

Directories

Path Synopsis
internal
contractgen command
Command contractgen projects the adapter's Go declarations into its Python artifacts.
Command contractgen projects the adapter's Go declarations into its Python artifacts.

Jump to

Keyboard shortcuts

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