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
refactor(web_chat): construct WebChannelEvent variants directly
Steven Enamakelb5066da9e40e
diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rsindex 86e0da7726..933bc3e3de 100644--- a/crates/openhuman-core/src/web_chat/event_bus.rs+++ b/crates/openhuman-core/src/web_chat/event_bus.rs@@ -7,6 +7,7 @@ use std::sync::{Arc, OnceLock};use crate::core::events::DomainEvent;use crate::web_chat::WebChannelEvent;+use super::channel_event::event_context;use tinybus::EventHandler;use tinybus::SubscriptionHandle;@@ -160,12 +161,9 @@ impl EventHandler<DomainEvent> for MemoryActivitySurfaceSubscriber {log::debug!("[web-channel] memory-activity-surface emitting memory_activity kind={event_name} thread_id={thread_id} client_id={client_id}");- publish_web_channel_event(WebChannelEvent {- event: "memory_activity".to_string(),- client_id,- thread_id,+ publish_web_channel_event(WebChannelEvent::MemoryActivity {+ context: event_context(client_id, thread_id, ""),args: Some(args),- ..Default::default()});}}@@ -222,47 +220,35 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {log::debug!("[web-channel] agent-surface emitting thread_goal_updated thread_id={thread_id}");- publish_web_channel_event(WebChannelEvent {- event: "thread_goal_updated".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::ThreadGoalUpdated {+ context: event_context("", thread_id, ""),goal: goal.clone(),- ..Default::default()});}DomainEvent::ThreadGoalCleared { thread_id } => {log::debug!("[web-channel] agent-surface emitting thread_goal_cleared thread_id={thread_id}");- publish_web_channel_event(WebChannelEvent {- event: "thread_goal_cleared".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),- ..Default::default()+ publish_web_channel_event(WebChannelEvent::ThreadGoalCleared {+ context: event_context("", thread_id, ""),});}DomainEvent::ThreadTodosChanged { thread_id, todos } => {log::debug!("[web-channel] agent-surface emitting thread_todos_changed thread_id={thread_id}");- publish_web_channel_event(WebChannelEvent {- event: "thread_todos_changed".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::ThreadTodosChanged {+ context: event_context("", thread_id, ""),todos: Some(todos.clone()),- ..Default::default()});}DomainEvent::ThreadRunModeChanged { thread_id, mode } => {log::debug!("[web-channel] agent-surface emitting run_mode_changed thread_id={thread_id} mode={mode}");- publish_web_channel_event(WebChannelEvent {- event: "run_mode_changed".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::RunModeChanged {+ context: event_context("", thread_id, ""),message: Some(mode.clone()),- ..Default::default()});}DomainEvent::RunQueueMessageQueued {@@ -283,16 +269,13 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {log::debug!("[web-channel] agent-surface emitting queue_item_queued thread_id={thread_id} item_id={item_id}");- publish_web_channel_event(WebChannelEvent {- event: "queue_item_queued".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::QueueItemQueued {+ context: event_context("", thread_id, ""),queue_item: Some(crate::web_chat::QueueItemPayload {id: item_id,lane: None,text_preview: text_preview.clone(),}),- ..Default::default()});}DomainEvent::RunQueueMessageDelivered {@@ -309,16 +292,13 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {log::debug!("[web-channel] agent-surface emitting queue_item_delivered thread_id={thread_id} item_id={item_id}");- publish_web_channel_event(WebChannelEvent {- event: "queue_item_delivered".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::QueueItemDelivered {+ context: event_context("", thread_id, ""),queue_item: Some(crate::web_chat::QueueItemPayload {id: item_id,lane,text_preview: text_preview.clone(),}),- ..Default::default()});}DomainEvent::RunQueueFollowupDispatched {@@ -340,16 +320,13 @@ impl EventHandler<DomainEvent> for AgentSurfaceSubscriber {log::debug!("[web-channel] agent-surface emitting queue_item_delivered thread_id={thread_id} item_id={item_id}");- publish_web_channel_event(WebChannelEvent {- event: "queue_item_delivered".to_string(),- client_id: String::new(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::QueueItemDelivered {+ context: event_context("", thread_id, ""),queue_item: Some(crate::web_chat::QueueItemPayload {id: item_id,lane,text_preview: text_preview.clone(),}),- ..Default::default()});}_ => {}@@ -392,12 +369,13 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {log::info!("[web-channel] artifact-surface emitting artifact_ready id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?}");- publish_web_channel_event(WebChannelEvent {- event: "artifact_ready".to_string(),- client_id: client_id.clone(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::ArtifactReady {+ context: {+ let mut context = event_context(client_id, thread_id, "");+ context.turn_request_id = request_id.clone();+ context+ },tool_call_id: tool_call_id.clone(),- turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,@@ -406,7 +384,6 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {"path": path,"size_bytes": size_bytes,})),- ..Default::default()});}DomainEvent::ArtifactFailed {@@ -430,12 +407,13 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {"[web-channel] artifact-surface emitting artifact_failed id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?} error_len={}",error.len());- publish_web_channel_event(WebChannelEvent {- event: "artifact_failed".to_string(),- client_id: client_id.clone(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::ArtifactFailed {+ context: {+ let mut context = event_context(client_id, thread_id, "");+ context.turn_request_id = request_id.clone();+ context+ },tool_call_id: tool_call_id.clone(),- turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,@@ -443,7 +421,6 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {"workspace_dir": workspace_dir,"error": error,})),- ..Default::default()});}DomainEvent::ArtifactPending {@@ -466,12 +443,13 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {log::info!("[web-channel] artifact-surface emitting artifact_pending id={artifact_id} kind={kind} thread_id={thread_id} client_id={client_id} tool_call_id={tool_call_id:?}");- publish_web_channel_event(WebChannelEvent {- event: "artifact_pending".to_string(),- client_id: client_id.clone(),- thread_id: thread_id.clone(),+ publish_web_channel_event(WebChannelEvent::ArtifactPending {+ context: {+ let mut context = event_context(client_id, thread_id, "");+ context.turn_request_id = request_id.clone();+ context+ },tool_call_id: tool_call_id.clone(),- turn_request_id: request_id.clone(),args: Some(serde_json::json!({"artifact_id": artifact_id,"kind": kind,@@ -479,7 +457,6 @@ impl EventHandler<DomainEvent> for ArtifactSurfaceSubscriber {"workspace_dir": workspace_dir,"path": path,})),- ..Default::default()});}_ => {}