config

package
v0.0.0-...-481d40d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug bool `mapstructure:"debug"`

	Server struct {
		Addr    string `mapstructure:"addr"`
		BaseURL string `mapstructure:"base_url"`
	} `mapstructure:"server"`

	Database Database `mapstructure:"database"`

	Redis struct {
		Host string `mapstructure:"host"`
		Port int    `mapstructure:"port"`
		Pass string `mapstructure:"pass"`
		DB   int    `mapstructure:"db"`
	} `mapstructure:"redis"`

	Session Session `mapstructure:"session"`
	SMTP    SMTP    `mapstructure:"smtp"`

	LLMProxy struct {
		Addr                 string `mapstructure:"addr"`
		BaseURL              string `mapstructure:"base_url"`
		Timeout              string `mapstructure:"timeout"`
		KeepAlive            string `mapstructure:"keep_alive"`
		ClientPoolSize       int    `mapstructure:"client_pool_size"`
		StreamClientPoolSize int    `mapstructure:"stream_client_pool_size"`
		RequestLogPath       string `mapstructure:"request_log_path"`
	} `mapstructure:"llm_proxy"`

	RootPath   string        `mapstructure:"root_path"`
	Logger     logger.Config `mapstructure:"logger"`
	AdminToken string        `mapstructure:"admin_token"`
	Proxies    []string      `mapstructure:"proxies"`

	TaskFlow    TaskFlow    `mapstructure:"taskflow"`
	PublicHost  PublicHost  `mapstructure:"public_host"`
	Task        Task        `mapstructure:"task"`
	TaskSummary TaskSummary `mapstructure:"task_summary"`
	Loki        Loki        `mapstructure:"loki"`
	LLM         LLM         `mapstructure:"llm"`
	Notify      Notify      `mapstructure:"notify"`
	VMIdle      VMIdle      `mapstructure:"vm_idle"`

	// Context7 API 配置
	Context7ApiKey string `mapstructure:"context7_api_key"`

	// Git 平台配置
	Github GithubConfig `mapstructure:"github"`
	Gitlab GitlabConfig `mapstructure:"gitlab"`
	Gitea  GiteaConfig  `mapstructure:"gitea"`
	Gitee  GiteeConfig  `mapstructure:"gitee"`

	InitTeam InitTeam `mapstructure:"init_team"`

	// 语音识别配置(阿里云 NLS)
	NLS NLS `mapstructure:"nls"`
}

func Init

func Init(dir string) (*Config, error)

func (*Config) GetGiteaBaseURL

func (c *Config) GetGiteaBaseURL() string

GetGiteaBaseURL 获取 Gitea Base URL

func (*Config) GetGiteaOAuthClientID

func (c *Config) GetGiteaOAuthClientID() string

GetGiteaOAuthClientID 获取 Gitea OAuth Client ID

func (*Config) GetGiteaOAuthClientSecret

func (c *Config) GetGiteaOAuthClientSecret() string

GetGiteaOAuthClientSecret 获取 Gitea OAuth Client Secret

func (*Config) GetGiteaOAuthRedirectURL

func (c *Config) GetGiteaOAuthRedirectURL() string

GetGiteaOAuthRedirectURL 获取 Gitea OAuth Redirect URL

func (*Config) GetGiteaToken

func (c *Config) GetGiteaToken() string

GetGiteaToken 获取 Gitea token

func (*Config) GetGiteeBaseURL

func (c *Config) GetGiteeBaseURL() string

GetGiteeBaseURL 获取 Gitee Base URL

func (*Config) GetGiteeOAuthClientID

func (c *Config) GetGiteeOAuthClientID() string

GetGiteeOAuthClientID 获取 Gitee OAuth Client ID

func (*Config) GetGiteeOAuthClientSecret

func (c *Config) GetGiteeOAuthClientSecret() string

GetGiteeOAuthClientSecret 获取 Gitee OAuth Client Secret

func (*Config) GetGiteeOAuthRedirectURL

func (c *Config) GetGiteeOAuthRedirectURL() string

GetGiteeOAuthRedirectURL 获取 Gitee OAuth Redirect URL

func (*Config) GetGiteeToken

func (c *Config) GetGiteeToken() string

GetGiteeToken 获取 Gitee token

func (*Config) GetGitlabBaseURL

func (c *Config) GetGitlabBaseURL(instanceName string) string

GetGitlabBaseURL 获取指定 GitLab 实例的 Base URL

func (*Config) GetGitlabOAuthClientID

