Skip to content

Class PluginServer

Namespace: DotBoxD.Plugins
Assembly: DotBoxD.Plugins.dll

In-process server-extension convenience surface: register a batch kernel under a service contract, then obtain a typed proxy that invokes it request/response. Plugin-facing remote facades usually expose the same capability from the domain surface they extend.

public sealed class PluginServer : IDisposable

objectPluginServer

IDisposable

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

PluginServerJsonExtensions.InstallJsonAsync(PluginServer, string, SandboxPolicy?, CancellationToken)

public PluginEventAdapterRegistry Events { get; }

PluginEventAdapterRegistry

public HookRegistry Hooks { get; }

HookRegistry

public KernelRegistry Kernels { get; }

KernelRegistry

public SubscriptionRegistry Subscriptions { get; }

SubscriptionRegistry

public LiveContext<T> BindContext<T>(string name, Action<T>? initialize = null) where T : class

name string

initialize Action<T>?

LiveContext<T>

T

public LiveValue<T> BindValue<T>(string name, T initialValue)

name string

initialValue T

LiveValue<T>

T

Create(IPluginMessageSink?, Action<SandboxHostBuilder>?, SandboxPolicy?, ExecutionMode, Action<SubscriptionDeliveryFault>?)

Section titled “ Create(IPluginMessageSink?, Action<SandboxHostBuilder>?, SandboxPolicy?, ExecutionMode, Action<SubscriptionDeliveryFault>?)”
public static PluginServer Create(IPluginMessageSink? messages, Action<SandboxHostBuilder>? configureHost, SandboxPolicy? defaultPolicy, ExecutionMode executionMode, Action<SubscriptionDeliveryFault>? onSubscriptionFault)

messages IPluginMessageSink?

configureHost Action<SandboxHostBuilder>?

defaultPolicy SandboxPolicy?

executionMode ExecutionMode

onSubscriptionFault Action<SubscriptionDeliveryFault>?

PluginServer

Create(IPluginMessageSink?, Action<SandboxHostBuilder>?, SandboxPolicy?, ExecutionMode, Action<SubscriptionDeliveryFault>?, Action<ResultHookFault>?)

Section titled “ Create(IPluginMessageSink?, Action<SandboxHostBuilder>?, SandboxPolicy?, ExecutionMode, Action<SubscriptionDeliveryFault>?, Action<ResultHookFault>?)”
public static PluginServer Create(IPluginMessageSink? messages = null, Action<SandboxHostBuilder>? configureHost = null, SandboxPolicy? defaultPolicy = null, ExecutionMode executionMode = ExecutionMode.Auto, Action<SubscriptionDeliveryFault>? onSubscriptionFault = null, Action<ResultHookFault>? onResultHookFault = null)

messages IPluginMessageSink?

configureHost Action<SandboxHostBuilder>?

defaultPolicy SandboxPolicy?

executionMode ExecutionMode

onSubscriptionFault Action<SubscriptionDeliveryFault>?

onResultHookFault Action<ResultHookFault>?

PluginServer

Creates a new ownership session. Every kernel installed through the session is tagged with it as the owner, so no other session can replace or mutate it; disposing the session revokes and unregisters the kernels it owns. Use one session per untrusted connection.

public PluginSession CreateSession()

PluginSession

Releases the owned DotBoxD.Hosting.Execution.SandboxHost (compiled executable cache, generated load contexts, hotness state, and other host-owned execution resources) so a host that retires a plugin server (per tenant, world, test, or reload) can deterministically reclaim them through the public plugin API. After disposal the lifecycle entrypoints (DotBoxD.Plugins.PluginServer.InstallAsync(DotBoxD.Plugins.PluginPackage,DotBoxD.Kernels.SandboxPolicy,System.Threading.CancellationToken), DotBoxD.Plugins.PluginServer.Uninstall(System.String)) throw System.ObjectDisposedException. Disposal is idempotent.

public void Dispose()

Analyzes a package against this server’s registered host bindings and returns the concrete capabilities its verified module requires. Use this to build a least-privilege install policy from host-trusted binding metadata instead of trusting the package manifest.

public IReadOnlyList<string> GetRequiredCapabilities(PluginPackage package)

package PluginPackage

IReadOnlyList<string>

InstallAsync(PluginPackage, SandboxPolicy?, CancellationToken)

Section titled “ InstallAsync(PluginPackage, SandboxPolicy?, CancellationToken)”
public ValueTask<InstalledKernel> InstallAsync(PluginPackage package, SandboxPolicy? policy = null, CancellationToken cancellationToken = default)

package PluginPackage

policy SandboxPolicy?

cancellationToken CancellationToken

ValueTask<InstalledKernel>

InstallPoolAsync(PluginPackage, int, SandboxPolicy?, CancellationToken)

