Skip to content

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

feat(security): add credential management tools

Steven Enamakelbf42a2cd9733
diff --git a/crates/openhuman-core/src/security/credentials/tools.rs b/crates/openhuman-core/src/security/credentials/tools.rs
index 08fafc410d..e85b3a52fe 100644
--- a/crates/openhuman-core/src/security/credentials/tools.rs
+++ b/crates/openhuman-core/src/security/credentials/tools.rs
@@ -26,10 +26,11 @@ use tinytools::{Tool, ToolResult};
/// 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(
+ ctx: DispatchCtx,
method: &str,
params: serde_json::Map<String, Value>,
) -> anyhow::Result<Value> {
- match crate::core::all::try_invoke_registered_rpc(DispatchCtx::ambient(), method, params).await
+ match crate::core::all::try_invoke_registered_rpc(ctx, method, params).await
{
Some(Ok(value)) => Ok(strip_log_envelope(value)),
Some(Err(err)) => Err(anyhow::anyhow!("{err}")),
@@ -174,6 +175,16 @@ impl Tool for OAuthConnectUrlTool {
})
}
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
+ self.execute_with_context(args, tinytools::ToolCallOptions::default(), None)
+ .await
+ }
+ async fn execute_with_context(
+ &self,
+ args: serde_json::Value,
+ _options: tinytools::ToolCallOptions,
+ context: Option<&dyn tinytools::ToolRunContext>,
+ ) -> anyhow::Result<ToolResult> {
+ let ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(context);
log::debug!("[tool][credentials] oauth_connect invoked");
let provider = args
.get("provider")
@@ -186,7 +197,7 @@ impl Tool for OAuthConnectUrlTool {
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)
+ let value = invoke_hosted(ctx, "openhuman.auth_oauth_connect", params)
.await
.map_err(|e| anyhow::anyhow!("oauth_connect_url: {e}"))?;
Ok(ToolResult::success(serde_json::to_string(&value)?))
@@ -218,8 +229,19 @@ impl Tool for OAuthListTool {
json!({ "type": "object", "properties": {} })
}
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
+ self.execute_with_context(_args, tinytools::ToolCallOptions::default(), None)
+ .await
+ }
+ async fn execute_with_context(
+ &self,
+ args: serde_json::Value,
+ _options: tinytools::ToolCallOptions,
+ context: Option<&dyn tinytools::ToolRunContext>,
+ ) -> anyhow::Result<ToolResult> {
+ let ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(context);
+ let _ = &args;
log::debug!("[tool][credentials] oauth_list invoked");
- let value = invoke_hosted("openhuman.auth_oauth_list_integrations", Default::default())
+ let value = invoke_hosted(ctx, "openhuman.auth_oauth_list_integrations", Default::default())
.await
.map_err(|e| anyhow::anyhow!("oauth_list: {e}"))?;
Ok(ToolResult::success(serde_json::to_string(&value)?))