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 ¶
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 ¶
ParseArgs unmarshals JSON arguments into a typed struct. Returns an error if parsing fails.
func RenderTool ¶
func ShortenPath ¶
ShortenPath replaces home directory with ~ for cleaner display.
func TruncateText ¶
TruncateText truncates text to fit within maxWidth, adding an ellipsis if needed. Uses lipgloss.Width for proper Unicode handling.
Types ¶
type Base ¶
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 ¶
func (b *Base) SessionState() *service.SessionState
SessionState returns the session state.
type Renderer ¶
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 ¶
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.).