config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDBLoader added in v0.2.0

func SetDBLoader(loader func() (*Config, error))

SetDBLoader 设置数据库配置加载函数

func SetDBMigrator added in v0.2.0

func SetDBMigrator(migrator func(*Config) error)

SetDBMigrator 设置数据库配置迁移函数

func SetGlobalConfig

func SetGlobalConfig(cfg *Config)

SetGlobalConfig 设置全局配置

Types

type AuthConfig

type AuthConfig struct {
	Enabled bool     `mapstructure:"enabled"`
	Type    string   `mapstructure:"type"` // token, basic, oauth2
	Tokens  []string `mapstructure:"tokens"`
}

AuthConfig 认证配置

type CICDConfig

type CICDConfig struct {
	Jenkins JenkinsConfig `mapstructure:"jenkins"`
}

CICDConfig CI/CD 工具配置

type CacheConfig

type CacheConfig struct {
	Enabled bool   `mapstructure:"enabled"`
	Type    string `mapstructure:"type"` // memory, redis
	TTL     int    `mapstructure:"ttl"`  // 秒
}

CacheConfig 缓存配置

type Config

type Config struct {
	Server           ServerConfig    `mapstructure:"server"`
	Providers        ProvidersConfig `mapstructure:"providers"`
	CICD             CICDConfig      `mapstructure:"cicd"`
	DingTalk         DingTalkConfig  `mapstructure:"dingtalk"`
	Feishu           FeishuConfig    `mapstructure:"feishu"`
	Wecom            WecomConfig     `mapstructure:"wecom"`
	LLM              LLMConfig       `mapstructure:"llm"`
	Auth             AuthConfig      `mapstructure:"auth"`
	Cache            CacheConfig     `mapstructure:"cache"`
	MCPServersConfig string          `mapstructure:"mcp_servers_config"` // 外部 MCP Servers 配置文件路径
}

Config 应用配置

func GetGlobalConfig

func GetGlobalConfig() *Config

GetGlobalConfig 获取全局配置

func LoadConfig

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

LoadConfig 加载配置文件 优先从数据库加载配置,如果数据库为空则从YAML文件加载并自动迁移

func LoadConfigWithDB added in v0.2.0

func LoadConfigWithDB(configFile string) (*Config, error)

LoadConfigWithDB 加载配置(支持数据库)

type ConfigLoader added in v0.2.0

type ConfigLoader interface {
	LoadConfig(configFile string) (*Config, error)
	LoadConfigFromDB() (*Config, error)
	MigrateConfigToDB(cfg *Config) error
}

ConfigLoader 配置加载器接口

type DefaultConfigLoader added in v0.2.0

type DefaultConfigLoader struct {
	// contains filtered or unexported fields
}

DefaultConfigLoader 默认配置加载器

type DingTalkConfig

type DingTalkConfig struct {
	Enabled        bool   `mapstructure:"enabled"`
	AppKey         string `mapstructure:"app_key"`
	AppSecret      string `mapstructure:"app_secret"`
	AgentID        string `mapstructure:"agent_id"`
	CardTemplateID string `mapstructure:"card_template_id"` // AI 流式卡片模板 ID
}

DingTalkConfig 钉钉配置

type FeishuConfig added in v0.1.2

type FeishuConfig struct {
	Enabled   bool   `mapstructure:"enabled"`
	AppID     string `mapstructure:"app_id"`
	AppSecret string `mapstructure:"app_secret"`
}

FeishuConfig 飞书配置

type HTTPConfig

type HTTPConfig struct {
	Enabled bool `mapstructure:"enabled"`
	Port    int  `mapstructure:"port"`
	Debug   bool `mapstructure:"debug"` // Gin Debug 模式
}

HTTPConfig HTTP 服务配置

type JenkinsConfig

type JenkinsConfig struct {
	Enabled  bool   `mapstructure:"enabled"`
	URL      string `mapstructure:"url"`
	Username string `mapstructure:"username"`
	Token    string `mapstructure:"token"`
}

JenkinsConfig Jenkins 配置

type LLMConfig

