Skip to content

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

refactor(channels): move outbound send helpers into a private module

Steven Enamakel441d1287af18
diff --git a/crates/openhuman-core/src/channels/mod.rs b/crates/openhuman-core/src/channels/mod.rs
index 338508cb7a..d6680f2a89 100644
--- a/crates/openhuman-core/src/channels/mod.rs
+++ b/crates/openhuman-core/src/channels/mod.rs
@@ -10,7 +10,7 @@ pub mod contract_schema;
#[cfg(any(feature = "voice", feature = "channels"))]
pub(crate) mod credentials;
-pub use tinychannels_bus::{Channel, ChannelSendExt, SendMessage};
+pub use tinychannels_bus::Channel;
#[cfg(feature = "channels")]
pub mod bus;
@@ -27,6 +27,8 @@ pub mod controllers;
#[cfg(feature = "channels")]
pub mod host;
#[cfg(feature = "channels")]
+mod outbound;
+#[cfg(feature = "channels")]
pub mod proactive;
pub(crate) mod prompt;
#[cfg(feature = "channels")]
diff --git a/crates/openhuman-core/src/channels/outbound.rs b/crates/openhuman-core/src/channels/outbound.rs
new file mode 100644
index 0000000000..c6a3e118a7
--- /dev/null
+++ b/crates/openhuman-core/src/channels/outbound.rs
@@ -0,0 +1,34 @@
+//! Host adapters for canonical TinyChannels outbound messages.
+
+use tinychannels_bus::{
+ ChannelOutboundMessage, ChannelOutboundIntent, ChannelRef, ConversationRef, DeliveryDurability,
+ OutboundPayload,
+};
+
+/// Build a text message addressed to one channel conversation.
+pub(crate) fn text_message(
+ channel: &str,
+ conversation: &str,
+ text: impl Into<String>,
+ thread_id: Option<String>,
+) -> ChannelOutboundMessage {
+ let intent = ChannelOutboundIntent {
+ idempotency_key: uuid::Uuid::new_v4().to_string(),
+ channel_id: channel.to_owned(),
+ conversation_id: conversation.to_owned(),
+ channel_ref: Some(ChannelRef {
+ id: channel.to_owned(),
+ account_id: None,
+ }),
+ conversation_ref: Some(ConversationRef {
+ id: conversation.to_owned(),
+ thread_id: thread_id.clone(),
+ ..Default::default()
+ }),
+ thread_id,
+ durability: DeliveryDurability::BestEffort,
+ payload: OutboundPayload::Text { text: text.into() },
+ ..Default::default()
+ };
+ ChannelOutboundMessage::from_intent(&intent)
+}