plugin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability string

Capability declares a contract a plugin satisfies.

const (
	// CapabilityTools indicates the plugin exposes MCP tools to the LLM.
	CapabilityTools Capability = "tools"
)

type Manager

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

Manager loads plugin configs, validates them, and registers their capabilities with the appropriate subsystem (currently only MCP tool servers via ToolRegistrar).

func NewManager

func NewManager(logger *slog.Logger) *Manager

NewManager creates a plugin Manager with no plugins loaded.

func (*Manager) Count

func (m *Manager) Count() int

Count returns the number of successfully loaded plugins.

func (*Manager) Load

func (m *Manager) Load(plugins map[string]config.PluginConfig, existingToolNames map[string]bool) error

Load validates all plugin configs and populates the internal plugin list. existingToolNames is used to detect name collisions with registered [tools.*] entries. Keys are processed in sorted order for deterministic error reporting. Returns an error on the first invalid plugin; does not continue past errors.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, tools ToolRegistrar) error

Start registers each loaded plugin's capabilities with the appropriate subsystem. Plugins with the "tools" capability are registered as MCP servers via tools.RegisterServer. A failure to register a plugin is logged as an error but does not halt other plugins. Returns the first error encountered, or nil if all plugins started successfully.

type Plugin

type Plugin struct {
	Name         string
	Type         PluginType
	Command      string
	Args         []string
	Env          map[string]string
	Capabilities []Capability
}

Plugin is the validated, normalised representation of a single plugin entry.

type PluginType

type PluginType string

PluginType is the execution strategy for a plugin.

const (
	// TypeSubprocess runs the plugin as a trusted subprocess with direct MCP stdio communication.
	TypeSubprocess PluginType = "subprocess"
	// TypeDocker is reserved for future sandboxed execution and is not yet implemented.
	TypeDocker PluginType = "docker"
)

type ToolRegistrar

type ToolRegistrar interface {
	RegisterServer(ctx context.Context, name, command string, args []string, env map[string]string) error
}

ToolRegistrar is the interface Manager uses to register MCP tool servers. *tool.Manager satisfies this interface; inject a mock in tests.

Jump to

Keyboard shortcuts

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