//! 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}; use exports::smith::plugin::provider::{ CatalogSnapshot, DecodeStep, Guest as ProviderGuest, ProviderRequest, ProviderSettings, RequestTemplate, SettingsProvenance, }; use exports::smith::plugin::registration::{Guest as RegistrationGuest, Registrations}; struct EchoPlugin; impl RegistrationGuest for EchoPlugin { fn declare() -> Registrations { Registrations { credential_sources: Vec::new(), providers: Vec::new(), models: Vec::new(), } } } impl ProviderGuest for EchoPlugin { fn declare_settings() -> ProviderSettings { ProviderSettings { include_usage: false, subscription: false, provenance: SettingsProvenance::BuiltIn, } } fn validate_settings(_settings: ProviderSettings) -> Result { Err("echo does not provide protocol settings".to_string()) } fn build_request( _model: String, _request: ProviderRequest, _settings: ProviderSettings, _catalog: CatalogSnapshot, ) -> Result { Err("echo does not provide a model codec".to_string()) } fn decode_response( _state: Vec, _chunk: Vec, _finished: bool, ) -> Result { Err("echo does not provide a model decoder".to_string()) } } impl Guest for EchoPlugin { fn declare_tools() -> Vec { vec![ToolDeclaration { name: "echo".to_string(), description: "Echoes the input string back verbatim.".to_string(), input_schema_json: r#"{"type":"object","properties":{},"required":[]}"#.to_string(), }] } fn invoke(name: String, input_json: String) -> Result { if name == "echo" { Ok(input_json) } else { Err(format!("unknown tool: {name}")) } } } export!(EchoPlugin);