process

package
v0.7.17 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGracefulTimeout = 5 * time.Second

DefaultGracefulTimeout is the default duration to wait for a process to stop gracefully before the lifecycle library forces a SIGKILL.

Variables

This section is empty.

Functions

func LoadTools

func LoadTools(path string) (map[string]ProcessConfig, error)

LoadTools reads a configuration file (YAML or JSON) and returns a map of tool names to configs.

Types

type ConfigFile

type ConfigFile struct {
	Tools []ProcessConfig `yaml:"tools" json:"tools"`
}

ConfigFile represents the structure of tools.yaml

type ProcessConfig

type ProcessConfig struct {
	Name        string            `yaml:"name" json:"name"`
	Command     string            `yaml:"command" json:"command"`
	Args        []string          `yaml:"args" json:"args"`
	Environment map[string]string `yaml:"env" json:"env"`
	Description string            `yaml:"description" json:"description"`
}

ProcessConfig represents the configuration for an external tool execution.

type RegisteredProcess

type RegisteredProcess struct {
	Command string
	Args    []string // Default/Template args
}

RegisteredProcess defines a allowed command execution.

type Runner

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

Runner implements a ToolRunner that executes local processes. It follows a Strict Registry pattern for security (Allow-Listing).

func NewRunner

func NewRunner(opts ...RunnerOption) *Runner

NewRunner creates a new Process Runner.

func (*Runner) Execute

func (r *Runner) Execute(ctx context.Context, toolCall domain.ToolCall) (domain.ToolResult, error)

Execute triggers the execution of a registered or inline process tool.

func (*Runner) Register

func (r *Runner) Register(name string, command string, args ...string)

Register adds a trusted script/command to the allow-list.

type RunnerOption

type RunnerOption func(*Runner)

RunnerOption configures the runner.

func WithBaseDir added in v0.7.3

func WithBaseDir(dir string) RunnerOption

WithBaseDir sets the working directory for executed processes.

func WithGracefulTimeout added in v0.7.13

func WithGracefulTimeout(d time.Duration) RunnerOption

WithGracefulTimeout sets the maximum time to wait for a process to shut down gracefully before forcing termination.

func WithInlineExecution

func WithInlineExecution(allow bool) RunnerOption

WithInlineExecution enables ad-hoc execution (Dangerous).

func WithRegistry

func WithRegistry(tools map[string]ProcessConfig) RunnerOption

WithRegistry populates the allow-list from a loaded config.

Jump to

Keyboard shortcuts

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