Skip to main content

synaps_cli/tools/
send_channel.rs

1//! SendChannelTool — proactively send a message to a specific channel.
2use serde_json::{json, Value};
3use crate::Result;
4use super::{Tool, ToolContext};
5
6pub struct SendChannelTool;
7
8#[async_trait::async_trait]
9impl Tool for SendChannelTool {
10    fn name(&self) -> &str { "send_channel" }
11
12    fn description(&self) -> &str {
13        "Send a message to a specific channel (discord, slack, system, etc). Use this to proactively notify through a specific channel rather than replying to an event."
14    }
15
16    fn parameters(&self) -> Value {
17        json!({
18            "type": "object",
19            "properties": {
20                "channel_type": {
21                    "type": "string",
22                    "description": "Channel type: discord, slack, telegram, system, desktop"
23                },
24                "channel_id": {
25                    "type": "string",
26                    "description": "Channel identifier (e.g. Discord channel ID, Slack channel)"
27                },
28                "text": { "type": "string", "description": "Message to send" }
29            },
30            "required": ["channel_type", "channel_id", "text"]
31        })
32    }
33
34    async fn execute(&self, params: Value, _ctx: ToolContext) -> Result<String> {
35        let channel_type = params["channel_type"].as_str()
36            .ok_or_else(|| crate::RuntimeError::Tool("Missing 'channel_type' parameter".to_string()))?
37            .to_string();
38        let channel_id = params["channel_id"].as_str()
39            .ok_or_else(|| crate::RuntimeError::Tool("Missing 'channel_id' parameter".to_string()))?
40            .to_string();
41        let text = params["text"].as_str()
42            .ok_or_else(|| crate::RuntimeError::Tool("Missing 'text' parameter".to_string()))?
43            .to_string();
44
45        tracing::info!(
46            channel_type = %channel_type,
47            channel_id = %channel_id,
48            "send_channel tool invoked: {}",
49            text
50        );
51
52        Ok(json!({
53            "sent": false,
54            "error": "send_channel is not yet implemented — no channel dispatch wired",
55            "channel_type": channel_type,
56            "channel_id": channel_id,
57        }).to_string())
58    }
59}