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(cron): add manual job run path through durable occurrence
Steven Enamakel3f4f02ba5d74
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rsindex 15674c67c4..82e5743672 100644--- a/crates/openhuman-core/src/cron/scheduler.rs+++ b/crates/openhuman-core/src/cron/scheduler.rs@@ -54,27 +54,23 @@ use crate::cron::documents_port::DocScope;use crate::modules::tinyflows as module;use crate::security::SecurityPolicy;use anyhow::{anyhow, Result};-use manual_run::{LoopSlot, MIN_POLL_SECONDS};use std::collections::{HashMap, HashSet};use std::sync::atomic::{AtomicBool, Ordering};use std::sync::{Arc, LazyLock, Mutex};use tinyflows_bus::schedule::types::CronJob;-use tinyflows_bus::schedule::{members, Attempt, StartScheduler, StoreBackend, StoreConfig};+use tinyflows_bus::schedule::{+ members, Attempt, ManualDelivery, RunJobNow, RunJobReply, StartScheduler, StoreBackend,+ StoreConfig,+};use tokio::time::{self, Duration};pub async fn run(ctx: &crate::core::runtime::DispatchCtx, config: Config) -> Result<()> {- let Some(_slot) = LoopSlot::acquire() else {- tracing::warn!(- "[cron:scheduler] a scheduler loop is already running; not starting another"- );- return Ok(());- };// Ensure the global event bus is initialized so cron delivery events// are not silently dropped. This is a no-op if already initialized.crate::core::bus::init().await.expect("bus init");crate::platform::health::bus::register_health_subscriber();- let poll_secs = config.reliability.scheduler_poll_secs.max(MIN_POLL_SECONDS);+ let poll_secs = config.reliability.scheduler_poll_secs.max(5);let mut interval = time::interval(Duration::from_secs(poll_secs));let security = Arc::new(SecurityPolicy::from_config(&config.autonomy,@@ -103,8 +99,15 @@ pub async fn run(ctx: &crate::core::runtime::DispatchCtx, config: Config) -> Res}pub use dispatcher::execute_job_now;+pub(crate) use dispatcher::run_job_now;pub(crate) use dispatcher::{tick_once, JobDispatcher};pub use live_agents::run_live_agent_pass;pub(crate) use live_agents::LiveAgentSchedulers;-pub use manual_run::is_running;-pub(crate) use manual_run::{scheduler_config, try_acquire_run, ALREADY_RUNNING};+pub(crate) fn scheduler_config(config: &Config) -> serde_json::Value {+ serde_json::json!({+ "poll_secs": config.reliability.scheduler_poll_secs,+ "max_concurrent": config.scheduler.max_concurrent,+ "retries": config.reliability.scheduler_retries,+ "backoff_ms": config.reliability.provider_backoff_ms,+ })+}diff --git a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs b/crates/openhuman-core/src/cron/scheduler/dispatcher.rsindex abc3c6f5b1..3f1df536d4 100644--- a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs+++ b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs@@ -21,6 +21,71 @@ pub async fn execute_job_now(}}+/// Admit and optionally wait for a manual run through the module's durable+/// occurrence path. Detached runs keep their callback object served until the+/// module sends the terminal projection.+pub(crate) async fn run_job_now(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ job: CronJob,+ run_id: String,+ wait: bool,+ delivery: ManualDelivery,+) -> Result<RunJobReply> {+ let security = Arc::new(SecurityPolicy::from_config(+ &config.autonomy,+ &config.workspace_dir,+ &config.action_dir,+ ));+ let binding = Binding::new(ctx, config, security);+ let host = bus_host::register(binding.clone()).await.map_err(|e| anyhow!(e))?;+ let scope = binding+ .within(async { DocScope::current(config) })+ .await?;+ let storage = StoreConfig {+ backend: StoreBackend::Documents {+ callback: crate::cron::documents_port::address(&scope).await?,+ },+ max_run_history: config.cron.max_run_history,+ max_tasks: config.scheduler.max_tasks,+ };+ let request = RunJobNow {+ scope: CLAIM_SCOPE.to_string(),+ callback: host.address(),+ config: scheduler_config(config),+ storage,+ job,+ run_id: run_id.clone(),+ delivery,+ wait,+ };+ if !wait {+ bus_host::retain_manual_host(&run_id, host);+ }+ let reply = async {+ let proxy = module::run_proxy(config).await.map_err(|e| anyhow!(e))?;+ proxy+ .call(members::RUN_JOB_NOW, (request,))+ .await+ .map_err(|error| anyhow!(error.wire_message()))+ }+ .await;+ match reply {+ Ok(reply) => {+ if !wait && !matches!(reply, RunJobReply::Accepted { .. }) {+ bus_host::release_manual_host(&run_id);+ }+ Ok(reply)+ }+ Err(error) => {+ if !wait {+ bus_host::release_manual_host(&run_id);+ }+ Err(error)+ }+ }+}+async fn execute_via_bus(ctx: &crate::core::runtime::DispatchCtx,config: &Config,@@ -184,7 +249,7 @@ impl JobDispatcher {max_tasks: config.scheduler.max_tasks,};let request = StartScheduler {- scope: CLAIM_SCOPE.to_string(),+ scope: scope.scheduler_scope(),callback: host.address(),config: scheduler_config(config),manual_ticks: true,