config

package
v0.0.0-...-8155ea7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-2.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxMediaSize = 20 * 1024 * 1024 // 20 MB

Variables

View Source
var (
	Version   = "dev" // Default value when not built with ldflags
	GitCommit string  // Git commit SHA (short)
	BuildTime string  // Build timestamp in RFC3339 format
	GoVersion string  // Go version used for building
)

Build-time variables injected via ldflags during build process. These are set by the Makefile or .goreleaser.yaml using the -X flag:

-X github.com/RealityLink-Tech/MoonHub/pkg/config.Version=<version>
-X github.com/RealityLink-Tech/MoonHub/pkg/config.GitCommit=<commit>
-X github.com/RealityLink-Tech/MoonHub/pkg/config.BuildTime=<timestamp>
-X github.com/RealityLink-Tech/MoonHub/pkg/config.GoVersion=<go-version>

Functions

func FormatBuildInfo

func FormatBuildInfo() (string, string)

FormatBuildInfo returns build time and go version info

func FormatVersion

func FormatVersion() string

FormatVersion returns the version string with optional git commit

func GetVersion

func GetVersion() string

GetVersion returns the version string

func MergeAPIKeys

func MergeAPIKeys(apiKey string, apiKeys []string) []string

func SaveConfig

func SaveConfig(path string, cfg *Config) error

Types

type AdaptiveMemoryConfig

type AdaptiveMemoryConfig struct {
	Enabled                  bool    `json:"enabled"                      env:"MOONHUB_ADAPTIVE_MEMORY_ENABLED"`
	EnableChinese            bool    `json:"enable_chinese"               env:"MOONHUB_ADAPTIVE_MEMORY_ENABLE_CHINESE"`
	FTSMaxResults            int     `json:"fts_max_results"              env:"MOONHUB_ADAPTIVE_MEMORY_FTS_MAX_RESULTS"`
	ContextMaxResults        int     `json:"context_max_results"          env:"MOONHUB_ADAPTIVE_MEMORY_CONTEXT_MAX_RESULTS"`
	DecayOlderThanDays       int     `json:"decay_older_than_days"        env:"MOONHUB_ADAPTIVE_MEMORY_DECAY_OLDER_THAN_DAYS"`
	DecayFactor              float64 `json:"decay_factor"                 env:"MOONHUB_ADAPTIVE_MEMORY_DECAY_FACTOR"`
	PruneImportanceMax       float64 `json:"prune_importance_max"         env:"MOONHUB_ADAPTIVE_MEMORY_PRUNE_IMPORTANCE_MAX"`
	PruneAccessCountMax      int     `json:"prune_access_count_max"       env:"MOONHUB_ADAPTIVE_MEMORY_PRUNE_ACCESS_COUNT_MAX"`
	PruneOlderThanDays       int     `json:"prune_older_than_days"        env:"MOONHUB_ADAPTIVE_MEMORY_PRUNE_OLDER_THAN_DAYS"`
	MergeSimilarityThreshold float64 `json:"merge_similarity_threshold"   env:"MOONHUB_ADAPTIVE_MEMORY_MERGE_SIMILARITY_THRESHOLD"`
}

AdaptiveMemoryConfig configures the adaptive memory system

func DefaultAdaptiveMemoryConfig

func DefaultAdaptiveMemoryConfig() AdaptiveMemoryConfig

DefaultAdaptiveMemoryConfig returns the default adaptive memory configuration

type AgentBinding

type AgentBinding struct {
	AgentID string       `json:"agent_id"`
	Match   BindingMatch `json:"match"`
}

type AgentConfig

type AgentConfig struct {
	ID        string            `json:"id"`
	Default   bool              `json:"default,omitempty"`
	Name      string            `json:"name,omitempty"`
	Workspace string            `json:"workspace,omitempty"`
	Model     *AgentModelConfig `json:"model,omitempty"`
	Skills    []string          `json:"skills,omitempty"`
	Subagents *SubagentsConfig  `json:"subagents,omitempty"`
}

type AgentDefaults

