The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(embed): redact credentials in Debug for Route and McpServer
Steven Enamakeleb395b0948c7
diff --git a/src/embed/agent.rs b/src/embed/agent.rsindex 2510289724..e682a9c8ed 100644--- a/src/embed/agent.rs+++ b/src/embed/agent.rs@@ -59,7 +59,7 @@ const AGENT_CHAT: &str = "openhuman.inference_agent_chat";/// credential with no endpoint are each half a statement, and the core ignores/// the pair unless both arrive non-blank. Constructing this type is what makes/// that requirement visible at compile time rather than at runtime.-#[derive(Debug, Clone, PartialEq, Eq)]+#[derive(Clone, PartialEq, Eq)]pub struct Route {/// OpenAI-compatible base URL; `/chat/completions` is appended to it.pub base_url: String,@@ -67,6 +67,17 @@ pub struct Route {pub api_key: String,}+impl std::fmt::Debug for Route {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ // The bearer is a credential; a derived Debug would spill it into+ // `Provider`'s Debug and from there into host logs and error paths.+ f.debug_struct("Route")+ .field("base_url", &self.base_url)+ .field("api_key", &"<redacted>")+ .finish()+ }+}+impl Route {/// An OpenAI-compatible endpoint and the bearer that authenticates it.pub fn openai_compatible(base_url: impl Into<String>, api_key: impl Into<String>) -> Self {diff --git a/src/embed/harness/mcp.rs b/src/embed/harness/mcp.rsindex 97e65703ff..7e336ba2ef 100644--- a/src/embed/harness/mcp.rs+++ b/src/embed/harness/mcp.rs@@ -25,9 +25,61 @@ pub use crate::openhuman::config::schema::{HttpHeader, McpAuthConfig};/// Build with [`stdio`](Self::stdio) for a local subprocess or/// [`http`](Self::http) for a remote endpoint; the two transports are mutually/// exclusive and the constructors keep them that way.-#[derive(Debug, Clone)]+#[derive(Clone)]pub struct McpServer(McpServerConfig);+impl std::fmt::Debug for McpServer {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ // `McpServerConfig` and `McpAuthConfig` both derive Debug without+ // redaction, so the derived formatter would print bearer tokens,+ // passwords, header values and stdio environment values. A harness+ // may be logged or surfaced in an error; keep the identifying fields+ // (name, endpoint, command, enabled tools) and redact everything+ // credential-shaped.+ let cfg = &self.0;+ f.debug_struct("McpServer")+ .field("name", &cfg.name)+ .field("endpoint", &cfg.endpoint)+ .field("command", &cfg.command)+ .field("args", &cfg.args)+ .field("env_redacted", &(!cfg.env.is_empty()))+ .field("cwd", &cfg.cwd)+ .field("description", &cfg.description)+ .field("enabled", &cfg.enabled)+ .field("allowed_tools", &cfg.allowed_tools)+ .field("disallowed_tools", &cfg.disallowed_tools)+ .field("timeout_secs", &cfg.timeout_secs)+ .field("auth", &McpAuthDebug(&cfg.auth))+ .finish()+ }+}++/// Redacting view of an [`McpAuthConfig`]: reveals only the auth kind, never the+/// credential value.+struct McpAuthDebug<'a>(&'a McpAuthConfig);++impl std::fmt::Debug for McpAuthDebug<'_> {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self.0 {+ McpAuthConfig::None => f.write_str("None"),+ McpAuthConfig::BearerToken { .. } => f.write_str("BearerToken(<redacted>)"),+ McpAuthConfig::Basic { .. } => f.write_str("Basic(<redacted>)"),+ McpAuthConfig::Header { name, .. } => {+ f.debug_tuple("Header").field(name).field(&"<redacted>").finish()+ }+ McpAuthConfig::Headers { headers } => {+ f.debug_tuple("Headers")+ .field(&headers.len())+ .field(&"<redacted>")+ .finish()+ }+ McpAuthConfig::QueryParam { name, .. } => {+ f.debug_tuple("QueryParam").field(name).field(&"<redacted>").finish()+ }+ }+ }+}+impl McpServer {/// A local server launched as a subprocess, speaking newline-delimited/// JSON-RPC over stdin/stdout.