Skip to content

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

feat(channels): project relay progressive events through web surface

Steven Enamakel8deae372dbd3
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rs
index 98a4519da0..275bc94095 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs
@@ -305,10 +305,13 @@ pub(crate) async fn run_relay_turn(
&format!("hosted-channel:{}", params.channel),
));
let progressive_target = Arc::new(crate::channels::runtime::dispatch::hosted_relay_target(
+ &dispatch_ctx,
&config,
Arc::clone(&channel),
channel_ref,
prepared.envelope.conversation.clone(),
+ params.client_id().to_owned(),
+ request_id.clone(),
));
tracing::debug!(
diff --git a/crates/openhuman-core/src/channels/providers/relay/progressive.rs b/crates/openhuman-core/src/channels/providers/relay/progressive.rs
index 3ad28460a5..12e6fdf99d 100644
--- a/crates/openhuman-core/src/channels/providers/relay/progressive.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/progressive.rs
@@ -18,6 +18,7 @@ pub(crate) struct RelayProgressiveTransport {
channel_ref: tinychannels_bus::ChannelRef,
conversation: tinychannels_bus::ConversationRef,
turn_id: String,
+ projection: Arc<crate::web_chat::surface::Surface>,
}
impl RelayProgressiveTransport {
@@ -26,12 +27,14 @@ impl RelayProgressiveTransport {
channel_ref: tinychannels_bus::ChannelRef,
conversation: tinychannels_bus::ConversationRef,
turn_id: String,
+ projection: Arc<crate::web_chat::surface::Surface>,
) -> Self {
Self {
channel,
channel_ref,
conversation,
turn_id,
+ projection,
}
}
@@ -63,6 +66,7 @@ impl RelayProgressiveTransport {
turn_id,
channel_ref,
conversation,
+ event,
..
} => {
self.check_scope(
@@ -71,9 +75,10 @@ impl RelayProgressiveTransport {
channel_ref.as_ref(),
conversation.as_ref(),
)?;
- // Output events are canonical engine observations. The relay
- // gateway receives only the typed terminal send below, so an
- // observer acknowledgement must not publish a duplicate.
+ // Project canonical events through the same compiled web
+ // adapter used by desktop and TUI turns. Provider delivery is
+ // still performed only by the typed terminal send below.
+ self.projection.output(event).await;
Ok(ProgressiveTransportResult::Acknowledged)
}
ProgressiveTransportRequest::SendTyped {
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
index d02b368373..f0eebfe8e1 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs
@@ -22,6 +22,10 @@ enum ProgressiveTargetKind {
HostedRelay {
client: tinybus::module::ModuleClient,
channel: std::sync::Arc<crate::channels::providers::relay::RelayChannel>,
+ ctx: crate::core::runtime::DispatchCtx,
+ config: crate::config::Config,
+ client_id: String,
+ request_id: String,
},
}
@@ -42,13 +46,33 @@ impl NativeProgressiveTarget {
)
.await?
}
- ProgressiveTargetKind::HostedRelay { client, channel } => {
+ ProgressiveTargetKind::HostedRelay {
+ client,
+ channel,
+ ctx,
+ config,
+ client_id,
+ request_id,
+ } => {
+ let projection = Arc::new(
+ crate::web_chat::surface::Surface::new(
+ ctx,
+ crate::web_chat::surface::TurnIds {
+ client_id: client_id.clone(),
+ thread_id: self.conversation.id.clone(),
+ request_id: request_id.clone(),
+ },
+ config.clone(),
+ )
+ .await,
+ );
let callback =
crate::channels::providers::relay::progressive::RelayProgressiveTransport::new(
Arc::clone(channel),
self.channel.clone(),
self.conversation.clone(),
turn_id.to_owned(),
+ projection,
);
let runtime = crate::modules::channel_runtime::ChannelRuntimeLease::open(
client.clone(),
@@ -70,15 +94,22 @@ impl NativeProgressiveTarget {
}
pub(crate) fn hosted_relay_target(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &crate::config::Config,
channel: std::sync::Arc<crate::channels::providers::relay::RelayChannel>,
channel_ref: tinychannels_bus::channel::ChannelRef,
conversation: tinychannels_bus::channel::ConversationRef,
+ client_id: String,
+ request_id: String,
) -> NativeProgressiveTarget {
NativeProgressiveTarget {
kind: ProgressiveTargetKind::HostedRelay {
client: crate::modules::client(config.clone()),
channel,
+ ctx: ctx.clone(),
+ config: config.clone(),
+ client_id,
+ request_id,
},
channel: channel_ref,
conversation,