Documentation
¶
Overview ¶
Package plugin implements infrastructure adapters for the plugin system.
The plugin package provides concrete implementations for plugin discovery, loading, validation, registration, and lifecycle management. It enables AWF workflows to extend functionality through external RPC-based plugins (operations, filters, transformers) without modifying core code. The package handles manifest parsing, version compatibility checking, state persistence, and operation registry integration.
Architecture Role ¶
In the hexagonal architecture:
- Implements plugin loading and lifecycle management (infrastructure adapters)
- Provides OperationRegistry for runtime operation lookup and registration
- Integrates with domain/ports.CommandExecutor for plugin discovery
- Application layer orchestrates workflow execution via registered plugin operations
- Domain layer defines operation contracts without plugin coupling
All plugin components use atomic file operations and thread-safe registries to support concurrent plugin loading during workflow initialization. The manifest parser validates semver constraints and capability declarations before plugin activation.
Plugin Management ¶
## RPCPluginManager (rpc_manager.go)
Plugin lifecycle orchestration:
- Discover: Scan plugins directory for valid manifests
- Load: Initialize plugin RPC client and register operations
- Init: Call plugin initialization hook with configuration
- Shutdown: Gracefully stop a running plugin
- ShutdownAll: Cleanup all active plugins on process termination
- Get: Retrieve loaded plugin by name
- List: Enumerate active plugin names
## Loader (loader.go)
Plugin discovery and validation:
- DiscoverPlugins: Find plugin.awf manifests in plugins directory
- LoadPlugin: Parse manifest, validate constraints, prepare RPC client
- ValidatePlugin: Check manifest schema, version compatibility, capability declarations
Registry and Discovery ¶
## OperationRegistry (registry.go)
Runtime operation registration and lookup:
- RegisterOperation: Add plugin-provided operation (thread-safe)
- UnregisterOperation: Remove operation by name
- GetOperation: Retrieve operation implementation by name
- GetPluginOperations: List operations provided by a plugin
- UnregisterPluginOperations: Remove all operations from a plugin
- Count: Total registered operations
- Clear: Reset registry state
Manifest and Metadata ¶
## ManifestParser (manifest_parser.go)
Plugin metadata parsing:
- ParseManifest: Read plugin.awf YAML manifest
- Validates: name, version, awf_version (semver constraints), capabilities
- Supports metadata: author, description, license, homepage
Capabilities: operation, filter, transform (plugin feature declarations)
State Persistence ¶
## JSONPluginStateStore (state_store.go)
Plugin state persistence:
- Save: Write plugin state to JSON file (atomic via temp file + rename)
- Load: Read plugin state from JSON file
- SetEnabled: Enable/disable plugin by name
- IsEnabled: Check if plugin is enabled
- GetConfig: Retrieve plugin-specific configuration
- SetConfig: Update plugin-specific configuration
- GetState: Access full plugin state
- ListDisabled: Enumerate disabled plugins
Uses file locking to prevent concurrent modification during workflow execution.
Version Handling ¶
## Version (version.go)
Semantic versioning support:
- ParseVersion: Parse semver string (e.g., "1.2.3")
- ParseConstraint: Parse version constraint (e.g., ">=1.0.0", "~1.2", "^2.0")
- CheckVersionConstraint: Validate version against constraint
- IsCompatible: Check plugin compatibility with AWF version
- Compare: Semver comparison (major.minor.patch)
Operators: =, !=, >, >=, <, <=, ~ (tilde range), ^ (caret range)
Index ¶
- Constants
- Variables
- func CheckVersionConstraint(constraintStr, versionStr string) (bool, error)
- func IsCompatible(awfVersionConstraint, currentAWFVersion string) (bool, error)
- func NormalizeTag(tag string) string
- func SourceDataFromPluginSource(source PluginSource) (map[string]any, error)
- func ValidateOwnerRepo(ownerRepo string) error
- type Asset
- type CompositeOperationProvider
- func (c *CompositeOperationProvider) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
- func (c *CompositeOperationProvider) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (c *CompositeOperationProvider) ListOperations() []*pluginmodel.OperationSchema
- type Constraint
- type Constraints
- type FileSystemLoader
- func (l *FileSystemLoader) DiscoverPlugins(ctx context.Context, pluginsDir string) ([]*pluginmodel.PluginInfo, error)
- func (l *FileSystemLoader) LoadPlugin(ctx context.Context, pluginDir string) (*pluginmodel.PluginInfo, error)
- func (l *FileSystemLoader) ValidatePlugin(info *pluginmodel.PluginInfo) error
- type GitHubReleaseClient
- type JSONPluginStateStore
- func (s *JSONPluginStateStore) BasePath() string
- func (s *JSONPluginStateStore) GetConfig(name string) map[string]any
- func (s *JSONPluginStateStore) GetSourceData(name string) map[string]any
- func (s *JSONPluginStateStore) GetState(name string) *pluginmodel.PluginState
- func (s *JSONPluginStateStore) IsEnabled(name string) bool
- func (s *JSONPluginStateStore) ListDisabled() []string
- func (s *JSONPluginStateStore) Load(ctx context.Context) error
- func (s *JSONPluginStateStore) RemoveState(ctx context.Context, name string) error
- func (s *JSONPluginStateStore) Save(ctx context.Context) error
- func (s *JSONPluginStateStore) SetConfig(ctx context.Context, name string, config map[string]any) error
- func (s *JSONPluginStateStore) SetEnabled(ctx context.Context, name string, enabled bool) error
- func (s *JSONPluginStateStore) SetSourceData(ctx context.Context, name string, data map[string]any) error
- type LoaderError
- type ManifestParseError
- type ManifestParser
- type OperationRegistry
- func (r *OperationRegistry) Clear()
- func (r *OperationRegistry) Count() int
- func (r *OperationRegistry) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (r *OperationRegistry) GetOperationSource(operationName string) (string, bool)
- func (r *OperationRegistry) GetPluginOperations(pluginName string) []*pluginmodel.OperationSchema
- func (r *OperationRegistry) Operations() []*pluginmodel.OperationSchema
- func (r *OperationRegistry) RegisterOperation(op *pluginmodel.OperationSchema) error
- func (r *OperationRegistry) UnregisterOperation(name string) error
- func (r *OperationRegistry) UnregisterPluginOperations(pluginName string) error
- type PluginInstaller
- func (pi *PluginInstaller) AtomicInstall(tempDir, targetDir string) error
- func (pi *PluginInstaller) Download(ctx context.Context, url, checksum string) ([]byte, error)
- func (pi *PluginInstaller) ExtractTarGz(data []byte, targetDir string) error
- func (pi *PluginInstaller) Install(ctx context.Context, url, checksum, targetDir string, force bool) error
- func (pi *PluginInstaller) ValidateManifest(dir string) error
- func (pi *PluginInstaller) VerifyChecksum(data []byte, checksum string) error
- type PluginSource
- type RPCManagerError
- type RPCPluginManager
- func (m *RPCPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
- func (m *RPCPluginManager) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
- func (m *RPCPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
- func (m *RPCPluginManager) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (m *RPCPluginManager) Init(ctx context.Context, name string, config map[string]any) error
- func (m *RPCPluginManager) List() []*pluginmodel.PluginInfo
- func (m *RPCPluginManager) ListOperations() []*pluginmodel.OperationSchema
- func (m *RPCPluginManager) Load(ctx context.Context, name string) error
- func (m *RPCPluginManager) SetPluginsDir(dir string)
- func (m *RPCPluginManager) SetPluginsDirs(dirs []string)
- func (m *RPCPluginManager) Shutdown(ctx context.Context, name string) error
- func (m *RPCPluginManager) ShutdownAll(ctx context.Context) error
- func (m *RPCPluginManager) StepTypeProvider(logger ports.Logger) ports.StepTypeProvider
- func (m *RPCPluginManager) ValidatorProvider(timeout time.Duration) ports.WorkflowValidatorProvider
- type Release
- type Version
Constants ¶
const ( OpEqual = "==" // Exact match OpNotEqual = "!=" // Not equal OpGreater = ">" // Greater than OpGreaterOrEqual = ">=" // Greater than or equal OpLess = "<" // Less than OpLessOrEqual = "<=" // Less than or equal OpTilde = "~" // Compatible with (allows patch updates) OpCaret = "^" // Compatible with (allows minor updates) )
Version comparison operators supported by the constraint parser.
const DefaultPluginsDir = "plugins"
Default plugins directory relative to config.
const ManifestFileName = "plugin.yaml"
ManifestFileName is the expected filename for plugin manifests.
Variables ¶
var ( ErrOperationAlreadyRegistered = errors.New("operation already registered") ErrOperationNotFound = errors.New("operation not found") ErrInvalidOperation = errors.New("invalid operation schema") )
Registry errors.
var ErrNoPluginsConfigured = errors.New("rpc_manager: no plugins configured")
ErrNoPluginsConfigured indicates no plugin loader or directory is configured.
Functions ¶
func CheckVersionConstraint ¶
CheckVersionConstraint checks if a version string satisfies a constraint string. This is the main entry point for version compatibility checking.
func IsCompatible ¶
IsCompatible checks if the current AWF version is compatible with a plugin's AWF version constraint. This is a convenience function.
func NormalizeTag ¶ added in v0.5.0
NormalizeTag strips a leading "v" prefix from a GitHub release tag.
func SourceDataFromPluginSource ¶ added in v0.5.0
func SourceDataFromPluginSource(source PluginSource) (map[string]any, error)
SourceDataFromPluginSource serializes a PluginSource to the format expected by PluginState.SourceData.
func ValidateOwnerRepo ¶ added in v0.5.0
ValidateOwnerRepo validates that the input is a valid GitHub repository reference in owner/repo format.
Valid format: owner/repo where both owner and repo are non-empty strings. Rejects:
- No slash separator
- Multiple slashes
- Empty segments (before/after slash)
- https:// prefix
- Strings longer than 200 characters
Parameters:
- ownerRepo: the owner/repo string to validate
Returns:
- error: validation error, or nil if valid
Types ¶
type Asset ¶ added in v0.5.0
type Asset struct {
Name string `json:"name"`
DownloadURL string `json:"browser_download_url"`
Size int `json:"size"`
}
Asset represents a release asset (binary, archive, etc).
func FindPlatformAsset ¶ added in v0.5.0
FindPlatformAsset finds the .tar.gz asset matching goos/goarch from a release's asset list. Pattern: awf-plugin-name_version_os_arch.tar.gz Returns an error listing available platforms when no match is found.
type CompositeOperationProvider ¶
type CompositeOperationProvider struct {
// contains filtered or unexported fields
}
CompositeOperationProvider wraps multiple OperationProvider instances into a single provider, delegating GetOperation/ListOperations/Execute by operation name. Enables coexistence of multiple built-in providers (e.g., github and notify).
func NewCompositeOperationProvider ¶
func NewCompositeOperationProvider(providers ...ports.OperationProvider) *CompositeOperationProvider
NewCompositeOperationProvider creates a new composite operation provider that delegates to the given providers.
func (*CompositeOperationProvider) Execute ¶
func (c *CompositeOperationProvider) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
Execute runs a plugin operation by delegating to the appropriate provider.
func (*CompositeOperationProvider) GetOperation ¶
func (c *CompositeOperationProvider) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation by name from the first provider that has it.
func (*CompositeOperationProvider) ListOperations ¶
func (c *CompositeOperationProvider) ListOperations() []*pluginmodel.OperationSchema
ListOperations returns all available operations from all providers.
type Constraint ¶
type Constraint struct {
Operator string // One of the Op* constants
Version Version // The version to compare against
}
Constraint represents a single version constraint (e.g., ">=0.4.0").
func ParseConstraint ¶
func ParseConstraint(s string) (Constraint, error)
ParseConstraint parses a constraint string into a Constraint struct. Accepts formats: ">=0.4.0", "~1.2.0", "^2.0.0", "1.0.0" (implies ==)
func (Constraint) Check ¶
func (c Constraint) Check(v Version) bool
Check tests if a version satisfies this constraint.
type Constraints ¶
type Constraints []Constraint
Constraints represents multiple version constraints that all must be satisfied.
func ParseConstraints ¶
func ParseConstraints(s string) (Constraints, error)
ParseConstraints parses a constraint string that may contain multiple constraints. Constraints are separated by spaces or commas. Examples: ">=0.4.0 <1.0.0", ">=0.4.0, <1.0.0"
func (Constraints) Check ¶
func (cs Constraints) Check(v Version) bool
Check tests if a version satisfies all constraints.
func (Constraints) String ¶
func (cs Constraints) String() string
String returns the string representation of the constraints.
type FileSystemLoader ¶
type FileSystemLoader struct {
// contains filtered or unexported fields
}
FileSystemLoader implements PluginLoader for filesystem-based plugin discovery.
func NewFileSystemLoader ¶
func NewFileSystemLoader(parser *ManifestParser) *FileSystemLoader
NewFileSystemLoader creates a new FileSystemLoader with the given manifest parser.
func (*FileSystemLoader) DiscoverPlugins ¶
func (l *FileSystemLoader) DiscoverPlugins(ctx context.Context, pluginsDir string) ([]*pluginmodel.PluginInfo, error)
DiscoverPlugins scans a directory for plugins and returns their info. Each subdirectory containing a plugin.yaml is considered a plugin.
func (*FileSystemLoader) LoadPlugin ¶
func (l *FileSystemLoader) LoadPlugin(ctx context.Context, pluginDir string) (*pluginmodel.PluginInfo, error)
LoadPlugin loads a single plugin from a directory path. Reads the plugin.yaml manifest and creates PluginInfo with status=StatusLoaded.
func (*FileSystemLoader) ValidatePlugin ¶
func (l *FileSystemLoader) ValidatePlugin(info *pluginmodel.PluginInfo) error
ValidatePlugin checks if a discovered plugin is valid and compatible. Validates manifest fields, capabilities, and AWF version constraint.
type GitHubReleaseClient ¶ added in v0.5.0
type GitHubReleaseClient struct {
// contains filtered or unexported fields
}
GitHubReleaseClient fetches and resolves releases from GitHub.
func NewGitHubReleaseClient ¶ added in v0.5.0
func NewGitHubReleaseClient(doer httpDoer) *GitHubReleaseClient
NewGitHubReleaseClient creates a new GitHub release client. If doer is nil, uses the default http.DefaultClient.
func (*GitHubReleaseClient) ListReleases ¶ added in v0.5.0
func (c *GitHubReleaseClient) ListReleases(ctx context.Context, ownerRepo string) ([]Release, error)
ListReleases fetches all releases for an owner/repo from GitHub API.
func (*GitHubReleaseClient) ResolveVersion ¶ added in v0.5.0
func (c *GitHubReleaseClient) ResolveVersion(ctx context.Context, ownerRepo, constraintStr string, includePrerelease bool) (Version, error)
ResolveVersion resolves the best matching version from available releases. constraintStr: empty string or version constraint like ">=1.0.0 <2.0.0" includePrerelease: if true, includes pre-release versions
type JSONPluginStateStore ¶
type JSONPluginStateStore struct {
// contains filtered or unexported fields
}
JSONPluginStateStore persists plugin states to a JSON file. Implements ports.PluginStateStore interface.
func NewJSONPluginStateStore ¶
func NewJSONPluginStateStore(basePath string) *JSONPluginStateStore
NewJSONPluginStateStore creates a new JSONPluginStateStore.
func (*JSONPluginStateStore) BasePath ¶
func (s *JSONPluginStateStore) BasePath() string
BasePath returns the storage directory path.
func (*JSONPluginStateStore) GetConfig ¶
func (s *JSONPluginStateStore) GetConfig(name string) map[string]any
GetConfig returns the stored configuration for a plugin. Returns nil if plugin has no stored configuration.
func (*JSONPluginStateStore) GetSourceData ¶ added in v0.5.0
func (s *JSONPluginStateStore) GetSourceData(name string) map[string]any
GetSourceData returns the stored source metadata for a plugin. Returns nil if plugin has no stored source data.
func (*JSONPluginStateStore) GetState ¶
func (s *JSONPluginStateStore) GetState(name string) *pluginmodel.PluginState
GetState returns the full state for a plugin, or nil if not found.
func (*JSONPluginStateStore) IsEnabled ¶
func (s *JSONPluginStateStore) IsEnabled(name string) bool
IsEnabled returns whether a plugin is enabled. Returns true for unknown plugins (enabled by default).
func (*JSONPluginStateStore) ListDisabled ¶
func (s *JSONPluginStateStore) ListDisabled() []string
ListDisabled returns names of all explicitly disabled plugins.
func (*JSONPluginStateStore) Load ¶
func (s *JSONPluginStateStore) Load(ctx context.Context) error
Load reads plugin states from storage.
func (*JSONPluginStateStore) RemoveState ¶ added in v0.5.0
func (s *JSONPluginStateStore) RemoveState(ctx context.Context, name string) error
RemoveState removes all state entries for a plugin name.
func (*JSONPluginStateStore) Save ¶
func (s *JSONPluginStateStore) Save(ctx context.Context) error
Save persists all plugin states to storage with atomic write.
func (*JSONPluginStateStore) SetConfig ¶
func (s *JSONPluginStateStore) SetConfig(ctx context.Context, name string, config map[string]any) error
SetConfig stores configuration for a plugin.
func (*JSONPluginStateStore) SetEnabled ¶
SetEnabled enables or disables a plugin by name.
func (*JSONPluginStateStore) SetSourceData ¶ added in v0.5.0
func (s *JSONPluginStateStore) SetSourceData(ctx context.Context, name string, data map[string]any) error
SetSourceData stores source metadata for a plugin.
type LoaderError ¶
type LoaderError struct {
Path string // plugin directory path
Op string // operation (discover, load, validate)
Message string // error message
Cause error // underlying error
}
LoaderError represents an error during plugin loading operations.
func NewLoaderError ¶
func NewLoaderError(op, path, message string) *LoaderError
NewLoaderError creates a new LoaderError.
func WrapLoaderError ¶
func WrapLoaderError(op, path string, cause error) *LoaderError
WrapLoaderError wraps an existing error as a LoaderError.
func (*LoaderError) Error ¶
func (e *LoaderError) Error() string
Error implements the error interface.
func (*LoaderError) Unwrap ¶
func (e *LoaderError) Unwrap() error
Unwrap returns the underlying error.
type ManifestParseError ¶
type ManifestParseError struct {
File string // file path
Field string // field path (e.g., "config.webhook_url")
Message string // error message
Cause error // underlying error
}
ManifestParseError represents an error during plugin manifest parsing.
func NewManifestParseError ¶
func NewManifestParseError(file, field, message string) *ManifestParseError
NewManifestParseError creates a new ManifestParseError with field and message.
func WrapManifestParseError ¶
func WrapManifestParseError(file string, cause error) *ManifestParseError
WrapManifestParseError wraps an existing error as a ManifestParseError.
func (*ManifestParseError) Error ¶
func (e *ManifestParseError) Error() string
Error implements the error interface.
func (*ManifestParseError) Unwrap ¶
func (e *ManifestParseError) Unwrap() error
Unwrap returns the underlying error.
type ManifestParser ¶
type ManifestParser struct{}
ManifestParser parses plugin manifests from YAML files.
func NewManifestParser ¶
func NewManifestParser() *ManifestParser
NewManifestParser creates a new ManifestParser.
func (*ManifestParser) Parse ¶
func (p *ManifestParser) Parse(r io.Reader) (*pluginmodel.Manifest, error)
Parse reads and parses a plugin manifest from an io.Reader.
func (*ManifestParser) ParseFile ¶
func (p *ManifestParser) ParseFile(path string) (*pluginmodel.Manifest, error)
ParseFile reads and parses a plugin manifest from a file path.
type OperationRegistry ¶
type OperationRegistry struct {
// contains filtered or unexported fields
}
OperationRegistry manages registration of plugin-provided operations. Thread-safe for concurrent access.
func NewOperationRegistry ¶
func NewOperationRegistry() *OperationRegistry
NewOperationRegistry creates a new empty operation registry.
func (*OperationRegistry) Clear ¶
func (r *OperationRegistry) Clear()
Clear removes all registered operations. Useful for testing.
func (*OperationRegistry) Count ¶
func (r *OperationRegistry) Count() int
Count returns the total number of registered operations.
func (*OperationRegistry) GetOperation ¶
func (r *OperationRegistry) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation by name. Returns nil and false if the operation is not found.
func (*OperationRegistry) GetOperationSource ¶
func (r *OperationRegistry) GetOperationSource(operationName string) (string, bool)
GetOperationSource returns the plugin name that registered an operation. Returns empty string and false if the operation is not found.
func (*OperationRegistry) GetPluginOperations ¶
func (r *OperationRegistry) GetPluginOperations(pluginName string) []*pluginmodel.OperationSchema
GetPluginOperations returns all operations registered by a specific plugin.
func (*OperationRegistry) Operations ¶
func (r *OperationRegistry) Operations() []*pluginmodel.OperationSchema
Operations returns all registered operations as a slice. Returns an empty slice if no operations are registered.
func (*OperationRegistry) RegisterOperation ¶
func (r *OperationRegistry) RegisterOperation(op *pluginmodel.OperationSchema) error
RegisterOperation adds a plugin operation to the registry. Returns ErrOperationAlreadyRegistered if an operation with the same name exists. Returns ErrInvalidOperation if the operation schema is nil or has no name.
func (*OperationRegistry) UnregisterOperation ¶
func (r *OperationRegistry) UnregisterOperation(name string) error
UnregisterOperation removes a plugin operation from the registry. Returns ErrOperationNotFound if the operation is not registered.
func (*OperationRegistry) UnregisterPluginOperations ¶
func (r *OperationRegistry) UnregisterPluginOperations(pluginName string) error
UnregisterPluginOperations removes all operations provided by a specific plugin. Useful when unloading or disabling a plugin.
type PluginInstaller ¶ added in v0.5.0
type PluginInstaller struct {
// contains filtered or unexported fields
}
PluginInstaller handles downloading, verifying, extracting, and atomically installing plugins from GitHub releases.
func NewPluginInstaller ¶ added in v0.5.0
func NewPluginInstaller(optionalClient ...httpx.HTTPDoer) *PluginInstaller
NewPluginInstaller creates a new PluginInstaller with optional client injection. If client is nil, uses a default *http.Client.
func (*PluginInstaller) AtomicInstall ¶ added in v0.5.0
func (pi *PluginInstaller) AtomicInstall(tempDir, targetDir string) error
AtomicInstall performs an atomic installation by moving a temp directory to the final location. tempDir: temporary directory with extracted plugin files targetDir: final plugin installation directory Returns error if installation fails; targetDir is rolled back on failure.
func (*PluginInstaller) Download ¶ added in v0.5.0
Download downloads a plugin binary from a URL. Returns the downloaded content as bytes, or an error. ctx: context for cancellation url: download URL checksum: expected SHA-256 checksum (hex string)
func (*PluginInstaller) ExtractTarGz ¶ added in v0.5.0
func (pi *PluginInstaller) ExtractTarGz(data []byte, targetDir string) error
ExtractTarGz extracts a tar.gz archive to a target directory. data: the tar.gz archive bytes targetDir: directory where files will be extracted Returns error if extraction fails.
func (*PluginInstaller) Install ¶ added in v0.5.0
func (pi *PluginInstaller) Install(ctx context.Context, url, checksum, targetDir string, force bool) error
Install downloads, verifies, extracts, and installs a plugin. Performs atomic installation with rollback on failure. Validates manifest exists after extraction. Rejects installation if plugin already exists (unless force=true).
ctx: context for cancellation url: download URL of plugin archive checksum: expected SHA-256 checksum (hex string) targetDir: directory where plugin will be installed force: if true, overwrites existing plugin directory
Returns error if: - Plugin already exists and force=false - Download fails - Checksum verification fails - Extraction fails - Manifest validation fails - Installation fails
func (*PluginInstaller) ValidateManifest ¶ added in v0.5.0
func (pi *PluginInstaller) ValidateManifest(dir string) error
ValidateManifest checks that a plugin directory contains a valid manifest file. dir: plugin directory to validate Returns error if manifest is missing or invalid.
func (*PluginInstaller) VerifyChecksum ¶ added in v0.5.0
func (pi *PluginInstaller) VerifyChecksum(data []byte, checksum string) error
VerifyChecksum verifies that data matches the expected SHA-256 checksum. data: the bytes to verify checksum: the expected SHA-256 checksum (hex string) Returns error if verification fails.
type PluginSource ¶ added in v0.5.0
type PluginSource struct {
Repository string `json:"repository"` // e.g., "owner/repo"
Version string `json:"version"` // e.g., "1.2.3"
InstalledAt time.Time `json:"installed_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginSource represents the origin and installation metadata of an external plugin. Serialized to PluginState.SourceData for persistence.
func PluginSourceFromSourceData ¶ added in v0.5.0
func PluginSourceFromSourceData(sourceData map[string]any) (PluginSource, error)
PluginSourceFromSourceData deserializes SourceData from PluginState into a PluginSource.
type RPCManagerError ¶
type RPCManagerError struct {
Op string // operation (load, init, shutdown)
Plugin string // plugin name
Message string // error message
Cause error // underlying error
}
RPCManagerError represents an error during plugin lifecycle operations.
func NewRPCManagerError ¶
func NewRPCManagerError(op, pluginName, message string) *RPCManagerError
NewRPCManagerError creates a new RPCManagerError.
func WrapRPCManagerError ¶
func WrapRPCManagerError(op, pluginName string, cause error) *RPCManagerError
WrapRPCManagerError wraps an existing error as an RPCManagerError.
func (*RPCManagerError) Error ¶
func (e *RPCManagerError) Error() string
Error implements the error interface.
func (*RPCManagerError) Unwrap ¶
func (e *RPCManagerError) Unwrap() error
Unwrap returns the underlying error.
type RPCPluginManager ¶
type RPCPluginManager struct {
// contains filtered or unexported fields
}
RPCPluginManager implements PluginManager using HashiCorp go-plugin for RPC. It manages plugin lifecycle: discovery, loading, initialization, and shutdown.
func NewRPCPluginManager ¶
func NewRPCPluginManager(loader *FileSystemLoader) *RPCPluginManager
NewRPCPluginManager creates a new RPCPluginManager.
func (*RPCPluginManager) Discover ¶
func (m *RPCPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
Discover finds plugins in the plugins directory. Returns ErrNoPluginsConfigured if no loader or plugins directory is configured.
func (*RPCPluginManager) Execute ¶
func (m *RPCPluginManager) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
Execute delegates an operation call to the correct connected plugin via gRPC. Name format is "pluginName.operationName" (consistent with built-in providers). If unprefixed, iterates all connections as fallback.
func (*RPCPluginManager) Get ¶
func (m *RPCPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
Get returns plugin info by name. Returns (nil, false) if plugin not found.
func (*RPCPluginManager) GetOperation ¶
func (m *RPCPluginManager) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation schema by name, searching all connected plugins. Name format is "pluginName.operationName" (consistent with built-in providers). Uses an internal 5s timeout per call because the port interface does not accept ctx.
func (*RPCPluginManager) List ¶
func (m *RPCPluginManager) List() []*pluginmodel.PluginInfo
List returns all known plugins.
func (*RPCPluginManager) ListOperations ¶
func (m *RPCPluginManager) ListOperations() []*pluginmodel.OperationSchema
ListOperations returns all operation schemas from all connected plugins. Calls gRPC ListOperations on each connection; skips plugins that fail. Uses an internal 5s timeout per call because the port interface does not accept ctx.
func (*RPCPluginManager) Load ¶
func (m *RPCPluginManager) Load(ctx context.Context, name string) error
Load loads a plugin by name. The plugin must have been discovered first, or a pluginsDir must be configured.
func (*RPCPluginManager) SetPluginsDir ¶
func (m *RPCPluginManager) SetPluginsDir(dir string)
SetPluginsDir sets the directory to discover plugins from. SetPluginsDir configures a single plugin directory (replaces any previous config).
func (*RPCPluginManager) SetPluginsDirs ¶ added in v0.5.0
func (m *RPCPluginManager) SetPluginsDirs(dirs []string)
SetPluginsDirs configures multiple plugin directories to scan. Plugins are discovered from all directories; first-found wins on name conflicts.
func (*RPCPluginManager) Shutdown ¶
func (m *RPCPluginManager) Shutdown(ctx context.Context, name string) error
Shutdown stops a running plugin gracefully. Full implementation: gRPC Shutdown call, client.Kill(), connection cleanup from m.connections.
func (*RPCPluginManager) ShutdownAll ¶
func (m *RPCPluginManager) ShutdownAll(ctx context.Context) error
ShutdownAll stops all running plugins with a 5s per-plugin deadline. Errors are accumulated via errors.Join() so all plugins are attempted even on partial failure.
func (*RPCPluginManager) StepTypeProvider ¶ added in v0.5.0
func (m *RPCPluginManager) StepTypeProvider(logger ports.Logger) ports.StepTypeProvider
StepTypeProvider returns a StepTypeProvider wrapping all step-type-capable plugins. Returns nil when no plugins have declared the step_types capability.
func (*RPCPluginManager) ValidatorProvider ¶ added in v0.5.0
func (m *RPCPluginManager) ValidatorProvider(timeout time.Duration) ports.WorkflowValidatorProvider
ValidatorProvider returns a WorkflowValidatorProvider wrapping all validator-capable plugins. Returns nil when no plugins have declared the validators capability.
type Release ¶ added in v0.5.0
type Release struct {
TagName string `json:"tag_name"`
Prerelease bool `json:"prerelease"`
URL string `json:"url"`
Assets []Asset `json:"assets"`
}
Release represents a GitHub release.
type Version ¶
type Version struct {
Major int // Major version number
Minor int // Minor version number
Patch int // Patch version number
Prerelease string // Prerelease identifier (e.g., "alpha.1")
}
Version represents a parsed semantic version.
func ParseVersion ¶
ParseVersion parses a version string into a Version struct. Accepts formats: "1.0.0", "1.0.0-alpha.1"
func (Version) Compare ¶
Compare compares this version to another. Returns -1 if v < other, 0 if v == other, 1 if v > other.
func (Version) IsPrerelease ¶ added in v0.5.0
IsPrerelease returns true if this version has a prerelease identifier.