Documentation
¶
Index ¶
- Constants
- Variables
- func CreateProvider(cfg *Config) (provider.Provider, error)
- func GetConfigDir() string
- type Config
- type DisplayConfig
- type GatewayConfig
- type MCPConfig
- type MemoryConfig
- type PlatformConfig
- type ProviderConfig
- type ProviderInfo
- 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 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"`
Providers map[string]ProviderConfig `json:"providers"`
Tools ToolsConfig `json:"tools"`
Memory MemoryConfig `json:"memory"`
Gateway GatewayConfig `json:"gateway"`
CortexEnabled bool `json:"cortex_enabled,omitempty"`
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"`
Agent struct {
GoalMaxTurns int `json:"goal_max_turns"`
} `json:"agent,omitempty"`
}
Config represents the application configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default configuration (exported version)
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 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 ProviderConfig ¶
type ProviderConfig struct {
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Model string `json:"model,omitempty"`
}
ProviderConfig represents provider configuration Note: api_key uses omitempty to prevent accidentally overwriting with empty value on Save()
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 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)