1pub mod context;
2pub mod error;
3pub mod result;
4pub mod schema;
5pub mod tools;
6pub mod traits;
7
8pub use context::ExecutionContext;
9pub use error::ToolError;
10pub use result::{ToolOutput, ToolResult};
11pub use schema::{InputSchema, ToolCall, ToolSchema};
12pub use traits::Tool;
13
14#[cfg(test)]
15mod description_format_tests {
16 use crate::*;
17 use schemars::JsonSchema;
18 use serde::{Deserialize, Serialize};
19
20 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
21 pub struct SimpleParams {
22 pub value: String,
23 }
24
25 mod string_literal_tool {
26 use super::*;
27 use steer_macros::tool;
28
29 tool! {
31 StringLiteralTool {
32 params: SimpleParams,
33 output: crate::result::ExternalResult,
34 variant: External,
35 description: "This is a simple string literal description",
36 name: "string_literal_tool",
37 require_approval: false
38 }
39
40 async fn run(
41 _tool: &StringLiteralTool,
42 params: SimpleParams,
43 _context: &ExecutionContext,
44 ) -> Result<crate::result::ExternalResult, ToolError> {
45 Ok(crate::result::ExternalResult {
46 tool_name: "string_literal_tool".to_string(),
47 payload: format!("Processed: {}", params.value),
48 })
49 }
50 }
51 }
52
53 mod formatted_string_tool {
54 use super::*;
55 use steer_macros::tool;
56
57 tool! {
59 FormattedStringTool {
60 params: SimpleParams,
61 output: crate::result::ExternalResult,
62 variant: External,
63 description: format!("This is a formatted description with version {} and features: {:?}",
64 "1.0.0",
65 vec!["advanced", "dynamic"]),
66 name: "formatted_string_tool",
67 require_approval: false
68 }
69
70 async fn run(
71 _tool: &FormattedStringTool,
72 params: SimpleParams,
73 _context: &ExecutionContext,
74 ) -> Result<crate::result::ExternalResult, ToolError> {
75 Ok(crate::result::ExternalResult {
76 tool_name: "formatted_string_tool".to_string(),
77 payload: format!("Formatted result: {}", params.value),
78 })
79 }
80 }
81 }
82
83 mod constant_description_tool {
84 use super::*;
85 use steer_macros::tool;
86
87 const TOOL_VERSION: &str = "2.1.0";
89
90 tool! {
91 ConstantDescriptionTool {
92 params: SimpleParams,
93 output: crate::result::ExternalResult,
94 variant: External,
95 description: format!("Tool version {} with enhanced capabilities", TOOL_VERSION),
96 name: "constant_description_tool",
97 require_approval: false
98 }
99
100 async fn run(
101 _tool: &ConstantDescriptionTool,
102 params: SimpleParams,
103 _context: &ExecutionContext,
104 ) -> Result<crate::result::ExternalResult, ToolError> {
105 Ok(crate::result::ExternalResult {
106 tool_name: "constant_description_tool".to_string(),
107 payload: format!("Version {} result: {}", TOOL_VERSION, params.value),
108 })
109 }
110 }
111 }
112
113 #[test]
114 fn test_string_literal_description() {
115 use string_literal_tool::*;
116 let tool = StringLiteralTool;
117 assert_eq!(
118 tool.description(),
119 "This is a simple string literal description"
120 );
121 }
122
123 #[test]
124 fn test_formatted_string_description() {
125 use formatted_string_tool::*;
126 let tool = FormattedStringTool;
127 let desc = tool.description();
128 assert!(desc.contains("version 1.0.0"));
129 assert!(desc.contains("advanced"));
130 assert!(desc.contains("dynamic"));
131 }
132
133 #[test]
134 fn test_constant_description() {
135 use constant_description_tool::*;
136 let tool = ConstantDescriptionTool;
137 let desc = tool.description();
138 assert!(desc.contains("Tool version 2.1.0"));
139 assert!(desc.contains("enhanced capabilities"));
140 }
141}