config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config handles moat.yaml manifest parsing.

Index

Constants

View Source
const (
	// RecordEvents records attach/detach, pin decisions, line settings, and
	// byte counters. It is the default.
	RecordEvents = "events"
	// RecordFull additionally captures the payload bytes. Serial carries
	// firmware images and device credentials, so it is opt-in.
	RecordFull = "full"
)

Record modes for a device session.

View Source
const ConfigFilename = "moat.yaml"

ConfigFilename is the preferred config file name.

View Source
const LegacyConfigFilename = "agent.yaml"

LegacyConfigFilename is the legacy config file name, supported as a fallback.

Variables

This section is empty.

Functions

func CheckVolumeRuntimeSupport added in v0.7.0

func CheckVolumeRuntimeSupport(vols []VolumeConfig, appleRuntime bool) error

CheckVolumeRuntimeSupport rejects `type: volume` entries when the effective container runtime is Apple's `container` CLI, which has no named-volume support.

It is called from both config load (when `runtime: apple` is explicit) and run setup (when the runtime is auto-detected) so the two validation points share one rule and error message and cannot drift.

func CreateProfile added in v0.9.0

func CreateProfile(name string, prof ProfileConfig) error

CreateProfile adds a profile without discarding comments or unrelated settings. It reads the YAML directly so malformed files are never replaced with defaults.

func DockerVolumeName added in v0.3.0

func DockerVolumeName(agentName, volumeName string) string

DockerVolumeName returns the Docker volume name for an agent volume. Format: moat_<agentName>_<volumeName>

func GlobalConfigDir

func GlobalConfigDir() string

GlobalConfigDir returns the path to the moat configuration directory.

By default this is ~/.moat, but the MOAT_HOME environment variable may override it to an absolute path. MOAT_HOME is the complete moat directory, not a parent containing .moat — set it to e.g. /tmp/moat-test, not /tmp. Primarily used for hermetic test runs and rare multi-version setups where one daemon must not see another's state.

func IsVolumeMode added in v0.7.0

func IsVolumeMode(mode string) bool

IsVolumeMode reports whether a stored/serialized workspace-mode string (e.g. run.Run.WorkspaceMode or storage.Metadata.WorkspaceMode, both plain strings) is volume mode. Centralizing the comparison avoids repeating the string(WorkspaceModeVolume) cast at every call site, where a single typo would silently diverge.

func ValidDeviceName added in v0.8.0

func ValidDeviceName(name string) bool

ValidDeviceName reports whether name is usable as a devices: entry name. Exported so `moat device rename` rejects a name at the point the user types it, rather than writing a pin that moat.yaml validation will later refuse.

func ValidateExcludes added in v0.4.0

func ValidateExcludes(excludes []string, target string) ([]string, error)

ValidateExcludes validates exclude paths on a MountEntry. Paths are normalized with filepath.Clean before validation. Returns the cleaned exclude list or an error.

func ValidateHTTPURL added in v0.8.0

func ValidateHTTPURL(raw string) (*url.URL, string, error)

ValidateHTTPURL parses raw and checks it names something a container can actually connect to: an http or https scheme and a non-empty hostname. It returns the parsed URL and its normalized string form.

It is shared by every place a user can name an LLM endpoint — moat.yaml's claude.base_url, `moat grant anthropic --base-url`, and the endpoint recorded on a credential — so the three cannot drift into disagreeing about what a usable endpoint is, nor produce different ANTHROPIC_BASE_URL values for the same endpoint.

Normalization strips trailing slashes, because callers join a path onto the result: "https://gw.example.com/" would otherwise yield "https://gw.example.com//v1/messages".

Hostname() is checked as well as Host because "http://:8080" has a non-empty Host but no hostname at all.

func ValidateNoGitExclude added in v0.7.0

func ValidateNoGitExclude(excludes []string) error

ValidateNoGitExclude rejects excluding .git (or any subpath) in volume mode. A partial .git is a broken repository, so volume-mode copy-in must always include the full .git directory.

func ValidateProfileName added in v0.8.0

func ValidateProfileName(name string) error

