nemo-relay-plugin 0.5.0

Rust plugin authoring SDK and stable native plugin ABI for NeMo Relay.
Documentation

License GitHub Release Codecov PyPI npm node Crates.io Crates.io Crates.io Ask DeepWiki

NeMo Relay Native Plugin SDK

nemo-relay-plugin is the Rust authoring SDK and stable ABI for trusted, in-process NeMo Relay dynamic plugins. Use it to build a Rust cdylib that Relay loads through the versioned native plugin interface.

Native plugins run in the Relay process and are not sandboxed. They should depend on this crate rather than the host nemo-relay runtime crate, keeping the dynamic-library boundary on the stable C-compatible ABI.

Why Use It?

  • Author native plugins safely: Implement NativePlugin with typed Rust callbacks instead of constructing ABI tables directly.
  • Register real runtime behavior: Use PluginContext for subscribers, guardrails, and intercepts.
  • Keep a stable boundary: Export one versioned native entry point through the nemo_relay_plugin! macro.
  • Use host runtime helpers: Emit events and manage scope state through the high-level PluginRuntime wrapper.

What You Get

  • NativePlugin: Plugin kind, configuration validation, and registration lifecycle contract.
  • PluginContext: Component-scoped registration APIs for middleware and subscribers.
  • PluginRuntime: Typed helpers for Relay-owned scopes and marks.
  • Stable native ABI v1: C-compatible host and plugin tables behind the safe Rust authoring interface.

Installation

Add the SDK to a Rust dynamic-plugin project:

cargo add nemo-relay-plugin serde_json

Configure the library as a dynamic library:

[lib]
crate-type = ["cdylib"]

Getting Started

Implement NativePlugin and export a constructor symbol:

use nemo_relay_plugin::{Json, NativePlugin, PluginContext, Result};
use serde_json::Map;

struct ExamplePlugin;

impl NativePlugin for ExamplePlugin {
    fn plugin_kind(&self) -> &str {
        "example.native"
    }

    fn register(&mut self, _config: &Map<String, Json>, ctx: &mut PluginContext<'_>) -> Result<()> {
        ctx.register_subscriber("log-events", |event| {
            eprintln!("{}", event.name());
        })
    }
}

nemo_relay_plugin::nemo_relay_plugin!(nemo_relay_register_plugin, || ExamplePlugin);

Build the cdylib, describe its entry symbol and compatibility in a relay-plugin.toml manifest, then register it through the Relay CLI. See the complete example for platform-specific artifact and manifest setup.

Documentation