Skip to main content

vtcode_core/tools/
request_user_input.rs

1use anyhow::{Result, anyhow};
2use async_trait::async_trait;
3use serde_json::Value;
4use vtcode_collaboration_tool_specs::{
5    request_user_input_description, request_user_input_parameters,
6};
7
8use crate::config::constants::tools;
9use crate::tool_policy::ToolPolicy;
10use crate::tools::traits::Tool;
11
12/// Tool declaration for requesting structured user input mid-turn.
13///
14/// This tool allows the LLM to ask 1-3 short questions with optional multiple-choice
15/// options.
16///
17/// The actual interactive UI implementation is provided by the VT Code front-end
18/// (TUI runloop) which can intercept this tool call and present a modal.
19pub struct RequestUserInputTool;
20
21#[async_trait]
22impl Tool for RequestUserInputTool {
23    async fn execute(&self, _args: Value) -> Result<Value> {
24        Err(anyhow!(
25            "request_user_input requires an interactive UI session and is handled by the VT Code front-end"
26        ))
27    }
28
29    fn name(&self) -> &str {
30        tools::REQUEST_USER_INPUT
31    }
32
33    fn description(&self) -> &str {
34        request_user_input_description()
35    }
36
37    fn parameter_schema(&self) -> Option<Value> {
38        Some(request_user_input_parameters())
39    }
40
41    fn default_permission(&self) -> ToolPolicy {
42        // Asking the user is always safe; it is still gated by interactive availability.
43        ToolPolicy::Allow
44    }
45
46    fn is_mutating(&self) -> bool {
47        false
48    }
49
50    fn is_parallel_safe(&self) -> bool {
51        false
52    }
53
54    fn kind(&self) -> &'static str {
55        "hitl"
56    }
57}