punch_types/channel_notify.rs
1//! Channel notification trait for proactive outbound messaging.
2//!
3//! This trait is defined in `punch-types` so that `punch-runtime` can use it
4//! without depending on `punch-channels`. The `ChannelBridge` in `punch-channels`
5//! (wrapped in the API layer) provides the concrete implementation.
6
7use async_trait::async_trait;
8
9use crate::error::PunchResult;
10
11/// Trait for sending proactive notifications to external channels.
12///
13/// This allows the tool executor in `punch-runtime` to send messages to
14/// Telegram, Slack, Discord, etc. without depending on `punch-channels`.
15/// The API layer implements this trait and passes it as
16/// `Arc<dyn ChannelNotifier>` into the tool execution context.
17#[async_trait]
18pub trait ChannelNotifier: Send + Sync {
19 /// Send a message to a specific channel.
20 ///
21 /// - `adapter_name`: The channel adapter name (e.g., "telegram", "discord", "slack").
22 /// - `chat_id`: The channel/conversation identifier on the platform.
23 /// - `message`: The text message to send.
24 async fn notify(&self, adapter_name: &str, chat_id: &str, message: &str) -> PunchResult<()>;
25
26 /// List available channel adapters by name.
27 async fn list_channels(&self) -> PunchResult<Vec<String>>;
28}