Skip to content

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

chore: I don't see an actual diff in your message — the "Diff:" section is empty, and the stat is bl

Steven Enamakel76ee4cf1b70e
diff --git a/crates/openhuman-embed/src/profiles.rs b/crates/openhuman-embed/src/profiles.rs
index b55b66d2c8..4afa4ac70c 100644
--- a/crates/openhuman-embed/src/profiles.rs
+++ b/crates/openhuman-embed/src/profiles.rs
@@ -67,6 +67,9 @@ pub use handle::{ChatReply, ProfileEvents, ProfileHandle, RelayAccepted};
pub use openhuman_core::channels::providers::relay::RelayInboundParams as RelayMessage;
pub use openhuman_core::core::runtime::saas::SaasSandboxConfig;
pub use openhuman_core::core::runtime::SaasConfig;
+pub use openhuman_core::cron::host_delivery::{CronDelivery, CronReply};
+pub use openhuman_core::cron::JobOrigin;
+pub use openhuman_core::profiles::cron::SweepReport as CronSweepReport;
pub use openhuman_core::profiles::{OpenError, ProfileId, ProfileIdMode, ProfileSummary};
pub use openhuman_core::storage::lease::LeaseRecord;
pub use openhuman_core::threads::{ConversationMessageRecord, ConversationThreadSummary};
@@ -120,6 +123,7 @@ pub struct ProfileRuntimeBuilder {
config: SaasConfig,
session_store: Option<Arc<dyn SessionStoreProvider>>,
host_options: host::ProfileHostOptions,
+ cron_delivery: Option<Arc<dyn CronDelivery>>,
}
impl ProfileRuntimeBuilder {
@@ -129,6 +133,7 @@ impl ProfileRuntimeBuilder {
config,
session_store: None,
host_options: Default::default(),
+ cron_delivery: None,
}
}
@@ -151,12 +156,27 @@ impl ProfileRuntimeBuilder {
self
}
+ /// Route the replies of scheduled jobs yourself, and serve them.
+ ///
+ /// With a delivery installed the runtime's background loop sweeps every
+ /// provisioned profile once a minute for due agent jobs
+ /// ([`ProfileRuntime::sweep_cron`]) and hands each reply to
+ /// [`CronDelivery::deliver`] with the profile, the thread the job was
+ /// created in and its [`JobOrigin`]. A run that answers `NO_REPLY`, or
+ /// fails, is never delivered. Without one nothing is swept.
+ #[must_use]
+ pub fn cron_delivery(mut self, delivery: Arc<dyn CronDelivery>) -> Self {
+ self.cron_delivery = Some(delivery);
+ self
+ }
+
/// Boot the SaaS core. See the [module docs](self) for what this locks.
pub async fn build(self) -> Result<ProfileRuntime, ProfileError> {
let Self {
config,
session_store,
host_options,
+ cron_delivery,
} = self;
let capabilities = host_options.finish(&config)?;
ensure_service_token(&config.service_token_path())?;
@@ -203,6 +223,9 @@ impl ProfileRuntimeBuilder {
}
ProfileError::Boot("the SaaS core installed no profile host".to_string())
})?;
+ if let Some(delivery) = cron_delivery {
+ openhuman_core::cron::host_delivery::install(delivery);
+ }
log::info!(
"[embed][profiles] profile runtime ready node={} root={}",
host.node(),
@@ -332,6 +355,19 @@ impl ProfileRuntime {
.map_err(ProfileError::Host)
}
+ /// Run every provisioned profile's due agent jobs now, as the background
+ /// loop does each minute: see [`ProfileRuntimeBuilder::cron_delivery`].
+ /// Safe to run on several nodes sharing one storage backend: each
+ /// scheduled occurrence is claimed in the store and runs once.
+ pub async fn sweep_cron(&self) -> CronSweepReport {
+ self.sweep_cron_at(chrono::Utc::now()).await
+ }
+
+ /// [`sweep_cron`](Self::sweep_cron) as of `now`.
+ pub async fn sweep_cron_at(&self, now: chrono::DateTime<chrono::Utc>) -> CronSweepReport {
+ openhuman_core::profiles::cron::sweep(&self.inner.host, now).await
+ }
+
/// Store the TinyHumans credential (`kind`) the profile's backend calls
/// ride: what the gateway does through `profiles.set_credential`.
pub async fn set_credential(