type AgentDefaults struct {
	Workspace                 string         `json:"workspace"                       env:"MOONHUB_AGENTS_DEFAULTS_WORKSPACE"`
	RestrictToWorkspace       bool           `json:"restrict_to_workspace"           env:"MOONHUB_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE"`
	AllowReadOutsideWorkspace bool           `json:"allow_read_outside_workspace"    env:"MOONHUB_AGENTS_DEFAULTS_ALLOW_READ_OUTSIDE_WORKSPACE"`
	Provider                  string         `json:"provider"                        env:"MOONHUB_AGENTS_DEFAULTS_PROVIDER"`
	ModelName                 string         `json:"model_name"                      env:"MOONHUB_AGENTS_DEFAULTS_MODEL_NAME"`
	Model                     string         `json:"model,omitempty"                 env:"MOONHUB_AGENTS_DEFAULTS_MODEL"` // Deprecated: use model_name instead
	ModelFallbacks            []string       `json:"model_fallbacks,omitempty"`
	ImageModel                string         `json:"image_model,omitempty"           env:"MOONHUB_AGENTS_DEFAULTS_IMAGE_MODEL"`
	ImageModelFallbacks       []string       `json:"image_model_fallbacks,omitempty"`
	MaxTokens                 int            `json:"max_tokens"                      env:"MOONHUB_AGENTS_DEFAULTS_MAX_TOKENS"`
	Temperature               *float64       `json:"temperature,omitempty"           env:"MOONHUB_AGENTS_DEFAULTS_TEMPERATURE"`
	MaxToolIterations         int            `json:"max_tool_iterations"             env:"MOONHUB_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
	SummarizeMessageThreshold int            `json:"summarize_message_threshold"     env:"MOONHUB_AGENTS_DEFAULTS_SUMMARIZE_MESSAGE_THRESHOLD"`
	SummarizeTokenPercent     int            `json:"summarize_token_percent"         env:"MOONHUB_AGENTS_DEFAULTS_SUMMARIZE_TOKEN_PERCENT"`
	MaxMediaSize              int            `json:"max_media_size,omitempty"        env:"MOONHUB_AGENTS_DEFAULTS_MAX_MEDIA_SIZE"`
	Routing                   *RoutingConfig `json:"routing,omitempty"`
}

func (*AgentDefaults) GetMaxMediaSize

func (d *AgentDefaults) GetMaxMediaSize() int

func (*AgentDefaults) GetModelName

func (d *AgentDefaults) GetModelName() string

GetModelName returns the effective model name for the agent defaults. It prefers the new "model_name" field but falls back to "model" for backward compatibility.

type AgentModelConfig

type AgentModelConfig struct {
	Primary   string   `json:"primary,omitempty"`
	Fallbacks []string `json:"fallbacks,omitempty"`
}

AgentModelConfig supports both string and structured model config. String format: "gpt-4" (just primary, no fallbacks) Object format: {"primary": "gpt-4", "fallbacks": ["claude-haiku"]}

func (AgentModelConfig) MarshalJSON

func (m AgentModelConfig) MarshalJSON() ([]byte, error)

func (*AgentModelConfig) UnmarshalJSON

func (m *AgentModelConfig) UnmarshalJSON(data []byte) error

type AgentsConfig

type AgentsConfig struct {
	Defaults AgentDefaults `json:"defaults"`
	List     []AgentConfig `json:"list,omitempty"`
}

type BindingMatch

type BindingMatch struct {
	Channel   string     `json:"channel"`
	AccountID string     `json:"account_id,omitempty"`
	Peer      *PeerMatch `json:"peer,omitempty"`
	GuildID   string     `json:"guild_id,omitempty"`
	TeamID    string     `json:"team_id,omitempty"`
}

type BraveConfig

type BraveConfig struct {
	Enabled    bool     `json:"enabled"     env:"MOONHUB_TOOLS_WEB_BRAVE_ENABLED"`
	APIKey     string   `json:"api_key"     env:"MOONHUB_TOOLS_WEB_BRAVE_API_KEY"`
	APIKeys    []string `json:"api_keys"    env:"MOONHUB_TOOLS_WEB_BRAVE_API_KEYS"`
	MaxResults int      `json:"max_results" env:"MOONHUB_TOOLS_WEB_BRAVE_MAX_RESULTS"`
}

type BuildInfo

type BuildInfo struct {
	Version   string `json:"version"`
	GitCommit string `json:"git_commit"`
	BuildTime string `json:"build_time"`
	GoVersion string `json:"go_version"`
}

BuildInfo contains build-time version information

type ChannelsConfig

type ChannelsConfig struct {
	WhatsApp   WhatsAppConfig   `json:"whatsapp"`
	Telegram   TelegramConfig   `json:"telegram"`
	Feishu     FeishuConfig     `json:"feishu"`
	Discord    DiscordConfig    `json:"discord"`
	MaixCam    MaixCamConfig    `json:"maixcam"`
	QQ         QQConfig         `json:"qq"`
	DingTalk   DingTalkConfig   `json:"dingtalk"`
	Slack      SlackConfig      `json:"slack"`
	Matrix     MatrixConfig     `json:"matrix"`
	LINE       LINEConfig       `json:"line"`
	OneBot     OneBotConfig     `json:"onebot"`
	WeCom      WeComConfig      `json:"wecom"`
	WeComApp   WeComAppConfig   `json:"wecom_app"`
	WeComAIBot WeComAIBotConfig `json:"wecom_aibot"`
	MoonHub    MoonHubConfig    `json:"moonhub"`
	IRC        IRCConfig        `json:"irc"`
}

type ClawHubRegistryConfig

type ClawHubRegistryConfig struct {
	Enabled         bool   `json:"enabled"           env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_ENABLED"`
	BaseURL         string `json:"base_url"          env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_BASE_URL"`
	AuthToken       string `json:"auth_token"        env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_AUTH_TOKEN"`
	SearchPath      string `json:"search_path"       env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_SEARCH_PATH"`
	SkillsPath      string `json:"skills_path"       env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_SKILLS_PATH"`
	DownloadPath    string `json:"download_path"     env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_DOWNLOAD_PATH"`
	Timeout         int    `json:"timeout"           env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_TIMEOUT"`
	MaxZipSize      int    `json:"max_zip_size"      env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_MAX_ZIP_SIZE"`
	MaxResponseSize int    `json:"max_response_size" env:"MOONHUB_SKILLS_REGISTRIES_CLAWHUB_MAX_RESPONSE_SIZE"`
}

type CloudConfig

type CloudConfig struct {
	Enabled           bool   `json:"enabled"                       env:"MOONHUB_CLOUD_ENABLED"`
	DirectoryURL      string `json:"directory_url"                 env:"MOONHUB_CLOUD_DIRECTORY_URL"`
	RelayURL          string `json:"relay_url"                     env:"MOONHUB_CLOUD_RELAY_URL"`
	HeartbeatInterval int    `json:"heartbeat_interval,omitempty"  env:"MOONHUB_CLOUD_HEARTBEAT_INTERVAL"`
	RegisterOnBoot    bool   `json:"register_on_boot,omitempty"    env:"MOONHUB_CLOUD_REGISTER_ON_BOOT"`
}

CloudConfig configures cloud directory and relay services.

type CompactorConfig

type CompactorConfig struct {
	Enabled                  bool              `json:"enabled"                     env:"MOONHUB_COMPACTOR_ENABLED"`
	TriggerTokenPercent      int               `json:"trigger_token_percent"       env:"MOONHUB_COMPACTOR_TRIGGER_TOKEN_PERCENT"`
	KeepRecent               int               `json:"keep_recent"                 env:"MOONHUB_COMPACTOR_KEEP_RECENT"`
	TierBudgets              TierBudgetsConfig `json:"tier_budgets"`
	DedupEnabled             bool              `json:"dedup_enabled"               env:"MOONHUB_COMPACTOR_DEDUP_ENABLED"`
	DedupSimilarityThreshold float64           `json:"dedup_similarity_threshold"  env:"MOONHUB_COMPACTOR_DEDUP_SIMILARITY_THRESHOLD"`
	StripEmoji               bool              `json:"strip_emoji"                 env:"MOONHUB_COMPACTOR_STRIP_EMOJI"`
	RemoveDuplicateLines     bool              `json:"remove_duplicate_lines"      env:"MOONHUB_COMPACTOR_REMOVE_DUPLICATE_LINES"`
	NormalizeCJK             bool              `json:"normalize_cjk"               env:"MOONHUB_COMPACTOR_NORMALIZE_CJK"`
	SmartRuleSelection       bool              `json:"smart_rule_selection"        env:"MOONHUB_COMPACTOR_SMART_RULE_SELECTION"`
	ParallelProcessing       bool              `json:"parallel_processing"         env:"MOONHUB_COMPACTOR_PARALLEL_PROCESSING"`
	IncrementalCompaction    bool              `json:"incremental_compaction"      env:"MOONHUB_COMPACTOR_INCREMENTAL_COMPACTION"`
	SummarizationModel       string            `json:"summarization_model"         env:"MOONHUB_COMPACTOR_SUMMARIZATION_MODEL"`
}

CompactorConfig configures the 4-layer context compactor system

func DefaultCompactorConfig

func DefaultCompactorConfig() CompactorConfig

DefaultCompactorConfig returns the default compactor configuration

type Config

