mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 20:27:37 +08:00
chore: update project files
This commit is contained in:
@@ -171,21 +171,8 @@ type ChannelsConfig struct {
|
||||
InboundContentDedupeWindowSeconds int `json:"inbound_content_dedupe_window_seconds" env:"CLAWGO_CHANNELS_INBOUND_CONTENT_DEDUPE_WINDOW_SECONDS"`
|
||||
OutboundDedupeWindowSeconds int `json:"outbound_dedupe_window_seconds" env:"CLAWGO_CHANNELS_OUTBOUND_DEDUPE_WINDOW_SECONDS"`
|
||||
Weixin WeixinConfig `json:"weixin"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type WhatsAppConfig struct {
|
||||
Enabled bool `json:"enabled" env:"CLAWGO_CHANNELS_WHATSAPP_ENABLED"`
|
||||
BridgeURL string `json:"bridge_url" env:"CLAWGO_CHANNELS_WHATSAPP_BRIDGE_URL"`
|
||||
AllowFrom []string `json:"allow_from" env:"CLAWGO_CHANNELS_WHATSAPP_ALLOW_FROM"`
|
||||
EnableGroups bool `json:"enable_groups" env:"CLAWGO_CHANNELS_WHATSAPP_ENABLE_GROUPS"`
|
||||
RequireMentionInGroups bool `json:"require_mention_in_groups" env:"CLAWGO_CHANNELS_WHATSAPP_REQUIRE_MENTION_IN_GROUPS"`
|
||||
}
|
||||
|
||||
type WeixinConfig struct {
|
||||
@@ -231,33 +218,6 @@ type FeishuConfig struct {
|
||||
RequireMentionInGroups bool `json:"require_mention_in_groups" env:"CLAWGO_CHANNELS_FEISHU_REQUIRE_MENTION_IN_GROUPS"`
|
||||
}
|
||||
|
||||
type DiscordConfig struct {
|
||||
Enabled bool `json:"enabled" env:"CLAWGO_CHANNELS_DISCORD_ENABLED"`
|
||||
Token string `json:"token" env:"CLAWGO_CHANNELS_DISCORD_TOKEN"`
|
||||
AllowFrom []string `json:"allow_from" env:"CLAWGO_CHANNELS_DISCORD_ALLOW_FROM"`
|
||||
}
|
||||
|
||||
type MaixCamConfig struct {
|
||||
Enabled bool `json:"enabled" env:"CLAWGO_CHANNELS_MAIXCAM_ENABLED"`
|
||||
Host string `json:"host" env:"CLAWGO_CHANNELS_MAIXCAM_HOST"`
|
||||
Port int `json:"port" env:"CLAWGO_CHANNELS_MAIXCAM_PORT"`
|
||||
AllowFrom []string `json:"allow_from" env:"CLAWGO_CHANNELS_MAIXCAM_ALLOW_FROM"`
|
||||
}
|
||||
|
||||
type QQConfig struct {
|
||||
Enabled bool `json:"enabled" env:"CLAWGO_CHANNELS_QQ_ENABLED"`
|
||||
AppID string `json:"app_id" env:"CLAWGO_CHANNELS_QQ_APP_ID"`
|
||||
AppSecret string `json:"app_secret" env:"CLAWGO_CHANNELS_QQ_APP_SECRET"`
|
||||
AllowFrom []string `json:"allow_from" env:"CLAWGO_CHANNELS_QQ_ALLOW_FROM"`
|
||||
}
|
||||
|
||||
type DingTalkConfig struct {
|
||||
Enabled bool `json:"enabled" env:"CLAWGO_CHANNELS_DINGTALK_ENABLED"`
|
||||
ClientID string `json:"client_id" env:"CLAWGO_CHANNELS_DINGTALK_CLIENT_ID"`
|
||||
ClientSecret string `json:"client_secret" env:"CLAWGO_CHANNELS_DINGTALK_CLIENT_SECRET"`
|
||||
AllowFrom []string `json:"allow_from" env:"CLAWGO_CHANNELS_DINGTALK_ALLOW_FROM"`
|
||||
}
|
||||
|
||||
type ModelsConfig struct {
|
||||
Providers map[string]ProviderConfig `json:"providers,omitempty"`
|
||||
}
|
||||
@@ -494,13 +454,6 @@ func DefaultConfig() *Config {
|
||||
Accounts: []WeixinAccountConfig{},
|
||||
AllowFrom: []string{},
|
||||
},
|
||||
WhatsApp: WhatsAppConfig{
|
||||
Enabled: false,
|
||||
BridgeURL: "",
|
||||
AllowFrom: []string{},
|
||||
EnableGroups: true,
|
||||
RequireMentionInGroups: true,
|
||||
},
|
||||
Telegram: TelegramConfig{
|
||||
Enabled: false,
|
||||
Token: "",
|
||||
@@ -521,29 +474,6 @@ func DefaultConfig() *Config {
|
||||
EnableGroups: true,
|
||||
RequireMentionInGroups: true,
|
||||
},
|
||||
Discord: DiscordConfig{
|
||||
Enabled: false,
|
||||
Token: "",
|
||||
AllowFrom: []string{},
|
||||
},
|
||||
MaixCam: MaixCamConfig{
|
||||
Enabled: false,
|
||||
Host: "0.0.0.0",
|
||||
Port: 18790,
|
||||
AllowFrom: []string{},
|
||||
},
|
||||
QQ: QQConfig{
|
||||
Enabled: false,
|
||||
AppID: "",
|
||||
AppSecret: "",
|
||||
AllowFrom: []string{},
|
||||
},
|
||||
DingTalk: DingTalkConfig{
|
||||
Enabled: false,
|
||||
ClientID: "",
|
||||
ClientSecret: "",
|
||||
AllowFrom: []string{},
|
||||
},
|
||||
},
|
||||
Models: ModelsConfig{
|
||||
Providers: map[string]ProviderConfig{
|
||||
|
||||
@@ -190,17 +190,6 @@ func Validate(cfg *Config) []error {
|
||||
if cfg.Channels.Telegram.Enabled && cfg.Channels.Telegram.Token == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.telegram.token is required when channels.telegram.enabled=true"))
|
||||
}
|
||||
if cfg.Channels.Discord.Enabled && cfg.Channels.Discord.Token == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.discord.token is required when channels.discord.enabled=true"))
|
||||
}
|
||||
if cfg.Channels.DingTalk.Enabled {
|
||||
if cfg.Channels.DingTalk.ClientID == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.dingtalk.client_id is required when channels.dingtalk.enabled=true"))
|
||||
}
|
||||
if cfg.Channels.DingTalk.ClientSecret == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.dingtalk.client_secret is required when channels.dingtalk.enabled=true"))
|
||||
}
|
||||
}
|
||||
if cfg.Channels.Feishu.Enabled {
|
||||
if cfg.Channels.Feishu.AppID == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.feishu.app_id is required when channels.feishu.enabled=true"))
|
||||
@@ -209,14 +198,6 @@ func Validate(cfg *Config) []error {
|
||||
errs = append(errs, fmt.Errorf("channels.feishu.app_secret is required when channels.feishu.enabled=true"))
|
||||
}
|
||||
}
|
||||
if cfg.Channels.QQ.Enabled {
|
||||
if cfg.Channels.QQ.AppID == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.qq.app_id is required when channels.qq.enabled=true"))
|
||||
}
|
||||
if cfg.Channels.QQ.AppSecret == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.qq.app_secret is required when channels.qq.enabled=true"))
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
@@ -111,6 +111,35 @@ func TestValidateSubagentsRejectsInvalidNotifyMainPolicy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSubagentsRejectsNodeTransport(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := DefaultConfig()
|
||||
cfg.Agents.Subagents["coder"] = SubagentConfig{
|
||||
Enabled: true,
|
||||
Transport: "node",
|
||||
SystemPromptFile: "agents/coder/AGENT.md",
|
||||
Runtime: SubagentRuntimeConfig{
|
||||
Provider: "openai",
|
||||
},
|
||||
}
|
||||
|
||||
errs := Validate(cfg)
|
||||
if len(errs) == 0 {
|
||||
t.Fatalf("expected validation errors")
|
||||
}
|
||||
found := false
|
||||
for _, err := range errs {
|
||||
if strings.Contains(err.Error(), "agents.subagents.coder.transport") {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("expected transport validation error, got %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSentinelWebhookURLRejectsInvalidScheme(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user