Documentation
¶
Index ¶
- type ChannelEventBus
- type Event
- type EventBus
- type EventType
- type IncomingMessage
- type LogEvent
- type LogLevel
- type MCPManager
- func (m *MCPManager) CallTool(ctx context.Context, name string, args json.RawMessage) (string, error)
- func (m *MCPManager) Close() error
- func (m *MCPManager) GetAthyrTools() []athyr.Tool
- func (m *MCPManager) GetServerForTool(toolName string) string
- func (m *MCPManager) GetToolsInfo() []ToolInfo
- func (m *MCPManager) RegisterTool(serverName string, tool athyr.Tool)
- func (m *MCPManager) SetToolExecutor(executor ToolExecutor)
- func (m *MCPManager) Start(ctx context.Context, servers []config.MCPServerConfig) error
- type MessageDirection
- type MessageEvent
- type MessageHandler
- func (h *MessageHandler) DirectChat(content string) (response string, model string, tokens int, err error)
- func (h *MessageHandler) Handle(msg athyr.SubscribeMessage)
- func (h *MessageHandler) PublishMessage(topic string, data []byte) error
- func (h *MessageHandler) RequestMessage(topic string, data []byte) ([]byte, error)
- func (h *MessageHandler) StopWatching() error
- func (h *MessageHandler) WatchTopic(topic string, callback WatchCallback) error
- func (h *MessageHandler) WatchingTopic() string
- type Options
- type Response
- type Runner
- type StatusEvent
- type ToolEvent
- type ToolExecutor
- type ToolInfo
- type ToolStatus
- type ToolsAvailableEvent
- type WatchCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelEventBus ¶
type ChannelEventBus struct {
// contains filtered or unexported fields
}
ChannelEventBus is the default EventBus implementation using a buffered channel.
func NewEventBus ¶
func NewEventBus(bufferSize int) *ChannelEventBus
NewEventBus creates a new ChannelEventBus with the given buffer size.
func (*ChannelEventBus) Events ¶
func (b *ChannelEventBus) Events() <-chan Event
Events returns the channel to receive events from.
func (*ChannelEventBus) Send ¶
func (b *ChannelEventBus) Send(event Event)
Send sends an event to the bus. Non-blocking; drops if buffer full.
type EventBus ¶
type EventBus interface {
// Send sends an event to the bus. Non-blocking; drops if buffer full.
Send(event Event)
// Events returns the channel to receive events from.
Events() <-chan Event
// Close closes the event bus.
Close()
}
EventBus receives events from the runner for TUI consumption.
type IncomingMessage ¶
type IncomingMessage struct {
SessionID string `json:"session_id,omitempty"`
Content string `json:"content,omitempty"`
}
IncomingMessage represents a structured message with optional session info.
type MCPManager ¶
type MCPManager struct {
// contains filtered or unexported fields
}
MCPManager manages MCP server connections and tool execution.
func NewMCPManager ¶
func NewMCPManager(logger *slog.Logger) *MCPManager
NewMCPManager creates a new MCP manager.
func (*MCPManager) CallTool ¶
func (m *MCPManager) CallTool(ctx context.Context, name string, args json.RawMessage) (string, error)
CallTool executes a tool call and returns the result.
func (*MCPManager) Close ¶
func (m *MCPManager) Close() error
Close shuts down all MCP server connections.
func (*MCPManager) GetAthyrTools ¶
func (m *MCPManager) GetAthyrTools() []athyr.Tool
GetAthyrTools returns all discovered tools in athyr.Tool format.
func (*MCPManager) GetServerForTool ¶
func (m *MCPManager) GetServerForTool(toolName string) string
GetServerForTool returns the server name that provides a given tool.
func (*MCPManager) GetToolsInfo ¶
func (m *MCPManager) GetToolsInfo() []ToolInfo
GetToolsInfo returns tool information including which server they came from.
func (*MCPManager) RegisterTool ¶
func (m *MCPManager) RegisterTool(serverName string, tool athyr.Tool)
RegisterTool manually registers a tool (useful for testing or shell tools).
func (*MCPManager) SetToolExecutor ¶
func (m *MCPManager) SetToolExecutor(executor ToolExecutor)
SetToolExecutor sets a custom tool executor (useful for testing).
func (*MCPManager) Start ¶
func (m *MCPManager) Start(ctx context.Context, servers []config.MCPServerConfig) error
Start connects to all configured MCP servers and discovers their tools.
type MessageDirection ¶
type MessageDirection int
MessageDirection indicates whether a message is incoming or outgoing.
const ( MessageIncoming MessageDirection = iota MessageOutgoing )
type MessageEvent ¶
type MessageEvent struct {
Time time.Time
Direction MessageDirection
Topic string
Content string
Model string
Tokens int
}
MessageEvent represents a message sent or received.
func (MessageEvent) Timestamp ¶
func (e MessageEvent) Timestamp() time.Time
func (MessageEvent) Type ¶
func (e MessageEvent) Type() EventType
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
MessageHandler processes incoming messages through the LLM.
func (*MessageHandler) DirectChat ¶
func (h *MessageHandler) DirectChat(content string) (response string, model string, tokens int, err error)
DirectChat sends a message directly to the LLM and returns the response. This is used by the TUI for interactive chat without going through pub/sub.
func (*MessageHandler) Handle ¶
func (h *MessageHandler) Handle(msg athyr.SubscribeMessage)
Handle processes a single incoming message.
func (*MessageHandler) PublishMessage ¶
func (h *MessageHandler) PublishMessage(topic string, data []byte) error
PublishMessage sends a message to a topic (fire-and-forget). This is used by the TUI to send messages without waiting for a response.
func (*MessageHandler) RequestMessage ¶
func (h *MessageHandler) RequestMessage(topic string, data []byte) ([]byte, error)
RequestMessage sends a message to a topic and waits for a reply. This uses the request/reply pattern with a 30 second timeout.
func (*MessageHandler) StopWatching ¶
func (h *MessageHandler) StopWatching() error
StopWatching stops the current watch subscription if any.
func (*MessageHandler) WatchTopic ¶
func (h *MessageHandler) WatchTopic(topic string, callback WatchCallback) error
WatchTopic subscribes to a topic and calls the callback for each message. Only one topic can be watched at a time; calling this again will stop the previous watch.
func (*MessageHandler) WatchingTopic ¶
func (h *MessageHandler) WatchingTopic() string
WatchingTopic returns the currently watched topic, or empty string if not watching.
type Options ¶
type Options struct {
ServerAddr string
Insecure bool
Logger *slog.Logger
EventBus EventBus // Optional: for TUI mode
}
Options configures the runner.
type Response ¶
type Response struct {
Content string `json:"content"`
Model string `json:"model"`
SourceTopic string `json:"source_topic"`
Tokens int `json:"tokens"`
FinishReason string `json:"finish_reason"`
}
Response is the structure published to output topics.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner manages the agent lifecycle.
func (*Runner) Handler ¶
func (r *Runner) Handler() *MessageHandler
Handler returns the message handler, used by the TUI for direct chat.
type StatusEvent ¶
type StatusEvent struct {
Time time.Time
Connected bool
AgentID string
AgentName string
Error error
}
StatusEvent indicates a change in connection status.
func (StatusEvent) Timestamp ¶
func (e StatusEvent) Timestamp() time.Time
func (StatusEvent) Type ¶
func (e StatusEvent) Type() EventType
type ToolEvent ¶
type ToolEvent struct {
Time time.Time
Status ToolStatus
Name string
Args string
Result string
Error error
Duration time.Duration
}
ToolEvent represents a tool execution.
type ToolExecutor ¶
ToolExecutor is a function that executes a tool call.
type ToolStatus ¶
type ToolStatus int
ToolStatus indicates the state of a tool execution.
const ( ToolStarted ToolStatus = iota ToolCompleted ToolFailed )
type ToolsAvailableEvent ¶
ToolsAvailableEvent is emitted when MCP tools are discovered.
func (ToolsAvailableEvent) Timestamp ¶
func (e ToolsAvailableEvent) Timestamp() time.Time
func (ToolsAvailableEvent) Type ¶
func (e ToolsAvailableEvent) Type() EventType
type WatchCallback ¶
WatchCallback is called when a message is received on a watched topic.