ValidateProfileName checks a profile name from the global config. It mirrors credential.ValidateProfile, which guards the --profile flag, so a name that is grantable is also configurable and vice versa. Duplicated rather than imported to keep config free of a dependency on credential.

func VolumeDir added in v0.3.0

func VolumeDir(agentName, volumeName string) string

VolumeDir returns the host directory for an agent volume. Path: ~/.moat/volumes/<agentName>/<volumeName>/

Callers must create the directory before mounting:

volDir := config.VolumeDir(agentName, volumeName)
if err := os.MkdirAll(volDir, 0755); err != nil { ... }

See internal/run/manager.go for usage.

Types

type ClaudeConfig

type ClaudeConfig struct {
	// BaseURL sets ANTHROPIC_BASE_URL inside the container, redirecting Claude
	// Code API traffic to a custom endpoint: an Anthropic-compatible gateway
	// (e.g. LunaRoute) or a host-side LLM proxy (e.g. Headroom).
	//
	// Traffic goes through the Moat proxy, which injects the anthropic or claude
	// grant's credential for the endpoint's host, so the key never enters the
	// container. A localhost URL is rewritten to the synthetic host-gateway
	// name and its port allowed, since the container cannot reach a host
	// service at its own loopback address.
	BaseURL string `yaml:"base_url,omitempty"`

	// SyncLogs enables mounting Claude's session logs directory so logs from
	// inside the container appear on the host at the correct project location.
	// Default: false, unless the "anthropic" grant is configured (then true).
	SyncLogs *bool `yaml:"sync_logs,omitempty"`

	// Plugins enables or disables specific plugins for this run.
	// Keys are in format "plugin-name@marketplace", values are true/false.
	Plugins map[string]bool `yaml:"plugins,omitempty"`

	// Marketplaces defines additional plugin marketplaces for this run.
	Marketplaces map[string]MarketplaceSpec `yaml:"marketplaces,omitempty"`

	// MCP defines MCP (Model Context Protocol) server configurations.
	MCP map[string]MCPServerSpec `yaml:"mcp,omitempty"`

	// SubscriptionType overrides the subscriptionType written to Claude Code's
	// .credentials.json (e.g. "pro", "max"). Setup-token and pasted-token grants
	// don't carry the plan, so moat defaults to "max"; set this to match your
	// plan. Imported grants use the real value unless this is set.
	SubscriptionType string `yaml:"subscription_type,omitempty"`

	// RateLimitTier overrides the rateLimitTier written to Claude Code's
	// .credentials.json (e.g. "default_claude_max_20x"). Optional; mainly affects
	// Claude Code's local rate-limit hints. Real plan limits are enforced
	// server-side via the proxy-injected token.
	RateLimitTier string `yaml:"rate_limit_tier,omitempty"`

	// LLMGateway configures a Keep LLM gateway sidecar inside the container.
	// Mutually exclusive with BaseURL.
	LLMGateway *LLMGatewayConfig `yaml:"llm-gateway,omitempty"`

	// SkipPermissionsPrompt controls whether to suppress the bypass-permissions
	// warning in Claude Code. Set automatically by moat when
	// --dangerously-skip-permissions is being passed. Not a moat.yaml field.
	SkipPermissionsPrompt bool `yaml:"-"`
}

ClaudeConfig configures Claude Code integration options.

type CodexConfig

type CodexConfig struct {
	// SyncLogs enables mounting a session directory so Codex transcripts
	// written inside the container appear on the host.
	// Default: false, unless the "openai" grant is configured (then true).
	SyncLogs *bool `yaml:"sync_logs,omitempty"`

	// SharedSessions mounts the host's own ~/.codex/sessions instead of the
	// per-workspace directory under ~/.moat/codex/sessions.
	//
	// Codex partitions sessions by date rather than by workspace and offers no
	// config key to relocate the directory, so sharing it exposes this host
	// user's Codex transcripts from every project to the container — including
	// projects whose transcripts may carry regulated or confidential data.
	// moat therefore isolates per workspace by default; set this to true only
	// when cross-project history in one place is worth that exposure.
	SharedSessions bool `yaml:"shared_sessions,omitempty"`

	// RequireApproval keeps Codex's own approval prompts and sandbox enabled
	// instead of moat's default of turning both off. Set automatically by moat
	// when `moat codex --noyolo` is used. Not a moat.yaml field.
	RequireApproval bool `yaml:"-"`

	// MCP defines MCP (Model Context Protocol) server configurations.
	MCP map[string]MCPServerSpec `yaml:"mcp,omitempty"`
}

