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 test channel handle variant
Steven Enamakelca16be95cd4c
diff --git a/crates/openhuman-core/src/channels/runtime/startup.rs b/crates/openhuman-core/src/channels/runtime/startup.rsindex 8cbd1235e6..6175e91acc 100644--- a/crates/openhuman-core/src/channels/runtime/startup.rs+++ b/crates/openhuman-core/src/channels/runtime/startup.rs@@ -25,6 +25,8 @@ pub(crate) type ChannelHandle = dyn tinychannels_runtime::Channel;pub(crate) enum ChannelHandle {Module(module_providers::ModuleChannel),Relay(std::sync::Arc<crate::channels::providers::relay::RelayChannel>),+ #[cfg(debug_assertions)]+ Test(std::sync::Arc<dyn tinychannels_runtime::Channel>),}#[cfg(not(test))]@@ -33,6 +35,8 @@ impl ChannelHandle {match self {Self::Module(channel) => &channel.name,Self::Relay(channel) => channel.name(),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.name(),}}@@ -40,6 +44,8 @@ impl ChannelHandle {match self {Self::Module(channel) => channel.proactive_target(),Self::Relay(_) => None,+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.proactive_target(),}}@@ -47,11 +53,18 @@ impl ChannelHandle {match self {Self::Module(channel) => channel.capabilities(),Self::Relay(_) => tinychannels_bus::ChannelCapabilities::unknown(),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.capabilities(),}}pub(crate) fn supports_reactions(&self) -> bool {- matches!(self, Self::Module(channel) if channel.interaction.supports_reactions)+ match self {+ Self::Module(channel) => channel.interaction.supports_reactions,+ Self::Relay(_) => false,+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.supports_reactions(),+ }}pub(crate) async fn send(@@ -61,6 +74,8 @@ impl ChannelHandle {match self {Self::Module(channel) => channel.send_prepared(message).await,Self::Relay(channel) => channel.send(message).await,+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.send(message).await,}}@@ -79,6 +94,8 @@ impl ChannelHandle {}).await,Self::Relay(_) => Ok(()),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.start_typing(recipient).await,}}@@ -90,6 +107,8 @@ impl ChannelHandle {}).await,Self::Relay(_) => Ok(()),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.stop_typing(recipient).await,}}@@ -101,6 +120,8 @@ impl ChannelHandle {match self {Self::Module(channel) => channel.begin_typing_refresh(recipient, interval_secs).await,Self::Relay(_) => Ok(None),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.begin_typing_refresh(recipient, interval_secs).await,}}@@ -108,6 +129,8 @@ impl ChannelHandle {match self {Self::Module(channel) => channel.end_typing_refresh(handle).await,Self::Relay(_) => Ok(()),+ #[cfg(debug_assertions)]+ Self::Test(channel) => channel.end_typing_refresh(handle).await,}}}diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rsindex bb81dc69e8..d433af18c5 100644--- a/crates/openhuman-core/src/channels/runtime/test_support.rs+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs@@ -326,9 +326,19 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHasupports_reactions: options.supports_reactions,state: Arc::clone(&state),});+ #[cfg(test)]let channel: Arc<dyn Channel> = channel_impl;+ #[cfg(test)]let mut channels_by_name = HashMap::new();+ #[cfg(test)]channels_by_name.insert(options.channel_name.clone(), channel);+ #[cfg(not(test))]+ let mut channels_by_name = HashMap::new();+ #[cfg(not(test))]+ channels_by_name.insert(+ options.channel_name.clone(),+ Arc::new(crate::channels::runtime::ChannelHandle::Test(channel_impl)),+ );let model: Arc<dyn ChatModel<()>> = Arc::new(HarnessModel);let mut provider_cache = HashMap::new();