sandbox

package
v1.1.68-test Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 8 Imported by: 1 module, 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

Index

Constants

View Source
const (
	// SandboxGatewayPort is the ide gateway (dev type), the reserved port the overlay
	// declares on the dev container.
	SandboxGatewayPort = 8888
	// SandboxDevboxdPort is the devboxd HTTP API, the worker's only listener.
	SandboxDevboxdPort = 49983

	// SandboxStandardImage is the dev container image injected when a dev sandbox is
	// created without containers; SandboxWorkerStandardImage is the worker equivalent
	// (devboxd as PID 1).
	SandboxStandardImage       = "build.cpln.io/public/sandbox-base:v1"
	SandboxWorkerStandardImage = "build.cpln.io/public/agentbox-base:v1"
	// The injected container carries its own resources: the workload defaults
	// (50m/128Mi) cannot run the IDE. The worker is sized for the sessions it holds,
	// not one IDE (sandbox.ts SandboxWorkerStandardContainer, master 115ed3912).
	SandboxStandardContainerName      = "dev"
	SandboxStandardContainerCpu       = "1000m"
	SandboxStandardContainerMem       = "2Gi"
	SandboxWorkerStandardContainerCpu = "4000m"
	SandboxWorkerStandardContainerMem = "8Gi"

	SandboxHomeVolumeDefaultGb     = 20
	SandboxScaleToZeroDelayDefault = 300

	// SandboxReservedMountPath is where the overlay mounts the home volumeset.
	SandboxReservedMountPath = "/home/devuser"

	// Tags the overlay maintains. SandboxMarkerTag is present iff spec.sandbox is, so
	// sandbox list queries never see stale rows.
	SandboxMarkerTag      = "cpln/sandbox"
	SandboxDevTypeTag     = "cpln/dev-type"
	SandboxDevTypeValue   = "devbox"
	SandboxIdePasswordTag = "cpln/dev-ide-password"

	// E2B sandbox pools (master a7e9e4899). SandboxPoolTag marks a worker as part of an
	// identity's (or the default) pool; the metrics port is the worker's per-session gauge.
	SandboxPoolTag = "cpln/sandbox-pool"
	// SandboxFirewallTag is the fingerprint of the session firewall a server-added worker was created for.
	SandboxFirewallTag           = "cpln/sandbox-firewall"
	SandboxMeshInboundExcludeTag = "cpln/disableServiceMeshInboundPort"
	SandboxMetricsPort           = 49984
	SandboxWorkerMetricsPort     = 49984
	// SandboxPoolSessionIdMax leaves room for the "-<8 hex worker key>" suffix in a 64-char id.
	SandboxPoolSessionIdMax = 64 - 9

	SandboxScalingMaxSessionsDefault     = 20
	SandboxScalingMinWorkersDefault      = 1
	SandboxScalingMaxWorkersDefault      = 10
	SandboxScalingIdleDeleteDelayDefault = 3600

	// The GVC every sandbox is created in (sandbox.ts, master 115ed3912). The fallback
	// name serves while the first is held by a GVC placed elsewhere; the location is
	// where kata runs (the default, SANDBOX_GVC_LOCATION may override it); the tag marks
	// the org's chosen GVC so a later GVC under the other name does not take over.
	SandboxGvcName         = "sandboxes"
	SandboxGvcFallbackName = "cpln-sandboxes"
	SandboxGvcLocation     = "oci-us-ashburn-1"
	SandboxGvcTag          = "cpln/sandboxGvc"
)

Variables

View Source
var SandboxCredentialEnvNames = []string{"CODE_SERVER_PASSWORD", "DEVBOXD_TOKEN"}

SandboxCredentialEnvNames are the reserved names whose values are credentials; only these are redacted (sandbox.ts SandboxCredentialEnvNames). DEVBOXD_MAX_SESSIONS is reserved but not a credential, so it is derived and canonicalized yet never hidden.

View Source
var SandboxDerivedEnvFields = map[string]string{
	"APP_PORT":             "spec.sandbox.appPort",
	"DEVBOXD_TOKEN":        "spec.sandbox.token",
	"DEVBOXD_MAX_SESSIONS": "spec.sandbox.scaling.maxSessions",
}

SandboxDerivedEnvFields maps each derived env entry to the section field it comes from, so the refusal can name where the value belongs (sandbox.ts SandboxDerivedEnvFields).

View Source
var SandboxIdes = []string{"vscode", "cursor", "ssh", "browser"}
View Source
var SandboxReservedEnvNames = []string{"APP_PORT", "CODE_SERVER_PASSWORD", "DEVBOXD_TOKEN", "DEVBOXD_MAX_SESSIONS"}

SandboxReservedEnvNames are owned by the sandbox runtime in the dev container; the overlay derives them and callers may not set them. CODE_SERVER_PASSWORD is retired as an injected value but stays reserved so a stored one is still redacted.

View Source
var SandboxReservedPorts = []int{22, 7681, 8443, 8888, 49983, 49984}

SandboxReservedPorts are bound by the sandbox runtime in the dev container: sshd (22), ttyd (7681), code-server (8443), the ide gateway (8888), devboxd (49983) and the worker metrics port (49984, master a7e9e4899).

View Source
var SandboxTypes = []string{"dev", "worker"}

Functions

func RedactSandboxCredential

func RedactSandboxCredential(workload map[string]any) map[string]any

RedactSandboxCredential returns a copy of a workload map with the worker token, the retired password and the credential env values removed (sandbox.ts redactSandboxCredential). A non-sandbox workload comes back unchanged. The audit and unauthorized-read paths call it so a worker's DEVBOXD_TOKEN never lands in a record or a response.

func SandboxChildName

func SandboxChildName(parts ...string) string

