Documentation
¶
Index ¶
- Constants
- Variables
- func CreateProvider(cfg *Config) (provider.Provider, error)
- func GetConfigDir() string
- type ApprovalConfig
- type Config
- type CortexConfig
- type DisplayConfig
- type GatewayConfig
- type Loader
- type MCPConfig
- type MemoryConfig
- type PlatformConfig
- type PluginsConfig
- type ProviderConfig
- type ProviderInfo
- type SkillsConfig
- type SubAgentConfig
- type ToolsConfig
- type VoiceConfig
Constants ¶
const ( DefaultMagicHome = "~/.magic" ConfigFileName = "config.json" )
Variables ¶
var ErrNoConfig = fmt.Errorf("config file not found")
ErrNoConfig indicates that no config file exists (first run).
Functions ¶
func CreateProvider ¶ added in v0.3.0
CreateProvider creates a provider.Provider from the given Config. It uses cfg.Provider as the provider name and looks up cfg.Providers[cfg.Provider] for API key, base URL, and model overrides. Returns an error if the provider is unknown or not configured.
func GetConfigDir ¶ added in v0.2.0
func GetConfigDir() string
GetConfigDir returns the configuration directory path.
Types ¶
type ApprovalConfig ¶ added in v0.4.12
type ApprovalConfig struct {
Strategy string `json:"strategy"` // "smart", "manual", "auto"
TrustThreshold int `json:"trust_threshold"` // Auto-approve after N trusted uses
EnableLearning bool `json:"enable_learning"` // Learn from user decisions
EnableCLIConfirm bool `json:"enable_cli_confirm"` // Enable CLI confirmation prompt
ApprovalTimeout int `json:"approval_timeout"` // Approval timeout in seconds
}
ApprovalConfig represents command approval system configuration
func DefaultApprovalConfig ¶ added in v0.4.12
func DefaultApprovalConfig() *ApprovalConfig
DefaultApprovalConfig returns default approval configuration
type Config ¶
type Config struct {
Profile string `json:"profile"`
MagicHome string `json:"magic_home"`
WorkingDir string `json:"working_dir,omitempty"`
Provider string `json:"provider"`
Model string `json:"model"` // Deprecated: Use Providers[].Models[0] instead
Providers map[string]ProviderConfig `json:"providers"`
Tools ToolsConfig `json:"tools"`
Skills SkillsConfig `json:"skills"`
Plugins PluginsConfig `json:"plugins"`
Memory MemoryConfig `json:"memory"`
Gateway GatewayConfig `json:"gateway"`
Cortex CortexConfig `json:"cortex"`
MCP *MCPConfig `json:"mcp,omitempty"`
SubAgent *SubAgentConfig `json:"subagent,omitempty"`
Voice *VoiceConfig `json:"voice,omitempty"`
Privacy *privacy.Config `json:"privacy,omitempty"`
Display DisplayConfig `json:"display,omitempty"`
// Agent settings
SecretRedaction bool `json:"secret_redaction,omitempty"`
Mode string `json:"mode,omitempty"` // chat, plan, act
ChatMode string `json:"chat_mode,omitempty"` // chat, coding - default mode for magic chat
AutoLinkGoals bool `json:"auto_link_goals,omitempty"` // Auto-link new sessions to active goals
Agent struct {
GoalMaxTurns int `json:"goal_max_turns"`
} `json:"agent,omitempty"`
// Approval settings
Approval *ApprovalConfig `json:"approval,omitempty"`
}
Config represents the application configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default configuration (exported version)
func LegacyLoad ¶ added in v0.4.10
LegacyLoad provides backward compatibility for existing code Deprecated: Use Loader.Load() instead
func (*Config) GetCurrentModel ¶ added in v0.4.14
GetCurrentModel returns the current model from the configured provider's Models array
type CortexConfig ¶ added in v0.4.16
type CortexConfig struct {
Enabled bool `json:"enabled"` // Enable/disable Cortex system
SkillMinPatternFreq int `json:"skill_min_pattern_freq"` // Min frequency for skill pattern detection
}
CortexConfig represents Cortex AI configuration
type DisplayConfig ¶ added in v0.2.0
type DisplayConfig struct {
Skin string `json:"skin,omitempty"` // Active skin name
NoColor bool `json:"no_color,omitempty"` // Disable colors
ShowBanner bool `json:"show_banner,omitempty"` // Show startup banner
ShowVersion bool `json:"show_version,omitempty"` // Show version info
}
DisplayConfig represents display/UI configuration
type GatewayConfig ¶
type GatewayConfig struct {
Enabled bool `json:"enabled"`
Platforms map[string]PlatformConfig `json:"platforms"`
}
GatewayConfig represents gateway configuration
type Loader ¶ added in v0.4.10
type Loader struct {
// contains filtered or unexported fields
}
Loader provides unified configuration loading This consolidates all config loading logic into a single entry point
func NewLoaderWithPath ¶ added in v0.4.10
NewLoaderWithPath creates a loader with custom config path
func (*Loader) ConfigFilePath ¶ added in v0.4.10
ConfigFilePath returns the path to the config file
func (*Loader) Load ¶ added in v0.4.10
func (l *Loader) Load() (*configtypes.Config, error)
Load loads the configuration from the default location This is the unified entry point for all configuration loading
func (*Loader) LoadFromFile ¶ added in v0.4.10
func (l *Loader) LoadFromFile(path string) (*configtypes.Config, error)
LoadFromFile loads configuration from a specific file path
type MCPConfig ¶
type MCPConfig struct {
Servers map[string]mcp.ServerConfig `json:"servers,omitempty"`
}
MCPConfig represents MCP server configuration
type MemoryConfig ¶ added in v0.3.0
type MemoryConfig struct {
Enabled bool `json:"enabled"`
}
MemoryConfig represents memory configuration
type PlatformConfig ¶
type PlatformConfig struct {
Token string `json:"token,omitempty"`
Enabled bool `json:"enabled"`
// Channel allowlist/blocklist - only respond to messages from allowed channels
AllowedChannels []string `json:"allowed_channels,omitempty"` // Whitelist of channel/chat IDs; empty means allow all
BlockedChannels []string `json:"blocked_channels,omitempty"` // Blacklist of channel/chat IDs; takes precedence over whitelist
// WeCom fields
CorpID string `json:"corp_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
Secret string `json:"secret,omitempty"`
// QQ fields
Number string `json:"number,omitempty"`
Password string `json:"password,omitempty"`
// DingTalk fields
AppKey string `json:"app_key,omitempty"`
AppSecret string `json:"app_secret,omitempty"`
// Feishu/Lark fields
AppID string `json:"app_id,omitempty"`
APIURL string `json:"api_url,omitempty"`
APIKey string `json:"api_key,omitempty"`
// WhatsApp fields
VerifyToken string `json:"verify_token,omitempty"`
Mode string `json:"mode,omitempty"` // WhatsApp: "personal" (QR login, default) or "business" (API)
// WeCom fields: Mode = "qr" (QR code login, default) or "app" (API callback mode)
// WeChat fields: Mode = "qr" (QR code login, default) or "callback" (webhook mode)
// WeChat ClawBot fields
AESKey string `json:"aes_key,omitempty"`
// WeChat ClawBot fields
ClientID string `json:"client_id,omitempty"`
DataDir string `json:"data_dir,omitempty"`
AutoLogin bool `json:"auto_login,omitempty"`
}
PlatformConfig represents platform-specific configuration
type PluginsConfig ¶ added in v0.4.10
PluginsConfig represents plugins configuration
type ProviderConfig ¶
type ProviderConfig struct {
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Model string `json:"model,omitempty"` // Deprecated: use Models[0] instead, kept for backward compatibility
Models []string `json:"models,omitempty"` // List of supported models, first element is current model
}
ProviderConfig represents provider configuration Note: api_key uses omitempty to prevent accidentally overwriting with empty value on Save() Model is deprecated, use Models[0] as current model instead
func (*ProviderConfig) GetCurrentModel ¶ added in v0.4.14
func (p *ProviderConfig) GetCurrentModel() string
GetCurrentModel returns the current model (first element of Models, fallback to Model field)
type ProviderInfo ¶ added in v0.3.0
type ProviderInfo struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Models []string `json:"models"`
NeedsAPIKey bool `json:"needs_api_key"`
NeedsBaseURL bool `json:"needs_base_url"`
}
ProviderInfo contains metadata about a supported provider.
func ListProviders ¶ added in v0.3.0
func ListProviders() []ProviderInfo
ListProviders returns all supported providers with their metadata.
type SkillsConfig ¶ added in v0.4.10
type SkillsConfig struct {
Enabled []string `json:"enabled"`
Disabled []string `json:"disabled"`
DefaultDir string `json:"default_dir,omitempty"` // Path to built-in default skills
UserDir string `json:"user_dir,omitempty"` // Path to user-installed skills
}
SkillsConfig represents skills configuration
type SubAgentConfig ¶
type SubAgentConfig struct {
MaxConcurrent int `json:"max_concurrent"`
MaxDepth int `json:"max_depth"`
Timeout time.Duration `json:"timeout"`
}
SubAgentConfig represents subagent configuration
func DefaultSubAgentConfig ¶
func DefaultSubAgentConfig() *SubAgentConfig
DefaultSubAgentConfig returns default subagent configuration
type ToolsConfig ¶
ToolsConfig represents tools configuration
type VoiceConfig ¶
type VoiceConfig = voice.VoiceConfig
VoiceConfig represents voice configuration (alias for voice.VoiceConfig)