agentmux_mcp/tools/
ui_tool.rs1use super::family::{pick, relabeled, Act};
11use super::*;
12
13pub(super) const ACTS: &[Act] = &[
14 Act { action: "screenshot", tool: "UIScreenshot", rename: &[] },
15 Act { action: "query", tool: "UIQuery", rename: &[] },
16 Act { action: "click", tool: "UIClick", rename: &[] },
17 Act { action: "shortcuts", tool: "ListShortcuts", rename: &[] },
18 Act { action: "command", tool: "RunCommand", rename: &[] },
19 Act { action: "keys", tool: "PressKeys", rename: &[] },
20 Act { action: "bind", tool: "SetShortcut", rename: &[] },
21 Act { action: "reset", tool: "ResetShortcuts", rename: &[] },
22 Act { action: "windows", tool: "DiscoverWindows", rename: &[] },
23 Act { action: "window", tool: "CaptureWindow", rename: &[] },
24 Act { action: "record", tool: "UIRecord", rename: &[] },
25];
26
27pub(super) async fn call(name: &str, arguments: &Value, cx: &ToolCtx<'_>) -> Result<String> {
28 match name {
29 "UI" => {
30 let (act, args) = pick("UI", ACTS, arguments)?;
31 relabeled("UI", ACTS, ui::call(act.tool, &args, cx).await)
32 }
33 _ => Err(not_in_family()),
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn every_action_is_in_the_schema() {
43 let schema: Value = serde_json::from_str(crate::tool_schemas::UI_TOOL).unwrap();
44 let mut listed: Vec<&str> = schema["inputSchema"]["properties"]["action"]["enum"]
45 .as_array()
46 .unwrap()
47 .iter()
48 .filter_map(|v| v.as_str())
49 .collect();
50 let mut want = super::super::family::action_names(ACTS);
51 listed.sort();
52 want.sort();
53 assert_eq!(listed, want);
54 }
55}