Skip to content

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

feat(channels): execute credential tests through the confidential module controller

Steven Enamakelac712c95c636
diff --git a/crates/openhuman-core/src/channels/README.md b/crates/openhuman-core/src/channels/README.md
index 53372f8922..3d6f0bbe09 100644
--- a/crates/openhuman-core/src/channels/README.md
+++ b/crates/openhuman-core/src/channels/README.md
@@ -149,6 +149,7 @@ The in-app web chat (RPC namespace `channel`, singular) is a separate domain in
- Conversation memory ingestion and `forget_channel` are in `memory/conversations/`.
- Backend REST calls go through `backend::BackendClient`; Telegram and Discord link flows that need a TinyHumans account live in `openhuman-tinyhumans`.
- Discord bot guild/channel discovery and permission checks call the released TinyChannels module through the confidential `ChannelController` member. The host resolves stored credentials and proxy scope, and the bus contract preserves the existing RPC response fields.
+- `channels.test` delegates field validation and email IMAP verification to the same confidential controller member. It never persists credentials or configuration, and an unavailable module fails the test instead of reporting local validation as success.
- Speech-to-text and text-to-speech are the `voice/` domain, reached through the `host/` adapters.
- Web-chat turns, the web-channel event stream, and the surface subscribers are `web_chat/`.
- Cron delivery is [`cron/bus.rs`](../cron/bus.rs) (`CronDeliverySubscriber`) and [`cron/channel_bridge.rs`](../cron/channel_bridge.rs); `start_channels` hands them the started channel map.
diff --git a/crates/openhuman-core/src/channels/controllers/definitions.rs b/crates/openhuman-core/src/channels/controllers/definitions.rs
index 3138e1ddd2..0757c1dea3 100644
--- a/crates/openhuman-core/src/channels/controllers/definitions.rs
+++ b/crates/openhuman-core/src/channels/controllers/definitions.rs
@@ -1,4 +1,4 @@
-pub use tinychannels::controllers::{
+pub use tinychannels_bus::controllers::{
all_channel_definitions, find_channel_definition, AuthModeSpec, ChannelAuthMode,
ChannelCapability, ChannelDefinition, FieldRequirement,
};
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
index 43605ccc46..ad53fc831e 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel.rs
@@ -1,57 +1,45 @@
-//! Testing a channel's credentials without persisting anything.
+//! Testing credentials through the module without persisting host configuration.
use serde_json::Value;
-use tinychannels_runtime::controllers::ChannelDefinitionExt as _;
+use tinychannels_bus::{methods, ChannelControllerRequest, ChannelControllerResult};
use crate::config::Config;
use crate::core::Outcome;
+use crate::modules::client::{ModuleCallError, ModuleClient};
-use super::super::super::definitions::{find_channel_definition, ChannelAuthMode};
+use super::super::super::definitions::ChannelAuthMode;
use super::super::types::ChannelTestResult;
-use tinychannels::controllers::build_email_config;
-use tinychannels::providers::verify_email_credentials;
-/// Test a channel connection without persisting credentials.
+/// Validate credentials inside TinyChannels, including native IMAP verification
+/// for email. No credentials or configuration are persisted.
pub async fn test_channel(
- _config: &Config,
+ config: &Config,
channel_id: &str,
auth_mode: ChannelAuthMode,
credentials_value: Value,
) -> Result<Outcome<ChannelTestResult>, String> {
- let def = find_channel_definition(channel_id)
- .ok_or_else(|| format!("unknown channel: {channel_id}"))?;
-
- let creds_map = credentials_value
- .as_object()
- .ok_or("credentials must be a JSON object")?;
-
- // Validate fields first.
- def.validate_credentials(auth_mode, creds_map)?;
-
- // Email supports a real connection test: build the effective config and
- // attempt an IMAP login without persisting anything.
- if channel_id == "email" && auth_mode == ChannelAuthMode::ApiKey {
- let email_cfg = build_email_config(creds_map, None)?;
- verify_email_credentials(&email_cfg).await?;
- return Ok(Outcome::new(
- ChannelTestResult {
- success: true,
- message: "IMAP login succeeded.".to_string(),
- },
- vec![],
- ));
+ let response = ModuleClient::new(config.clone())
+ .call_confidential(
+ "tinychannels",
+ methods::CHANNEL_CONTROLLER,
+ (ChannelControllerRequest::TestChannel {
+ config: config.channels_config.clone(),
+ channel: channel_id.to_owned(),
+ auth_mode,
+ credentials: credentials_value,
+ },),
+ )
+ .await
+ .map_err(|error| error.to_string())?;
+ match response {
+ ChannelControllerResult::TestChannel(result) => Ok(Outcome::new(result, vec![])),
+ _ => {
+ ModuleClient::report_malformed_reply("tinychannels");
+ Err(ModuleCallError::ModuleFault.to_string())
+ }
}
-
- // For other channels, field validation is the test. A future version can
- // instantiate the channel provider and call health_check().
- Ok(Outcome::new(
- ChannelTestResult {
- success: true,
- message: format!(
- "Credentials for '{}' ({}) are structurally valid.",
- channel_id, auth_mode
- ),
- },
- vec![],
- ))
}
+
+#[cfg(test)]
+#[path = "test_channel_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel_tests.rs b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel_tests.rs
new file mode 100644
index 0000000000..d0d27ba578
--- /dev/null
+++ b/crates/openhuman-core/src/channels/controllers/ops/connect/test_channel_tests.rs
@@ -0,0 +1,21 @@
+use super::*;
+
+#[tokio::test]
+async fn unavailable_module_cannot_report_locally_valid_credentials_as_connected() {
+ let temporary = tempfile::tempdir().unwrap();
+ let mut config = Config::default();
+ config.modules.enabled = false;
+ config.workspace_dir = temporary.path().join("workspace");
+ config.config_path = temporary.path().join("config.toml");
+ let error = test_channel(
+ &config,
+ "telegram",
+ ChannelAuthMode::BotToken,
+ serde_json::json!({"bot_token":"fixture-token"}),
+ )
+ .await
+ .unwrap_err();
+ assert!(error.contains("module unavailable"), "{error}");
+ assert!(!config.config_path.exists());
+ assert!(!config.workspace_dir.exists());
+}
diff --git a/crates/openhuman-core/src/channels/controllers/ops/types.rs b/crates/openhuman-core/src/channels/controllers/ops/types.rs
index 3f7cb67294..f36b6ed07d 100644
--- a/crates/openhuman-core/src/channels/controllers/ops/types.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops/types.rs
@@ -1,6 +1,6 @@
#![allow(unused_imports)]
-pub use tinychannels::controllers::{
+pub use tinychannels_bus::controllers::{
ChannelAccountSnapshot, ChannelAccountState, ChannelConnectionResult, ChannelLastDisconnect,
ChannelReactionResult, ChannelSendMessageResult, ChannelStatusEntry, ChannelTestResult,
ChannelThreadEntry, ChannelThreadListResult, ChannelThreadResult, DiscordChannelEntry,
diff --git a/crates/openhuman-core/src/channels/controllers/ops_yuanbao_email_tests.rs b/crates/openhuman-core/src/channels/controllers/ops_yuanbao_email_tests.rs
index f9d57f1325..039a0ac007 100644
--- a/crates/openhuman-core/src/channels/controllers/ops_yuanbao_email_tests.rs
+++ b/crates/openhuman-core/src/channels/controllers/ops_yuanbao_email_tests.rs
@@ -302,8 +302,9 @@ async fn connect_email_rejects_invalid_port_before_network() {
}
#[tokio::test]
-async fn test_channel_email_rejects_invalid_port_before_network() {
- let config = Config::default();
+async fn test_channel_email_requires_the_module_before_native_verification() {
+ let mut config = Config::default();
+ config.modules.enabled = false;
let err = test_channel(
&config,
"email",
@@ -317,6 +318,6 @@ async fn test_channel_email_rejects_invalid_port_before_network() {
}),
)
.await
- .expect_err("invalid smtp port must be rejected");
- assert!(err.contains("smtp_port"), "{err}");
+ .expect_err("an unavailable module must not trigger host IMAP verification");
+ assert!(err.contains("module unavailable"), "{err}");
}
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index 988c837c39..cae379cb75 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 | tinyconnectors, tinyconnectors-sync | tinyconnectors-bus | core integrations, credentials and triggers | Argument preparation, calendar defaults, task windows, structured provider errors, trigger archives; preserve sign-in/out reconciliation |
| 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 and podcast email, TinyHumans host, CLI REPL | Contract is pure; v0.1.16 supplies complete Discord response vocabulary. Podcast SMTP and Discord discovery/permission 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 and podcast email, TinyHumans host, CLI REPL | Contract is pure; v0.1.16 supplies complete Discord response vocabulary. Podcast SMTP, Discord discovery/permission checks, and credential tests use confidential module calls. Remaining runtime callers need bus cutover with inbound/status callbacks and shutdown draining |
| tinyhosts | tinyhosts | tinyhosts-bus | core hosting tools | Consume released Execute/Providers contract; keep workspace authorization, credentials, and approval policy in OpenHuman |
| tinywallet | tinywallet-crypto, tinywallet-web3, tinywallet-x402 via bus and direct imports | tinywallet-bus | core wallet/web3/x402 | Move behavioral re-exports out of bus; validation, transaction construction, quotes, swaps, payments, budgets, ledger; retain host custody/approval and confidential attestation |
| tinybox | tinybox-core, tinybox-jail, tinybox-docker, tinybox-host, tinybox-ssh | 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 |