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 channel context and cron bridge
Steven Enamakelf21724dd0345
diff --git a/crates/openhuman-core/src/channels/context.rs b/crates/openhuman-core/src/channels/context.rsindex acf84c9397..92a804ae4b 100644--- a/crates/openhuman-core/src/channels/context.rs+++ b/crates/openhuman-core/src/channels/context.rs@@ -10,14 +10,14 @@ use std::path::PathBuf;use std::sync::{Arc, Mutex};use tinytools::Tool;-pub(crate) use tinychannels_bus::context::{+pub(crate) use tinychannels_runtime::context::{clear_sender_history, compact_sender_history, ChannelRouteSelection, ConversationHistoryMap,CHANNEL_MESSAGE_TIMEOUT_SECS, CHANNEL_TYPING_REFRESH_INTERVAL_SECS,DEFAULT_CHANNEL_INITIAL_BACKOFF_SECS, DEFAULT_CHANNEL_MAX_BACKOFF_SECS, MAX_CHANNEL_HISTORY,};#[cfg(test)]-pub(crate) use tinychannels_bus::context::{+pub(crate) use tinychannels_runtime::context::{CHANNEL_HISTORY_COMPACT_CONTENT_CHARS, CHANNEL_HISTORY_COMPACT_KEEP_MESSAGES,};diff --git a/crates/openhuman-core/src/channels/context_tests.rs b/crates/openhuman-core/src/channels/context_tests.rsindex e7e91a7346..fdd9de075a 100644--- a/crates/openhuman-core/src/channels/context_tests.rs+++ b/crates/openhuman-core/src/channels/context_tests.rs@@ -92,9 +92,9 @@ fn clear_and_compact_sender_history_update_cached_messages() {let ctx = runtime_context();let sender = "discord_alice_reply_thread:thread-1";let mut history = Vec::new();- history.push(tinychannels_bus::context::ChatMessage::user("short"));+ history.push(tinychannels_runtime::context::ChatMessage::user("short"));history.extend(- (0..20).map(|idx| tinychannels_bus::context::ChatMessage::assistant("x".repeat(700 + idx))),+ (0..20).map(|idx| tinychannels_runtime::context::ChatMessage::assistant("x".repeat(700 + idx))),);ctx.conversation_histories.lock()diff --git a/crates/openhuman-core/src/channels/contract_reexport_tests.rs b/crates/openhuman-core/src/channels/contract_reexport_tests.rsindex b7440bbb23..80e96fd760 100644--- a/crates/openhuman-core/src/channels/contract_reexport_tests.rs+++ b/crates/openhuman-core/src/channels/contract_reexport_tests.rs@@ -8,7 +8,7 @@ struct Recorder {}#[async_trait::async_trait]-impl tinychannels_bus::Channel for Recorder {+impl tinychannels_runtime::Channel for Recorder {fn name(&self) -> &str {"recorder"}@@ -38,7 +38,7 @@ fn channel_vocabulary_is_the_contract_crates_own_types() {use std::any::TypeId;assert_eq!(TypeId::of::<dyn Channel>(),- TypeId::of::<dyn tinychannels_bus::Channel>()+ TypeId::of::<dyn tinychannels_runtime::Channel>());assert_eq!(TypeId::of::<SendMessage>(),diff --git a/crates/openhuman-core/src/channels/mod.rs b/crates/openhuman-core/src/channels/mod.rsindex ccba734c86..31dbd19928 100644--- a/crates/openhuman-core/src/channels/mod.rs+++ b/crates/openhuman-core/src/channels/mod.rs@@ -11,7 +11,8 @@ 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::SendMessage;+pub use tinychannels_runtime::{Channel, ChannelSendExt};#[cfg(feature = "channels")]pub mod bus;diff --git a/crates/openhuman-core/src/channels/providers/relay/channel.rs b/crates/openhuman-core/src/channels/providers/relay/channel.rsindex d3426ddf8d..8aadcbae8a 100644--- a/crates/openhuman-core/src/channels/providers/relay/channel.rs+++ b/crates/openhuman-core/src/channels/providers/relay/channel.rs@@ -11,7 +11,8 @@ use async_trait::async_trait;use serde_json::json;use crate::web_chat::{publish_web_channel_event, WebChannelEvent};-use tinychannels_bus::{Channel, ChannelMessage, SendMessage};+use tinychannels_bus::{ChannelMessage, SendMessage};+use tinychannels_runtime::Channel;/// The event name a relayed reply is published under.pub const CHANNEL_OUTBOUND_EVENT: &str = "channel_outbound";diff --git a/crates/openhuman-core/src/channels/providers/relay/ops.rs b/crates/openhuman-core/src/channels/providers/relay/ops.rsindex 73869968f5..a1bbbf283b 100644--- a/crates/openhuman-core/src/channels/providers/relay/ops.rs+++ b/crates/openhuman-core/src/channels/providers/relay/ops.rs@@ -133,7 +133,7 @@ pub(crate) async fn run_relay_turn(tracing::warn!("relayed channel runtime limits unavailable: {error}");let reply ="⚠️ This chat's assistant is not available right now. Please try again later.";- let _ = tinychannels_bus::Channel::send(+ let _ = tinychannels_runtime::Channel::send(channel.as_ref(),&crate::channels::SendMessage::new(reply, ¶ms.chat_id),)@@ -170,7 +170,7 @@ pub(crate) async fn run_relay_turn();let reply ="⚠️ This chat's assistant is not available right now. Please try again later.";- let _ = tinychannels_bus::Channel::send(+ let _ = tinychannels_runtime::Channel::send(channel.as_ref(),&crate::channels::SendMessage::new(reply, ¶ms.chat_id),)diff --git a/crates/openhuman-core/src/channels/providers/relay/store.rs b/crates/openhuman-core/src/channels/providers/relay/store.rsindex 1dc0313803..504a12bbaf 100644--- a/crates/openhuman-core/src/channels/providers/relay/store.rs+++ b/crates/openhuman-core/src/channels/providers/relay/store.rs@@ -15,7 +15,7 @@ type ThreadLocks = Mutex<HashMap<(PathBuf, String), Arc<tokio::sync::Mutex<()>>>use chrono::Utc;use serde_json::json;-use tinychannels_bus::context::ChatMessage;+use tinychannels_runtime::context::ChatMessage;use super::params::RelayInboundParams;use crate::threads::store::blocking as conversations;diff --git a/crates/openhuman-core/src/channels/routes_tests.rs b/crates/openhuman-core/src/channels/routes_tests.rsindex d1c642f116..6faad77f51 100644--- a/crates/openhuman-core/src/channels/routes_tests.rs+++ b/crates/openhuman-core/src/channels/routes_tests.rs@@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};use std::task::{Context, Poll, Waker};use tinybus::EventHandler;use tinychannels::routes::resolve_provider_alias;-use tinychannels_bus::context::ChatMessage;+use tinychannels_runtime::context::ChatMessage;use tinychannels_bus::ChannelMessage;use tinytools::{Tool, ToolResult};diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rsindex 49e939da66..c83696402d 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs@@ -18,7 +18,7 @@ use std::sync::Arc;use std::time::{Duration, Instant};use tinyagents_session::transcript::TranscriptMessage;use tinychannels_bus as traits;-use tinychannels_bus::context::ChatMessage;+use tinychannels_runtime::context::ChatMessage;use tokio_util::sync::CancellationToken;use tokio_util::task::AbortOnDropHandle;diff --git a/crates/openhuman-core/src/channels/runtime/startup.rs b/crates/openhuman-core/src/channels/runtime/startup.rsindex 2ddb66581a..8092b220a9 100644--- a/crates/openhuman-core/src/channels/runtime/startup.rs+++ b/crates/openhuman-core/src/channels/runtime/startup.rs@@ -37,7 +37,7 @@ pub(crate) async fn prepare_runtime_limits(ChannelControlResult::RuntimeLimits {timeout_secs,max_in_flight,- } if timeout_secs >= tinychannels_bus::context::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS+ } if timeout_secs >= tinychannels_runtime::context::MIN_CHANNEL_MESSAGE_TIMEOUT_SECS&& max_in_flight > 0 =>{Ok((timeout_secs, max_in_flight))diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rsindex 3f661745d1..f58095305b 100644--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers.rs@@ -14,7 +14,8 @@ use tinychannels_bus::module_runtime::{ChannelIngressKind, ChannelMessagePreparation, ConfiguredChannelInfo,};use tinychannels_bus::module_supervision::ChannelSupervisionPolicy;-use tinychannels_bus::{Channel, ChannelMessage, SendMessage};+use tinychannels_bus::{ChannelMessage, SendMessage};+use tinychannels_runtime::Channel;use tinychannels_bus::{ChannelInteraction, ChannelInteractionResult};use tokio::sync::mpsc;diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rsindex 79edbb13ea..dc96145f3c 100644--- a/crates/openhuman-core/src/channels/runtime/test_support.rs+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs@@ -21,7 +21,7 @@ use std::path::PathBuf;use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};use std::time::Duration;-use tinychannels_bus::context::ChatMessage;+use tinychannels_runtime::context::ChatMessage;use tinychannels_bus::{ChannelMessage, SendMessage};use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};use tinytools::{Tool, ToolResult};diff --git a/crates/openhuman-core/src/cron/bus.rs b/crates/openhuman-core/src/cron/bus.rsindex fe1a72afd7..4a95582319 100644--- a/crates/openhuman-core/src/cron/bus.rs+++ b/crates/openhuman-core/src/cron/bus.rs@@ -11,7 +11,8 @@ use async_trait::async_trait;use std::collections::HashMap;use std::sync::Arc;use tinybus::EventHandler;-use tinychannels_bus::{Channel, SendMessage};+use tinychannels_bus::SendMessage;+use tinychannels_runtime::Channel;/// Subscribes to `CronDeliveryRequested` events and dispatches/// the output to the named channel.diff --git a/crates/openhuman-core/src/cron/channel_bridge.rs b/crates/openhuman-core/src/cron/channel_bridge.rsindex db9614c05c..315428b21d 100644--- a/crates/openhuman-core/src/cron/channel_bridge.rs+++ b/crates/openhuman-core/src/cron/channel_bridge.rs@@ -10,8 +10,9 @@use std::collections::HashMap;use std::sync::{Arc, Mutex, RwLock};-use tinychannels_bus::context::ChatMessage;-use tinychannels_bus::{Channel, SendMessage};+use tinychannels_runtime::context::ChatMessage;+use tinychannels_bus::SendMessage;+use tinychannels_runtime::Channel;/// Same shape as `channels::context::ConversationHistoryMap`, spelled out so/// cron does not depend on the feature-gated `channels` module.