driver

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunPlaceholderTask        = "{{claw.run.task}}"
	RunPlaceholderSession     = "{{claw.run.session}}"
	RunPlaceholderCllamaToken = "{{claw.run.cllama_token}}"
)

Run placeholders are substituted by the run supervisor at launch. They only ever appear as complete values inside RunWorkerSpec.Inputs.

Variables

This section is empty.

Functions

func DeterministicInvocationID added in v0.5.2

func DeterministicInvocationID(serviceName string, origin InvocationOrigin, scheduleExpr, message string) string

func Register

func Register(name string, d Driver)

func Registered added in v0.10.0

func Registered() map[string]Driver

func RetirementError added in v0.28.0

func RetirementError(name string) error

RetirementError returns the canonical migration error for a retired runner. Other unknown names return nil and keep the generic unknown-driver path.

Types

type BaseImageProvider added in v0.2.0

type BaseImageProvider interface {
	BaseImage() (tag string, dockerfile string)
}

BaseImageProvider is optionally implemented by drivers that can auto-build their base image when it's not available locally.

type ChannelConfig

type ChannelConfig struct {
	Guilds            map[string]ChannelGuildConfig // guild ID → routing config
	DM                ChannelDMConfig
	AllowFromHandles  bool     // append all declared platform handles to each guild users[] allowlist
	AllowFromServices []string // append Discord bot IDs derived from these pod service envs
}

ChannelConfig is the full routing config declared in a map-form channel surface. Non-nil only when the pod declares map form (channel://discord: {...}).

type ChannelDMConfig

type ChannelDMConfig struct {
	Enabled   bool
	Policy    string   // "pairing", "allowlist", "open", "disabled", or "" (legacy "denylist" alias supported)
	AllowFrom []string // user IDs allowed to DM the bot
}

ChannelDMConfig is the DM routing config for a channel surface.

type ChannelGuildConfig

type ChannelGuildConfig struct {
	Policy         string   // "allowlist", "denylist", or "" (inherit platform default)
	Users          []string // user IDs for the policy list
	RequireMention bool
}

ChannelGuildConfig is the routing config for one guild in a channel surface.

type ChannelInfo

type ChannelInfo struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
}

ChannelInfo describes a single channel within a guild.

type ContainerRef

type ContainerRef struct {
	ContainerID string
	ServiceName string
}

type DirectTurnWaker added in v0.29.0

type DirectTurnWaker interface {
	WakeHelper() string
	InvocationTimeoutSeconds(*ResolvedClaw) (int, error)
}

DirectTurnWaker opts a runner into compiler-owned scheduling and bounded direct turns, independently of the lifecycle Driver interface.

type Driver

type Driver interface {
	Validate(rc *ResolvedClaw) error
	Materialize(rc *ResolvedClaw, opts MaterializeOpts) (*MaterializeResult, error)
	PostApply(rc *ResolvedClaw, opts PostApplyOpts) error
	HealthProbe(ref ContainerRef) (*Health, error)
}

Driver translates Clawfile intent into runner-specific enforcement. Fail-closed: Validate runs before compose up, PostApply runs after.

func Lookup

func Lookup(name string) (Driver, error)

type GeneratedSkill

type GeneratedSkill struct {
	Name    string // filename (e.g., "surface-fleet-master.md")
	Content []byte // skill file content
}

type GuildInfo

type GuildInfo struct {
	ID       string        `json:"id"`
	Name     string        `json:"name,omitempty"`
	Channels []ChannelInfo `json:"channels,omitempty"`
}

GuildInfo describes one guild/server/workspace membership.

type HandleInfo

type HandleInfo struct {
	ID       string      `json:"id"`
	Username string      `json:"username,omitempty"`
	Guilds   []GuildInfo `json:"guilds,omitempty"`
}

HandleInfo is the full contact card for an agent on a platform. Enables sibling services to mention, message, and route to this agent.

type Health

type Health struct {
	OK     bool
	Detail string
}

