container

package
v0.1.61 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements DockerClient by delegating to the Docker SDK.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new Client backed by the Docker SDK.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying Docker client resources.

func (*Client) ContainerCreate

func (c *Client) ContainerCreate(ctx context.Context, cfg *ContainerConfig, name string) (string, error)

ContainerCreate creates a new Docker container from the given config.

func (*Client) ContainerList

func (c *Client) ContainerList(ctx context.Context, labelKey, labelValue string) ([]string, error)

ContainerList returns the IDs of containers matching the given label.

func (*Client) ContainerLogs

func (c *Client) ContainerLogs(ctx context.Context, containerID string) (io.Reader, error)

ContainerLogs retrieves the container's stdout/stderr logs after it exits. It demultiplexes the Docker stream so the caller receives clean output bytes.

func (*Client) ContainerLogsFollow added in v0.1.28

func (c *Client) ContainerLogsFollow(ctx context.Context, containerID string) (io.ReadCloser, error)

ContainerLogsFollow follows the container's stdout/stderr logs in real-time. The returned ReadCloser streams log output as it is produced. The caller must close the reader when done.

func (*Client) ContainerRemove

func (c *Client) ContainerRemove(ctx context.Context, containerID string) error

ContainerRemove forcefully removes the specified container.

func (*Client) ContainerStart

func (c *Client) ContainerStart(ctx context.Context, containerID string) error

ContainerStart starts the specified container.

func (*Client) ContainerWait

func (c *Client) ContainerWait(ctx context.Context, containerID string) (<-chan WaitResponse, <-chan error)

ContainerWait waits for the container to reach a "not-running" state and converts the Docker SDK response into our WaitResponse type.

func (*Client) CopyToContainer added in v0.1.56

func (c *Client) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader) error

CopyToContainer copies a tar archive into the container at the given path.

func (*Client) ImageBuild

func (c *Client) ImageBuild(ctx context.Context, contextDir, tag string) error

ImageBuild builds a Docker image from the given context directory.

func (*Client) ImageList

func (c *Client) ImageList(ctx context.Context, imageName string) ([]string, error)

ImageList returns the IDs of images matching the given reference.

func (*Client) ImagePull

func (c *Client) ImagePull(ctx context.Context, imageName string) error

ImagePull pulls the specified image and drains the response.

type ContainerConfig

type ContainerConfig struct {
	Image      string
	MemoryMB   int64
	CPUs       float64
	Env        []string
	Cmd        []string
	Binds      []string
	WorkingDir string
	GroupAdd   []string
}

ContainerConfig holds settings for creating a container.

type DockerClient

type DockerClient interface {
	ContainerCreate(ctx context.Context, cfg *ContainerConfig, name string) (string, error)
	ContainerStart(ctx context.Context, containerID string) error
	ContainerLogs(ctx context.Context, containerID string) (io.Reader, error)
	ContainerLogsFollow(ctx context.Context, containerID string) (io.ReadCloser, error)
	ContainerWait(ctx context.Context, containerID string) (<-chan WaitResponse, <-chan error)
	ContainerRemove(ctx context.Context, containerID string) error
	ImageList(ctx context.Context, image string) ([]string, error)
	ImagePull(ctx context.Context, image string) error
	ImageBuild(ctx context.Context, contextDir, tag string) error
	ContainerList(ctx context.Context, labelKey, labelValue string) ([]string, error)
	CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader) error
}

DockerClient abstracts the Docker SDK methods used by DockerRunner.

type DockerRunner

type DockerRunner struct {
	// contains filtered or unexported fields
}

DockerRunner implements Runner using Docker containers.

func NewDockerRunner

func NewDockerRunner(client DockerClient, cfg *config.Config) *DockerRunner

NewDockerRunner creates a new DockerRunner with the given Docker client and config.

func (*DockerRunner) Cleanup

func (r *DockerRunner) Cleanup(ctx context.Context) error

Cleanup removes any lingering containers with the loop-agent label.

func (*DockerRunner) Run

Run executes an agent request in a Docker container. If a session ID is set and the run fails, it retries with --resume using only the original prompt (no full message history rebuild).

type Runner

type Runner interface {
	Run(ctx context.Context, req *agent.AgentRequest) (*agent.AgentResponse, error)
	Cleanup(ctx context.Context) error
}

Runner executes agent requests inside containers.

type WaitResponse

type WaitResponse struct {
	StatusCode int64
	Error      error
}

WaitResponse represents the result of waiting for a container to finish.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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