Skip to main content

claude_api/tool_dispatch/
mod.rs

1//! Tool-dispatch foundation: the [`Tool`] trait, plus a registry and agent
2//! loop runner (the latter two land in v0.2 tasks #19 and #20).
3//!
4//! v0.2 will layer three ergonomic shapes on this single trait:
5//!
6//! 1. [`Tool`] -- async trait. Implement directly when each tool is its
7//!    own type (typical for shared crate code).
8//! 2. `ToolRegistry::register` -- closure-based handler. The registry wraps
9//!    closures in an internal `FnTool<F>` adapter that implements [`Tool`].
10//! 3. `ToolRegistry::register_typed::<Args>` -- typed-input handler driven
11//!    by `schemars`. Internally builds a `Tool` impl that deserializes the
12//!    raw input into `Args` before dispatching. Behind the
13//!    `schemars-tools` feature.
14//!
15//! Gated on the `async` feature.
16
17pub mod registry;
18pub mod tool;
19
20#[cfg(feature = "conversation")]
21#[cfg_attr(docsrs, doc(cfg(feature = "conversation")))]
22pub mod runner;
23
24#[cfg(feature = "schemars-tools")]
25#[cfg_attr(docsrs, doc(cfg(feature = "schemars-tools")))]
26pub mod typed;
27
28pub use registry::{FnTool, ToolRegistry};
29pub use tool::{ApprovalDecision, Tool, ToolApprover, ToolError, fn_approver};
30
31#[cfg(feature = "conversation")]
32pub use runner::RunOptions;
33
34#[cfg(feature = "schemars-tools")]
35pub use typed::TypedTool;