type Config struct {
	Agents         AgentsConfig         `json:"agents"`
	Bindings       []AgentBinding       `json:"bindings,omitempty"`
	Session        SessionConfig        `json:"session,omitempty"`
	Channels       ChannelsConfig       `json:"channels"`
	Providers      ProvidersConfig      `json:"providers,omitempty"`
	ModelList      []ModelConfig        `json:"model_list"` // New model-centric provider configuration
	Gateway        GatewayConfig        `json:"gateway"`
	Tools          ToolsConfig          `json:"tools"`
	Heartbeat      HeartbeatConfig      `json:"heartbeat"`
	Devices        DevicesConfig        `json:"devices"`
	Voice          VoiceConfig          `json:"voice"`
	AdaptiveMemory AdaptiveMemoryConfig `json:"adaptive_memory,omitempty"` // Adaptive memory system configuration
	Compactor      CompactorConfig      `json:"compactor,omitempty"`       // Context compactor configuration
	Delegation     DelegationConfig     `json:"delegation,omitempty"`      // Delegation system configuration
	Cloud          CloudConfig          `json:"cloud,omitempty"`           // Cloud directory and relay configuration
	// BuildInfo contains build-time version information
	BuildInfo BuildInfo `json:"build_info,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for MoonHub.

func LoadConfig

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

func (*Config) GetAPIBase

func (c *Config) GetAPIBase() string

func (*Config) GetAPIKey

func (c *Config) GetAPIKey() string

func (*Config) GetModelConfig

func (c *Config) GetModelConfig(modelName string) (*ModelConfig, error)

GetModelConfig returns the ModelConfig for the given model name. If multiple configs exist with the same model_name, it uses round-robin selection for load balancing. Returns an error if the model is not found.

func (*Config) HasProvidersConfig

func (c *Config) HasProvidersConfig() bool

HasProvidersConfig checks if any provider in the old providers config has configuration.

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for Config to omit providers section when empty and session when empty

func (*Config) ValidateModelList

func (c *Config) ValidateModelList() error

ValidateModelList validates all ModelConfig entries in the model_list. It checks that each model config is valid. Note: Multiple entries with the same model_name are allowed for load balancing.

func (*Config) WorkspacePath

func (c *Config) WorkspacePath() string

type CronToolsConfig

type CronToolsConfig struct {
	ToolConfig         `    envPrefix:"MOONHUB_TOOLS_CRON_"`
	ExecTimeoutMinutes int `                                 env:"MOONHUB_TOOLS_CRON_EXEC_TIMEOUT_MINUTES" json:"exec_timeout_minutes"` // 0 means no timeout
}

type DelegationConfig

type DelegationConfig struct {
	Enabled              bool     `json:"enabled"                env:"MOONHUB_DELEGATION_ENABLED"`
	DefaultSubAgentTools []string `json:"default_sub_agent_tools"`
	MaxActivePerUser     int      `json:"max_active_per_user"    env:"MOONHUB_DELEGATION_MAX_ACTIVE_PER_USER"`
	MaxConcurrentTasks   int      `json:"max_concurrent_tasks"   env:"MOONHUB_DELEGATION_MAX_CONCURRENT_TASKS"`
	RetentionDays        int      `json:"retention_days"         env:"MOONHUB_DELEGATION_RETENTION_DAYS"`
	ReuseThreshold       float64  `json:"reuse_threshold"        env:"MOONHUB_DELEGATION_REUSE_THRESHOLD"`
}

DelegationConfig configures the sub-agent delegation system

func DefaultDelegationConfig

func DefaultDelegationConfig() DelegationConfig

DefaultDelegationConfig returns the default delegation configuration

type DevicesConfig

type DevicesConfig struct {
	Enabled    bool `json:"enabled"     env:"MOONHUB_DEVICES_ENABLED"`
	MonitorUSB bool `json:"monitor_usb" env:"MOONHUB_DEVICES_MONITOR_USB"`
}

type DingTalkConfig

type DingTalkConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_DINGTALK_ENABLED"`
	ClientID           string              `json:"client_id"               env:"MOONHUB_CHANNELS_DINGTALK_CLIENT_ID"`
	ClientSecret       string              `json:"client_secret"           env:"MOONHUB_CHANNELS_DINGTALK_CLIENT_SECRET"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_DINGTALK_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_DINGTALK_REASONING_CHANNEL_ID"`
}

type DiscordConfig

type DiscordConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_DISCORD_ENABLED"`
	Token              string              `json:"token"                   env:"MOONHUB_CHANNELS_DISCORD_TOKEN"`
	Proxy              string              `json:"proxy"                   env:"MOONHUB_CHANNELS_DISCORD_PROXY"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_DISCORD_ALLOW_FROM"`
	MentionOnly        bool                `json:"mention_only"            env:"MOONHUB_CHANNELS_DISCORD_MENTION_ONLY"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_DISCORD_REASONING_CHANNEL_ID"`
}

type DuckDuckGoConfig

type DuckDuckGoConfig struct {
	Enabled    bool `json:"enabled"     env:"MOONHUB_TOOLS_WEB_DUCKDUCKGO_ENABLED"`
	MaxResults int  `json:"max_results" env:"MOONHUB_TOOLS_WEB_DUCKDUCKGO_MAX_RESULTS"`
}

type ExecConfig

type ExecConfig struct {
	ToolConfig          `         envPrefix:"MOONHUB_TOOLS_EXEC_"`
	EnableDenyPatterns  bool     `                                 env:"MOONHUB_TOOLS_EXEC_ENABLE_DENY_PATTERNS"  json:"enable_deny_patterns"`
	AllowRemote         bool     `                                 env:"MOONHUB_TOOLS_EXEC_ALLOW_REMOTE"          json:"allow_remote"`
	CustomDenyPatterns  []string `                                 env:"MOONHUB_TOOLS_EXEC_CUSTOM_DENY_PATTERNS"  json:"custom_deny_patterns"`
	CustomAllowPatterns []string `                                 env:"MOONHUB_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"`
	TimeoutSeconds      int      `                                 env:"MOONHUB_TOOLS_EXEC_TIMEOUT_SECONDS"       json:"timeout_seconds"` // 0 means use default (60s)
}

type FeishuConfig

type FeishuConfig struct {
	Enabled             bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_FEISHU_ENABLED"`
	AppID               string              `json:"app_id"                  env:"MOONHUB_CHANNELS_FEISHU_APP_ID"`
	AppSecret           string              `json:"app_secret"              env:"MOONHUB_CHANNELS_FEISHU_APP_SECRET"`
	EncryptKey          string              `json:"encrypt_key"             env:"MOONHUB_CHANNELS_FEISHU_ENCRYPT_KEY"`
	VerificationToken   string              `json:"verification_token"      env:"MOONHUB_CHANNELS_FEISHU_VERIFICATION_TOKEN"`
	AllowFrom           FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_FEISHU_ALLOW_FROM"`
	GroupTrigger        GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Placeholder         PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID  string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_FEISHU_REASONING_CHANNEL_ID"`
	RandomReactionEmoji FlexibleStringSlice `json:"random_reaction_emoji"   env:"MOONHUB_CHANNELS_FEISHU_RANDOM_REACTION_EMOJI"`
}

