Documentation
¶
Index ¶
- func ExtractField[T any](field func(T) string) func(string) string
- func FormatToolResult(content string, width int) string
- func Icon(msg *types.Message, inProgress spinner.Spinner) string
- func ParseArgs[T any](args string) (T, error)
- func RenderTool(msg *types.Message, inProgress spinner.Spinner, args, result string, width int, ...) string
- func ShortenPath(path string) string
- func TruncateText(text string, maxWidth int) string
- type Base
- func (b *Base) Height() int
- func (b *Base) Init() tea.Cmd
- func (b *Base) Message() *types.Message
- func (b *Base) SessionState() *service.SessionState
- func (b *Base) SetSize(width, height int) tea.Cmd
- func (b *Base) Spinner() spinner.Spinner
- func (b *Base) Update(msg tea.Msg) (layout.Model, tea.Cmd)
- func (b *Base) View() string
- func (b *Base) Width() int
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractField ¶ added in v1.16.0
ExtractField creates an argument extractor function that parses JSON and extracts a field. The field function receives the parsed args and returns the display string.
func FormatToolResult ¶
func ParseArgs ¶ added in v1.16.0
ParseArgs unmarshals JSON arguments into a typed struct. Returns an error if parsing fails.
func RenderTool ¶ added in v1.9.22
func ShortenPath ¶ added in v1.16.0
ShortenPath replaces home directory with ~ for cleaner display.
func TruncateText ¶ added in v1.16.0
TruncateText truncates text to fit within maxWidth, adding an ellipsis if needed. Uses lipgloss.Width for proper Unicode handling.
Types ¶
type Base ¶ added in v1.16.0
type Base struct {
// contains filtered or unexported fields
}
Base provides common boilerplate for tool components. It handles spinner management, sizing, and delegates rendering to a custom function.
func (*Base) SessionState ¶ added in v1.16.0
func (b *Base) SessionState() *service.SessionState
SessionState returns the session state.
type Renderer ¶ added in v1.16.0
type Renderer func(msg *types.Message, s spinner.Spinner, sessionState *service.SessionState, width, height int) string
Renderer is a function that renders a tool call view. It receives the message, spinner, session state, and available width/height.
func SimpleRenderer ¶ added in v1.16.0
SimpleRenderer creates a renderer that extracts a single string argument and renders it with RenderTool. This covers the most common case where tools just display one argument (like path, command, etc.).
func SimpleRendererWithResult ¶ added in v1.16.0
func SimpleRendererWithResult( extractArg func(args string) string, extractResult func(msg *types.Message) string, ) Renderer
SimpleRendererWithResult creates a renderer that extracts a single string argument and also shows a result/summary after completion.