docker

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerAgentHome    = "/root"
	ContainerWorkspaceDir = ContainerAgentHome + "/workspace"
	ContainerInputDir     = ContainerAgentHome + "/input"
	ContainerOutputDir    = ContainerAgentHome + "/output"
	ContainerStateDir     = ContainerAgentHome + "/state"
)

Variables

This section is empty.

Functions

func BuildContainerEnv

func BuildContainerEnv(cfg *EnvConfig) []string

BuildContainerEnv assembles the environment variables for a container This function is pure and deterministic - no Docker client interaction

func BuildContainerHostConfig added in v0.11.0

func BuildContainerHostConfig(cfg *HostConfigOptions) *container.HostConfig

BuildContainerHostConfig assembles host-level sandbox settings for containers. Runtime mode is included to make mode-specific policies explicit in one place.

func BuildContainerMounts

func BuildContainerMounts(cfg *MountConfig) []mount.Mount

BuildContainerMounts assembles the Docker mounts configuration.

func ValidateMountTargets

func ValidateMountTargets(cfg *MountConfig) error

ValidateMountTargets validates mount sources and prepares optional state mounts.

func ValidateRequiredArtifacts

func ValidateRequiredArtifacts(outDir string, requiredArtifacts []v1.Artifact) error

ValidateRequiredArtifacts checks that all required artifacts are present This function is pure and deterministic - no Docker client interaction

Types

type AgentConfigMode

type AgentConfigMode string

AgentConfigMode represents the mode for mounting agent-specific configuration from the host into the container. This replaces the boolean UseLocalClaudeConfig with more flexible behavior.

const (
	// AgentConfigModeAuto automatically mounts host config if it exists
	// and appears compatible (not headless/container Claude),
	// and silently skips if it doesn't exist or is incompatible.
	AgentConfigModeAuto AgentConfigMode = "auto"

	// AgentConfigModeYes always attempts to mount the host config,
	// and emits a warning if the config directory doesn't exist.
	// Use with caution as it may mount incompatible configs.
	AgentConfigModeYes AgentConfigMode = "yes"

	// AgentConfigModeNo never mounts the host config.
	// This is the default behavior to prevent accidental credential exposure.
	AgentConfigModeNo AgentConfigMode = "no"
)

func ParseAgentConfigMode

func ParseAgentConfigMode(s string) (AgentConfigMode, error)

ParseAgentConfigMode parses a string into an AgentConfigMode. Case-insensitive. Returns error for invalid values.

func (AgentConfigMode) ShouldMount

func (m AgentConfigMode) ShouldMount(dirExists bool) bool

ShouldMount determines whether to mount the config based on the mode and whether the config directory exists.

func (AgentConfigMode) String

func (m AgentConfigMode) String() string

String returns the string representation of the mode.

func (AgentConfigMode) WarnIfMissing

func (m AgentConfigMode) WarnIfMissing() bool

WarnIfMissing returns true if a warning should be emitted when the config directory doesn't exist.

type ContainerConfig

type ContainerConfig struct {
	BaseImage   string // e.g., golang:1.22 (The toolchain)
	AgentBundle string // Required path to agent bundle archive (.tar.gz)
	Workspace   string
	InputPath   string // Path to input directory (contains spec.yaml, context/, prompts/)
	OutDir      string
	StateDir    string // Path to state directory for cross-run skill caches (optional)
	AgentHome   string // Path to agent home mounted to /root (optional, persistent agent identity/state)
	Env         map[string]string
	Cmd         []string // Optional command override

	// Workspace preparation options
	WorkspaceStrategy    string                // Workspace preparation strategy (e.g., "git-clone", "snapshot")
	WorkspaceHistory     workspace.HistoryMode // How much git history to include
	WorkspaceRef         string                // Git ref to checkout (optional)
	WorkspaceIsTemporary bool                  // true when workspace should be used directly (already prepared, no extra snapshot)

	// Agent config mount mode
	AgentConfigMode string // Agent config mount mode: "auto", "yes", "no"

	// Git configuration (already resolved by caller)
	// These values are pre-resolved using git.ResolveConfig() with proper priority:
	// host git config > ProjectConfig > env vars > defaults
	GitAuthorName  string // Git author name for commits
	GitAuthorEmail string // Git author email for commits

	// Skills configuration
	Skills []string // Paths to skill directories to include

	// Builtin skills configuration (optional, overrides embedded skills)
	BuiltinSkillsSource string // Remote source URL for builtin skills (e.g., "https://github.com/holon-run/holon/releases/download/v1.0.0/holon-skills-v1.0.0.zip")
	BuiltinSkillsRef    string // Version/ref tag for builtin skills (e.g., "v1.0.0")

	// Skill mode configuration
	UseSkillMode bool // True if using skill mode (agent handles collect/publish)

	// Runtime mode configuration
	RuntimeMode       string // Runtime mode: "prod" (default) or "dev"
	DevAgentSourceDir string // Local agent source directory for runtime-mode=dev (expects dist/)

	// Extra same-path host mounts configured by agent-home runtime policy.
	ExtraMounts []ExtraMount
}