type FlexibleStringSlice

type FlexibleStringSlice []string

FlexibleStringSlice is a []string that also accepts JSON numbers, so allow_from can contain both "123" and 123. It also supports parsing comma-separated strings from environment variables, including both English (,) and Chinese (,) commas.

func (*FlexibleStringSlice) UnmarshalJSON

func (f *FlexibleStringSlice) UnmarshalJSON(data []byte) error

func (*FlexibleStringSlice) UnmarshalText

func (f *FlexibleStringSlice) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler to support env variable parsing. It handles comma-separated values with both English (,) and Chinese (,) commas.

type GLMSearchConfig

type GLMSearchConfig struct {
	Enabled bool   `json:"enabled"  env:"MOONHUB_TOOLS_WEB_GLM_ENABLED"`
	APIKey  string `json:"api_key"  env:"MOONHUB_TOOLS_WEB_GLM_API_KEY"`
	BaseURL string `json:"base_url" env:"MOONHUB_TOOLS_WEB_GLM_BASE_URL"`
	// SearchEngine specifies the search backend: "search_std" (default),
	// "search_pro", "search_pro_sogou", or "search_pro_quark".
	SearchEngine string `json:"search_engine" env:"MOONHUB_TOOLS_WEB_GLM_SEARCH_ENGINE"`
	MaxResults   int    `json:"max_results"   env:"MOONHUB_TOOLS_WEB_GLM_MAX_RESULTS"`
}

type GatewayConfig

type GatewayConfig struct {
	Host string `json:"host" env:"MOONHUB_GATEWAY_HOST"`
	Port int    `json:"port" env:"MOONHUB_GATEWAY_PORT"`
}

type GroupTriggerConfig

type GroupTriggerConfig struct {
	MentionOnly bool     `json:"mention_only,omitempty"`
	Prefixes    []string `json:"prefixes,omitempty"`
}

GroupTriggerConfig controls when the bot responds in group chats.

type HeartbeatConfig

type HeartbeatConfig struct {
	Enabled  bool `json:"enabled"  env:"MOONHUB_HEARTBEAT_ENABLED"`
	Interval int  `json:"interval" env:"MOONHUB_HEARTBEAT_INTERVAL"` // minutes, min 5
}

type IRCConfig

type IRCConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_IRC_ENABLED"`
	Server             string              `json:"server"                  env:"MOONHUB_CHANNELS_IRC_SERVER"`
	TLS                bool                `json:"tls"                     env:"MOONHUB_CHANNELS_IRC_TLS"`
	Nick               string              `json:"nick"                    env:"MOONHUB_CHANNELS_IRC_NICK"`
	User               string              `json:"user,omitempty"          env:"MOONHUB_CHANNELS_IRC_USER"`
	RealName           string              `json:"real_name,omitempty"     env:"MOONHUB_CHANNELS_IRC_REAL_NAME"`
	Password           string              `json:"password"                env:"MOONHUB_CHANNELS_IRC_PASSWORD"`
	NickServPassword   string              `json:"nickserv_password"       env:"MOONHUB_CHANNELS_IRC_NICKSERV_PASSWORD"`
	SASLUser           string              `json:"sasl_user"               env:"MOONHUB_CHANNELS_IRC_SASL_USER"`
	SASLPassword       string              `json:"sasl_password"           env:"MOONHUB_CHANNELS_IRC_SASL_PASSWORD"`
	Channels           FlexibleStringSlice `json:"channels"                env:"MOONHUB_CHANNELS_IRC_CHANNELS"`
	RequestCaps        FlexibleStringSlice `json:"request_caps,omitempty"  env:"MOONHUB_CHANNELS_IRC_REQUEST_CAPS"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_IRC_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_IRC_REASONING_CHANNEL_ID"`
}

type LINEConfig

type LINEConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_LINE_ENABLED"`
	ChannelSecret      string              `json:"channel_secret"          env:"MOONHUB_CHANNELS_LINE_CHANNEL_SECRET"`
	ChannelAccessToken string              `json:"channel_access_token"    env:"MOONHUB_CHANNELS_LINE_CHANNEL_ACCESS_TOKEN"`
	WebhookHost        string              `json:"webhook_host"            env:"MOONHUB_CHANNELS_LINE_WEBHOOK_HOST"`
	WebhookPort        int                 `json:"webhook_port"            env:"MOONHUB_CHANNELS_LINE_WEBHOOK_PORT"`
	WebhookPath        string              `json:"webhook_path"            env:"MOONHUB_CHANNELS_LINE_WEBHOOK_PATH"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_LINE_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_LINE_REASONING_CHANNEL_ID"`
}

type MCPConfig

type MCPConfig struct {
	ToolConfig `                    envPrefix:"MOONHUB_TOOLS_MCP_"`
	Discovery  ToolDiscoveryConfig `                                json:"discovery"`
	// Servers is a map of server name to server configuration
	Servers map[string]MCPServerConfig `json:"servers,omitempty"`
}

MCPConfig defines configuration for all MCP servers

type MCPServerConfig

type MCPServerConfig struct {
	// Enabled indicates whether this MCP server is active
	Enabled bool `json:"enabled"`
	// Command is the executable to run (e.g., "npx", "python", "/path/to/server")
	Command string `json:"command"`
	// Args are the arguments to pass to the command
	Args []string `json:"args,omitempty"`
	// Env are environment variables to set for the server process (stdio only)
	Env map[string]string `json:"env,omitempty"`
	// EnvFile is the path to a file containing environment variables (stdio only)
	EnvFile string `json:"env_file,omitempty"`
	// Type is "stdio", "sse", or "http" (default: stdio if command is set, sse if url is set)
	Type string `json:"type,omitempty"`
	// URL is used for SSE/HTTP transport
	URL string `json:"url,omitempty"`
	// Headers are HTTP headers to send with requests (sse/http only)
	Headers map[string]string `json:"headers,omitempty"`
}

MCPServerConfig defines configuration for a single MCP server

type MaixCamConfig

type MaixCamConfig struct {
	Enabled            bool                `json:"enabled"              env:"MOONHUB_CHANNELS_MAIXCAM_ENABLED"`
	Host               string              `json:"host"                 env:"MOONHUB_CHANNELS_MAIXCAM_HOST"`
	Port               int                 `json:"port"                 env:"MOONHUB_CHANNELS_MAIXCAM_PORT"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"           env:"MOONHUB_CHANNELS_MAIXCAM_ALLOW_FROM"`
	ReasoningChannelID string              `json:"reasoning_channel_id" env:"MOONHUB_CHANNELS_MAIXCAM_REASONING_CHANNEL_ID"`
}

type MatrixConfig

