tooloutput

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTools added in v0.7.0

func BuildTools(store *OutputStore) []*agent.Tool

BuildTools creates tools for retrieving stored tool output.

func Compress

func Compress(text string, contentType ContentType, maxTokens int, headRatio, tailRatio float64) string

Compress applies the appropriate compressor based on content type.

func CompressCode

func CompressCode(text string, maxTokens int) string

CompressCode compresses code by extracting signatures/imports, then head/tail of the body.

func CompressHeadTail

func CompressHeadTail(text string, headRatio, tailRatio float64, maxTokens int) string

CompressHeadTail is the generic fallback compressor. Takes headRatio/tailRatio (e.g. 0.7/0.3) and a maxTokens budget. Splits by lines, takes head and tail portions, inserts a separator.

func CompressJSON

func CompressJSON(text string, maxTokens int) string

CompressJSON compresses JSON by extracting schema + sample + count. For arrays: shows first N items + total count. For objects: shows keys + truncated values.

func CompressLog

func CompressLog(text string, maxTokens int) string

CompressLog compresses log output by extracting ERROR/WARN lines, then head/tail of remaining lines, with a summary.

func CompressStackTrace

func CompressStackTrace(text string, maxTokens int) string

CompressStackTrace compresses stack traces by keeping the first goroutine/thread fully, summarizing the rest.

Types

type ContentType

type ContentType string

ContentType represents the detected content type of tool output.

const (
	ContentTypeJSON       ContentType = "json"
	ContentTypeLog        ContentType = "log"
	ContentTypeCode       ContentType = "code"
	ContentTypeStackTrace ContentType = "stacktrace"
	ContentTypeText       ContentType = "text"
)

func DetectContentType

func DetectContentType(text string) ContentType

DetectContentType analyzes text and returns the most likely content type.

type OutputStore

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

OutputStore is an in-memory TTL store for tool output. It implements lifecycle.Component for app lifecycle integration.

func NewOutputStore

func NewOutputStore(ttl time.Duration) *OutputStore

NewOutputStore creates a store with the given TTL for entries.

func (*OutputStore) Get

func (s *OutputStore) Get(ref string) (string, bool)

Get retrieves the full content by reference.

func (*OutputStore) GetRange

func (s *OutputStore) GetRange(ref string, offset, limit int) (string, int, bool)

GetRange retrieves a line range. Returns (lines, totalLines, found).

func (*OutputStore) Grep

func (s *OutputStore) Grep(ref, pattern string) (string, bool)

Grep searches content by regex pattern. Returns (matchingLines, found).

func (*OutputStore) Name

func (s *OutputStore) Name() string

Name implements lifecycle.Component.

func (*OutputStore) Start

func (s *OutputStore) Start(_ context.Context, wg *sync.WaitGroup) error

Start implements lifecycle.Component. Starts the cleanup goroutine.

func (*OutputStore) Stop

func (s *OutputStore) Stop(_ context.Context) error

Stop implements lifecycle.Component. Stops the cleanup goroutine.

func (*OutputStore) Store

func (s *OutputStore) Store(toolName, content string) string

Store saves content and returns a UUID reference.

Jump to

Keyboard shortcuts

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