config

package
v0.0.0-...-12e3ab2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides YAML configuration management with live reload support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConfigFile

func FindConfigFile(flagPath string) (string, error)

FindConfigFile searches for config in standard locations

Types

type Config

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

Config provides thread-safe access to configuration with live reload

func New

func New(path string, watch bool) (*Config, error)

New creates Config with optional file watching

func (*Config) Close

func (c *Config) Close() error

Close stops the file watcher

func (*Config) Get

func (c *Config) Get() *ConfigData

Get returns current config snapshot (thread-safe read)

func (*Config) OnReload

func (c *Config) OnReload(callback func())

OnReload registers a callback to be called when config is reloaded

type ConfigData

type ConfigData struct {
	Server struct {
		Port            string        `yaml:"port"`
		ReadTimeout     time.Duration `yaml:"read_timeout"`
		WriteTimeout    time.Duration `yaml:"write_timeout"`
		IdleTimeout     time.Duration `yaml:"idle_timeout"`
		ShutdownTimeout time.Duration `yaml:"shutdown_timeout"`
	} `yaml:"server"`

	Claude struct {
		Path             string        `yaml:"path"`
		WorkingDir       string        `yaml:"working_dir"`
		ExecutionTimeout time.Duration `yaml:"execution_timeout"`
		MaxPromptLength  int           `yaml:"max_prompt_length"`
	} `yaml:"claude"`

	Session struct {
		Timeout         time.Duration `yaml:"timeout"`
		CleanupInterval time.Duration `yaml:"cleanup_interval"`
	} `yaml:"session"`

	Telegram struct {
		Enabled          bool   `yaml:"enabled"`
		BotToken         string `yaml:"bot_token"`
		GroupSessionMode string `yaml:"group_session_mode"`

		Voice struct {
			Enabled         bool          `yaml:"enabled"`
			MaxFileSize     int64         `yaml:"max_file_size"`
			DownloadTimeout time.Duration `yaml:"download_timeout"`
		} `yaml:"voice"`

		Photo struct {
			Enabled         bool          `yaml:"enabled"`
			MaxFileSize     int64         `yaml:"max_file_size"`
			DownloadTimeout time.Duration `yaml:"download_timeout"`
		} `yaml:"photo"`
	} `yaml:"telegram"`

	Deepgram struct {
		APIKey   string `yaml:"api_key"`
		Language string `yaml:"language"`
		Model    string `yaml:"model"`
	} `yaml:"deepgram"`

	Memory struct {
		Enabled bool   `yaml:"enabled"`
		DBPath  string `yaml:"db_path"`

		Extraction struct {
			Interval         time.Duration `yaml:"interval"`
			Timeout          time.Duration `yaml:"timeout"`
			MaxConversations int           `yaml:"max_conversations"`
			FactLimit        int           `yaml:"fact_limit"`
			AdminTimeout     time.Duration `yaml:"admin_timeout"`
		} `yaml:"extraction"`
	} `yaml:"memory"`

	Scheduler struct {
		Enabled bool            `yaml:"enabled"`
		Tasks   []ScheduledTask `yaml:"tasks"`
	} `yaml:"scheduler"`
}

ConfigData holds all configuration values

func DefaultConfig

func DefaultConfig() *ConfigData

DefaultConfig returns config with sensible defaults

func LoadFromFile

func LoadFromFile(path string) (*ConfigData, error)

LoadFromFile reads and parses YAML config file

func (*ConfigData) Validate

func (c *ConfigData) Validate() error

Validate checks config values are valid

type ScheduledTask

type ScheduledTask struct {
	Name            string        `yaml:"name"`
	Interval        time.Duration `yaml:"interval"`
	Type            string        `yaml:"type"`
	Command         string        `yaml:"command"`
	Args            string        `yaml:"args"`
	WorkingDir      string        `yaml:"working_dir"`
	Timeout         time.Duration `yaml:"timeout"`
	SkipPermissions bool          `yaml:"skip_permissions"`
	Enabled         bool          `yaml:"enabled"`
}

ScheduledTask represents a task to be executed on a schedule

Jump to

Keyboard shortcuts

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