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(security): enforce approval gate for tool calls in dev gallery
Steven Enamakel5a9370f9790e
diff --git a/app/src/pages/dev/ToolCallGallery.tsx b/app/src/pages/dev/ToolCallGallery.tsxindex 1da502e43a..f7379d335a 100644--- a/app/src/pages/dev/ToolCallGallery.tsx+++ b/app/src/pages/dev/ToolCallGallery.tsx@@ -205,6 +205,66 @@ export default function ToolCallGallery() {/></section>+ <section className="flex flex-col gap-3">+ <h2 className="text-foreground/60 mb-2 text-xs font-medium uppercase">Approvals</h2>++ <p className="text-foreground/40 text-xs">Pending, in-thread (chat-approval-*)</p>+ <ApprovalCardAdapter+ ariaLabel="Approval needed"+ title="Approval needed"+ subtitle={APPROVAL_PENDING_APPROVAL.message}+ command={APPROVAL_PENDING_APPROVAL.command ?? ''}+ toolName={APPROVAL_PENDING_APPROVAL.toolName}+ alwaysDecision="approve_always_for_tool"+ analyticsPrefix="chat-approval"+ onDecide={async () => {}}+ />++ <p className="text-foreground/40 text-xs">Pending with a live expiry countdown</p>+ <ApprovalCardAdapter+ ariaLabel="Approval needed"+ title="Approval needed"+ subtitle={APPROVAL_EXPIRING.message}+ command={APPROVAL_EXPIRING.command ?? ''}+ toolName={APPROVAL_EXPIRING.toolName}+ expiresAt={APPROVAL_EXPIRING.expiresAt}+ alwaysDecision="approve_always_for_tool"+ analyticsPrefix="chat-approval"+ onDecide={async () => {}}+ />++ <p className="text-foreground/40 text-xs">Denied (no always-allow, unrouted surface)</p>+ <ApprovalCardAdapter+ ariaLabel="Approval needed"+ title="Approval needed"+ subtitle="Background task needs approval"+ command="triage.escalate"+ toolName="triage.escalate"+ analyticsPrefix="unrouted-approval"+ onDecide={() => Promise.reject(new Error('rejected for the gallery'))}+ />++ <p className="text-foreground/40 text-xs">+ composio_connect (permission-grant, one Connect action)+ </p>+ <PermissionGrantAdapter threadId="dev-thread" approval={COMPOSIO_CONNECT_APPROVAL} />++ <p className="text-foreground/40 text-xs">Elicitation — ask_user_clarification</p>+ <ElicitationAdapter+ server="OpenHuman"+ message="Which repository should I open a PR against?"+ pending+ onAnswer={() => {}}+ testId="tool-gallery-elicitation"+ />+ <ElicitationAdapter+ server="OpenHuman"+ message="Which repository should I open a PR against?"+ pending={false}+ onAnswer={() => {}}+ />+ </section>+<section className="flex flex-col gap-1"><h2 className="text-foreground/60 mb-2 text-xs font-medium uppercase">Message queue</h2><MessageQueuediff --git a/crates/openhuman-core/src/agent/plan_review/gate.rs b/crates/openhuman-core/src/agent/plan_review/gate.rsindex c8fcef4345..2c5bf9572e 100644--- a/crates/openhuman-core/src/agent/plan_review/gate.rs+++ b/crates/openhuman-core/src/agent/plan_review/gate.rs@@ -100,8 +100,9 @@ impl PlanReviewGate {.lock().insert(tid, request_id.clone());}- let expires_at = (chrono::Utc::now() + chrono::Duration::from_std(self.ttl).unwrap_or_default())- .to_rfc3339();+ let expires_at = (chrono::Utc::now()+ + chrono::Duration::from_std(self.ttl).unwrap_or_default())+ .to_rfc3339();self.parked.lock().insert(request_id.clone(),ParkedReview {diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rsindex 6b2f7e6704..64486b1f04 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs@@ -102,9 +102,7 @@ impl PlanExitTool {tinyagents_harness::middleware::RunMode::Build,);} else {- tracing::debug!(- "[tool][plan_exit] no thread id on this run context — nothing to flip"- );+ tracing::debug!("[tool][plan_exit] no thread id on this run context — nothing to flip");}Ok(ToolResult::success(format!("{PLAN_EXIT_MARKER}\n{trimmed}"diff --git a/crates/openhuman-core/src/agent/tools/todo.rs b/crates/openhuman-core/src/agent/tools/todo.rsindex d4d5e25c38..59fb348e13 100644--- a/crates/openhuman-core/src/agent/tools/todo.rs+++ b/crates/openhuman-core/src/agent/tools/todo.rs@@ -165,7 +165,8 @@ impl TodoTool {// thread id. If the new key has no list yet and the legacy key does,// migrate it forward so an in-flight list isn't dropped by the rekey.if let Some(legacy_key) = legacy_session_key(parent.as_ref(), &scope) {- self.migrate_legacy_list_if_absent(&scope, &legacy_key).await;+ self.migrate_legacy_list_if_absent(&scope, &legacy_key)+ .await;}tracing::debug!(session_id = ?scope.session_id(), "[tool][todo] dispatch");let key = ScopedKey(scope.key());diff --git a/crates/openhuman-core/src/config/schema/web_chat_config_tests.rs b/crates/openhuman-core/src/config/schema/web_chat_config_tests.rsindex 30d6a0455a..3734d9a866 100644--- a/crates/openhuman-core/src/config/schema/web_chat_config_tests.rs+++ b/crates/openhuman-core/src/config/schema/web_chat_config_tests.rs@@ -14,7 +14,6 @@ fn deserializes_missing_field_as_enabled() {#[test]fn deserializes_explicit_false() {- let config: WebChatConfig =- serde_json::from_str(r#"{"suggestions_enabled": false}"#).unwrap();+ let config: WebChatConfig = serde_json::from_str(r#"{"suggestions_enabled": false}"#).unwrap();assert!(!config.suggestions_enabled);}diff --git a/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs b/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rsindex 8f81a9514e..52bb96ffa1 100644--- a/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/tools_metadata_and_sandbox_tests.rs@@ -186,7 +186,7 @@ async fn connect_tool_validates_before_gating_in_chat_context() {let ctx = ApprovalChatContext {thread_id: "t-test".into(),client_id: "c-test".into(),- request_id: None,+ request_id: None,};let result = APPROVAL_CHAT_CONTEXT.scope(diff --git a/crates/openhuman-core/src/media/generation/artifact_tool.rs b/crates/openhuman-core/src/media/generation/artifact_tool.rsindex 99de1e8d14..2071fb5d2d 100644--- a/crates/openhuman-core/src/media/generation/artifact_tool.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool.rs@@ -107,10 +107,7 @@ impl<T: Tool> MediaArtifactTool<T> {};let total = artifacts.len();for (index, entry) in artifacts.iter_mut().enumerate() {- let Some(src_path) = entry- .get("path")- .and_then(Value::as_str)- .map(PathBuf::from)+ let Some(src_path) = entry.get("path").and_then(Value::as_str).map(PathBuf::from)else {continue;};@@ -156,18 +153,19 @@ impl<T: Tool> MediaArtifactTool<T> {}};match move_or_copy(src, &dest).await {- Ok(size_bytes) => match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes).await- {- Ok(updated) => {- if let Some(obj) = entry.as_object_mut() {- obj.insert("artifact_id".into(), json!(updated.id));+ Ok(size_bytes) => {+ match finalize_artifact(&self.workspace_dir, &meta.id, size_bytes).await {+ Ok(updated) => {+ if let Some(obj) = entry.as_object_mut() {+ obj.insert("artifact_id".into(), json!(updated.id));+ }+ }+ Err(err) => {+ let _ = fail_artifact(&self.workspace_dir, &meta.id, &err).await;+ set_artifact_error(entry, &err);}}- Err(err) => {- let _ = fail_artifact(&self.workspace_dir, &meta.id, &err).await;- set_artifact_error(entry, &err);- }- },+ }Err(err) => {let _ = fail_artifact(&self.workspace_dir, &meta.id, &err).await;tracing::warn!(diff --git a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rsindex 996297c9bc..eab9fcb706 100644--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs@@ -128,7 +128,11 @@ async fn files_every_artifact_when_n_greater_than_one() {for entry in artifacts {let id = entry["artifact_id"].as_str().expect("artifact_id set");assert!(ids.insert(id.to_string()), "artifact ids must be unique");- assert!(workspace.join("artifacts").join(id).join("meta.json").exists());+ assert!(workspace+ .join("artifacts")+ .join(id)+ .join("meta.json")+ .exists());}}diff --git a/crates/openhuman-core/src/security/approval/gate_tests.rs b/crates/openhuman-core/src/security/approval/gate_tests.rsindex b2488cb357..c78edbcc23 100644--- a/crates/openhuman-core/src/security/approval/gate_tests.rs+++ b/crates/openhuman-core/src/security/approval/gate_tests.rs@@ -134,7 +134,7 @@ fn chat_ctx() -> ApprovalChatContext {ApprovalChatContext {thread_id: "t-test".into(),client_id: "c-test".into(),- request_id: None,+ request_id: None,}}@@ -213,9 +213,11 @@ async fn find_approval_decided() -> crate::core::events::DomainEvent {loop {match rx.recv().await {- Some(- ev @ crate::core::events::DomainEvent::ApprovalDecided { ref request_id, .. },- ) if request_id == expected_request_id => return ev,+ Some(ev @ crate::core::events::DomainEvent::ApprovalDecided { ref request_id, .. })+ if request_id == expected_request_id =>+ {+ return ev+ }Some(_) => continue,None => panic!("the bus closed before the expected event arrived"),}diff --git a/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs b/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rsindex 51dc970c64..643d85910c 100644--- a/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs+++ b/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs@@ -14,7 +14,7 @@ async fn pending_for_thread_tracks_request_under_chat_context_and_clears() {let ctx = ApprovalChatContext {thread_id: "thread-42".into(),client_id: "client-1".into(),- request_id: None,+ request_id: None,};let origin = AgentTurnOrigin::WebChat {thread_id: "thread-42".into(),@@ -193,7 +193,7 @@ async fn intercept_audited_bounded_abandons_park_and_leaves_row_pending() {let ctx = ApprovalChatContext {thread_id: "thread-bound".into(),client_id: "client-1".into(),- request_id: None,+ request_id: None,};let origin = AgentTurnOrigin::WebChat {thread_id: "thread-bound".into(),@@ -651,7 +651,7 @@ async fn a_parked_approval_is_recoverable_from_its_thread_for_replay() {let ctx = ApprovalChatContext {thread_id: "thread-replay".into(),client_id: "client-that-went-away".into(),- request_id: None,+ request_id: None,};let origin = AgentTurnOrigin::WebChat {thread_id: "thread-replay".into(),diff --git a/crates/openhuman-core/src/security/egress/emit_tests.rs b/crates/openhuman-core/src/security/egress/emit_tests.rsindex 4f68168c42..b7c68b525f 100644--- a/crates/openhuman-core/src/security/egress/emit_tests.rs+++ b/crates/openhuman-core/src/security/egress/emit_tests.rs@@ -89,7 +89,7 @@ async fn attaches_ambient_chat_context() {ApprovalChatContext {thread_id: "thread-xyz".to_string(),client_id: "client-abc".to_string(),- request_id: None,+ request_id: None,},async {emit_external_transfer(EgressDescriptor::composio(marker));diff --git a/crates/openhuman-core/src/threads/ops/live_state_tests.rs b/crates/openhuman-core/src/threads/ops/live_state_tests.rsindex fa99be23f6..9f70e8c86c 100644--- a/crates/openhuman-core/src/threads/ops/live_state_tests.rs+++ b/crates/openhuman-core/src/threads/ops/live_state_tests.rs@@ -94,10 +94,7 @@ async fn todos_get_reads_back_what_the_todo_tool_wrote() {.await.unwrap();let empty_json = empty.into_cli_compatible_json().unwrap();- assert!(empty_json["result"]["todos"]- .as_array()- .unwrap()- .is_empty());+ assert!(empty_json["result"]["todos"].as_array().unwrap().is_empty());let scope = crate::agent::todos::ops::TodoScope::Session {id: "thread-todos-live".to_string(),