shell

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shell ties command sources (native host, upstream MCP servers, scripts), the builtins and an engine together into one runnable shell. Both the MCP server and the CLI's `run` go through Shell.Run.

Index

Constants

View Source
const (
	DefaultTimeout   = 120 * time.Second
	DefaultMaxOutput = 64 << 10
)

Variables

This section is empty.

Functions

func FormatSources

func FormatSources(statuses []SourceStatus) string

FormatSources renders a "Sources:" block for listings.

func Warnings

func Warnings(statuses []SourceStatus) []string

Warnings formats the failed sources in statuses.

Types

type Result

type Result struct {
	Stdout    string
	Stderr    string
	ExitCode  int
	Truncated bool
	// Err is set when the script could not run to completion: no source reachable,
	// parse error, timeout. ExitCode is still meaningful (124 for timeouts).
	Err error
	// Warnings report sources that were unavailable while others worked.
	Warnings []string
}

Result is the outcome of one script run.

func (Result) Text

func (r Result) Text() string

Text renders a result for an agent: stdout, then stderr and status only when they carry information.

type Shell

type Shell struct {
	// Sources supply the shell's commands. On a name clash a later source wins over an
	// earlier one, and every source wins over the generic builtins.
	Sources []host.Source
	Engine  engine.Engine
	// Extra are Go-side commands added by the embedding binary. They take precedence
	// over the builtins and every source.
	Extra     []engine.Command
	Timeout   time.Duration // default DefaultTimeout
	MaxOutput int           // per stream, in bytes; default DefaultMaxOutput
}

func (*Shell) Close

func (s *Shell) Close()

Close releases every source that holds resources (upstream subprocesses, sessions).

func (*Shell) Commands

func (s *Shell) Commands(ctx context.Context) (engine.Registry, []SourceStatus, error)

Commands fetches every source's commands and returns the full registry for a run. A failing source only produces a SourceStatus error, unless every source failed.

func (*Shell) Run

func (s *Shell) Run(ctx context.Context, script string, timeout time.Duration) Result

Run runs script with the default timeout, or timeout when it is positive.

type SourceStatus

type SourceStatus struct {
	Label    string
	Commands int
	Err      error
}

SourceStatus is one source's state after fetching commands.

Jump to

Keyboard shortcuts

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