MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute

Method execute

crates/opencode-tool/src/question.rs:99–127  ·  view source on GitHub ↗
(
        &self,
        args: serde_json::Value,
        _ctx: ToolContext,
    )

Source from the content-addressed store, hash-verified

97 }
98
99 async fn execute(
100 &self,
101 args: serde_json::Value,
102 _ctx: ToolContext,
103 ) -> Result<ToolResult, ToolError> {
104 let input: QuestionInput =
105 serde_json::from_value(args).map_err(|e| ToolError::InvalidArguments(e.to_string()))?;
106
107 let mut all_answers: Vec<String> = Vec::new();
108
109 for q in input.questions.iter() {
110 let answer = ask_question(q)?;
111 all_answers.extend(answer);
112 }
113
114 let response = QuestionResponse {
115 answers: all_answers,
116 };
117
118 let output = serde_json::to_string_pretty(&response)
119 .unwrap_or_else(|_| format!("{:?}", response.answers));
120
121 Ok(ToolResult {
122 title: "User response received".to_string(),
123 output,
124 metadata: std::collections::HashMap::new(),
125 truncated: false,
126 })
127 }
128}
129
130fn ask_question(q: &QuestionDef) -> Result<Vec<String>, ToolError> {

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
ask_questionFunction · 0.85

Tested by

no test coverage detected