SandboxChildName is the deterministic child-object name, hash-tailed when the join would exceed the Name schema's 64 characters so two sandboxes cannot collide.

func SandboxHomeVolumesetName

func SandboxHomeVolumesetName(workloadName string) string

SandboxHomeVolumesetName is the sandbox's only child: the home volumeset, created and deleted with the workload.

func SandboxIdentityNameOf

func SandboxIdentityNameOf(identityLink string) string

SandboxIdentityNameOf is the identity name an identityLink points at, or "" (sandboxIdentityNameOf).

func SandboxPoolIdentityOf

func SandboxPoolIdentityOf(tags base.Tags) string

SandboxPoolIdentityOf is the pool a worker belongs to (sandbox.ts sandboxPoolIdentityOf): the SandboxPoolTag value, or "" when absent/empty.

func SandboxPoolWorkerName

func SandboxPoolWorkerName(identity string, n int) string

SandboxPoolWorkerName is the Nth pool worker's name for an identity (sandboxPoolWorkerName).

func SandboxRunsDaemon

func SandboxRunsDaemon(sandboxType string) bool

SandboxRunsDaemon reports whether the profile runs devboxd as its only listener (worker), secured by the token.

func SandboxSessionWorkerKey

func SandboxSessionWorkerKey(sessionID string) string

SandboxSessionWorkerKey is the worker key a pool session id ends in, or "" (sandboxSessionWorkerKey).

func SandboxWorkerKey

func SandboxWorkerKey(workerName string) string

SandboxWorkerKey is the stable 8-hex key of a worker name (sandboxWorkerKey).

Types

type HomeVolumeset

type HomeVolumeset struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Spec        HomeVolumesetSpec `json:"spec"`
}

HomeVolumeset is the home-volumeset body the server creates for a sandbox.

func SandboxHomeVolumeset

func SandboxHomeVolumeset(workloadName string, sizeGb int) HomeVolumeset

SandboxHomeVolumeset is the shared-filesystem volumeset the server creates and owns.

type HomeVolumesetSpec

type HomeVolumesetSpec struct {
	InitialCapacity  int    `json:"initialCapacity"`
	PerformanceClass string `json:"performanceClass"`
	FileSystemType   string `json:"fileSystemType"`
}

type SandboxIde

type SandboxIde string
const (
	SandboxIdeVscode  SandboxIde = "vscode"
	SandboxIdeCursor  SandboxIde = "cursor"
	SandboxIdeSsh     SandboxIde = "ssh"
	SandboxIdeBrowser SandboxIde = "browser"
)

func (SandboxIde) EnumValues

func (SandboxIde) EnumValues() []string

type SandboxPort

type SandboxPort float64

SandboxPort is Port minus the ports the sandbox runtime binds inside the dev container; the rule lives in validate.go.

func (SandboxPort) ValidationRule

func (SandboxPort) ValidationRule() *validate.Rule

ValidationRule = Port.custom(reserved by the sandbox runtime).

type SandboxScaling

type SandboxScaling struct {
	MaxSessions     *float64 `json:"maxSessions,omitzero" validate:"integer,min=1,max=500,default=20"`
	MinWorkers      *float64 `json:"minWorkers,omitzero" validate:"integer,min=1,max=100,default=1"`
	MaxWorkers      *float64 `json:"maxWorkers,omitzero" validate:"integer,min=1,max=100,default=10"`
	IdleDeleteDelay *float64 `json:"idleDeleteDelay,omitzero" validate:"integer,min=300,max=604800,default=3600"`
}

SandboxScaling is the worker-pool policy for a worker sandbox's identity (sandbox.ts SandboxScaling, master a7e9e4899). maxWorkers must be >= minWorkers (validate.go).

func (SandboxScaling) ValidationRule

func (SandboxScaling) ValidationRule() *validate.Rule

ValidationRule enforces SandboxScaling's maxWorkers >= minWorkers (sandbox.ts SandboxScaling custom, master a7e9e4899); the per-field bounds/defaults are tags.

type SandboxSpec

type SandboxSpec struct {
	Ide  SandboxIde  `json:"ide,omitzero" validate:"default=browser"`
	Type SandboxType `json:"type,omitzero" validate:"default=dev"`
	// retired; stripped not rejected, so legacy rows and older clients stay writable
	Password         string          `json:"password,omitzero" validate:"strip"`
	Token            string          `json:"token,omitzero" validate:"min=16,max=512"`
	Volume           *SandboxVolume  `json:"volume,omitzero" validate:"default={}"`
	AppPort          *SandboxPort    `json:"appPort,omitzero" validate:"default=8080"`
	ScaleToZeroDelay *float64        `json:"scaleToZeroDelay,omitzero" validate:"min=30,max=3600,default=300"`
	Scaling          *SandboxScaling `json:"scaling,omitzero"`
	// retired; stripped not rejected
	Ttl string `json:"ttl,omitzero" validate:"strip"`
}

func (SandboxSpec) ValidationRule

func (SandboxSpec) ValidationRule() *validate.Rule

ValidationRule reflects the section; every constraint is on the fields.

type SandboxType

type SandboxType string

SandboxType selects the sandbox profile: dev (human devbox, browser IDE behind a Control Plane sign-in) or worker (agent box, the devboxd API gated by the token).

const (
	SandboxTypeDev    SandboxType = "dev"
	SandboxTypeWorker SandboxType = "worker"
)

func (SandboxType) EnumValues

func (SandboxType) EnumValues() []string

type SandboxVolume

type SandboxVolume struct {
	InitialCapacity *float64 `json:"initialCapacity,omitzero" validate:"integer,min=10,default=20"`
}

SandboxVolume is the home volumeset's sole knob. initialCapacity is the GB size the server creates it at; immutable after create (resize the volumeset itself).

Jump to

Keyboard shortcuts

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