Skip to content

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

chore: files changed crates/openhuman-core/src/web_chat/event_bus_channel.rs,crates/openhuman-core/s

Steven Enamakelbb1228b8b5b2
diff --git a/crates/openhuman-core/src/web_chat/event_bus_channel.rs b/crates/openhuman-core/src/web_chat/event_bus_channel.rs
index be625606aa..b664af91cc 100644
--- a/crates/openhuman-core/src/web_chat/event_bus_channel.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus_channel.rs
@@ -4,14 +4,14 @@ use once_cell::sync::Lazy;
use tokio::sync::broadcast;
use crate::core::runtime::DispatchCtx;
-use crate::web_chat::WebChannelEvent;
+use crate::web_chat::{ScopedWebEvent, WebChannelEvent};
-static EVENT_BUS: Lazy<broadcast::Sender<WebChannelEvent>> = Lazy::new(|| {
+static EVENT_BUS: Lazy<broadcast::Sender<ScopedWebEvent>> = Lazy::new(|| {
let (tx, _rx) = broadcast::channel(512);
tx
});
-pub fn subscribe_web_channel_events() -> broadcast::Receiver<WebChannelEvent> {
+pub fn subscribe_web_channel_events() -> broadcast::Receiver<ScopedWebEvent> {
EVENT_BUS.subscribe()
}
@@ -26,9 +26,10 @@ pub fn publish_web_channel_event(event: WebChannelEvent) {
/// [`publish_web_channel_event`] with the tenant stamped from `ctx`: the one
/// the calling turn runs under, rather than the calling task's own scope.
pub fn publish_web_channel_event_in(ctx: &DispatchCtx, mut event: WebChannelEvent) {
- if event.ts.is_none() {
- event.ts = Some(crate::web_chat::progress::unix_epoch_ms());
+ if event.context().ts.is_none() {
+ event.context_mut().ts = Some(crate::web_chat::progress::unix_epoch_ms());
}
- event.stamp_tenant(ctx.tenant().ok());
- let _ = EVENT_BUS.send(event);
+ let mut scoped = ScopedWebEvent::new(event);
+ scoped.stamp_tenant(ctx.tenant().ok());
+ let _ = EVENT_BUS.send(scoped);
}
diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rs
index a9513d4333..2352925c42 100644
--- a/crates/openhuman-core/src/web_chat/mod.rs
+++ b/crates/openhuman-core/src/web_chat/mod.rs
@@ -3,7 +3,7 @@
//! A thin host over two shared engines. TinyAgents' turn runner owns the
//! lifecycle of a chat turn (ingress order, per-thread serialization, the
//! queue modes, cancellation, the idle and wall-clock guards, reply
-//! persistence, one terminal event), and the `tinychannels` web adapter owns
+//! persistence, one terminal event), and TinyChannels' compiled web module owns
//! the projection of a turn's output onto the web wire. This module is what
//! only OpenHuman can supply: the ports the runner calls (`ingress.rs`,
//! `turn_host.rs`, `turn_events.rs`, state in `runner.rs`), the session
@@ -14,8 +14,8 @@
//! (`event_bus.rs`) and the `channel.web_*` RPC (`schemas.rs`). See `README.md`
//! for the lifecycle and wiring.
//!
-//! The wire types are `tinychannels-bus`'s (`channel_event.rs` keeps the flat
-//! in-process form every consumer already reads).
+//! The wire types are `tinychannels-bus`'s. OpenHuman adds only a host-private
+//! routing envelope around those typed events for its process-wide bus.
mod channel_event;
mod egress_surface;
@@ -56,8 +56,9 @@ pub(crate) use web_errors::{
// Public API — event bus
pub use channel_event::{
- ChatSuggestion, GuardrailPayload, GuardrailReason, QueueItemPayload, SubagentProgressDetail,
- SubagentUsagePayload, TurnTimingPayload, TurnUsagePayload, WebChannelEvent,
+ ChatSuggestion, GuardrailPayload, GuardrailReason, QueueItemPayload, ScopedWebEvent,
+ SubagentProgressDetail, SubagentUsagePayload, TurnTimingPayload, TurnUsagePayload,
+ WebChannelEvent,
};
pub use egress_surface::register_egress_surface_subscriber;
pub use event_bus::{
diff --git a/crates/openhuman-core/src/web_chat/surface.rs b/crates/openhuman-core/src/web_chat/surface.rs
index 51637e7f33..e500a25f81 100644
--- a/crates/openhuman-core/src/web_chat/surface.rs
+++ b/crates/openhuman-core/src/web_chat/surface.rs
@@ -167,12 +167,13 @@ impl Surface {
self.end_if_needed(&mut state).await;
}
- fn publish(&self, event: bus_web::WebChannelEvent, interim_round: Option<u32>) {
- let mut flat = WebChannelEvent::from(event);
- if flat.event == "chat_interim" && flat.round.is_none() {
- flat.round = interim_round.filter(|round| *round > 0);
+ fn publish(&self, mut event: bus_web::WebChannelEvent, interim_round: Option<u32>) {
+ if let bus_web::WebChannelEvent::ChatInterim { round, .. } = &mut event {
+ if round.is_none() {
+ *round = interim_round.filter(|round| *round > 0);
+ }
}
- publish_web_channel_event_in(&self.ctx, flat);
+ publish_web_channel_event_in(&self.ctx, event);
}
/// Project one canonical output event onto the web wire, in module-owned