exec

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundProcess

type BackgroundProcess struct {
	ID        string
	Command   string
	Cmd       *exec.Cmd
	Output    *syncBuffer
	StartTime time.Time
	Done      bool
	ExitCode  int
	Error     string
}

BackgroundProcess represents a running background command

type Config

type Config struct {
	DefaultTimeout  time.Duration
	AllowBackground bool
	WorkDir         string
	EnvFilter       []string           // environment variables to exclude
	EnvWhitelist    []string           // if set, ONLY these vars are allowed
	Refs            *security.RefStore // secret reference token resolver
}

Config holds exec tool configuration

type Result

type Result struct {
	ExitCode int    `json:"exitCode"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	TimedOut bool   `json:"timedOut,omitempty"`
}

Result represents command execution result

type Tool

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

Tool provides shell command execution

func New

func New(cfg Config) *Tool

New creates a new exec tool

func (*Tool) Cleanup

func (t *Tool) Cleanup()

Cleanup terminates all background processes

func (*Tool) GetBackgroundStatus

func (t *Tool) GetBackgroundStatus(id string) (*BackgroundProcess, error)

GetBackgroundStatus returns the status of a background process

func (*Tool) ListBackground

func (t *Tool) ListBackground() []*BackgroundProcess

ListBackground returns all background processes

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, command string, timeout time.Duration) (*Result, error)

Run executes a command synchronously

func (*Tool) RunWithPTY

func (t *Tool) RunWithPTY(ctx context.Context, command string, timeout time.Duration) (*Result, error)

RunWithPTY executes a command with PTY support

func (*Tool) StartBackground

func (t *Tool) StartBackground(command string) (string, error)

StartBackground starts a command in the background

func (*Tool) StopBackground

func (t *Tool) StopBackground(id string) error

StopBackground stops a background process

Jump to

Keyboard shortcuts

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