70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// ProviderConfig holds provider-specific settings.
|
|
type ProviderConfig struct {
|
|
Type string `yaml:"type"`
|
|
Model string `yaml:"model"`
|
|
APIKey string `yaml:"api_key"`
|
|
BaseURL string `yaml:"base_url,omitempty"`
|
|
MaxTokens int `yaml:"max_tokens,omitempty"`
|
|
Temperature float32 `yaml:"temperature,omitempty"`
|
|
}
|
|
|
|
// ToolPolicy controls which tools are available and their permissions.
|
|
type ToolPolicy struct {
|
|
DefaultPermission string `yaml:"default_permission"`
|
|
AllowList []string `yaml:"allow_list,omitempty"`
|
|
DenyList []string `yaml:"deny_list,omitempty"`
|
|
}
|
|
|
|
// LoggingConfig controls logging output.
|
|
type LoggingConfig struct {
|
|
Level string `yaml:"level"`
|
|
Format string `yaml:"format"`
|
|
Output string `yaml:"output"`
|
|
}
|
|
|
|
// Config is the top-level configuration for the agent.
|
|
type Config struct {
|
|
Model string `yaml:"model"`
|
|
Provider ProviderConfig `yaml:"provider"`
|
|
Tools ToolPolicy `yaml:"tools"`
|
|
Logging LoggingConfig `yaml:"logging"`
|
|
}
|
|
|
|
// Loader is responsible for loading configuration from various sources.
|
|
type Loader interface {
|
|
Load(ctx context.Context, workdir string) (Config, error)
|
|
}
|
|
|
|
// ErrConfigNotFound is returned when no configuration file is found.
|
|
var ErrConfigNotFound = fmt.Errorf("config file not found")
|
|
|
|
// ErrInvalidConfig is returned when the configuration is invalid.
|
|
var ErrInvalidConfig = fmt.Errorf("invalid configuration")
|
|
|
|
// LoadDefault returns a Config with sensible defaults.
|
|
func LoadDefault() Config {
|
|
return Config{
|
|
Model: "gpt-4o",
|
|
Provider: ProviderConfig{
|
|
Type: "openai",
|
|
Model: "gpt-4o",
|
|
Temperature: 0.7,
|
|
MaxTokens: 4096,
|
|
},
|
|
Tools: ToolPolicy{
|
|
DefaultPermission: "allow",
|
|
},
|
|
Logging: LoggingConfig{
|
|
Level: "info",
|
|
Format: "text",
|
|
Output: "stderr",
|
|
},
|
|
}
|
|
}
|