config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config provides configuration types and loading for omniagent.

Package config provides configuration types and loading for omniagent.

Package config provides configuration types and loading for omniagent.

Index

Constants

View Source
const DefaultRecallMax = 5

DefaultRecallMax is the default maximum memories to recall per request.

Variables

This section is empty.

Functions

func ExpandEnvVars

func ExpandEnvVars(s string) string

ExpandEnvVars expands environment variables in string values. Supports ${VAR} and $VAR syntax.

Types

type AgentConfig

type AgentConfig struct {
	ID           string   `json:"id,omitempty" yaml:"id,omitempty"`
	Name         string   `json:"name,omitempty" yaml:"name,omitempty"`
	Description  string   `json:"description,omitempty" yaml:"description,omitempty"`
	Provider     string   `json:"provider" yaml:"provider"`
	Model        string   `json:"model" yaml:"model"`
	APIKey       string   `json:"api_key" yaml:"api_key"` //nolint:gosec // G117: APIKey loaded from config file
	BaseURL      string   `json:"base_url" yaml:"base_url"`
	Temperature  float64  `json:"temperature" yaml:"temperature"`
	MaxTokens    int      `json:"max_tokens" yaml:"max_tokens"`
	SystemPrompt string   `json:"system_prompt" yaml:"system_prompt"`
	AllowedTools []string `json:"allowed_tools,omitempty" yaml:"allowed_tools,omitempty"`
	DeniedTools  []string `json:"denied_tools,omitempty" yaml:"denied_tools,omitempty"`
	Enabled      *bool    `json:"enabled,omitempty" yaml:"enabled,omitempty"`
}

AgentConfig configures the AI agent.

func (*AgentConfig) IsEnabled added in v0.11.0

func (c *AgentConfig) IsEnabled() bool

IsEnabled returns whether the agent is enabled. Defaults to true if Enabled is nil.

type BrowserToolConfig

type BrowserToolConfig struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Headless bool   `json:"headless" yaml:"headless"`
	UserData string `json:"user_data" yaml:"user_data"`
}

BrowserToolConfig configures the browser automation tool.

type ChannelsConfig

type ChannelsConfig struct {
	Telegram  TelegramConfig  `json:"telegram" yaml:"telegram"`
	Discord   DiscordConfig   `json:"discord" yaml:"discord"`
	WhatsApp  WhatsAppConfig  `json:"whatsapp" yaml:"whatsapp"`
	TwilioSMS TwilioSMSConfig `json:"twilio_sms" yaml:"twilio_sms"`
}

ChannelsConfig configures messaging channels.

type Config

type Config struct {
	Gateway       GatewayConfig       `json:"gateway" yaml:"gateway"`
	Agent         AgentConfig         `json:"agent" yaml:"agent"`
	Agents        []AgentConfig       `json:"agents,omitempty" yaml:"agents,omitempty"` // Multi-agent configs
	Channels      ChannelsConfig      `json:"channels" yaml:"channels"`
	Tools         ToolsConfig         `json:"tools" yaml:"tools"`
	Skills        SkillsConfig        `json:"skills" yaml:"skills"`
	Memory        MemoryConfig        `json:"memory" yaml:"memory"`
	Voice         VoiceConfig         `json:"voice" yaml:"voice"`
	Image         ImageConfig         `json:"image" yaml:"image"`
	Observability ObservabilityConfig `json:"observability" yaml:"observability"`
	Tokens        TokenConfig         `json:"tokens" yaml:"tokens"`
}

Config is the root configuration for omniagent.

func Default

func Default() Config

Default returns a Config with sensible defaults.

func Load

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

Load reads configuration from a file and environment variables. Environment variables override file values. Vault-backed credentials (op://, bw://, keeper://) are resolved automatically.

func LoadWithContext added in v0.9.0

func LoadWithContext(ctx context.Context, path string) (*Config, error)

LoadWithContext reads configuration with a context for vault operations.

func (*Config) ResolveCredentials added in v0.9.0

func (c *Config) ResolveCredentials(ctx context.Context) error

ResolveCredentials resolves all vault-backed credentials in the config. Values starting with op://, bw://, keeper://, file://, or env:// are resolved using omnivault. Plain string values are left unchanged.

type DiscordConfig

type DiscordConfig struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	Token   string `json:"token" yaml:"token"`
	GuildID string `json:"guild_id" yaml:"guild_id"`
}

DiscordConfig configures the Discord channel.

type EmbedderConfig added in v0.11.0

type EmbedderConfig struct {
	Provider string `json:"provider" yaml:"provider"` // openai, bedrock, etc.
	Model    string `json:"model" yaml:"model"`       // text-embedding-3-small, etc.
	APIKey   string `json:"api_key" yaml:"api_key"`   //nolint:gosec // G117: APIKey loaded from config file
}