Section titled “ InstallPoolAsync(PluginPackage, int, SandboxPolicy?, CancellationToken)”
public ValueTask<InstalledKernelPool> InstallPoolAsync(PluginPackage package, int degreeOfParallelism, SandboxPolicy? policy = null, CancellationToken cancellationToken = default)

package PluginPackage

degreeOfParallelism int

policy SandboxPolicy?

cancellationToken CancellationToken

ValueTask<InstalledKernelPool>

InstallServerExtensionAsync(PluginPackage, SandboxPolicy?, CancellationToken)

Section titled “ InstallServerExtensionAsync(PluginPackage, SandboxPolicy?, CancellationToken)”

Installs a server extension package: a kernel invoked request/response (via DotBoxD.Plugins.Kernel.InstalledKernel.InvokeServerExtensionAsync(System.Collections.Generic.IReadOnlyList{DotBoxD.Kernels.Sandbox.SandboxValue},System.Threading.CancellationToken)) rather than wired to an event. It is validated by DotBoxD.Plugins.Runtime.Rpc.RpcKernelPackageValidator because the manifest uses the existing rpcEntrypoint field and has no event subscription/contract.

public ValueTask<InstalledKernel> InstallServerExtensionAsync(PluginPackage package, SandboxPolicy? policy = null, CancellationToken cancellationToken = default)

package PluginPackage

policy SandboxPolicy?

cancellationToken CancellationToken

ValueTask<InstalledKernel>

RegisterEventAdapter<TEvent>(IPluginEventAdapter<TEvent>)

Section titled “ RegisterEventAdapter<TEvent>(IPluginEventAdapter<TEvent>)”
public PluginServer RegisterEventAdapter<TEvent>(IPluginEventAdapter<TEvent> adapter)

adapter IPluginEventAdapter<TEvent>

PluginServer

TEvent

RegisterServerExtensionAsync<TService, TKernel>(SandboxPolicy?, CancellationToken)

Section titled “ RegisterServerExtensionAsync<TService, TKernel>(SandboxPolicy?, CancellationToken)”

Resolves TKernel’s generated verified-IR package, installs it as a server extension, and binds the TService contract to it for DotBoxD.Plugins.PluginServer.ServerExtension.

public ValueTask<string> RegisterServerExtensionAsync<TService, TKernel>(SandboxPolicy? policy = null, CancellationToken cancellationToken = default) where TService : class where TKernel : class

policy SandboxPolicy?

cancellationToken CancellationToken

ValueTask<string>

TService

TKernel

Returns a typed proxy implementing TService whose calls run the bound batch kernel request/response (arguments and results are marshaled to and from the sandbox). Throws if no extension was registered for the contract.

public TService ServerExtension<TService>() where TService : class

TService

TService

public bool Uninstall(string pluginId)

pluginId string

bool

public bool UninstallPool(InstalledKernelPool pool)

pool InstalledKernelPool

bool

Wires an installed kernel into the hook pipeline for the event it subscribes to, selecting the terminal (Use / UseProjecting / UseResult / UseProjectingResult) from the kernel’s trusted, recomputed classification. Replaces the per-event / per-terminal routing every host used to hand-write. The event is resolved by name from the registered adapters, so the host stays agnostic of plugin ids and event types. Throws when the subscribed event has no registered adapter.

public WireResult WireHook(InstalledKernel kernel, WireOptions? options = null)

kernel InstalledKernel

options WireOptions?

WireResult

Opt-in convenience over public API: customize the routing decision via DotBoxD.Plugins.WireOptions.ClassifyOverride, build a custom by-name router on DotBoxD.Plugins.Runtime.PluginEventAdapterRegistry.TryResolveErased(System.String,DotBoxD.Plugins.Runtime.IErasedPluginEventAdapter@), or hand-write the equivalent directly with typed server.Hooks.On<TEvent>().Use(kernel) plus your own event-name → type dispatch.

WireSubscription(InstalledKernel, WireOptions?)

Section titled “ WireSubscription(InstalledKernel, WireOptions?)”

Wires an installed kernel into the subscription (fire-and-forget) pipeline for the event it subscribes to. A plain terminal is routed through DotBoxD.Plugins.WireOptions.IndexRegistry first (when supplied, DotBoxD.Plugins.WireOptions.UseIndex is set, and verified IR maps to indexed fields), falling back to the broad pipeline; a projecting terminal pushes to the plugin’s native delegate. Result terminals are rejected — subscriptions have no result channel.

public WireResult WireSubscription(InstalledKernel kernel, WireOptions? options = null)

kernel InstalledKernel

options WireOptions?

WireResult

Opt-in convenience; see DotBoxD.Plugins.PluginServer.WireHook(DotBoxD.Plugins.Kernel.InstalledKernel,DotBoxD.Plugins.WireOptions) for the customization seams and the hand-written equivalent (server.Subscriptions.On<TEvent>().Use(kernel)).