Skip to content

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

feat(cron): deliver scheduled job output to origin channel

Steven Enamakel93eea0bd8cb8
diff --git a/crates/openhuman-core/src/cron/mod.rs b/crates/openhuman-core/src/cron/mod.rs
index aff93a72f0..42557c0a8d 100644
--- a/crates/openhuman-core/src/cron/mod.rs
+++ b/crates/openhuman-core/src/cron/mod.rs
@@ -11,7 +11,9 @@ pub mod scheduler_gate;
pub mod bus;
pub mod channel_bridge;
+pub mod claims;
pub mod completion_owner;
+pub mod host_delivery;
pub mod job_builder;
pub mod ops;
pub mod origin;
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
index ed9dfce3bf..8b71dbcb8b 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -149,6 +149,30 @@ pub(crate) async fn deliver_to_origin(
};
let text = output.trim();
+ // A hosted profile's host routes the reply itself.
+ if let (Some(sink), Some(profile_id)) = (
+ crate::cron::host_delivery::installed(),
+ crate::core::runtime::current_tenant()
+ .ok()
+ .and_then(|tenant| tenant.profile),
+ ) {
+ let thread_id = match origin {
+ JobOrigin::Web { thread_id, .. } => Some(thread_id.clone()),
+ JobOrigin::Channel { thread_id, .. } => thread_id.clone(),
+ };
+ sink.deliver(crate::cron::host_delivery::CronReply {
+ profile_id,
+ job_id: job.id.clone(),
+ run_id: run_id.to_string(),
+ thread_id,
+ origin: Some(origin.clone()),
+ text: text.to_string(),
+ })
+ .await
+ .map_err(|e| anyhow!("the host could not deliver the reply: {e}"))?;
+ return Ok(DeliveryStatus::Delivered);
+ }
+
match origin {
JobOrigin::Web {
thread_id,