type Healthcheck

type Healthcheck struct {
	StartPeriod string
	Test        []string
	Interval    string
	Timeout     string
	Retries     int
}

type HermesConfig added in v0.14.1

type HermesConfig struct {
	AllowTools  []string
	AllowSilent bool
}

type Invocation

type Invocation struct {
	ID       string           `json:"id,omitempty"`
	Schedule string           // 5-field cron expression (e.g., "15 8 * * 1-5")
	Message  string           // agent task payload (agentTurn message)
	Channel  string           `json:"channel,omitempty"` // resolved delivery platform
	To       string           // platform delivery target (channel/chat ID; empty = driver default behavior)
	Name     string           // human-readable job name (optional, derived from message if empty)
	Origin   InvocationOrigin `json:"origin,omitempty"`
	When     *schedule.When   `json:"when,omitempty"`
}

Invocation is a scheduled agent task resolved from image labels or pod x-claw.invoke.

type InvocationOrigin added in v0.5.2

type InvocationOrigin string
const (
	OriginImage InvocationOrigin = "image"
	OriginPod   InvocationOrigin = "pod"
)

type MaterializeOpts

type MaterializeOpts struct {
	RuntimeDir string // host directory for generated artifacts
	StateDir   string // host directory for durable writable state
	PodName    string // pod name for context injection (CLAWDAPUS.md)
}

type MaterializeResult

type MaterializeResult struct {
	Mounts          []Mount
	Tmpfs           []string          // paths needing tmpfs (for read_only: true)
	Environment     map[string]string // additional env vars
	User            string            // optional compose user override (lower priority than explicit compose user)
	Healthcheck     *Healthcheck
	ReadOnly        bool   // default: true
	Restart         string // default: "on-failure"
	StopGracePeriod string // optional driver default; explicit compose value wins
	SkillDir        string // container path for skills (e.g., "/claw/skills")
	SkillLayout     string // "" (flat, default) or "directory" (Claude Code: skills/name/SKILL.md)
}

MaterializeResult describes what the compose generator must add to the service.

type Mount

type Mount struct {
	HostPath          string
	HostPathByService map[string]string // optional host path override keyed by emitted compose service name
	ContainerPath     string
	ReadOnly          bool
}

type PostApplyOpts

type PostApplyOpts struct {
	ContainerID string
}

type ResolvedClaw

type ResolvedClaw struct {
	ServiceName     string
	ImageRef        string
	ClawType        string
	Agent           string                            // filename from image labels (e.g., "AGENTS.md")
	AgentHostPath   string                            // resolved host path for bind mount
	Persona         string                            // runtime persona ref from x-claw or image metadata
	PersonaHostPath string                            // resolved host path for persona workspace mount
	Models          map[string]string                 // slot -> provider/model
	Handles         map[string]*HandleInfo            // platform -> contact card (from x-claw handles block)
	PeerHandles     map[string]map[string]*HandleInfo // service name -> platform -> HandleInfo for sibling services
	Includes        []ResolvedInclude                 // composed contract fragments from x-claw.include
	Feeds           []ResolvedFeed
	Surfaces        []ResolvedSurface
	Skills          []ResolvedSkill
	Privileges      map[string]string
	Configures      []string          // openclaw config set commands from labels
	Invocations     []Invocation      // scheduled agent tasks from image labels + pod x-claw.invoke
	Count           int               // from pod x-claw (default 1)
	Environment     map[string]string // from pod environment block
	RuntimeEnv      map[string]string // compose interpolation context: pod .env plus process env
	Timezone        string            // resolved service timezone from TZ env (falls back to UTC)
	Cllama          []string          // ordered cllama proxy types (e.g., ["passthrough"])
	CllamaToken     string            // per-agent bearer token injected when cllama is active
	Hermes          *HermesConfig     // Hermes-specific pod config
}

ResolvedClaw combines image-level claw labels with pod-level x-claw overrides.

type ResolvedFeed added in v0.3.5

