execution

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 16 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 execution runs external processes through structured argv. It never builds or interprets a shell string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentEnv added in v1.37.0

func AgentEnv(env []string) []string

AgentEnv is the environment the agent gets: the given one without what it must not see.

Types

type Claude added in v1.37.0

type Claude struct {
	// Path is the claude executable; empty looks it up on PATH.
	Path string
	// Grace is how long a stopped turn has to end by itself before it is killed; zero means five seconds.
	Grace time.Duration
}

Claude runs turns of the claude command in its non-interactive mode (`claude -p` with stream-json output). It is the same claude as in the terminal: it loads the project's instructions, settings and hooks, so what governs the agent there governs it here.

One thing is not the same, and it is why this adapter checks the hooks twice: with a settings file that is not valid, `claude -p` runs with NO hooks and says nothing (seen with 2.1.333). So a turn is refused before it starts when the project's settings do not parse or declare no hooks, and it is stopped when the session opens without having run the project's SessionStart hook.

It never passes --bare (which skips hooks) nor any flag that bypasses permissions.

func (Claude) Ready added in v1.37.0

func (k Claude) Ready(dir string) error

Ready says why a turn could not be run in dir: the command is not on PATH, or the project's hooks would not run.

func (Claude) Run added in v1.37.0

func (k Claude) Run(ctx context.Context, turn ports.AgentTurn, emit func(ports.AgentEvent)) (string, error)

Run runs one turn. See ports.AgentRunner.

type Runner

type Runner struct {
	// Log receives one debug line per process; nil means no logging.
	Log ports.Logger
}

Runner is the process adapter.

func New

func New() *Runner

New returns a Runner.

func (Runner) LookPath

func (Runner) LookPath(name string) (string, error)

LookPath resolves an executable name on PATH. bash is resolved with the platform rules of lookBash (Git Bash on Windows, never the WSL launcher).

func (Runner) Run

func (r Runner) Run(ctx context.Context, c ports.Command) (ports.Result, error)

Run executes one command. A non-zero exit is reported in the result, not as an error; an error means the process could not be run at all.

func (Runner) Start added in v1.26.0

func (r Runner) Start(c ports.Command) (int, error)

Start launches a process detached from this one and from the terminal (its own session, no stdin, stdout or stderr) and returns its pid without waiting. The child is released: it outlives the caller.

Jump to

Keyboard shortcuts

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