crabtalk_runtime/
ask_user.rs1use serde::Deserialize;
7use wcore::{
8 agent::{AsTool, ToolDescription},
9 model::Tool,
10};
11
12#[derive(Deserialize, schemars::JsonSchema)]
14pub struct QuestionOption {
15 pub label: String,
17 pub description: String,
19}
20
21#[derive(Deserialize, schemars::JsonSchema)]
23pub struct Question {
24 pub question: String,
26 pub header: String,
28 pub options: Vec<QuestionOption>,
30 #[serde(default)]
32 pub multi_select: bool,
33}
34
35#[derive(Deserialize, schemars::JsonSchema)]
37pub struct AskUser {
38 pub questions: Vec<Question>,
40}
41
42impl ToolDescription for AskUser {
43 const DESCRIPTION: &'static str = r#"Ask the user one or more structured questions with predefined options. Each question needs a short UI header, the full question text, and options with labels and descriptions. The user picks from the options or types a free-text "Other" answer. Returns JSON mapping question text to selected label. For multi_select, the answer is a comma-joined string like "Option A, Option B"."#;
44}
45
46pub fn tools() -> Vec<Tool> {
47 vec![AskUser::as_tool()]
48}