Rust SDK
Crate name vibex-plugin-sdk, path crates/plugin-sdk. MSRV 1.85. stdio uses a tokio current-thread runtime. publish = false in Cargo.toml; plugins depend via path or the crate bundled in the Host family. Template rust-worker writes runtime/Cargo.toml and runtime/src/main.rs. entrypoints.worker.runtime is native, protocol 1.1.
[package]
name = "my-plugin-worker"
version = "0.1.0"
edition = "2021"
rust-version = "1.85"
[dependencies]
serde_json = "1"
vibex-plugin-sdk = { path = "../../../crates/plugin-sdk" }Constants PLUGIN_API_VERSION, PLUGIN_PROTOCOL_VERSION, and PLUGIN_SDK_VERSION match JS and Python.
Worker
use serde_json::json;
use vibex_plugin_sdk::{define_plugin_worker, run_stdio_plugin_worker_blocking};
fn main() {
let definition = define_plugin_worker(|registrar, _env| {
registrar.handle_sync("hello", |input, _env| {
Ok(json!({
"message": "Hello from VibeX",
"input": input,
}))
});
registrar.on_dispose(|| async { Ok(()) });
});
if let Err(error) = run_stdio_plugin_worker_blocking(definition) {
eprintln!("{error}");
std::process::exit(1);
}
}PluginRegistrar:
handle(id, async_fn): async handler,Result<Value, PluginSdkError>handle_sync(id, fn): sync wrapperon_dispose(async_fn): cleanup, reverse order
WorkerEnv: context() / replace_context(), host (HostClient), log.debug/info/warn/error, is_cancelled() / cancel(), async call(capability, operation, input).
run_stdio_plugin_worker is async. run_stdio_plugin_worker_blocking is for main. The panic hook writes protocol error worker_panic then dispose.
PluginSdkError is the error type. Handler regex matches the other languages. hello_plugin_worker is an in-crate sample used by protocol fixtures.
Compile and manifest path
The Host spawns entrypoints.worker.path as an executable: Command::new(path), working directory the package root. That path must be a compiled binary.
Sequence:
- Run
cargo build --releaseinsideruntime/on the same OS / CPU triple as the Host. - Copy the artifact to
dist/, for exampledist/my-plugin-worker. - Set the manifest to
"path": "dist/my-plugin-worker","runtime": "native","protocol": "1.1". vibex-plugin validate/pack.
vibex-plugin build compiles JavaScript Workers (runtime/main.mjs → dist/worker.mjs) and managed MCP sources. Authors supply the native binary. init --template rust-worker writes path runtime/src/main.rs; change it to the compiled binary before release.
Isolated
cargo build --release --no-default-features --features isolatedDefault feature std includes filesystem and network helpers. The Isolated feature omits those helpers and relies on Host spawn plus the OS sandbox. define_plugin_worker stays the same. v5 manifest fields: Plugin architecture.
Testing
The crate exports create_worker_harness, create_generation_harness, and MemoryHost. WorkerHarness::invoke is async. dispose runs on_dispose in reverse.
cargo test -p vibex-plugin-sdkProtocol fixtures read packages/plugin-contract/fixtures/protocol/*.jsonl, shared across the three language SDKs. Plugin-package tests are author-maintained. init --template rust-worker ships a Node test that checks the manifest; authors add Rust-side tests.

