executor

package
v0.3.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package executor provides agent execution interfaces for different AI coding agents

Package executor provides Amp agent implementation

Package executor handles Claude Code subprocess execution

Package executor provides Claude Code agent implementation

Package executor provides OpenAI Codex agent implementation

Package executor provides drover-code agent implementation

Package executor provides OpenCode agent implementation

Package executor provides agent execution interfaces for different AI coding agents

Index

Constants

View Source
const AgentTypeDroverCode = "drovercode"

Variables

This section is empty.

Functions

func CheckClaudeInstalled

func CheckClaudeInstalled(path string) error

CheckClaudeInstalled verifies Claude Code is available

Types

type Agent

type Agent interface {
	// ExecuteWithContext runs a task with a context and returns the execution result
	ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

	// CheckInstalled verifies the agent is available and properly configured
	CheckInstalled() error

	// SetVerbose enables or disables verbose logging
	SetVerbose(bool)

	// SetProjectGuidelines sets project-specific guidelines for the agent
	SetProjectGuidelines(guidelines string)

	// SetContextManager sets the context window manager for the agent
	SetContextManager(manager *ctxmngr.Manager)

	// SetTaskContext sets recent completed tasks for context carrying
	SetTaskContext(recentTasks []*types.Task, taskContextCount int)
}

Agent is the interface that all AI coding agents must implement

func NewAgent

func NewAgent(cfg *AgentConfig) (Agent, error)

NewAgent creates a new Agent based on the provided configuration

type AgentConfig

type AgentConfig struct {
	// Type is the agent type: "claude", "codex", "amp", "opencode", or "worker"
	Type string

	// Path is the path to the agent binary (for claude/codex/amp CLIs)
	Path string

	// Timeout is the maximum duration to wait for task completion
	Timeout time.Duration

	// Verbose enables detailed logging
	Verbose bool

	// ProjectGuidelines contains project-specific guidelines to include in prompts
	ProjectGuidelines string

	// ContextThresholds defines size limits for content types
	ContextThresholds *ctxmngr.ContentThresholds

	// WorkerBinary is the path to drover-worker binary (for type="worker")
	WorkerBinary string

	// WorkerMemoryLimit is the memory limit for worker processes (for type="worker")
	WorkerMemoryLimit string
}

AgentConfig contains configuration for creating an agent

type AgentResult

type AgentResult struct {
	Success bool   `json:"success"`
	Output  string `json:"output,omitempty"`
	Error   string `json:"error,omitempty"`
	Version int    `json:"version,omitempty"`
}

type AmpAgent

type AmpAgent struct {
	// contains filtered or unexported fields
}

AmpAgent runs tasks using Amp CLI See: https://ampcode.com/manual

func NewAmpAgent

func NewAmpAgent(ampPath string, timeout time.Duration) *AmpAgent

NewAmpAgent creates a new Amp agent

func (*AmpAgent) CheckInstalled

func (a *AmpAgent) CheckInstalled() error

CheckInstalled verifies Amp CLI is available

func (*AmpAgent) ExecuteWithContext

func (a *AmpAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*AmpAgent) SetContextManager

func (a *AmpAgent) SetContextManager(manager *ctxmngr.Manager)

SetContextManager sets the context window manager for the agent

func (*AmpAgent) SetProjectGuidelines