func (c *Config) GetGitlabOAuthClientID(instanceName string) string

GetGitlabOAuthClientID 获取指定 GitLab 实例的 OAuth Client ID

func (*Config) GetGitlabOAuthClientSecret

func (c *Config) GetGitlabOAuthClientSecret(instanceName string) string

GetGitlabOAuthClientSecret 获取指定 GitLab 实例的 OAuth Client Secret

func (*Config) GetGitlabOAuthRedirectURL

func (c *Config) GetGitlabOAuthRedirectURL(instanceName string) string

GetGitlabOAuthRedirectURL 获取指定 GitLab 实例的 OAuth Redirect URL

func (*Config) GetGitlabOAuthScope

func (c *Config) GetGitlabOAuthScope(instanceName string) string

GetGitlabOAuthScope 获取指定 GitLab 实例的 OAuth Scope

func (*Config) GetGitlabToken

func (c *Config) GetGitlabToken(instanceName string) string

GetGitlabToken 获取 GitLab token

func (*Config) IsGiteaEnabled

func (c *Config) IsGiteaEnabled() bool

IsGiteaEnabled 检查 Gitea 是否启用

func (*Config) IsGiteeEnabled

func (c *Config) IsGiteeEnabled() bool

IsGiteeEnabled 检查 Gitee 是否启用

func (*Config) IsGithubEnabled

func (c *Config) IsGithubEnabled() bool

IsGithubEnabled 检查 GitHub 是否启用

func (*Config) IsGitlabInstanceEnabled

func (c *Config) IsGitlabInstanceEnabled(instanceName string) bool

IsGitlabInstanceEnabled 检查指定 GitLab 实例是否启用

type Database

type Database struct {
	Master          string `mapstructure:"master"`
	Slave           string `mapstructure:"slave"`
	MaxOpenConns    int    `mapstructure:"max_open_conns"`
	MaxIdleConns    int    `mapstructure:"max_idle_conns"`
	ConnMaxLifetime int    `mapstructure:"conn_max_lifetime"`
}

type GiteaConfig

type GiteaConfig struct {
	BaseURL string           `mapstructure:"base_url"`
	Token   string           `mapstructure:"token"`
	Enabled bool             `mapstructure:"enabled"`
	OAuth   GiteaOAuthConfig `mapstructure:"oauth"`
}

GiteaConfig Gitea 配置

type GiteaOAuthConfig

type GiteaOAuthConfig struct {
	ClientID     string `mapstructure:"client_id"`
	ClientSecret string `mapstructure:"client_secret"`
	RedirectURL  string `mapstructure:"redirect_url"`
}

GiteaOAuthConfig Gitea OAuth 配置

type GiteeConfig

type GiteeConfig struct {
	BaseURL string           `mapstructure:"base_url"`
	Token   string           `mapstructure:"token"`
	Enabled bool             `mapstructure:"enabled"`
	OAuth   GiteeOAuthConfig `mapstructure:"oauth"`
}

GiteeConfig Gitee 配置

type GiteeOAuthConfig

type GiteeOAuthConfig struct {
	ClientID     string `mapstructure:"client_id"`
	ClientSecret string `mapstructure:"client_secret"`
	RedirectURL  string `mapstructure:"redirect_url"`
}

GiteeOAuthConfig Gitee OAuth 配置

type GithubAppConfig

type GithubAppConfig struct {
	ID            int64  `mapstructure:"id"`
	WebhookSecret string `mapstructure:"webhook_secret"`
	PrivateKey    string `mapstructure:"private_key"`
	RedirectURL   string `mapstructure:"redirect_url"` // 安装完 GitHub App 后的跳转地址
}

type GithubConfig

type GithubConfig struct {
	Token   string            `mapstructure:"token"`
	Enabled bool              `mapstructure:"enabled"`
	App     GithubAppConfig   `mapstructure:"app"`
	OAuth   GithubOAuthConfig `mapstructure:"oauth"`
}

GithubConfig GitHub 配置

type GithubOAuthConfig

type GithubOAuthConfig struct {
	ClientID     string `mapstructure:"client_id"`
	ClientSecret string `mapstructure:"client_secret"`
	RedirectURL  string `mapstructure:"redirect_url"`
}

GithubOAuthConfig GitHub OAuth 配置

type GitlabConfig

type GitlabConfig struct {
	Default        string                    `mapstructure:"default"`
	Instances      map[string]GitlabInstance `mapstructure:"instances"`
	WebhookSecret  string                    `mapstructure:"webhook_secret"`
	AllowedDomains []string                  `mapstructure:"allowed_domains"`
}

GitlabConfig GitLab 配置

type GitlabInstance

type GitlabInstance struct {
	Token   string            `mapstructure:"token"`
	BaseURL string            `mapstructure:"base_url"`
	Enabled bool              `mapstructure:"enabled"`
	OAuth   GitlabOAuthConfig `mapstructure:"oauth"`
}

GitlabInstance GitLab 实例配置

type GitlabOAuthConfig

type GitlabOAuthConfig struct {
	ClientID     string   `mapstructure:"client_id"`
	ClientSecret string   `mapstructure:"client_secret"`
	RedirectURL  string   `mapstructure:"redirect_url"`
	Scope        []string `mapstructure:"scope"`
}

GitlabOAuthConfig GitLab OAuth 配置

type InitTeam

type InitTeam struct {
	Email    string `mapstructure:"email"`
	Password string `mapstructure:"password"`
	Name     string `mapstructure:"name"`
}

type LLM

type LLM struct {
	BaseURL       string `mapstructure:"base_url"`
	APIKey        string `mapstructure:"api_key"`
	Model         string `mapstructure:"model"`
	InterfaceType string `mapstructure:"interface_type"` // openai_chat, openai_responses, anthropic
}

LLM 大语言模型配置

type Loki

type Loki struct {
	Addr string `mapstructure:"addr"` // Loki 服务地址
}

Loki Loki 日志配置

type NLS

type NLS struct {
	AppKey string `mapstructure:"app_key"`
	AkID   string `mapstructure:"ak_id"`
	AkKey  string `mapstructure:"ak_key"`
}

NLS 阿里云语音识别配置

type Notify

type Notify struct {
	VMExpireWarningMinutes int `mapstructure:"vm_expire_warning_minutes"` // VM 过期预警时间(分钟)
}

Notify 通知配置

type PublicHost

type PublicHost struct {
	CountLimit int   `mapstructure:"count_limit"` // 每用户公共主机 VM 数量限制,0 表示不限制
	TTLLimit   int64 `mapstructure:"ttl_limit"`   // 公共主机 VM 续期上限(秒),0 表示不限制
}

PublicHost 公共主机配置(可选,内部项目通过 WithPublicHost 注入时生效)

type SMTP

type SMTP struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	From     string `mapstructure:"from"`
	TLS      bool   `mapstructure:"tls"`
}

type Session

type Session struct {
	ExpireDay int `mapstructure:"expire_day"`
}

type Task

type Task struct {
	LogLimit         int    `mapstructure:"log_limit"`          // Loki tail 日志 limit
	TaskerTTLSeconds int    `mapstructure:"tasker_ttl_seconds"` // Tasker 状态机 TTL(秒)
	ImageID          string `mapstructure:"image_id"`           // 默认镜像 ID
	Core             int    `mapstructure:"core"`               // VM CPU 核数
	Memory           uint64 `mapstructure:"memory"`             // VM 内存(字节)
}

Task 任务相关配置

type TaskFlow

type TaskFlow struct {
	GrpcHost string `mapstructure:"grpc_host"`
	GrpcPort int    `mapstructure:"grpc_port"`
	GrpcURL  string `mapstructure:"grpc_url"`
}

type TaskSummary

type TaskSummary struct {
	Enabled       bool   `mapstructure:"enabled"`        // 是否启用
	Model         string `mapstructure:"model"`          // 摘要生成模型 ID
	BaseURL       string `mapstructure:"base_url"`       // API Base URL
	ApiKey        string `mapstructure:"api_key"`        // API Key // nolint:revive
	InterfaceType string `mapstructure:"interface_type"` // API 接口类型(openai_chat/openai_responses/anthropic)
	Delay         int    `mapstructure:"delay"`          // 延迟时间(秒),默认 3600
	MaxChars      int    `mapstructure:"max_chars"`      // 摘要最大字符数,默认 300
	MaxWorkers    int    `mapstructure:"max_workers"`    // 最大消费者数量,默认 5
}

TaskSummary 任务摘要生成配置

type VMIdle

type VMIdle struct {
	SleepSeconds   int `mapstructure:"sleep_seconds"`   // VM 空闲休眠时间(秒)
	RecycleSeconds int `mapstructure:"recycle_seconds"` // VM 空闲回收时间(秒)
}

Jump to

Keyboard shortcuts

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