shell

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package shell implements the shell tool: bash -c execution with timeout and output truncation. No sandboxing here — slice 1F adds that layer.

non-login non-interactive bash skips ~/.bash_profile and ~/.bashrc to avoid tripping over user rc files that misbehave under sandbox.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() tools.Tool

New returns a shell tool with no approval gating. Use NewWithApprover to enable the dangerous-pattern prompt flow.

func NewWithApprover

func NewWithApprover(app approval.Approver) tools.Tool

NewWithApprover returns a shell tool that consults app before running any command flagged by safety.DetectDangerous. A Deny verdict aborts execution and returns an explanatory IsError result.

func NewWithOptions

func NewWithOptions(app approval.Approver, opts Options) tools.Tool

NewWithOptions wires both approval gating and shell options. nil app = no approval gating.

Types

type Options

type Options struct {
	UseUserRC bool
	Shell     string
	RCFile    string
}

Options configures shell behavior beyond approval gating.

UseUserRC sources the user's interactive rc file (.zshrc / .bashrc) before each command so aliases and shell functions are available. Default false preserves the hermetic shape. Shell and RCFile override autodetection (autodetect = $SHELL → ~/.zshrc or ~/.bashrc).

type Tool

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

Tool is the shell executor.

approver, when non-nil, is consulted whenever safety.DetectDangerous flags the command. nil approver = no gating (legacy behavior). Hardline checks in safety.CheckShellCommand always run regardless of approver.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, input map[string]any) (tools.Result, error)

Run executes the command and returns the result.

func (*Tool) Spec

func (t *Tool) Spec() llm.ToolSpec

Spec advertises the tool to the model.

Jump to

Keyboard shortcuts

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