Skip to content

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

fix(security): correct credential validation to accept empty string for optional fields

Steven Enamakelf913bc02a2a6
diff --git a/crates/openhuman-core/src/security/credentials/tools.rs b/crates/openhuman-core/src/security/credentials/tools.rs
index 76b4e1c5d2..682add0f03 100644
--- a/crates/openhuman-core/src/security/credentials/tools.rs
+++ b/crates/openhuman-core/src/security/credentials/tools.rs
@@ -18,6 +18,38 @@ use crate::config::Config;
use crate::security::credentials;
use tinytools::{Tool, ToolResult};
+/// Dispatch a hosted `auth.oauth_*` controller through the registry.
+///
+/// The backend-brokered OAuth RPCs live in `openhuman-tinyhumans`
+/// (`hosted::oauth`) and are registered only when that layer is installed, so
+/// the tools reach them by wire name instead of calling them directly. With no
+/// hosted layer the tool reports the `BACKEND_UNAVAILABLE:` sentinel.
+async fn invoke_hosted(method: &str, params: serde_json::Map<String, Value>) -> anyhow::Result<Value> {
+ match crate::core::all::try_invoke_registered_rpc(method, params).await {
+ Some(Ok(value)) => Ok(strip_log_envelope(value)),
+ Some(Err(err)) => Err(anyhow::anyhow!("{err}")),
+ None => {
+ log::debug!("[tool][credentials] {method} not registered (no hosted layer)");
+ Err(anyhow::anyhow!(
+ "{}{method} requires the hosted TinyHumans layer",
+ crate::core::observability::BACKEND_UNAVAILABLE_PREFIX
+ ))
+ }
+ }
+}
+
+/// `{ "result": v, "logs": [...] }` → `v`; anything else unchanged.
+fn strip_log_envelope(value: Value) -> Value {
+ match value {
+ Value::Object(mut map)
+ if map.len() == 2 && map.contains_key("result") && map.contains_key("logs") =>
+ {
+ map.remove("result").unwrap_or(Value::Null)
+ }
+ other => other,
+ }
+}
+
macro_rules! emit {
($outcome:expr, $name:literal) => {{
let outcome = $outcome.map_err(|e| anyhow::anyhow!(concat!($name, ": {}"), e))?;
@@ -132,11 +164,15 @@ impl Tool for OAuthConnectUrlTool {
.map(str::trim)
.filter(|s| !s.is_empty())
.ok_or_else(|| anyhow::anyhow!("missing required string argument `provider`"))?;
- let skill_id = args.get("skill_id").and_then(Value::as_str);
- emit!(
- credentials::oauth_connect(&self.config, provider, skill_id, None, None).await,
- "oauth_connect_url"
- )
+ let mut params = serde_json::Map::new();
+ params.insert("provider".into(), json!(provider));
+ if let Some(skill_id) = args.get("skill_id").and_then(Value::as_str) {
+ params.insert("skillId".into(), json!(skill_id));
+ }
+ let value = invoke_hosted("openhuman.auth_oauth_connect", params)
+ .await
+ .map_err(|e| anyhow::anyhow!("oauth_connect_url: {e}"))?;
+ Ok(ToolResult::success(serde_json::to_string(&value)?))
}
}
@@ -162,10 +198,10 @@ impl Tool for OAuthListTool {
}
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
log::debug!("[tool][credentials] oauth_list invoked");
- emit!(
- credentials::oauth_list_integrations(&self.config).await,
- "oauth_list"
- )
+ let value = invoke_hosted("openhuman.auth_oauth_list_integrations", Default::default())
+ .await
+ .map_err(|e| anyhow::anyhow!("oauth_list: {e}"))?;
+ Ok(ToolResult::success(serde_json::to_string(&value)?))
}
fn is_concurrency_safe(&self, _args: &serde_json::Value) -> bool {
true