type MatrixConfig struct {
	Enabled            bool                `json:"enabled"                  env:"MOONHUB_CHANNELS_MATRIX_ENABLED"`
	Homeserver         string              `json:"homeserver"               env:"MOONHUB_CHANNELS_MATRIX_HOMESERVER"`
	UserID             string              `json:"user_id"                  env:"MOONHUB_CHANNELS_MATRIX_USER_ID"`
	AccessToken        string              `json:"access_token"             env:"MOONHUB_CHANNELS_MATRIX_ACCESS_TOKEN"`
	DeviceID           string              `json:"device_id,omitempty"      env:"MOONHUB_CHANNELS_MATRIX_DEVICE_ID"`
	JoinOnInvite       bool                `json:"join_on_invite"           env:"MOONHUB_CHANNELS_MATRIX_JOIN_ON_INVITE"`
	MessageFormat      string              `json:"message_format,omitempty" env:"MOONHUB_CHANNELS_MATRIX_MESSAGE_FORMAT"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"               env:"MOONHUB_CHANNELS_MATRIX_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"     env:"MOONHUB_CHANNELS_MATRIX_REASONING_CHANNEL_ID"`
}

type MediaCleanupConfig

type MediaCleanupConfig struct {
	ToolConfig `    envPrefix:"MOONHUB_MEDIA_CLEANUP_"`
	MaxAge     int `                                    env:"MOONHUB_MEDIA_CLEANUP_MAX_AGE"  json:"max_age_minutes"`
	Interval   int `                                    env:"MOONHUB_MEDIA_CLEANUP_INTERVAL" json:"interval_minutes"`
}

type ModelConfig

type ModelConfig struct {
	// Required fields
	ModelName string `json:"model_name"` // User-facing alias for the model
	Model     string `json:"model"`      // Protocol/model-identifier (e.g., "openai/gpt-4o", "anthropic/claude-sonnet-4.6")

	// HTTP-based providers
	APIBase string `json:"api_base,omitempty"` // API endpoint URL
	APIKey  string `json:"api_key"`            // API authentication key
	Proxy   string `json:"proxy,omitempty"`    // HTTP proxy URL

	// Special providers (CLI-based, OAuth, etc.)
	AuthMethod  string `json:"auth_method,omitempty"`  // Authentication method: oauth, token
	ConnectMode string `json:"connect_mode,omitempty"` // Connection mode: stdio, grpc
	Workspace   string `json:"workspace,omitempty"`    // Workspace path for CLI-based providers

	// Optional optimizations
	RPM            int    `json:"rpm,omitempty"`              // Requests per minute limit
	MaxTokensField string `json:"max_tokens_field,omitempty"` // Field name for max tokens (e.g., "max_completion_tokens")
	RequestTimeout int    `json:"request_timeout,omitempty"`
	ThinkingLevel  string `json:"thinking_level,omitempty"` // Extended thinking: off|low|medium|high|xhigh|adaptive
}

ModelConfig represents a model-centric provider configuration. It allows adding new providers (especially OpenAI-compatible ones) via configuration only. The model field uses protocol prefix format: [protocol/]model-identifier Supported protocols: openai, anthropic, antigravity, claude-cli, codex-cli, github-copilot Default protocol is "openai" if no prefix is specified.

func ConvertProvidersToModelList

func ConvertProvidersToModelList(cfg *Config) []ModelConfig

ConvertProvidersToModelList converts the old ProvidersConfig to a slice of ModelConfig. This enables backward compatibility with existing configurations. It preserves the user's configured model from agents.defaults.model when possible.

func (*ModelConfig) Validate

func (c *ModelConfig) Validate() error

Validate checks if the ModelConfig has all required fields.

type MoonHubConfig

type MoonHubConfig struct {
	Enabled        bool                `json:"enabled"                     env:"MOONHUB_CHANNELS_MOONHUB_ENABLED"`
	Port           int                 `json:"port,omitempty"              env:"MOONHUB_CHANNELS_MOONHUB_PORT"`
	Token          string              `json:"token"                       env:"MOONHUB_CHANNELS_MOONHUB_TOKEN"`
	AllowFrom      FlexibleStringSlice `json:"allow_from"                  env:"MOONHUB_CHANNELS_MOONHUB_ALLOW_FROM"`
	PingInterval   int                 `json:"ping_interval,omitempty"`
	ReadTimeout    int                 `json:"read_timeout,omitempty"`
	MaxConnections int                 `json:"max_connections,omitempty"`
}

type OneBotConfig

type OneBotConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_ONEBOT_ENABLED"`
	WSUrl              string              `json:"ws_url"                  env:"MOONHUB_CHANNELS_ONEBOT_WS_URL"`
	AccessToken        string              `json:"access_token"            env:"MOONHUB_CHANNELS_ONEBOT_ACCESS_TOKEN"`
	ReconnectInterval  int                 `json:"reconnect_interval"      env:"MOONHUB_CHANNELS_ONEBOT_RECONNECT_INTERVAL"`
	GroupTriggerPrefix []string            `json:"group_trigger_prefix"    env:"MOONHUB_CHANNELS_ONEBOT_GROUP_TRIGGER_PREFIX"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_ONEBOT_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_ONEBOT_REASONING_CHANNEL_ID"`
}

type OpenAIProviderConfig

type OpenAIProviderConfig struct {
	ProviderConfig
	WebSearch bool `json:"web_search" env:"MOONHUB_PROVIDERS_OPENAI_WEB_SEARCH"`
}

type PeerMatch

type PeerMatch struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

type PerplexityConfig

type PerplexityConfig struct {
	Enabled    bool     `json:"enabled"     env:"MOONHUB_TOOLS_WEB_PERPLEXITY_ENABLED"`
	APIKey     string   `json:"api_key"     env:"MOONHUB_TOOLS_WEB_PERPLEXITY_API_KEY"`
	APIKeys    []string `json:"api_keys"    env:"MOONHUB_TOOLS_WEB_PERPLEXITY_API_KEYS"`
	MaxResults int      `json:"max_results" env:"MOONHUB_TOOLS_WEB_PERPLEXITY_MAX_RESULTS"`
}

type PlaceholderConfig

type PlaceholderConfig struct {
	Enabled bool   `json:"enabled,omitempty"`
	Text    string `json:"text,omitempty"`
}

PlaceholderConfig controls placeholder message behavior (Phase 10).

type ProviderConfig

