Documentation
¶
Index ¶
- func BuildTools(store *OutputStore) []*agent.Tool
- func Compress(text string, contentType ContentType, maxTokens int, ...) string
- func CompressCode(text string, maxTokens int) string
- func CompressHeadTail(text string, headRatio, tailRatio float64, maxTokens int) string
- func CompressJSON(text string, maxTokens int) string
- func CompressLog(text string, maxTokens int) string
- func CompressStackTrace(text string, maxTokens int) string
- type ContentType
- type OutputStore
- func (s *OutputStore) Get(ref string) (string, bool)
- func (s *OutputStore) GetRange(ref string, offset, limit int) (string, int, bool)
- func (s *OutputStore) Grep(ref, pattern string) (string, bool)
- func (s *OutputStore) Name() string
- func (s *OutputStore) Start(_ context.Context, wg *sync.WaitGroup) error
- func (s *OutputStore) Stop(_ context.Context) error
- func (s *OutputStore) Store(toolName, content string) string
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 ¶
CompressCode compresses code by extracting signatures/imports, then head/tail of the body.
func CompressHeadTail ¶
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 ¶
CompressJSON compresses JSON by extracting schema + sample + count. For arrays: shows first N items + total count. For objects: shows keys + truncated values.
func CompressLog ¶
CompressLog compresses log output by extracting ERROR/WARN lines, then head/tail of remaining lines, with a summary.
func CompressStackTrace ¶
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) Grep ¶
func (s *OutputStore) Grep(ref, pattern string) (string, bool)
Grep searches content by regex pattern. Returns (matchingLines, found).
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.