exec

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 9 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 StderrCap = 64 << 10

StderrCap bounds captured stderr. Only its tail is kept: the CLIs write a verbose progress trace there and the error that matters comes last. It is independent of MaxOutputBytes, which callers set to 0 when stdout is a structured stream that must be parsed whole.

View Source
const StdoutHardCap = 32 << 20

StdoutHardCap bounds stdout when the caller sets no MaxOutputBytes (the structured JSON/JSONL streams that are parsed whole). Exceeding it sets StdoutTruncated, which those callers treat as an error.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Command string
	Args    []string
	Dir     string
	Stdin   string
	Timeout time.Duration
	// MaxOutputBytes caps captured stdout (the head is kept); 0 means "no
	// caller cap", which still stops at StdoutHardCap so a runaway CLI cannot
	// exhaust memory. Stderr is capped separately: see StderrCap.
	MaxOutputBytes int
	// StreamTo, if non-nil, means stdout and stderr are also written here live,
	// in addition to being captured in the Result.
	StreamTo io.Writer
	// Env holds extra KEY=VALUE entries appended to the inherited environment
	// (later entries win), e.g. to neutralise a tool's config lookups.
	Env []string
}

type Result

type Result struct {
	Stdout string
	Stderr string
	// ExitCode is the process exit code; it is -1 when TimedOut is true.
	ExitCode int
	Elapsed  time.Duration
	TimedOut bool
	// StdoutTruncated reports that stdout exceeded MaxOutputBytes and was cut.
	StdoutTruncated bool
	// StderrTruncated reports that stderr exceeded StderrCap; Stderr then
	// holds only its last StderrCap bytes.
	StderrTruncated bool
}

func Run

func Run(ctx context.Context, req Request) (Result, error)

type Runner

type Runner struct{}

Runner adapts the package-level Run into a value that satisfies codex.Runner.

func (Runner) Run

func (Runner) Run(ctx context.Context, req Request) (Result, error)

Jump to

Keyboard shortcuts

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