worker

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAgentImage = "verve:base"

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	WorkType string // "task" or "epic"

	// Task fields
	TaskID             string
	TaskTitle          string
	TaskDescription    string
	SkipPR             bool
	DraftPR            bool
	Attempt            int
	RetryReason        string
	AcceptanceCriteria []string
	RetryContext       string
	PreviousStatus     string

	// Epic fields
	EpicID             string
	EpicTitle          string
	EpicDescription    string
	EpicPlanningPrompt string
	EpicFeedback       string // User feedback for re-planning
	EpicPreviousPlan   string // JSON of previous proposed tasks for re-planning context
	APIURL             string // For epic agent to call back to server

	// Common fields
	GitHubToken               string
	GitHubRepo                string
	AnthropicAPIKey           string
	AnthropicBaseURL          string // Custom base URL for Anthropic API (e.g. for proxies or self-hosted endpoints)
	ClaudeCodeOAuthToken      string // OAuth token (subscription-based, alternative to API key)
	ClaudeModel               string
	DryRun                    bool
	GitHubInsecureSkipVerify  bool
	StripAnthropicBetaHeaders bool // Pass through to agent container to run a local header-stripping proxy
}

AgentConfig holds the configuration for running an agent

type Config

type Config struct {
	APIURL                    string
	AnthropicAPIKey           string // API key auth (pay-per-use)
	AnthropicBaseURL          string // Custom base URL for Anthropic API (e.g. for proxies or self-hosted endpoints)
	ClaudeCodeOAuthToken      string // OAuth token auth (subscription-based, alternative to API key)
	AgentImage                string // Docker image for agent — defaults to verve:base
	MaxConcurrentTasks        int    // Maximum concurrent tasks (default: 1)
	DryRun                    bool   // Skip Claude and make a dummy change instead
	GitHubInsecureSkipVerify  bool   // Disable TLS certificate verification for GitHub operations in agent containers
	StripAnthropicBetaHeaders bool   // Strip anthropic-beta headers via reverse proxy inside agent containers (for Bedrock proxy compatibility)
}

Config holds the worker configuration

type DockerRunner

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

func NewDockerRunner

func NewDockerRunner(agentImage string, logger log.Logger) (*DockerRunner, error)

func (*DockerRunner) AgentImage

func (d *DockerRunner) AgentImage() string

AgentImage returns the configured agent image name

func (*DockerRunner) Close

func (d *DockerRunner) Close() error

func (*DockerRunner) EnsureImage

func (d *DockerRunner) EnsureImage(ctx context.Context) error

EnsureImage checks if the agent image exists locally

func (*DockerRunner) RunAgent

func (d *DockerRunner) RunAgent(ctx context.Context, cfg AgentConfig, onLog LogCallback) RunResult

RunAgent runs the agent container and streams logs via the callback in real-time. The callback is called from a separate goroutine as logs arrive.

type Epic

type Epic struct {
	ID             string          `json:"id"`
	RepoID         string          `json:"repo_id"`
	Title          string          `json:"title"`
	Description    string          `json:"description"`
	PlanningPrompt string          `json:"planning_prompt,omitempty"`
	Model          string          `json:"model,omitempty"`
	Feedback       *string         `json:"feedback,omitempty"`
	ProposedTasks  json.RawMessage `json:"proposed_tasks,omitempty"`
}

type LogCallback

type LogCallback func(line string)

LogCallback is called for each log line from the container

type PollResponse

type PollResponse struct {
	Type         string `json:"type"` // "task" or "epic"
	Task         *Task  `json:"task,omitempty"`
	Epic         *Epic  `json:"epic,omitempty"`
	GitHubToken  string `json:"github_token"`
	RepoFullName string `json:"repo_full_name"`
}

PollResponse is a discriminated union returned by the unified poll endpoint.

type RunResult

type RunResult struct {
	Success  bool
	ExitCode int
	Error    error
}

type Task

type Task struct {
	ID                 string   `json:"id"`
	RepoID             string   `json:"repo_id"`
	Title              string   `json:"title"`
	Description        string   `json:"description"`
	Status             string   `json:"status"`
	Attempt            int      `json:"attempt"`
	MaxAttempts        int      `json:"max_attempts"`
	RetryReason        string   `json:"retry_reason,omitempty"`
	AcceptanceCriteria []string `json:"acceptance_criteria"`
	RetryContext       string   `json:"retry_context,omitempty"`
	AgentStatus        string   `json:"agent_status,omitempty"`
	CostUSD            float64  `json:"cost_usd"`
	MaxCostUSD         float64  `json:"max_cost_usd,omitempty"`
	SkipPR             bool     `json:"skip_pr"`
	DraftPR            bool     `json:"draft_pr"`
	Model              string   `json:"model,omitempty"`
}

type Worker

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

func New

func New(cfg Config, logger log.Logger) (*Worker, error)

func (*Worker) Close

func (w *Worker) Close() error

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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