Documentation
¶
Index ¶
- func NewTUILogger(eventBus runner.EventBus, level slog.Level) *slog.Logger
- func NewTUILoggerWithFallback(eventBus runner.EventBus, level slog.Level, fallback slog.Handler) *slog.Logger
- type ChatHandler
- type ChatResponseMsg
- type EventMsg
- type LogHandler
- type MessagingHandler
- type MessagingResponseMsg
- type Model
- type Options
- type SetChatHandlerMsg
- type SetMessagingHandlerMsg
- type TUI
- type WatchCallback
- type WatchMessageMsg
- type WatchStatusMsg
- type WindowSizeMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTUILogger ¶
NewTUILogger creates a logger that sends logs to both the TUI and stderr.
Types ¶
type ChatHandler ¶
type ChatHandler interface {
DirectChat(content string) (response string, model string, tokens int, err error)
}
ChatHandler is the interface for sending chat messages. This is implemented by the Runner/MessageHandler.
type ChatResponseMsg ¶
ChatResponseMsg is sent when a direct chat response is received.
type LogHandler ¶
type LogHandler struct {
// contains filtered or unexported fields
}
LogHandler is an slog.Handler that emits LogEvents to an EventBus. It also forwards logs to an underlying handler if provided.
func NewLogHandler ¶
NewLogHandler creates a new LogHandler that emits to the given EventBus. If underlying is provided, logs are also forwarded there.
func (*LogHandler) Enabled ¶
Enabled reports whether the handler handles records at the given level.
type MessagingHandler ¶
type MessagingHandler interface {
PublishMessage(topic string, data []byte) error
RequestMessage(topic string, data []byte) ([]byte, error)
WatchTopic(topic string, callback WatchCallback) error
StopWatching() error
WatchingTopic() string
}
MessagingHandler is the interface for sending messages to topics. This is implemented by the Runner/MessageHandler.
type MessagingResponseMsg ¶
MessagingResponseMsg is sent when a messaging request response is received.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root Bubble Tea model for the TUI.
func (*Model) SetChatHandler ¶
func (m *Model) SetChatHandler(h ChatHandler)
SetChatHandler sets the handler for sending chat messages.
func (*Model) SetMessagingHandler ¶
func (m *Model) SetMessagingHandler(h MessagingHandler)
SetMessagingHandler sets the handler for sending messages to topics.
func (*Model) SetProgram ¶
SetProgram sets the tea.Program reference for sending async messages.
type Options ¶
type Options struct {
Config *config.Config
EventBus runner.EventBus
ChatHandler ChatHandler
MessagingHandler MessagingHandler
ServerAddr string // Athyr server address
}
Options configures the TUI.
type SetChatHandlerMsg ¶
type SetChatHandlerMsg struct {
Handler ChatHandler
}
SetChatHandlerMsg is sent to set the chat handler from outside the event loop.
type SetMessagingHandlerMsg ¶
type SetMessagingHandlerMsg struct {
Handler MessagingHandler
}
SetMessagingHandlerMsg is sent to set the messaging handler from outside the event loop.
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
TUI wraps the Bubble Tea program and provides a high-level interface.
func (*TUI) Send ¶
Send sends a message to the TUI program. This can be used to inject events from outside.
func (*TUI) SetChatHandler ¶
func (t *TUI) SetChatHandler(h ChatHandler)
SetChatHandler sets the chat handler after creation. This sends a message through Bubble Tea's event loop to ensure the handler is set on the actual model instance being used.
func (*TUI) SetMessagingHandler ¶
func (t *TUI) SetMessagingHandler(h MessagingHandler)
SetMessagingHandler sets the messaging handler after creation. This sends a message through Bubble Tea's event loop to ensure the handler is set on the actual model instance being used.
type WatchCallback ¶
WatchCallback is the function signature for receiving watch messages.
type WatchMessageMsg ¶
WatchMessageMsg is sent when a message is received on a watched topic.
type WatchStatusMsg ¶
WatchStatusMsg is sent when watch status changes (started, stopped, error).
type WindowSizeMsg ¶
WindowSizeMsg wraps terminal size updates.