CodexConfig configures OpenAI Codex CLI integration options.

type Config

type Config struct {
	Name         string            `yaml:"name,omitempty"`
	Agent        string            `` /* 177-byte string literal not displayed */
	Agents       []string          `` /* 249-byte string literal not displayed */
	Version      string            `yaml:"version,omitempty"`
	Dependencies []string          `yaml:"dependencies,omitempty"`
	Grants       []string          `yaml:"grants,omitempty"`
	Env          map[string]string `yaml:"env,omitempty"`
	Secrets      map[string]string `yaml:"secrets,omitempty"`
	Mounts       []MountEntry      `yaml:"mounts,omitempty"`
	Devices      []DeviceEntry     `` /* 179-byte string literal not displayed */
	Ports        map[string]int    `yaml:"ports,omitempty"`
	Network      NetworkConfig     `yaml:"network,omitempty"`
	Command      []string          `yaml:"command,omitempty"`
	Claude       ClaudeConfig      `yaml:"claude,omitempty"`
	Copilot      CopilotConfig     `yaml:"copilot,omitempty"`
	Codex        CodexConfig       `yaml:"codex,omitempty"`
	Gemini       GeminiConfig      `yaml:"gemini,omitempty"`
	Pi           PiConfig          `yaml:"pi,omitempty"`
	Interactive  bool              `yaml:"interactive,omitempty"`
	// Clipboard enables host clipboard bridging. Default true when nil.
	Clipboard *bool           `yaml:"clipboard,omitempty"`
	Snapshots SnapshotConfig  `yaml:"snapshots,omitempty"`
	Tracing   TracingConfig   `yaml:"tracing,omitempty"`
	Hooks     HooksConfig     `yaml:"hooks,omitempty"`
	Workspace WorkspaceConfig `yaml:"workspace,omitempty"`

	// Sandbox configures container sandboxing.
	// "none" disables gVisor sandbox (Docker only).
	// Empty string or omitted uses default (gVisor enabled).
	Sandbox string `yaml:"sandbox,omitempty"`

	// Runtime forces a specific container runtime ("docker" or "apple").
	// If not set, moat auto-detects the best available runtime.
	// Useful when agent needs docker:dind on macOS (Apple containers can't run dind).
	Runtime string `yaml:"runtime,omitempty"`

	Volumes         []VolumeConfig         `yaml:"volumes,omitempty"`
	Container       ContainerConfig        `yaml:"container,omitempty"`
	MCP             []MCPServerConfig      `yaml:"mcp,omitempty"`
	Services        map[string]ServiceSpec `yaml:"services,omitempty"`
	LanguageServers []string               `yaml:"language_servers,omitempty"`

	// BaseImage specifies a custom base image for the container.
	// Moat layers its infrastructure (user, entrypoint, etc.) on top.
	// Must be Debian-based (Ubuntu, Debian) since moat uses apt-get.
	BaseImage string `yaml:"base_image,omitempty"`

	// Deprecated: old runtime field for language versions
	DeprecatedRuntime *deprecatedRuntime `yaml:"-"`
}

Config represents a moat.yaml manifest.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration.

func Load

func Load(dir string) (*Config, error)

Load reads moat.yaml (or agent.yaml as fallback) from the given directory. Returns nil, nil if neither file exists.

func (*Config) ShouldSyncClaudeLogs

func (c *Config) ShouldSyncClaudeLogs() bool

ShouldSyncClaudeLogs returns true if Claude session logs should be synced. The logic is: - If claude.sync_logs is explicitly set, use that value - Otherwise, enable sync_logs if "anthropic" is in grants (Claude Code integration)

