config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config loads pocketagent's YAML config file.

The config knows the shape shared by every agent and speech provider, but not their individual settings: those are kept as Options and decoded by the implementation that owns them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHome

func DefaultHome() string

DefaultHome is $POCKETAGENT_HOME or ~/.pocketagent.

func DefaultPath

func DefaultPath() string

DefaultPath is the config file inside DefaultHome.

func ExpandHome

func ExpandHome(p string) string

ExpandHome replaces a leading ~ with the user's home directory.

Types

type Agent

type Agent struct {
	Type    string   `yaml:"type"`
	Command Command  `yaml:"command"`
	Wrap    Command  `yaml:"wrap"`
	Env     []string `yaml:"env"`
	Model   string   `yaml:"model"`  // default model
	Models  []string `yaml:"models"` // offered in the model picker

	Options Options `yaml:"-"`
}

Agent is one configured agent. Keys other than the common ones below are the adapter's own options.

func (Agent) Spec added in v0.6.0

func (a Agent) Spec(name string) agent.Spec

Spec converts the config entry into what an adapter is built from.

func (*Agent) UnmarshalYAML added in v0.6.0

func (a *Agent) UnmarshalYAML(n *yaml.Node) error

type Budget

type Budget struct {
	DailyUSD float64 `yaml:"daily_usd"` // per user; 0 means unlimited
}

type Command

type Command []string

Command accepts either a string ("aider --yes") or a list (["npx", "-y", "pkg"]).

func (*Command) UnmarshalYAML

func (c *Command) UnmarshalYAML(n *yaml.Node) error

type Config

type Config struct {
	Telegram    Telegram           `yaml:"telegram"`
	Defaults    Defaults           `yaml:"defaults"`
	Permissions Permissions        `yaml:"permissions"`
	Agents      map[string]Agent   `yaml:"agents"`
	Projects    map[string]Project `yaml:"projects"`
	Transcriber Provider           `yaml:"transcriber"`
	TTS         Provider           `yaml:"tts"`
	Budget      Budget             `yaml:"budget"`
	Output      Output             `yaml:"output"`
	Checkpoints *bool              `yaml:"checkpoints"`
	// BridgeHost is how agents reach pocketagent's tool server. Set it to
	// host.docker.internal when agents run in containers.
	BridgeHost string `yaml:"bridge_host"`

	// Home holds state, logs and uploads: the directory of the config file.
	Home string `yaml:"-"`
	Path string `yaml:"-"`
}

func Load

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

Load reads and validates the config at path. ${VAR} references are replaced with environment variables, so secrets can live outside the file.

func Parse added in v0.6.0

func Parse(raw []byte, path string) (*Config, error)

Parse reads a config from YAML; path determines Home.

func (*Config) AgentNames

func (c *Config) AgentNames() []string

AgentNames returns configured agent names, sorted.

func (*Config) CheckpointsEnabled

func (c *Config) CheckpointsEnabled() bool

CheckpointsEnabled reports whether git checkpoints are on (default true).

func (*Config) ProjectNames

func (c *Config) ProjectNames() []string

ProjectNames returns configured project names, sorted.

type Defaults

type Defaults struct {
	Agent string     `yaml:"agent"`
	Cwd   string     `yaml:"cwd"`
	Mode  agent.Mode `yaml:"mode"`
}

type Duration

type Duration time.Duration

Duration accepts Go duration strings like "10m".

func (Duration) D

func (d Duration) D() time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(n *yaml.Node) error

type Options added in v0.6.0

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

Options holds implementation-specific keys from a YAML mapping.

func OptionsFrom added in v0.6.0

func OptionsFrom(m map[string]any) Options

OptionsFrom builds Options from a map, for tests and generated configs.

func (Options) Decode added in v0.6.0

func (o Options) Decode(v any) error

Decode fills v (a pointer to a struct with yaml tags), rejecting unknown keys.

type Output

type Output struct {
	// Replies longer than this many characters are sent as a file.
	FileThreshold int `yaml:"file_threshold"`
}

type Permissions added in v0.6.0

type Permissions struct {
	// AutoAllow lists tool kinds that run without asking.
	AutoAllow []agent.Kind `yaml:"auto_allow"`
	Timeout   Duration     `yaml:"timeout"`
}

type Project

type Project struct {
	Cwd   string     `yaml:"cwd"`
	Agent string     `yaml:"agent"`
	Model string     `yaml:"model"`
	Mode  agent.Mode `yaml:"mode"`
}

type Provider added in v0.6.0

type Provider struct {
	Type    string  `yaml:"type"`
	Options Options `yaml:"-"`
}

Provider selects a speech implementation by type; every other key is the provider's own options.

func (*Provider) UnmarshalYAML added in v0.6.0

func (p *Provider) UnmarshalYAML(n *yaml.Node) error

type Telegram

type Telegram struct {
	Token        string  `yaml:"token"`
	AllowedUsers []int64 `yaml:"allowed_users"`
}

Jump to

Keyboard shortcuts

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