Skip to content

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

feat(channels): route hosted progressive replies through module runtime

Steven Enamakelfa0a69f3478f
diff --git a/crates/openhuman-core/src/channels/README.md b/crates/openhuman-core/src/channels/README.md
index 3e0958276e..0b2fadf169 100644
--- a/crates/openhuman-core/src/channels/README.md
+++ b/crates/openhuman-core/src/channels/README.md
@@ -56,19 +56,16 @@ The listener supervisor reports through `OpenHumanListenerObserver`, which publi
The desktop app usually has no native listeners. Messages for hosted bots arrive over the backend socket instead: [`platform/socket/event_handlers.rs`](../platform/socket/event_handlers.rs) publishes `DomainEvent::ChannelInboundMessage`. `bus::ChannelInboundSubscriber` ([`bus/subscriber.rs`](./bus/subscriber.rs)) handles it. It is registered on the always-on boot path by `register_domain_subscribers` in [`core/runtime/subscribers.rs`](../core/runtime/subscribers.rs), not by `start_channels`, so it works on a core that never starts listeners.
-The subscriber derives a thread id from (channel, sender, reply target, thread) with `derive_inbound_thread_id`, starts a turn through `web_chat::start_chat`, and watches the web-channel event stream for that request. The reply is shown progressively with `tinychannels::delivery::progressive::ProgressiveReply`: a draft that is edited as text streams in, typing refreshes, and filler bubbles on slow turns, then a finalize. The transport underneath is `BackendProgressiveSender` ([`bus/delivery.rs`](./bus/delivery.rs)), which sends through `BackendClient` with idempotency keys and maps typed `BackendApiError`s (`ChannelEditUnsupported`, `MessageNotFound`) to the recoveries the progressive driver expects.
+The subscriber obtains the existing thread and client identifiers through confidential `PrepareChannelIdentity`, opens a private module runtime, starts a turn through `web_chat::start_chat`, and projects ordered turn events in bounded batches. `ExecuteProgressive` owns drafts, typing refreshes, filler bubbles, idempotency and final delivery inside the module. The callback in [`bus/delivery.rs`](./bus/delivery.rs) supplies managed REST transport with the credential and channel captured for that turn. Typed backend errors become transport facts that the module uses for recovery. Sign-out cancels the captured transport; close retains the callback until the module acknowledges shutdown.
```text
backend socket --> DomainEvent::ChannelInboundMessage
|
- v
- ChannelInboundSubscriber
- | web_chat::start_chat(thread_id, ...)
- v
- web channel events --> ProgressiveReply
- |
- v
- BackendProgressiveSender --> backend REST
+ PrepareChannelIdentity --> web_chat::start_chat
+ |
+ ordered turn event batches --> ExecuteProgressive(handle)
+ |
+ captured managed callback --> backend REST
```
### Path 3: gateway-relayed inbound (`channel_relay_inbound`)
@@ -102,7 +99,7 @@ When a tool call needs approval on a channel whose provider has `chat_approvals`
| `host/` | The OpenHuman implementation of the `tinychannels::host` boundary: `build_channel_host` and its adapters (`adapters.rs`), the approval-surface and turn-state subscribers (`channel_events.rs`), and the remote-control host (`remote_control.rs`). |
| `runtime/` | Startup, listener supervision, the account-lifetime session, and the dispatch pipeline. See [runtime/README.md](runtime/README.md). |
| `controllers/` | The `channels.*` RPC namespace and `OpenHumanChannelBackend`. See [controllers/README.md](controllers/README.md). |
-| [`bus.rs`](./bus.rs), `bus/` | `ChannelInboundSubscriber` (`subscriber.rs`), the backend progressive sender (`delivery.rs`), and the inbound thread-id re-export (`thread_id.rs`). |
+| [`bus.rs`](./bus.rs), `bus/` | `ChannelInboundSubscriber` (`subscriber.rs`), the captured managed transport (`delivery.rs`), and the inbound thread-id re-export (`thread_id.rs`). |
| `context.rs` | `ChannelRuntimeContext`, per-sender history maps, history compaction, and timeout/backoff constants re-exported from `tinychannels::context`. |
| `routes.rs` | Slash-command parsing and per-sender route selection (provider and model overrides). |
| `proactive.rs` | `ProactiveMessageSubscriber` and the active-channel handle. |
diff --git a/crates/openhuman-core/src/channels/host/remote_control.rs b/crates/openhuman-core/src/channels/host/remote_control.rs
index ea39374b57..d8ecbe2e9e 100644
--- a/crates/openhuman-core/src/channels/host/remote_control.rs
+++ b/crates/openhuman-core/src/channels/host/remote_control.rs
@@ -88,3 +88,56 @@ impl RemoteControlHost for RuntimeRemoteControl<'_> {
crate::web_chat::invalidate_thread_sessions(thread_id).await;
}
}
+
+/// Serves product-owned conversation state to the captured module runtime.
+pub(crate) async fn dispatch_callback(
+ ctx: &ChannelRuntimeContext,
+ request: tinychannels_bus::module_remote::RemoteHostRequest,
+) -> tinybus::Result<tinychannels_bus::module_remote::RemoteHostResult> {
+ use tinychannels_bus::module_remote::{
+ RemoteHostRequest as Request, RemoteHostResult as Response,
+ };
+ match request {
+ Request::ListThreads => {
+ let threads = conversations::list_threads(ctx.workspace_dir.to_path_buf())
+ .map_err(|_| tinybus::Error::failed("conversation state unavailable"))?;
+ Ok(Response::Threads(
+ threads
+ .into_iter()
+ .map(
+ |thread| tinychannels_bus::module_remote::RemoteThreadSummary {
+ id: thread.id,
+ title: thread.title,
+ message_count: thread.message_count,
+ last_message_at: thread.last_message_at,
+ },
+ )
+ .collect(),
+ ))
+ }
+ Request::CreateThread(thread) => {
+ conversations::ensure_thread(
+ ctx.workspace_dir.to_path_buf(),
+ CreateConversationThread {
+ id: thread.id,
+ title: thread.title,
+ created_at: thread.created_at,
+ parent_thread_id: None,
+ labels: Some(thread.labels),
+ personality_id: None,
+ working_dir: None,
+ },
+ )
+ .map_err(|_| tinybus::Error::failed("conversation state unavailable"))?;
+ Ok(Response::Completed)
+ }
+ Request::ClearHistory { sender_key } => {
+ clear_sender_history(ctx, &sender_key);
+ Ok(Response::Completed)
+ }
+ Request::InvalidateThread { thread_id } => {
+ crate::web_chat::invalidate_thread_sessions(&thread_id).await;
+ Ok(Response::Completed)
+ }
+ }
+}
diff --git a/crates/openhuman-core/src/channels/traits.rs b/crates/openhuman-core/src/channels/traits.rs
deleted file mode 100644
index 68396e9f72..0000000000
--- a/crates/openhuman-core/src/channels/traits.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//! Legacy channel orchestration seam during the provider cutover.
-//!
-//! Serialized messages come from the pure bus contract. The remaining
-//! in-process trait is an explicit `tinychannels-runtime` migration exception;
-//! it will be replaced when provider runtime callers switch to TinyBus.
-pub use tinychannels_bus::{ChannelMessage, SendMessage};
-pub use tinychannels_runtime::{Channel, ChannelSendExt};
-
-#[cfg(test)]
-#[path = "traits_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/security/core_tests.rs b/crates/openhuman-core/src/security/core_tests.rs
index 477902d66a..53a9c03ab2 100644
--- a/crates/openhuman-core/src/security/core_tests.rs
+++ b/crates/openhuman-core/src/security/core_tests.rs
@@ -1,13 +1,10 @@
use super::*;
-use crate::security::{AutonomyLevel, PairingGuard, SecretStore, SecurityPolicy};
+use crate::security::{AutonomyLevel, SecretStore, SecurityPolicy};
#[test]
-fn reexported_policy_and_pairing_types_are_usable() {
+fn reexported_policy_is_usable() {
let policy = SecurityPolicy::default();
assert_eq!(policy.autonomy, AutonomyLevel::Supervised);
-
- let (guard, _) = PairingGuard::new(false, &[]);
- assert!(!guard.require_pairing());
}
#[test]
diff --git a/crates/openhuman-core/src/security/mod.rs b/crates/openhuman-core/src/security/mod.rs
index f9f3ec53a6..53c847692b 100644
--- a/crates/openhuman-core/src/security/mod.rs
+++ b/crates/openhuman-core/src/security/mod.rs
@@ -41,8 +41,7 @@ pub use ops as rpc;
pub use ops::*;
#[allow(unused_imports)]
pub use pairing::{
- ensure_core_rpc_token_for_bind, is_public_bind, CoreBindTokenError, PairingGuard,
- CORE_TOKEN_ENV_VAR,
+ ensure_core_rpc_token_for_bind, is_public_bind, CoreBindTokenError, CORE_TOKEN_ENV_VAR,
};
pub use policy::validate_path_within_root;
#[allow(unused_imports)]
diff --git a/crates/openhuman-core/src/security/pairing.rs b/crates/openhuman-core/src/security/pairing.rs
index 3fc9492cdc..cd2ffb43cb 100644
--- a/crates/openhuman-core/src/security/pairing.rs
+++ b/crates/openhuman-core/src/security/pairing.rs
@@ -11,14 +11,6 @@ use std::io::Write as _;
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt as _;
-/// `PairingGuard`, `constant_time_eq`, and the pairing lockout constants now
-/// live in tinychannels (portable, self-contained); re-export them so existing
-/// callers (channels, `core::auth`, tests) keep their paths.
-pub use tinychannels_runtime::security::{
- constant_time_eq, generate_code, generate_token, hash_token, is_token_hash, PairingGuard,
- MAX_PAIR_ATTEMPTS, PAIR_LOCKOUT_SECS,
-};
-
/// Environment variable for the core JSON-RPC bearer token (see `crate::core::auth`).
pub const CORE_TOKEN_ENV_VAR: &str = "OPENHUMAN_CORE_TOKEN";
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index 19f7a77315..c592db6923 100644
--- a/docs/module-boundary-inventory.md
+++ b/docs/module-boundary-inventory.md
@@ -16,7 +16,7 @@ copying its implementation into a host, or accepting weaker isolation.
| tinyjuice | none (module loaded through TinyBus) | tinyjuice-bus | core tools, compression, CCR REPL | Complete: PR #59 provides module-owned compression, CCR queries, HTML extraction, schemas and declarations; the host retains turn-bound model callbacks and artifact authorization |
| tinyconnectors | none | tinyconnectors-bus | core integrations, credentials and triggers | Module-backed argument preparation, action execution and trigger archives; host credential reconciliation and frozen tool restoration remain in OpenHuman |
| tinymcp | tinymcp | tinymcp-bus | core MCP registry, supervisor, CLI stdio/HTTP server | Supervisor notifications, server protocol operations and callbacks for approved host tools/resources/prompts |
-| tinychannels | tinychannels, tinychannels-runtime (remaining runtime callers) | tinychannels-bus | core channels, TinyHumans host, CLI REPL | Contract is pure; v0.1.22 adds scoped runtime/provider facts, outbound preparation, and inbound identity contracts. Discord discovery/permission checks, credential tests and connection validation/defaults and `doctor channels` health checks use confidential module calls. Remaining runtime callers need bus cutover with inbound/status callbacks and shutdown draining |
+| tinychannels | tinychannels, tinychannels-runtime (remaining runtime callers) | tinychannels-bus | core channels, TinyHumans host, CLI REPL | Contract is pure; v0.1.24 adds scoped runtime/provider facts, outbound preparation, and inbound identity contracts. Discord discovery/permission checks, credential tests and connection validation/defaults and `doctor channels` health checks use confidential module calls. Remaining runtime callers need bus cutover with inbound/status callbacks and shutdown draining |
| tinyhosts | none | tinyhosts-bus | core hosting tools | Released Execute/Providers contract consumed through the module; workspace authorization, credentials and approval policy remain in OpenHuman |
| tinywallet | tinywallet-crypto, tinywallet-web3, tinywallet-x402 through remaining host imports | tinywallet-bus | core wallet/web3/x402 | Contract is pure at v0.13.0; native transfer preparation/execution use confidential module calls with host custody, exact approval binding and explicit close. Initialization, remaining validation, Web3 quotes/swaps, x402 payments, budgets and ledger still need host cutover |
| tinybox | tinybox-core, tinybox-jail, tinybox-docker | tinybox-bus | core sandbox and security, desktop gateways | Pre-core gateways use the released v0.1.18 bus client. Core sandbox execution and shell analysis still require cutover |
@@ -356,7 +356,7 @@ those callers and their dependency graphs are cut over.
## Channel message preparation and hosted ingress
-The host now pins verified TinyChannels v0.1.22 (contract 12, operation 1.13).
+The host now pins verified TinyChannels v0.1.24 (contract 14, operation 1.15).
All eleven published archives and their checksum manifest were checked against
actual downloaded bytes, GitHub digests, and sizes. Published Linux module
fixtures pass with both the owning loader and OpenHuman's shipped TinyBus kernel.
@@ -376,3 +376,11 @@ and zero stale exceptions, with nine temporary implementation exceptions still
present across Channels, MCP, Box, and Wallet. Both Channels implementation
exceptions remain pending provider, relay, remote-command, and progressive
runtime cutover.
+
+Hosted progressive replies now run through a private runtime's `ExecuteProgressive`
+handle. OpenHuman supplies ordered turn facts and captured managed transport;
+the module owns delivery choreography and idempotency. A released-artifact host
+fixture passes callback isolation, acknowledged stop, and final-send replay,
+alongside four lease validation and cancellation tests. Native providers, relay,
+remote-command host adapters and context helpers are still being migrated;
+both Channels implementation exceptions remain.