present

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package present provides bounded list and field preview helpers for tool payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapSlice

func CapSlice[T any](items []T, limit int) ([]T, summarize.Meta)

CapSlice caps a slice without list metadata wrapping.

func MapCapList

func MapCapList[T, V any](items []T, limit int, mapFn func(*T) V) ([]V, summarize.Meta)

MapCapList caps items and maps each element into a presentation view.

func PreviewField

func PreviewField(text string, limit int) (preview string, truncated bool)

PreviewField returns a bounded text preview.

func SummarizeToolList

func SummarizeToolList[T any](data any, meta summarize.Meta, spec summarize.ToolListSummary[T]) (summary string, next []string)

SummarizeToolList builds envelope summary and next hints from tool result list data.

func ToolListItems

func ToolListItems[T any](data any) ([]T, bool)

ToolListItems returns typed items from tool result data (structured list or bare slice).

func ToolListTotal

func ToolListTotal(data any) (int, bool)

ToolListTotal returns the item total for tool result list data.

Types

type TextPreview

type TextPreview struct {
	Preview   string
	Truncated bool
}

TextPreview holds a bounded text preview for tool result data.

func RedactText

func RedactText(text string, limit int) (preview TextPreview, cleared string)

RedactText returns a preview and the text to expose in tool result data. When truncated, cleared is empty so callers can omit the full field from payloads.

type ToolListData

type ToolListData struct {
	Items     any    `json:"items"`
	Count     int    `json:"count"`
	Total     int    `json:"total,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
	Hint      string `json:"hint,omitempty"`
}

ToolListData is the structured list payload placed in tool result data.

func List

func List[T any](items []T, limit int, hintTemplate string) (ToolListData, summarize.Meta)

List wraps items for tool result data. Prefer WrapToolList for new code.

func WrapToolList

func WrapToolList[T any](items []T, limit int, hintTemplate string) (ToolListData, summarize.Meta)

WrapToolList caps items and attaches list metadata for tool result data.

Jump to

Keyboard shortcuts

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