1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Proc macros for the agentic-tools library family.
//!
//! This crate provides:
//! - `#[tool]` attribute macro for defining tools
//! - `#[derive(TextFormat)]` for implementing the TextFormat trait
use TokenStream;
/// Attribute macro to define a tool from an async function.
///
/// # Usage
///
/// ```ignore
/// use agentic_tools_macros::tool;
/// use agentic_tools_core::ToolError;
///
/// #[tool(name = "my_tool", description = "Does something useful")]
/// async fn my_tool(input: MyInput) -> Result<MyOutput, ToolError> {
/// // implementation
/// }
/// ```
///
/// This generates a `MyToolTool` struct implementing the `Tool` trait.
///
/// # Attributes
///
/// - `name`: The tool's unique name (defaults to function name)
/// - `description`: Human-readable description of what the tool does
/// Derive macro for implementing the TextFormat trait.
///
/// By default, produces pretty-printed JSON. When `markdown = true` in TextOptions,
/// wraps the JSON in a fenced code block.
///
/// # Usage
///
/// ```ignore
/// use agentic_tools_macros::TextFormat;
///
/// #[derive(TextFormat, serde::Serialize)]
/// struct MyOutput {
/// message: String,
/// count: usize,
/// }
/// ```
///
/// # Attributes
///
/// - `#[text_format(with = "path::to_fn")]`: Delegate formatting to a custom function.
/// The function must have signature `fn(&Self, &TextOptions) -> String`.
///
/// ```ignore
/// fn format_my_output(output: &MyOutput, opts: &TextOptions) -> String {
/// format!("Message: {} (count: {})", output.message, output.count)
/// }
///
/// #[derive(TextFormat, serde::Serialize)]
/// #[text_format(with = "format_my_output")]
/// struct MyOutput {
/// message: String,
/// count: usize,
/// }
/// ```