Skip to content

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

feat(channels): add relay provider module

Steven Enamakel07970d3bd04a
diff --git a/crates/openhuman-core/src/channels/providers/mod.rs b/crates/openhuman-core/src/channels/providers/mod.rs
index 297d692b86..790deb1ad7 100644
--- a/crates/openhuman-core/src/channels/providers/mod.rs
+++ b/crates/openhuman-core/src/channels/providers/mod.rs
@@ -2,6 +2,10 @@
//!
//! Provider transports, and the provider-independent remote control and
//! in-chat approvals that used to be Telegram glue, belong to `tinychannels`.
+//! [`relay`] is the exception: not a transport, but the host-side entry for
+//! messages a gateway relays in from a hosted platform.
+
+pub mod relay;
pub use tinychannels::providers::email_channel;
pub use tinychannels::providers::lark;
diff --git a/crates/openhuman-core/src/channels/providers/relay/mod.rs b/crates/openhuman-core/src/channels/providers/relay/mod.rs
new file mode 100644
index 0000000000..1a2ae246f7
--- /dev/null
+++ b/crates/openhuman-core/src/channels/providers/relay/mod.rs
@@ -0,0 +1,34 @@
+//! Hosted-channel relay: messages from a chat platform the core does not
+//! listen to itself, relayed in by a gateway as the user they belong to.
+//!
+//! In SaaS the cloud gateway owns the hosted Telegram, iMessage and Discord
+//! webhooks and the account links (`openhuman_tinyhumans::hosted::channel_link`).
+//! For each message it calls `channel_relay_inbound` under that user's scope.
+//! The core:
+//!
+//! 1. validates the message ([`params`]) and derives its thread,
+//! `channel:<channel>/<sender>/<chat>` (`channels::bus::derive_inbound_thread_id`);
+//! 2. records the message on that thread in the caller's workspace
+//! ([`store`]), refusing a duplicate `message_id`;
+//! 3. runs the turn through the channel dispatch pipeline
+//! (`channels::runtime`), under the channel's `ExternalChannel` origin, with
+//! a runtime context built from the caller's config ([`ops`]);
+//! 4. publishes each reply as a `channel_outbound` event on the caller's
+//! `/events` stream ([`RelayChannel`]) and records it on the thread.
+//!
+//! It works in a single-user core too (an embedder's or a local relay), where
+//! the caller's config is the process's.
+
+mod channel;
+mod ops;
+mod params;
+mod schemas;
+mod store;
+
+pub use channel::{RelayChannel, CHANNEL_OUTBOUND_EVENT};
+pub use ops::channel_relay_inbound;
+pub use params::{
+ validate_channel, validate_id, RelayInboundParams, DEFAULT_RELAY_CLIENT_ID, MAX_CHANNEL_LEN,
+ MAX_ID_LEN, MAX_SENDER_NAME_CHARS, MAX_TEXT_BYTES, RESERVED_CHANNELS,
+};
+pub use schemas::{all_relay_controller_schemas, all_relay_registered_controllers};