config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config loads pocketagent's YAML config file.

Index

Constants

This section is empty.

Variables

View Source
var Modes = []string{"ask", "edits", "plan", "yolo"}

Modes control how much the agent may do without asking.

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 Expand

func Expand(args []string, vars map[string]string) []string

Expand replaces {key} placeholders in each argument.

func ExpandHome

func ExpandHome(p string) string

Types

type Agent

type Agent struct {
	// Type is "claude" (native Claude Code CLI), "acp" (any Agent Client
	// Protocol agent) or "command" (any CLI that takes a prompt and prints a reply).
	Type    string   `yaml:"type"`
	Command Command  `yaml:"command"`
	Env     []string `yaml:"env"`
	Models  []string `yaml:"models"`
	Model   string   `yaml:"model"`

	// Wrap is prepended to the agent command, e.g. a docker run invocation
	// for sandboxing. Supports {cwd}.
	Wrap Command `yaml:"wrap"`

	// command type only
	ModelArgs Command  `yaml:"model_args"` // added when a model is set; supports {model}
	ImageArgs Command  `yaml:"image_args"` // added once per image; supports {path}
	Stdin     bool     `yaml:"stdin"`      // send the prompt on stdin instead of {prompt}
	Timeout   Duration `yaml:"timeout"`
}

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 ("claude") 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"`
	AutoAllow       []string           `yaml:"auto_allow"`
	ApprovalTimeout Duration           `yaml:"approval_timeout"`
	Agents          map[string]Agent   `yaml:"agents"`
	Projects        map[string]Project `yaml:"projects"`
	Transcriber     Transcriber        `yaml:"transcriber"`
	TTS             TTS                `yaml:"tts"`
	Budget          Budget             `yaml:"budget"`
	Output          Output             `yaml:"output"`
	Checkpoints     *bool              `yaml:"checkpoints"`
	// BridgeHost is how agents reach pocketagent's MCP server. Set it to
	// host.docker.internal when agents run in containers.
	BridgeHost string `yaml:"bridge_host"`

	// Home is the directory holding state, logs and uploads. Not read from YAML.
	Home string `yaml:"-"`
	// Path is the file this config was loaded from.
	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 (*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) IsAllowed

func (c *Config) IsAllowed(userID int64) bool

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  string `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 Output

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

type Project

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

type TTS

type TTS struct {
	// Type is "say" (macOS), "openai" (OpenAI-compatible /audio/speech),
	// "command" or "none".
	Type    string  `yaml:"type"`
	Command Command `yaml:"command"` // command template ({text_file}, {out})
	Model   string  `yaml:"model"`
	Voice   string  `yaml:"voice"`
	BaseURL string  `yaml:"base_url"`
	APIKey  string  `yaml:"api_key"`
	FFmpeg  string  `yaml:"ffmpeg"`
}

type Telegram

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

type Transcriber

type Transcriber struct {
	// Type is "whisper-cpp", "openai" (any OpenAI-compatible endpoint),
	// "command" or "none".
	Type     string  `yaml:"type"`
	Command  Command `yaml:"command"` // whisper-cpp binary, or the command template ({file})
	Model    string  `yaml:"model"`
	Language string  `yaml:"language"`
	BaseURL  string  `yaml:"base_url"`
	APIKey   string  `yaml:"api_key"`
	FFmpeg   string  `yaml:"ffmpeg"`
}

Jump to

Keyboard shortcuts

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