config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads ~/.tomo/config.yaml: providers, the default model, and agent knobs. Values may reference environment variables with ${VAR} so keys never have to live in the file itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns ~/.tomo/config.yaml.

Types

type Agent

type Agent struct {
	MaxTokens int `yaml:"max_tokens"`
	MaxTurns  int `yaml:"max_turns"`
}

Agent holds the loop knobs.

type Channels

type Channels map[string]map[string]any

Channels configures the front doors serve turns on. It is a map from a channel name to that channel's own settings, left untyped on purpose: the config package does not know what a Telegram token or a Discord allow-list is, only the channel's driver does. To add a channel you register a driver and add a block here; the config schema never grows a field per channel.

channels:
  telegram:
    token: ${TELEGRAM_TOKEN}
    allow_chats: [123456789]
  discord:
    token: ${DISCORD_TOKEN}
    allow_channels: ["C0123"]

type Config

type Config struct {
	DefaultModel string              `yaml:"default_model"`
	Providers    map[string]Provider `yaml:"providers"`
	Agent        Agent               `yaml:"agent"`
	Policy       Policy              `yaml:"policy"`
	Sandbox      string              `yaml:"sandbox"`
	Channels     Channels            `yaml:"channels"`
	Heartbeat    Heartbeat           `yaml:"heartbeat"`
	Voice        Voice               `yaml:"voice"`
	MCP          MCP                 `yaml:"mcp"`
	Workers      map[string]Worker   `yaml:"workers"`
	DataDir      string              `yaml:"data_dir"`
}

Config is the whole file. Policy is left as a raw map so pkg/config need not import pkg/policy; the cli decodes it into policy.Config.

func Load

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

Load reads and expands the config at path; an empty path means the default location. A missing file is an error that names the fix.

func (*Config) Resolve

func (c *Config) Resolve(spec string) (name, model string, pc Provider, err error)

Resolve splits a provider/model spec against the configured providers. An empty spec falls back to default_model. The model part may itself contain slashes, which some gateways use.

type Heartbeat

type Heartbeat struct {
	Enabled bool   `yaml:"enabled"`
	Every   string `yaml:"every"`   // schedule spec, defaults to @every 30m
	File    string `yaml:"file"`    // checklist to read each beat, defaults to HEARTBEAT.md in the data dir
	Channel string `yaml:"channel"` // where to deliver anything worth saying, defaults to web
	Chat    string `yaml:"chat"`    // chat id within that channel
}

Heartbeat runs tomo on a cadence against a checklist file, so it can pick up standing work without being spoken to. It stays quiet when there is nothing to report. Off unless enabled.

type MCP

type MCP struct {
	Servers map[string]MCPServer `yaml:"servers"`
}

MCP lists the Model Context Protocol servers to attach on startup. Each one contributes its tools, namespaced by the server key.

type MCPServer

type MCPServer struct {
	Command string            `yaml:"command"` // executable to run for a stdio server
	Args    []string          `yaml:"args"`    // its arguments
	Env     map[string]string `yaml:"env"`     // extra environment for it
	URL     string            `yaml:"url"`     // endpoint of an HTTP server
	Headers map[string]string `yaml:"headers"` // sent on every HTTP request, for auth
}

MCPServer describes one MCP server. Set command to launch it as a local subprocess over stdio, or url to reach a remote one over HTTP.

type Policy

type Policy struct {
	Read  string            `yaml:"read"`
	Net   string            `yaml:"net"`
	Write string            `yaml:"write"`
	Exec  string            `yaml:"exec"`
	Rules map[string]string `yaml:"rules"`
}

Policy mirrors the policy section without depending on pkg/policy.

type Provider

type Provider struct {
	Type    string `yaml:"type"` // "anthropic" or "openai"
	APIKey  string `yaml:"api_key"`
	BaseURL string `yaml:"base_url"`
}

Provider is one model backend entry.

type Voice

type Voice struct {
	Model    string `yaml:"model"`     // path to a ggml whisper model; setting it enables voice-in
	Bin      string `yaml:"bin"`       // whisper.cpp cli, defaults to whisper-cli
	FFmpeg   string `yaml:"ffmpeg"`    // ffmpeg for decode and opus encode, defaults to ffmpeg
	TTSModel string `yaml:"tts_model"` // path to a piper voice model; setting it enables voice-out
	TTSBin   string `yaml:"tts_bin"`   // piper cli, defaults to piper
}

Voice configures speech both ways, all handled locally so no audio leaves the machine. Setting model turns on transcription of inbound voice notes with whisper.cpp; setting tts_model turns on spoken replies with piper, sent back as a voice note wherever the user spoke first.

type Worker

type Worker struct {
	Persona  string   `yaml:"persona"`  // extra system-prompt lines that set its role
	Model    string   `yaml:"model"`    // provider/model override, empty means the default
	Policy   Policy   `yaml:"policy"`   // its own gate, merged over the top-level policy
	Sandbox  string   `yaml:"sandbox"`  // exec sandbox for this worker, empty means the default
	Channels []string `yaml:"channels"` // channel:chat keys whose messages route to it
}

Worker is a named specialist that handles some conversations in its own right: its own persona, an optional model, its own policy, and the channel:chat bindings that route to it. Anything left unset falls back to the top-level default. The default worker, tomo, needs no entry here.

Jump to

Keyboard shortcuts

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