Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

4.6 KB
Raw Blame
// Copyright 2025 BoxLite AI (originally Daytona Platforms Inc.
// Modified by BoxLite AI, 2025-2026
// SPDX-License-Identifier: AGPL-3.0

package dto

// CreateBoxDTO carries two unrelated "user" fields. OsUser is a Daytona-era
// provisioning label: it only ever became a DAYTONA_SANDBOX_USER env var for a
// computer-use daemon that never read it, and nothing acts on it today.
// RunAsUser is the OCI process.user override (docker `-u`), empty when the
// caller did not ask for one so the image's own USER directive stands.
type CreateBoxDTO struct {
	Id           string `json:"id" validate:"required"`
	FromVolumeId string `json:"fromVolumeId,omitempty"`
	Image        string `json:"image" validate:"required"`
	OsUser       string `json:"osUser" validate:"required"`
	// CPU allocation in cores (0.125–16), in increments of 0.001; omitted means 1.
	CpuQuota     *float64          `json:"cpuQuota,omitempty" validate:"omitempty,min=0.125,max=16"`
	GpuQuota     int64             `json:"gpuQuota" validate:"min=0"`
	MemoryQuota  float64           `json:"memoryQuota" validate:"min=0.125"`
	StorageQuota int64             `json:"storageQuota" validate:"min=1"`
	Env          map[string]string `json:"env,omitempty"`
	Registry     *RegistryDTO      `json:"registry,omitempty"`
	Entrypoint   []string          `json:"entrypoint,omitempty"`
	Cmd          []string          `json:"cmd,omitempty"`
	WorkingDir   string            `json:"workingDir,omitempty"`
	RunAsUser    string            `json:"runAsUser,omitempty"`
	Privileged   bool              `json:"privileged,omitempty"`
	Volumes      []VolumeDTO       `json:"volumes,omitempty"`
	Secrets      []SecretDTO       `json:"secrets,omitempty" validate:"dive"`
	// Outbound network policy. outboundEnabled is required: a request without
	// it is rejected rather than started with a guessed policy.
	OutboundEnabled  *bool             `json:"outboundEnabled" validate:"required"`
	OutboundAllowNet []string          `json:"outboundAllowNet,omitempty"`
	Metadata         map[string]string `json:"metadata,omitempty"`
	AuthToken        *string           `json:"authToken,omitempty"`
	OtelEndpoint     *string           `json:"otelEndpoint,omitempty"`
	SkipStart        *bool             `json:"skipStart,omitempty"`

	// Requires explicit authorization on the Runner process; omitted means off.
	NestedVirtualization bool `json:"nestedVirtualization,omitempty"`

	// Nullable for backward compatibility
	OrganizationId *string `json:"organizationId,omitempty"`
	RegionId       *string `json:"regionId,omitempty"`

	// RequireExisting is internal to credential-bearing CREATE_BOX replays.
	// It prevents a concurrent deletion from turning adoption into creation.
	RequireExisting bool `json:"-"`
} //	@name	CreateBoxDTO

// Same outbound policy shape as CreateBoxDTO; an omitted field is left unchanged.
type UpdateNetworkSettingsDTO struct {
	OutboundEnabled    *bool    `json:"outboundEnabled,omitempty"`
	OutboundAllowNet   []string `json:"outboundAllowNet,omitempty"`
	NetworkLimitEgress *bool    `json:"networkLimitEgress,omitempty"`
} //	@name	UpdateNetworkSettingsDTO

type RecoverBoxDTO struct {
	FromVolumeId string `json:"fromVolumeId,omitempty"`
	OsUser       string `json:"osUser" validate:"required"`
	// CPU allocation in cores (0.125–16), in increments of 0.001; omitted means 1.
	CpuQuota     *float64          `json:"cpuQuota,omitempty" validate:"omitempty,min=0.125,max=16"`
	GpuQuota     int64             `json:"gpuQuota" validate:"min=0"`
	MemoryQuota  float64           `json:"memoryQuota" validate:"min=0.125"`
	StorageQuota int64             `json:"storageQuota" validate:"min=1"`
	Env          map[string]string `json:"env,omitempty"`
	Privileged   bool              `json:"privileged,omitempty"`
	Volumes      []VolumeDTO       `json:"volumes,omitempty"`
	Secrets      []SecretDTO       `json:"secrets,omitempty" validate:"dive"`
	// Outbound network policy. outboundEnabled is required: a request without
	// it is rejected rather than started with a guessed policy.
	OutboundEnabled  *bool    `json:"outboundEnabled" validate:"required"`
	OutboundAllowNet []string `json:"outboundAllowNet,omitempty"`
	ErrorReason      string   `json:"errorReason" validate:"required"`
} //	@name	RecoverBoxDTO

type IsRecoverableDTO struct {
	ErrorReason string `json:"errorReason" validate:"required"`
} //	@name	IsRecoverableDTO

type IsRecoverableResponse struct {
	Recoverable bool `json:"recoverable"`
} //	@name	IsRecoverableResponse
type StartBoxResponse struct {
	DaemonVersion string `json:"daemonVersion"`
} //	@name	StartBoxResponse

type StopBoxDTO struct {
	Force bool `json:"force,omitempty"`
} //	@name	StopBoxDTO