func (*Config) ShouldSyncCodexLogs

func (c *Config) ShouldSyncCodexLogs() bool

ShouldSyncCodexLogs returns true if Codex session transcripts should be synced. The logic is: - If codex.sync_logs is explicitly set, use that value - Otherwise, enable sync_logs if "codex" or "openai" is in grants

func (*Config) ShouldSyncGeminiLogs

func (c *Config) ShouldSyncGeminiLogs() bool

ShouldSyncGeminiLogs returns true if Gemini session logs should be synced. The logic is: - If gemini.sync_logs is explicitly set, use that value - Otherwise, enable sync_logs if "gemini" is in grants (Gemini integration)

func (*Config) ShouldSyncPiLogs added in v0.9.0

func (c *Config) ShouldSyncPiLogs() bool

ShouldSyncPiLogs returns true only when Pi transcript syncing is requested.

func (*Config) ValidateServices

func (c *Config) ValidateServices(serviceNames []string) error

ValidateServices checks that services: keys correspond to declared service dependencies.

type ContainerConfig

type ContainerConfig struct {
	// Memory specifies the memory limit in megabytes.
	// Applies to both Docker and Apple containers.
	// If not set, Apple containers default to 8192 MB (8 GB) for AI agent
	// runs (claude/codex/gemini), or 4096 MB (4 GB) otherwise.
	// Docker containers have no default limit.
	//
	// Example:
	//   container:
	//     memory: 8192  # 8 GB
	Memory int `yaml:"memory,omitempty"`

	// CPUs specifies the number of CPUs.
	// Applies to both Docker and Apple containers.
	// If not set, uses runtime defaults.
	//
	// Example:
	//   container:
	//     cpus: 8
	CPUs int `yaml:"cpus,omitempty"`

	// DNS specifies DNS servers for both runtime containers and builders.
	// Applies to both Docker and Apple containers.
	// If not set, defaults to ["8.8.8.8", "8.8.4.4"] (Google DNS).
	//
	// Example:
	//   container:
	//     dns: ["192.168.1.1", "1.1.1.1"]
	//
	// Note: Using public DNS will send queries to that provider,
	// potentially leaking information about your dependencies and internal services.
	DNS []string `yaml:"dns,omitempty"`

	// Ulimits specifies resource limits (ulimits) for the container.
	// Applies to both Docker and Apple containers.
	// Keys are ulimit names (e.g., "nofile", "nproc", "memlock").
	// Values specify soft and hard limits. Use -1 for unlimited.
	//
	// Example:
	//   container:
	//     ulimits:
	//       nofile:
	//         soft: 1024
	//         hard: 65536
	Ulimits map[string]UlimitSpec `yaml:"ulimits,omitempty"`
}

ContainerConfig configures container resource limits and settings. These settings apply to both Docker and Apple container runtimes.

type CopilotConfig added in v0.7.0

type CopilotConfig struct {
	// Model optionally selects the model passed to `copilot --model`.
	Model string `yaml:"model,omitempty"`

	// Context sets the context window tier passed to `copilot --context`.
	// Valid values: "default", "long_context".
	Context string `yaml:"context,omitempty"`

	// ReasoningEffort sets the reasoning effort level passed to `copilot --reasoning-effort`.
	// Valid values: "none", "minimal", "low", "medium", "high", "xhigh", "max".
	ReasoningEffort string `yaml:"reasoning_effort,omitempty"`

	// Experimental starts Copilot CLI with --experimental.
	Experimental bool `yaml:"experimental,omitempty"`

	// Autopilot starts Copilot CLI in autopilot mode.
	Autopilot bool `yaml:"autopilot,omitempty"`
}

CopilotConfig configures GitHub Copilot CLI integration options.

type DebugConfig

type DebugConfig struct {
	RetentionDays int `yaml:"retention_days"`
}

DebugConfig holds debug logging settings.

type DeviceEntry added in v0.8.0

