Skip to content

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

test(channels): migrate dispatch tests to tinychannels v22 types

Steven Enamakelba0a45db20a0
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
index 651c40c225..e6b9267229 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
@@ -13,9 +13,17 @@ impl crate::channels::Channel for DeferredTyping {
fn name(&self) -> &str {
"fixture"
}
- async fn send(&self, _: &crate::channels::SendMessage) -> anyhow::Result<()> {
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy send trait method"
+ )]
+ async fn send(&self, _: &tinychannels_bus::SendMessage) -> anyhow::Result<()> {
Ok(())
}
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy listener trait method"
+ )]
async fn listen(
&self,
_: tokio::sync::mpsc::Sender<traits::ChannelMessage>,
@@ -69,9 +77,17 @@ impl crate::channels::Channel for ProbeTyping {
fn name(&self) -> &str {
"probe"
}
- async fn send(&self, _: &crate::channels::SendMessage) -> anyhow::Result<()> {
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy send trait method"
+ )]
+ async fn send(&self, _: &tinychannels_bus::SendMessage) -> anyhow::Result<()> {
Ok(())
}
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy listener trait method"
+ )]
async fn listen(
&self,
_: tokio::sync::mpsc::Sender<traits::ChannelMessage>,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
index 471645f715..090d586c89 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/dispatch_tests.rs
@@ -3,13 +3,13 @@
//! still goes to the orchestrator over the bus.
use super::*;
-use crate::agent::bus::{mock_agent_run_turn, AgentTurnRequest, AgentTurnResponse};
+use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, mock_agent_run_turn};
use crate::agent::host_agents::{self, HostAgent, HostAgentResolver};
-use crate::channels::context::{ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS};
+use crate::channels::Channel;
+use crate::channels::context::{CHANNEL_MESSAGE_TIMEOUT_SECS, ChannelRuntimeContext};
use crate::channels::runtime::process_channel_message;
-use crate::channels::{Channel, SendMessage};
use crate::core::runtime::{CoreContext, DomainSet};
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
@@ -28,10 +28,18 @@ impl Channel for Telegram {
fn name(&self) -> &str {
"telegram"
}
- async fn send(&self, message: &SendMessage) -> anyhow::Result<()> {
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy send trait method"
+ )]
+ async fn send(&self, message: &traits::SendMessage) -> anyhow::Result<()> {
self.sent.lock().unwrap().push(message.content.clone());
Ok(())
}
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy listener trait method"
+ )]
async fn listen(
&self,
_tx: tokio::sync::mpsc::Sender<traits::ChannelMessage>,
@@ -68,16 +76,23 @@ fn context(channel: Arc<Telegram>, config: Config) -> Arc<ChannelRuntimeContext>
})
}
-fn message(text: &str) -> traits::ChannelMessage {
- traits::ChannelMessage {
- id: "m1".into(),
- sender: "alice".into(),
- sender_name: None,
- reply_target: "42".into(),
- content: text.into(),
- channel: "telegram".into(),
- timestamp: 0,
- thread_ts: None,
+fn message(text: &str) -> traits::ChannelInboundEnvelope {
+ traits::ChannelInboundEnvelope {
+ message_id: "m1".into(),
+ sender: traits::SenderRef {
+ id: "alice".into(),
+ ..Default::default()
+ },
+ conversation: traits::ConversationRef {
+ id: "42".into(),
+ ..Default::default()
+ },
+ text: text.into(),
+ channel: traits::ChannelRef {
+ id: "telegram".into(),
+ ..Default::default()
+ },
+ ..Default::default()
}
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/mod_approval_surface_gating_tests_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/mod_approval_surface_gating_tests_tests.rs
index 5807d7df71..efb64c1ec3 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/mod_approval_surface_gating_tests_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/mod_approval_surface_gating_tests_tests.rs
@@ -1,5 +1,5 @@
use super::channel_has_approval_surface;
-use tinychannels_bus::{Channel, ChannelMessage, SendMessage};
+use tinychannels_bus::Channel;
struct ConfiguredChannel {
approvals: bool,
@@ -11,11 +11,22 @@ impl Channel for ConfiguredChannel {
"configured"
}
- async fn send(&self, _message: &SendMessage) -> anyhow::Result<()> {
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy send trait method"
+ )]
+ async fn send(&self, _message: &tinychannels_bus::SendMessage) -> anyhow::Result<()> {
Ok(())
}
- async fn listen(&self, _tx: tokio::sync::mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {
+ #[allow(
+ deprecated,
+ reason = "TinyChannels v22 still requires the legacy listener trait method"
+ )]
+ async fn listen(
+ &self,
+ _tx: tokio::sync::mpsc::Sender<tinychannels_bus::ChannelMessage>,
+ ) -> anyhow::Result<()> {
Ok(())
}