plugins

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenericBinaryPrefix = "nucleus-plugin-"
	DefaultProbeTimeout = 2 * time.Second
)
View Source
const (
	EnvelopeVersionV1 = "v1"

	CapabilityMailSend       = "mail.send"
	CapabilityQueuePublish   = "queue.publish"
	CapabilityWebhookDeliver = "webhook.deliver"
)
View Source
const (
	ExitCodeSuccess    = 0
	ExitCodeValidation = 10
	ExitCodeTransient  = 20
	ExitCodeRejected   = 30
	ExitCodeTimeout    = 40
	ExitCodeInternal   = 50
)

Variables

This section is empty.

Functions

func IsExecutableFile

func IsExecutableFile(path string, entry os.DirEntry) (bool, error)

func ParseProviderFromBinary

func ParseProviderFromBinary(name, prefix string) (string, bool)

func ProbeCapabilities

func ProbeCapabilities(ctx context.Context, binaryPath string, timeout time.Duration) ([]string, error)

func SupportsCapability

func SupportsCapability(desc Descriptor, capability string) bool

Types

type Descriptor

type Descriptor struct {
	Provider     string   `json:"provider"`
	Capabilities []string `json:"capabilities"`
	Source       Source   `json:"source"`
	BinaryPath   string   `json:"binary_path,omitempty"`
	ProbeError   string   `json:"probe_error,omitempty"`
}

func BuiltinMailDescriptorsFromProviders

func BuiltinMailDescriptorsFromProviders(providers []string) []Descriptor

func CollectInventory

func CollectInventory(pathEnv string, builtinMailProviders []string, probeTimeout time.Duration) []Descriptor

func DiscoverExternal

func DiscoverExternal(pathEnv string, probeTimeout time.Duration) []Descriptor

type ExecutionError

type ExecutionError struct {
	ExitCode  int
	Retriable bool
	Code      string
	Message   string
	Stderr    string
	Cause     error
}

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

func (*ExecutionError) Unwrap

func (e *ExecutionError) Unwrap() error

type Host

type Host interface {
	CollectInventory(pathEnv string, builtinMailProviders []string, probeTimeout time.Duration) []Descriptor
	ProbeCapabilities(ctx context.Context, binaryPath string, timeout time.Duration) ([]string, error)
	ExecuteRequest(ctx context.Context, binaryPath string, request RequestEnvelope, timeout time.Duration) (ResponseEnvelope, error)
}

Host is the stable plugin runtime contract exposed by Nucleus. It allows callers to discover providers, probe capabilities, and execute capability requests independently from the underlying transport/runtime.

type LocalHost

type LocalHost struct{}

LocalHost is the default Host implementation backed by local executables.

func (LocalHost) CollectInventory

func (LocalHost) CollectInventory(pathEnv string, builtinMailProviders []string, probeTimeout time.Duration) []Descriptor

func (LocalHost) ExecuteRequest

func (LocalHost) ExecuteRequest(ctx context.Context, binaryPath string, request RequestEnvelope, timeout time.Duration) (ResponseEnvelope, error)

func (LocalHost) ProbeCapabilities

func (LocalHost) ProbeCapabilities(ctx context.Context, binaryPath string, timeout time.Duration) ([]string, error)

type MailSendOutput

type MailSendOutput struct {
	Accepted          bool   `json:"accepted"`
	ProviderRequestID string `json:"provider_request_id,omitempty"`
}

func DecodeMailSendOutput

func DecodeMailSendOutput(raw json.RawMessage) (MailSendOutput, error)

type MailSendPayload

type MailSendPayload struct {
	From    string            `json:"from"`
	To      []string          `json:"to"`
	Subject string            `json:"subject"`
	Body    string            `json:"body"`
	Headers map[string]string `json:"headers,omitempty"`
}

type QueuePublishOutput

type QueuePublishOutput struct {
	Accepted  bool   `json:"accepted"`
	MessageID string `json:"message_id,omitempty"`
}

type QueuePublishPayload

type QueuePublishPayload struct {
	Topic   string            `json:"topic"`
	Key     string            `json:"key,omitempty"`
	Body    json.RawMessage   `json:"body"`
	Headers map[string]string `json:"headers,omitempty"`
}

type RequestEnvelope

type RequestEnvelope struct {
	Version    string            `json:"version"`
	RequestID  string            `json:"request_id"`
	Timestamp  string            `json:"timestamp"`
	Capability string            `json:"capability"`
	Provider   string            `json:"provider"`
	TimeoutMS  int64             `json:"timeout_ms"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	Payload    json.RawMessage   `json:"payload"`
}

func NewRequestEnvelope

func NewRequestEnvelope(provider, capability string, timeout time.Duration, payload any, metadata map[string]string) (RequestEnvelope, error)

type ResponseEnvelope

type ResponseEnvelope struct {
	Version           string           `json:"version"`
	RequestID         string           `json:"request_id,omitempty"`
	OK                bool             `json:"ok"`
	ProviderRequestID string           `json:"provider_request_id,omitempty"`
	Retriable         bool             `json:"retriable,omitempty"`
	Output            json.RawMessage  `json:"output,omitempty"`
	Error             *ResponseError   `json:"error,omitempty"`
	Metrics           *ResponseMetrics `json:"metrics,omitempty"`
}

func ExecuteRequest

func ExecuteRequest(ctx context.Context, binaryPath string, request RequestEnvelope, timeout time.Duration) (ResponseEnvelope, error)

type ResponseError

type ResponseError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type ResponseMetrics

type ResponseMetrics struct {
	DurationMS int64 `json:"duration_ms,omitempty"`
}

type Source

type Source string
const (
	SourceBuiltinMail     Source = "builtin_mail"
	SourceExternalGeneric Source = "external_generic"
)

type WebhookDeliverOutput

type WebhookDeliverOutput struct {
	Accepted   bool `json:"accepted"`
	StatusCode int  `json:"status_code,omitempty"`
}

type WebhookDeliverPayload

type WebhookDeliverPayload struct {
	URL       string            `json:"url"`
	Method    string            `json:"method,omitempty"`
	Headers   map[string]string `json:"headers,omitempty"`
	Body      string            `json:"body,omitempty"`
	TimeoutMS int64             `json:"timeout_ms,omitempty"`
}

Jump to

Keyboard shortcuts

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