Documentation
¶
Index ¶
- func BaseStyle() lipgloss.Style
- func EstimateTokens(text string) int
- func GetMarkdownRenderer(width int) *glamour.TermRenderer
- type CLI
- func (c *CLI) ClearMessages()
- func (c *CLI) CreateCallbackHandler() callbacks.Handler
- func (c *CLI) DisplayAssistantMessage(message string) error
- func (c *CLI) DisplayAssistantMessageWithModel(message, modelName string) error
- func (c *CLI) DisplayCancellation()
- func (c *CLI) DisplayDebugConfig(config map[string]any)
- func (c *CLI) DisplayError(err error)
- func (c *CLI) DisplayHelp()
- func (c *CLI) DisplayHistory(messages []*schema.Message)
- func (c *CLI) DisplayInfo(message string)
- func (c *CLI) DisplayServers(servers []string)
- func (c *CLI) DisplayStreamingMessage(reader *schema.StreamReader[*schema.Message]) error
- func (c *CLI) DisplayToolCallMessage(toolName, toolArgs string)
- func (c *CLI) DisplayToolMessage(toolName, toolArgs, toolResult string, isError bool)
- func (c *CLI) DisplayTools(tools []string)
- func (c *CLI) DisplayUsageStats()
- func (c *CLI) DisplayUserMessage(message string)
- func (c *CLI) GetPrompt() (string, error)
- func (c *CLI) HandleSlashCommand(input string, servers []string, tools []string, history []*schema.Message) bool
- func (c *CLI) IsSlashCommand(input string) bool
- func (c *CLI) ResetUsageStats()
- func (c *CLI) SetUsageTracker(tracker *UsageTracker)
- func (c *CLI) ShowSpinner(message string, action func() error) error
- func (c *CLI) UpdateUsage(inputText, outputText string)
- func (c *CLI) UpdateUsageFromResponse(response *schema.Message, inputText string)
- type MessageContainer
- type MessageRenderer
- func (r *MessageRenderer) RenderAssistantMessage(content string, timestamp time.Time, modelName string) UIMessage
- func (r *MessageRenderer) RenderDebugConfigMessage(config map[string]any, timestamp time.Time) UIMessage
- func (r *MessageRenderer) RenderErrorMessage(errorMsg string, timestamp time.Time) UIMessage
- func (r *MessageRenderer) RenderSystemMessage(content string, timestamp time.Time) UIMessage
- func (r *MessageRenderer) RenderToolCallMessage(toolName, toolArgs string, timestamp time.Time) UIMessage
- func (r *MessageRenderer) RenderToolMessage(toolName, toolArgs, toolResult string, isError bool) UIMessage
- func (r *MessageRenderer) RenderUserMessage(content string, timestamp time.Time) UIMessage
- func (r *MessageRenderer) SetWidth(width int)
- type MessageType
- type SessionStats
- type Spinner
- type UIMessage
- type UsageStats
- type UsageTracker
- func (ut *UsageTracker) EstimateAndUpdateUsage(inputText, outputText string)
- func (ut *UsageTracker) EstimateAndUpdateUsageFromText(inputText, outputText string)
- func (ut *UsageTracker) GetLastRequestStats() *UsageStats
- func (ut *UsageTracker) GetSessionStats() SessionStats
- func (ut *UsageTracker) RenderUsageInfo() string
- func (ut *UsageTracker) Reset()
- func (ut *UsageTracker) SetWidth(width int)
- func (ut *UsageTracker) UpdateUsage(inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶ added in v0.14.0
EstimateTokens provides a rough estimate of tokens in text This is a simple approximation - real token counting would require the actual tokenizer
func GetMarkdownRenderer ¶
func GetMarkdownRenderer(width int) *glamour.TermRenderer
GetMarkdownRenderer returns a glamour TermRenderer configured for our use
Types ¶
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI handles the command line interface with improved message rendering
func (*CLI) ClearMessages ¶
func (c *CLI) ClearMessages()
ClearMessages clears all messages from the container
func (*CLI) CreateCallbackHandler ¶
CreateCallbackHandler creates a callback handler using HandlerHelper
func (*CLI) DisplayAssistantMessage ¶
DisplayAssistantMessage displays the assistant's message using the new renderer
func (*CLI) DisplayAssistantMessageWithModel ¶
DisplayAssistantMessageWithModel displays the assistant's message with model info
func (*CLI) DisplayCancellation ¶ added in v0.14.0
func (c *CLI) DisplayCancellation()
DisplayCancellation displays a cancellation message
func (*CLI) DisplayDebugConfig ¶ added in v0.12.0
DisplayDebugConfig displays configuration settings in debug mode using tool response block styling
func (*CLI) DisplayError ¶
DisplayError displays an error message using the message component
func (*CLI) DisplayHelp ¶
func (c *CLI) DisplayHelp()
DisplayHelp displays help information in a message block
func (*CLI) DisplayHistory ¶
DisplayHistory displays conversation history using the message container
func (*CLI) DisplayInfo ¶
DisplayInfo displays an informational message using the system message component
func (*CLI) DisplayServers ¶
DisplayServers displays configured MCP servers in a message block
func (*CLI) DisplayStreamingMessage ¶
DisplayStreamingMessage displays streaming content
func (*CLI) DisplayToolCallMessage ¶
DisplayToolCallMessage displays a tool call in progress
func (*CLI) DisplayToolMessage ¶
DisplayToolMessage displays a tool call message
func (*CLI) DisplayTools ¶
DisplayTools displays available tools in a message block
func (*CLI) DisplayUsageStats ¶ added in v0.14.0
func (c *CLI) DisplayUsageStats()
DisplayUsageStats displays current usage statistics
func (*CLI) DisplayUserMessage ¶
DisplayUserMessage displays the user's message using the new renderer
func (*CLI) HandleSlashCommand ¶
func (c *CLI) HandleSlashCommand(input string, servers []string, tools []string, history []*schema.Message) bool
HandleSlashCommand handles slash commands and returns true if handled
func (*CLI) IsSlashCommand ¶
IsSlashCommand checks if the input is a slash command
func (*CLI) ResetUsageStats ¶ added in v0.14.0
func (c *CLI) ResetUsageStats()
ResetUsageStats resets the usage tracking statistics
func (*CLI) SetUsageTracker ¶ added in v0.14.0
func (c *CLI) SetUsageTracker(tracker *UsageTracker)
SetUsageTracker sets the usage tracker for the CLI
func (*CLI) ShowSpinner ¶
ShowSpinner displays a spinner with the given message and executes the action
func (*CLI) UpdateUsage ¶ added in v0.14.0
UpdateUsage updates the usage tracker with token counts and costs
type MessageContainer ¶
type MessageContainer struct {
// contains filtered or unexported fields
}
MessageContainer wraps multiple messages in a container
func NewMessageContainer ¶
func NewMessageContainer(width, height int) *MessageContainer
NewMessageContainer creates a new message container
func (*MessageContainer) AddMessage ¶
func (c *MessageContainer) AddMessage(msg UIMessage)
AddMessage adds a message to the container
func (*MessageContainer) Clear ¶
func (c *MessageContainer) Clear()
Clear clears all messages from the container
func (*MessageContainer) Render ¶
func (c *MessageContainer) Render() string
Render renders all messages in the container
func (*MessageContainer) SetSize ¶
func (c *MessageContainer) SetSize(width, height int)
SetSize updates the container size
type MessageRenderer ¶
type MessageRenderer struct {
// contains filtered or unexported fields
}
MessageRenderer handles rendering of messages with proper styling
func NewMessageRenderer ¶
func NewMessageRenderer(width int, debug bool) *MessageRenderer
NewMessageRenderer creates a new message renderer
func (*MessageRenderer) RenderAssistantMessage ¶
func (r *MessageRenderer) RenderAssistantMessage(content string, timestamp time.Time, modelName string) UIMessage
RenderAssistantMessage renders an assistant message with proper styling
func (*MessageRenderer) RenderDebugConfigMessage ¶ added in v0.12.0
func (r *MessageRenderer) RenderDebugConfigMessage(config map[string]any, timestamp time.Time) UIMessage
RenderDebugConfigMessage renders debug configuration settings with tool response block styling
func (*MessageRenderer) RenderErrorMessage ¶
func (r *MessageRenderer) RenderErrorMessage(errorMsg string, timestamp time.Time) UIMessage
RenderErrorMessage renders an error message with proper styling
func (*MessageRenderer) RenderSystemMessage ¶
func (r *MessageRenderer) RenderSystemMessage(content string, timestamp time.Time) UIMessage
RenderSystemMessage renders a system message (help, tools, etc.) with proper styling
func (*MessageRenderer) RenderToolCallMessage ¶
func (r *MessageRenderer) RenderToolCallMessage(toolName, toolArgs string, timestamp time.Time) UIMessage
RenderToolCallMessage renders a tool call in progress with proper styling
func (*MessageRenderer) RenderToolMessage ¶
func (r *MessageRenderer) RenderToolMessage(toolName, toolArgs, toolResult string, isError bool) UIMessage
RenderToolMessage renders a tool call message with proper styling
func (*MessageRenderer) RenderUserMessage ¶
func (r *MessageRenderer) RenderUserMessage(content string, timestamp time.Time) UIMessage
RenderUserMessage renders a user message with proper styling
func (*MessageRenderer) SetWidth ¶
func (r *MessageRenderer) SetWidth(width int)
SetWidth updates the renderer width
type MessageType ¶
type MessageType int
MessageType represents the type of message
const ( UserMessage MessageType = iota AssistantMessage ToolMessage ToolCallMessage // New type for showing tool calls in progress SystemMessage // New type for MCPHost system messages (help, tools, etc.) ErrorMessage // New type for error messages )
type SessionStats ¶ added in v0.14.0
type SessionStats struct {
TotalInputTokens int
TotalOutputTokens int
TotalCacheReadTokens int
TotalCacheWriteTokens int
TotalCost float64
RequestCount int
}
SessionStats represents cumulative stats for the entire session
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner wraps the bubbles spinner for both interactive and non-interactive mode
func NewSpinner ¶
NewSpinner creates a new spinner with the given message
func NewThemedSpinner ¶
func NewThemedSpinner(message string, color lipgloss.AdaptiveColor) *Spinner
NewThemedSpinner creates a new spinner with the given message and color
type UIMessage ¶
type UIMessage struct {
ID string
Type MessageType
Position int
Height int
Content string
Timestamp time.Time
}
UIMessage represents a rendered message for display
type UsageStats ¶ added in v0.14.0
type UsageStats struct {
InputTokens int
OutputTokens int
CacheReadTokens int
CacheWriteTokens int
InputCost float64
OutputCost float64
CacheReadCost float64
CacheWriteCost float64
TotalCost float64
}
UsageStats represents token and cost information for a single request/response
type UsageTracker ¶ added in v0.14.0
type UsageTracker struct {
// contains filtered or unexported fields
}
UsageTracker tracks token usage and costs for LLM interactions
func NewUsageTracker ¶ added in v0.14.0
func NewUsageTracker(modelInfo *models.ModelInfo, provider string, width int) *UsageTracker
NewUsageTracker creates a new usage tracker for the given model
func (*UsageTracker) EstimateAndUpdateUsage ¶ added in v0.14.0
func (ut *UsageTracker) EstimateAndUpdateUsage(inputText, outputText string)
EstimateAndUpdateUsage estimates tokens from text and updates usage
func (*UsageTracker) EstimateAndUpdateUsageFromText ¶ added in v0.14.0
func (ut *UsageTracker) EstimateAndUpdateUsageFromText(inputText, outputText string)
EstimateAndUpdateUsageFromText estimates tokens from text and updates usage
func (*UsageTracker) GetLastRequestStats ¶ added in v0.14.0
func (ut *UsageTracker) GetLastRequestStats() *UsageStats
GetLastRequestStats returns a copy of the last request statistics
func (*UsageTracker) GetSessionStats ¶ added in v0.14.0
func (ut *UsageTracker) GetSessionStats() SessionStats
GetSessionStats returns a copy of the current session statistics
func (*UsageTracker) RenderUsageInfo ¶ added in v0.14.0
func (ut *UsageTracker) RenderUsageInfo() string
RenderUsageInfo renders the current usage information in a single line format
func (*UsageTracker) Reset ¶ added in v0.14.0
func (ut *UsageTracker) Reset()
Reset clears all usage statistics
func (*UsageTracker) SetWidth ¶ added in v0.14.0
func (ut *UsageTracker) SetWidth(width int)
SetWidth updates the display width for rendering
func (*UsageTracker) UpdateUsage ¶ added in v0.14.0
func (ut *UsageTracker) UpdateUsage(inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens int)
UpdateUsage updates the tracker with new usage information