unix

package
v0.1.8-rc.21 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseEnvKeys = []string{
	"PATH",
	"HOME",
	"USER",
	"TMPDIR",
	"LANG",
	"TERM",
	"SHELL",

	"XDG_CONFIG_HOME",
	"XDG_CACHE_HOME",
	"XDG_DATA_HOME",
	"XDG_RUNTIME_DIR",
}

BaseEnvKeys are always passed through env -i to ensure a functioning Unix environment. These are read-only identifiers and paths — no secrets.

Functions

func NewShellTool

func NewShellTool(executor codeexecutor.CodeExecutor, secrets security.SecretProvider, config ShellToolConfig) tool.Tool

NewShellTool creates a new ShellTool with the given executor, secret provider, and config. Environment filtering is always active — only PATH (plus any keys listed in config.AllowedEnv) is resolved via the SecretProvider and injected into the shell process.

Types

type ShellTool

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

ShellTool is a simplified tool for running shell commands. It wraps a codeexecutor.CodeExecutor but exposes a simpler "command" interface that is friendlier to models than the full codeexec.Tool.

func (*ShellTool) AllowedEnvKeys

func (t *ShellTool) AllowedEnvKeys() []string

AllowedEnvKeys returns the set of allowed env var names (for testing).

func (*ShellTool) Call

func (t *ShellTool) Call(ctx context.Context, input []byte) (any, error)

func (*ShellTool) Declaration

func (t *ShellTool) Declaration() *tool.Declaration

type ShellToolConfig

type ShellToolConfig struct {
	// AllowedEnv controls which environment variables are visible to shell
	// commands. Only listed variables (plus base Unix variables like PATH,
	// HOME, TMPDIR, etc.) are resolved via the SecretProvider and injected.
	// When empty or nil, only the base Unix variables are visible.
	AllowedEnv []string `yaml:"allowed_env" toml:"allowed_env"`

	// Timeout overrides the default 10-minute shell execution timeout.
	// Use Go duration syntax (e.g. "5m", "30s").
	Timeout time.Duration `yaml:"timeout,omitempty" toml:"timeout,omitempty"`
}

ShellToolConfig configures the run_shell tool's security behaviour.

Jump to

Keyboard shortcuts

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