exec

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// RateLimitWaitSeconds is how long to wait when rate limited (61 minutes)
	RateLimitWaitSeconds = 3660
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Prompt        string
	MaxIterations int
	Branch        string
	LogDir        string
	StateDir      string
}

Config represents the configuration for the exec command. All values are loaded from environment variables.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads configuration from environment variables using viper.

type LogSinkFactory

type LogSinkFactory func(ctx context.Context) (io.Writer, func())

LogSinkFactory creates an optional io.Writer for streaming logs to a remote store. Returns (nil, nil) if not applicable. The cleanup function should be called when the writer is no longer needed.

type Runner

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

Runner executes the main iteration loop.

func NewRunner

func NewRunner(config *Config, state *State, statePath string, opts ...RunnerOption) *Runner

NewRunner creates a new Runner with the given config and state.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) int

Run executes the main iteration loop. Returns exit code: 0 for completion, 1 for auth error, 1 for max iterations reached.

type RunnerOption

type RunnerOption func(*Runner)

RunnerOption configures optional Runner behavior.

func WithLogSinkFactory

func WithLogSinkFactory(f LogSinkFactory) RunnerOption

WithLogSinkFactory sets a factory for creating a remote log sink.

func WithStateSyncFactory

func WithStateSyncFactory(f StateSyncFactory) RunnerOption

WithStateSyncFactory sets a factory for creating a remote state sync function.

type State

type State struct {
	Branch        string    `json:"branch"`
	Iteration     int       `json:"iteration"`
	Status        status    `json:"status"`
	LastUpdated   time.Time `json:"last_updated"`
	StartedAt     time.Time `json:"started_at"`
	CompletedAt   time.Time `json:"completed_at,omitempty"`
	ErrorMessage  string    `json:"error_message,omitempty"`
	CPUPercent    float64   `json:"cpu_percent,omitempty"`
	MemoryPercent float64   `json:"memory_percent,omitempty"`
}

State represents the persistent state of the execution loop.

func LoadState

func LoadState(path string) (*State, error)

LoadState loads the state from a JSON file. If the file does not exist, it returns a new state with default values.

type StateSyncFactory

type StateSyncFactory func(ctx context.Context) StateSyncFunc

StateSyncFactory creates an optional function for syncing state to a remote store. Returns nil if not applicable.

type StateSyncFunc

type StateSyncFunc func(statePath string)

StateSyncFunc is called after each local state save to sync state to a remote store (e.g., GCS). It receives the path to the local state file. Errors are logged as warnings but do not fail the loop.

Jump to

Keyboard shortcuts

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