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
chore(channels): reorder imports and reformat dispatch code
Steven Enamakel4a1c4f5e624a
diff --git a/crates/openhuman-core/src/channels/proactive.rs b/crates/openhuman-core/src/channels/proactive.rsindex 53b366f9a5..5f7d1decdc 100644--- a/crates/openhuman-core/src/channels/proactive.rs+++ b/crates/openhuman-core/src/channels/proactive.rs@@ -22,8 +22,8 @@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;+use crate::web_chat::publish_web_channel_event;use async_trait::async_trait;use std::collections::HashMap;use std::sync::{Arc, RwLock};diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rsindex c53b41f2ca..2c82f109ab 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers.rs@@ -54,7 +54,9 @@ 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: &tinychannels_bus::ChannelInboundEnvelope) -> String {+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")diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rsindex 3d4f739bb4..651c40c225 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs@@ -1,7 +1,7 @@use super::*;use crate::core::runtime::DispatchCtx;use std::sync::Arc;-use tokio::sync::{oneshot, Notify};+use tokio::sync::{Notify, oneshot};struct DeferredTyping {started: Notify,diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rsindex 83b7c226f4..77cf608265 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/inbound_batch_tests.rs@@ -7,14 +7,20 @@ fn queued(seq: u64, id: &str, timestamp: u64, content: &str) -> QueuedInbound {inbound: AdmittedInbound {msg: ChannelInboundEnvelope {message_id: id.to_string(),- sender: SenderRef { id: "alice".to_string(), ..Default::default() },+ sender: SenderRef {+ id: "alice".to_string(),+ ..Default::default()+ },conversation: ConversationRef {id: format!("reply-{id}"),thread_id: Some(format!("thread-{id}")),..Default::default()},text: content.to_string(),- channel: ChannelRef { id: "telegram".to_string(), ..Default::default() },+ channel: ChannelRef {+ id: "telegram".to_string(),+ ..Default::default()+ },timestamp_unix_ms: Some(timestamp),..Default::default()},@@ -29,7 +35,10 @@ fn single_message_passes_through_unchanged() {let merged = merge_channel_batch(vec![one.clone()]).unwrap();assert_eq!(merged.msg.text, " hello ");assert_eq!(merged.msg.message_id, "m1");- assert_eq!(merged.msg.conversation.thread_id.as_deref(), Some("thread-m1"));+ assert_eq!(+ merged.msg.conversation.thread_id.as_deref(),+ Some("thread-m1")+ );assert_eq!(merged.history_key, one.inbound.history_key);assert!(merge_channel_batch(Vec::new()).is_none());}@@ -45,7 +54,10 @@ fn merge_orders_by_timestamp_then_receive_order_and_uses_newest_as_base() {assert_eq!(merged.msg.text, "first\nsecond\nthird");assert_eq!(merged.msg.message_id, "m3");assert_eq!(merged.msg.conversation.id, "reply-m3");- assert_eq!(merged.msg.conversation.thread_id.as_deref(), Some("thread-m3"));+ assert_eq!(+ merged.msg.conversation.thread_id.as_deref(),+ Some("thread-m3")+ );assert_eq!(merged.msg.timestamp_unix_ms, Some(20));}diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rsindex 38056f34f4..ef3cbe3aaa 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor.rs@@ -23,7 +23,7 @@ mod bus_turn;mod in_order;mod turn;-use super::inbound_batch::{merge_channel_batch, QueuedInbound};+use super::inbound_batch::{QueuedInbound, merge_channel_batch};use crate::channels::context::ChannelRuntimeContext;use crate::config::InboundDebounceConfig;use crate::inbound_debounce::{KeyedDebouncer, Push};@@ -64,8 +64,8 @@ impl RuntimeChannelMessage {}}-use admit::admit_runtime_message;pub(crate) use admit::AdmittedInbound;+use admit::admit_runtime_message;#[cfg(test)]pub(crate) use approval::channel_has_approval_surface;use turn::run_admitted_turn;diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rsindex 7648ed86ac..bf77dad619 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/admit.rs@@ -10,8 +10,8 @@ use crate::util::truncate_with_ellipsis;use std::sync::Arc;use tinychannels_bus::ChannelInboundEnvelope;-use super::approval::{channel_has_approval_surface, try_route_approval_reply};use super::RuntimeChannelMessage;+use super::approval::{channel_has_approval_surface, try_route_approval_reply};/// A prepared inbound message that still needs an agent turn: not a runtime/// command and not an approval reply.diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rsindex 37f50c1cb2..072649449b 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/bus_turn.rs@@ -1,7 +1,7 @@//! The orchestrator path: an unbound channel's turn goes over the native bus//! to the `agent.run_turn` handler, with the orchestrator's tool scoping.-use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METHOD};+use crate::agent::bus::{AGENT_RUN_TURN_METHOD, AgentTurnRequest, AgentTurnResponse};use crate::channels::context::{ChannelRouteSelection, ChannelRuntimeContext};use crate::core::bus::BUS;use crate::progress::AgentProgress;diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex f1f6a3c780..507c50f5c3 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -4,7 +4,7 @@use crate::agent::bus::AgentTurnResponse;use crate::channels::context::{- compact_sender_history, is_context_window_overflow_error, ChannelRuntimeContext,+ ChannelRuntimeContext, compact_sender_history, is_context_window_overflow_error,};use crate::channels::outbound::text_message;use crate::channels::routes::{get_or_create_turn_model_source, get_route_selection};@@ -15,20 +15,20 @@ use crate::util::truncate_with_ellipsis;use std::sync::Arc;use std::time::{Duration, Instant};use tinyagents_session::transcript::TranscriptMessage;-use tinychannels_bus::context::ChatMessage;use tinychannels_bus::ChannelInboundEnvelope;+use tinychannels_bus::context::ChatMessage;use tokio_util::sync::CancellationToken;use tokio_util::task::AbortOnDropHandle;use super::super::helpers::{- build_channel_context_block, log_worker_join_result, spawn_typing_task,- REPLY_LOG_TRUNCATE_CHARS,+ REPLY_LOG_TRUNCATE_CHARS, build_channel_context_block, log_worker_join_result,+ spawn_typing_task,};-use super::super::host_agent::{self, run_host_agent_turn, seed_rows, HostChannelTurn, HostRoute};-use super::admit::{admit_runtime_message, AdmittedInbound};+use super::super::host_agent::{self, HostChannelTurn, HostRoute, run_host_agent_turn, seed_rows};+use super::RuntimeChannelMessage;+use super::admit::{AdmittedInbound, admit_runtime_message};use super::approval::channel_has_approval_surface;use super::bus_turn::dispatch_bus_turn;-use super::RuntimeChannelMessage;pub(crate) async fn process_channel_message(ctx: Arc<ChannelRuntimeContext>,diff --git a/crates/openhuman-core/src/channels/runtime/dispatch_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch_tests.rsindex 16e2e804f7..f772d22c79 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch_tests.rs@@ -80,9 +80,18 @@ fn ack_reaction_is_deterministic_and_total_on_edge_inputs() {fn cm(channel: &str, reply_target: &str) -> tinychannels_bus::ChannelInboundEnvelope {tinychannels_bus::ChannelInboundEnvelope {- channel: tinychannels_bus::ChannelRef { id: channel.into(), ..Default::default() },- conversation: tinychannels_bus::ConversationRef { id: reply_target.into(), ..Default::default() },- sender: tinychannels_bus::SenderRef { id: "alice".into(), ..Default::default() },+ channel: tinychannels_bus::ChannelRef {+ id: channel.into(),+ ..Default::default()+ },+ conversation: tinychannels_bus::ConversationRef {+ id: reply_target.into(),+ ..Default::default()+ },+ sender: tinychannels_bus::SenderRef {+ id: "alice".into(),+ ..Default::default()+ },text: "hi".into(),message_id: "m1".into(),..Default::default()