Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

mofa-plugins

The plugin system enabling extensibility through Rust/WASM and Rhai.

Purpose

mofa-plugins provides:

  • Compile-time plugin infrastructure (Rust/WASM)
  • Runtime plugin engine (Rhai scripts)
  • Hot-reload support
  • Plugin adapters

Plugin Types

TypeTechnologyUse Case
Compile-timeRust / WASMPerformance critical
RuntimeRhai scriptsBusiness logic, hot-reload

Usage

Rhai Plugin

#![allow(unused)]
fn main() {
use mofa_plugins::{RhaiPlugin, RhaiPluginManager};

let mut manager = RhaiPluginManager::new();
let plugin = RhaiPlugin::from_file("./plugins/my_plugin.rhai").await?;
manager.register(plugin).await?;
}

Rust Plugin

#![allow(unused)]
fn main() {
use mofa_kernel::plugin::AgentPlugin;

pub struct MyPlugin;

#[async_trait]
impl AgentPlugin for MyPlugin {
    fn name(&self) -> &str { "my_plugin" }
    // ...
}
}

Feature Flags

FlagDescription
rhaiRhai scripting engine
wasmWASM plugin support

See Also