Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tracing-appender = "0.2"
bip39 = { version = "2", features = ["rand", "std"] }
wasmparser = "0.116.0"
wasmprinter = "0.252"
wasmi = "0.31"
wat = "1.0"
hmac = "0.12"
rustyline = "14.0.0"
Expand Down
21 changes: 19 additions & 2 deletions crates/starforge-plugin-sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! StarForge Plugin SDK
//!
//! Implement the [`StarForgePlugin`] trait and use [`export_plugin!`] to
//! expose your plugin to the StarForge CLI loader.
//! Implement the [`StarForgePlugin`] trait and use [`export_plugin!`] for
//! native plugins or [`export_wasm_plugin_abi!`] for WebAssembly plugins.

/// WASM plugin ABI supported by the StarForge runtime.
pub const WASM_PLUGIN_ABI_VERSION: i32 = 1;

/// Metadata every plugin must provide.
pub struct PluginMeta {
Expand Down Expand Up @@ -47,3 +50,17 @@ macro_rules! export_plugin {
}
};
}

/// Exports the WASM plugin ABI version for sandboxed StarForge plugins.
///
/// WASM plugins should compile to a WebAssembly target and include this export
/// so StarForge can reject incompatible modules before execution.
#[macro_export]
macro_rules! export_wasm_plugin_abi {
() => {
#[no_mangle]
pub extern "C" fn starforge_plugin_abi_version() -> i32 {
$crate::WASM_PLUGIN_ABI_VERSION
}
};
}
Loading
Loading