plugin

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package plugin provides the plugin runner framework for extending flowbot via external binaries communicating over gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbilityDecl

type AbilityDecl struct {
	Capability string   `json:"capability" yaml:"capability"`
	Operations []string `json:"operations" yaml:"operations"`
}

AbilityDecl declares a capability the plugin provides as an ability backend.

type ExecutionLimit

type ExecutionLimit struct {
	Timeout string `json:"timeout" yaml:"timeout"` // e.g. "30s"
}

ExecutionLimit contains execution constraints.

type FSPermission

type FSPermission struct {
	Path string `json:"path" yaml:"path"`
	Mode string `json:"mode" yaml:"mode"` // "readwrite" or "read"
}

FSPermission defines filesystem access for Wasm plugins.

type GRPCConfig

type GRPCConfig struct {
	Binary string   `json:"binary" yaml:"binary"`
	Args   []string `json:"args" yaml:"args"`
}

GRPCConfig is the gRPC runner configuration.

type HTTPPermission

type HTTPPermission struct {
	Host string `json:"host" yaml:"host"`
}

HTTPPermission allowlist entry for HTTP requests from Wasm.

type HealthStatus

type HealthStatus struct {
	Ready     bool
	LastError string
	Uptime    time.Duration
}

HealthStatus reports plugin readiness and last error.

type HostAPI

type HostAPI interface {
	GetConfig(ctx context.Context, key string) (string, error)
	Log(ctx context.Context, level string, msg string, fields map[string]string)
	KVGet(ctx context.Context, key string) ([]byte, error)
	KVSet(ctx context.Context, key string, value []byte) error
	KVDelete(ctx context.Context, key string) error
	HTTPRequest(ctx context.Context, req *HostHTTPRequest) (*HostHTTPResponse, error)
	EmitEvent(ctx context.Context, event types.DataEvent) error
}

HostAPI defines the services available to plugins from the host.

type HostHTTPRequest

type HostHTTPRequest struct {
	Method  string            `json:"method"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
	Body    []byte            `json:"body"`
}

HostHTTPRequest is an HTTP request from a plugin to the host.

type HostHTTPResponse

type HostHTTPResponse struct {
	Status  int               `json:"status"`
	Headers map[string]string `json:"headers"`
	Body    []byte            `json:"body"`
}

HostHTTPResponse is an HTTP response from the host to a plugin.

type Manifest

type Manifest struct {
	Name         string          `json:"name" yaml:"name"`
	Version      string          `json:"version" yaml:"version"`
	Description  string          `json:"description" yaml:"description"`
	Author       string          `json:"author" yaml:"author"`
	Runtime      RuntimeKind     `json:"runtime" yaml:"runtime"`
	Provides     Provides        `json:"provides" yaml:"provides"`
	GRPC         *GRPCConfig     `json:"grpc" yaml:"grpc"`
	Wasm         *WasmConfig     `json:"wasm" yaml:"wasm"`
	ConfigSchema json.RawMessage `json:"config_schema" yaml:"config_schema"`
}

Manifest is the parsed plugin.yaml configuration.

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest parses plugin.yaml bytes into a Manifest, validating required fields.

func (*Manifest) ValidateConfig

func (m *Manifest) ValidateConfig(config json.RawMessage) error

ValidateConfig validates per-plugin config against the manifest's config_schema. Returns nil if no schema is defined.

type MemoryLimit

type MemoryLimit struct {
	Max string `json:"max" yaml:"max"` // e.g. "64MB"
}

MemoryLimit contains Wasm memory constraints.

type PluginInfo

type PluginInfo struct {
	Name         string
	Version      string
	Provides     Provides
	ConfigSchema json.RawMessage
}

PluginInfo is returned after Load() and describes what the plugin provides.

type PluginState

type PluginState string

PluginState represents the lifecycle state of a loaded plugin.

const (
	StateLoading  PluginState = "loading"
	StateRunning  PluginState = "running"
	StateStopping PluginState = "stopping"
	StateError    PluginState = "error"
)

type ProviderDecl

type ProviderDecl struct {
	Name  string `json:"name" yaml:"name"`
	OAuth bool   `json:"oauth" yaml:"oauth"`
}

ProviderDecl declares a provider plugin.

type Provides

type Provides struct {
	Module    bool          `json:"module" yaml:"module"`
	Abilities []AbilityDecl `json:"abilities" yaml:"abilities"`
	Provider  *ProviderDecl `json:"provider" yaml:"provider"`
}

Provides declares what the plugin implements.

type Runner

type Runner interface {
	Load(ctx context.Context, manifest *Manifest) (*PluginInfo, error)
	Start(ctx context.Context, config json.RawMessage) error
	Stop(ctx context.Context) error
	Call(ctx context.Context, function string, params json.RawMessage) (json.RawMessage, error)
	Health(ctx context.Context) (*HealthStatus, error)
}

Runner is the common contract for plugin execution environments. Each runner (gRPC, Wasm) implements this interface.

type RuntimeKind

type RuntimeKind string

RuntimeKind is the plugin execution environment.

const (
	RuntimeGRPC RuntimeKind = "grpc"
	RuntimeWasm RuntimeKind = "wasm"
)

type WasmConfig

type WasmConfig struct {
	Module      string           `json:"module" yaml:"module"`
	Permissions *WasmPermissions `json:"permissions" yaml:"permissions"`
	Pool        *WasmPoolConfig  `json:"pool" yaml:"pool"`
}

WasmConfig is the Wasm runner configuration.

type WasmPermissions

type WasmPermissions struct {
	HTTP       []HTTPPermission `json:"http" yaml:"http"`
	Filesystem []FSPermission   `json:"filesystem" yaml:"filesystem"`
	Memory     *MemoryLimit     `json:"memory" yaml:"memory"`
	Execution  *ExecutionLimit  `json:"execution" yaml:"execution"`
}

WasmPermissions defines Wasm sandbox permissions.

type WasmPoolConfig

type WasmPoolConfig struct {
	MaxInstances int    `json:"max_instances" yaml:"max_instances"` // default 4
	WaitTimeout  string `json:"wait_timeout" yaml:"wait_timeout"`   // default "5s"
}

WasmPoolConfig contains the Wasm instance pool configuration.

Directories

Path Synopsis
Package adapter provides bridge types that adapt plugin.Runner calls to flowbot's module, ability, and provider registries.
Package adapter provides bridge types that adapt plugin.Runner calls to flowbot's module, ability, and provider registries.
Package grpc provides the gRPC-based plugin runtime implementation.
Package grpc provides the gRPC-based plugin runtime implementation.
Package manager provides the PluginManager that orchestrates plugin discovery, loading, lifecycle, and hot-reload.
Package manager provides the PluginManager that orchestrates plugin discovery, loading, lifecycle, and hot-reload.
Package sdk provides the plugin SDK for building flowbot module plugins.
Package sdk provides the plugin SDK for building flowbot module plugins.
Package source provides plugin discovery from local filesystem directories.
Package source provides plugin discovery from local filesystem directories.
Package types provides shared plugin types with zero internal dependencies to avoid import cycles.
Package types provides shared plugin types with zero internal dependencies to avoid import cycles.
Package wasm provides the WebAssembly-based plugin runner.
Package wasm provides the WebAssembly-based plugin runner.

Jump to

Keyboard shortcuts

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