type ResolvedFeed struct {
	Name        string
	Source      string
	Path        string
	TTL         int
	Description string
}

type ResolvedInclude added in v0.2.0

type ResolvedInclude struct {
	ID          string
	Mode        string
	Description string
	HostPath    string
	SkillName   string // set for reference includes mounted into the skill directory
}

type ResolvedSkill

type ResolvedSkill struct {
	Name     string // basename (e.g., "custom-workflow.md")
	HostPath string // resolved absolute host path
}

type ResolvedSurface

type ResolvedSurface struct {
	Scheme        string              // channel, service, volume, host, egress
	Target        string              // discord, fleet-master, shared-cache, etc.
	AccessMode    string              // read-only, read-write (for volume/host surfaces)
	Ports         []string            // exposed ports from service definition (service surfaces only)
	SkillName     string              // mounted skill filename for this surface when one exists
	ServiceInfo   *ServiceSurfaceInfo // non-nil when a service surface has descriptor metadata
	ChannelConfig *ChannelConfig      // non-nil only for map-form channel surfaces
}

type RunResultContract added in v0.29.0

type RunResultContract struct {
	// Source is "stdout".
	Source string `json:"source"`
	// Marker, when set, starts the answer: the answer is everything after the
	// first occurrence of Marker in the stream, minus one trailing newline.
	Marker string `json:"marker,omitempty"`
}

RunResultContract describes how the supervisor extracts a worker's answer.

type RunWorkerCompiler added in v0.29.0

type RunWorkerCompiler interface {
	ValidateRunWorker(rc *ResolvedClaw) error
	CompileRunWorker(rc *ResolvedClaw, opts RunWorkerOpts) (*RunWorkerSpec, error)
}

RunWorkerCompiler is optionally implemented by drivers that can run as a one-shot per-run worker (x-claw.lifecycle: per-run). Validation is separate from Validate so long-lived service requirements are never weakened.

type RunWorkerOpts added in v0.29.0

type RunWorkerOpts struct {
	PodName string
}

type RunWorkerSpec added in v0.29.0

type RunWorkerSpec struct {
	// Entrypoint and Command are pinned; the image ENTRYPOINT is overridden.
	// Command elements may reference inputs as ${NAME} Compose interpolations.
	Entrypoint []string `json:"entrypoint"`
	Command    []string `json:"command,omitempty"`
	// Environment holds static, non-secret container env.
	Environment map[string]string `json:"environment,omitempty"`
	// Inputs maps a container env name to a value template. Templates may embed
	// run placeholders. Inputs are interpolated, never written to disk.
	Inputs map[string]string `json:"inputs"`
	// Tmpfs mounts are the only writable paths; the root filesystem is read-only.
	Tmpfs []string `json:"tmpfs"`
	// Result describes where the worker reports its answer.
	Result RunResultContract `json:"result"`
}

RunWorkerSpec is the secret-free, driver-compiled process contract for a per-run worker. The supervisor never interprets driver configuration: it substitutes placeholders into Inputs and passes each input to the container through Compose interpolation, so no task text or secret is written into the rendered project file.

type RunnerBaseProvider added in v0.10.0

type RunnerBaseProvider interface {
	BaseImageProvider
	RunnerAlias() string
}

RunnerBaseProvider is optionally implemented by drivers whose base image is a synthetic local alias refreshed from upstream sources.

type RunnerVersionProber added in v0.10.0

type RunnerVersionProber interface {
	RunnerVersionProbe() []string
}

RunnerVersionProber is optionally implemented by RunnerBaseProvider drivers that can report the installed upstream runner version.

type ServiceEndpoint added in v0.3.5

type ServiceEndpoint struct {
	Method      string
	Path        string
	Description string
}

type ServiceSurfaceInfo added in v0.3.5

type ServiceSurfaceInfo struct {
	Description string
	AuthType    string
	AuthEnv     string
	Endpoints   []ServiceEndpoint
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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