1use crate::{operation::OperationDescriptor, AxorContext, Payload};
2use downcast_rs::{impl_downcast, DowncastSync};
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6pub trait Agent: DowncastSync + Send + Sync {
7
8 fn name(&self) -> &'static str;
9
10 fn operations(&self) -> Vec<OperationDescriptor>;
11
12 fn inject_dependencies(&self, context: &AxorContext);
13
14 fn call_operation(&self, payload: &Payload) -> InvokeResult;
15
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct InvokeResult {
20 pub operation: String,
21 pub success: bool,
22 pub data: Option<Value>,
23}
24
25impl_downcast!(sync Agent);