repositories / smith
smith
There are many coding harnesses - but this one is fast
owned by admin
plugins/echo/src/lib.rs
Raw//! Reference system plugin: one echo tool over the smith:plugin world.
#![expect(missing_docs, reason = "wit-bindgen generates the world surface")]
#![expect(clippy::pedantic, reason = "wit-bindgen generates the world surface")]
wit_bindgen::generate!({
path: "../../wit/smith-plugin.wit",
world: "plugin-world",
});
use exports::smith::plugin::plugin::{Guest, ToolDeclaration};
struct EchoPlugin;
impl Guest for EchoPlugin {
fn declare_tools() -> Vec<ToolDeclaration> {
vec![ToolDeclaration {
name: "echo".to_string(),
description: "Echoes the input string back verbatim.".to_string(),
}]
}
fn invoke(name: String, input_json: String) -> Result<String, String> {
if name == "echo" {
Ok(input_json)
} else {
Err(format!("unknown tool: {name}"))
}
}
}
export!(EchoPlugin);