type ProviderConfig struct {
	APIKey         string `json:"api_key"                   env:"MOONHUB_PROVIDERS_{{.Name}}_API_KEY"`
	APIBase        string `json:"api_base"                  env:"MOONHUB_PROVIDERS_{{.Name}}_API_BASE"`
	Proxy          string `json:"proxy,omitempty"           env:"MOONHUB_PROVIDERS_{{.Name}}_PROXY"`
	RequestTimeout int    `json:"request_timeout,omitempty" env:"MOONHUB_PROVIDERS_{{.Name}}_REQUEST_TIMEOUT"`
	AuthMethod     string `json:"auth_method,omitempty"     env:"MOONHUB_PROVIDERS_{{.Name}}_AUTH_METHOD"`
	ConnectMode    string `json:"connect_mode,omitempty"    env:"MOONHUB_PROVIDERS_{{.Name}}_CONNECT_MODE"` // only for Github Copilot, `stdio` or `grpc`
}

type ProvidersConfig

type ProvidersConfig struct {
	Anthropic     ProviderConfig       `json:"anthropic"`
	OpenAI        OpenAIProviderConfig `json:"openai"`
	LiteLLM       ProviderConfig       `json:"litellm"`
	OpenRouter    ProviderConfig       `json:"openrouter"`
	Groq          ProviderConfig       `json:"groq"`
	Zhipu         ProviderConfig       `json:"zhipu"`
	VLLM          ProviderConfig       `json:"vllm"`
	Gemini        ProviderConfig       `json:"gemini"`
	Nvidia        ProviderConfig       `json:"nvidia"`
	Ollama        ProviderConfig       `json:"ollama"`
	Moonshot      ProviderConfig       `json:"moonshot"`
	ShengSuanYun  ProviderConfig       `json:"shengsuanyun"`
	DeepSeek      ProviderConfig       `json:"deepseek"`
	Cerebras      ProviderConfig       `json:"cerebras"`
	Vivgrid       ProviderConfig       `json:"vivgrid"`
	VolcEngine    ProviderConfig       `json:"volcengine"`
	GitHubCopilot ProviderConfig       `json:"github_copilot"`
	Antigravity   ProviderConfig       `json:"antigravity"`
	Qwen          ProviderConfig       `json:"qwen"`
	Mistral       ProviderConfig       `json:"mistral"`
	Avian         ProviderConfig       `json:"avian"`
	Minimax       ProviderConfig       `json:"minimax"`
	LongCat       ProviderConfig       `json:"longcat"`
	ModelScope    ProviderConfig       `json:"modelscope"`
}

func (ProvidersConfig) IsEmpty

func (p ProvidersConfig) IsEmpty() bool

IsEmpty checks if all provider configs are empty (no API keys or API bases set) Note: WebSearch is an optimization option and doesn't count as "non-empty"

func (ProvidersConfig) MarshalJSON

func (p ProvidersConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for ProvidersConfig to omit the entire section when empty

type QQConfig

type QQConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_QQ_ENABLED"`
	AppID              string              `json:"app_id"                  env:"MOONHUB_CHANNELS_QQ_APP_ID"`
	AppSecret          string              `json:"app_secret"              env:"MOONHUB_CHANNELS_QQ_APP_SECRET"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_QQ_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	MaxMessageLength   int                 `json:"max_message_length"      env:"MOONHUB_CHANNELS_QQ_MAX_MESSAGE_LENGTH"`
	SendMarkdown       bool                `json:"send_markdown"           env:"MOONHUB_CHANNELS_QQ_SEND_MARKDOWN"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_QQ_REASONING_CHANNEL_ID"`
}

type ReadFileToolConfig

type ReadFileToolConfig struct {
	Enabled         bool `json:"enabled"`
	MaxReadFileSize int  `json:"max_read_file_size"`
}

type RoutingConfig

type RoutingConfig struct {
	Enabled    bool    `json:"enabled"`
	LightModel string  `json:"light_model"` // model_name from model_list to use for simple tasks
	Threshold  float64 `json:"threshold"`   // complexity score in [0,1]; score >= threshold → primary model

	// V2 4-tier routing
	TierMapping    map[string]string     `json:"tier_mapping,omitempty"`    // tier -> model_name (e.g., {"simple": "gpt-3.5", "complex": "gpt-4"})
	TierBoundaries *TierBoundariesConfig `json:"tier_boundaries,omitempty"` // custom tier boundaries
}

RoutingConfig controls the intelligent model routing feature. When enabled, each incoming message is scored against structural features (message length, code blocks, tool call history, conversation depth, attachments). Messages scoring below Threshold are sent to LightModel; all others use the agent's primary model. This reduces cost and latency for simple tasks without requiring any keyword matching — all scoring is language-agnostic.

V2 4-tier routing: When TierMapping is configured, the router uses 4 tiers instead of 2: - simple: greetings, trivial Q&A - moderate: short questions, simple tasks - complex: coding, long context - reasoning: deep analysis, multi-modal

type SearXNGConfig

type SearXNGConfig struct {
	Enabled    bool   `json:"enabled"     env:"MOONHUB_TOOLS_WEB_SEARXNG_ENABLED"`
	BaseURL    string `json:"base_url"    env:"MOONHUB_TOOLS_WEB_SEARXNG_BASE_URL"`
	MaxResults int    `json:"max_results" env:"MOONHUB_TOOLS_WEB_SEARXNG_MAX_RESULTS"`
}

type SearchCacheConfig

type SearchCacheConfig struct {
	MaxSize    int `json:"max_size"    env:"MOONHUB_SKILLS_SEARCH_CACHE_MAX_SIZE"`
	TTLSeconds int `json:"ttl_seconds" env:"MOONHUB_SKILLS_SEARCH_CACHE_TTL_SECONDS"`
}

type SessionConfig

type SessionConfig struct {
	DMScope       string              `json:"dm_scope,omitempty"`
	IdentityLinks map[string][]string `json:"identity_links,omitempty"`
}

type SkillsGithubConfig

type SkillsGithubConfig struct {
	Token string `json:"token,omitempty" env:"MOONHUB_TOOLS_SKILLS_GITHUB_AUTH_TOKEN"`
	Proxy string `json:"proxy,omitempty" env:"MOONHUB_TOOLS_SKILLS_GITHUB_PROXY"`
}

type SkillsRegistriesConfig

type SkillsRegistriesConfig struct {
	ClawHub ClawHubRegistryConfig `json:"clawhub"`
}

type SkillsToolsConfig

type SkillsToolsConfig struct {
	ToolConfig            `                       envPrefix:"MOONHUB_TOOLS_SKILLS_"`
	Registries            SkillsRegistriesConfig `                                   json:"registries"`
	Github                SkillsGithubConfig     `                                   json:"github"`
	MaxConcurrentSearches int                    `                                   json:"max_concurrent_searches" env:"MOONHUB_TOOLS_SKILLS_MAX_CONCURRENT_SEARCHES"`
	SearchCache           SearchCacheConfig      `                                   json:"search_cache"`
}

type SlackConfig

type SlackConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_SLACK_ENABLED"`
	BotToken           string              `json:"bot_token"               env:"MOONHUB_CHANNELS_SLACK_BOT_TOKEN"`
	AppToken           string              `json:"app_token"               env:"MOONHUB_CHANNELS_SLACK_APP_TOKEN"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_SLACK_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_SLACK_REASONING_CHANNEL_ID"`
}

