Documentation
¶
Overview ¶
Package control hosts lifecycle control-plane orchestration.
Index ¶
- Constants
- func ListenAndServe(ctx context.Context, socketPath string, service *Service, logger *slog.Logger) error
- type ContainerEvent
- type ContainerInspectResult
- type Service
- func (s *Service) CancelExec(_ context.Context, req *agboxv1.CancelExecRequest) (*agboxv1.AcceptedResponse, error)
- func (s *Service) CreateExec(_ context.Context, req *agboxv1.CreateExecRequest) (*agboxv1.CreateExecResponse, error)
- func (s *Service) CreateSandbox(_ context.Context, req *agboxv1.CreateSandboxRequest) (*agboxv1.CreateSandboxResponse, error)
- func (s *Service) DeleteSandbox(_ context.Context, req *agboxv1.DeleteSandboxRequest) (*agboxv1.AcceptedResponse, error)
- func (s *Service) DeleteSandboxes(_ context.Context, req *agboxv1.DeleteSandboxesRequest) (*agboxv1.DeleteSandboxesResponse, error)
- func (s *Service) GetExec(_ context.Context, req *agboxv1.GetExecRequest) (*agboxv1.GetExecResponse, error)
- func (s *Service) GetSandbox(_ context.Context, req *agboxv1.GetSandboxRequest) (*agboxv1.GetSandboxResponse, error)
- func (s *Service) ListActiveExecs(_ context.Context, req *agboxv1.ListActiveExecsRequest) (*agboxv1.ListActiveExecsResponse, error)
- func (s *Service) ListSandboxes(_ context.Context, req *agboxv1.ListSandboxesRequest) (*agboxv1.ListSandboxesResponse, error)
- func (s *Service) Ping(context.Context, *agboxv1.PingRequest) (*agboxv1.PingResponse, error)
- func (s *Service) ResumeSandbox(_ context.Context, req *agboxv1.ResumeSandboxRequest) (*agboxv1.AcceptedResponse, error)
- func (s *Service) StopSandbox(_ context.Context, req *agboxv1.StopSandboxRequest) (*agboxv1.AcceptedResponse, error)
- func (s *Service) SubscribeSandboxEvents(req *agboxv1.SubscribeSandboxEventsRequest, ...) error
- type ServiceConfig
- type YAMLCompanionContainerSpec
- type YAMLConfig
- type YAMLCopySpec
- type YAMLHealthcheckConfig
- type YAMLMountSpec
- type YAMLPortMapping
Constants ¶
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" )
const ErrorDomain = "agents-sandbox"
ErrorDomain is the domain string used in all ErrorInfo details emitted by this service.
Variables ¶
This section is empty.
Functions ¶
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 (s *Service) CancelExec(_ context.Context, req *agboxv1.CancelExecRequest) (*agboxv1.AcceptedResponse, error)
func (*Service) CreateExec ¶
func (s *Service) CreateExec(_ context.Context, req *agboxv1.CreateExecRequest) (*agboxv1.CreateExecResponse, error)
func (*Service) CreateSandbox ¶
func (s *Service) CreateSandbox(_ context.Context, req *agboxv1.CreateSandboxRequest) (*agboxv1.CreateSandboxResponse, error)
func (*Service) DeleteSandbox ¶
func (s *Service) DeleteSandbox(_ context.Context, req *agboxv1.DeleteSandboxRequest) (*agboxv1.AcceptedResponse, error)
func (*Service) DeleteSandboxes ¶
func (s *Service) DeleteSandboxes(_ context.Context, req *agboxv1.DeleteSandboxesRequest) (*agboxv1.DeleteSandboxesResponse, error)
func (*Service) GetExec ¶
func (s *Service) GetExec(_ context.Context, req *agboxv1.GetExecRequest) (*agboxv1.GetExecResponse, error)
func (*Service) GetSandbox ¶
func (s *Service) GetSandbox(_ context.Context, req *agboxv1.GetSandboxRequest) (*agboxv1.GetSandboxResponse, error)
func (*Service) ListActiveExecs ¶
func (s *Service) ListActiveExecs(_ context.Context, req *agboxv1.ListActiveExecsRequest) (*agboxv1.ListActiveExecsResponse, error)
func (*Service) ListSandboxes ¶
func (s *Service) ListSandboxes(_ context.Context, req *agboxv1.ListSandboxesRequest) (*agboxv1.ListSandboxesResponse, error)
func (*Service) Ping ¶
func (s *Service) Ping(context.Context, *agboxv1.PingRequest) (*agboxv1.PingResponse, error)
func (*Service) ResumeSandbox ¶
func (s *Service) ResumeSandbox(_ context.Context, req *agboxv1.ResumeSandboxRequest) (*agboxv1.AcceptedResponse, error)
func (*Service) StopSandbox ¶
func (s *Service) StopSandbox(_ context.Context, req *agboxv1.StopSandboxRequest) (*agboxv1.AcceptedResponse, error)
func (*Service) SubscribeSandboxEvents ¶
func (s *Service) SubscribeSandboxEvents(req *agboxv1.SubscribeSandboxEventsRequest, stream agboxv1.SandboxService_SubscribeSandboxEventsServer) error
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.
Source Files
¶
- doc.go
- docker_event_watcher.go
- docker_runtime.go
- docker_runtime_copy.go
- docker_runtime_dockerapi.go
- docker_runtime_health.go
- docker_runtime_materialize.go
- docker_runtime_nftables.go
- docker_runtime_nftables_linux.go
- errors.go
- event_store.go
- id_registry.go
- resource_limits.go
- service.go
- service_async.go
- service_clone.go
- service_events.go
- service_validation.go
- yaml_config.go