Skip to main content

deck_plugin/
lib.rs

1//! deck-plugin — WASM plugin host surface.
2//!
3//! The trait + manifest format are stabilized in `0.1`; the actual
4//! `wasmtime` loader lands in `0.2`. We keep the SDK dep out of `0.1` so
5//! first-time builds stay under a minute.
6
7use std::path::PathBuf;
8
9use serde::{Deserialize, Serialize};
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct PluginManifest {
13    pub name: String,
14    pub version: String,
15    pub entry: PathBuf,
16    #[serde(default)]
17    pub capabilities: Vec<Capability>,
18    #[serde(default)]
19    pub description: String,
20}
21
22#[derive(Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq)]
23#[serde(rename_all = "kebab-case")]
24pub enum Capability {
25    /// Plugin may register one or more MCP tools.
26    McpTool,
27    /// Plugin may render a panel in the TUI.
28    TuiPanel,
29    /// Plugin may receive orchestrator events read-only.
30    EventConsumer,
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36
37    #[test]
38    fn manifest_parses_minimal_toml() {
39        let s = r#"
40            name = "icebreaker"
41            version = "0.1.0"
42            entry = "icebreaker.wasm"
43            capabilities = ["mcp-tool"]
44            description = "promptfoo+garak+PyRIT red-team bundle"
45        "#;
46        let m: PluginManifest = toml::from_str(s).expect("parse");
47        assert_eq!(m.name, "icebreaker");
48        assert_eq!(m.capabilities, vec![Capability::McpTool]);
49    }
50}