启动项目逻辑

This commit is contained in:
2026-06-09 22:43:29 +08:00
parent d5a28b11a3
commit f4a7c770af
43 changed files with 3797 additions and 42 deletions
+26
View File
@@ -43,6 +43,7 @@ type Config struct {
Notify NotifyConfig `mapstructure:"notify"`
Acp AcpConfig `mapstructure:"acp"`
MCP MCPConfig `mapstructure:"mcp"`
Run RunConfig `mapstructure:"run"`
}
// HTTPConfig 描述 HTTP 服务监听参数。
@@ -200,6 +201,20 @@ type AcpConfig struct {
PermissionTimeout time.Duration `mapstructure:"permission_timeout"`
}
// RunConfig 控制 workspace run profiles 模块:进程托管的终止宽限、日志环形缓冲
// 容量、WS 发送缓冲、关停宽限,以及传递给被托管命令的宿主环境变量白名单。
type RunConfig struct {
Enabled bool `mapstructure:"enabled"`
KillGrace time.Duration `mapstructure:"kill_grace"`
OutBufferLines int `mapstructure:"out_buffer_lines"`
OutTailBytes int `mapstructure:"out_tail_bytes"`
WSSendBuffer int `mapstructure:"ws_send_buffer"`
ShutdownGrace time.Duration `mapstructure:"shutdown_grace"`
// EnvWhitelist 是允许从宿主进程透传给被托管命令的环境变量名白名单。
// APP_MASTER_KEY、DB DSN、git 凭据等敏感变量绝不应出现在此名单中。
EnvWhitelist []string `mapstructure:"env_whitelist"`
}
// MCPConfig 控制 MCP 模块的开关、对外 URL(注入 ACP 子进程 env)、system token TTL 与速率限制。
type MCPConfig struct {
Enabled bool `mapstructure:"enabled"`
@@ -285,6 +300,17 @@ func Load(configFile string) (*Config, error) {
v.SetDefault("mcp.system_token_ttl", "24h")
v.SetDefault("mcp.rate_limit.per_token_per_minute", 100)
v.SetDefault("mcp.rate_limit.global_per_minute", 1000)
v.SetDefault("run.enabled", true)
v.SetDefault("run.kill_grace", "5s")
v.SetDefault("run.out_buffer_lines", 1000)
v.SetDefault("run.out_tail_bytes", 2000)
v.SetDefault("run.ws_send_buffer", 256)
v.SetDefault("run.shutdown_grace", "30s")
v.SetDefault("run.env_whitelist", []string{
"PATH", "HOME", "LANG", "LC_ALL", "TZ", "USER", "SHELL",
"SystemRoot", "TEMP", "TMP", "USERPROFILE", "APPDATA", "LOCALAPPDATA",
"PATHEXT", "ComSpec", "NUMBER_OF_PROCESSORS",
})
if configFile != "" {
v.SetConfigFile(configFile)