diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-07 23:53:37 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 06:23:05 +0000 |
| commit | 7bd258e8f356e66147d975dfddee23f0adc5c5c1 (patch) | |
| tree | 04820fa855e884ac09b5a8c983e2d425db9db112 /internal | |
| parent | ebdb12fc37c9c8db460827fdba1aa10e5b208cb9 (diff) | |
feat(api): update elaborate and validate endpoints to use AgentConfig
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/api/elaborate.go | 20 | ||||
| -rw-r--r-- | internal/api/validate.go | 24 |
2 files changed, 28 insertions, 16 deletions
diff --git a/internal/api/elaborate.go b/internal/api/elaborate.go index 00f3297..5ab9ff0 100644 --- a/internal/api/elaborate.go +++ b/internal/api/elaborate.go @@ -18,7 +18,7 @@ func buildElaboratePrompt(workDir string) string { if workDir != "" { workDirLine = fmt.Sprintf(` "working_dir": string — use %q for tasks that operate on this codebase, empty string otherwise,`, workDir) } - return `You are a task configuration assistant for Claudomator, an AI task runner that executes tasks by running Claude as a subprocess. + return `You are a task configuration assistant for Claudomator, an AI task runner that executes tasks by running Claude or Gemini as a subprocess. Your ONLY job is to convert any user request into a Claudomator task JSON object. You MUST always output valid JSON. Never ask clarifying questions. Never explain. Never refuse. Make reasonable assumptions and produce the JSON. @@ -27,9 +27,10 @@ Output ONLY a valid JSON object matching this schema (no markdown fences, no pro { "name": string — short imperative title (≤60 chars), "description": string — 1-2 sentence summary, - "claude": { - "model": string — "sonnet" unless the task obviously needs opus, - "instructions": string — detailed, step-by-step instructions for Claude, + "agent": { + "type": "claude" | "gemini", + "model": string — "sonnet" for claude, "gemini-2.0-flash" for gemini, + "instructions": string — detailed, step-by-step instructions for the agent, ` + workDirLine + ` "max_budget_usd": number — conservative estimate (0.25–5.00), "allowed_tools": array — only tools the task genuinely needs @@ -44,13 +45,14 @@ Output ONLY a valid JSON object matching this schema (no markdown fences, no pro type elaboratedTask struct { Name string `json:"name"` Description string `json:"description"` - Claude elaboratedClaude `json:"claude"` + Agent elaboratedAgent `json:"agent"` Timeout string `json:"timeout"` Priority string `json:"priority"` Tags []string `json:"tags"` } -type elaboratedClaude struct { +type elaboratedAgent struct { + Type string `json:"type"` Model string `json:"model"` Instructions string `json:"instructions"` WorkingDir string `json:"working_dir"` @@ -144,12 +146,16 @@ func (s *Server) handleElaborateTask(w http.ResponseWriter, r *http.Request) { return } - if result.Name == "" || result.Claude.Instructions == "" { + if result.Name == "" || result.Agent.Instructions == "" { writeJSON(w, http.StatusBadGateway, map[string]string{ "error": "elaboration failed: missing required fields in response", }) return } + if result.Agent.Type == "" { + result.Agent.Type = "claude" + } + writeJSON(w, http.StatusOK, result) } diff --git a/internal/api/validate.go b/internal/api/validate.go index d8ebde9..a3b2cf0 100644 --- a/internal/api/validate.go +++ b/internal/api/validate.go @@ -12,7 +12,7 @@ import ( const validateTimeout = 20 * time.Second -const validateSystemPrompt = `You are a task instruction reviewer for Claudomator, an AI task runner that executes tasks by running Claude as a subprocess. +const validateSystemPrompt = `You are a task instruction reviewer for Claudomator, an AI task runner that executes tasks by running Claude or Gemini as a subprocess. Analyze the given task name and instructions for clarity and completeness. @@ -54,11 +54,12 @@ func (s *Server) validateBinaryPath() string { func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { var input struct { Name string `json:"name"` - Claude struct { + Agent struct { + Type string `json:"type"` Instructions string `json:"instructions"` WorkingDir string `json:"working_dir"` AllowedTools []string `json:"allowed_tools"` - } `json:"claude"` + } `json:"agent"` } if err := json.NewDecoder(r.Body).Decode(&input); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid JSON: " + err.Error()}) @@ -68,17 +69,22 @@ func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "name is required"}) return } - if input.Claude.Instructions == "" { + if input.Agent.Instructions == "" { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "instructions are required"}) return } - userMsg := fmt.Sprintf("Task name: %s\n\nInstructions:\n%s", input.Name, input.Claude.Instructions) - if input.Claude.WorkingDir != "" { - userMsg += fmt.Sprintf("\n\nWorking directory: %s", input.Claude.WorkingDir) + agentType := input.Agent.Type + if agentType == "" { + agentType = "claude" } - if len(input.Claude.AllowedTools) > 0 { - userMsg += fmt.Sprintf("\n\nAllowed tools: %v", input.Claude.AllowedTools) + + userMsg := fmt.Sprintf("Task name: %s\nAgent: %s\n\nInstructions:\n%s", input.Name, agentType, input.Agent.Instructions) + if input.Agent.WorkingDir != "" { + userMsg += fmt.Sprintf("\n\nWorking directory: %s", input.Agent.WorkingDir) + } + if len(input.Agent.AllowedTools) > 0 { + userMsg += fmt.Sprintf("\n\nAllowed tools: %v", input.Agent.AllowedTools) } ctx, cancel := context.WithTimeout(r.Context(), validateTimeout) |
