summaryrefslogtreecommitdiff
path: root/internal/executor/claude.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/claude.go')
-rw-r--r--internal/executor/claude.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/internal/executor/claude.go b/internal/executor/claude.go
index 8901d35..8486427 100644
--- a/internal/executor/claude.go
+++ b/internal/executor/claude.go
@@ -20,6 +20,7 @@ type ClaudeRunner struct {
BinaryPath string // defaults to "claude"
Logger *slog.Logger
LogDir string // base directory for execution logs
+ APIURL string // base URL of the Claudomator API, passed to subprocesses
}
func (r *ClaudeRunner) binaryPath() string {
@@ -34,6 +35,10 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi
args := r.buildArgs(t)
cmd := exec.CommandContext(ctx, r.binaryPath(), args...)
+ cmd.Env = append(os.Environ(),
+ "CLAUDOMATOR_API_URL="+r.APIURL,
+ "CLAUDOMATOR_TASK_ID="+t.ID,
+ )
if t.Claude.WorkingDir != "" {
cmd.Dir = t.Claude.WorkingDir
}
@@ -96,8 +101,26 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi
}
func (r *ClaudeRunner) buildArgs(t *task.Task) []string {
+ instructions := t.Claude.Instructions
+ allowedTools := t.Claude.AllowedTools
+
+ if !t.Claude.SkipPlanning {
+ instructions = withPlanningPreamble(instructions)
+ // Ensure Bash is available so the agent can POST subtasks.
+ hasBash := false
+ for _, tool := range allowedTools {
+ if tool == "Bash" {
+ hasBash = true
+ break
+ }
+ }
+ if !hasBash {
+ allowedTools = append(allowedTools, "Bash")
+ }
+ }
+
args := []string{
- "-p", t.Claude.Instructions,
+ "-p", instructions,
"--output-format", "stream-json",
"--verbose",
}
@@ -114,7 +137,7 @@ func (r *ClaudeRunner) buildArgs(t *task.Task) []string {
if t.Claude.SystemPromptAppend != "" {
args = append(args, "--append-system-prompt", t.Claude.SystemPromptAppend)
}
- for _, tool := range t.Claude.AllowedTools {
+ for _, tool := range allowedTools {
args = append(args, "--allowedTools", tool)
}
for _, tool := range t.Claude.DisallowedTools {