Skip to main content

mofa_plugins/rhai_runtime/
mod.rs

1//! Rhai Runtime Plugin
2//!
3//! Provides Rhai script-based runtime plugin support for MoFA agent system
4//! - Load and execute Rhai scripts as plugins
5//! - Full lifecycle management (load, init, start, stop, unload)
6//! - Plugin metadata and configuration
7//! - Safe execution environment
8//! - Hot reload support
9//!
10//! A Rhai plugin is a script that defines:
11//! ```rhai
12//! // Plugin metadata (optional)
13//! plugin_name = "my_rhai_plugin";
14//! plugin_version = "1.0.0";
15//! plugin_description = "A sample Rhai plugin";
16//! plugin_author = "Example Author";
17//!
18//! // Lifecycle functions
19//! fn init() {
20//!     // Initialization logic
21//!     print("Plugin initialized");
22//! }
23//!
24//! fn start() {
25//!     // Start logic
26//!     print("Plugin started");
27//! }
28//!
29//! fn stop() {
30//!     // Stop logic
31//!     print("Plugin stopped");
32//! }
33//!
34//! fn unload() {
35//!     // Unload logic
36//!     print("Plugin unloaded");
37//! }
38//!
39//! // Execution function
40//! fn execute(input) {
41//!     // Handle execution requests
42//!     "Rhai plugin executed: " + input
43//! }
44//!
45//! // Event handler example
46//! fn on_event(event) {
47//!     print("Event received: " + event.name);
48//! }
49//! ```
50
51mod plugin;
52mod types;
53
54pub use plugin::{RhaiPlugin, RhaiPluginConfig, RhaiPluginState};
55pub use types::{PluginMetadata, RhaiPluginError, RhaiPluginResult};