type DeviceEntry struct {
	// Name is the device's name in moat.yaml. It determines how the container
	// addresses the device: MOAT_SERIAL_<NAME>_URL carries its rfc2217://
	// endpoint.
	Name string `yaml:"name"`

	// Match selects which attached device this entry refers to. The specific
	// device is pinned on first use; see internal/serialdev.
	Match DeviceMatch `yaml:"match"`

	// Baud optionally sets the initial line rate. Tools normally set their own.
	Baud int `yaml:"baud,omitempty"`

	// Record is "events" (default) or "full".
	Record string `yaml:"record,omitempty"`
}

DeviceEntry requests access to one serial device.

func (DeviceEntry) RecordMode added in v0.8.0

func (d DeviceEntry) RecordMode() string

RecordMode returns the effective record mode, applying the default.

func (DeviceEntry) VIDPID added in v0.8.0

func (d DeviceEntry) VIDPID() (string, string)

VIDPID returns the match's vendor and product IDs, lowercased, for device resolution. Callers have validated the format already.

type DeviceMatch added in v0.8.0

type DeviceMatch struct {
	USB string `yaml:"usb"`

	// Interface picks one UART of a multi-interface bridge (FT2232H, CP2105,
	// ESP-Prog): one USB device, several ttys, identical USB IDs. It is the
	// interface number moat device list shows for each port. Empty matches
	// single-UART devices unchanged.
	Interface string `yaml:"interface,omitempty"`
}

DeviceMatch selects a host device by its USB ID. The value is the exact `vid:pid` pair the device list prints, so a row can be copied into moat.yaml without splitting it.

type GeminiConfig

type GeminiConfig struct {
	// SyncLogs enables mounting Gemini's session logs directory so logs from
	// inside the container appear on the host at the correct project location.
	// Default: false, unless the "gemini" grant is configured (then true).
	SyncLogs *bool `yaml:"sync_logs,omitempty"`

	// MCP defines MCP (Model Context Protocol) server configurations.
	MCP map[string]MCPServerSpec `yaml:"mcp,omitempty"`
}

GeminiConfig configures Google Gemini CLI integration options.

type GlobalConfig

type GlobalConfig struct {
	Proxy  ProxyConfig  `yaml:"proxy"`
	Debug  DebugConfig  `yaml:"debug"`
	Mounts []MountEntry `yaml:"mounts,omitempty"`

	// Profiles holds per-credential-profile settings, keyed by profile name.
	// They apply to any run using that profile (--profile / MOAT_PROFILE).
	Profiles map[string]ProfileConfig `yaml:"profiles,omitempty"`
}

GlobalConfig holds global Moat settings from ~/.moat/config.yaml.

func DefaultGlobalConfig

func DefaultGlobalConfig() *GlobalConfig

DefaultGlobalConfig returns the default global configuration.

func LoadGlobal

func LoadGlobal() (*GlobalConfig, error)

LoadGlobal reads the moat global config file and applies environment overrides. The config path is <GlobalConfigDir>/config.yaml — by default ~/.moat/config.yaml, or $MOAT_HOME/config.yaml when MOAT_HOME is set.

