plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package plugin implements Console's out-of-process plugin system using hashicorp/go-plugin over gRPC. The host (the console binary) launches a plugin executable, performs a handshake, and dispenses a typed client that satisfies the corresponding core interface — so engines stay unaware that an implementation lives in another process.

This package currently implements the storage seam (store.Store); other seams follow the same shape.

Index

Constants

View Source
const LLMPluginName = "llm"

LLMPluginName is the dispense key for the LLM seam.

View Source
const NotifierPluginName = "notifier"

NotifierPluginName is the dispense key for the notify seam.

View Source
const StatusProviderPluginName = "status_provider"

StatusProviderPluginName is the dispense key for the status seam.

View Source
const StorePluginName = "store"

StorePluginName is the dispense key for the storage seam.

Variables

View Source
var Handshake = goplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "CONSOLE_PLUGIN",
	MagicCookieValue: "console-plugin-v1",
}

Handshake is shared by host and plugin; a mismatch makes go-plugin refuse to run the binary, guarding against accidentally executing a non-plugin.

Functions

func LLMPluginSet

func LLMPluginSet(impl llm.Provider) goplugin.PluginSet

LLMPluginSet returns the go-plugin set for an LLM implementation.

func LoadLLM

func LoadLLM(path string) (llm.Provider, func() error, error)

LoadLLM launches the LLM plugin executable at path and returns an llm.Provider backed by it over gRPC. The returned func stops the subprocess. The plugin inherits the host's environment.

func LoadNotifier

func LoadNotifier(path string) (notify.Notifier, func() error, error)

LoadNotifier launches the notifier-plugin executable at path and returns a notify.Notifier backed by it over gRPC. The returned func stops the subprocess. The plugin inherits the host's environment.

func LoadStatusProvider

func LoadStatusProvider(path string) (status.Provider, func() error, error)

LoadStatusProvider launches the status-provider plugin executable at path and returns a status.Provider backed by it over gRPC. The returned func stops the subprocess. The plugin inherits the host's environment.

func LoadStore

func LoadStore(path string) (store.Store, error)

LoadStore launches the store-plugin executable at path and returns a store.Store backed by it over gRPC. Closing the returned store stops the subprocess. The plugin inherits the host's environment (so configuration such as CONSOLE_DB reaches it).

func NotifierPluginSet

func NotifierPluginSet(impl notify.Notifier) goplugin.PluginSet

NotifierPluginSet returns the go-plugin set for a notifier implementation.

func PluginSet

func PluginSet(impl store.Store) goplugin.PluginSet

PluginSet returns the go-plugin plugin set for a store implementation. With a nil impl it is suitable for the host (dispensing a client); with a real impl it is suitable for the plugin (serving it).

func Serve

func Serve(impl store.Store)

Serve runs a store implementation as a plugin. Plugin executables call this from main; it blocks until the host disconnects.

func ServeLLM

func ServeLLM(impl llm.Provider)

ServeLLM runs an LLM implementation as a plugin. Plugin executables call this from main; it blocks until the host disconnects.

func ServeNotifier

func ServeNotifier(impl notify.Notifier)

ServeNotifier runs a notifier implementation as a plugin. Plugin executables call this from main; it blocks until the host disconnects.

func ServeStatusProvider

func ServeStatusProvider(impl status.Provider)

ServeStatusProvider runs a status-provider implementation as a plugin. Plugin executables call this from main; it blocks until the host disconnects.

func StatusProviderPluginSet

func StatusProviderPluginSet(impl status.Provider) goplugin.PluginSet

StatusProviderPluginSet returns the go-plugin set for a status provider.

Types

type LLMPlugin

type LLMPlugin struct {
	goplugin.NetRPCUnsupportedPlugin
	Impl llm.Provider
}

LLMPlugin is the go-plugin GRPCPlugin for the LLM seam. On the plugin side Impl holds the real provider; on the host side it is nil and GRPCClient returns a client adapter.

func (*LLMPlugin) GRPCClient

func (p *LLMPlugin) GRPCClient(_ context.Context, _ *goplugin.GRPCBroker, c *grpc.ClientConn) (any, error)

GRPCClient returns an llm.Provider backed by the connection (host side).

func (*LLMPlugin) GRPCServer

func (p *LLMPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the LLM service backed by Impl (plugin side).

type NotifierPlugin

type NotifierPlugin struct {
	goplugin.NetRPCUnsupportedPlugin
	Impl notify.Notifier
}

NotifierPlugin is the go-plugin GRPCPlugin for the notify seam.

func (*NotifierPlugin) GRPCClient

GRPCClient returns a notify.Notifier backed by the connection (host side).

func (*NotifierPlugin) GRPCServer

func (p *NotifierPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the notifier service backed by Impl (plugin side).

type StatusProviderPlugin

type StatusProviderPlugin struct {
	goplugin.NetRPCUnsupportedPlugin
	Impl status.Provider
}

StatusProviderPlugin is the go-plugin GRPCPlugin for the status seam. On the plugin side Impl holds the real provider; on the host side it is nil and GRPCClient returns a client adapter.

func (*StatusProviderPlugin) GRPCClient

GRPCClient returns a status.Provider backed by the connection (host side).

func (*StatusProviderPlugin) GRPCServer

func (p *StatusProviderPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the status-provider service backed by Impl (plugin side).

type StorePlugin

type StorePlugin struct {
	goplugin.NetRPCUnsupportedPlugin
	Impl store.Store
}

StorePlugin is the go-plugin GRPCPlugin for the storage seam. On the plugin side Impl holds the real store; on the host side it is nil and GRPCClient returns a client adapter.

func (*StorePlugin) GRPCClient

func (p *StorePlugin) GRPCClient(_ context.Context, _ *goplugin.GRPCBroker, c *grpc.ClientConn) (any, error)

GRPCClient returns a store.Store backed by the gRPC connection (host side).

func (*StorePlugin) GRPCServer

func (p *StorePlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the store service backed by Impl (plugin side).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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