type SubagentsConfig

type SubagentsConfig struct {
	AllowAgents []string          `json:"allow_agents,omitempty"`
	Model       *AgentModelConfig `json:"model,omitempty"`
}

type TavilyConfig

type TavilyConfig struct {
	Enabled    bool     `json:"enabled"     env:"MOONHUB_TOOLS_WEB_TAVILY_ENABLED"`
	APIKey     string   `json:"api_key"     env:"MOONHUB_TOOLS_WEB_TAVILY_API_KEY"`
	APIKeys    []string `json:"api_keys"    env:"MOONHUB_TOOLS_WEB_TAVILY_API_KEYS"`
	BaseURL    string   `json:"base_url"    env:"MOONHUB_TOOLS_WEB_TAVILY_BASE_URL"`
	MaxResults int      `json:"max_results" env:"MOONHUB_TOOLS_WEB_TAVILY_MAX_RESULTS"`
}

type TelegramConfig

type TelegramConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_TELEGRAM_ENABLED"`
	Token              string              `json:"token"                   env:"MOONHUB_CHANNELS_TELEGRAM_TOKEN"`
	BaseURL            string              `json:"base_url"                env:"MOONHUB_CHANNELS_TELEGRAM_BASE_URL"`
	Proxy              string              `json:"proxy"                   env:"MOONHUB_CHANNELS_TELEGRAM_PROXY"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_TELEGRAM_ALLOW_FROM"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	Typing             TypingConfig        `json:"typing,omitempty"`
	Placeholder        PlaceholderConfig   `json:"placeholder,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_TELEGRAM_REASONING_CHANNEL_ID"`
}

type TierBoundariesConfig

type TierBoundariesConfig struct {
	SimpleModerate   *float64 `json:"simple_moderate,omitempty"`
	ModerateComplex  *float64 `json:"moderate_complex,omitempty"`
	ComplexReasoning *float64 `json:"complex_reasoning,omitempty"`
}

TierBoundariesConfig holds custom score boundaries for the 4-tier system. Each field defines the threshold between tiers. Pointer fields distinguish "JSON omitted / unset" from an explicit 0.0 (e.g. simple_moderate: 0). Omitted fields fall back to defaults: -0.05, 0.15, 0.35.

func (*TierBoundariesConfig) HasCustomBoundaries

func (c *TierBoundariesConfig) HasCustomBoundaries() bool

HasCustomBoundaries returns true if any cutpoint was set in JSON/config.

type TierBudgetsConfig

type TierBudgetsConfig struct {
	L0 int `json:"l0"` // Ultra-compact (default: 200 tokens)
	L1 int `json:"l1"` // Working memory (default: 1000 tokens)
	L2 int `json:"l2"` // Full context (default: 3000 tokens)
}

TierBudgetsConfig holds token budgets for each tier

type ToolConfig

type ToolConfig struct {
	Enabled bool `json:"enabled" env:"ENABLED"`
}

type ToolDiscoveryConfig

type ToolDiscoveryConfig struct {
	Enabled          bool `json:"enabled"            env:"MOONHUB_TOOLS_DISCOVERY_ENABLED"`
	TTL              int  `json:"ttl"                env:"MOONHUB_TOOLS_DISCOVERY_TTL"`
	MaxSearchResults int  `json:"max_search_results" env:"MOONHUB_MAX_SEARCH_RESULTS"`
	UseBM25          bool `json:"use_bm25"           env:"MOONHUB_TOOLS_DISCOVERY_USE_BM25"`
	UseRegex         bool `json:"use_regex"          env:"MOONHUB_TOOLS_DISCOVERY_USE_REGEX"`
}

type ToolsConfig

type ToolsConfig struct {
	AllowReadPaths  []string           `json:"allow_read_paths"  env:"MOONHUB_TOOLS_ALLOW_READ_PATHS"`
	AllowWritePaths []string           `json:"allow_write_paths" env:"MOONHUB_TOOLS_ALLOW_WRITE_PATHS"`
	Web             WebToolsConfig     `json:"web"`
	Cron            CronToolsConfig    `json:"cron"`
	Exec            ExecConfig         `json:"exec"`
	Skills          SkillsToolsConfig  `json:"skills"`
	MediaCleanup    MediaCleanupConfig `json:"media_cleanup"`
	MCP             MCPConfig          `json:"mcp"`
	Memory          ToolConfig         `json:"memory"                                                  envPrefix:"MOONHUB_TOOLS_MEMORY_"`
	AppendFile      ToolConfig         `json:"append_file"                                              envPrefix:"MOONHUB_TOOLS_APPEND_FILE_"`
	EditFile        ToolConfig         `json:"edit_file"                                                envPrefix:"MOONHUB_TOOLS_EDIT_FILE_"`
	FindSkills      ToolConfig         `json:"find_skills"                                              envPrefix:"MOONHUB_TOOLS_FIND_SKILLS_"`
	I2C             ToolConfig         `json:"i2c"                                                      envPrefix:"MOONHUB_TOOLS_I2C_"`
	InstallSkill    ToolConfig         `json:"install_skill"                                            envPrefix:"MOONHUB_TOOLS_INSTALL_SKILL_"`
	ListDir         ToolConfig         `json:"list_dir"                                                 envPrefix:"MOONHUB_TOOLS_LIST_DIR_"`
	Message         ToolConfig         `json:"message"                                                  envPrefix:"MOONHUB_TOOLS_MESSAGE_"`
	ReadFile        ReadFileToolConfig `json:"read_file"                                                envPrefix:"MOONHUB_TOOLS_READ_FILE_"`
	SendFile        ToolConfig         `json:"send_file"                                                envPrefix:"MOONHUB_TOOLS_SEND_FILE_"`
	Spawn           ToolConfig         `json:"spawn"                                                    envPrefix:"MOONHUB_TOOLS_SPAWN_"`
	SPI             ToolConfig         `json:"spi"                                                      envPrefix:"MOONHUB_TOOLS_SPI_"`
	Subagent        ToolConfig         `json:"subagent"                                                 envPrefix:"MOONHUB_TOOLS_SUBAGENT_"`
	WebFetch        ToolConfig         `json:"web_fetch"                                                envPrefix:"MOONHUB_TOOLS_WEB_FETCH_"`
	WriteFile       ToolConfig         `json:"write_file"                                               envPrefix:"MOONHUB_TOOLS_WRITE_FILE_"`
}

func (*ToolsConfig) IsToolEnabled

func (t *ToolsConfig) IsToolEnabled(name string) bool

type TypingConfig

type TypingConfig struct {
	Enabled bool `json:"enabled,omitempty"`
}

TypingConfig controls typing indicator behavior (Phase 10).

type VoiceConfig

type VoiceConfig struct {
	EchoTranscription bool `json:"echo_transcription" env:"MOONHUB_VOICE_ECHO_TRANSCRIPTION"`
}

type WeComAIBotConfig

type WeComAIBotConfig struct {
	Enabled            bool                `json:"enabled"              env:"MOONHUB_CHANNELS_WECOM_AIBOT_ENABLED"`
	Token              string              `json:"token"                env:"MOONHUB_CHANNELS_WECOM_AIBOT_TOKEN"`
	EncodingAESKey     string              `json:"encoding_aes_key"     env:"MOONHUB_CHANNELS_WECOM_AIBOT_ENCODING_AES_KEY"`
	WebhookPath        string              `json:"webhook_path"         env:"MOONHUB_CHANNELS_WECOM_AIBOT_WEBHOOK_PATH"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"           env:"MOONHUB_CHANNELS_WECOM_AIBOT_ALLOW_FROM"`
	ReplyTimeout       int                 `json:"reply_timeout"        env:"MOONHUB_CHANNELS_WECOM_AIBOT_REPLY_TIMEOUT"`
	MaxSteps           int                 `json:"max_steps"            env:"MOONHUB_CHANNELS_WECOM_AIBOT_MAX_STEPS"`       // Maximum streaming steps
	WelcomeMessage     string              `json:"welcome_message"      env:"MOONHUB_CHANNELS_WECOM_AIBOT_WELCOME_MESSAGE"` // Sent on enter_chat event; empty = no welcome
	ReasoningChannelID string              `json:"reasoning_channel_id" env:"MOONHUB_CHANNELS_WECOM_AIBOT_REASONING_CHANNEL_ID"`
}

