Documentation
¶
Index ¶
- Constants
- Variables
- func RedactSandboxCredential(workload map[string]any) map[string]any
- func SandboxChildName(parts ...string) string
- func SandboxHomeVolumesetName(workloadName string) string
- func SandboxIdentityNameOf(identityLink string) string
- func SandboxPoolIdentityOf(tags base.Tags) string
- func SandboxPoolWorkerName(identity string, n int) string
- func SandboxRunsDaemon(sandboxType string) bool
- func SandboxSessionWorkerKey(sessionID string) string
- func SandboxWorkerKey(workerName string) string
- type HomeVolumeset
- type HomeVolumesetSpec
- type SandboxIde
- type SandboxPort
- type SandboxScaling
- type SandboxSpec
- type SandboxType
- type SandboxVolume
Constants ¶
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 ¶
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.
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).
var SandboxIdes = []string{"vscode", "cursor", "ssh", "browser"}
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.
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).
var SandboxTypes = []string{"dev", "worker"}
Functions ¶
func RedactSandboxCredential ¶
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 ¶
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 ¶
SandboxHomeVolumesetName is the sandbox's only child: the home volumeset, created and deleted with the workload.
func SandboxIdentityNameOf ¶
SandboxIdentityNameOf is the identity name an identityLink points at, or "" (sandboxIdentityNameOf).
func SandboxPoolIdentityOf ¶
SandboxPoolIdentityOf is the pool a worker belongs to (sandbox.ts sandboxPoolIdentityOf): the SandboxPoolTag value, or "" when absent/empty.
func SandboxPoolWorkerName ¶
SandboxPoolWorkerName is the Nth pool worker's name for an identity (sandboxPoolWorkerName).
func SandboxRunsDaemon ¶
SandboxRunsDaemon reports whether the profile runs devboxd as its only listener (worker), secured by the token.
func SandboxSessionWorkerKey ¶
SandboxSessionWorkerKey is the worker key a pool session id ends in, or "" (sandboxSessionWorkerKey).
func SandboxWorkerKey ¶
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 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).