runner

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 17 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

Overview

Package runner executes CommandSpecs. It is the only package that touches os/exec, so every caller can be tested against a fake.

Agent CLIs spawn children, so cancellation kills the whole process group. Killing only the parent leaks grandchildren that hold the stdout pipe open.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandSpec

type CommandSpec struct {
	Argv []string // Argv[0] is replaced with the resolved CLI path before exec
	Dir  string   // workspace the agent runs in
	Env  []string // extras appended to os.Environ()
}

CommandSpec describes a runner invocation. Harnesses build specs but never touch os/exec; this package executes them, so callers can fake execution entirely.

type Exec

type Exec struct{}

Exec runs commands for real. Isolation is the pod's concern, not this package's: specs execute unconfined.

func (*Exec) Run

func (e *Exec) Run(ctx context.Context, spec CommandSpec, timeout time.Duration,
	onLine func(line []byte) (abort bool, reason string)) (Result, error)

Run executes spec with the given timeout, collecting stdout (bounded) into Result.Stdout. When onLine is non-nil it observes every stdout line as it streams; returning abort=true kills the process group and ends the run with Aborted=true and the observer's reason, plus everything collected so far. Neither an abort nor a timed-out run is an error: a timeout returns TimedOut=true with whatever output arrived, so callers can grade or parse partial output. The returned error is non-nil only for unstartable commands or parent-context cancellation (Ctrl-C).

type Result

type Result struct {
	Stdout      []byte        // full stdout (bounded), ANSI-stripped
	TimedOut    bool          // the per-run timeout expired
	Aborted     bool          // the per-line observer ended the run early
	AbortReason string        // the observer's reason for aborting
	ExitCode    int           // process exit code (-1 when killed)
	StderrTail  string        // last bytes of stderr, for timeout diagnostics
	Elapsed     time.Duration // wall clock of the agent run
}

Result is the outcome of one agent run.

Jump to

Keyboard shortcuts

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