tooloutput

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxLines = 2000
	DefaultMaxBytes = 50 * 1024
)

DefaultMaxLines and DefaultMaxBytes match pi coding-agent bash/read truncation.

Variables

View Source
var ErrShellCancelled = errors.New("shell cancelled")

ErrShellCancelled marks a shell command stopped by context cancellation.

Functions

func BashModelResult

func BashModelResult(ctx context.Context, ws workspace.Service, workDir string, out BashStreams, runErr error) (string, error)

BashModelResult formats combined output for the bash tool (pi coding-agent semantics).

func BashToolDescription

func BashToolDescription() string

BashToolDescription matches pi coding-agent / durable bash tool description.

func CombineStdoutStderr

func CombineStdoutStderr(stdout, stderr string) string

CombineStdoutStderr merges process streams in order (stdout then stderr).

func FormatBashModelText

func FormatBashModelText(ctx context.Context, ws workspace.Service, trunc TailTruncation, spillAbs string) string

FormatBashModelText builds model-visible bash output with pi-style truncation hints.

func ResolveRunTimeout

func ResolveRunTimeout(perCall *float64, configSeconds int) (time.Duration, error)

ResolveRunTimeout returns the limit for a command: per-call wins, else configSeconds when > 0.

func SlashCommandText

func SlashCommandText(stdout, stderr string, exitCode int) string

SlashCommandText formats /shell output (combined streams + optional exit suffix).

func ValidateTimeoutSeconds

func ValidateTimeoutSeconds(timeout *float64) error

ValidateTimeoutSeconds checks per-call timeout (pi bash tool).

func WriteBashSpill

func WriteBashSpill(workDir string, full string) (absPath string, err error)

WriteBashSpill persists full command output under workDir (pi-bash-* temp file).

Types

type BashStreams

type BashStreams struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

BashStreams is raw subprocess output before pi-style formatting.

type TailTruncation

type TailTruncation struct {
	Content         string
	Truncated       bool
	TruncatedBy     string // "", "lines", or "bytes"
	TotalLines      int
	TotalBytes      int
	OutputLines     int
	OutputBytes     int
	LastLinePartial bool
	MaxLines        int
	MaxBytes        int
}

TailTruncation describes pi-style tail truncation of combined shell output.

func TruncateTail

func TruncateTail(content string, maxLines, maxBytes int) TailTruncation

TruncateTail keeps the last maxLines/maxBytes of content (pi truncateTail).

type TimeoutError

type TimeoutError struct {
	Seconds float64
}

TimeoutError is returned when a shell command hits its time limit.

func AsTimeoutError

func AsTimeoutError(err error) (*TimeoutError, bool)

AsTimeoutError reports whether err is a TimeoutError.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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