EmbedderConfig configures the embedding model for semantic memory.

type GatewayConfig

type GatewayConfig struct {
	Address      string        `json:"address" yaml:"address"`
	ReadTimeout  time.Duration `json:"read_timeout" yaml:"read_timeout"`
	WriteTimeout time.Duration `json:"write_timeout" yaml:"write_timeout"`
	PingInterval time.Duration `json:"ping_interval" yaml:"ping_interval"`
}

GatewayConfig configures the WebSocket gateway.

type ImageConfig added in v0.12.0

type ImageConfig struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Provider string `json:"provider" yaml:"provider"` // openai, fal
	Model    string `json:"model" yaml:"model"`       // Default model (e.g., gpt-image-2, fal-ai/flux-pro)
	APIKey   string `json:"api_key" yaml:"api_key"`   //nolint:gosec // G117: APIKey loaded from config file
	BaseURL  string `json:"base_url" yaml:"base_url"` // Optional custom base URL
}

ImageConfig configures image generation via OmniImage.

type MemoryConfig added in v0.11.0

type MemoryConfig struct {
	Enabled   bool           `json:"enabled" yaml:"enabled"`
	Provider  string         `json:"provider" yaml:"provider"`     // memory, postgres, kvs, mem0, twilio
	DSN       string         `json:"dsn" yaml:"dsn"`               // Database connection string (postgres)
	APIKey    string         `json:"api_key" yaml:"api_key"`       // API key (mem0, twilio) //nolint:gosec // G117: APIKey loaded from config file
	Endpoint  string         `json:"endpoint" yaml:"endpoint"`     // API endpoint (mem0, twilio)
	TenantID  string         `json:"tenant_id" yaml:"tenant_id"`   // Default tenant for this agent
	AgentID   string         `json:"agent_id" yaml:"agent_id"`     // Agent identifier
	Options   map[string]any `json:"options" yaml:"options"`       // Provider-specific options
	Embedder  EmbedderConfig `json:"embedder" yaml:"embedder"`     // Optional embedder configuration
	RecallMax int            `json:"recall_max" yaml:"recall_max"` // Max memories to recall per request
}

MemoryConfig configures the omnimemory integration.

func (*MemoryConfig) GetRecallMax added in v0.11.0

func (c *MemoryConfig) GetRecallMax() int

GetRecallMax returns the recall max, defaulting to DefaultRecallMax if not set.

func (*MemoryConfig) ToClientConfig added in v0.11.0

func (c *MemoryConfig) ToClientConfig() core.ClientConfig

ToClientConfig converts MemoryConfig to omnimemory ClientConfig.

type ObservabilityConfig

type ObservabilityConfig struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Provider string `json:"provider" yaml:"provider"`
	Endpoint string `json:"endpoint" yaml:"endpoint"`
	APIKey   string `json:"api_key" yaml:"api_key"` //nolint:gosec // G117: APIKey loaded from config file
}

ObservabilityConfig configures observability features.

type STTConfig

type STTConfig struct {
	Provider string `json:"provider" yaml:"provider"`
	APIKey   string `json:"api_key" yaml:"api_key"` //nolint:gosec // G117: APIKey loaded from config file
	Model    string `json:"model" yaml:"model"`
	Language string `json:"language" yaml:"language"`
}

STTConfig configures speech-to-text.

type ServiceTokenConfig added in v0.9.0

type ServiceTokenConfig struct {
	// CredentialsName is the name of the credentials in the vault.
	// If empty, defaults to the service name.
	CredentialsName string `json:"credentials_name" yaml:"credentials_name"`

	// Scopes are the OAuth scopes to request (for Google, etc.).
	Scopes []string `json:"scopes" yaml:"scopes"`
}

ServiceTokenConfig configures a single OAuth service.

type ShellToolConfig

type ShellToolConfig struct {
	Enabled    bool     `json:"enabled" yaml:"enabled"`
	WorkingDir string   `json:"working_dir" yaml:"working_dir"`
	Allowlist  []string `json:"allowlist" yaml:"allowlist"`
}

ShellToolConfig configures the shell execution tool.

type SkillsConfig

type SkillsConfig struct {
	Enabled     bool     `json:"enabled" yaml:"enabled"`
	Packs       []string `json:"packs" yaml:"packs"`       // Skill pack names (e.g., "omniagent-skills")
	Paths       []string `json:"paths" yaml:"paths"`       // Directories to search (alias: dirs)
	Includes    []string `json:"includes" yaml:"includes"` // Only load these skills
	Excludes    []string `json:"excludes" yaml:"excludes"` // Skip these skills
	Disabled    []string `json:"disabled" yaml:"disabled"` // Deprecated: use excludes
	MaxInjected int      `json:"max_injected" yaml:"max_injected"`
}

