use std::sync::Arc;
use async_trait::async_trait;
use atomr_agents_callable::Callable;
use atomr_agents_core::{CallCtx, HarnessId, Result, Value};
#[async_trait]
pub trait HarnessDispatch: Send + Sync + 'static {
async fn dispatch(&self) -> Result<Value>;
}
pub struct HarnessRef {
pub id: HarnessId,
inner: Arc<dyn HarnessDispatch>,
}
impl HarnessRef {
pub fn new(id: HarnessId, inner: Arc<dyn HarnessDispatch>) -> Self {
Self { id, inner }
}
pub async fn run(&self) -> Result<Value> {
self.inner.dispatch().await
}
}
#[async_trait]
impl Callable for HarnessRef {
async fn call(&self, _input: Value, _ctx: CallCtx) -> Result<Value> {
self.run().await
}
fn label(&self) -> &str {
self.id.as_str()
}
}