Skip to content

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

refactor(cron): use typed web channel event variants

Steven Enamakel1a08af58db03
diff --git a/crates/openhuman-core/src/cron/scheduler/executor.rs b/crates/openhuman-core/src/cron/scheduler/executor.rs
index bfe2d308a8..1aa9c924a6 100644
--- a/crates/openhuman-core/src/cron/scheduler/executor.rs
+++ b/crates/openhuman-core/src/cron/scheduler/executor.rs
@@ -296,12 +296,10 @@ pub(super) fn agent_session_target_tag(target: &SessionTarget) -> &'static str {
/// metadata-only rule in CLAUDE.md), so no secrets / PII leave the core.
pub(super) fn publish_cron_user_error(kind: &str) {
tracing::debug!("[cron] action=surface_user_error kind={kind}");
- crate::web_chat::publish_web_channel_event(crate::web_chat::WebChannelEvent {
- event: "user_error".to_string(),
- client_id: "system".to_string(),
+ crate::web_chat::publish_web_channel_event(crate::web_chat::WebChannelEvent::UserError {
+ context: crate::web_chat::channel_event::event_context("system", "", ""),
error_type: Some(kind.to_string()),
error_source: Some("cron".to_string()),
- ..Default::default()
});
}
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
index d47b2620e6..e4301c2829 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -279,15 +279,17 @@ async fn deliver_to_web_thread(
.map_err(|e| anyhow!("origin reply persistence task failed: {e}"))?
.map_err(|e| anyhow!("could not store the reply in the origin thread: {e}"))?;
- publish_web_channel_event(WebChannelEvent {
- event: "proactive_message".to_string(),
- client_id: "system".to_string(),
- thread_id: thread_id.to_string(),
- request_id: request_id.clone(),
+ publish_web_channel_event(WebChannelEvent::ProactiveMessage {
+ context: crate::web_chat::channel_event::event_context(
+ "system",
+ thread_id,
+ request_id.clone(),
+ ),
full_response: Some(text.to_string()),
+ message: None,
success: Some(true),
persisted_message_id: Some(crate::threads::store::run_reply_message_id(&request_id)),
- ..Default::default()
+ parts: None,
});
// After the announcement: waiting out a live turn of this session must not
diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rs
index e0a62951a5..e59bb64b64 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -127,14 +127,22 @@ pub(super) async fn finalize_flow_stream(
.await;
}
Err(err) => {
- crate::web_chat::publish_web_channel_event(crate::web_chat::WebChannelEvent {
- event: "chat_error".to_string(),
- client_id: "system".to_string(),
- thread_id: target.thread_id.clone(),
- request_id: target.request_id.clone(),
+ crate::web_chat::publish_web_channel_event(crate::web_chat::WebChannelEvent::ChatError {
+ context: crate::web_chat::channel_event::event_context(
+ "system",
+ target.thread_id.clone(),
+ target.request_id.clone(),
+ ),
message: Some(err.clone()),
error_type: Some("agent_error".to_string()),
- ..Default::default()
+ error_source: None,
+ error_retryable: None,
+ error_retry_after_ms: None,
+ error_provider: None,
+ error_fallback_available: None,
+ copy_key: None,
+ copy_params: None,
+ guardrail: None,
});
}
}