type EnvConfig

type EnvConfig struct {
	UserEnv map[string]string
	HostUID int
	HostGID int
}

EnvConfig represents the environment configuration for a container

type ExtraMount added in v0.11.0

type ExtraMount struct {
	Path     string
	ReadOnly bool
}

ExtraMount defines a validated host path bind-mounted into the same path in container. Same-path mapping avoids host/container path ambiguity in user-agent conversations.

type HostConfigOptions added in v0.11.0

type HostConfigOptions struct {
	Mounts []mount.Mount
}

HostConfigOptions represents docker host configuration inputs.

type MountConfig

type MountConfig struct {
	SnapshotDir          string
	InputPath            string // Path to input directory (contains spec.yaml, context/, prompts/)
	OutDir               string
	StateDir             string // Path to state directory for cross-run skill caches (optional, for mounting)
	AgentHome            string // Path to agent home mounted to /root (optional, for persistent persona/state)
	LocalClaudeConfigDir string // Path to host ~/.claude directory (optional, for mounting)
	LocalSkillsDir       string // Path to skills staging directory (optional, for mounting)
	LocalAgentDistDir    string // Path to local agent dist directory for dev runtime mode (optional, for mounting)
	ExtraMounts          []ExtraMount
}

MountConfig represents the mount configuration for a container

type Runtime

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

func NewRuntime

func NewRuntime() (*Runtime, error)

func (*Runtime) RunHolon

func (r *Runtime) RunHolon(ctx context.Context, cfg *ContainerConfig) (string, error)

func (*Runtime) StartSession added in v0.11.0

func (r *Runtime) StartSession(ctx context.Context, cfg *ContainerConfig) (*SessionHandle, error)

StartSession starts a long-running Holon container session. Unlike RunHolon, this does not wait for completion or validate output artifacts.

func (*Runtime) StopSession added in v0.11.0

func (r *Runtime) StopSession(ctx context.Context, handle *SessionHandle) error

StopSession stops and removes a session container.

func (*Runtime) WaitSession added in v0.11.0

func (r *Runtime) WaitSession(ctx context.Context, handle *SessionHandle) error

WaitSession waits for a session container to exit.

type RuntimeMode added in v0.11.0

type RuntimeMode string

RuntimeMode controls how agent code is sourced in container runtime.

const (
	// RuntimeModeProd uses the bundled agent code in composed images.
	RuntimeModeProd RuntimeMode = "prod"
	// RuntimeModeDev overlays bundled agent code with local dist output.
	RuntimeModeDev RuntimeMode = "dev"
)

func ParseRuntimeMode added in v0.11.0

func ParseRuntimeMode(s string) (RuntimeMode, error)

func (RuntimeMode) String added in v0.11.0

func (m RuntimeMode) String() string

type SessionHandle added in v0.11.0

type SessionHandle struct {
	ContainerID     string
	SnapshotDir     string
	OwnsSnapshotDir bool
	SkillsDir       string
	// contains filtered or unexported fields
}

SessionHandle tracks a long-running runtime session container.

Jump to

Keyboard shortcuts

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