{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sdk\n\nPackage sdk is the public runtime SDK for out-of-process Workflow plugins.\n\nPlugin binaries implement PluginProvider plus optional provider interfaces such as StepProvider, TypedStepProvider, ModuleProvider, ContractProvider, or CLIProvider. A typical main function constructs the provider and calls Serve:\n\n\tfunc main() {\n\t\tsdk.Serve(internal.NewProvider(),\n\t\t\tsdk.WithBuildVersion(sdk.ResolveBuildVersion(internal.Version)),\n\t\t)\n\t}\n\nPlugins that also expose CLI commands or build hooks can use ServePluginFull. IaC provider plugins should use ServeIaCPlugin so typed IaC gRPC services are registered and advertised consistently.\n\n## Variables\n\n```go\nvar ErrTypedContractNotHandled = errors.New(\"typed contract not handled\")\n```\nErrTypedContractNotHandled lets mixed typed/legacy providers decline a type so the server can fall back to the legacy provider path.\n\n## Functions\n\n```go\nfunc BuildContractRegistry(grpcSrv *grpc.Server) *pb.ContractRegistry\n```\nBuildContractRegistry enumerates the gRPC services registered on grpcSrv and returns a \\*pb.ContractRegistry with a SERVICE-kind ContractDescriptor for each one. Mode is set to CONTRACT\\_MODE\\_STRICT\\_PROTO so the host can distinguish typed IaC services from the legacy structpb-mode contracts produced by Module/Step/Trigger ContractProvider implementations.\n\nWhy this exists (per cycle 3 I-1 of the strict-contracts force-cutover design): wfctl needs a single mechanism to discover \"is the optional service registered on this plugin handle?\". Reusing the existing ContractRegistry shape keeps Module/Step/Trigger and IaC capability discovery on the same wire surface — no new server-reflection dependency required.\n\nThe helper is safe to call with a nil server; it returns an empty (but non-nil) ContractRegistry. Service descriptors are emitted in a deterministic alphabetical order so callers can rely on stable FileDescriptorSet-adjacent output for diff/compare operations and the wftest BDD test in Task 15.\n\nIaC plugin authors typically wire this into their ContractProvider implementation:\n\n\tfunc (p *plugin) ContractRegistry() *pb.ContractRegistry {\n\t    return sdk.BuildContractRegistry(p.grpcServer)\n\t}\n\nwhere p.grpcServer was captured inside the iacGRPCPlugin.GRPCServer callback at startup. The ContractProvider hook keeps the wfctl-side GetContractRegistry RPC path unchanged.\n\n```go\nfunc BuildContractRegistryForPlugin(grpcSrv *grpc.Server, namespacePrefix string) *pb.ContractRegistry\n```\nBuildContractRegistryForPlugin enumerates gRPC services registered on grpcSrv whose name STARTS WITH namespacePrefix and returns a \\*pb.ContractRegistry with one SERVICE-kind STRICT\\_PROTO ContractDescriptor per matching service. Filters out go-plugin infra services (PluginService, GRPCBroker, GRPCStdio, grpc.health.v1.Health) so downstream contract-diff (workflow#767) sees only plugin-owned services.\n\nSafe to call with nil server; returns empty (but non-nil) registry. Names alphabetically sorted for stable diff output.\n\nTypical caller: iacPluginServiceBridge.GetContractRegistry derives prefix from pb.IaCProviderRequired\\_ServiceDesc.ServiceName minus the \".IaCProviderRequired\" suffix so the filter cannot drift from the .proto package declaration.\n\nBuildContractRegistry (full-surface, no filter) is retained for callers that want every registered service.\n\n```go\nfunc BuildMessageContractRegistry(contracts ...MessageContract) (*pb.ContractRegistry, error)\n```\nBuildMessageContractRegistry returns a registry containing MESSAGE-kind descriptors. Descriptor-only plugins can expose these contracts statically in plugin.contracts.json; runtime-backed plugins can return the same shape from ContractRegistry for parity tests.\n\n```go\nfunc DispatchArgs(args []string, p PluginProvider, cli CLIProvider, hooks HookHandler, stdin io.Reader, stdout io.Writer) int\n```\nDispatchArgs is the testable core of ServePluginFull. It inspects args (which should be os.Args in production) and dispatches accordingly. stdin and stdout are used for hook payload I/O; pass os.Stdin/os.Stdout in production and an in-memory reader/writer in tests.\n\nReturns:\n\n  - \\-1 if no wfctl flag is present (caller should fall back to Serve)\n  - 0 on success\n  - \u003e0 on error\n\n```go\nfunc EmbedManifest(content []byte) (*pluginpkg.PluginManifest, error)\n```\nEmbedManifest parses plugin.json content (typically loaded via go:embed) into the canonical \\*plugin.PluginManifest type and runs the canonical Validate().\n\nValidate() requires ALL of: Name, Version, Author, Description (verified at plugin/manifest.go:183-201). A plugin.json missing any of these is rejected. This matches the same contract enforced by the engine's manager.go on disk load — there is no \"minimal\" path. If you cannot supply Author or Description at build time, the plugin should not ship a release.\n\nPlugin authors write:\n\n\t//go:embed plugin.json\n\tvar manifestJSON []byte\n\tvar manifest = sdk.MustEmbedManifest(manifestJSON)\n\nThe returned manifest is passed into sdk.Serve via WithManifestProvider, or into sdk.IaCServeOptions.ManifestProvider for ServeIaCPlugin. The SDK wires it into the appropriate GetManifest gRPC handler so the workflow engine sees a fully-populated manifest at plugin registration time.\n\nParses via the canonical \\*plugin.PluginManifest (camelCase JSON tags matching the plugin.json authoring convention), NOT directly into \\*pb.Manifest (which has snake\\_case proto JSON tags and would silently drop configMutable etc.).\n\nFor production code paths that need to recover from a missing/malformed plugin.json (e.g., plugins that ship with multiple manifest candidates), prefer EmbedManifest with explicit error handling over MustEmbedManifest. MustEmbedManifest panics at process startup, which surfaces misconfiguration loudly but is unrecoverable.\n\n```go\nfunc MustEmbedManifest(content []byte) *pluginpkg.PluginManifest\n```\nMustEmbedManifest panics on parse or validation error. Intended for package-level var initialization in plugin main packages — failure indicates a build-time misconfiguration that must be fixed before the binary ships.\n\nWARNING: panic semantics make this a process-startup canary. Plugin authors who need graceful degradation (e.g., to recover from a missing/malformed plugin.json in tooling-only code paths) should use EmbedManifest with explicit error handling instead.\n\n```go\nfunc RegisterAllIaCProviderServices(s *grpc.Server, provider any) error\n```\nRegisterAllIaCProviderServices uses Go type-assertion to register every typed IaC gRPC service that the provider satisfies, in a single call.\n\nREQUIRED service:\n\n\tpb.IaCProviderRequiredServer — every IaC plugin MUST implement every\n\tmethod on this interface. The type-assert here surfaces missing\n\tmethods at plugin-startup time as a clear error rather than at the\n\tfirst RPC dispatch with a generic \"unimplemented\" status.\n\nOPTIONAL services (auto-detected):\n\n\tpb.IaCProviderEnumeratorServer\n\tpb.IaCProviderDriftDetectorServer\n\tpb.IaCProviderCredentialRevokerServer\n\tpb.IaCProviderRegionListerServer\n\tpb.IaCProviderOwnershipServer\n\tpb.IaCProviderMigrationRepairerServer\n\tpb.IaCProviderValidatorServer\n\tpb.IaCProviderDriftConfigDetectorServer\n\tpb.IaCProviderLogCaptureServer\n\tpb.IaCProviderRunnerServer\n\tpb.IaCProviderJobCancelerServer\n\tpb.IaCRequirementDiscoveryServer\n\tpb.IaCProviderRequirementMapperServer\n\tpb.IaCStateBackendServer\n\tpb.ResourceSensitiveInputDeclarerServer\n\nNative interfaces.IaCProviderRunner and interfaces.IaCProviderJobCanceler are also registered through typed SDK bridges when no protobuf implementation exists. Cancellation is discovered independently; neither capability implies the other.\n\nResourceDriver:\n\n\tpb.ResourceDriverServer — separate gRPC service, also auto-registered\n\twhen the provider satisfies it.\n\nPer cycle 3 I-1 of the strict-contracts force-cutover design: plugin authors write ONE call; they cannot omit registration for a capability they implemented. That eliminates the registration-omission bug class (the same shape as the legacy InvokeService case-string-typo bug) by removing the manual step entirely.\n\nCapability discovery on the host side uses the existing ContractRegistry RPC + FileDescriptorSet mechanism (kept via §Salvage in the design); the SDK auto-publishes the registered services there in Task 5.\n\nPlugin authors who DO NOT want a capability advertised must NOT implement those methods at the Go level — there is no half-implemented stub-and-forget-to-register failure mode.\n\n```go\nfunc ResolveBuildVersion(declared string) string\n```\nResolveBuildVersion returns the operator-visible build-version string.\n\nWhen declared is non-empty AND not a known dev sentinel (\"\", \"dev\", \"(devel)\"), returns declared as-is. This is the typical path for goreleaser-built plugin binaries where the ldflag injects the release tag into a package-level Version var.\n\nOtherwise consults runtime/debug.ReadBuildInfo() as fallback:\n\n  - \"(devel) \\[@ shortsha\\[.dirty]]\" when vcs.revision is set\n  - \"(devel)\" when no VCS info\n\nIntended call sites (plugin author chooses ANY package-level Version var):\n\n\tvar Version = \"dev\"   // ldflag-injected at release time\n\n\tsdk.ServeIaCPlugin(srv, sdk.IaCServeOptions{\n\t    BuildVersion: sdk.ResolveBuildVersion(internal.Version),\n\t})\n\tsdk.Serve(p, sdk.WithManifestProvider(m),\n\t    sdk.WithBuildVersion(sdk.ResolveBuildVersion(internal.Version)))\n\nGoreleaser config provides the tag:\n\n\tldflags:\n\t  - -X github.com/\u003c...\u003e/internal.Version={{.Version}}\n\nMirrors the wfctl pattern at cmd/wfctl/main.go (var version = \"dev\" + debug.ReadBuildInfo() fallback). Closes workflow#758.\n\n```go\nfunc Serve(provider PluginProvider, opts ...ServeOption)\n```\nServe is the entry point for plugin authors. It starts the gRPC plugin server and blocks until the host process terminates the connection.\n\nIf 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.\n\nUsage:\n\n\tfunc main() {\n\t    sdk.Serve(\u0026myPlugin{})\n\t}\n\nWith disk-embedded manifest:\n\n\tfunc main() {\n\t    sdk.Serve(\u0026myPlugin{}, sdk.WithManifestProvider(manifest))\n\t}\n\n```go\nfunc ServeIaCPlugin(provider any, opts IaCServeOptions)\n```\nServeIaCPlugin starts a typed IaC plugin gRPC server with auto registration of every IaC service the provider satisfies. Plugin authors call this once in main.go:\n\n\tfunc main() {\n\t    sdk.ServeIaCPlugin(\u0026doProvider{}, sdk.IaCServeOptions{})\n\t}\n\nPer cycle 3 I-1 of the strict-contracts force-cutover design, the service registration happens INSIDE go-plugin's GRPCServer callback (see iacGRPCPlugin.GRPCServer), so plugin authors cannot pre-create a \\*grpc.Server and forget to register a typed service on it.\n\nBlocks until the host process terminates the connection. Panics on invalid IaCServeOptions (e.g., partial handshake override missing MagicCookieKey or MagicCookieValue) — see resolveServeHandshake. Plugin authors fix the misconfig at the call site; the panic is preferable to a silent fallback that produces a broken handshake at dial time.\n\n```go\nfunc ServePluginFull(p PluginProvider, cli CLIProvider, hooks HookHandler, opts ...ServeOption)\n```\nServePluginFull is the multi-mode entry point for plugin authors that use CLI commands and/or build-pipeline hook handlers in addition to the standard gRPC plugin server.\n\nDispatch rules (os.Args inspected at startup):\n\n 1. \\--wfctl-cli  → CLIProvider.RunCLI is called; process exits with its return code.\n 2. \\--wfctl-hook → HookHandler.HandleBuildHook is called with the event name and the JSON payload read from stdin; result is written to stdout; process exits 0.\n 3. Neither flag → falls through to the standard gRPC Serve(p).\n\nPlugins that don't need CLI/hook capabilities keep using Serve(p).\n\nUsage:\n\n\tfunc main() {\n\t    sdk.ServePluginFull(\u0026myPlugin{}, \u0026myCLI{}, \u0026myHooks{})\n\t}\n\nWith disk-embedded manifest:\n\n\tfunc main() {\n\t    sdk.ServePluginFull(\u0026myPlugin{}, \u0026myCLI{}, \u0026myHooks{},\n\t        sdk.WithManifestProvider(manifest))\n\t}\n\n## Types\n\n```go\ntype AssetProvider interface {\n\tGetAsset(path string) (content []byte, contentType string, err error)\n}\n```\nAssetProvider allows plugins to serve embedded static assets (e.g., UI files).\n\n```go\ntype CLIProvider interface {\n\t// RunCLI handles the command. args contains the command and all subsequent\n\t// arguments (the plugin binary path and the --wfctl-cli flag are stripped).\n\t// The return value becomes the process exit code.\n\tRunCLI(args []string) int\n}\n```\nCLIProvider is implemented by plugins that expose top-level wfctl subcommands. When wfctl detects a matching command it invokes the plugin binary with --wfctl-cli \\\u003ccommand\u003e \\[args...], and the plugin must exit with the returned code.\n\n```go\ntype ConfigField struct {\n\tName         string\n\tType         string\n\tDescription  string\n\tDefaultValue string\n\tRequired     bool\n\tOptions      []string\n}\n```\nConfigField describes a configuration field.\n\n```go\ntype ConfigProvider interface {\n\t// ConfigFragment returns YAML config to merge into the host config.\n\tConfigFragment() ([]byte, error)\n}\n```\nConfigProvider is optionally implemented by plugins that need to inject config (modules, workflows, triggers) into the host config before module registration.\n\n```go\ntype ContractProvider interface {\n\tContractRegistry() *pb.ContractRegistry\n}\n```\nContractProvider is optionally implemented to expose typed contract descriptors.\n\n```go\ntype HookHandler interface {\n\t// HandleBuildHook handles the given hook event.\n\t// payload is the raw JSON payload from wfctl.\n\t// result is the raw JSON response written back to wfctl.\n\t// A non-nil error causes wfctl to apply the plugin's on_hook_failure policy.\n\tHandleBuildHook(event string, payload []byte) (result []byte, err error)\n}\n```\nHookHandler is implemented by plugins that register build-pipeline hook handlers. When wfctl dispatches a hook event it invokes the plugin binary with --wfctl-hook \\\u003cevent\u003e, writes the JSON payload to stdin, and reads the JSON result from stdout.\n\n```go\ntype IaCServeOptions struct {\n\t// PluginInfo overrides the default handshake/metadata. When nil,\n\t// ServeIaCPlugin uses the canonical wfctl\u003c-\u003eplugin\n\t// handshake — required for compatibility with the workflow host).\n\tPluginInfo *PluginInfo\n\n\t// ManifestProvider, when set, is returned by the bridge's GetManifest\n\t// RPC. Typically populated via sdk.MustEmbedManifest from a go:embed-ed\n\t// plugin.json. When nil, GetManifest returns codes.Unimplemented and the\n\t// engine falls back to its manager.go-loaded plugin.json (workflow plan\n\t// Task 1).\n\tManifestProvider *pluginpkg.PluginManifest\n\n\t// BuildVersion, when non-empty, overrides any ManifestProvider.Version\n\t// in the GetManifest RPC response. Typically populated via\n\t// sdk.ResolveBuildVersion(\u003cplugin's ldflag-injected Version var\u003e) so\n\t// operator + engine observe the release tag at runtime even when the\n\t// committed plugin.json carries a dev sentinel (\"0.0.0\"). Closes\n\t// workflow#758.\n\tBuildVersion string\n\n\t// Modules supplies plugin-native module providers. When non-nil, the\n\t// bridge wires GetModuleTypes / CreateModule / InitModule / StartModule /\n\t// StopModule / DestroyModule to delegate to grpc_server.go's existing\n\t// PluginService implementation via a thin mapBackedProvider adapter.\n\t// Zero-value = current behavior (Unimplemented for those RPCs).\n\t// See decisions/0038.\n\tModules map[string]ModuleProvider\n\n\t// Steps supplies plugin-native step providers. Same wiring rationale as\n\t// Modules; values are sdk.StepProvider — the same interface non-IaC\n\t// plugins consume via sdk.Serve.\n\tSteps map[string]StepProvider\n\n\t// TypedModules supplies plugin-native module providers that implement the\n\t// strict-proto TypedModuleProvider surface (sdk.TypedModuleFactory or a\n\t// custom implementor). When non-nil, mapBackedProvider implements\n\t// TypedModuleProvider and grpc_server.go's CreateModule path dispatches\n\t// CreateTypedModule on the looked-up entry — passing the host-supplied\n\t// *anypb.Any TypedConfig directly to the typed factory's proto-message\n\t// unpack. The legacy Modules map remains supported alongside (the\n\t// dispatch is Typed-first, then legacy-fallback). See decisions/0039.\n\tTypedModules map[string]TypedModuleProvider\n\n\t// TypedSteps supplies plugin-native step providers that implement\n\t// TypedStepProvider. Same wiring rationale as TypedModules. See\n\t// decisions/0039.\n\tTypedSteps map[string]TypedStepProvider\n}\n```\nIaCServeOptions configures the IaC plugin gRPC server entrypoint.\n\nPlugin authors typically zero-value this; ServeIaCPlugin then uses the canonical host\\\u003c-\u003eplugin handshake. The struct exists as a forward-extension point so future metadata fields (PluginInfo) can be added without breaking the API.\n\n```go\ntype MessageAwareModule interface {\n\tSetMessagePublisher(pub MessagePublisher)\n\tSetMessageSubscriber(sub MessageSubscriber)\n}\n```\nMessageAwareModule is optionally implemented by ModuleInstance to receive message capabilities.\n\n```go\ntype MessageContract struct {\n\tContractType    string\n\tProtoPackage    string\n\tMessageNames    []string\n\tGoImportPath    string\n\tSchemaDigest    string\n\tProtocolVersion string\n}\n```\nMessageContract describes a descriptor-only protobuf message contract.\n\n```go\ntype MessagePublisher interface {\n\tPublish(topic string, payload []byte, metadata map[string]string) (messageID string, err error)\n}\n```\nMessagePublisher is provided to modules that need to send messages to the host.\n\n```go\ntype MessageSubscriber interface {\n\tSubscribe(topic string, handler func(payload []byte, metadata map[string]string) error) error\n\tUnsubscribe(topic string) error\n}\n```\nMessageSubscriber is provided to modules that need to receive messages from the host.\n\n```go\ntype ModuleInstance interface {\n\tInit() error\n\tStart(ctx context.Context) error\n\tStop(ctx context.Context) error\n}\n```\nModuleInstance is a remote module's lifecycle.\n\n```go\ntype ModuleProvider interface {\n\t// ModuleTypes returns the module type names this plugin provides.\n\tModuleTypes() []string\n\t// CreateModule creates a module instance of the given type.\n\tCreateModule(typeName, name string, config map[string]any) (ModuleInstance, error)\n}\n```\nModuleProvider is optionally implemented to provide module types.\n\n```go\ntype ModuleSchemaData struct {\n\tType         string\n\tLabel        string\n\tCategory     string\n\tDescription  string\n\tInputs       []ServiceIO\n\tOutputs      []ServiceIO\n\tConfigFields []ConfigField\n}\n```\nModuleSchemaData describes a module type for the UI.\n\n```go\ntype PluginInfo struct {\n\t// HandshakeConfig is the go-plugin handshake. Plugin authors should\n\t// leave this zero-valued to inherit the host (wfctl)\n\t// and plugin MUST agree on the cookie + protocol version, so override\n\t// only when implementing a non-workflow host.\n\tHandshakeConfig goplugin.HandshakeConfig\n}\n```\nPluginInfo carries the metadata that go-plugin needs to serve an IaC plugin. Currently only HandshakeConfig is meaningful; reserved as the extension point for future Name/Version metadata fields without breaking the IaCServeOptions API.\n\n```go\ntype PluginManifest struct {\n\t// Name is the canonical plugin name, usually workflow-plugin-\u003cshort-name\u003e.\n\tName string\n\t// Version is the operator-visible runtime version.\n\tVersion string\n\t// Author identifies the organization or person that maintains the plugin.\n\tAuthor string\n\t// Description is shown in registry and documentation output.\n\tDescription string\n\t// ConfigMutable reports whether tenants can override the config fragment.\n\tConfigMutable bool\n\t// SampleCategory marks sample/app plugins for grouped presentation.\n\tSampleCategory string\n}\n```\nPluginManifest is the runtime metadata a plugin returns to the host.\n\nFor release-built plugins, prefer sdk.WithBuildVersion with ResolveBuildVersion so Version reflects the Git tag injected by the build instead of the committed plugin.json sentinel.\n\n```go\ntype PluginProvider interface {\n\t// Manifest returns the plugin's metadata.\n\tManifest() PluginManifest\n}\n```\nPluginProvider is the minimum interface every external plugin implements.\n\n```go\ntype SchemaProvider interface {\n\tModuleSchemas() []ModuleSchemaData\n}\n```\nSchemaProvider is optionally implemented to provide UI schemas.\n\n```go\ntype ServeOption func(*grpcServer)\n```\nServeOption configures Serve and ServePluginFull.\n\n```go\nfunc WithBuildVersion(v string) ServeOption\n```\nWithBuildVersion sets the runtime build-version surfaced via GetManifest. Single-channel precedence: takes precedence over any ManifestProvider.Version or provider.Manifest().Version. Typically populated via sdk.ResolveBuildVersion(\\\u003cplugin's ldflag-injected Version var\u003e).\n\nRecommended pattern:\n\n\timport (\n\t    \"github.com/\u003c...\u003e/internal\"  // ldflag-injected Version var\n\t    sdk \"github.com/GoCodeAlone/workflow/plugin/external/sdk\"\n\t)\n\n\tfunc main() {\n\t    sdk.Serve(\u0026myPlugin{},\n\t        sdk.WithManifestProvider(manifest),\n\t        sdk.WithBuildVersion(sdk.ResolveBuildVersion(internal.Version)),\n\t    )\n\t}\n\nGoreleaser config injects the tag at build time:\n\n\tldflags:\n\t  - -X github.com/\u003c...\u003e/internal.Version={{.Version}}\n\nCloses workflow#758.\n\n```go\nfunc WithManifestProvider(m *pluginpkg.PluginManifest) ServeOption\n```\nWithManifestProvider wires a canonical \\*plugin.PluginManifest (typically loaded via sdk.EmbedManifest) into the gRPC GetManifest handler. When set, the disk-embedded manifest takes precedence over the provider's Manifest() method.\n\nRecommended pattern:\n\n\t//go:embed plugin.json\n\tvar manifestJSON []byte\n\tvar manifest = sdk.MustEmbedManifest(manifestJSON)\n\n\tfunc main() {\n\t    sdk.Serve(\u0026myProvider{}, sdk.WithManifestProvider(manifest))\n\t}\n\n```go\ntype ServiceContextInvoker interface {\n\tInvokeMethodContext(ctx context.Context, method string, args map[string]any) (map[string]any, error)\n}\n```\nServiceContextInvoker is optionally implemented by ModuleInstance to receive the gRPC request context for long-running service invocations.\n\n```go\ntype ServiceIO struct {\n\tName        string\n\tType        string\n\tDescription string\n}\n```\nServiceIO describes a service input or output.\n\n```go\ntype ServiceInvoker interface {\n\tInvokeMethod(method string, args map[string]any) (map[string]any, error)\n}\n```\nServiceInvoker is optionally implemented by ModuleInstance to handle service method invocations from the host. The host calls InvokeService with a method name and a map of arguments; the implementation dispatches to the appropriate logic and returns a result map.\n\n```go\ntype StepInstance interface {\n\tExecute(ctx context.Context, triggerData map[string]any, stepOutputs map[string]map[string]any, current map[string]any, metadata map[string]any, config map[string]any) (*StepResult, error)\n}\n```\nStepInstance is a remote pipeline step.\n\n```go\ntype StepProvider interface {\n\t// StepTypes returns the step type names this plugin provides.\n\tStepTypes() []string\n\t// CreateStep creates a step instance of the given type.\n\tCreateStep(typeName, name string, config map[string]any) (StepInstance, error)\n}\n```\nStepProvider is optionally implemented to provide step types.\n\n```go\ntype StepResult struct {\n\tOutput       map[string]any\n\tStopPipeline bool\n}\n```\nStepResult is the output of a step execution.\n\n```go\ntype TelemetryAttrs = telemetry.Attrs\n```\nTelemetryAttrs aliases the host telemetry attribute map type for plugin APIs.\n\n```go\ntype TelemetryLogEmitter = telemetry.LogEmitter\n```\nTelemetryLogEmitter aliases the host log emitter interface for plugin APIs.\n\n```go\ntype TelemetryLogRecord = telemetry.LogRecord\n```\nTelemetryLogRecord aliases the host log record type for plugin APIs.\n\n```go\ntype TelemetryMetricEmitter = telemetry.MetricEmitter\n```\nTelemetryMetricEmitter aliases the host metric emitter interface for plugin APIs.\n\n```go\ntype TelemetryMetricKind = telemetry.MetricKind\n```\nTelemetryMetricKind aliases the host metric kind enum for plugin APIs.\n\n```go\ntype TelemetryMetricRecord = telemetry.MetricRecord\n```\nTelemetryMetricRecord aliases the host metric record type for plugin APIs.\n\n```go\ntype TelemetryMetricRecorder = telemetry.MetricRecorder\n```\nTelemetryMetricRecorder aliases the host metric recorder interface for plugin APIs.\n\n```go\ntype TelemetrySpanEvent = telemetry.SpanEvent\n```\nTelemetrySpanEvent aliases the host span event type for plugin APIs.\n\n```go\ntype TelemetrySpanRecorder = telemetry.SpanRecorder\n```\nTelemetrySpanRecorder aliases the host span recorder interface for plugin APIs.\n\n```go\ntype TelemetryTraceAnnotator = telemetry.TraceAnnotator\n```\nTelemetryTraceAnnotator aliases the host trace annotator interface for plugin APIs.\n\n```go\ntype TriggerCallback func(action string, data map[string]any) error\n```\nTriggerCallback allows a trigger to fire workflow actions on the host.\n\n```go\ntype TriggerInstance interface {\n\tStart(ctx context.Context) error\n\tStop(ctx context.Context) error\n}\n```\nTriggerInstance is a remote trigger's lifecycle.\n\n```go\ntype TriggerProvider interface {\n\tTriggerTypes() []string\n\tCreateTrigger(typeName string, config map[string]any, cb TriggerCallback) (TriggerInstance, error)\n}\n```\nTriggerProvider is optionally implemented by plugins that provide trigger types.\n\n```go\ntype TypedModuleCreator[C proto.Message] func(name string, config C) (ModuleInstance, error)\n```\nTypedModuleCreator constructs a module after its typed config has been unpacked and validated.\n\n```go\ntype TypedModuleFactory[C proto.Message] struct {\n\t// contains filtered or unexported fields\n}\n```\nTypedModuleFactory is a single-module TypedModuleProvider implementation.\n\n```go\nfunc NewTypedModuleFactory[C proto.Message](\n\ttypeName string,\n\tconfigPrototype C,\n\tcreate TypedModuleCreator[C],\n) *TypedModuleFactory[C]\n```\nNewTypedModuleFactory returns a provider for one typed module type. The factory validates typed\\_config before invoking create.\n\n```go\nfunc (f *TypedModuleFactory[C]) CreateTypedModule(typeName, name string, config *anypb.Any) (ModuleInstance, error)\n```\n\n```go\nfunc (f *TypedModuleFactory[C]) TypedModuleTypes() []string\n```\n\n```go\ntype TypedModuleInstance[C proto.Message] struct {\n\tModuleInstance\n\t// contains filtered or unexported fields\n}\n```\nTypedModuleInstance adapts protobuf-typed module config while preserving the normal ModuleInstance lifecycle interface.\n\n```go\nfunc NewTypedModuleInstance[C proto.Message](configPrototype C, module ModuleInstance) *TypedModuleInstance[C]\n```\nNewTypedModuleInstance returns a ModuleInstance wrapper that can accept typed module config from CreateModuleRequest. The wrapped instance still owns the module lifecycle.\n\n```go\nfunc (m *TypedModuleInstance[C]) Init() error\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) InvokeMethod(method string, args map[string]any) (map[string]any, error)\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) InvokeTypedMethod(method string, input *anypb.Any) (*anypb.Any, error)\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) SetMessagePublisher(pub MessagePublisher)\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) SetMessageSubscriber(sub MessageSubscriber)\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) Start(ctx context.Context) error\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) Stop(ctx context.Context) error\n```\n\n```go\nfunc (m *TypedModuleInstance[C]) TypedConfig() C\n```\nTypedConfig returns the unpacked module config most recently supplied by the host.\n\n```go\ntype TypedModuleProvider interface {\n\tTypedModuleTypes() []string\n\tCreateTypedModule(typeName, name string, config *anypb.Any) (ModuleInstance, error)\n}\n```\nTypedModuleProvider creates protobuf-typed module instances after validating typed\\_config. Implement this instead of ModuleProvider for strict typed modules.\n\n```go\ntype TypedServiceInvoker interface {\n\tInvokeTypedMethod(method string, input *anypb.Any) (*anypb.Any, error)\n}\n```\nTypedServiceInvoker is optionally implemented by ModuleInstance to handle strict protobuf service method invocations from the host.\n\n```go\ntype TypedStepFactory[C proto.Message, I proto.Message, O proto.Message] struct {\n\t// contains filtered or unexported fields\n}\n```\nTypedStepFactory is a single-step TypedStepProvider implementation.\n\n```go\nfunc NewTypedStepFactory[C proto.Message, I proto.Message, O proto.Message](\n\ttypeName string,\n\tconfigPrototype C,\n\tinputPrototype I,\n\thandler TypedStepHandler[C, I, O],\n) *TypedStepFactory[C, I, O]\n```\nNewTypedStepFactory returns a provider for one typed step type. The factory validates typed\\_config before returning an instance, so failed creation does not leak a partially-created step into plugin-local state.\n\n```go\nfunc (f *TypedStepFactory[C, I, O]) CreateTypedStep(typeName, _ string, config *anypb.Any) (StepInstance, error)\n```\n\n```go\nfunc (f *TypedStepFactory[C, I, O]) TypedStepTypes() []string\n```\n\n```go\ntype TypedStepHandler[C proto.Message, I proto.Message, O proto.Message] func(context.Context, TypedStepRequest[C, I]) (*TypedStepResult[O], error)\n```\nTypedStepHandler executes a typed step with protobuf config and input.\n\n```go\ntype TypedStepInstance[C proto.Message, I proto.Message, O proto.Message] struct {\n\t// contains filtered or unexported fields\n}\n```\nTypedStepInstance adapts a protobuf-typed step implementation to the legacy StepInstance interface and the typed gRPC execution path.\n\n```go\nfunc NewTypedStepInstance[C proto.Message, I proto.Message, O proto.Message](\n\tconfigPrototype C,\n\tinputPrototype I,\n\thandler TypedStepHandler[C, I, O],\n) *TypedStepInstance[C, I, O]\n```\nNewTypedStepInstance returns a StepInstance that validates typed Any payloads before invoking handler. configPrototype and inputPrototype define the expected protobuf message types.\n\n```go\nfunc (s *TypedStepInstance[C, I, O]) Execute(context.Context, map[string]any, map[string]map[string]any, map[string]any, map[string]any, map[string]any) (*StepResult, error)\n```\nExecute keeps TypedStepInstance assignable to StepInstance. Typed plugins should normally execute through ExecuteStep with typed\\_input; legacy map-only execution cannot safely populate arbitrary protobuf messages.\n\n```go\ntype TypedStepProvider interface {\n\tTypedStepTypes() []string\n\tCreateTypedStep(typeName, name string, config *anypb.Any) (StepInstance, error)\n}\n```\nTypedStepProvider creates protobuf-typed step instances after validating typed\\_config. Implement this instead of StepProvider for strict typed steps.\n\n```go\ntype TypedStepRequest[C proto.Message, I proto.Message] struct {\n\tConfig C\n\tInput  I\n\n\tTriggerData map[string]any\n\tStepOutputs map[string]map[string]any\n\tCurrent     map[string]any\n\tMetadata    map[string]any\n}\n```\nTypedStepRequest is passed to typed step handlers after protobuf Any payloads have been validated and unpacked.\n\n```go\ntype TypedStepResult[O proto.Message] struct {\n\tOutput       O\n\tStopPipeline bool\n}\n```\nTypedStepResult is returned from typed step handlers and packed into Any.\n\n```go\ntype UIManifest = contract.UIManifest\n```\n\n```go\ntype UINavItem = contract.UINavItem\n```\n\n```go\ntype UIProvider interface {\n\t// UIManifest returns the UI manifest for this plugin.\n\tUIManifest() UIManifest\n}\n```\nUIProvider is an optional interface that PluginProvider implementations can satisfy to declare UI assets and navigation contributions.\n\nIf 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.\n\n### Type aliases {#hdr-Type_aliases}\n\nThe UI manifest types are aliases for the shared contract package so plugins can use the SDK without importing host-side external plugin adapters.\n\n","path":"github.com/GoCodeAlone/workflow/plugin/external/sdk","name":"sdk","synopsis":"Package sdk is the public runtime SDK for out-of-process Workflow plugins.","isRedistributable":true}
