diff options
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 43 | ||||
| -rw-r--r-- | internal/config/config_test.go | 24 |
2 files changed, 58 insertions, 9 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index b9454d1..9e065b5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -72,14 +72,26 @@ type RunnersConfig struct { // Anthropic vs. Claude above. Also requires [providers.google].api_key to // be set; Google = true with no configured key has no effect. Google *bool `toml:"google"` + // Groq, OpenRouter, and OpenAI gate NativeRunners registered under agent + // types "groq"/"openrouter"/"openai", all backed by + // internal/provider/openaicompat (they're OpenAI-wire-compatible, so no + // dedicated adapter package is needed — see docs/api-keys-setup.md). + // Each also requires the matching [providers.<name>].api_key to be set; + // true with no configured key has no effect, same as Anthropic/Google. + Groq *bool `toml:"groq"` + OpenRouter *bool `toml:"openrouter"` + OpenAI *bool `toml:"openai"` } -func (r RunnersConfig) ClaudeEnabled() bool { return r.Claude == nil || *r.Claude } -func (r RunnersConfig) GeminiEnabled() bool { return r.Gemini == nil || *r.Gemini } -func (r RunnersConfig) LocalEnabled() bool { return r.Local == nil || *r.Local } -func (r RunnersConfig) ContainerEnabled() bool { return r.Container == nil || *r.Container } -func (r RunnersConfig) AnthropicEnabled() bool { return r.Anthropic == nil || *r.Anthropic } -func (r RunnersConfig) GoogleEnabled() bool { return r.Google == nil || *r.Google } +func (r RunnersConfig) ClaudeEnabled() bool { return r.Claude == nil || *r.Claude } +func (r RunnersConfig) GeminiEnabled() bool { return r.Gemini == nil || *r.Gemini } +func (r RunnersConfig) LocalEnabled() bool { return r.Local == nil || *r.Local } +func (r RunnersConfig) ContainerEnabled() bool { return r.Container == nil || *r.Container } +func (r RunnersConfig) AnthropicEnabled() bool { return r.Anthropic == nil || *r.Anthropic } +func (r RunnersConfig) GoogleEnabled() bool { return r.Google == nil || *r.Google } +func (r RunnersConfig) GroqEnabled() bool { return r.Groq == nil || *r.Groq } +func (r RunnersConfig) OpenRouterEnabled() bool { return r.OpenRouter == nil || *r.OpenRouter } +func (r RunnersConfig) OpenAIEnabled() bool { return r.OpenAI == nil || *r.OpenAI } // ProviderConfig configures a native (or OpenAI-compatible) LLM provider // backend for the multi-provider harness — see docs/api-keys-setup.md. Phase @@ -131,6 +143,10 @@ type Config struct { LocalModel LocalModel `toml:"local_model"` Runners RunnersConfig `toml:"runners"` Budget BudgetConfig `toml:"budget"` + // Scheduler configures internal/scheduler.Scheduler, the retry-then- + // escalate loop for role-typed tasks. Started only by `serve` (the + // one-shot `run` command has no background scheduler). + Scheduler SchedulerConfig `toml:"scheduler"` // Providers configures native/OpenAI-compatible LLM backends by name (see // ProviderConfig). Unused by runner construction in Phase 1. Providers map[string]ProviderConfig `toml:"providers"` @@ -145,6 +161,21 @@ type BudgetConfig struct { Provider5hUSD map[string]float64 `toml:"provider_5h_usd"` } +// SchedulerConfig configures internal/scheduler.Scheduler's poll loop. +type SchedulerConfig struct { + // PollIntervalSeconds is how often the scheduler checks for role-typed + // FAILED tasks to retry or escalate. Defaults to 30 when zero/unset. + PollIntervalSeconds int `toml:"poll_interval_seconds"` +} + +// PollInterval returns the configured poll interval, defaulting to 30s. +func (c SchedulerConfig) PollInterval() time.Duration { + if c.PollIntervalSeconds <= 0 { + return 30 * time.Second + } + return time.Duration(c.PollIntervalSeconds) * time.Second +} + func Default() (*Config, error) { home, err := os.UserHomeDir() if err != nil { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 4167ff7..31863f8 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -74,11 +74,20 @@ func TestRunnersConfig_DefaultsAllEnabled(t *testing.T) { if !r.GoogleEnabled() { t.Error("google should be enabled by default (nil)") } + if !r.GroqEnabled() { + t.Error("groq should be enabled by default (nil)") + } + if !r.OpenRouterEnabled() { + t.Error("openrouter should be enabled by default (nil)") + } + if !r.OpenAIEnabled() { + t.Error("openai should be enabled by default (nil)") + } } func TestRunnersConfig_ExplicitFalseDisables(t *testing.T) { f := false - r := RunnersConfig{Claude: &f, Gemini: &f, Local: &f, Container: &f, Anthropic: &f, Google: &f} + r := RunnersConfig{Claude: &f, Gemini: &f, Local: &f, Container: &f, Anthropic: &f, Google: &f, Groq: &f, OpenRouter: &f, OpenAI: &f} if r.ClaudeEnabled() { t.Error("explicit false should disable claude") } @@ -97,12 +106,21 @@ func TestRunnersConfig_ExplicitFalseDisables(t *testing.T) { if r.GoogleEnabled() { t.Error("explicit false should disable google") } + if r.GroqEnabled() { + t.Error("explicit false should disable groq") + } + if r.OpenRouterEnabled() { + t.Error("explicit false should disable openrouter") + } + if r.OpenAIEnabled() { + t.Error("explicit false should disable openai") + } } func TestRunnersConfig_ExplicitTrueEnables(t *testing.T) { tr := true - r := RunnersConfig{Claude: &tr, Gemini: &tr, Local: &tr, Container: &tr, Anthropic: &tr, Google: &tr} - if !r.ClaudeEnabled() || !r.GeminiEnabled() || !r.LocalEnabled() || !r.ContainerEnabled() || !r.AnthropicEnabled() || !r.GoogleEnabled() { + r := RunnersConfig{Claude: &tr, Gemini: &tr, Local: &tr, Container: &tr, Anthropic: &tr, Google: &tr, Groq: &tr, OpenRouter: &tr, OpenAI: &tr} + if !r.ClaudeEnabled() || !r.GeminiEnabled() || !r.LocalEnabled() || !r.ContainerEnabled() || !r.AnthropicEnabled() || !r.GoogleEnabled() || !r.GroqEnabled() || !r.OpenRouterEnabled() || !r.OpenAIEnabled() { t.Error("explicit true should keep all runners enabled") } } |
