Skip to main content

declare_tool

Macro declare_tool 

Source
macro_rules! declare_tool {
    ($name:expr, $handler:ident) => { ... };
}
Expand description

Declare a WASM plugin tool with ABI v2 exports.

Generates three required exports:

  • az_alloc(size: i32) -> i32 — allocator for host↔plugin memory sharing
  • az_tool_name() -> i64 — packed ptr|len of the tool name string
  • az_tool_execute(input_ptr: i32, input_len: i32) -> i64 — main entry point

§Usage

use agentzero_plugin_sdk::prelude::*;

declare_tool!("my_tool", handler);

fn handler(input: ToolInput) -> ToolOutput {
    ToolOutput::success("hello from plugin")
}

The handler function must have signature fn(ToolInput) -> ToolOutput.