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
feat(security): gate tool approvals on per-session state
Steven Enamakel6f2a6bfc8fa5
diff --git a/crates/openhuman-core/src/security/approval/gate_state.rs b/crates/openhuman-core/src/security/approval/gate_state.rsindex b89655d2e5..3b73a4904e 100644--- a/crates/openhuman-core/src/security/approval/gate_state.rs+++ b/crates/openhuman-core/src/security/approval/gate_state.rs@@ -364,6 +364,16 @@ impl ApprovalGate {.then_some(row)}+ /// Whether the parked `request_id` was routed to its chat thread from a+ /// detached task (an async-delegated sub-agent), so the replayed card keeps+ /// the live event's `detached` flag. `false` for an unknown request.+ pub fn request_is_detached(&self, request_id: &str) -> bool {+ self.request_routes+ .lock()+ .get(request_id)+ .is_some_and(|route| route.detached)+ }+/// Drop the thread → request mapping when it still belongs to this request.fn clear_thread(&self, thread_key: &Option<String>, request_id: &str) {if let Some(key) = thread_key {diff --git a/crates/openhuman-core/src/web_chat/channel_event.rs b/crates/openhuman-core/src/web_chat/channel_event.rsindex f55b6f44a8..21250b3a2d 100644--- a/crates/openhuman-core/src/web_chat/channel_event.rs+++ b/crates/openhuman-core/src/web_chat/channel_event.rs@@ -228,6 +228,12 @@ pub struct WebChannelEvent {/// requeue), when applicable.#[serde(skip_serializing_if = "Option::is_none")]pub superseded_by: Option<String>,+ /// `Some(true)` on an `approval_request` whose park can outlive the chat+ /// turn it is shown on (an async-delegated sub-agent). The client keeps+ /// such a card across that turn's `chat_done` and clears it on+ /// `approval_decided` instead. Absent for an ordinary in-turn park.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub detached: Option<bool>,}impl WebChannelEvent {diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rsindex 1479e9b50d..9015326282 100644--- a/crates/openhuman-core/src/web_chat/event_bus.rs+++ b/crates/openhuman-core/src/web_chat/event_bus.rs@@ -552,6 +552,7 @@ pub fn approval_request_event(client_id: &str,tool_call_id: Option<&str>,expires_at: Option<&str>,+ detached: bool,) -> WebChannelEvent {WebChannelEvent {event: "approval_request".to_string(),@@ -563,6 +564,7 @@ pub fn approval_request_event(args: Some(args_redacted.clone()),tool_call_id: tool_call_id.map(str::to_string),expires_at: expires_at.map(str::to_string),+ detached: detached.then_some(true),..Default::default()}}@@ -619,10 +621,11 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {tool_call_id,expires_at,agent_id: _,+ detached,} => match (thread_id, client_id) {(Some(thread_id), Some(client_id)) => {log::info!(- "[web-channel] approval-surface emitting approval_request request_id={request_id} thread_id={thread_id} client_id={client_id} tool={tool_name}"+ "[web-channel] approval-surface emitting approval_request request_id={request_id} thread_id={thread_id} client_id={client_id} tool={tool_name} detached={detached}");publish_web_channel_event(approval_request_event(request_id,@@ -633,6 +636,7 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {client_id,tool_call_id.as_deref(),expires_at.as_deref(),+ *detached,));}_ => {@@ -697,6 +701,7 @@ impl EventHandler<DomainEvent> for ApprovalSurfaceSubscriber {client_id,tool_call_id.as_deref(),expires_at.as_deref(),+ *detached,));}_ => {diff --git a/crates/openhuman-rpc/src/server/socketio.rs b/crates/openhuman-rpc/src/server/socketio.rsindex 0ef4b84e6a..35fcd50408 100644--- a/crates/openhuman-rpc/src/server/socketio.rs+++ b/crates/openhuman-rpc/src/server/socketio.rs@@ -1261,6 +1261,7 @@ fn replay_parked_approval(socket: &SocketRef, thread_id: &str) {&client_id,row.tool_call_id.as_deref(),expires_at.as_deref(),+ gate.request_is_detached(&row.request_id),);// Replay is a fresh emit to a newly-joined socket, not a resend of the// original event, so stamp `ts` with "now" (same clock as