toolformatter

package
v0.266.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HintProvider

type HintProvider interface {
	GetKeyOnly(actionID string) string
}

HintProvider resolves keybinding hints for tool result affordances. It is satisfied by *hints.Formatter.

type ResultBodyProvider

type ResultBodyProvider interface {
	FormatResultBody(result *agentdomain.ToolExecutionResult) string
}

ResultBodyProvider is an optional interface a tool may implement to expose its primary output (command stdout, file content, …) for the collapsed preview and the full-on-failure view. It is distinct from FormatPreview (a one-line summary) and FormatForLLM (the full tree) and lives in the services package so adding it does not touch the agentdomain.Tool interface or its generated mocks.

type ToolFormatterService

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

ToolFormatterService provides formatting for tool results by delegating to individual tools

func NewToolFormatterService

func NewToolFormatterService(registry ToolRegistry, styleProvider *styles.Provider) *ToolFormatterService

NewToolFormatterService creates a new tool formatter service

func (*ToolFormatterService) FormatToolCall

func (s *ToolFormatterService) FormatToolCall(toolName string, args map[string]any) string

FormatToolCall formats a tool call for consistent display

func (*ToolFormatterService) FormatToolResultExpanded

func (s *ToolFormatterService) FormatToolResultExpanded(result *agentdomain.ToolExecutionResult, terminalWidth int) string

FormatToolResultExpanded formats the expanded (ctrl+o) tool result: the tool's existing detail tree, themed for consistency with the rest of the UI (accent+bold tool-call line, dim connectors, accent field labels), with a dim collapse hint. The underlying tree text is unchanged, so tool-specific bodies (diffs, raw output) are preserved exactly.

func (*ToolFormatterService) FormatToolResultForLLM

func (s *ToolFormatterService) FormatToolResultForLLM(result *agentdomain.ToolExecutionResult) string

FormatToolResultForLLM formats tool execution results for LLM consumption

func (*ToolFormatterService) FormatToolResultForUI

func (s *ToolFormatterService) FormatToolResultForUI(result *agentdomain.ToolExecutionResult, terminalWidth int) string

FormatToolResultForUI formats the collapsed (default) tool result: a themed status line followed by an indented dim output preview (first 5 lines on success, the full output on failure) and a "+N lines · ctrl+o to expand" footer.

func (*ToolFormatterService) RenderToolSummary

func (s *ToolFormatterService) RenderToolSummary(icon, toolName string, args map[string]any, trailing string, terminalWidth int) string

RenderToolSummary renders the shared "<icon> Name(args) <trailing>" line of the status line, live preview, approval summary and queue preview, so the name and width-aware argument preview look the same everywhere. icon and trailing are styled by the caller, and "" omits either.

func (*ToolFormatterService) SetHintFormatter

func (s *ToolFormatterService) SetHintFormatter(h HintProvider)

SetHintFormatter wires the keybinding hint resolver so the collapsed and expanded views can show the "ctrl+o to expand/collapse" affordance. Nil is safe - the hint is simply omitted.

func (*ToolFormatterService) SetMaxResultBytes

func (s *ToolFormatterService) SetMaxResultBytes(n int)

SetMaxResultBytes caps the size of a single tool result fed back to the LLM (FormatToolResultForLLM). 0 disables the cap. Wired from tools.max_result_bytes in the container so one oversized tool output can't dominate the context window.

func (*ToolFormatterService) ShouldAlwaysExpandTool

func (s *ToolFormatterService) ShouldAlwaysExpandTool(toolName string) bool

ShouldAlwaysExpandTool checks if a tool result should always be expanded

type ToolRegistry

type ToolRegistry interface {
	GetTool(name string) (agentdomain.Tool, error)
	ListAvailableTools() []string
}

ToolRegistry interface for accessing tools (implemented by tools.Registry)

Jump to

Keyboard shortcuts

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