From e6e1e7cd6d79eb969345e738f2554108681ade95 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 8 Mar 2026 21:41:08 +0000 Subject: fix: restore task execution broken by add-gemini merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - handleCreateTask: add legacy "claude" key fallback in input struct so old clients and YAML files sending claude:{...} still work - cli/create: send "agent" key instead of "claude"; add --agent-type flag - storage/db_test: fix ClaudeConfig → AgentConfig after rename Co-Authored-By: Claude Sonnet 4.6 --- internal/api/server.go | 20 +++++++++++++------- internal/cli/create.go | 13 ++++++++----- internal/cli/create_test.go | 6 +++--- internal/storage/db_test.go | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) (limited to 'internal') diff --git a/internal/api/server.go b/internal/api/server.go index 3d7cb1e..34e1872 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -346,19 +346,25 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) { func (s *Server) handleCreateTask(w http.ResponseWriter, r *http.Request) { var input struct { - Name string `json:"name"` - Description string `json:"description"` - Agent task.AgentConfig `json:"agent"` - Timeout string `json:"timeout"` - Priority string `json:"priority"` - Tags []string `json:"tags"` - ParentTaskID string `json:"parent_task_id"` + Name string `json:"name"` + Description string `json:"description"` + Agent task.AgentConfig `json:"agent"` + Claude task.AgentConfig `json:"claude"` // legacy alias + Timeout string `json:"timeout"` + Priority string `json:"priority"` + Tags []string `json:"tags"` + ParentTaskID string `json:"parent_task_id"` } if err := json.NewDecoder(r.Body).Decode(&input); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid JSON: " + err.Error()}) return } + // Accept legacy "claude" key when "agent" is not provided. + if input.Agent.Instructions == "" && input.Claude.Instructions != "" { + input.Agent = input.Claude + } + now := time.Now().UTC() t := &task.Task{ ID: uuid.New().String(), diff --git a/internal/cli/create.go b/internal/cli/create.go index addd034..e5435d3 100644 --- a/internal/cli/create.go +++ b/internal/cli/create.go @@ -15,6 +15,7 @@ func newCreateCmd() *cobra.Command { instructions string workingDir string model string + agentType string parentID string budget float64 timeout string @@ -27,14 +28,15 @@ func newCreateCmd() *cobra.Command { Short: "Create a task via the running server", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - return createTask(serverURL, args[0], instructions, workingDir, model, parentID, budget, timeout, priority, autoStart) + return createTask(serverURL, args[0], instructions, workingDir, model, agentType, parentID, budget, timeout, priority, autoStart) }, } - cmd.Flags().StringVar(&serverURL, "server", "http://localhost:8484", "claudomator server URL") + cmd.Flags().StringVar(&serverURL, "server", defaultServerURL, "claudomator server URL") cmd.Flags().StringVarP(&instructions, "instructions", "i", "", "task instructions (required)") cmd.Flags().StringVarP(&workingDir, "working-dir", "d", "", "working directory for the task") - cmd.Flags().StringVarP(&model, "model", "m", "", "claude model to use") + cmd.Flags().StringVarP(&model, "model", "m", "", "model to use") + cmd.Flags().StringVar(&agentType, "agent-type", "claude", "agent type: claude, gemini") cmd.Flags().StringVar(&parentID, "parent-id", "", "parent task ID (makes this a subtask)") cmd.Flags().Float64Var(&budget, "budget", 1.0, "max budget in USD") cmd.Flags().StringVar(&timeout, "timeout", "15m", "task timeout") @@ -45,12 +47,13 @@ func newCreateCmd() *cobra.Command { return cmd } -func createTask(serverURL, name, instructions, workingDir, model, parentID string, budget float64, timeout, priority string, autoStart bool) error { +func createTask(serverURL, name, instructions, workingDir, model, agentType, parentID string, budget float64, timeout, priority string, autoStart bool) error { body := map[string]interface{}{ "name": name, "timeout": timeout, "priority": priority, - "claude": map[string]interface{}{ + "agent": map[string]interface{}{ + "type": agentType, "instructions": instructions, "project_dir": workingDir, "model": model, diff --git a/internal/cli/create_test.go b/internal/cli/create_test.go index 22ce6bd..4ce1071 100644 --- a/internal/cli/create_test.go +++ b/internal/cli/create_test.go @@ -21,7 +21,7 @@ func TestCreateTask_TimesOut(t *testing.T) { httpClient = &http.Client{Timeout: 50 * time.Millisecond} defer func() { httpClient = orig }() - err := createTask(srv.URL, "test", "do something", "", "", "", 1.0, "15m", "normal", false) + err := createTask(srv.URL, "test", "do something", "", "", "claude", "", 1.0, "15m", "normal", false) if err == nil { t.Fatal("expected timeout error, got nil") } @@ -61,7 +61,7 @@ func TestCreateTask_MissingIDField_ReturnsError(t *testing.T) { })) defer srv.Close() - err := createTask(srv.URL, "test", "do something", "", "", "", 1.0, "15m", "normal", false) + err := createTask(srv.URL, "test", "do something", "", "", "claude", "", 1.0, "15m", "normal", false) if err == nil { t.Fatal("expected error for missing id field, got nil") } @@ -77,7 +77,7 @@ func TestCreateTask_NonJSONResponse_ReturnsError(t *testing.T) { })) defer srv.Close() - err := createTask(srv.URL, "test", "do something", "", "", "", 1.0, "15m", "normal", false) + err := createTask(srv.URL, "test", "do something", "", "", "claude", "", 1.0, "15m", "normal", false) if err == nil { t.Fatal("expected error for non-JSON response, got nil") } diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go index f737096..e76c00a 100644 --- a/internal/storage/db_test.go +++ b/internal/storage/db_test.go @@ -130,7 +130,7 @@ func TestUpdateTaskState_InvalidTransition(t *testing.T) { tk := &task.Task{ ID: "task-invalid", Name: "InvalidTransition", - Claude: task.ClaudeConfig{Instructions: "test"}, + Agent: task.AgentConfig{Instructions: "test"}, Priority: task.PriorityNormal, Retry: task.RetryConfig{MaxAttempts: 1, Backoff: "linear"}, Tags: []string{}, -- cgit v1.2.3