Documentation
¶
Overview ¶
Package userconfig provides user-level configuration for cagent. This configuration is stored in ~/.config/cagent/config.yaml and contains user preferences like aliases.
Index ¶
Constants ¶
const CurrentVersion = "v1"
CurrentVersion is the current version of the user config format
Variables ¶
This section is empty.
Functions ¶
func ValidateAliasName ¶
ValidateAliasName checks if an alias name is valid. Valid names must: - Not be empty - Start with an alphanumeric character - Contain only alphanumeric characters, hyphens, and underscores - Not contain path separators or special characters
Types ¶
type Alias ¶
type Alias struct {
// Path is the agent file path or OCI reference
Path string `yaml:"path"`
// Yolo enables auto-approve mode for all tool calls
Yolo bool `yaml:"yolo,omitempty"`
// Model overrides the agent's model (format: [agent=]provider/model)
Model string `yaml:"model,omitempty"`
// HideToolResults hides tool call results in the TUI
HideToolResults bool `yaml:"hide_tool_results,omitempty"`
}
Alias represents an alias configuration with optional runtime settings
func (*Alias) HasOptions ¶
HasOptions returns true if the alias has any runtime options set
type Config ¶
type Config struct {
// Version is the config format version
Version string `yaml:"version,omitempty"`
// ModelsGateway is the default models gateway URL
ModelsGateway string `yaml:"models_gateway,omitempty"`
// Aliases maps alias names to alias configurations
Aliases map[string]*Alias `yaml:"aliases,omitempty"`
// Settings contains global user settings
Settings *Settings `yaml:"settings,omitempty"`
// CredentialHelper configures an external command to retrieve Docker credentials
CredentialHelper *CredentialHelper `yaml:"credential_helper,omitempty"`
// contains filtered or unexported fields
}
Config represents the user-level cagent configuration
func Load ¶
Load loads the user configuration from the config file. If the config file doesn't exist but a legacy aliases.yaml does, the aliases are migrated to the new config file.
func (*Config) DeleteAlias ¶
DeleteAlias removes an alias by name. It returns true if the alias existed.
This method is safe for concurrent use. Access to the Aliases map is protected by a mutex to prevent concurrent map read/write panics when called from parallel tests or goroutines.
func (*Config) GetAlias ¶
GetAlias retrieves the alias configuration for a given name.
This method is safe for concurrent use. Reads from the Aliases map are protected by a mutex to avoid concurrent read/write panics when aliases are accessed while being modified.
func (*Config) GetSettings ¶ added in v1.19.5
GetSettings returns the global settings, or an empty Settings if not set
func (*Config) SetAlias ¶
SetAlias creates or updates an alias. Returns an error if the alias name or alias configuration is invalid.
This method is safe for concurrent use. Writes to the Aliases map are protected by a mutex to avoid concurrent map write panics when aliases are modified from multiple goroutines.
type CredentialHelper ¶ added in v1.19.5
type CredentialHelper struct {
// Command is the CLI command to execute to retrieve the Docker token.
// The command should output the token on stdout.
Command string `yaml:"command,omitempty"`
Args []string `yaml:"args,omitempty"`
}
CredentialHelper contains configuration for a credential helper command that retrieves Docker credentials (DOCKER_TOKEN) from an external source.