agentmux_mcp/tools/
message_tool.rs1use super::family::{pick, relabeled, Act};
12use super::*;
13
14pub(super) const ACTS: &[Act] = &[
15 Act { action: "send", tool: "SendMessage", rename: &[] },
16 Act { action: "broadcast", tool: "FleetBroadcast", rename: &[] },
17 Act { action: "post", tool: "PostToChannel", rename: &[] },
18 Act { action: "read", tool: "ReadChannel", rename: &[] },
19 Act { action: "bulletin", tool: "PostBulletin", rename: &[] },
20 Act { action: "read_bulletin", tool: "ReadBulletin", rename: &[] },
21 Act { action: "quota_mode", tool: "QuotaMode", rename: &[] },
22];
23
24pub(super) async fn call(name: &str, arguments: &Value, cx: &ToolCtx<'_>) -> Result<String> {
25 match name {
26 "Message" => {
27 let (act, args) = pick("Message", ACTS, arguments)?;
28 let result = match act.tool {
29 "SendMessage" | "FleetBroadcast" => fleet::call(act.tool, &args, cx).await,
30 _ => overlap::call(act.tool, &args, cx).await,
31 };
32 relabeled("Message", ACTS, result)
33 }
34 _ => Err(not_in_family()),
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn every_action_is_in_the_schema() {
44 let schema: Value = serde_json::from_str(crate::tool_schemas::MESSAGE_TOOL).unwrap();
45 let mut listed: Vec<&str> = schema["inputSchema"]["properties"]["action"]["enum"]
46 .as_array()
47 .unwrap()
48 .iter()
49 .filter_map(|v| v.as_str())
50 .collect();
51 let mut want = super::super::family::action_names(ACTS);
52 listed.sort();
53 want.sort();
54 assert_eq!(listed, want);
55 }
56}