feat(events): add generic Event Bus and /events/wait endpoint for agent wakeups
This commit is contained in:
1 parent
b8d58b2e64
commit
efcab4a7b4
5 files changed
+69
No files matched your search
@@ -5,6 +5,13 @@ use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct GenericEvent {
|
||||
pub topic: String,
|
||||
pub session_id: Option<String>,
|
||||
pub payload: serde_json::Value,
|
||||
}
|
||||
|
||||
pub struct MemoryState {
|
||||
pub base_dir: PathBuf,
|
||||
pub graph: Store<KnowledgeGraph>,
|
||||
@@ -29,6 +36,7 @@ pub struct MemoryState {
|
||||
pub context_workspaces: Store<Vec<ContextWorkspace>>,
|
||||
pub recent_activities: Store<std::collections::VecDeque<serde_json::Value>>,
|
||||
pub activity_tx: tokio::sync::broadcast::Sender<String>,
|
||||
pub event_bus_tx: tokio::sync::broadcast::Sender<GenericEvent>,
|
||||
}
|
||||
|
||||
impl MemoryState {
|
||||
@@ -72,6 +80,7 @@ impl MemoryState {
|
||||
context_workspaces: Store::new("context_workspaces", db.clone()),
|
||||
recent_activities: Store::new("recent_activities", db.clone()),
|
||||
activity_tx: tokio::sync::broadcast::channel(100).0,
|
||||
event_bus_tx: tokio::sync::broadcast::channel(1000).0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user