bash

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package bash provides shell command execution using mvdan/sh interpreter.

Index

Constants

View Source
const DefaultTimeout = 15 * time.Second

DefaultTimeout is the default command timeout.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inputs

type Inputs struct {
	Command   string `json:"command"              jsonschema:"required,description=Shell command or script to execute"      validate:"required"`
	Workdir   string `json:"workdir,omitempty"    jsonschema:"description=Working directory to execute command in"`
	TimeoutMS int64  `json:"timeout_ms,omitempty" jsonschema:"description=Command timeout in milliseconds (default: 15000)"`
}

Inputs defines the parameters for the Bash tool.

type LimitedBuffer

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

LimitedBuffer is an io.Writer that wraps bytes.Buffer with a byte-level cap. When max <= 0, writes pass through without capping. When the cap is reached, excess bytes are silently discarded.

func (*LimitedBuffer) Capped

func (lb *LimitedBuffer) Capped() bool

func (*LimitedBuffer) Len

func (lb *LimitedBuffer) Len() int

func (*LimitedBuffer) String

func (lb *LimitedBuffer) String() string

func (*LimitedBuffer) Write

func (lb *LimitedBuffer) Write(p []byte) (int, error)

type StreamingWriter

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

StreamingWriter wraps a LimitedBuffer and calls a callback with each complete line of output, throttled to avoid flooding the UI event channel. Thread-safe: shell pipelines may write from multiple goroutines.

func NewStreamingWriter

func NewStreamingWriter(buf *LimitedBuffer, callback func(line string)) *StreamingWriter

NewStreamingWriter creates a writer that tees to buf and streams lines via callback.

func (*StreamingWriter) Flush

func (sw *StreamingWriter) Flush()

Flush emits any remaining partial line (content without a trailing newline). Call after the command finishes to ensure the last line is not lost.

func (*StreamingWriter) Write

func (sw *StreamingWriter) Write(p []byte) (int, error)

Write implements io.Writer. It always writes to the underlying LimitedBuffer, then splits on newlines and calls the callback for complete lines (throttled).

type Tool

type Tool struct {
	tool.Base

	Timeout    time.Duration
	Truncation config.BashTruncation
	Rewrite    string
	// contains filtered or unexported fields
}

Tool implements the Bash command execution tool using mvdan/sh interpreter.

func New

func New(truncation config.BashTruncation, rewrite string) *Tool

New creates a new Bash tool with documentation.

func (*Tool) Close

func (t *Tool) Close()

Close removes any temp files created during truncated output.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, args map[string]any) (string, error)

Execute runs the bash command using mvdan/sh interpreter.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool's identifier.

func (*Tool) Schema

func (t *Tool) Schema() tool.Schema

Schema returns the provider-agnostic tool definition.

Jump to

Keyboard shortcuts

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