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): add native progressive reply handle for channel output
Steven Enamakel643cf51e0530
diff --git a/crates/openhuman-core/src/channels/bus.rs b/crates/openhuman-core/src/channels/bus.rsindex 429d696440..061787fb07 100644--- a/crates/openhuman-core/src/channels/bus.rs+++ b/crates/openhuman-core/src/channels/bus.rs@@ -10,6 +10,7 @@ mod subscriber;mod thread_id;pub use subscriber::ChannelInboundSubscriber;+pub(crate) use delivery::NativeProgressiveReply;#[cfg(test)]pub(crate) use thread_id::derive_inbound_thread_id;diff --git a/crates/openhuman-core/src/channels/bus/delivery.rs b/crates/openhuman-core/src/channels/bus/delivery.rsindex f27402365b..51f485d39b 100644--- a/crates/openhuman-core/src/channels/bus/delivery.rs+++ b/crates/openhuman-core/src/channels/bus/delivery.rs@@ -9,8 +9,8 @@ use serde_json::json;use serde_json::Value;use tinybus::module::ModuleCallError;use tinychannels_bus::module_progressive::{- ProgressiveCommand, ProgressiveEvent, ProgressiveResult, ProgressiveTransportRequest,- ProgressiveTransportResult,+ ChannelOutputEvent, ProgressiveCommand, ProgressiveEvent, ProgressiveResult,+ ProgressiveTransportRequest, ProgressiveTransportResult,};use tinychannels_bus::{methods, ChannelBackendRequest, ChannelBackendResult};@@ -153,6 +153,81 @@ pub(super) struct ModuleProgressiveReply {handle: String,}+/// Native listener output handle on the already-running compiled module+/// object. Its callback is the captured configured provider adapter, so native+/// output never falls back to the hosted REST transport.+pub(crate) struct NativeProgressiveReply {+ object: tinybus::module::ModuleObjectClient,+ handle: String,+}++impl NativeProgressiveReply {+ pub(crate) async fn open(+ object: tinybus::module::ModuleObjectClient,+ channel: tinychannels_bus::channel::ChannelRef,+ conversation: tinychannels_bus::channel::ConversationRef,+ turn_id: String,+ lifetime: std::time::Duration,+ ) -> anyhow::Result<Self> {+ let result: ProgressiveResult = object+ .call_confidential(+ methods::EXECUTE_PROGRESSIVE,+ (ProgressiveCommand::OpenOutput {+ channel,+ conversation,+ turn_id,+ lifetime_ms: lifetime.as_millis().min(u64::MAX as u128) as u64,+ },),+ )+ .await?;+ match result {+ ProgressiveResult::Opened { handle } if !handle.is_empty() && handle.len() <= 128 => {+ Ok(Self { object, handle })+ }+ _ => {+ crate::modules::report::malformed_reply("tinychannels");+ Err(ModuleCallError::ModuleFault.into())+ }+ }+ }++ pub(crate) async fn feed(&self, events: Vec<ChannelOutputEvent>) -> Result<(), ModuleCallError> {+ let result: ProgressiveResult = self+ .object+ .call_confidential(+ methods::EXECUTE_PROGRESSIVE,+ (ProgressiveCommand::FeedOutput {+ handle: self.handle.clone(),+ events,+ },),+ )+ .await?;+ if !matches!(result, ProgressiveResult::Updated | ProgressiveResult::DeliveryBatch { .. }) {+ crate::modules::report::malformed_reply("tinychannels");+ return Err(ModuleCallError::ModuleFault);+ }+ Ok(())+ }++ pub(crate) async fn finish(&self, text: &str) -> Result<(), ModuleCallError> {+ let result: ProgressiveResult = self+ .object+ .call_confidential(+ methods::EXECUTE_PROGRESSIVE,+ (ProgressiveCommand::Finish {+ handle: self.handle.clone(),+ text: text.to_owned(),+ },),+ )+ .await?;+ if result != ProgressiveResult::Closed {+ crate::modules::report::malformed_reply("tinychannels");+ return Err(ModuleCallError::ModuleFault);+ }+ Ok(())+ }+}+impl ModuleProgressiveReply {pub(super) async fn open(config: crate::config::Config,