The returned config is ALWAYS usable, never nil, even when the error is non-nil: a validation failure yields defaults plus the error. A personal config file is not worth crashing an unrelated command over, and several callers legitimately ignore the error and read a field (the root command's debug settings, the routing proxy port). Callers that want to tell the user should report the error; callers that just need a value can use the config as-is. Malformed YAML already behaved this way.

func (*GlobalConfig) ProfileChain added in v0.9.0

func (c *GlobalConfig) ProfileChain(name string) ([]string, error)

ProfileChain returns the lookup order, including the requested profile. The empty string denotes the default store, which has no parent or env.

func (*GlobalConfig) ProfileEnv added in v0.8.0

func (c *GlobalConfig) ProfileEnv(name string) map[string]string

ProfileEnv returns the environment variables configured for a credential profile, or nil when the profile has none. An empty name (no --profile) never matches: the default store is not a named profile, so there is nowhere to hang settings and a `profiles:` entry cannot accidentally apply to every run.

func (*GlobalConfig) ProfileExists added in v0.9.0

func (c *GlobalConfig) ProfileExists(name string) (bool, error)

ProfileExists includes profiles created implicitly by granting credentials.

type HooksConfig

type HooksConfig struct {
	// PostBuild runs as the container user (moatuser) during image build,
	// after all dependencies are installed. Baked into image layers and cached.
	// Use for user-level image setup like configuring git defaults.
	PostBuild string `yaml:"post_build,omitempty"`

	// PostBuildRoot runs as root during image build, after all dependencies
	// are installed. Baked into image layers and cached.
	// Use for system-level setup like installing packages or kernel tuning.
	PostBuildRoot string `yaml:"post_build_root,omitempty"`

	// PreRun runs as the container user (moatuser) in /workspace on every
	// container start, before the main command. Use for workspace-level
	// setup that needs project files (e.g., "npm install").
	PreRun string `yaml:"pre_run,omitempty"`
}

HooksConfig configures lifecycle hooks that run at different stages.

type LLMGatewayConfig added in v0.5.0

type LLMGatewayConfig struct {
	Policy *keep.PolicyConfig `yaml:"policy,omitempty"`
}

LLMGatewayConfig configures Keep LLM policy evaluation in the proxy. When configured, the proxy evaluates tool_use blocks in Anthropic API responses against Keep rules before forwarding to the container.

type MCPAuthConfig

type MCPAuthConfig struct {
	Grant  string `yaml:"grant"`
	Header string `yaml:"header"`
}

MCPAuthConfig defines authentication for an MCP server. It specifies which grant credential to use and which HTTP header to inject it into when proxying requests to the MCP server.

type MCPServerConfig

type MCPServerConfig struct {
	Name   string             `yaml:"name"`
	URL    string             `yaml:"url"`
	Auth   *MCPAuthConfig     `yaml:"auth,omitempty"`
	Policy *keep.PolicyConfig `yaml:"policy,omitempty"`
}

MCPServerConfig defines an MCP server configuration for top-level MCP servers in moat.yaml. It specifies the server name, URL endpoint, and optional authentication settings for credential injection.

Supports both remote HTTPS servers and host-local HTTP servers. Host-local servers (http://localhost, http://127.0.0.1, or http://[::1]) are reached through the proxy relay, which runs on the host and can connect to host-local services that the container cannot reach directly.

func (*MCPServerConfig) UnmarshalYAML added in v0.6.0

func (m *MCPServerConfig) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML lets an mcp[] entry be either a bare service name (string) or a full mapping. A bare string resolves its url/auth from the well-known catalog during config load (see resolveMCPShorthand).

type MCPServerSpec

type MCPServerSpec struct {
	// Command is the executable to run
	Command string `yaml:"command"`

	// Args are command-line arguments
	Args []string `yaml:"args,omitempty"`

	// Env are environment variables for the server
	Env map[string]string `yaml:"env,omitempty"`

	// Grant specifies a credential grant to inject (e.g., "github", "anthropic")
	Grant string `yaml:"grant,omitempty"`

	// Cwd is the working directory for the server
	Cwd string `yaml:"cwd,omitempty"`
}

MCPServerSpec defines an MCP server configuration.

type MarketplaceSpec

type MarketplaceSpec struct {
	// Source is the type of marketplace: "github", "git", or "directory"
	Source string `yaml:"source"`

	// Repo is the GitHub repository in "owner/repo" format (for source: github)
	Repo string `yaml:"repo,omitempty"`

	// URL is the git URL (for source: git)
	// Supports both HTTPS (https://github.com/org/repo.git) and
	// SSH (git@github.com:org/repo.git) URLs
	URL string `yaml:"url,omitempty"`

	// Path is the local directory path (for source: directory)
	Path string `yaml:"path,omitempty"`
}

MarketplaceSpec defines a plugin marketplace source.

type MountEntry added in v0.4.0

type MountEntry struct {
	Source   string   `yaml:"source"`
	Target   string   `yaml:"target"`
	Mode     string   `yaml:"mode,omitempty"`
	ReadOnly bool     `yaml:"-"`
	Exclude  []string `yaml:"exclude,omitempty"`
}

MountEntry represents a mount configuration. It supports two YAML forms: - String: "source:target[:mode]" (existing format) - Object: {source, target, mode, exclude} (new format with exclude support)

func ParseMount

func ParseMount(s string) (*MountEntry, error)

ParseMount parses a mount string like "./data:/data:ro". This is the public API used by the run manager for --mount CLI flags.

func (*MountEntry) UnmarshalYAML added in v0.4.0

func (m *MountEntry) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML handles both string and object forms in a mixed-type YAML array.

type NetworkConfig

type NetworkConfig struct {
	Policy     string                      `yaml:"policy,omitempty"` // "permissive" or "strict", default "permissive"
	Allow      []string                    `yaml:"allow,omitempty"`  // deprecated: hard error
	Rules      []netrules.NetworkRuleEntry `yaml:"rules,omitempty"`
	KeepPolicy *keep.PolicyConfig          `yaml:"keep_policy,omitempty"`
	Host       []int                       `yaml:"host,omitempty"` // TCP ports on the host the container may access
}

NetworkConfig configures network access policies for the agent.

type PiConfig added in v0.7.0

type PiConfig struct {
	Provider string   `yaml:"provider,omitempty"`
	Model    string   `yaml:"model,omitempty"`
	Packages []string `yaml:"packages,omitempty"`
	// SyncLogs persists Pi transcripts in a per-workspace host directory.
	// Opt-in: backend grants alone do not enable Pi session sharing.
	SyncLogs *bool `yaml:"sync_logs,omitempty"`
}

PiConfig configures the Pi coding agent integration.

Pi has no credential of its own; it runs against the anthropic or openai grant. Provider selects the backend (must be "anthropic" or "openai" in v1); when unset it is inferred from the single configured grant. Model optionally pins a model pattern (the first available model for the backend is used when empty).

type ProfileConfig added in v0.8.0

type ProfileConfig struct {
	// Inherit names a parent profile; InheritDefault selects the unscoped store.
	// These are mutually exclusive, so a named profile called "default" remains valid.
	Inherit        string `yaml:"inherit,omitempty"`
	InheritDefault bool   `yaml:"inherit_default,omitempty"`

	// Env are environment variables set in the container for any run using
	// this profile. moat.yaml env and -e flags override them; proxy variables
	// moat owns are filtered out, exactly as for the other two layers.
	Env map[string]string `yaml:"env,omitempty"`
}

ProfileConfig holds settings that apply to every run using a credential profile. A profile is an identity — a set of credentials plus whatever configuration goes with them — so settings that belong to the identity rather than to a project live here instead of in each moat.yaml.

type ProxyConfig

type ProxyConfig struct {
	Port int `yaml:"port"`
}

ProxyConfig holds reverse proxy settings.

type ServiceSpec

type ServiceSpec struct {
	Env    map[string]string `yaml:"env,omitempty"`
	Image  string            `yaml:"image,omitempty"`
	Wait   *bool             `yaml:"wait,omitempty"`
	Memory int               `yaml:"memory,omitempty"` // Memory limit in MB for the service container (0 = runtime default)
	// Extra holds unknown list-valued keys (e.g., "models" for ollama).
	// Populated by UnmarshalYAML. The run layer maps these to provisions
	// using the registry's provisions_key.
	Extra map[string][]string `yaml:"-"`
}

ServiceSpec allows customizing service behavior.

func (ServiceSpec) ServiceWait

func (s ServiceSpec) ServiceWait() bool

ServiceWait returns whether to wait for this service to be ready (default: true).

func (*ServiceSpec) UnmarshalYAML added in v0.4.0

func (s *ServiceSpec) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom unmarshaling to capture unknown list-valued keys into Extra. Known keys (env, image, wait) are parsed normally.

type SnapshotConfig

type SnapshotConfig struct {
	Disabled  bool                    `yaml:"disabled,omitempty"`
	Triggers  SnapshotTriggerConfig   `yaml:"triggers,omitempty"`
	Exclude   SnapshotExcludeConfig   `yaml:"exclude,omitempty"`
	Retention SnapshotRetentionConfig `yaml:"retention,omitempty"`
}

SnapshotConfig configures workspace snapshots.

type SnapshotExcludeConfig

type SnapshotExcludeConfig struct {
	IgnoreGitignore bool     `yaml:"ignore_gitignore,omitempty"`
	Additional      []string `yaml:"additional,omitempty"`
}

SnapshotExcludeConfig configures what to exclude from snapshots.

type SnapshotRetentionConfig

type SnapshotRetentionConfig struct {
	MaxCount      int  `yaml:"max_count,omitempty"`
	DeleteInitial bool `yaml:"delete_initial,omitempty"`
}

SnapshotRetentionConfig configures snapshot retention.

type SnapshotTriggerConfig

type SnapshotTriggerConfig struct {
	DisablePreRun        bool `yaml:"disable_pre_run,omitempty"`
	DisableGitCommits    bool `yaml:"disable_git_commits,omitempty"`
	DisableBuilds        bool `yaml:"disable_builds,omitempty"`
	DisableIdle          bool `yaml:"disable_idle,omitempty"`
	IdleThresholdSeconds int  `yaml:"idle_threshold_seconds,omitempty"`
}

SnapshotTriggerConfig configures when snapshots are created.

type TracingConfig

type TracingConfig struct {
	DisableExec bool `yaml:"disable_exec,omitempty"`
}

TracingConfig configures execution tracing.

type UlimitSpec added in v0.3.2

type UlimitSpec struct {
	Soft int64 `yaml:"soft"`
	Hard int64 `yaml:"hard"`
}

UlimitSpec defines a resource limit with soft and hard values. Use -1 for unlimited.

type VolumeConfig added in v0.3.0

type VolumeConfig struct {
	Name     string `yaml:"name"`
	Target   string `yaml:"target"`
	ReadOnly bool   `yaml:"readonly,omitempty"`
	// Type selects the backing store: "bind" (default) is a host bind mount at
	// ~/.moat/volumes/<agent>/<name> (visible on the host; crosses the host↔VM
	// filesystem-sharing layer on VM-based runtimes). "volume" is a Docker named
	// volume on the engine's native filesystem (not host-visible; bypasses that
	// layer). Docker runtime only.
	Type string `yaml:"type,omitempty"`
}

VolumeConfig defines a named volume to mount inside the container. Volumes are managed by moat and persist across runs for the same agent name.

func (VolumeConfig) IsNamedVolume added in v0.7.0

func (v VolumeConfig) IsNamedVolume() bool

IsNamedVolume reports whether the entry is backed by a native Docker named volume (type: volume) rather than the default host bind mount (type: bind or ""). This is the single source of truth for the predicate — validation, image-init gating, and mount construction all route through it so they cannot drift.

type WorkspaceConfig added in v0.7.0

type WorkspaceConfig struct {
	// Mode is "bind" (default) or "volume". Empty means bind.
	Mode WorkspaceMode `yaml:"mode,omitempty"`
}

WorkspaceConfig is the moat.yaml `workspace:` block.

func (WorkspaceConfig) Validate added in v0.7.0

func (w WorkspaceConfig) Validate() error

Validate rejects any mode other than "", "bind", or "volume".

type WorkspaceMode added in v0.7.0

type WorkspaceMode string

WorkspaceMode selects how the host working tree is presented to the container.

const (
	// WorkspaceModeBind bind-mounts the host tree at /workspace (default, current behavior).
	WorkspaceModeBind WorkspaceMode = "bind"
	// WorkspaceModeVolume copies the host tree into an ephemeral Docker named volume.
	WorkspaceModeVolume WorkspaceMode = "volume"
)

func ResolveWorkspaceMode added in v0.7.0

func ResolveWorkspaceMode(w WorkspaceConfig, override string) (WorkspaceMode, error)

ResolveWorkspaceMode applies precedence: CLI override > yaml > default(bind). override is the raw --workspace-mode flag value ("" when unset). It also validates w.Mode, so it is safe to call without a prior Load().

Jump to

Keyboard shortcuts

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