control

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Overview

Package control hosts lifecycle control-plane orchestration.

Index

Constants

View Source
const (
	ReasonSandboxConflict             = "SANDBOX_CONFLICT"
	ReasonSandboxIDAlreadyExists      = "SANDBOX_ID_ALREADY_EXISTS"
	ReasonSandboxNotFound             = "SANDBOX_NOT_FOUND"
	ReasonSandboxNotReady             = "SANDBOX_NOT_READY"
	ReasonSandboxInvalidState         = "SANDBOX_INVALID_STATE"
	ReasonExecIDAlreadyExists         = "EXEC_ID_ALREADY_EXISTS"
	ReasonExecNotFound                = "EXEC_NOT_FOUND"
	ReasonExecAlreadyTerminal         = "EXEC_ALREADY_TERMINAL"
	ReasonExecNotRunning              = "EXEC_NOT_RUNNING"
	ReasonSandboxEventSequenceExpired = "SANDBOX_EVENT_SEQUENCE_EXPIRED"
)
View Source
const ErrorDomain = "agents-sandbox"

ErrorDomain is the domain string used in all ErrorInfo details emitted by this service.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, socketPath string, service *Service, logger *slog.Logger) error

Types

type ContainerEvent

type ContainerEvent struct {
	SandboxID              string
	ContainerName          string
	Action                 string // "die" or "oom"
	IsCompanionContainer   bool
	CompanionContainerName string
}

ContainerEvent represents a Docker container lifecycle event relevant to sandbox state management.

type ContainerInspectResult

type ContainerInspectResult struct {
	Exists    bool
	Running   bool
	Paused    bool
	ExitCode  int
	OOMKilled bool
}

ContainerInspectResult holds the state of a single container queried via Docker inspect.

type Service

type Service struct {
	agboxv1.UnimplementedSandboxServiceServer
	// contains filtered or unexported fields
}

func NewService

func NewService(config ServiceConfig) (*Service, io.Closer, error)

func NewServiceWithPersistentIDStore

func NewServiceWithPersistentIDStore(ctx context.Context, config ServiceConfig, path string) (*Service, io.Closer, error)

NewServiceWithPersistentIDStore builds a service backed by persistent ID and event stores.

func (*Service) CancelExec

func (*Service) CreateExec

func (*Service) CreateSandbox

func (*Service) DeleteSandbox

func (*Service) GetExec

func (*Service) GetSandbox

func (*Service) ListSandboxes

func (*Service) Ping

func (*Service) ResumeSandbox

func (*Service) StopSandbox

type ServiceConfig

type ServiceConfig struct {
	TransitionDelay        time.Duration
	PollInterval           time.Duration
	IdleTTL                time.Duration
	CleanupTTL             time.Duration
	CleanupInterval        time.Duration
	ArtifactOutputRoot     string
	ArtifactOutputTemplate string
	Version                string
	DaemonName             string
	LogLevel               string
	Logger                 *slog.Logger
	// NowFunc is the clock used for crashloop window evaluation and restore recovery.
	// Defaults to time.Now when nil. Inject a custom clock in tests for deterministic behaviour.
	NowFunc func() time.Time
	// contains filtered or unexported fields
}

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

type YAMLCompanionContainerSpec added in v0.3.0

type YAMLCompanionContainerSpec struct {
	Image              string                 `yaml:"image"`
	Envs               map[string]string      `yaml:"envs"`
	Healthcheck        *YAMLHealthcheckConfig `yaml:"healthcheck"`
	PostStartOnPrimary []string               `yaml:"post_start_on_primary"`
	// Command overrides the companion container's Docker CMD. A pointer type
	// preserves YAML presence semantics: nil = field omitted (image CMD
	// applies); non-nil with len == 0 = explicit empty array (rejected).
	Command *[]string `yaml:"command"`
	// CPULimit / MemoryLimit / DiskLimit follow the same Docker CLI syntax as
	// the top-level CreateSpec fields, scoped to this companion container.
	// Empty = unlimited.
	CPULimit    string `yaml:"cpu_limit"`
	MemoryLimit string `yaml:"memory_limit"`
	DiskLimit   string `yaml:"disk_limit"`
}

YAMLCompanionContainerSpec describes a companion container.

type YAMLConfig

type YAMLConfig struct {
	Image               string                                `yaml:"image"`
	Mounts              []YAMLMountSpec                       `yaml:"mounts"`
	Copies              []YAMLCopySpec                        `yaml:"copies"`
	Ports               []YAMLPortMapping                     `yaml:"ports"`
	BuiltinTools        []string                              `yaml:"builtin_tools"`
	CompanionContainers map[string]YAMLCompanionContainerSpec `yaml:"companion_containers"`
	Labels              map[string]string                     `yaml:"labels"`
	Envs                map[string]string                     `yaml:"envs"`
	// IdleTTL is the per-sandbox idle TTL override. Empty = use global daemon
	// default; "0" = disable idle stop for this sandbox.
	IdleTTL string `yaml:"idle_ttl"`
	// Command overrides the primary container's Docker CMD. A pointer type
	// preserves YAML presence semantics: nil = field omitted (daemon falls
	// back to the sleep-loop default); non-nil with len == 0 = explicit empty
	// array (rejected as a misconfiguration).
	Command *[]string `yaml:"command"`
	// CPULimit / MemoryLimit / DiskLimit follow Docker CLI syntax. Empty =
	// unlimited (no enforcement). See CreateSpec in api/proto/service.proto.
	CPULimit    string `yaml:"cpu_limit"`
	MemoryLimit string `yaml:"memory_limit"`
	DiskLimit   string `yaml:"disk_limit"`
	// GPUs follows Docker --gpus device-request syntax for the primary
	// container. MVP accepts only empty and "all".
	GPUs string `yaml:"gpus"`
}

YAMLConfig is the top-level schema for declarative sandbox configuration supplied via the config_yaml field in CreateSandboxRequest.

type YAMLCopySpec

type YAMLCopySpec struct {
	Source          string   `yaml:"source"`
	Target          string   `yaml:"target"`
	ExcludePatterns []string `yaml:"exclude_patterns"`
}

YAMLCopySpec describes a file-copy from host to container.

type YAMLHealthcheckConfig

type YAMLHealthcheckConfig struct {
	Test          []string `yaml:"test"`
	Interval      string   `yaml:"interval"`
	Timeout       string   `yaml:"timeout"`
	Retries       uint32   `yaml:"retries"`
	StartPeriod   string   `yaml:"start_period"`
	StartInterval string   `yaml:"start_interval"`
}

YAMLHealthcheckConfig describes the healthcheck for a companion container.

type YAMLMountSpec

type YAMLMountSpec struct {
	Source   string `yaml:"source"`
	Target   string `yaml:"target"`
	Writable bool   `yaml:"writable"`
}

YAMLMountSpec describes a bind-mount from host to container.

type YAMLPortMapping added in v0.4.0

type YAMLPortMapping struct {
	ContainerPort uint32 `yaml:"container_port"`
	HostPort      uint32 `yaml:"host_port"`
	Protocol      string `yaml:"protocol"`
}

YAMLPortMapping describes a port mapping from container to host.

Directories

Path Synopsis
Package reslimits parses sandbox resource limit strings into typed values.
Package reslimits parses sandbox resource limit strings into typed values.

Jump to

Keyboard shortcuts

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