sdk

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Overview

Package sdk provides the public API for building external workflow plugins. Plugin authors implement the interfaces defined here and call Serve() to run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(provider PluginProvider)

Serve is the entry point for plugin authors. It starts the gRPC plugin server and blocks until the host process terminates the connection.

If provider implements UIProvider, Serve writes a "ui.json" file to the current working directory (if one does not already exist). Plugin authors can also maintain "ui.json" manually without implementing UIProvider.

Usage:

func main() {
    sdk.Serve(&myPlugin{})
}

Types

type ConfigField added in v0.1.5

type ConfigField struct {
	Name         string
	Type         string
	Description  string
	DefaultValue string
	Required     bool
	Options      []string
}

ConfigField describes a configuration field.

type MessageAwareModule added in v0.1.5

type MessageAwareModule interface {
	SetMessagePublisher(pub MessagePublisher)
	SetMessageSubscriber(sub MessageSubscriber)
}

MessageAwareModule is optionally implemented by ModuleInstance to receive message capabilities.

type MessagePublisher added in v0.1.5

type MessagePublisher interface {
	Publish(topic string, payload []byte, metadata map[string]string) (messageID string, err error)
}

MessagePublisher is provided to modules that need to send messages to the host.

type MessageSubscriber added in v0.1.5

type MessageSubscriber interface {
	Subscribe(topic string, handler func(payload []byte, metadata map[string]string) error) error
	Unsubscribe(topic string) error
}

MessageSubscriber is provided to modules that need to receive messages from the host.

type ModuleInstance

type ModuleInstance interface {
	Init() error
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

ModuleInstance is a remote module's lifecycle.

type ModuleProvider

type ModuleProvider interface {
	// ModuleTypes returns the module type names this plugin provides.
	ModuleTypes() []string
	// CreateModule creates a module instance of the given type.
	CreateModule(typeName, name string, config map[string]any) (ModuleInstance, error)
}

ModuleProvider is optionally implemented to provide module types.

type ModuleSchemaData added in v0.1.5

type ModuleSchemaData struct {
	Type         string
	Label        string
	Category     string
	Description  string
	Inputs       []ServiceIO
	Outputs      []ServiceIO
	ConfigFields []ConfigField
}

ModuleSchemaData describes a module type for the UI.

type PluginManifest

type PluginManifest struct {
	Name        string
	Version     string
	Author      string
	Description string
}

PluginManifest describes the plugin.

type PluginProvider

type PluginProvider interface {
	// Manifest returns the plugin's metadata.
	Manifest() PluginManifest
}

PluginProvider is the main interface plugin authors implement.

type SchemaProvider added in v0.1.5

type SchemaProvider interface {
	ModuleSchemas() []ModuleSchemaData
}

SchemaProvider is optionally implemented to provide UI schemas.

type ServiceIO added in v0.1.5

type ServiceIO struct {
	Name        string
	Type        string
	Description string
}

ServiceIO describes a service input or output.

type StepInstance

type StepInstance interface {
	Execute(ctx context.Context, triggerData map[string]any, stepOutputs map[string]map[string]any, current map[string]any, metadata map[string]any) (*StepResult, error)
}

StepInstance is a remote pipeline step.

type StepProvider

type StepProvider interface {
	// StepTypes returns the step type names this plugin provides.
	StepTypes() []string
	// CreateStep creates a step instance of the given type.
	CreateStep(typeName, name string, config map[string]any) (StepInstance, error)
}

StepProvider is optionally implemented to provide step types.

type StepResult

type StepResult struct {
	Output       map[string]any
	StopPipeline bool
}

StepResult is the output of a step execution.

type TriggerCallback added in v0.1.5

type TriggerCallback func(action string, data map[string]any) error

TriggerCallback allows a trigger to fire workflow actions on the host.

type TriggerInstance added in v0.1.5

type TriggerInstance interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
}

TriggerInstance is a remote trigger's lifecycle.

type TriggerProvider added in v0.1.5

type TriggerProvider interface {
	TriggerTypes() []string
	CreateTrigger(typeName string, config map[string]any, cb TriggerCallback) (TriggerInstance, error)
}

TriggerProvider is optionally implemented by plugins that provide trigger types.

type UIProvider added in v0.1.1

type UIProvider interface {
	// UIManifest returns the UI manifest for this plugin.
	UIManifest() ext.UIManifest
}

UIProvider is an optional interface that PluginProvider implementations can satisfy to declare UI assets and navigation contributions.

If a PluginProvider implements UIProvider, the SDK Serve() function will write a "ui.json" file to the plugin's working directory on first start (if one does not already exist). Alternatively, authors can maintain "ui.json" manually without implementing this interface.

Type aliases

The UI manifest types (UIManifest, UINavItem) are defined in the github.com/GoCodeAlone/workflow/plugin/external package so that both the host engine and plugin processes share the same type definitions without introducing an import cycle.

Jump to

Keyboard shortcuts

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