SkillsConfig configures skill loading.

type TTSConfig

type TTSConfig struct {
	Provider string `json:"provider" yaml:"provider"`
	APIKey   string `json:"api_key" yaml:"api_key"` //nolint:gosec // G117: APIKey loaded from config file
	Model    string `json:"model" yaml:"model"`
	VoiceID  string `json:"voice_id" yaml:"voice_id"`
}

TTSConfig configures text-to-speech.

type TelegramConfig

type TelegramConfig struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	Token   string `json:"token" yaml:"token"`
}

TelegramConfig configures the Telegram channel.

type TokenConfig added in v0.9.0

type TokenConfig struct {
	// VaultURI is the vault URI for storing credentials and tokens.
	// Examples: "op://MyVault", "bw://org-id", "keeper://"
	VaultURI string `json:"vault_uri" yaml:"vault_uri"`

	// Services maps service names to their credential configuration.
	// The credential name in the vault defaults to the service name.
	Services map[string]ServiceTokenConfig `json:"services" yaml:"services"`
}

TokenConfig configures OAuth token management for services that require access token refresh (Google, Zoom, RingCentral, etc.).

type TokenManager added in v0.9.0

type TokenManager struct {
	// contains filtered or unexported fields
}

TokenManager provides OAuth token management with automatic refresh. It wraps omnitoken.TokenManager and provides vault-backed credential storage.

func NewTokenManager added in v0.9.0

func NewTokenManager(ctx context.Context, config TokenConfig) (*TokenManager, error)

NewTokenManager creates a token manager from configuration. The token manager handles OAuth token lifecycle including automatic refresh and vault coordination for multi-process scenarios.

func (*TokenManager) Close added in v0.9.0

func (m *TokenManager) Close() error

Close releases resources held by the token manager.

func (*TokenManager) HTTPClient added in v0.9.0

func (m *TokenManager) HTTPClient(ctx context.Context, service string) (*http.Client, error)

HTTPClient returns an HTTP client for the service with automatic token refresh. The client automatically: 1. Adds Authorization header with access token 2. Refreshes token when expired 3. Coordinates with vault for multi-process token sharing

Example:

client := tm.HTTPClient(ctx, "google")
resp, err := client.Get("https://www.googleapis.com/...")

func (*TokenManager) LoadGoogleServiceAccount added in v0.9.0

func (m *TokenManager) LoadGoogleServiceAccount(ctx context.Context, name, serviceAccountFile string, scopes []string) error

LoadGoogleServiceAccount loads a Google service account from a JSON file and stores it in the vault for token management.

func (*TokenManager) RefreshToken added in v0.9.0

func (m *TokenManager) RefreshToken(ctx context.Context, service string) error

RefreshToken forces a token refresh for the service. This is useful when you know the token is invalid and want to refresh immediately.

type ToolsConfig

type ToolsConfig struct {
	Browser BrowserToolConfig `json:"browser" yaml:"browser"`
	Shell   ShellToolConfig   `json:"shell" yaml:"shell"`
}

ToolsConfig configures available tools.

type TwilioSMSConfig added in v0.6.0

type TwilioSMSConfig struct {
	Enabled             bool   `json:"enabled" yaml:"enabled"`
	AccountSID          string `json:"account_sid" yaml:"account_sid"`
	AuthToken           string `json:"auth_token" yaml:"auth_token"` //nolint:gosec // G101: Auth token loaded from config file
	PhoneNumber         string `json:"phone_number" yaml:"phone_number"`
	MessagingServiceSid string `json:"messaging_service_sid" yaml:"messaging_service_sid"` // For RCS
	WebhookPath         string `json:"webhook_path" yaml:"webhook_path"`                   // Default: /webhook/twilio/sms
}

TwilioSMSConfig configures the Twilio SMS channel.

type VoiceConfig

type VoiceConfig struct {
	Enabled      bool      `json:"enabled" yaml:"enabled"`
	ResponseMode string    `json:"response_mode" yaml:"response_mode"`
	STT          STTConfig `json:"stt" yaml:"stt"`
	TTS          TTSConfig `json:"tts" yaml:"tts"`
}

VoiceConfig configures voice processing.

type WhatsAppConfig

type WhatsAppConfig struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	DBPath  string `json:"db_path" yaml:"db_path"`
}

WhatsAppConfig configures the WhatsApp channel.

Jump to

Keyboard shortcuts

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