Files
goclaw/internal/tools/team_notify_config.go
T
viettranx 4cb6991fc6 fix: default noisy team notifications to off
Disable progress, failed, commented, and slow_tool notifications
by default — these are too verbose for most teams.
2026-03-29 19:41:35 +07:00

80 lines
2.2 KiB
Go

package tools
import "encoding/json"
// TeamNotifyConfig controls which team task events are forwarded to chat channels.
type TeamNotifyConfig struct {
Dispatched bool `json:"dispatched"` // task dispatched to member
Progress bool `json:"progress"` // member updates progress
Failed bool `json:"failed"` // task failed
Completed bool `json:"completed"` // task completed
Commented bool `json:"commented"` // task comment added
NewTask bool `json:"new_task"` // new task created (human-initiated)
SlowTool bool `json:"slow_tool"` // system alert when tool call exceeds adaptive threshold
Mode string `json:"mode"` // "direct" (outbound) or "leader" (through leader agent)
}
// DefaultTeamNotifyConfig returns the default notification config.
func DefaultTeamNotifyConfig() TeamNotifyConfig {
return TeamNotifyConfig{
Dispatched: true,
Progress: false,
Failed: false,
Completed: true,
Commented: false,
NewTask: true,
SlowTool: false,
Mode: "direct",
}
}
// ParseTeamNotifyConfig extracts notification config from team settings JSON.
// Returns defaults for missing/invalid settings.
func ParseTeamNotifyConfig(settings json.RawMessage) TeamNotifyConfig {
cfg := DefaultTeamNotifyConfig()
if len(settings) == 0 {
return cfg
}
var s struct {
Notifications *struct {
Dispatched *bool `json:"dispatched"`
Progress *bool `json:"progress"`
Failed *bool `json:"failed"`
Completed *bool `json:"completed"`
Commented *bool `json:"commented"`
NewTask *bool `json:"new_task"`
SlowTool *bool `json:"slow_tool"`
Mode string `json:"mode"`
} `json:"notifications"`
}
if json.Unmarshal(settings, &s) != nil || s.Notifications == nil {
return cfg
}
n := s.Notifications
if n.Dispatched != nil {
cfg.Dispatched = *n.Dispatched
}
if n.Progress != nil {
cfg.Progress = *n.Progress
}
if n.Failed != nil {
cfg.Failed = *n.Failed
}
if n.Completed != nil {
cfg.Completed = *n.Completed
}
if n.Commented != nil {
cfg.Commented = *n.Commented
}
if n.NewTask != nil {
cfg.NewTask = *n.NewTask
}
if n.SlowTool != nil {
cfg.SlowTool = *n.SlowTool
}
if n.Mode == "leader" {
cfg.Mode = "leader"
}
return cfg
}