Skip to main content

agent_engine/tools/
send_channel.rs

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