Documentation
¶
Index ¶
- Constants
- func AnnaHome() string
- func CachePath() string
- func Path() string
- func ResetAnnaHome()
- func SaveModelSelection(workspace, provider, model string) error
- type ChannelsConfig
- type CompactionConfig
- type Config
- func (cfg *Config) LogPath() string
- func (cfg *Config) ModelsPath() string
- func (cfg *Config) ResolveModel() ai.Model
- func (cfg *Config) ResolveModelID(tier string) string
- func (cfg *Config) ResolveModelTier(tier string) ai.Model
- func (cfg *Config) SkillsPath() string
- func (cfg *Config) StatePath() string
- type CronConfig
- type FeishuConfig
- type HeartbeatConfig
- type ModelConfig
- type ModelCostConfig
- type ProviderConfig
- type QQConfig
- type RunnerConfig
- type TelegramConfig
Constants ¶
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 ResetAnnaHome ¶
func ResetAnnaHome()
ResetAnnaHome clears the cached AnnaHome value (for testing).
func SaveModelSelection ¶
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 (*Config) ModelsPath ¶
func (*Config) ResolveModel ¶
ResolveModel returns the ai.Model for the default provider/model.
func (*Config) ResolveModelID ¶
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 ¶
ResolveModelTier returns the model for the given tier after applying the fallback: strong -> model, fast -> model.
func (*Config) SkillsPath ¶
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 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) IsNotifyEnabled ¶
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