Documentation
¶
Index ¶
- func LoadBuiltin()
- func RegisterPlugin(p Plugin)
- type Channel
- type ChannelPlugin
- type Manager
- func (m *Manager) AllChannels() map[string]Channel
- func (m *Manager) AllProviders() map[string]providers.LLMProvider
- func (m *Manager) GetChannel(prefix string) (Channel, bool)
- func (m *Manager) GetProvider(name string) (providers.LLMProvider, bool)
- func (m *Manager) Initialize(ctx context.Context) error
- func (m *Manager) InitializeToolsOnly(ctx context.Context) error
- func (m *Manager) ToolRegistry() *tools.ToolRegistry
- type Metadata
- type Plugin
- type PluginType
- type ProviderPlugin
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) CountChannels() int
- func (r *Registry) CountProviders() int
- func (r *Registry) CountTools() int
- func (r *Registry) GetChannelPlugins() map[string]ChannelPlugin
- func (r *Registry) GetPlugin(id string) (Plugin, bool)
- func (r *Registry) GetProviderPlugins() map[string]ProviderPlugin
- func (r *Registry) GetToolPlugins() map[string]ToolPlugin
- func (r *Registry) ListChannelPlugins() []string
- func (r *Registry) ListPlugins() []string
- func (r *Registry) ListProviderPlugins() []string
- func (r *Registry) ListToolPlugins() []string
- func (r *Registry) Register(p Plugin)
- type RuntimeContext
- type ToolPlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadBuiltin ¶
func LoadBuiltin()
LoadBuiltin ensures all builtin plugins are registered. Plugin registration happens via init() when plugin packages are imported. The gateway (cmd/moonhub/internal/gateway/helpers.go) imports all plugin packages to trigger registration:
- Channel plugins: pkg/plugins/channels/*
- Provider plugins: pkg/plugins/providers/*
- Tool plugins: pkg/plugins/tools/*
This function is a no-op kept for API compatibility.
func RegisterPlugin ¶
func RegisterPlugin(p Plugin)
RegisterPlugin is a convenience function for the global registry
Types ¶
type Channel ¶
type Channel interface {
Name() string
Start(ctx context.Context) error
Stop(ctx context.Context) error
Send(ctx context.Context, msg bus.OutboundMessage) error
IsRunning() bool
}
Channel is the interface for messaging channels Defined here to avoid circular imports
type ChannelPlugin ¶
type ChannelPlugin interface {
Plugin
// ChannelPrefix returns the userId prefix this channel owns (e.g., "telegram", "discord")
ChannelPrefix() string
// CreateChannel instantiates the channel implementation
CreateChannel(cfg *config.Config, bus *bus.MessageBus) (Channel, error)
// IsEnabled checks if the channel is enabled in config
IsEnabled(cfg *config.Config) bool
}
ChannelPlugin extends Plugin with channel-specific functionality. Channel plugins connect external messaging platforms (Telegram, Discord, etc.)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates plugin lifecycle
func NewManager ¶
func NewManager(cfg *config.Config, messageBus *bus.MessageBus, store media.MediaStore) *Manager
NewManager creates a new plugin manager
func (*Manager) AllChannels ¶
AllChannels returns all initialized channels
func (*Manager) AllProviders ¶
func (m *Manager) AllProviders() map[string]providers.LLMProvider
AllProviders returns all initialized providers
func (*Manager) GetChannel ¶
GetChannel returns an initialized channel by prefix
func (*Manager) GetProvider ¶
func (m *Manager) GetProvider(name string) (providers.LLMProvider, bool)
GetProvider returns an initialized provider by name
func (*Manager) Initialize ¶
Initialize loads and initializes all enabled plugins
func (*Manager) InitializeToolsOnly ¶
InitializeToolsOnly initializes only tool plugins. Used when channels and providers are managed separately (e.g., by gateway).
func (*Manager) ToolRegistry ¶
func (m *Manager) ToolRegistry() *tools.ToolRegistry
ToolRegistry returns the tool registry for agent use
type Metadata ¶
type Metadata struct {
// ID is the unique identifier for the plugin (e.g., "moonhub-channel-telegram")
ID string `json:"id"`
// Name is the human-readable name (e.g., "Telegram")
Name string `json:"name"`
// Type indicates the plugin category
Type PluginType `json:"type"`
// Version follows semantic versioning (e.g., "1.0.0")
Version string `json:"version"`
// Description provides a brief summary of the plugin
Description string `json:"description"`
// Author is optional attribution
Author string `json:"author,omitempty"`
// Priority affects loading order (higher = loaded later)
Priority int `json:"priority,omitempty"`
}
Metadata contains common plugin information
type Plugin ¶
type Plugin interface {
// Metadata returns plugin metadata
Metadata() Metadata
// Init initializes the plugin with runtime context
Init(ctx *RuntimeContext) error
// Validate checks if the plugin can run with current config
Validate(cfg *config.Config) error
}
Plugin is the base interface all plugins must implement
type PluginType ¶
type PluginType string
PluginType defines the category of plugin
const ( // TypeChannel indicates a channel plugin (Telegram, Discord, etc.) TypeChannel PluginType = "channel" // TypeProvider indicates a provider plugin (OpenAI, Anthropic, etc.) TypeProvider PluginType = "provider" // TypeTool indicates a tool plugin (web search, filesystem, etc.) TypeTool PluginType = "tool" )
type ProviderPlugin ¶
type ProviderPlugin interface {
Plugin
// ProviderName returns the provider identifier (e.g., "anthropic", "openai")
ProviderName() string
// CreateProvider instantiates the provider from full config (used for IsEnabled checks).
// For actual provider creation, use CreateProviderFromModelConfig.
CreateProvider(cfg *config.Config) (providers.LLMProvider, error)
// CreateProviderFromModelConfig creates a provider from model-centric config.
// Used by the factory when routing by protocol.
CreateProviderFromModelConfig(modelCfg *config.ModelConfig) (providers.LLMProvider, error)
// IsEnabled checks if the provider has valid configuration
IsEnabled(cfg *config.Config) bool
// SupportsProtocol returns true if this plugin handles the given protocol (e.g., "openai", "anthropic").
// Used for routing in CreateProviderFromConfig.
SupportsProtocol(protocol string) bool
// SupportsModel checks if this provider can handle a given model name (e.g., "openai/gpt-4o")
SupportsModel(modelName string) bool
}
ProviderPlugin extends Plugin with provider-specific functionality. Provider plugins add LLM providers (OpenAI, Anthropic, Gemini, etc.)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all registered plugins
func (*Registry) CountChannels ¶
CountChannels returns the number of registered channel plugins
func (*Registry) CountProviders ¶
CountProviders returns the number of registered provider plugins
func (*Registry) CountTools ¶
CountTools returns the number of registered tool plugins
func (*Registry) GetChannelPlugins ¶
func (r *Registry) GetChannelPlugins() map[string]ChannelPlugin
GetChannelPlugins returns all registered channel plugins
func (*Registry) GetProviderPlugins ¶
func (r *Registry) GetProviderPlugins() map[string]ProviderPlugin
GetProviderPlugins returns all registered provider plugins
func (*Registry) GetToolPlugins ¶
func (r *Registry) GetToolPlugins() map[string]ToolPlugin
GetToolPlugins returns all registered tool plugins
func (*Registry) ListChannelPlugins ¶
ListChannelPlugins returns a sorted list of channel plugin IDs
func (*Registry) ListPlugins ¶
ListPlugins returns a list of all registered plugin IDs
func (*Registry) ListProviderPlugins ¶
ListProviderPlugins returns a sorted list of provider plugin IDs
func (*Registry) ListToolPlugins ¶
ListToolPlugins returns a sorted list of tool plugin IDs
type RuntimeContext ¶
type RuntimeContext struct {
// Config is the application configuration
Config *config.Config
// Bus is the message bus for inter-component communication
Bus *bus.MessageBus
// Workspace is the path to the workspace directory
Workspace string
// MediaStore handles media file storage
MediaStore media.MediaStore
}
RuntimeContext provides dependencies injected at initialization
type ToolPlugin ¶
type ToolPlugin interface {
Plugin
// CreateTools returns tool instances this plugin provides
CreateTools(ctx *RuntimeContext) []tools.Tool
// IsCore indicates if this is a core tool (always available)
// Non-core tools can be dynamically promoted/discovered
IsCore() bool
}
ToolPlugin extends Plugin with tool-specific functionality. Tool plugins extend the agent's capabilities with custom tools.