func (a *AmpAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines for the agent

func (*AmpAgent) SetTaskContext

func (a *AmpAgent) SetTaskContext(recentTasks []*types.Task, taskContextCount int)

SetTaskContext sets recent completed tasks for context carrying

func (*AmpAgent) SetVerbose

func (a *AmpAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type ClaudeAgent

type ClaudeAgent struct {
	// contains filtered or unexported fields
}

ClaudeAgent runs tasks using Claude Code CLI

func NewClaudeAgent

func NewClaudeAgent(claudePath string, timeout time.Duration) *ClaudeAgent

NewClaudeAgent creates a new Claude Code agent

func (*ClaudeAgent) CheckInstalled

func (a *ClaudeAgent) CheckInstalled() error

CheckInstalled verifies Claude Code is available

func (*ClaudeAgent) ExecuteWithContext

func (a *ClaudeAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*ClaudeAgent) SetContextManager

func (a *ClaudeAgent) SetContextManager(manager *ctxmngr.Manager)

SetContextManager sets the context window manager for the agent

func (*ClaudeAgent) SetProjectGuidelines

func (a *ClaudeAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines for the agent

func (*ClaudeAgent) SetTaskContext

func (a *ClaudeAgent) SetTaskContext(recentTasks []*types.Task, taskContextCount int)

SetTaskContext sets recent completed tasks for context carrying

func (*ClaudeAgent) SetVerbose

func (a *ClaudeAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type CodexAgent

type CodexAgent struct {
	// contains filtered or unexported fields
}

CodexAgent runs tasks using OpenAI Codex CLI See: https://developers.openai.com/codex/cli/

func NewCodexAgent

func NewCodexAgent(codexPath string, timeout time.Duration) *CodexAgent

NewCodexAgent creates a new Codex agent

func (*CodexAgent) CheckInstalled

func (a *CodexAgent) CheckInstalled() error

CheckInstalled verifies Codex CLI is available

func (*CodexAgent) ExecuteWithContext

func (a *CodexAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*CodexAgent) SetContextManager

func (a *CodexAgent) SetContextManager(manager *ctxmngr.Manager)

SetContextManager sets the context window manager for the agent

func (*CodexAgent) SetProjectGuidelines

func (a *CodexAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines for the agent

func (*CodexAgent) SetTaskContext

func (a *CodexAgent) SetTaskContext(recentTasks []*types.Task, taskContextCount int)

SetTaskContext sets recent completed tasks for context carrying

func (*CodexAgent) SetVerbose

func (a *CodexAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type DroverCodeAgent

type DroverCodeAgent struct {
	// contains filtered or unexported fields
}

DroverCodeAgent runs tasks using the drover-code binary (pure-Go Claude-compatible agent)

func NewDroverCodeAgent

func NewDroverCodeAgent(binaryPath string, timeout time.Duration) *DroverCodeAgent

NewDroverCodeAgent creates a new drover-code agent

func (*DroverCodeAgent) CheckInstalled

func (a *DroverCodeAgent) CheckInstalled() error

CheckInstalled verifies drover-code is available

func (*DroverCodeAgent) ExecuteWithContext

func (a *DroverCodeAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*DroverCodeAgent) SetDroverCodeConfig

func (a *DroverCodeAgent) SetDroverCodeConfig(resultJSONPath, permissionPreset string, coordinatorMode, jsonl bool)

SetDroverCodeConfig sets drover-code-specific options (call after NewDroverCodeAgent)

func (*DroverCodeAgent) SetProjectGuidelines

func (a *DroverCodeAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines for the agent

func (*DroverCodeAgent) SetVerbose

func (a *DroverCodeAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type ExecutionResult

type ExecutionResult struct {
	Success  bool
	Output   string
	Error    error
	Duration time.Duration
	Signal   worker.WorkerSignal // Worker signal for backpressure control

	// Memory metrics for drover-mem-6
	WorkerPID     int   `json:"worker_pid,omitempty"`      // PID of the worker process
	PeakRSSBytes  int64 `json:"peak_rss_bytes,omitempty"`  // Peak RSS during execution
	FinalRSSBytes int64 `json:"final_rss_bytes,omitempty"` // Final RSS at completion
}

ExecutionResult contains the result of a Claude execution

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor runs tasks using Claude Code

func NewExecutor

func NewExecutor(claudePath string, timeout time.Duration) *Executor

NewExecutor creates a new Claude Code executor

func (*Executor) Execute

func (e *Executor) Execute(worktreePath string, task *types.Task) *ExecutionResult

Execute runs a task using Claude Code in the given directory and returns the execution result

func (*Executor) ExecuteWithContext

func (e *Executor) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*Executor) ExecuteWithTimeout

func (e *Executor) ExecuteWithTimeout(parentCtx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithTimeout runs a task with a timeout and returns the execution result

func (*Executor) SetVerbose

func (e *Executor) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type OpenCodeAgent

type OpenCodeAgent struct {
	// contains filtered or unexported fields
}

OpenCodeAgent runs tasks using OpenCode CLI

func NewOpenCodeAgent

func NewOpenCodeAgent(opencodePath string, timeout time.Duration) *OpenCodeAgent

NewOpenCodeAgent creates a new OpenCode agent

func (*OpenCodeAgent) CheckInstalled

func (a *OpenCodeAgent) CheckInstalled() error

CheckInstalled verifies OpenCode is available

func (*OpenCodeAgent) ExecuteWithContext

func (a *OpenCodeAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task with a context and returns the execution result

func (*OpenCodeAgent) SetContextManager

func (a *OpenCodeAgent) SetContextManager(manager *ctxmngr.Manager)

SetContextManager sets the context window manager for the agent

func (*OpenCodeAgent) SetProjectGuidelines

func (a *OpenCodeAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines for the agent

func (*OpenCodeAgent) SetTaskContext

func (a *OpenCodeAgent) SetTaskContext(recentTasks []*types.Task, taskContextCount int)

SetTaskContext sets recent completed tasks for context carrying

func (*OpenCodeAgent) SetVerbose

func (a *OpenCodeAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

type WorkerAgent

type WorkerAgent struct {
	// contains filtered or unexported fields
}

WorkerAgent executes tasks via the drover-worker subprocess

func NewWorkerAgent

func NewWorkerAgent(workerBinary, claudePath string, timeout time.Duration) *WorkerAgent

NewWorkerAgent creates a new worker subprocess agent

func (*WorkerAgent) CheckInstalled

func (a *WorkerAgent) CheckInstalled() error

CheckInstalled verifies the drover-worker binary is available

func (*WorkerAgent) ExecuteWithContext

func (a *WorkerAgent) ExecuteWithContext(ctx context.Context, worktreePath string, task *types.Task, parentSpan ...trace.Span) *ExecutionResult

ExecuteWithContext runs a task using the drover-worker subprocess

func (*WorkerAgent) SetContextManager

func (a *WorkerAgent) SetContextManager(manager *ctxmngr.Manager)

SetContextManager sets the context window manager (not used in worker mode)

func (*WorkerAgent) SetMemoryLimit

func (a *WorkerAgent) SetMemoryLimit(limit string)

SetMemoryLimit sets the memory limit for worker processes

func (*WorkerAgent) SetProjectGuidelines

func (a *WorkerAgent) SetProjectGuidelines(guidelines string)

SetProjectGuidelines sets project-specific guidelines (not yet supported in worker mode)

func (*WorkerAgent) SetTaskContext

func (a *WorkerAgent) SetTaskContext(recentTasks []*types.Task, taskContextCount int)

SetTaskContext sets recent completed tasks for context carrying

func (*WorkerAgent) SetVerbose

func (a *WorkerAgent) SetVerbose(v bool)

SetVerbose enables or disables verbose logging

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL