config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelTierStrong = "strong"
	ModelTierFast   = "fast"
)

Model tier constants.

Variables

This section is empty.

Functions

func AnnaHome

func AnnaHome() string

AnnaHome returns the anna home directory. Priority: ANNA_HOME env -> ~/.anna The result is cached after the first call.

func CachePath

func CachePath() string

CachePath returns the cache directory inside the anna home.

func Path

func Path() string

Path returns the path to config.yaml inside the anna home.

func ResetAnnaHome

func ResetAnnaHome()

ResetAnnaHome clears the cached AnnaHome value (for testing).

func SaveModelSelection

func SaveModelSelection(workspace, provider, model string) error

SaveModelSelection persists the provider and model to state.yaml in the given workspace, keeping config.yaml as a static, user-edited file.

Types

type ChannelsConfig

type ChannelsConfig struct {
	Telegram TelegramConfig `yaml:"telegram" envPrefix:"TELEGRAM_"`
	QQ       QQConfig       `yaml:"qq"       envPrefix:"QQ_"`
	Feishu   FeishuConfig   `yaml:"feishu"   envPrefix:"FEISHU_"`
}

ChannelsConfig groups all channel (interface) configurations.

type CompactionConfig

type CompactionConfig = agent.CompactionConfig

CompactionConfig is an alias for agent.CompactionConfig for config YAML binding.

type Config

type Config struct {
	Provider    string                    `yaml:"provider"     env:"PROVIDER"`
	Model       string                    `yaml:"model"        env:"MODEL"`
	ModelStrong string                    `yaml:"model_strong" env:"MODEL_STRONG"`
	ModelFast   string                    `yaml:"model_fast"   env:"MODEL_FAST"`
	Workspace   string                    `yaml:"workspace"    env:"WORKSPACE"`
	Runner      RunnerConfig              `yaml:"runner"       envPrefix:"RUNNER_"`
	Cron        CronConfig                `yaml:"cron"         envPrefix:"CRON_"`
	Heartbeat   HeartbeatConfig           `yaml:"heartbeat"    envPrefix:"HEARTBEAT_"`
	Providers   map[string]ProviderConfig `yaml:"providers"`
	Channels    ChannelsConfig            `yaml:"channels"`
}

Config is the top-level configuration for anna. Env vars use ANNA_ prefix (e.g. ANNA_PROVIDER, ANNA_MODEL).

func Load

func Load() (*Config, error)

Load loads config from the default anna home (~/.anna/config.yaml).

func LoadFrom

func LoadFrom(dir string) (*Config, error)

LoadFrom loads config from the given directory.

func (*Config) LogPath

func (cfg *Config) LogPath() string

func (*Config) ModelsPath

func (cfg *Config) ModelsPath() string

func (*Config) ResolveModel

func (cfg *Config) ResolveModel() ai.Model

ResolveModel returns the ai.Model for the default provider/model.

func (*Config) ResolveModelID

func (cfg *Config) ResolveModelID(tier string) string

ResolveModelID returns the model ID string for the given tier, falling back to Model if the tier-specific value is not set.

func (*Config) ResolveModelTier

func (cfg *Config) ResolveModelTier(tier string) ai.Model

ResolveModelTier returns the model for the given tier after applying the fallback: strong -> model, fast -> model.

func (*Config) SkillsPath

func (cfg *Config) SkillsPath() string

func (*Config) StatePath

func (cfg *Config) StatePath() string

type CronConfig

type CronConfig struct {
	Enabled *bool  `yaml:"enabled"  env:"ENABLED"`
	DataDir string `yaml:"data_dir" env:"DATA_DIR"`
}

func (CronConfig) CronEnabled

func (c CronConfig) CronEnabled() bool

CronEnabled returns whether cron is enabled (defaults to true).

type FeishuConfig

type FeishuConfig struct {
	Enabled           *bool    `yaml:"enabled"            env:"ENABLED"`
	EnableNotify      *bool    `yaml:"enable_notify"      env:"ENABLE_NOTIFY"`
	AppID             string   `yaml:"app_id"             env:"APP_ID"`
	AppSecret         string   `yaml:"app_secret"         env:"APP_SECRET"`
	EncryptKey        string   `yaml:"encrypt_key"        env:"ENCRYPT_KEY"`
	VerificationToken string   `yaml:"verification_token" env:"VERIFICATION_TOKEN"`
	NotifyChat        string   `yaml:"notify_chat"        env:"NOTIFY_CHAT"`
	GroupMode         string   `yaml:"group_mode"         env:"GROUP_MODE"`
	AllowedIDs        []string `yaml:"allowed_ids"        env:"ALLOWED_IDS"`
}

