nexo_core/agent/
plugin.rs1use async_trait::async_trait;
2use nexo_broker::AnyBroker;
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub enum Command {
7 SendMessage {
8 to: String,
9 text: String,
10 },
11 SendMedia {
12 to: String,
13 url: String,
14 caption: Option<String>,
15 },
16 Custom {
17 name: String,
18 payload: Value,
19 },
20}
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub enum Response {
23 Ok,
24 MessageSent { message_id: String },
25 Error { message: String },
26 Custom { payload: Value },
27}
28#[async_trait]
29pub trait Plugin: Send + Sync {
30 fn name(&self) -> &str;
31 async fn start(&self, broker: AnyBroker) -> anyhow::Result<()>;
33 async fn stop(&self) -> anyhow::Result<()>;
35 async fn send_command(&self, cmd: Command) -> anyhow::Result<Response>;
37}