Skip to main content

tool

Macro tool 

Source
macro_rules! tool {
    ($name:ident, |$input:ident : ToolInput| $body:expr) => { ... };
}
Expand description

Define a tool handler function.

This macro generates the #[no_mangle] extern "C" boilerplate so your tool handler is a plain Rust closure that receives a ToolInput and returns a ToolOutput.

use workforce_skill_sdk::prelude::*;

workforce_skill_sdk::init!();

tool!(get_weather, |input: ToolInput| {
    let city = input.get_str("city").unwrap_or("unknown");
    ToolOutput::success(json!({"city": city, "temp": 22}))
});