plugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package plugin is part of the GoFastr harness.

See docs/harness-architecture.md for the architecture this package implements.

Package plugin defines the Plugin interface. Plugins are compile-time: a plugin author imports the harness as a library, implements Plugin, and links it into a custom binary. Go's plugin.Open is rejected for ABI fragility (see § Plugin distribution model). The recommended distribution channel for third-party tools is an MCP server bridged via mcpclient.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventEnvelope

type EventEnvelope = any // control.EventEnvelope

type Host

type Host interface {
	// ClaimSlashCommand reserves a namespace prefix for this
	// plugin's commands (e.g. "custom" for `/custom:foo`). Returns
	// an error on conflict with built-in or another plugin.
	ClaimSlashCommand(namespace string) error

	// AddRequestMiddleware appends a RequestMiddleware to the
	// engine's chain. The host wires it into every per-session
	// engine that boots after this point.
	AddRequestMiddleware(mw RequestMiddleware)

	// AddToolMiddleware appends a ToolMiddleware to the dispatcher
	// chain.
	AddToolMiddleware(mw ToolMiddleware)

	// RegisterToolSource adds a ToolSource (e.g. plugin-defined
	// tools) to the registry.
	RegisterToolSource(src ToolSource) error

	// RegisterProvider adds an LLM provider implementation.
	RegisterProvider(p Provider) error

	// SubscribeEvents returns a channel of canonical event
	// envelopes for cross-session subscribers (cost dashboards,
	// telemetry, etc.).
	SubscribeEvents() <-chan EventEnvelope
}

Host is the API surface plugins access. Concrete harness.Harness satisfies this; we declare only what's needed so the interface doesn't drift.

Subsystem-shaped methods take the subsystem's package-level type; this package re-declares minimal interfaces below to avoid heavy imports.

type Manager

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

Manager holds the registered plugins for a harness process and drives Register on boot.

func NewManager

func NewManager() *Manager

NewManager returns an empty Manager.

func (*Manager) InitAll

func (m *Manager) InitAll(h Host) error

InitAll calls Register(h) on every registered plugin in registration order. Returns the first error.

func (*Manager) List

func (m *Manager) List() []string

List returns the plugin names in registration order.

func (*Manager) Register

func (m *Manager) Register(p Plugin)

Register adds a plugin. Order matters: plugins registered earlier see their middleware run before later ones in the chain.

type Plugin

type Plugin interface {
	Name() string
	Register(h Host) error
}

Plugin is the single extension contract. On Register, a plugin attaches middleware, subscribes to events, registers backends, and claims slash-command namespaces.

The Host is the subset of the harness API a plugin may touch; concrete *harness.Harness satisfies it. Defining Host as an interface in this package keeps plugin/ free of the harness/ import (which would create a cycle).

type Provider

type Provider = any // provider.Provider

type RequestMiddleware

type RequestMiddleware = any // engine.RequestMiddleware

type ToolMiddleware

type ToolMiddleware = any // tool.Middleware

type ToolSource

type ToolSource = any // tool.ToolSource

Jump to

Keyboard shortcuts

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