The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(channels): support progressive replies for hosted relay channels
Steven Enamakelbd646f79bb17
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rsindex 2252007910..99a56570d1 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs@@ -34,6 +34,9 @@ pub(crate) struct RuntimeChannelMessage {pub(crate) authenticated_relay: bool,pub(crate) prepared_inbound: Option<tinychannels_bus::module_inbound::PreparedChannelInbound>,pub(crate) imported_history: Vec<tinyagents_session::transcript::TranscriptMessage>,+ /// Trusted per-turn callback target installed by a hosted relay. Native+ /// configured channels resolve their target from the prepared envelope.+ pub(crate) progressive_target: Option<Arc<super::progressive::NativeProgressiveTarget>>,}impl RuntimeChannelMessage {@@ -47,6 +50,7 @@ impl RuntimeChannelMessage {authenticated_relay: false,prepared_inbound: None,imported_history: Vec::new(),+ progressive_target: None,}}@@ -61,6 +65,7 @@ impl RuntimeChannelMessage {authenticated_relay: delivery.delivered_via_authenticated_relay,prepared_inbound: None,imported_history: Vec::new(),+ progressive_target: None,}}}@@ -73,6 +78,7 @@ impl From<ChannelMessage> for RuntimeChannelMessage {authenticated_relay: false,prepared_inbound: None,imported_history: Vec::new(),+ progressive_target: None,}}}diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rsindex cc719a4d10..b4ef5c7f74 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/progressive.rs@@ -10,26 +10,76 @@ use tokio::sync::mpsc;/// queued follow-up gets a fresh module handle after it wins admission.#[derive(Clone)]pub(crate) struct NativeProgressiveTarget {- object: tinybus::module::ModuleObjectClient,+ kind: ProgressiveTargetKind,channel: tinychannels_bus::channel::ChannelRef,conversation: tinychannels_bus::channel::ConversationRef,}+#[derive(Clone)]+enum ProgressiveTargetKind {+ Configured(tinybus::module::ModuleObjectClient),+ HostedRelay {+ client: tinybus::module::ModuleClient,+ channel: std::sync::Arc<super::super::super::providers::relay::channel::RelayChannel>,+ },+}+impl NativeProgressiveTarget {pub(crate) async fn open(&self,turn_id: &str,) -> anyhow::Result<std::sync::Arc<NativeProgressiveReply>> {- Ok(std::sync::Arc::new(- NativeProgressiveReply::open(- self.object.clone(),- self.channel.clone(),- self.conversation.clone(),- turn_id.to_owned(),- std::time::Duration::from_secs(3_660),- )- .await?,- ))+ let lifetime = std::time::Duration::from_secs(3_660);+ let reply = match &self.kind {+ ProgressiveTargetKind::Configured(object) => {+ NativeProgressiveReply::open(+ object.clone(),+ self.channel.clone(),+ self.conversation.clone(),+ turn_id.to_owned(),+ lifetime,+ )+ .await?+ }+ ProgressiveTargetKind::HostedRelay { client, channel } => {+ let callback = crate::channels::providers::relay::progressive::RelayProgressiveTransport::new(+ Arc::clone(channel),+ self.channel.clone(),+ self.conversation.clone(),+ turn_id.to_owned(),+ );+ let runtime = crate::modules::channel_runtime::ChannelRuntimeLease::open(+ client.clone(),+ callback,+ )+ .await?;+ NativeProgressiveReply::open_hosted(+ runtime,+ self.channel.clone(),+ self.conversation.clone(),+ turn_id.to_owned(),+ lifetime,+ )+ .await?+ }+ };+ Ok(std::sync::Arc::new(reply))+ }+}++pub(crate) fn hosted_relay_target(+ config: &crate::config::Config,+ channel: std::sync::Arc<super::super::super::providers::relay::channel::RelayChannel>,+ channel_ref: tinychannels_bus::channel::ChannelRef,+ conversation: tinychannels_bus::channel::ConversationRef,+) -> NativeProgressiveTarget {+ NativeProgressiveTarget {+ kind: ProgressiveTargetKind::HostedRelay {+ client: crate::modules::client(config.clone()),+ channel,+ },+ channel: channel_ref,+ conversation,}}@@ -53,7 +103,7 @@ pub(crate) fn native_target(.cloned().ok_or_else(|| anyhow::anyhow!("native channel account is not configured"))?;Ok(Some(NativeProgressiveTarget {- object,+ kind: ProgressiveTargetKind::Configured(object),channel: envelope.channel.clone(),conversation: envelope.conversation.clone(),}))diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 3bf6ccb1c1..2fb8d02130 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -46,6 +46,7 @@ pub(crate) async fn process_channel_runtime_message(authenticated_relay,prepared_inbound,imported_history,+ progressive_target,} = runtime_msg;let prepared = match prepared_inbound {Some(prepared) => prepared,@@ -88,11 +89,15 @@ pub(crate) async fn process_channel_runtime_message(let mut envelope = prepared.envelope;envelope.access.delivered_via_upstream_relay = authenticated_relay;crate::channels::host::voice::record_inbound_envelope(&envelope);- let native_target = match super::progressive::native_target(&ctx, &envelope) {- Ok(target) => target.map(Arc::new),- Err(error) => {- tracing::error!("[dispatch] native channel target is invalid: {error}");- return;+ let native_target = if let Some(target) = progressive_target {+ Some(target)+ } else {+ match super::progressive::native_target(&ctx, &envelope) {+ Ok(target) => target.map(Arc::new),+ Err(error) => {+ tracing::error!("[dispatch] native channel target is invalid: {error}");+ return;+ }}};