Documentation
¶
Overview ¶
Package runctx provides runtime context types and rendering for agent instruction files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
func Render(rc *RuntimeContext) string
Render produces a markdown document describing the runtime context. Sections for optional fields (Grants, Services, etc.) are only included when their corresponding slice is non-empty or pointer is non-nil.
Types ¶
type AllowedHost ¶ added in v0.4.0
type AllowedHost struct {
Host string
Rules []string // human-readable rule summaries, e.g. "allow GET /repos/*"
}
AllowedHost describes a host that the run is allowed to access, optionally with per-path rules that restrict specific methods/paths.
type AnthropicAPI ¶ added in v0.8.0
type AnthropicAPI struct {
// KeyEnv is the environment variable holding the (placeholder) API key.
KeyEnv string
}
AnthropicAPI describes shell-scoped Anthropic API access. It is only set when a run holds both the "claude" and "anthropic" grants, where the key is exported via BASH_ENV so Claude Code's own OAuth login is not overridden.
type BuildOptions ¶ added in v0.7.0
type BuildOptions struct {
// WorkspaceMode is the resolved workspace mode ("bind"/"volume"). Empty is
// treated as bind. Sourced from the resolved run options, not cfg, because a
// --workspace-mode CLI flag can override the moat.yaml value.
WorkspaceMode config.WorkspaceMode
// DockerMode is the resolved Docker mode ("host"/"dind"). Empty means Docker
// is not enabled for this run.
DockerMode deps.DockerMode
// AnthropicKeyEnv is the environment variable holding the shell-scoped
// Anthropic API key. Set only when the key is exported via BASH_ENV rather
// than container-wide (both "claude" and "anthropic" grants active). Empty
// means there is nothing special to explain.
AnthropicKeyEnv string
// OpenAIKeyEnv is the environment variable holding the shell-scoped OpenAI
// API key. Set only when the key is exported via BASH_ENV rather than
// container-wide (both "codex" and "openai" grants active). Empty means
// there is nothing special to explain.
OpenAIKeyEnv string
}
BuildOptions carries resolved run facts that are not derivable from the moat.yaml Config alone — they come from CLI overrides or runtime resolution at container-creation time.
type Docker ¶ added in v0.7.0
type Docker struct {
Mode string // "dind" (Docker-in-Docker) or "host" (mounted host socket)
}
Docker describes Docker access available inside the container.
type NetworkPolicy ¶
type NetworkPolicy struct {
Policy string
AllowedHosts []AllowedHost
}
NetworkPolicy describes the network access policy for the run.
type OpenAIAPI ¶ added in v0.8.0
type OpenAIAPI struct {
// KeyEnv is the environment variable holding the (placeholder) API key.
KeyEnv string
}
OpenAIAPI describes shell-scoped OpenAI API access. It is only set when a run holds both the "codex" and "openai" grants, where the key is exported via BASH_ENV so Codex's own subscription login is not switched to API billing.
type RuntimeContext ¶
type RuntimeContext struct {
RunID string
Agent string
Workspace string
WorkspaceMode string // "bind" or "volume"; empty is treated as bind
Grants []Grant
Services []Service
Tools []string // installed non-service, non-docker dependencies
Docker *Docker // non-nil when Docker access is available
Ports []Port
NetworkPolicy *NetworkPolicy
MCPServers []MCPServer
HasDependencies bool // true when the config declares any dependencies
// AnthropicAPI is non-nil when an Anthropic API key is available to shell
// commands but deliberately absent from the container environment.
AnthropicAPI *AnthropicAPI
// OpenAIAPI is non-nil when an OpenAI API key is available to shell
// commands but deliberately absent from the container environment.
OpenAIAPI *OpenAIAPI
}
RuntimeContext holds the information about a moat run that is rendered into agent instruction files (CLAUDE.md, AGENTS.md, etc.).
func BuildFromConfig ¶
func BuildFromConfig(cfg *config.Config, runID string, opts BuildOptions) *RuntimeContext
BuildFromConfig constructs a RuntimeContext from a moat config, run ID, and resolved run options. A nil cfg means the workspace has no moat.yaml. That is a valid run — grants can come entirely from --grant flags — and resolved facts in opts may still be worth rendering, so it is treated as an empty config rather than refused.