type LLMConfig struct {
	Enabled bool   `mapstructure:"enabled"`
	Model   string `mapstructure:"model"`
	APIKey  string `mapstructure:"api_key"`
	BaseURL string `mapstructure:"base_url"` // 自定义 API 端点
}

LLMConfig LLM 配置

type MCPConfig

type MCPConfig struct {
	Enabled                   bool   `mapstructure:"enabled"`
	Port                      int    `mapstructure:"port"`
	AutoRegisterExternalTools bool   `mapstructure:"auto_register_external_tools"` // 是否自动注册外部 MCP 工具
	ToolNameFormat            string `mapstructure:"tool_name_format"`             // 工具命名格式,默认 "{prefix}{name}"
}

MCPConfig MCP 服务配置

type MCPServerConfig added in v0.2.0

type MCPServerConfig struct {
	IsActive      bool              `yaml:"is_active" json:"isActive"`
	Name          string            `yaml:"name" json:"name"`
	Type          string            `yaml:"type" json:"type"` // "stdio" | "sse"
	Description   string            `yaml:"description" json:"description"`
	BaseURL       string            `yaml:"base_url" json:"baseUrl"`
	Command       string            `yaml:"command" json:"command"`
	Args          []string          `yaml:"args" json:"args"`
	Env           map[string]string `yaml:"env" json:"env"`
	Headers       map[string]string `yaml:"headers" json:"headers"` // 用于 SSE/HTTP
	Provider      string            `yaml:"provider" json:"provider"`
	ProviderURL   string            `yaml:"provider_url" json:"providerUrl"`
	LogoURL       string            `yaml:"logo_url" json:"logoUrl"`
	Tags          []string          `yaml:"tags" json:"tags"`
	LongRunning   bool              `yaml:"long_running" json:"longRunning"`
	Timeout       int               `yaml:"timeout" json:"timeout"`
	InstallSource string            `yaml:"install_source" json:"installSource"`

	// ZenOps 扩展字段
	ToolPrefix   string `yaml:"tool_prefix" json:"toolPrefix"`     // 工具名前缀
	AutoRegister bool   `yaml:"auto_register" json:"autoRegister"` // 是否自动注册
}

MCPServerConfig 标准 MCP Server 配置 (兼容 Claude Desktop 格式)

type MCPServersConfig added in v0.2.0

type MCPServersConfig struct {
	MCPServers map[string]*MCPServerConfig `yaml:"mcp_servers" json:"mcpServers"`
}

MCPServersConfig MCP Servers 配置集合

func LoadMCPServersConfig added in v0.2.0

func LoadMCPServersConfig(configPath string) (*MCPServersConfig, error)

LoadMCPServersConfig 加载 MCP Servers 配置

func (*MCPServersConfig) Validate added in v0.2.0

func (c *MCPServersConfig) Validate() error

Validate 校验配置

type ProviderConfig

type ProviderConfig struct {
	Name    string            `mapstructure:"name"` // 账号名称,用于区分多个账号
	Enabled bool              `mapstructure:"enabled"`
	AK      string            `mapstructure:"ak"`
	SK      string            `mapstructure:"sk"`
	Regions []string          `mapstructure:"regions"`
	Extra   map[string]string `mapstructure:"extra"`
}

ProviderConfig 云服务提供商配置

type ProvidersConfig

type ProvidersConfig struct {
	Aliyun  []ProviderConfig `mapstructure:"aliyun"`
	Tencent []ProviderConfig `mapstructure:"tencent"`
}

ProvidersConfig 云服务提供商配置集合

type ServerConfig

type ServerConfig struct {
	HTTP HTTPConfig `mapstructure:"http"`
	MCP  MCPConfig  `mapstructure:"mcp"`
}

ServerConfig 服务器配置

type WecomConfig added in v0.1.2

type WecomConfig struct {
	Enabled        bool   `mapstructure:"enabled"`
	Token          string `mapstructure:"token"`            // 企业微信AI机器人Token
	EncodingAESKey string `mapstructure:"encoding_aes_key"` // 消息加密密钥
}

WecomConfig 企业微信配置

Jump to

Keyboard shortcuts

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