diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/cli/run.go | 16 | ||||
| -rw-r--r-- | internal/cli/serve.go | 26 | ||||
| -rw-r--r-- | internal/config/config.go | 19 | ||||
| -rw-r--r-- | internal/config/config_test.go | 82 |
4 files changed, 127 insertions, 16 deletions
diff --git a/internal/cli/run.go b/internal/cli/run.go index 48f34b7..771c7b7 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -77,8 +77,10 @@ func runTasks(file string, parallel int, dryRun bool) error { apiURL = "http://" + cfg.ServerAddr } - runners := map[string]executor.Runner{ - "claude": &executor.ContainerRunner{ + runners := map[string]executor.Runner{} + + if cfg.Runners.ClaudeEnabled() { + runners["claude"] = &executor.ContainerRunner{ Image: cfg.ClaudeImage, Logger: logger, LogDir: cfg.LogDir, @@ -87,8 +89,10 @@ func runTasks(file string, parallel int, dryRun bool) error { SSHAuthSock: cfg.SSHAuthSock, ClaudeBinary: cfg.ClaudeBinaryPath, GeminiBinary: cfg.GeminiBinaryPath, - }, - "gemini": &executor.ContainerRunner{ + } + } + if cfg.Runners.GeminiEnabled() { + runners["gemini"] = &executor.ContainerRunner{ Image: cfg.GeminiImage, Logger: logger, LogDir: cfg.LogDir, @@ -97,11 +101,11 @@ func runTasks(file string, parallel int, dryRun bool) error { SSHAuthSock: cfg.SSHAuthSock, ClaudeBinary: cfg.ClaudeBinaryPath, GeminiBinary: cfg.GeminiBinaryPath, - }, + } } localClient := buildLocalLLMClient(cfg.LocalModel, logger) - if localClient != nil { + if localClient != nil && cfg.Runners.LocalEnabled() { runners["local"] = &executor.LocalRunner{ Client: localClient, Logger: logger, diff --git a/internal/cli/serve.go b/internal/cli/serve.go index 459c35b..dae66d6 100644 --- a/internal/cli/serve.go +++ b/internal/cli/serve.go @@ -79,10 +79,12 @@ func serve(addr string) error { claudeConfigDir := cfg.ClaudeConfigDir repoDir, _ := os.Getwd() - runners := map[string]executor.Runner{ - // ContainerRunner: binaries are resolved via PATH inside the container image, - // so ClaudeBinary/GeminiBinary are left empty (host paths would not exist inside). - "claude": &executor.ContainerRunner{ + runners := map[string]executor.Runner{} + + // ContainerRunner: binaries are resolved via PATH inside the container image, + // so ClaudeBinary/GeminiBinary are left empty (host paths would not exist inside). + if cfg.Runners.ClaudeEnabled() { + runners["claude"] = &executor.ContainerRunner{ Image: cfg.ClaudeImage, Logger: logger, LogDir: cfg.LogDir, @@ -92,8 +94,10 @@ func serve(addr string) error { ClaudeConfigDir: claudeConfigDir, CredentialSyncCmd: filepath.Join(repoDir, "scripts", "sync-credentials"), Store: store, - }, - "gemini": &executor.ContainerRunner{ + } + } + if cfg.Runners.GeminiEnabled() { + runners["gemini"] = &executor.ContainerRunner{ Image: cfg.GeminiImage, Logger: logger, LogDir: cfg.LogDir, @@ -103,8 +107,10 @@ func serve(addr string) error { ClaudeConfigDir: claudeConfigDir, CredentialSyncCmd: filepath.Join(repoDir, "scripts", "sync-credentials"), Store: store, - }, - "container": &executor.ContainerRunner{ + } + } + if cfg.Runners.ContainerEnabled() { + runners["container"] = &executor.ContainerRunner{ Image: "claudomator-agent:latest", Logger: logger, LogDir: cfg.LogDir, @@ -114,11 +120,11 @@ func serve(addr string) error { ClaudeConfigDir: claudeConfigDir, CredentialSyncCmd: filepath.Join(repoDir, "scripts", "sync-credentials"), Store: store, - }, + } } localClient := buildLocalLLMClient(cfg.LocalModel, logger) - if localClient != nil { + if localClient != nil && cfg.Runners.LocalEnabled() { runners["local"] = &executor.LocalRunner{ Client: localClient, Logger: logger, diff --git a/internal/config/config.go b/internal/config/config.go index 25187cf..892d3f7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -45,6 +45,24 @@ func (m LocalModel) UseForElaborate() bool { return *m.PreferForElaborate } +// RunnersConfig controls which agent runners are registered. Each field is a +// *bool so that nil (absent from TOML) means "enabled by default", while an +// explicit false disables the runner without affecting others. +// +// The local runner also requires LocalModel.Endpoint to be set; setting +// Local = true without an endpoint has no effect. +type RunnersConfig struct { + Claude *bool `toml:"claude"` + Gemini *bool `toml:"gemini"` + Local *bool `toml:"local"` + Container *bool `toml:"container"` +} + +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 } + type Config struct { DataDir string `toml:"data_dir"` DBPath string `toml:"-"` @@ -68,6 +86,7 @@ type Config struct { VAPIDEmail string `toml:"vapid_email"` ClaudeConfigDir string `toml:"claude_config_dir"` LocalModel LocalModel `toml:"local_model"` + Runners RunnersConfig `toml:"runners"` } func Default() (*Config, error) { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index e4f1a5d..0d47ca0 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -54,6 +54,88 @@ func TestLoadFile_MissingFile_ReturnsError(t *testing.T) { } } +func TestRunnersConfig_DefaultsAllEnabled(t *testing.T) { + r := RunnersConfig{} + if !r.ClaudeEnabled() { + t.Error("claude should be enabled by default (nil)") + } + if !r.GeminiEnabled() { + t.Error("gemini should be enabled by default (nil)") + } + if !r.LocalEnabled() { + t.Error("local should be enabled by default (nil)") + } + if !r.ContainerEnabled() { + t.Error("container should be enabled by default (nil)") + } +} + +func TestRunnersConfig_ExplicitFalseDisables(t *testing.T) { + f := false + r := RunnersConfig{Claude: &f, Gemini: &f, Local: &f, Container: &f} + if r.ClaudeEnabled() { + t.Error("explicit false should disable claude") + } + if r.GeminiEnabled() { + t.Error("explicit false should disable gemini") + } + if r.LocalEnabled() { + t.Error("explicit false should disable local") + } + if r.ContainerEnabled() { + t.Error("explicit false should disable container") + } +} + +func TestRunnersConfig_ExplicitTrueEnables(t *testing.T) { + tr := true + r := RunnersConfig{Claude: &tr, Gemini: &tr, Local: &tr, Container: &tr} + if !r.ClaudeEnabled() || !r.GeminiEnabled() || !r.LocalEnabled() || !r.ContainerEnabled() { + t.Error("explicit true should keep all runners enabled") + } +} + +func TestRunnersConfig_MixedToggles(t *testing.T) { + f, tr := false, true + r := RunnersConfig{Claude: &tr, Gemini: &f, Local: &tr} + if !r.ClaudeEnabled() { + t.Error("claude should be enabled") + } + if r.GeminiEnabled() { + t.Error("gemini should be disabled") + } + if !r.LocalEnabled() { + t.Error("local should be enabled") + } + if !r.ContainerEnabled() { + t.Error("container should be enabled (nil = default)") + } +} + +func TestRunnersConfig_TOMLRoundTrip(t *testing.T) { + dir := t.TempDir() + path := filepath.Join(dir, "config.toml") + toml := "[runners]\ngemini = false\n" + if err := os.WriteFile(path, []byte(toml), 0600); err != nil { + t.Fatal(err) + } + t.Setenv("HOME", dir) + + cfg, err := LoadFile(path) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if cfg.Runners.GeminiEnabled() { + t.Error("gemini should be disabled after TOML load") + } + if !cfg.Runners.ClaudeEnabled() { + t.Error("claude should remain enabled (not in TOML)") + } + if !cfg.Runners.LocalEnabled() { + t.Error("local should remain enabled (not in TOML)") + } +} + func TestLocalModel_UseForElaborate_EmptyEndpoint(t *testing.T) { m := LocalModel{} if m.UseForElaborate() { |
