Documentation
¶
Index ¶
- Constants
- func ActiveSandboxBackend(plugins []Plugin) string
- func AnnaHome() string
- func BuiltinPluginIDs() []string
- func CachePath() string
- func DBPath() string
- func DefaultAgentModelRef(providers []Provider) string
- func DefaultModelIDForProviderType(providerType string) string
- func DefaultModelRefForProvider(provider Provider) string
- func DefaultModelRefForProviderType(providerType string) string
- func ModelConfigToAI(provider string, m ModelConfig) ai.Model
- func ModelsCachePath() string
- func ParseModelRef(ref string) (provider, model string)
- func PluginID(kind, name string) string
- func ResetAnnaHome()
- func SandboxDockerImage() string
- func SandboxDockerImageIsDev() bool
- func SaveModelsCache(cache *ModelsCache) error
- type Agent
- type CachedModel
- type Channel
- type CompactionConfig
- type DBStore
- func (s *DBStore) CreateAgent(ctx context.Context, a Agent) error
- func (s *DBStore) CreateProvider(ctx context.Context, p Provider) error
- func (s *DBStore) DeleteAgent(ctx context.Context, id string) error
- func (s *DBStore) DeleteChannel(ctx context.Context, id string) error
- func (s *DBStore) DeleteChatAgent(ctx context.Context, channelID, platform, chatID string) error
- func (s *DBStore) DeletePlugin(ctx context.Context, id string) error
- func (s *DBStore) DeleteProvider(ctx context.Context, id string) error
- func (s *DBStore) GetAgent(ctx context.Context, id string) (Agent, error)
- func (s *DBStore) GetChannel(ctx context.Context, id string) (Channel, error)
- func (s *DBStore) GetChatAgent(ctx context.Context, channelID, platform, chatID string) (string, error)
- func (s *DBStore) GetPlugin(ctx context.Context, id string) (Plugin, error)
- func (s *DBStore) GetProvider(ctx context.Context, id string) (Provider, error)
- func (s *DBStore) GetSetting(ctx context.Context, key string) (string, error)
- func (s *DBStore) ListAgents(ctx context.Context) ([]Agent, error)
- func (s *DBStore) ListChannels(ctx context.Context) ([]Channel, error)
- func (s *DBStore) ListChannelsByType(ctx context.Context, channelType string) ([]Channel, error)
- func (s *DBStore) ListEnabledAgents(ctx context.Context) ([]Agent, error)
- func (s *DBStore) ListEnabledPlugins(ctx context.Context) ([]Plugin, error)
- func (s *DBStore) ListPlugins(ctx context.Context) ([]Plugin, error)
- func (s *DBStore) ListPluginsByKind(ctx context.Context, kind string) ([]Plugin, error)
- func (s *DBStore) ListProviders(ctx context.Context) ([]Provider, error)
- func (s *DBStore) SeedDefaults(ctx context.Context) error
- func (s *DBStore) SetChatAgent(ctx context.Context, channelID, platform, chatID, agentID string) error
- func (s *DBStore) SetPluginConfig(ctx context.Context, id string, config map[string]any) error
- func (s *DBStore) SetPluginEnabled(ctx context.Context, id string, enabled bool) error
- func (s *DBStore) SetSetting(ctx context.Context, key, value string) error
- func (s *DBStore) Snapshot(ctx context.Context, agentID string) (*Snapshot, error)
- func (s *DBStore) UpdateAgent(ctx context.Context, a Agent) error
- func (s *DBStore) UpdateProvider(ctx context.Context, p Provider) error
- func (s *DBStore) UpsertChannel(ctx context.Context, ch Channel) error
- func (s *DBStore) UpsertPlugin(ctx context.Context, p Plugin) error
- type HeartbeatConfig
- type ModelConfig
- type ModelCostConfig
- type ModelsCache
- type Plugin
- type Provider
- type ProviderCreds
- type ProviderModel
- type ProviderModelCost
- type RunnerConfig
- type SandboxConfig
- type SandboxNetworkConfig
- type SchedulerConfig
- type Snapshot
- func (s *Snapshot) LogPath() string
- func (s *Snapshot) ResolveModel() ai.Model
- func (s *Snapshot) ResolveModelID(tier string) string
- func (s *Snapshot) ResolveModelTier(tier string) ai.Model
- func (s *Snapshot) ResolveProviderCreds(providerID string) ProviderCreds
- func (s *Snapshot) SkillsPath() string
- type Store
Constants ¶
const ( DefaultAnthropicModelID = "claude-sonnet-4-6" DefaultOpenAIModelID = "gpt-4o" DefaultOpenAIResponseModelID = "gpt-4o" )
const ( ModelTierStrong = "strong" ModelTierFast = "fast" )
Model tier constants.
const ( PluginKindTool = "tool" PluginKindChannel = "channel" PluginKindHook = "hook" PluginKindProvider = "provider" PluginKindMemory = "memory" PluginKindSandbox = "sandbox" PluginKindAuth = "auth" )
Plugin kind constants.
const ( SandboxBackendDocker = "docker" SandboxBackendBoxsh = "boxsh" SandboxBackendLocal = "local" SandboxNetworkDisabled = "disabled" SandboxNetworkAllowAll = "allow_all" )
const ( AgentScopeSystem = "system" // all users can access AgentScopeRestricted = "restricted" // only assigned users can access )
AgentScope constants define the access scope for an agent.
Variables ¶
This section is empty.
Functions ¶
func ActiveSandboxBackend ¶ added in v0.13.0
ActiveSandboxBackend returns the name of the enabled sandbox backend plugin, or SandboxBackendDocker if none is explicitly enabled.
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 BuiltinPluginIDs ¶ added in v0.9.0
func BuiltinPluginIDs() []string
BuiltinPluginIDs returns all built-in plugin IDs in deterministic order. Provider instances are stored separately in settings_providers.
func CachePath ¶
func CachePath() string
CachePath returns the cache directory inside the anna home.
func DBPath ¶ added in v0.8.0
func DBPath() string
DBPath returns the default database path inside the anna home.
func DefaultAgentModelRef ¶ added in v0.10.2
DefaultAgentModelRef picks the preferred starter model ref from the configured providers. It prefers Anthropic, then OpenAI, then OpenAI Responses, and falls back to the Anthropic compatibility alias.
func DefaultModelIDForProviderType ¶ added in v0.10.2
DefaultModelIDForProviderType returns the preferred starter model ID for a built-in provider type.
func DefaultModelRefForProvider ¶ added in v0.10.2
DefaultModelRefForProvider returns the default provider/model ref for a concrete provider instance.
func DefaultModelRefForProviderType ¶ added in v0.10.2
DefaultModelRefForProviderType returns the default provider/model ref for the given provider type using the provider type as the prefix.
func ModelConfigToAI ¶ added in v0.8.0
func ModelConfigToAI(provider string, m ModelConfig) ai.Model
ModelConfigToAI converts a ModelConfig to an ai.Model.
func ModelsCachePath ¶ added in v0.8.1
func ModelsCachePath() string
ModelsCachePath returns the path to the models.json cache file.
func ParseModelRef ¶ added in v0.8.0
ParseModelRef splits a "provider/model" string into its parts. If the string contains no "/", it returns ("", ref) as fallback.
func ResetAnnaHome ¶
func ResetAnnaHome()
ResetAnnaHome clears the cached AnnaHome value (for testing).
func SandboxDockerImage ¶ added in v0.13.0
func SandboxDockerImage() string
SandboxDockerImage returns the sandbox container image tag for the current anna build. Dev builds use a local `anna-sandbox:dev` tag (produced by `mise run sandbox:docker:build`); tagged releases pull `ghcr.io/vaayne/anna-sandbox:<version>` from GHCR. The version is normalized to strip any leading "v" so "v1.2.3" and "1.2.3" resolve to the same image tag.
func SandboxDockerImageIsDev ¶ added in v0.13.0
func SandboxDockerImageIsDev() bool
SandboxDockerImageIsDev reports whether SandboxDockerImage resolves to the local dev tag. Callers use this to surface a build-image hint when the image is missing locally.
func SaveModelsCache ¶ added in v0.8.1
func SaveModelsCache(cache *ModelsCache) error
SaveModelsCache writes the models cache to the cache directory.
Types ¶
type Agent ¶ added in v0.8.0
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
Model string `json:"model"`
ModelStrong string `json:"model_strong"`
ModelFast string `json:"model_fast"`
SystemPrompt string `json:"system_prompt"`
Soul string `json:"soul"`
Workspace string `json:"workspace"`
Sandbox SandboxConfig `json:"sandbox"`
EnabledBuiltinSkills []string `json:"enabled_builtin_skills"`
Scope string `json:"scope"`
CreatorID int64 `json:"creator_id"`
Enabled bool `json:"enabled"`
}
Agent represents an agent definition. Model fields use {provider}/{model} format (e.g. "anthropic/claude-sonnet-4-6").
type CachedModel ¶ added in v0.8.1
CachedModel is the on-disk representation of a model in models.json.
type Channel ¶ added in v0.8.0
type Channel struct {
ID string `json:"id"`
Type string `json:"type"`
AgentID string `json:"agent_id,omitempty"`
Enabled bool `json:"enabled"`
Config string `json:"config"`
}
Channel represents a platform channel configuration.
type CompactionConfig ¶
type CompactionConfig struct {
// MaxTokens triggers compaction when the estimated token count exceeds this.
// 0 (or omitted) uses the default of 80000. Negative values disable
// automatic compaction. Manual /compact still works.
MaxTokens int `json:"max_tokens"`
// KeepTail is the number of recent message entries to preserve verbatim
// after compaction. Default: 20.
KeepTail int `json:"keep_tail"`
}
CompactionConfig controls automatic session compaction.
type DBStore ¶ added in v0.8.0
type DBStore struct {
// contains filtered or unexported fields
}
DBStore implements Store using sqlc queries backed by SQLite.
func NewDBStore ¶ added in v0.8.0
NewDBStore creates a new DBStore wrapping the given database connection. It sets MaxOpenConns(1) to mitigate SQLite concurrency issues.
func (*DBStore) CreateAgent ¶ added in v0.8.0
func (*DBStore) CreateProvider ¶ added in v0.8.0
func (*DBStore) DeleteAgent ¶ added in v0.8.0
func (*DBStore) DeleteChannel ¶ added in v0.10.0
func (*DBStore) DeleteChatAgent ¶ added in v0.8.0
func (*DBStore) DeletePlugin ¶ added in v0.9.0
func (*DBStore) DeleteProvider ¶ added in v0.8.0
func (*DBStore) GetChannel ¶ added in v0.8.0
func (*DBStore) GetChatAgent ¶ added in v0.8.0
func (*DBStore) GetProvider ¶ added in v0.8.0
func (*DBStore) GetSetting ¶ added in v0.8.0
func (*DBStore) ListAgents ¶ added in v0.8.0
func (*DBStore) ListChannels ¶ added in v0.8.0
func (*DBStore) ListChannelsByType ¶ added in v0.10.0
func (*DBStore) ListEnabledAgents ¶ added in v0.8.0
func (*DBStore) ListEnabledPlugins ¶ added in v0.9.0
func (*DBStore) ListPlugins ¶ added in v0.9.0
func (*DBStore) ListPluginsByKind ¶ added in v0.9.0
func (*DBStore) ListProviders ¶ added in v0.8.0
func (*DBStore) SeedDefaults ¶ added in v0.8.0
SeedDefaults populates the DB with sensible defaults on first bootstrap. It is idempotent: if providers/agents already exist, it does nothing.
func (*DBStore) SetChatAgent ¶ added in v0.8.0
func (*DBStore) SetPluginConfig ¶ added in v0.9.0
func (*DBStore) SetPluginEnabled ¶ added in v0.9.0
func (*DBStore) SetSetting ¶ added in v0.8.0
func (*DBStore) UpdateAgent ¶ added in v0.8.0
func (*DBStore) UpdateProvider ¶ added in v0.8.0
func (*DBStore) UpsertChannel ¶ added in v0.8.0
type HeartbeatConfig ¶
type HeartbeatConfig struct {
Enabled *bool `json:"enabled"`
Every string `json:"every"`
File string `json:"file"`
}
HeartbeatConfig configures periodic heartbeat checks.
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 `json:"id"`
Name string `json:"name"`
API string `json:"api"`
Reasoning bool `json:"reasoning"`
Input []string `json:"input"`
ContextWindow int `json:"context_window"`
MaxTokens int `json:"max_tokens"`
Headers map[string]string `json:"headers"`
Cost *ModelCostConfig `json:"cost"`
}
ModelConfig describes a model's metadata (used in model listing/caching).
type ModelCostConfig ¶
type ModelCostConfig struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheRead float64 `json:"cache_read"`
CacheWrite float64 `json:"cache_write"`
}
ModelCostConfig describes the cost of a model per million tokens.
type ModelsCache ¶ added in v0.8.1
type ModelsCache struct {
UpdatedAt time.Time `json:"updated_at"`
Models []CachedModel `json:"models"`
}
ModelsCache is the top-level structure for models.json in the cache directory.
func LoadModelsCache ¶ added in v0.8.1
func LoadModelsCache() (*ModelsCache, error)
LoadModelsCache reads the cached models from the workspace models.json.
type Plugin ¶ added in v0.9.0
type Plugin struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Config map[string]any `json:"config"`
}
Plugin represents a unified plugin entry stored in settings_plugins. IDs follow "kind/name" format, e.g. "tool/webfetch" or "channel/telegram".
type Provider ¶ added in v0.8.0
type Provider struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
APIKey string `json:"api_key"`
BaseURL string `json:"base_url"`
Models map[string]ProviderModel `json:"models,omitempty"`
}
Provider represents an LLM API provider.
type ProviderCreds ¶ added in v0.8.0
ProviderCreds holds credentials for a single provider.
type ProviderModel ¶ added in v0.10.0
type ProviderModel struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Enabled bool `json:"enabled"`
Reasoning bool `json:"reasoning,omitempty"`
Input []string `json:"input,omitempty"`
Output []string `json:"output,omitempty"`
ContextWindow int `json:"contextWindow,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
Cost ProviderModelCost `json:"cost,omitzero"`
}
type ProviderModelCost ¶ added in v0.10.0
type RunnerConfig ¶
type RunnerConfig struct {
Type string `json:"type"`
System string `json:"system"`
IdleTimeout int `json:"idle_timeout"`
Compaction CompactionConfig `json:"compaction"`
}
RunnerConfig configures the agent runner.
type SandboxConfig ¶ added in v0.10.0
type SandboxConfig struct {
Network SandboxNetworkConfig `json:"network"`
}
SandboxConfig configures the sandbox backend. The docker backend takes no per-agent knobs — the container image, user, mounts, and DooD translation are all fixed by the shipped sandbox image and auto-derived from env.
func (SandboxConfig) NetworkMode ¶ added in v0.10.0
func (c SandboxConfig) NetworkMode() string
NetworkMode returns the configured network mode with defaults applied.
func (*SandboxConfig) UnmarshalJSON ¶ added in v0.15.0
func (c *SandboxConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler so that legacy "backend" keys in stored or user-supplied config are silently ignored with a one-time log warning instead of producing an unknown-field error.
func (SandboxConfig) Validate ¶ added in v0.10.0
func (c SandboxConfig) Validate() error
Validate returns an error when the sandbox configuration is invalid.
type SandboxNetworkConfig ¶ added in v0.10.0
type SandboxNetworkConfig struct {
Mode string `json:"mode"`
Allowlist []string `json:"allowlist"`
}
SandboxNetworkConfig configures sandbox network access.
type SchedulerConfig ¶ added in v0.6.2
SchedulerConfig configures the scheduler subsystem.
func (SchedulerConfig) IsEnabled ¶ added in v0.6.2
func (c SchedulerConfig) IsEnabled() bool
IsEnabled returns whether the scheduler is enabled (defaults to true).
type Snapshot ¶ added in v0.8.0
type Snapshot struct {
AgentID string // the agent ID this snapshot belongs to
// Provider, APIKey, BaseURL are the default provider credentials derived
// from the Model field's provider prefix. Kept for backward compatibility.
Provider string
Model string
ModelStrong string
ModelFast string
Workspace string
Sandbox SandboxConfig
APIKey string
BaseURL string
SystemPrompt string // agent's base system prompt from DB
Soul string // agent's default soul from DB (fallback for all users)
// EnabledBuiltinSkills is retained for backward compatibility with older
// templates and agent rows. System-scope builtin skills are now always
// visible to every agent, so this list no longer affects prompt catalog
// visibility.
EnabledBuiltinSkills []string
Runner RunnerConfig
Compaction CompactionConfig
Heartbeat HeartbeatConfig
Scheduler SchedulerConfig
Plugins []Plugin
// Providers maps provider ID to credentials, enabling per-tier provider
// resolution when model_strong or model_fast use a different provider.
Providers map[string]ProviderCreds
}
Snapshot is a read-only config snapshot assembled from DB for downstream consumption. It replaces the old *Config for code that needs provider/model information for a specific agent.
func (*Snapshot) ResolveModel ¶ added in v0.8.0
ResolveModel returns the ai.Model for the default (strong) tier.
func (*Snapshot) ResolveModelID ¶ added in v0.8.0
ResolveModelID returns the model ID string for the given tier, falling back to Model if the tier-specific value is not set.
func (*Snapshot) ResolveModelTier ¶ added in v0.8.0
ResolveModelTier returns the ai.Model for the given tier, constructing a minimal Model from the snapshot's provider and model information. It parses the provider from the model ref and looks up per-provider credentials from the Providers map.
func (*Snapshot) ResolveProviderCreds ¶ added in v0.8.0
func (s *Snapshot) ResolveProviderCreds(providerID string) ProviderCreds
ResolveProviderCreds returns the API key and base URL for the given provider ID, falling back to the default Provider credentials.
func (*Snapshot) SkillsPath ¶ added in v0.8.0
SkillsPath returns the per-workspace agent-level skills directory.
type Store ¶ added in v0.8.0
type Store interface {
// Providers
ListProviders(ctx context.Context) ([]Provider, error)
GetProvider(ctx context.Context, id string) (Provider, error)
CreateProvider(ctx context.Context, p Provider) error
UpdateProvider(ctx context.Context, p Provider) error
DeleteProvider(ctx context.Context, id string) error
// Agents
ListAgents(ctx context.Context) ([]Agent, error)
ListEnabledAgents(ctx context.Context) ([]Agent, error)
GetAgent(ctx context.Context, id string) (Agent, error)
CreateAgent(ctx context.Context, a Agent) error
UpdateAgent(ctx context.Context, a Agent) error
DeleteAgent(ctx context.Context, id string) error
// Channels
ListChannels(ctx context.Context) ([]Channel, error)
ListChannelsByType(ctx context.Context, channelType string) ([]Channel, error)
GetChannel(ctx context.Context, id string) (Channel, error)
UpsertChannel(ctx context.Context, ch Channel) error
DeleteChannel(ctx context.Context, id string) error
// Plugins
ListPlugins(ctx context.Context) ([]Plugin, error)
ListPluginsByKind(ctx context.Context, kind string) ([]Plugin, error)
ListEnabledPlugins(ctx context.Context) ([]Plugin, error)
GetPlugin(ctx context.Context, id string) (Plugin, error)
UpsertPlugin(ctx context.Context, p Plugin) error
SetPluginEnabled(ctx context.Context, id string, enabled bool) error
SetPluginConfig(ctx context.Context, id string, config map[string]any) error
DeletePlugin(ctx context.Context, id string) error
// Chat Agents (group -> agent mapping)
GetChatAgent(ctx context.Context, channelID, platform, chatID string) (string, error) // returns agentID
SetChatAgent(ctx context.Context, channelID, platform, chatID, agentID string) error
DeleteChatAgent(ctx context.Context, channelID, platform, chatID string) error
// Settings (key-value JSON)
GetSetting(ctx context.Context, key string) (string, error) // returns JSON string
SetSetting(ctx context.Context, key, value string) error
// Snapshot assembles a read-only config snapshot for an agent.
Snapshot(ctx context.Context, agentID string) (*Snapshot, error)
// Bootstrap
SeedDefaults(ctx context.Context) error
}
Store provides typed access to configuration stored in the database.