agentproc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 12 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 agentproc starts and stops ACP agent processes.

Index

Constants

View Source
const StderrTail = 8 << 10

StderrTail is how much of an agent's stderr is kept for error messages.

Variables

This section is empty.

Functions

func AppendPath added in v0.1.1

func AppendPath(env []string, dirs ...string) []string

AppendPath adds folders to the end of PATH in env, skipping ones already there.

func BuildEnv

func BuildEnv(base []string, add map[string]string, remove []string) []string

BuildEnv applies removals and additions to a base environment.

func CachedLoginShellEnv

func CachedLoginShellEnv() []string

CachedLoginShellEnv is LoginShellEnv, read once per process.

func Getenv

func Getenv(env []string, key string) string

Getenv reads a variable from an environment list.

func KillGroupByPID

func KillGroupByPID(pid int)

KillGroupByPID stops a leftover process group from an earlier run. Agents lead their own group, so a reused pid that leads no group is left alone.

func LoginShellEnv

func LoginShellEnv(ctx context.Context) []string

LoginShellEnv returns the environment of the user's login shell, which has the PATH agents usually need. Apps started from a desktop or a service manager get a minimal PATH otherwise. Falls back to os.Environ().

func LookPath

func LookPath(command string, env []string) (string, error)

LookPath finds a command using the PATH of the given environment, not of actp itself.

Types

type Process

type Process struct {
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
	// contains filtered or unexported fields
}

Process is a running agent.

func Start

func Start(spec Spec) (*Process, error)

Start launches the agent in its own process group.

func (*Process) Done

func (p *Process) Done() <-chan struct{}

Done is closed when the process has exited.

func (*Process) ExitCode

func (p *Process) ExitCode() int

ExitCode is the exit code, or -1 while running or when killed by a signal.

func (*Process) PID

func (p *Process) PID() int

PID is the agent's process id.

func (*Process) Stderr

func (p *Process) Stderr() string

Stderr returns the last bytes the agent wrote to stderr.

func (*Process) Stop

func (p *Process) Stop(grace time.Duration)

Stop closes stdin, asks the process group to stop, and kills it after grace.

type Spec

type Spec struct {
	Command   string
	Args      []string
	Dir       string
	BaseEnv   []string // nil means os.Environ()
	Env       map[string]string
	EnvRemove []string
}

Spec describes how to start an agent.

Jump to

Keyboard shortcuts

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