func (FeishuConfig) IsEnabled

func (c FeishuConfig) IsEnabled() bool

func (FeishuConfig) IsNotifyEnabled

func (c FeishuConfig) IsNotifyEnabled() bool

type HeartbeatConfig

type HeartbeatConfig struct {
	Enabled *bool  `yaml:"enabled" env:"ENABLED"`
	Every   string `yaml:"every"   env:"EVERY"`
	File    string `yaml:"file"    env:"FILE"`
}

func (HeartbeatConfig) FilePath

func (c HeartbeatConfig) FilePath(workspace string) string

FilePath resolves the configured heartbeat file relative to the workspace.

func (HeartbeatConfig) Interval

func (c HeartbeatConfig) Interval() string

Interval returns the configured heartbeat cadence.

func (HeartbeatConfig) IsEnabled

func (c HeartbeatConfig) IsEnabled() bool

IsEnabled returns whether heartbeat is enabled (defaults to false).

type ModelConfig

type ModelConfig struct {
	ID            string            `yaml:"id"`
	Name          string            `yaml:"name"`
	API           string            `yaml:"api"`
	Reasoning     bool              `yaml:"reasoning"`
	Input         []string          `yaml:"input"`
	ContextWindow int               `yaml:"context_window"`
	MaxTokens     int               `yaml:"max_tokens"`
	Headers       map[string]string `yaml:"headers"`
	Cost          *ModelCostConfig  `yaml:"cost"`
}

type ModelCostConfig

type ModelCostConfig struct {
	Input      float64 `yaml:"input"`
	Output     float64 `yaml:"output"`
	CacheRead  float64 `yaml:"cache_read"`
	CacheWrite float64 `yaml:"cache_write"`
}

type ProviderConfig

type ProviderConfig struct {
	APIKey  string        `yaml:"api_key"`
	BaseURL string        `yaml:"base_url"`
	Models  []ModelConfig `yaml:"models"`
}

type QQConfig

type QQConfig struct {
	Enabled      *bool    `yaml:"enabled"       env:"ENABLED"`
	EnableNotify *bool    `yaml:"enable_notify" env:"ENABLE_NOTIFY"`
	AppID        string   `yaml:"app_id"        env:"APP_ID"`
	AppSecret    string   `yaml:"app_secret"    env:"APP_SECRET"`
	GroupMode    string   `yaml:"group_mode"    env:"GROUP_MODE"`
	AllowedIDs   []string `yaml:"allowed_ids"   env:"ALLOWED_IDS"`
}

func (QQConfig) IsEnabled

func (c QQConfig) IsEnabled() bool

func (QQConfig) IsNotifyEnabled

func (c QQConfig) IsNotifyEnabled() bool

type RunnerConfig

type RunnerConfig struct {
	Type        string           `yaml:"type"         env:"TYPE"`
	System      string           `yaml:"system"       env:"SYSTEM"`
	IdleTimeout int              `yaml:"idle_timeout" env:"IDLE_TIMEOUT"`
	Compaction  CompactionConfig `yaml:"compaction"   envPrefix:"COMPACTION_"`
}

type TelegramConfig

type TelegramConfig struct {
	Enabled      *bool   `yaml:"enabled"       env:"ENABLED"`
	EnableNotify *bool   `yaml:"enable_notify" env:"ENABLE_NOTIFY"`
	Token        string  `yaml:"token"         env:"TOKEN"`
	NotifyChat   string  `yaml:"notify_chat"   env:"NOTIFY_CHAT"`
	ChannelID    string  `yaml:"channel_id"    env:"CHANNEL_ID"`
	GroupMode    string  `yaml:"group_mode"    env:"GROUP_MODE"`
	AllowedIDs   []int64 `yaml:"allowed_ids"   env:"ALLOWED_IDS"`
}

func (TelegramConfig) IsEnabled

func (c TelegramConfig) IsEnabled() bool

func (TelegramConfig) IsNotifyEnabled

func (c TelegramConfig) IsNotifyEnabled() bool

Jump to

Keyboard shortcuts

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