{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package external\n\nPackage external provides gRPC-based external plugin support for the workflow engine. External plugins run as separate processes communicating over gRPC via hashicorp/go-plugin.\n\n## Constants\n\n```go\nconst (\n\t// ProtocolVersion is the plugin protocol version.\n\t// Increment this when making breaking changes to the gRPC interface.\n\tProtocolVersion = contract.ProtocolVersion\n\n\t// MagicCookieKey is the environment variable used for the handshake.\n\tMagicCookieKey = contract.MagicCookieKey\n\n\t// MagicCookieValue is the expected value for the handshake cookie.\n\tMagicCookieValue = contract.MagicCookieValue\n)\n```\n\n## Variables\n\n```go\nvar Handshake = contract.Handshake\n```\nHandshake is the shared handshake configuration between host and plugins. Both the host (client) and plugin (server) must use identical values.\n\n## Functions\n\n```go\nfunc AsModuleError(m modular.Module) error\n```\nAsModuleError returns the wrapped error if m was produced by a failed CreateModule call (i.e. the factory returned an \\*errorModule), or nil if m is a successfully-created module. Callers outside this package use this to surface plugin-reported errors without depending on the unexported type.\n\n```go\nfunc NewErrorModule(name string, err error) modular.Module\n```\nNewErrorModule returns a Module that surfaces err from Init and Start. Exported for use in tests that need to simulate a plugin factory failure without importing the unexported errorModule type directly.\n\n## Types\n\n```go\ntype CallbackServer struct {\n\tpb.UnimplementedEngineCallbackServiceServer\n\t// contains filtered or unexported fields\n}\n```\nCallbackServer implements the EngineCallbackService gRPC server. It runs on the host and is called by plugin processes.\n\n```go\nfunc NewCallbackServer(onTrigger TriggerFunc, lookup ServiceLookupFunc, logger *log.Logger) *CallbackServer\n```\nNewCallbackServer creates a new callback server.\n\n```go\nfunc (s *CallbackServer) GetService(_ context.Context, req *pb.GetServiceRequest) (*pb.GetServiceResponse, error)\n```\n\n```go\nfunc (s *CallbackServer) Log(_ context.Context, req *pb.LogRequest) (*emptypb.Empty, error)\n```\n\n```go\nfunc (s *CallbackServer) PublishMessage(_ context.Context, req *pb.PublishMessageRequest) (*pb.PublishMessageResponse, error)\n```\n\n```go\nfunc (s *CallbackServer) SetMessagePublishFunc(fn MessagePublishFunc)\n```\nSetMessagePublishFunc configures the callback for message publishing.\n\n```go\nfunc (s *CallbackServer) SetMessageSubscribeFunc(fn MessageSubscribeFunc)\n```\nSetMessageSubscribeFunc configures the callback for message subscriptions.\n\n```go\nfunc (s *CallbackServer) Subscribe(_ context.Context, req *pb.SubscribeRequest) (*pb.ErrorResponse, error)\n```\n\n```go\nfunc (s *CallbackServer) TriggerWorkflow(_ context.Context, req *pb.TriggerWorkflowRequest) (*pb.ErrorResponse, error)\n```\n\n```go\nfunc (s *CallbackServer) Unsubscribe(_ context.Context, req *pb.UnsubscribeRequest) (*pb.ErrorResponse, error)\n```\n\n```go\ntype ExternalPluginAdapter struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalPluginAdapter wraps a gRPC plugin client to implement plugin.EnginePlugin. The engine sees this as a regular plugin — no changes to engine.go needed.\n\n```go\nfunc NewExternalPluginAdapter(name string, client *PluginClient, diskManifest *plugin.PluginManifest) (*ExternalPluginAdapter, error)\n```\nNewExternalPluginAdapter creates an adapter from a connected plugin client. diskManifest is the \\*plugin.PluginManifest loaded by the manager at manager.go:108 via pluginpkg.LoadManifest + Validate. It is used as the canonical fallback when the plugin's gRPC GetManifest RPC returns codes.Unimplemented (strict-cutover IaC plugins) or an empty Version (defensive). Pass nil only in tests that exercise the no-disk fallback path; production callers must pass the manager-loaded manifest.\n\n```go\nfunc (a *ExternalPluginAdapter) Capabilities() []capability.Contract\n```\n\n```go\nfunc (a *ExternalPluginAdapter) ConfigFragmentBytes() []byte\n```\nConfigFragmentBytes returns the raw YAML config fragment fetched from the plugin.\n\n```go\nfunc (a *ExternalPluginAdapter) ConfigTransformHooks() []plugin.ConfigTransformHook\n```\n\n```go\nfunc (a *ExternalPluginAdapter) Conn() *grpc.ClientConn\n```\nConn returns the underlying gRPC client connection used to talk to the plugin process. Callers (notably wfctl's typed-IaC cutover in plan Task 16) construct additional typed gRPC service clients against this conn — for example \\`pb.NewIaCProviderRequiredClient(adapter.Conn())\\`.\n\nReturns nil in two cases:\n\n 1. The adapter was constructed without a backing PluginClient (e.g. \\`newExternalPluginAdapterWithContractRegistry\\` test fixtures populate manifest + registry directly without a gRPC subprocess).\n 2. The adapter has a non-nil PluginClient but its underlying PluginClient.Conn() is itself nil (in-process test plumbing that wires only the PluginServiceClient interface without a real \\*grpc.ClientConn).\n\nCallers MUST nil-check before constructing typed clients.\n\nThe connection lifecycle is owned by the host's plugin manager — callers MUST NOT call Close() on the returned conn. The plugin shutdown path tears it down via the registered Closer.\n\n```go\nfunc (a *ExternalPluginAdapter) ContractRegistry() *pb.ContractRegistry\n```\n\n```go\nfunc (a *ExternalPluginAdapter) ContractRegistryError() error\n```\n\n```go\nfunc (a *ExternalPluginAdapter) Dependencies() []plugin.PluginDependency\n```\n\n```go\nfunc (a *ExternalPluginAdapter) DeployTargets() map[string]deploy.DeployTarget\n```\n\n```go\nfunc (a *ExternalPluginAdapter) Description() string\n```\n\n```go\nfunc (a *ExternalPluginAdapter) EngineManifest() *plugin.PluginManifest\n```\n\n```go\nfunc (a *ExternalPluginAdapter) GetAsset(path string) ([]byte, string, error)\n```\nGetAsset fetches a static asset from the plugin by path.\n\n```go\nfunc (a *ExternalPluginAdapter) IaCStateBackendClients() (map[string]pb.IaCStateBackendClient, error)\n```\nIaCStateBackendClients implements plugin.IaCStateBackendProvider. At plugin-load the engine type-asserts the adapter against that interface and registers each returned (name → client) pair into module's iac.state backend registry. Amendment A2 (decisions/0035).\n\nBehaviour:\n\n  - If the plugin's ContractRegistry does not advertise the IaCStateBackend service: when the disk manifest declares a non-empty IaCStateBackends list, that is a silent misconfiguration (the plugin claims backends but the host would register none) — return an error so plugin-load fails loudly. When the manifest is also silent, the plugin genuinely serves no state backend — return (nil, nil); the engine type-assert still succeeds and just registers nothing.\n  - Otherwise call the live ListBackendNames RPC for the authoritative backend-name list and cross-check it against the plugin's declared PluginManifest.IaCStateBackends.\n\nCross-check decision: the RPC is the live source of truth. The manifest is only consulted as a declared-vs-served consistency guard — when the manifest declares a non-empty backend set, it MUST match the RPC result exactly (a plugin whose live RPC contradicts its declared manifest is misconfigured and is rejected). When the manifest is silent (no diskManifest, or an empty IaCStateBackends list — e.g. a strict-cutover plugin that left GetManifest unimplemented and whose plugin.json omits the field) the RPC result is accepted on its own.\n\n```go\nfunc (a *ExternalPluginAdapter) IsConfigMutable() bool\n```\nIsConfigMutable returns true if tenants can override the plugin's config fragment.\n\n```go\nfunc (a *ExternalPluginAdapter) IsSamplePlugin() bool\n```\nIsSamplePlugin returns true if the plugin declares a sample category.\n\n```go\nfunc (a *ExternalPluginAdapter) KubernetesBackendClients() (map[string]pb.ResourceDriverClient, error)\n```\nKubernetesBackendClients implements plugin.KubernetesBackendProvider. At plugin-load the engine type-asserts the adapter against that interface and registers each returned (cluster-type → ResourceDriver client) pair into module's kubernetes backend registry. Per ADR 0037.\n\nBehaviour:\n\n  - If the plugin does not advertise the ResourceDriver service it serves no kubernetes backend — return (nil, nil); the engine type-assert still succeeds and just registers nothing.\n  - Otherwise the live Capabilities RPC is the source of truth (mirroring how IaCStateBackendClients trusts the ListBackendNames RPC): when it declares the infra.k8s\\_cluster resource type, the plugin serves the \\`gke\\` kubernetes backend and a ResourceDriver client is registered under that name.\n\n```go\nfunc (a *ExternalPluginAdapter) ModuleFactories() map[string]plugin.ModuleFactory\n```\n\n```go\nfunc (a *ExternalPluginAdapter) ModuleSchemas() []*schema.ModuleSchema\n```\n\n```go\nfunc (a *ExternalPluginAdapter) Name() string\n```\n\n```go\nfunc (a *ExternalPluginAdapter) OnDisable(_ plugin.PluginContext) error\n```\n\n```go\nfunc (a *ExternalPluginAdapter) OnEnable(_ plugin.PluginContext) error\n```\n\n```go\nfunc (a *ExternalPluginAdapter) PreInitWiringHooks() []plugin.WiringHook\n```\n\n```go\nfunc (a *ExternalPluginAdapter) RegisterRoutes(_ *http.ServeMux)\n```\n\n```go\nfunc (a *ExternalPluginAdapter) SampleCategory() string\n```\nSampleCategory returns the sample category declared by the plugin.\n\n```go\nfunc (a *ExternalPluginAdapter) SidecarProviders() map[string]deploy.SidecarProvider\n```\n\n```go\nfunc (a *ExternalPluginAdapter) StepFactories() map[string]plugin.StepFactory\n```\n\n```go\nfunc (a *ExternalPluginAdapter) StepSchemas() []*schema.StepSchema\n```\n\n```go\nfunc (a *ExternalPluginAdapter) TriggerFactories() map[string]plugin.TriggerFactory\n```\n\n```go\nfunc (a *ExternalPluginAdapter) UIPages() []plugin.UIPageDef\n```\n\n```go\nfunc (a *ExternalPluginAdapter) Version() string\n```\n\n```go\nfunc (a *ExternalPluginAdapter) WiringHooks() []plugin.WiringHook\n```\n\n```go\nfunc (a *ExternalPluginAdapter) WorkflowHandlers() map[string]plugin.WorkflowHandlerFactory\n```\n\n```go\ntype ExternalPluginManager struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalPluginManager discovers, loads, and manages external plugin subprocesses. Each plugin lives in its own subdirectory under the plugins directory and communicates with the host via gRPC through the go-plugin framework.\n\n```go\nfunc NewExternalPluginManager(pluginsDir string, logger *log.Logger) *ExternalPluginManager\n```\nNewExternalPluginManager creates a new manager that scans the given directory for plugins.\n\n```go\nfunc (m *ExternalPluginManager) DiscoverPlugins() ([]string, error)\n```\nDiscoverPlugins scans the plugins directory for subdirectories that contain a plugin.json manifest and an executable binary matching the directory name. It returns the list of discovered plugin names.\n\n```go\nfunc (m *ExternalPluginManager) IsLoaded(name string) bool\n```\nIsLoaded returns true if the named plugin is currently loaded.\n\n```go\nfunc (m *ExternalPluginManager) LoadPlugin(name string) (*ExternalPluginAdapter, error)\n```\nLoadPlugin starts the named plugin subprocess, performs the handshake, and creates an ExternalPluginAdapter. The plugin must have been previously discovered via DiscoverPlugins.\n\n```go\nfunc (m *ExternalPluginManager) LoadedPlugins() []string\n```\nLoadedPlugins returns the names of all currently loaded plugins.\n\n```go\nfunc (m *ExternalPluginManager) ReloadPlugin(name string) (*ExternalPluginAdapter, error)\n```\nReloadPlugin starts and validates the replacement before stopping the currently loaded plugin. Candidate failure leaves the old process registered.\n\n```go\nfunc (m *ExternalPluginManager) SetCallbackServer(server *CallbackServer)\n```\nSetCallbackServer configures the host callback server used by plugins that expose triggers or host callback features.\n\n```go\nfunc (m *ExternalPluginManager) SetProcessOutput(stdout, stderr io.Writer)\n```\nSetProcessOutput selects host-owned subprocess output sinks. Nil preserves the default stdout discard and stderr logging behavior. Set before loading.\n\n```go\nfunc (m *ExternalPluginManager) Shutdown()\n```\nShutdown kills all loaded plugin subprocesses.\n\n```go\nfunc (m *ExternalPluginManager) UnloadPlugin(name string) error\n```\nUnloadPlugin stops the named plugin subprocess and removes it from the internal map.\n\n```go\ntype GRPCPlugin struct {\n\tgoplugin.Plugin\n\t// CallbackServer is the host-side callback implementation.\n\t// When non-nil, it will be registered on the broker for plugin access.\n\tCallbackServer *CallbackServer\n}\n```\nGRPCPlugin implements go-plugin's Plugin and GRPCPlugin interfaces. It bridges between go-plugin's plugin system and our gRPC services.\n\n```go\nfunc (p *GRPCPlugin) GRPCClient(_ context.Context, broker *goplugin.GRPCBroker, c *grpc.ClientConn) (any, error)\n```\nGRPCClient returns the client wrapper (host side). This is called by the host process to get a client that talks to the plugin.\n\n```go\nfunc (p *GRPCPlugin) GRPCServer(broker *goplugin.GRPCBroker, s *grpc.Server) error\n```\nGRPCServer registers the plugin service on the gRPC server (plugin side). This is called by the plugin process.\n\n```go\ntype MessagePublishFunc func(brokerName, topic string, payload []byte, metadata map[string]string) (messageID string, err error)\n```\nMessagePublishFunc publishes a message to a named broker topic on behalf of a plugin.\n\n```go\ntype MessageSubscribeFunc func(brokerName, topic string, handler func([]byte, map[string]string) error) (cancel func(), err error)\n```\nMessageSubscribeFunc subscribes to a topic on a named broker on behalf of a plugin. It returns a cancel function to remove the subscription and any error.\n\n```go\ntype PluginClient struct {\n\t// contains filtered or unexported fields\n}\n```\nPluginClient wraps the gRPC client for the plugin service.\n\nThe underlying \\*grpc.ClientConn is retained so callers that need to instantiate additional typed gRPC clients (e.g. the typed pb.IaCProviderRequiredClient that wfctl's typedIaCAdapter wraps in the strict-contracts cutover, plan Task 16) can do so without going through the legacy pb.PluginServiceClient string-dispatch path. Exposed via Conn() rather than as a public field so the rest of the PluginClient surface stays opaque.\n\n```go\nfunc (p *PluginClient) Conn() *grpc.ClientConn\n```\nConn returns the underlying gRPC client connection to the plugin process. Callers MAY use it to construct additional typed gRPC service clients (for example pb.NewIaCProviderRequiredClient).\n\nThe connection lifecycle is owned by the host's plugin manager — callers MUST NOT call Close() on it. The connection is shared across every typed-client constructed against it; closing it would tear down every other consumer too.\n\n```go\ntype PluginHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nPluginHandler provides HTTP API endpoints for managing external plugins.\n\n```go\nfunc NewPluginHandler(manager *ExternalPluginManager) *PluginHandler\n```\nNewPluginHandler creates a new handler backed by the given external plugin manager.\n\n```go\nfunc (h *PluginHandler) RegisterRoutes(mux *http.ServeMux)\n```\nRegisterRoutes registers the external plugin management HTTP routes on the given mux.\n\n```go\ntype RemoteModule struct {\n\t// contains filtered or unexported fields\n}\n```\nRemoteModule implements modular.Module by delegating to a gRPC plugin.\n\n```go\nfunc NewRemoteModule(name, handleID string, client pb.PluginServiceClient, contracts ...remoteModuleContracts) *RemoteModule\n```\nNewRemoteModule creates a remote module proxy.\n\n```go\nfunc (m *RemoteModule) Dependencies() []string\n```\n\n```go\nfunc (m *RemoteModule) Destroy() error\n```\nDestroy releases the remote module resources.\n\n```go\nfunc (m *RemoteModule) Init(app modular.Application) error\n```\n\n```go\nfunc (m *RemoteModule) InvokeService(method string, args map[string]any) (map[string]any, error)\n```\nInvokeService calls a named method on the remote module's service interface.\n\n```go\nfunc (m *RemoteModule) InvokeServiceContext(ctx context.Context, method string, args map[string]any) (map[string]any, error)\n```\nInvokeServiceContext calls a named method on the remote module's service interface using the caller's context.\n\n```go\nfunc (m *RemoteModule) Name() string\n```\n\n```go\nfunc (m *RemoteModule) ProvidesServices() []string\n```\n\n```go\nfunc (m *RemoteModule) RegisterConfig(app modular.Application) error\n```\n\n```go\nfunc (m *RemoteModule) RequiresServices() []string\n```\n\n```go\nfunc (m *RemoteModule) SetDependencies(deps []string)\n```\nSetDependencies records the yaml-level \\`dependsOn:\\` keys declared for this module so modular's Init() walker can honour them. Called by the engine from BuildFromConfig immediately after the factory returns and before app.RegisterModule, but only when the module's \\`modCfg.DependsOn\\` is \\*\\*non-empty after filtering\\*\\* (filterResolvableDeps drops empty strings + names not present in cfg.Modules) AND the module satisfies \\`interface{ SetDependencies(\\[]string) }\\` — modules with no resolvable dependsOn are skipped so a constructor-time default isn't clobbered with a SetDependencies(nil) call. See workflow#663.\n\nDefensive copy: although the engine already copies before calling, the setter is exported and Dependencies() exposes the same backing array to modular. Copying here too means any caller (engine, tests, future integration paths) can mutate its source slice after calling without silently corrupting this module's init graph.\n\n```go\nfunc (m *RemoteModule) Start(ctx context.Context) error\n```\n\n```go\nfunc (m *RemoteModule) Stop(ctx context.Context) error\n```\n\n```go\ntype RemoteStep struct {\n\t// contains filtered or unexported fields\n}\n```\nRemoteStep implements module.PipelineStep by delegating to a gRPC plugin.\n\n```go\nfunc NewRemoteStep(name, handleID string, client pb.PluginServiceClient, config map[string]any, contracts ...*pb.ContractDescriptor) *RemoteStep\n```\nNewRemoteStep creates a remote step proxy. config holds the raw (possibly template-containing) step configuration that will be resolved against the live pipeline context on each Execute call.\n\n```go\nfunc NewRemoteStepWithContractTypes(name, handleID string, client pb.PluginServiceClient, config map[string]any, contract *pb.ContractDescriptor, types protoregistry.MessageTypeResolver) *RemoteStep\n```\n\n```go\nfunc (s *RemoteStep) Destroy() error\n```\nDestroy releases the remote step resources.\n\n```go\nfunc (s *RemoteStep) Execute(ctx context.Context, pc *module.PipelineContext) (*module.StepResult, error)\n```\n\n```go\nfunc (s *RemoteStep) Name() string\n```\n\n```go\ntype RemoteTrigger struct {\n\t// contains filtered or unexported fields\n}\n```\nRemoteTrigger implements module.Trigger by proxying to a plugin trigger type. Trigger lifecycle (Start/Stop) is managed through the plugin's module RPCs, treating trigger handles as module handles.\n\n```go\nfunc NewRemoteTrigger(typeName, name string, client pb.PluginServiceClient) *RemoteTrigger\n```\nNewRemoteTrigger creates a remote trigger proxy. The plugin handle is allocated after Configure receives YAML trigger config.\n\n```go\nfunc (t *RemoteTrigger) Configure(_ modular.Application, triggerConfig any) error\n```\nConfigure applies YAML trigger config and creates the remote trigger handle.\n\n```go\nfunc (t *RemoteTrigger) Destroy() error\n```\nDestroy releases the remote trigger resources in the plugin process.\n\n```go\nfunc (t *RemoteTrigger) Init(_ modular.Application) error\n```\n\n```go\nfunc (t *RemoteTrigger) Name() string\n```\n\n```go\nfunc (t *RemoteTrigger) Start(ctx context.Context) error\n```\n\n```go\nfunc (t *RemoteTrigger) Stop(ctx context.Context) error\n```\n\n```go\ntype SecurityScannerRemoteModule struct {\n\t*RemoteModule\n}\n```\nSecurityScannerRemoteModule wraps a RemoteModule for security.scanner type modules. On Init it registers a RemoteSecurityScannerProvider in the service registry so that scan steps can call app.GetService(\"security-scanner\", \u0026provider).\n\n```go\nfunc NewSecurityScannerRemoteModule(remote *RemoteModule) *SecurityScannerRemoteModule\n```\nNewSecurityScannerRemoteModule wraps a RemoteModule as a security scanner module.\n\n```go\nfunc (m *SecurityScannerRemoteModule) Init(app modular.Application) error\n```\nInit calls the remote Init and registers the scanner provider in the service registry.\n\n```go\ntype ServiceLookupFunc func(name string) bool\n```\nServiceLookupFunc checks if a named service exists in the host.\n\n```go\ntype TriggerFunc func(triggerType, action string, data map[string]any) error\n```\nTriggerFunc is called when a plugin fires a workflow trigger.\n\n```go\ntype UIManifest = contract.UIManifest\n```\nUIManifest describes the UI contribution of a go-plugin UI plugin. Place this as \"ui.json\" in the plugin directory alongside \"plugin.json\".\n\n### Directory Layout {#hdr-Directory_Layout}\n\n\tplugins/\n\t  my-ui-plugin/\n\t    my-ui-plugin  (binary, required for API handlers; optional for asset-only plugins)\n\t    plugin.json   (gRPC plugin manifest; required when binary is present)\n\t    ui.json       (UI manifest: nav items and asset location)\n\t    assets/       (static files: HTML, CSS, JS, images, etc.)\n\t      index.html\n\t      main.js\n\n### Asset Versioning {#hdr-Asset_Versioning}\n\nInclude a version hash in asset filenames (e.g. main.abc123.js) and reference them from index.html so browsers pick up new files after hot-deploy.\n\n### Hot-Reload {#hdr-Hot_Reload}\n\nAfter updating assets or ui.json, call:\n\n\tPOST /api/v1/plugins/ui/{name}/reload\n\nThis re-reads the manifest and serves the new files without restarting the workflow engine.\n\n### Hot-Deploy {#hdr-Hot_Deploy}\n\nReplace the plugin binary and/or assets directory with the new version, then call the reload endpoint above.\n\n```go\ntype UINavItem = contract.UINavItem\n```\nUINavItem describes a single entry in the admin UI navigation sidebar.\n\n```go\ntype UIPluginEntry struct {\n\t// Manifest is the parsed ui.json for this plugin.\n\tManifest UIManifest\n\t// AssetsDir is the absolute path to the plugin's static assets directory.\n\tAssetsDir string\n}\n```\nUIPluginEntry holds the runtime state of a loaded UI plugin.\n\n```go\ntype UIPluginHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nUIPluginHandler provides HTTP API endpoints for managing UI plugins.\n\nRoutes registered by RegisterRoutes:\n\n\tGET  /api/v1/plugins/ui                       – list loaded UI plugins\n\tGET  /api/v1/plugins/ui/available             – list all discovered UI plugins\n\tGET  /api/v1/plugins/ui/{name}/manifest       – get a plugin's UI manifest\n\tPOST /api/v1/plugins/ui/{name}/load           – load a UI plugin\n\tPOST /api/v1/plugins/ui/{name}/unload         – unload a UI plugin\n\tPOST /api/v1/plugins/ui/{name}/reload         – hot-reload a UI plugin\n\tGET  /api/v1/plugins/ui/{name}/assets/{path…} – serve static assets\n\n```go\nfunc NewUIPluginHandler(manager *UIPluginManager) *UIPluginHandler\n```\nNewUIPluginHandler creates a new handler backed by the given UIPluginManager.\n\n```go\nfunc (h *UIPluginHandler) RegisterRoutes(mux *http.ServeMux)\n```\nRegisterRoutes registers all UI plugin HTTP routes on mux.\n\n```go\ntype UIPluginInfo struct {\n\tName        string      `json:\"name\"`\n\tVersion     string      `json:\"version\"`\n\tDescription string      `json:\"description,omitempty\"`\n\tNavItems    []UINavItem `json:\"navItems,omitempty\"`\n\tLoaded      bool        `json:\"loaded\"`\n}\n```\nUIPluginInfo is the JSON representation of a UI plugin for API responses.\n\n```go\ntype UIPluginManager struct {\n\t// contains filtered or unexported fields\n}\n```\nUIPluginManager discovers and manages UI plugins under a shared plugins directory.  Each UI plugin is a subdirectory that contains a \"ui.json\" manifest and an optional \"assets\" subdirectory with static files.\n\n### Hot-reload {#hdr-Hot_reload}\n\nCalling ReloadPlugin re-reads the manifest and the assets directory from disk without restarting the workflow engine. The static file server for the plugin is updated atomically so in-flight requests are not interrupted.\n\n### Integration with PluginManager navigation {#hdr-Integration_with_PluginManager_navigation}\n\nCall UIPages to get UIPageDef entries for a loaded UI plugin, then register a UIPluginNativePlugin wrapper with a PluginManager to surface those entries through the standard navigation API.\n\n```go\nfunc NewUIPluginManager(pluginsDir string, logger *log.Logger) *UIPluginManager\n```\nNewUIPluginManager creates a manager that scans the given directory for UI plugins (subdirectories containing a \"ui.json\" manifest).\n\n```go\nfunc (m *UIPluginManager) AllUIPluginInfos() []UIPluginInfo\n```\nAllUIPluginInfos returns summary information for every currently loaded UI plugin.\n\n```go\nfunc (m *UIPluginManager) AsNativePlugin(name string) plugin.NativePlugin\n```\nAsNativePlugin returns a plugin.NativePlugin implementation that surfaces the named UI plugin's navigation entries through the standard PluginManager API.  Returns nil if the plugin is not loaded.\n\nUse this to register a UI plugin's nav items with a PluginManager:\n\n\tif np := uiMgr.AsNativePlugin(\"my-ui-plugin\"); np != nil {\n\t    _ = pluginMgr.Register(np)\n\t    _ = pluginMgr.Enable(\"my-ui-plugin\")\n\t}\n\n```go\nfunc (m *UIPluginManager) DiscoverPlugins() ([]string, error)\n```\nDiscoverPlugins scans the plugins directory and returns names of all subdirectories that contain a \"ui.json\" manifest file.\n\n```go\nfunc (m *UIPluginManager) GetPlugin(name string) (*UIPluginEntry, bool)\n```\nGetPlugin returns the entry for the named UI plugin.  The second return value is false if the plugin is not loaded.\n\n```go\nfunc (m *UIPluginManager) IsLoaded(name string) bool\n```\nIsLoaded returns true if the named UI plugin is currently loaded.\n\n```go\nfunc (m *UIPluginManager) LoadPlugin(name string) error\n```\nLoadPlugin reads the \"ui.json\" manifest for the named plugin and registers it.  If the plugin is already loaded it is replaced (hot-reload semantics).\n\n```go\nfunc (m *UIPluginManager) LoadedPlugins() []string\n```\nLoadedPlugins returns the names of all currently loaded UI plugins.\n\n```go\nfunc (m *UIPluginManager) ReloadPlugin(name string) error\n```\nReloadPlugin re-reads the manifest and assets directory from disk for the named plugin.  This is the primary hot-reload mechanism: deploy updated assets to the plugin directory, then call this method.\n\n```go\nfunc (m *UIPluginManager) ServeAssets(name string) http.Handler\n```\nServeAssets returns an http.Handler that serves the static assets of the named plugin directly from its assets directory.  Returns nil if the plugin is not loaded or its assets directory does not exist.\n\n```go\nfunc (m *UIPluginManager) UIPages(name string) []plugin.UIPageDef\n```\nUIPages converts the nav items declared in a loaded UI plugin's manifest into plugin.UIPageDef entries compatible with the PluginManager navigation system.\n\n```go\nfunc (m *UIPluginManager) UnloadPlugin(name string) error\n```\nUnloadPlugin removes a UI plugin from the manager.  Returns an error if the plugin is not currently loaded.\n\n```go\ntype UIPluginNativePlugin struct {\n\t// contains filtered or unexported fields\n}\n```\nUIPluginNativePlugin adapts a loaded UI plugin as a plugin.NativePlugin so its navigation entries are visible through the standard PluginManager API. It implements a read-through to the UIPluginManager so that hot-reloads automatically update the navigation data returned by UIPages.\n\n```go\nfunc (p *UIPluginNativePlugin) Dependencies() []plugin.PluginDependency\n```\n\n```go\nfunc (p *UIPluginNativePlugin) Description() string\n```\n\n```go\nfunc (p *UIPluginNativePlugin) Name() string\n```\n\n```go\nfunc (p *UIPluginNativePlugin) OnDisable(_ plugin.PluginContext) error\n```\n\n```go\nfunc (p *UIPluginNativePlugin) OnEnable(_ plugin.PluginContext) error\n```\n\n```go\nfunc (p *UIPluginNativePlugin) RegisterRoutes(_ *http.ServeMux)\n```\n\n```go\nfunc (p *UIPluginNativePlugin) UIPages() []plugin.UIPageDef\n```\nUIPages reads the current nav items from the UIPluginManager so that hot-reloads (which call UIPluginManager.ReloadPlugin) are reflected immediately without re-registering the plugin.\n\n```go\nfunc (p *UIPluginNativePlugin) Version() string\n```\n\n","path":"github.com/GoCodeAlone/workflow/plugin/external","name":"external","synopsis":"Package external provides gRPC-based external plugin support for the workflow engine.","isRedistributable":true}