type WeComAppConfig

type WeComAppConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_WECOM_APP_ENABLED"`
	CorpID             string              `json:"corp_id"                 env:"MOONHUB_CHANNELS_WECOM_APP_CORP_ID"`
	CorpSecret         string              `json:"corp_secret"             env:"MOONHUB_CHANNELS_WECOM_APP_CORP_SECRET"`
	AgentID            int64               `json:"agent_id"                env:"MOONHUB_CHANNELS_WECOM_APP_AGENT_ID"`
	Token              string              `json:"token"                   env:"MOONHUB_CHANNELS_WECOM_APP_TOKEN"`
	EncodingAESKey     string              `json:"encoding_aes_key"        env:"MOONHUB_CHANNELS_WECOM_APP_ENCODING_AES_KEY"`
	WebhookHost        string              `json:"webhook_host"            env:"MOONHUB_CHANNELS_WECOM_APP_WEBHOOK_HOST"`
	WebhookPort        int                 `json:"webhook_port"            env:"MOONHUB_CHANNELS_WECOM_APP_WEBHOOK_PORT"`
	WebhookPath        string              `json:"webhook_path"            env:"MOONHUB_CHANNELS_WECOM_APP_WEBHOOK_PATH"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_WECOM_APP_ALLOW_FROM"`
	ReplyTimeout       int                 `json:"reply_timeout"           env:"MOONHUB_CHANNELS_WECOM_APP_REPLY_TIMEOUT"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_WECOM_APP_REASONING_CHANNEL_ID"`
}

type WeComConfig

type WeComConfig struct {
	Enabled            bool                `json:"enabled"                 env:"MOONHUB_CHANNELS_WECOM_ENABLED"`
	Token              string              `json:"token"                   env:"MOONHUB_CHANNELS_WECOM_TOKEN"`
	EncodingAESKey     string              `json:"encoding_aes_key"        env:"MOONHUB_CHANNELS_WECOM_ENCODING_AES_KEY"`
	WebhookURL         string              `json:"webhook_url"             env:"MOONHUB_CHANNELS_WECOM_WEBHOOK_URL"`
	WebhookHost        string              `json:"webhook_host"            env:"MOONHUB_CHANNELS_WECOM_WEBHOOK_HOST"`
	WebhookPort        int                 `json:"webhook_port"            env:"MOONHUB_CHANNELS_WECOM_WEBHOOK_PORT"`
	WebhookPath        string              `json:"webhook_path"            env:"MOONHUB_CHANNELS_WECOM_WEBHOOK_PATH"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"              env:"MOONHUB_CHANNELS_WECOM_ALLOW_FROM"`
	ReplyTimeout       int                 `json:"reply_timeout"           env:"MOONHUB_CHANNELS_WECOM_REPLY_TIMEOUT"`
	GroupTrigger       GroupTriggerConfig  `json:"group_trigger,omitempty"`
	ReasoningChannelID string              `json:"reasoning_channel_id"    env:"MOONHUB_CHANNELS_WECOM_REASONING_CHANNEL_ID"`
}

type WebToolsConfig

type WebToolsConfig struct {
	ToolConfig `                 envPrefix:"MOONHUB_TOOLS_WEB_"`
	Brave      BraveConfig      `                                json:"brave"`
	Tavily     TavilyConfig     `                                json:"tavily"`
	DuckDuckGo DuckDuckGoConfig `                                json:"duckduckgo"`
	Perplexity PerplexityConfig `                                json:"perplexity"`
	SearXNG    SearXNGConfig    `                                json:"searxng"`
	GLMSearch  GLMSearchConfig  `                                json:"glm_search"`
	// Proxy is an optional proxy URL for web tools (http/https/socks5/socks5h).
	// For authenticated proxies, prefer HTTP_PROXY/HTTPS_PROXY env vars instead of embedding credentials in config.
	Proxy           string `json:"proxy,omitempty"             env:"MOONHUB_TOOLS_WEB_PROXY"`
	FetchLimitBytes int64  `json:"fetch_limit_bytes,omitempty" env:"MOONHUB_TOOLS_WEB_FETCH_LIMIT_BYTES"`
}

type WhatsAppConfig

type WhatsAppConfig struct {
	Enabled            bool                `json:"enabled"              env:"MOONHUB_CHANNELS_WHATSAPP_ENABLED"`
	BridgeURL          string              `json:"bridge_url"           env:"MOONHUB_CHANNELS_WHATSAPP_BRIDGE_URL"`
	UseNative          bool                `json:"use_native"           env:"MOONHUB_CHANNELS_WHATSAPP_USE_NATIVE"`
	SessionStorePath   string              `json:"session_store_path"   env:"MOONHUB_CHANNELS_WHATSAPP_SESSION_STORE_PATH"`
	AllowFrom          FlexibleStringSlice `json:"allow_from"           env:"MOONHUB_CHANNELS_WHATSAPP_ALLOW_FROM"`
	ReasoningChannelID string              `json:"reasoning_channel_id" env:"MOONHUB_CHANNELS_WHATSAPP_REASONING_CHANNEL_ID"`
}

Jump to

Keyboard shortcuts

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