stynx_code_tools/infrastructure/
send_message_tool.rs1use stynx_code_errors::AppResult;
2use stynx_code_types::{PermissionLevel, Tool};
3use serde_json::{Value, json};
4
5pub struct SendMessageTool;
6
7impl SendMessageTool {
8 pub fn new() -> Self {
9 Self
10 }
11}
12
13#[async_trait::async_trait]
14impl Tool for SendMessageTool {
15 fn name(&self) -> &str {
16 "send_message"
17 }
18
19 fn description(&self) -> &str {
20 "Send a message to a named agent or team."
21 }
22
23 fn input_schema(&self) -> Value {
24 json!({
25 "type": "object",
26 "properties": {
27 "to": {
28 "type": "string",
29 "description": "Name of the agent or team to send the message to"
30 },
31 "message": {
32 "type": "string",
33 "description": "The message content to send"
34 }
35 },
36 "required": ["to", "message"]
37 })
38 }
39
40 fn permission_level(&self) -> PermissionLevel {
41 PermissionLevel::Dangerous
42 }
43
44 async fn execute(&self, input: Value) -> AppResult<String> {
45 let to = input
46 .get("to")
47 .and_then(|v| v.as_str())
48 .ok_or_else(|| stynx_code_errors::AppError::Tool("missing 'to' field".into()))?;
49
50 let message = input
51 .get("message")
52 .and_then(|v| v.as_str())
53 .ok_or_else(|| stynx_code_errors::AppError::Tool("missing 'message' field".into()))?;
54
55 tracing::info!(to, message_len = message.len(), "sending message (stub)");
56
57 Ok(format!("Message delivered to '{to}'. Length: {} chars.", message.len()))
58 }
59}