Building Plugins
SDK setup
Section titled “SDK setup”Tundra plugins are WebAssembly components targeting wasm32-wasip2. The SDK provides WIT bindings for all host capabilities.
cargo new --lib my-tundra-plugincd my-tundra-pluginCargo.toml:
[lib]crate-type = ["cdylib"]
[dependencies]tundra-plugin-sdk = "1.0"wit-bindgen = "0.36"Plugin manifest
Section titled “Plugin manifest”Create tundra-plugin.toml:
[plugin]id = "com.example.my-plugin"name = "My Plugin"version = "1.0.0"description = "Does something useful"author = "Your Name <you@example.com>"license = "MIT"
[capabilities]http_outbound = ["api.example.com"] # allowlisted domainskv_read = truekv_write = trueevents_publish = true
[hooks]on_deployment_complete = "handle_deployment" # exported function nameWriting a plugin
Section titled “Writing a plugin”use tundra_plugin_sdk::prelude::*;
// Called by Tundra when a deployment completes#[tundra_hook]fn handle_deployment(ctx: DeploymentContext) -> Result<()> { let site = ctx.site();
// Write to plugin kv store tundra_sdk::kv::set("last_deploy", &site.id)?;
// Make an outbound HTTP request (must be in capabilities allowlist) let resp = tundra_sdk::http::post( "https://api.example.com/webhook", &json!({ "site": site.id, "status": "deployed" }), )?;
tundra_sdk::audit::log("deployment.notified", &site.id)?; Ok(())}Building
Section titled “Building”# Install the wasm targetrustup target add wasm32-wasip2
# Buildcargo build --release --target wasm32-wasip2
# The plugin is at target/wasm32-wasip2/release/my_tundra_plugin.wasmTesting locally
Section titled “Testing locally”# Install the Tundra plugin dev runnercargo install tundra-plugin-dev
# Run against a local Tundra instancetundra-plugin-dev run \ --plugin target/wasm32-wasip2/release/my_tundra_plugin.wasm \ --tundra-url http://localhost:7400 \ --token tnd_dev_<token>WIT contracts
Section titled “WIT contracts”The full WIT interface definitions are in tundra-plugin-sdk/wit/:
| Interface | What it exposes |
|---|---|
tundra:plugin/http | Outbound HTTP with allowlist enforcement |
tundra:plugin/kv | Isolated key-value store |
tundra:plugin/events | Publish events to tundrad |
tundra:plugin/audit | Write audit log entries |
tundra:plugin/sites | Read site metadata |
tundra:plugin/deployments | Trigger deployments |