summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-05-13 04:02:20 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-05-13 04:02:20 +0000
commit68399a598924775a3ec22a39c2336ae497fb07f3 (patch)
tree29ade8224eb51eca47a1d9d03bb4d0d3653a72aa /internal/cli
parentf01231cc45f41ce2dc37072e77428e467ef3fc15 (diff)
parentd970c0730ff0dc7d714d3261197d8ba52b5d21f4 (diff)
merge: integrate github/main — LocalRunner, real GeminiRunner, llm clientHEADmain
Merges 12 commits from github/main (formerly master) that were developed independently. Key additions: - LocalRunner: OpenAI-compatible local LLM execution (Ollama, LM Studio) - Real GeminiRunner with full sandbox parity to ClaudeRunner - llm.Client for enriching CI failures and elaboration via local model - retry.ParseRetryAfter moved to shared package - tokens_in/tokens_out columns in executions table Conflict resolutions: - Kept local main's VAPID/push, stories, projects, agent events schema - Merged both sets of Config fields (local + LocalModel from github/main) - Unified activePerAgent accounting (decActiveAgent helper) - Removed duplicate helpers from claude.go (now in helpers.go) - Fixed double-decrement bug in handleRunResult vs decActiveAgent Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/llm.go31
-rw-r--r--internal/cli/run.go19
-rw-r--r--internal/cli/serve.go24
3 files changed, 70 insertions, 4 deletions
diff --git a/internal/cli/llm.go b/internal/cli/llm.go
new file mode 100644
index 0000000..04fe902
--- /dev/null
+++ b/internal/cli/llm.go
@@ -0,0 +1,31 @@
+package cli
+
+import (
+ "log/slog"
+ "net/http"
+ "time"
+
+ "github.com/thepeterstone/claudomator/internal/config"
+ "github.com/thepeterstone/claudomator/internal/llm"
+)
+
+// buildLocalLLMClient returns an *llm.Client when a local model endpoint is
+// configured. Returns nil when LocalModel.Endpoint is empty so callers can
+// gate on `if c != nil` to skip registering LocalRunner / using the LLM
+// classifier path.
+func buildLocalLLMClient(cfg config.LocalModel, logger *slog.Logger) *llm.Client {
+ if cfg.Endpoint == "" {
+ return nil
+ }
+ timeout := 60 * time.Second
+ if cfg.TimeoutSeconds > 0 {
+ timeout = time.Duration(cfg.TimeoutSeconds) * time.Second
+ }
+ return &llm.Client{
+ Endpoint: cfg.Endpoint,
+ Model: cfg.Model,
+ APIKey: cfg.APIKey,
+ HTTPClient: &http.Client{Timeout: timeout},
+ Logger: logger,
+ }
+}
diff --git a/internal/cli/run.go b/internal/cli/run.go
index cfac893..48f34b7 100644
--- a/internal/cli/run.go
+++ b/internal/cli/run.go
@@ -100,9 +100,24 @@ func runTasks(file string, parallel int, dryRun bool) error {
},
}
+ localClient := buildLocalLLMClient(cfg.LocalModel, logger)
+ if localClient != nil {
+ runners["local"] = &executor.LocalRunner{
+ Client: localClient,
+ Logger: logger,
+ LogDir: cfg.LogDir,
+ DefaultTemperature: cfg.LocalModel.DefaultTemperature,
+ }
+ }
+
+
pool := executor.NewPool(parallel, runners, store, logger)
- if cfg.GeminiBinaryPath != "" {
- pool.Classifier = &executor.Classifier{GeminiBinaryPath: cfg.GeminiBinaryPath}
+ pool.Classifier = &executor.Classifier{
+ LLM: localClient,
+ GeminiBinaryPath: cfg.GeminiBinaryPath,
+ }
+ if localClient != nil {
+ pool.LLM = localClient
}
// Handle graceful shutdown.
diff --git a/internal/cli/serve.go b/internal/cli/serve.go
index 581a064..459c35b 100644
--- a/internal/cli/serve.go
+++ b/internal/cli/serve.go
@@ -117,9 +117,25 @@ func serve(addr string) error {
},
}
+ localClient := buildLocalLLMClient(cfg.LocalModel, logger)
+ if localClient != nil {
+ runners["local"] = &executor.LocalRunner{
+ Client: localClient,
+ Logger: logger,
+ LogDir: cfg.LogDir,
+ DefaultTemperature: cfg.LocalModel.DefaultTemperature,
+ }
+ logger.Info("local runner registered", "endpoint", cfg.LocalModel.Endpoint, "model", cfg.LocalModel.Model)
+ }
+
+
pool := executor.NewPool(cfg.MaxConcurrent, runners, store, logger)
- if cfg.GeminiBinaryPath != "" {
- pool.Classifier = &executor.Classifier{GeminiBinaryPath: cfg.GeminiBinaryPath}
+ pool.Classifier = &executor.Classifier{
+ LLM: localClient,
+ GeminiBinaryPath: cfg.GeminiBinaryPath,
+ }
+ if localClient != nil {
+ pool.LLM = localClient
}
if err := store.SeedProjects(); err != nil {
@@ -154,6 +170,10 @@ func serve(addr string) error {
if cfg.WorkspaceRoot != "" {
srv.SetWorkspaceRoot(cfg.WorkspaceRoot)
}
+ if cfg.LocalModel.UseForElaborate() {
+ srv.SetLLM(localClient)
+ logger.Info("elaboration prefers local llm", "endpoint", cfg.LocalModel.Endpoint)
+ }
srv.SetGitHubWebhookConfig(cfg.WebhookSecret, cfg.Projects)
// Register scripts.