ui

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseStyle

func BaseStyle() lipgloss.Style

BaseStyle returns a basic lipgloss style

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 NewCLI

func NewCLI(debug bool) (*CLI, error)

NewCLI creates a new CLI instance with message container

func (*CLI) ClearMessages

func (c *CLI) ClearMessages()

ClearMessages clears all messages from the container

func (*CLI) CreateCallbackHandler

func (c *CLI) CreateCallbackHandler() callbacks.Handler

CreateCallbackHandler creates a callback handler using HandlerHelper

func (*CLI) DisplayAssistantMessage

func (c *CLI) DisplayAssistantMessage(message string) error

DisplayAssistantMessage displays the assistant's message using the new renderer

func (*CLI) DisplayAssistantMessageWithModel

func (c *CLI) DisplayAssistantMessageWithModel(message, modelName string) error

DisplayAssistantMessageWithModel displays the assistant's message with model info

func (*CLI) DisplayDebugConfig added in v0.12.0

func (c *CLI) DisplayDebugConfig(config map[string]any)

DisplayDebugConfig displays configuration settings in debug mode using tool response block styling

func (*CLI) DisplayError

func (c *CLI) DisplayError(err error)

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

func (c *CLI) DisplayHistory(messages []*schema.Message)

DisplayHistory displays conversation history using the message container

func (*CLI) DisplayInfo

func (c *CLI) DisplayInfo(message string)

DisplayInfo displays an informational message using the system message component

func (*CLI) DisplayServers

func (c *CLI) DisplayServers(servers []string)

DisplayServers displays configured MCP servers in a message block

func (*CLI) DisplayStreamingMessage

func (c *CLI) DisplayStreamingMessage(reader *schema.StreamReader[*schema.Message]) error

DisplayStreamingMessage displays streaming content

func (*CLI) DisplayToolCallMessage

func (c *CLI) DisplayToolCallMessage(toolName, toolArgs string)

DisplayToolCallMessage displays a tool call in progress

func (*CLI) DisplayToolMessage

func (c *CLI) DisplayToolMessage(toolName, toolArgs, toolResult string, isError bool)

DisplayToolMessage displays a tool call message

func (*CLI) DisplayTools

func (c *CLI) DisplayTools(tools []string)

DisplayTools displays available tools in a message block

func (*CLI) DisplayUserMessage

func (c *CLI) DisplayUserMessage(message string)

DisplayUserMessage displays the user's message using the new renderer

func (*CLI) GetPrompt

func (c *CLI) GetPrompt() (string, error)

GetPrompt gets user input using the huh library with divider and padding

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

func (c *CLI) IsSlashCommand(input string) bool

IsSlashCommand checks if the input is a slash command

func (*CLI) ShowSpinner

func (c *CLI) ShowSpinner(message string, action func() error) error

ShowSpinner displays a spinner with the given message and executes the action

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 Spinner

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

Spinner wraps the bubbles spinner for both interactive and non-interactive mode

func NewSpinner

func NewSpinner(message string) *Spinner

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

func (*Spinner) Start

func (s *Spinner) Start()

Start begins the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop ends the spinner animation

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

Jump to

Keyboard shortcuts

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