Skip to content

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

refactor(channels): migrate dispatch to typed inbound envelopes

Steven Enamakel55bd2404d23d
diff --git a/crates/openhuman-core/src/channels/proactive.rs b/crates/openhuman-core/src/channels/proactive.rs
index 716c0f5d39..53b366f9a5 100644
--- a/crates/openhuman-core/src/channels/proactive.rs
+++ b/crates/openhuman-core/src/channels/proactive.rs
@@ -19,7 +19,8 @@
//! (step 1). This avoids double-delivering to a channel that doesn't
//! exist.
-use crate::channels::{Channel, ChannelSendExt, SendMessage};
+use crate::channels::Channel;
+use crate::channels::outbound::text_message;
use crate::core::events::DomainEvent;
use crate::web_chat::publish_web_channel_event;
use crate::web_chat::WebChannelEvent;
@@ -336,7 +337,7 @@ impl EventHandler<DomainEvent> for ProactiveMessageSubscriber {
}
let send_result = ch
- .send_with_outbound_intent(&SendMessage::new(message, &recipient))
+ .send_typed(&text_message(&key, &recipient, message, None))
.await;
// Record the terminal status on the approval audit
// row before we log the outcome — best-effort, see
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
index 902f59a767..c53b41f2ca 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs
@@ -54,15 +54,15 @@ pub(super) fn spawn_typing_task(
/// Reminders and scheduled tasks created from this chat are delivered back to
/// it automatically (the job records its origin), so the model is told only
/// that, not a target to copy.
-pub(super) fn build_channel_context_block(msg: &traits::ChannelMessage) -> String {
- let channel = msg.channel.trim();
+pub(super) fn build_channel_context_block(msg: &tinychannels_bus::ChannelInboundEnvelope) -> String {
+ let channel = msg.channel.id.trim();
if channel.is_empty()
|| channel.eq_ignore_ascii_case("web")
|| channel.eq_ignore_ascii_case("cli")
{
return String::new();
}
- let reply_target = msg.reply_target.trim();
+ let reply_target = msg.conversation.id.trim();
if reply_target.is_empty() {
return String::new();
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
index 15e5413ccc..42ae7aaff2 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch.rs
@@ -3,7 +3,7 @@
use super::processor::AdmittedInbound;
use crate::inbound_debounce::DebounceItem;
-use tinychannels_bus::channel::ContentPart;
+use tinychannels_bus::channel::{ContentPart, ConversationRef};
const MEDIA_MARKERS: [&str; 5] = ["[IMAGE:", "[FILE:", "[VIDEO:", "[DOCUMENT:", "[Attachment:"];
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/mod_test_support_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/mod_test_support_tests.rs
index f410efe876..6ee48c3297 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/mod_test_support_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/mod_test_support_tests.rs
@@ -2,7 +2,9 @@
use super::*;
-pub fn build_channel_context_block_for_test(msg: &traits::ChannelMessage) -> String {
+pub fn build_channel_context_block_for_test(
+ msg: &tinychannels_bus::ChannelInboundEnvelope,
+) -> String {
build_channel_context_block(msg)
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
index 8a38dcdfc6..38056f34f4 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs
@@ -110,8 +110,8 @@ pub(crate) async fn run_message_dispatch_loop(
match merge_channel_batch(batch) {
Some(admitted) => {
tracing::debug!(
- channel = %admitted.msg.channel,
- message_id = %admitted.msg.id,
+ channel = %admitted.msg.channel.id,
+ message_id = %admitted.msg.message_id,
batch_len,
in_flight = turns.len() + 1,
held,
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs
index ec1d8e1005..7648ed86ac 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs
@@ -8,7 +8,7 @@ use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::util::truncate_with_ellipsis;
use std::sync::Arc;
-use tinychannels_bus as traits;
+use tinychannels_bus::ChannelInboundEnvelope;
use super::approval::{channel_has_approval_surface, try_route_approval_reply};
use super::RuntimeChannelMessage;
@@ -17,7 +17,7 @@ use super::RuntimeChannelMessage;
/// command and not an approval reply.
#[derive(Debug, Clone)]
pub(crate) struct AdmittedInbound {
- pub(crate) msg: traits::ChannelMessage,
+ pub(crate) msg: ChannelInboundEnvelope,
pub(crate) history_key: String,
}