Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(core): add typed event bus for core event dispatch

Steven Enamakel8f7873613953
diff --git a/crates/openhuman-core/src/core/bus.rs b/crates/openhuman-core/src/core/bus.rs
index 3d7eb6db5e..6a4172417c 100644
--- a/crates/openhuman-core/src/core/bus.rs
+++ b/crates/openhuman-core/src/core/bus.rs
@@ -91,7 +91,11 @@ pub const EVENTS_INTERFACE: &str = "ai.tinyhumans.openhuman.Events";
/// schedule trigger through the schedule runtime's `TriggerSink` instead.
/// `1.12.0` adds optional `thread_id` and `client_id` to `MemoryStored` and
/// `MemoryRecalled` (additive): the chat routing was an ambient task-local.
-pub const EVENTS_VERSION: Version = Version::new(1, 12, 0);
+/// `1.13.0` adds an optional `tenant` to `CredentialChanged`, `CronSystemJobDue`,
+/// `ComposioConnectionCreated` and `ComposioConfigChanged` (additive): a
+/// subscriber rebuilds its dispatch context from it instead of reading an
+/// ambient one.
+pub const EVENTS_VERSION: Version = Version::new(1, 13, 0);
/// The bus. Initialised once by [`init`]; safe to touch before that.
pub static BUS: OnceBus<DomainEvent> = OnceBus::new();
diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rs
index 1bf732dae2..428bf102eb 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -409,6 +409,9 @@ pub enum DomainEvent {
CronSystemJobDue {
/// The job name, e.g. `memory_context_refresh`.
job: String,
+ /// The tenant whose scheduler fired the job; `None` for the host's own.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ tenant: Option<crate::core::runtime::Tenant>,
},
/// Live per-step progress of an in-flight `flows_run` / `flows_resume`
/// (issue G2, live run observation). Published from
@@ -879,6 +882,9 @@ pub enum DomainEvent {
toolkit: String,
connection_id: String,
connect_url: String,
+ /// The tenant owns the connection; `None` for the host's own.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ tenant: Option<crate::core::runtime::Tenant>,
},
/// A Composio connection was removed.
ComposioConnectionDeleted {
@@ -910,6 +916,9 @@ pub enum DomainEvent {
/// Whether a direct-mode API key is now present in the encrypted
/// store. The key itself is never carried on the event.
api_key_set: bool,
+ /// The tenant the change concerns; `None` for the host's own.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ tenant: Option<crate::core::runtime::Tenant>,
},
// ── Triage ──────────────────────────────────────────────────────────
@@ -1254,7 +1263,12 @@ pub enum DomainEvent {
/// `local` or `cleared` — never the credential itself. Subscribers that
/// cache credential-derived state (the search module's managed routes)
/// refresh on it.
- CredentialChanged { kind: String },
+ CredentialChanged {
+ kind: String,
+ /// The tenant the change concerns; `None` for the host's own.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ tenant: Option<crate::core::runtime::Tenant>,
+ },
// ── Voice ────────────────────────────────────────────────────────────
/// A voice domain event (PTT, transcription lifecycle, etc.).