# klieo-macros

Procedural macros for the klieo agent framework.

Part of the [klieo](https://crates.io/crates/klieo) Rust agent framework.

## Features

- `#[tool]`: derives a `Tool` impl from an `async fn` — name, description, and JSON schema inferred automatically
- Zero boilerplate: annotate a function, register the result

## Quickstart

```toml
[dependencies]
klieo-macros = "2"
klieo-core   = "2"
klieo-tools  = "2"   # for ChainedInvoker
```

```rust
use std::sync::Arc;
use klieo_macros::tool;
use klieo_core::tool::{ToolCtx, ToolError};
use klieo_tools::ChainedInvoker;

#[tool(description = "Adds two numbers together.")]
async fn add(_ctx: &ToolCtx, a: f64, b: f64) -> Result<f64, ToolError> {
    Ok(a + b)
}

# fn run() -> Result<(), klieo_tools::InvokerError> {
let invoker = ChainedInvoker::new().with_tool_owned(AddTool)?;
# let _ = invoker; Ok(()) }
```

The macro generates a struct (`AddTool` for `fn add`) that implements
`Tool`. Pass the owned struct to either:

- `ChainedInvoker::with_tool_owned(AddTool)` — Arc-wraps internally; no
  `Arc::new(...)` at the call site (klieo-tools 2.0+).
- `App::tool(AddTool)` — the umbrella crate's `App` builder accepts
  owned `Tool` values and Arc-wraps as part of building the runtime.

If you do want to manage the Arc yourself (e.g. registering one tool
in multiple invokers), `ChainedInvoker::with_tool(Arc::new(AddTool))`
stays available.

## Status

`2.x` — stable. See [`docs/SEMVER.md`](https://github.com/mohrimic/klieo/blob/main/docs/SEMVER.md).

## License

MIT — see [`LICENSE`](https://github.com/mohrimic/klieo/blob/main/LICENSE).
