Skip to main content

ferrin_tool/
lib.rs

1//! Ferrin tool system.
2//!
3//! Tool definitions ([`Tool`], [`ToolKind`], [`ToolSet`]), the execution
4//! contract ([`ToolExecute`], [`ToolOutput`], [`ToolContext`], [`ToolError`]),
5//! approval declarations ([`NeedsApproval`]), model-output normalisation,
6//! caller restrictions, tool fingerprints and (feature `sandbox`) the
7//! [`Sandbox`] trait with a local-process implementation.
8//!
9//! Tool call parsing, approval resolution, execution scheduling and repair
10//! live in the core crate; this crate only describes tools and runs one
11//! execution when asked.
12//!
13//! Design: `docs/01-architecture/06-tool-system.md`, ADR 0012.
14//!
15//! # Attribution
16//!
17//! Portions of this crate are derived from the Vercel AI SDK (Apache-2.0,
18//! Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and
19//! modified. See the `NOTICE` file in the crate root.
20
21mod builder;
22pub mod callers;
23mod error;
24mod execute;
25pub mod fingerprint;
26pub mod model_output;
27#[cfg(feature = "sandbox")]
28pub mod sandbox;
29mod set;
30mod tool;
31
32pub use builder::ToolBuilder;
33pub use callers::PreparedToolCallers;
34pub use callers::ToolCaller;
35pub use callers::ToolCallerDefinition;
36pub use callers::ToolCallers;
37pub use error::DuplicateToolError;
38pub use error::ToolError;
39pub use execute::ToolContext;
40pub use execute::ToolExecute;
41pub use execute::ToolOutput;
42pub use execute::ToolOutputStream;
43pub use execute::execute_to_completion;
44pub use ferrin_schema::JsonSchema;
45pub use ferrin_schema::Schema;
46pub use fingerprint::ToolDrift;
47pub use model_output::ErrorMode;
48#[cfg(feature = "sandbox")]
49pub use sandbox::LocalProcessSandbox;
50#[cfg(feature = "sandbox")]
51pub use sandbox::Sandbox;
52#[cfg(feature = "sandbox")]
53pub use sandbox::SandboxProcess;
54pub use set::ToolSet;
55pub use tool::ApprovalFn;
56pub use tool::Description;
57pub use tool::DescriptionContext;
58pub use tool::DescriptionFn;
59pub use tool::InputAvailableHook;
60pub use tool::InputDeltaHook;
61pub use tool::InputStartHook;
62pub use tool::ModelOutputArgs;
63pub use tool::NeedsApproval;
64pub use tool::ToModelOutputFn;
65pub use tool::Tool;
66pub use tool::ToolHooks;
67pub use tool::ToolKind;