1use super::*;
4use serde::Deserialize;
5
6pub struct AskUserQuestionTool;
7
8#[async_trait]
9impl Tool for AskUserQuestionTool {
10 fn name(&self) -> &str {
11 "AskUserQuestion"
12 }
13 fn description(&self) -> &str {
14 "Ask the user a question and wait for their response. Use when you need clarification or input."
15 }
16 fn permission_level(&self) -> PermissionLevel {
17 PermissionLevel::None
18 }
19
20 fn input_schema(&self) -> Value {
21 serde_json::json!({
22 "type": "object",
23 "properties": {
24 "question": { "type": "string", "description": "The question to ask the user" }
25 },
26 "required": ["question"]
27 })
28 }
29
30 async fn execute(&self, input: Value, _ctx: &ToolContext) -> ToolResult {
31 #[derive(Deserialize)]
32 struct Input {
33 question: String,
34 }
35
36 let input: Input = match serde_json::from_value(input) {
37 Ok(i) => i,
38 Err(e) => return ToolResult::error(format!("Invalid input: {}", e)),
39 };
40
41 ToolResult::success(format!(
45 "[Question for user]: {}\n\n(Waiting for user response via event handler)",
46 input.question
47 ))
48 }
49}