amico-core 1.2.0

The core Agent components of the Amico AI Agent Framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use tokio::task::JoinHandle;

#[cfg(feature = "wasm")]
use tokio_with_wasm::alias as tokio;

use crate::types::AgentEvent;

/// An event source listens for events, and calls the `on_event`
/// callback to react to events.
pub trait EventSource {
    /// The method to run the `EventSource`.
    ///
    /// The `run` method will be called by `Agent` in a new thread.
    fn spawn<F, Fut>(&self, on_event: F) -> JoinHandle<anyhow::Result<()>>
    where
        F: Fn(AgentEvent) -> Fut + Send + Sync + 'static,
        Fut: Future<Output = Option<String>> + Send + 'static;
}