Documentation
¶
Index ¶
- func BaseStyle() lipgloss.Style
- func CreateBadge(text string, color lipgloss.AdaptiveColor) string
- func CreateGradientText(text string, startColor, endColor lipgloss.AdaptiveColor) string
- func CreateProgressBar(width int, percentage float64, theme Theme) string
- func CreateSeparator(width int, char string, color lipgloss.AdaptiveColor) string
- func EstimateTokens(text string) int
- func GetMarkdownRenderer(width int) *glamour.TermRenderer
- func SetTheme(theme Theme)
- func StyleCard(width int, theme Theme) lipgloss.Style
- func StyleError(theme Theme) lipgloss.Style
- func StyleHeader(theme Theme) lipgloss.Style
- func StyleInfo(theme Theme) lipgloss.Style
- func StyleMuted(theme Theme) lipgloss.Style
- func StyleSubheader(theme Theme) lipgloss.Style
- func StyleSuccess(theme Theme) lipgloss.Style
- func StyleWarning(theme Theme) lipgloss.Style
- func WithAlign(align lipgloss.Position) renderingOption
- func WithBorderColor(color lipgloss.AdaptiveColor) renderingOption
- func WithFullWidth() renderingOption
- func WithMarginBottom(margin int) renderingOption
- func WithMarginTop(margin int) renderingOption
- func WithPaddingBottom(padding int) renderingOption
- func WithPaddingLeft(padding int) renderingOption
- func WithPaddingRight(padding int) renderingOption
- func WithPaddingTop(padding int) renderingOption
- func WithWidth(width int) renderingOption
- 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) 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) SlashCommandResult
- 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) StartStreamingMessage(modelName string)
- func (c *CLI) UpdateStreamingMessage(content string)
- 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 SlashCommandResult
- type Spinner
- type Theme
- 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 CreateBadge ¶ added in v0.17.0
func CreateBadge(text string, color lipgloss.AdaptiveColor) string
CreateBadge creates a styled badge
func CreateGradientText ¶ added in v0.17.0
func CreateGradientText(text string, startColor, endColor lipgloss.AdaptiveColor) string
CreateGradientText creates text with gradient-like effect using different shades
func CreateProgressBar ¶ added in v0.17.0
CreateProgressBar creates a simple progress bar
func CreateSeparator ¶ added in v0.17.0
func CreateSeparator(width int, char string, color lipgloss.AdaptiveColor) string
CreateSeparator creates a styled separator line
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
func StyleError ¶ added in v0.17.0
StyleError creates error text styling
func StyleHeader ¶ added in v0.17.0
StyleHeader creates a styled header
func StyleMuted ¶ added in v0.17.0
StyleMuted creates muted text styling
func StyleSubheader ¶ added in v0.17.0
StyleSubheader creates a styled subheader
func StyleSuccess ¶ added in v0.17.0
StyleSuccess creates success text styling
func StyleWarning ¶ added in v0.17.0
StyleWarning creates warning text styling
func WithBorderColor ¶ added in v0.17.0
func WithBorderColor(color lipgloss.AdaptiveColor) renderingOption
WithBorderColor sets the border color
func WithFullWidth ¶ added in v0.17.0
func WithFullWidth() renderingOption
WithFullWidth makes the block take full available width
func WithMarginBottom ¶ added in v0.17.0
func WithMarginBottom(margin int) renderingOption
WithMarginBottom sets the bottom margin
func WithMarginTop ¶ added in v0.17.0
func WithMarginTop(margin int) renderingOption
WithMarginTop sets the top margin
func WithPaddingBottom ¶ added in v0.17.0
func WithPaddingBottom(padding int) renderingOption
WithPaddingBottom sets the bottom padding
func WithPaddingLeft ¶ added in v0.17.0
func WithPaddingLeft(padding int) renderingOption
WithPaddingLeft sets the left padding
func WithPaddingRight ¶ added in v0.17.0
func WithPaddingRight(padding int) renderingOption
WithPaddingRight sets the right padding
func WithPaddingTop ¶ added in v0.17.0
func WithPaddingTop(padding int) renderingOption
WithPaddingTop sets the top padding
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) 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) SlashCommandResult
HandleSlashCommand handles slash commands and returns the result
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) StartStreamingMessage ¶ added in v0.18.0
StartStreamingMessage starts a streaming assistant message
func (*CLI) UpdateStreamingMessage ¶ added in v0.18.0
UpdateStreamingMessage updates the streaming message with new content
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
func (*MessageContainer) UpdateLastMessage ¶ added in v0.18.0
func (c *MessageContainer) UpdateLastMessage(content string)
UpdateLastMessage updates the content of the last message efficiently
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 left border and background header
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 left border and background header
func (*MessageRenderer) RenderSystemMessage ¶
func (r *MessageRenderer) RenderSystemMessage(content string, timestamp time.Time) UIMessage
RenderSystemMessage renders a system message with left border and background header
func (*MessageRenderer) RenderToolCallMessage ¶
func (r *MessageRenderer) RenderToolCallMessage(toolName, toolArgs string, timestamp time.Time) UIMessage
RenderToolCallMessage renders a tool call in progress with left border and background header
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 right border and background header
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 SlashCommandResult ¶ added in v0.17.0
SlashCommandResult represents the result of handling a slash command
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 enhanced styling
func NewThemedSpinner ¶
func NewThemedSpinner(message string, color lipgloss.AdaptiveColor) *Spinner
NewThemedSpinner creates a new spinner with the given message and color
type Theme ¶ added in v0.17.0
type Theme struct {
Primary lipgloss.AdaptiveColor
Secondary lipgloss.AdaptiveColor
Success lipgloss.AdaptiveColor
Warning lipgloss.AdaptiveColor
Error lipgloss.AdaptiveColor
Info lipgloss.AdaptiveColor
Text lipgloss.AdaptiveColor
Muted lipgloss.AdaptiveColor
VeryMuted lipgloss.AdaptiveColor
Background lipgloss.AdaptiveColor
Border lipgloss.AdaptiveColor
MutedBorder lipgloss.AdaptiveColor
System lipgloss.AdaptiveColor
Tool lipgloss.AdaptiveColor
Accent lipgloss.AdaptiveColor
Highlight lipgloss.AdaptiveColor
}
Theme represents a complete UI theme
func DefaultTheme ¶ added in v0.17.0
func DefaultTheme() Theme
DefaultTheme returns the default MCPHost theme (Catppuccin Mocha)
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, isOAuth bool) *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 enhanced usage information with better styling
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