pluginapi

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = "v1"

Variables

This section is empty.

Functions

func ErrTriggerRuntimeUnsupported

func ErrTriggerRuntimeUnsupported() error

func ErrUnknownNode

func ErrUnknownNode(nodeID string) error

Types

type ActionNode

type ActionNode interface {
	ValidateConfig(ctx context.Context, config json.RawMessage) error
	Execute(ctx context.Context, config json.RawMessage, input map[string]any) (any, error)
}

type Bundle

type Bundle struct {
	Info                   PluginInfo
	Actions                map[string]ActionNode
	Triggers               map[string]TriggerNode
	Tools                  map[string]ToolNode
	TriggerRuntimeProvider TriggerRuntimeProvider
}

func (*Bundle) Describe

func (b *Bundle) Describe(_ context.Context) (PluginInfo, error)

func (*Bundle) ExecuteAction

func (b *Bundle) ExecuteAction(ctx context.Context, nodeID string, config json.RawMessage, input map[string]any) (any, error)

func (*Bundle) ExecuteTool

func (b *Bundle) ExecuteTool(ctx context.Context, nodeID string, config json.RawMessage, args json.RawMessage, input map[string]any) (any, error)

func (*Bundle) OpenTriggerRuntime

func (b *Bundle) OpenTriggerRuntime(ctx context.Context) (TriggerRuntime, error)

func (*Bundle) ToolDefinition

func (b *Bundle) ToolDefinition(ctx context.Context, nodeID string, meta ToolNodeMetadata, config json.RawMessage) (*ToolDefinition, error)

func (*Bundle) ValidateConfig

func (b *Bundle) ValidateConfig(ctx context.Context, nodeID string, config json.RawMessage) error

type FieldOption

type FieldOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

type FieldSpec

type FieldSpec struct {
	Name               string        `json:"name"`
	Label              string        `json:"label"`
	Description        string        `json:"description,omitempty"`
	Type               FieldType     `json:"type"`
	Required           bool          `json:"required,omitempty"`
	Placeholder        string        `json:"placeholder,omitempty"`
	TemplateSupported  bool          `json:"template_supported,omitempty"`
	Options            []FieldOption `json:"options,omitempty"`
	DefaultStringValue string        `json:"default_string_value,omitempty"`
	DefaultBoolValue   *bool         `json:"default_bool_value,omitempty"`
	DefaultNumberValue *float64      `json:"default_number_value,omitempty"`
}

type FieldType

type FieldType string
const (
	FieldTypeString   FieldType = "string"
	FieldTypeTextarea FieldType = "textarea"
	FieldTypeNumber   FieldType = "number"
	FieldTypeBoolean  FieldType = "boolean"
	FieldTypeSelect   FieldType = "select"
	FieldTypeJSON     FieldType = "json"
)

type NodeKind

type NodeKind string
const (
	NodeKindAction  NodeKind = "action"
	NodeKindTrigger NodeKind = "trigger"
	NodeKindTool    NodeKind = "tool"
)

type NodeSpec

type NodeSpec struct {
	ID            string                 `json:"id"`
	Kind          NodeKind               `json:"kind"`
	Label         string                 `json:"label"`
	Description   string                 `json:"description,omitempty"`
	Icon          string                 `json:"icon,omitempty"`
	Color         string                 `json:"color,omitempty"`
	MenuPath      []string               `json:"menu_path,omitempty"`
	DefaultConfig map[string]any         `json:"default_config,omitempty"`
	Fields        []FieldSpec            `json:"fields,omitempty"`
	Outputs       []OutputHandle         `json:"outputs,omitempty"`
	OutputHints   []OutputHint           `json:"output_hints,omitempty"`
	Metadata      map[string]interface{} `json:"metadata,omitempty"`
}

type OutputHandle

type OutputHandle struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	Color string `json:"color,omitempty"`
}

type OutputHint

type OutputHint struct {
	Expression  string `json:"expression"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

type Plugin

type Plugin interface {
	Describe(ctx context.Context) (PluginInfo, error)
	ValidateConfig(ctx context.Context, nodeID string, config json.RawMessage) error
	ExecuteAction(ctx context.Context, nodeID string, config json.RawMessage, input map[string]any) (any, error)
	ToolDefinition(ctx context.Context, nodeID string, meta ToolNodeMetadata, config json.RawMessage) (*ToolDefinition, error)
	ExecuteTool(ctx context.Context, nodeID string, config json.RawMessage, args json.RawMessage, input map[string]any) (any, error)
	OpenTriggerRuntime(ctx context.Context) (TriggerRuntime, error)
}

type PluginInfo

type PluginInfo struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	Version    string     `json:"version"`
	APIVersion string     `json:"api_version"`
	Nodes      []NodeSpec `json:"nodes"`
}

type ToolDefinition

type ToolDefinition struct {
	Type     string   `json:"type"`
	Function ToolSpec `json:"function"`
}

type ToolNode

type ToolNode interface {
	ValidateConfig(ctx context.Context, config json.RawMessage) error
	ToolDefinition(ctx context.Context, meta ToolNodeMetadata, config json.RawMessage) (*ToolDefinition, error)
	ExecuteTool(ctx context.Context, config json.RawMessage, args json.RawMessage, input map[string]any) (any, error)
}

type ToolNodeMetadata

type ToolNodeMetadata struct {
	NodeID string `json:"node_id"`
	Label  string `json:"label"`
}

type ToolSpec

type ToolSpec struct {
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Parameters  map[string]any `json:"parameters,omitempty"`
}

type TriggerEvent

type TriggerEvent struct {
	SubscriptionID string `json:"subscription_id"`
	Payload        any    `json:"payload,omitempty"`
}

type TriggerNode

type TriggerNode interface {
	ValidateConfig(ctx context.Context, config json.RawMessage) error
}

type TriggerRuntime

type TriggerRuntime interface {
	SendSnapshot(ctx context.Context, snapshot TriggerSubscriptionSnapshot) error
	Recv(ctx context.Context) (*TriggerEvent, error)
	Close() error
}

type TriggerRuntimeProvider

type TriggerRuntimeProvider interface {
	OpenTriggerRuntime(ctx context.Context) (TriggerRuntime, error)
}

type TriggerSubscription

type TriggerSubscription struct {
	SubscriptionID string          `json:"subscription_id"`
	PipelineID     string          `json:"pipeline_id,omitempty"`
	NodeType       string          `json:"node_type,omitempty"`
	NodeID         string          `json:"node_id"`
	NodeInstanceID string          `json:"node_instance_id,omitempty"`
	Config         json.RawMessage `json:"config,omitempty"`
}

type TriggerSubscriptionSnapshot

type TriggerSubscriptionSnapshot struct {
	Subscriptions []TriggerSubscription `json:"subscriptions"`
}

Jump to

Keyboard shortcuts

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