Documentation
¶
Overview ¶
Package container provides container lifecycle management for agents.
Index ¶
- type AgentOpts
- type Container
- type ContainerManager
- type DockerManager
- func (m *DockerManager) Close()
- func (m *DockerManager) GetRunning(ctx context.Context, agentID uuid.UUID) (*Container, error)
- func (m *DockerManager) PruneAgentResources(ctx context.Context, validAgents map[string]string)
- func (m *DockerManager) RemoveImage(ctx context.Context, imageRef string) error
- func (m *DockerManager) StartAgent(ctx context.Context, opts AgentOpts) (*Container, error)
- func (m *DockerManager) StartToolserver(ctx context.Context, opts ToolserverOpts) (*Container, error)
- func (m *DockerManager) StopAgent(ctx context.Context, id string) error
- func (m *DockerManager) StopToolserver(ctx context.Context, name string) error
- type ToolserverOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentOpts ¶
type AgentOpts struct {
AgentID uuid.UUID
Image string // Docker image to run (e.g., "my-agent:abc123")
Env map[string]string // Additional environment variables
}
AgentOpts configures an agent container.
type Container ¶
type Container struct {
ID string // Docker container ID
Name string // Human-readable name
Endpoint string // HTTP endpoint (e.g., "http://172.17.0.2:8080")
Token string // Bearer token for authenticating requests to this container
}
Container represents a running container.
type ContainerManager ¶
type ContainerManager interface {
// StartAgent ensures an agent container is running.
// Returns the existing container if already running and healthy.
StartAgent(ctx context.Context, opts AgentOpts) (*Container, error)
// GetRunning returns the running container for an agent without starting
// one if absent. Returns (nil, nil) when no container is up. Used by
// out-of-band signals (e.g. /refresh push) where booting a container
// just to notify it would defeat the purpose.
GetRunning(ctx context.Context, agentID uuid.UUID) (*Container, error)
// StopAgent stops a specific agent container.
StopAgent(ctx context.Context, id string) error
// StartToolserver starts an ephemeral toolserver container for build operations.
// Returns the container with a WebSocket endpoint for tool execution.
StartToolserver(ctx context.Context, opts ToolserverOpts) (*Container, error)
// StopToolserver stops and removes an ephemeral toolserver container.
StopToolserver(ctx context.Context, name string) error
// RemoveImage removes a Docker image by reference (e.g., "agentID:hash").
RemoveImage(ctx context.Context, imageRef string) error
}
ContainerManager manages the lifecycle of agent containers.
type DockerManager ¶
type DockerManager struct {
// contains filtered or unexported fields
}
DockerManager implements ContainerManager using the Docker API.
func NewDockerManager ¶
func NewDockerManager(cfg *config.Config, logger *zap.Logger) *DockerManager
NewDockerManager creates a Docker-based ContainerManager.
func (*DockerManager) Close ¶
func (m *DockerManager) Close()
Close stops the idle reaper and closes the Docker client.
func (*DockerManager) GetRunning ¶
GetRunning implements ContainerManager. Returns (nil, nil) when no container exists for the agent — caller is expected to treat that as "nothing to do" rather than an error. Repopulates the in-memory cache when it finds a running container Airlock didn't previously know about (typical after an Airlock restart).
func (*DockerManager) PruneAgentResources ¶
func (m *DockerManager) PruneAgentResources(ctx context.Context, validAgents map[string]string)
PruneAgentResources removes Docker containers and images for agents that no longer exist in the database, and removes stale image tags for active agents (keeping only the current image_ref).
validAgents maps agent UUID string → current image_ref (e.g., "uuid:hash"). Any airlock-agent-* container or UUID-tagged image not matching this set is removed.
func (*DockerManager) RemoveImage ¶
func (m *DockerManager) RemoveImage(ctx context.Context, imageRef string) error
RemoveImage removes a Docker image by reference.
func (*DockerManager) StartAgent ¶
StartAgent implements ContainerManager.
func (*DockerManager) StartToolserver ¶
func (m *DockerManager) StartToolserver(ctx context.Context, opts ToolserverOpts) (*Container, error)
StartToolserver starts an ephemeral toolserver container for build operations. The container runs the toolserver binary with the workspace mounted. Returns the container with a WebSocket endpoint for remote tool execution.
func (*DockerManager) StopAgent ¶
func (m *DockerManager) StopAgent(ctx context.Context, id string) error
StopAgent implements ContainerManager.
func (*DockerManager) StopToolserver ¶
func (m *DockerManager) StopToolserver(ctx context.Context, name string) error
StopToolserver stops and removes an ephemeral toolserver container.
type ToolserverOpts ¶
type ToolserverOpts struct {
Image string // toolserver image (e.g., "agent-builder:v1.0.0")
Mounts []mount.Mount // workspace bind mounts
WorkDir string // -space-dir value inside the container
Env []string // additional environment variables
}
ToolserverOpts configures an ephemeral toolserver container for build operations.