plugins

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package plugins implements the Go native plugin (.so) loading system for DevClaw. Plugins extend the runtime with additional channels, webhooks, and custom integrations without recompiling the binary.

Plugin .so files must export one of:

  • var Channel channels.Channel (for channel plugins)
  • var Plugin plugins.Plugin (for generic plugins)

Build a plugin:

go build -buildmode=plugin -o plugins/discord.so discord_plugin.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Dir is the directory to scan for .so files.
	Dir string `yaml:"dir"`

	// Enabled lists plugins to load (empty = load all found).
	Enabled []string `yaml:"enabled"`

	// Disabled lists plugins to skip.
	Disabled []string `yaml:"disabled"`
}

Config holds plugin loader configuration.

type LoadedPlugin

type LoadedPlugin struct {
	// Path is the .so file path.
	Path string

	// Name is the plugin name (from filename or Plugin.Name()).
	Name string

	// Channel is the channel implementation (if this is a channel plugin).
	Channel channels.Channel

	// Plugin is the generic plugin interface (optional).
	Plugin Plugin

	// Raw is the raw *plugin.Plugin handle.
	Raw *plugin.Plugin
}

LoadedPlugin holds a loaded plugin and its metadata.

type Loader

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

Loader discovers and loads Go native plugins from a directory.

func NewLoader

func NewLoader(cfg Config, logger *slog.Logger) *Loader

NewLoader creates a new plugin loader.

func (*Loader) All

func (l *Loader) All() []*LoadedPlugin

All returns all loaded plugins.

func (*Loader) Channels

func (l *Loader) Channels() []channels.Channel

Channels returns all loaded channel plugins.

func (*Loader) Count

func (l *Loader) Count() int

Count returns the number of loaded plugins.

func (*Loader) LoadAll

func (l *Loader) LoadAll(ctx context.Context) error

LoadAll scans the plugin directory and loads all valid .so files.

func (*Loader) Plugins

func (l *Loader) Plugins() []Plugin

Plugins returns all loaded generic plugins.

func (*Loader) RegisterChannels

func (l *Loader) RegisterChannels(mgr *channels.Manager) error

RegisterChannels registers all loaded channel plugins with a Manager.

func (*Loader) Shutdown

func (l *Loader) Shutdown()

Shutdown gracefully stops all loaded plugins.

type Plugin

type Plugin interface {
	// Name returns the plugin identifier.
	Name() string

	// Version returns the plugin version string.
	Version() string

	// Init is called after loading. Use for setup.
	Init(ctx context.Context, config map[string]any) error

	// Shutdown is called on graceful stop.
	Shutdown() error
}

Plugin is the interface for generic DevClaw plugins. Channel plugins can also implement this for lifecycle hooks, but it's not required — exporting var Channel is enough.

Jump to

Keyboard shortcuts

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