config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config provides configuration management for AgentPipe. It defines the structure for YAML configuration files and handles loading, validation, and default value application.

Package config provides configuration management for AgentPipe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Version is the configuration file format version
	Version string `yaml:"version"`
	// Agents is the list of agent configurations
	Agents []agent.AgentConfig `yaml:"agents"`
	// Orchestrator defines conversation orchestration settings
	Orchestrator OrchestratorConfig `yaml:"orchestrator"`
	// Logging defines logging behavior
	Logging LoggingConfig `yaml:"logging"`
}

Config is the top-level configuration structure for AgentPipe. It defines agents, orchestration behavior, and logging settings.

func LoadConfig

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

LoadConfig loads and validates a configuration from a YAML file. It applies default values for any missing optional fields. Returns an error if the file cannot be read, parsed, or is invalid.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a configuration with sensible defaults. The default log directory is ~/.agentpipe/chats.

func (*Config) SaveConfig

func (c *Config) SaveConfig(path string) error

SaveConfig writes the configuration to a YAML file. The file is created with 0600 permissions (read/write for owner only).

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors. It ensures at least one agent is configured, all required fields are present, agent IDs are unique, and the orchestration mode is valid.

type ConfigChangeCallback added in v0.0.16

type ConfigChangeCallback func(oldConfig, newConfig *Config)

ConfigChangeCallback is called when the configuration file changes. It receives the old and new configurations.

type ConfigWatcher added in v0.0.16

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

ConfigWatcher watches a configuration file for changes and reloads it.

func NewConfigWatcher added in v0.0.16

func NewConfigWatcher(configPath string) (*ConfigWatcher, error)

NewConfigWatcher creates a new configuration watcher. It loads the initial configuration and sets up file watching.

func (*ConfigWatcher) GetConfig added in v0.0.16

func (cw *ConfigWatcher) GetConfig() *Config

GetConfig returns the current configuration (thread-safe).

func (*ConfigWatcher) OnConfigChange added in v0.0.16

func (cw *ConfigWatcher) OnConfigChange(callback ConfigChangeCallback)

OnConfigChange registers a callback to be invoked when the config changes. Callbacks are executed in the order they were registered.

func (*ConfigWatcher) StartWatching added in v0.0.16

func (cw *ConfigWatcher) StartWatching()

StartWatching begins monitoring the configuration file for changes. When a change is detected, the config is reloaded and callbacks are invoked. This method blocks, so it should typically be run in a goroutine.

func (*ConfigWatcher) StopWatching added in v0.0.16

func (cw *ConfigWatcher) StopWatching()

StopWatching stops monitoring the configuration file.

type LoggingConfig

type LoggingConfig struct {
	// Enabled determines if conversation logging is active
	Enabled bool `yaml:"enabled"`
	// ChatLogDir is the directory where chat logs are stored
	ChatLogDir string `yaml:"chat_log_dir"`
	// LogFormat is either "text" or "json"
	LogFormat string `yaml:"log_format"`
	// ShowMetrics determines if token/cost metrics are logged
	ShowMetrics bool `yaml:"show_metrics"`
}

LoggingConfig defines conversation logging behavior.

type OrchestratorConfig

type OrchestratorConfig struct {
	// Mode is the orchestration mode: "round-robin", "reactive", or "free-form"
	Mode string `yaml:"mode"`
	// MaxTurns is the maximum number of conversation turns (0 = unlimited)
	MaxTurns int `yaml:"max_turns"`
	// TurnTimeout is the maximum time an agent has to respond
	TurnTimeout time.Duration `yaml:"turn_timeout"`
	// ResponseDelay is the pause between agent responses
	ResponseDelay time.Duration `yaml:"response_delay"`
	// InitialPrompt is an optional starting prompt for the conversation
	InitialPrompt string `yaml:"initial_prompt"`
}

OrchestratorConfig defines how the orchestrator manages conversations.

Jump to

Keyboard shortcuts

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