Skip to content

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

refactor(cron): import schedule types from tinyflows_schedule

Steven Enamakelfb5a5a254ca2
diff --git a/crates/openhuman-core/src/cron/scheduler/agent_run.rs b/crates/openhuman-core/src/cron/scheduler/agent_run.rs
index f416e98acb..0feddd91aa 100644
--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs
+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs
@@ -8,7 +8,7 @@ use crate::agent::OpenHumanSessionHost;
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use crate::cron::{CronJob, SessionTarget};
+use {tinyflows_schedule::types::CronJob, tinyflows_schedule::types::SessionTarget};
/// Recency window the morning briefing installs around its turn so Composio
/// task-fetch tools only surface tasks created/changed in the last day. Read
diff --git a/crates/openhuman-core/src/cron/scheduler/delivery.rs b/crates/openhuman-core/src/cron/scheduler/delivery.rs
index 68cfadca19..6a316124c7 100644
--- a/crates/openhuman-core/src/cron/scheduler/delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/delivery.rs
@@ -7,7 +7,7 @@ use super::origin_delivery::{deliver_to_origin, is_suppressed_output};
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use crate::cron::{delivery_mode, CronJob, DeliveryConfig, DeliveryStatus, JobType};
+use {tinyflows_schedule::types::delivery_mode, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::DeliveryConfig, tinyflows_schedule::types::DeliveryStatus, tinyflows_schedule::types::JobType};
use anyhow::Result;
use chrono::Utc;
diff --git a/crates/openhuman-core/src/cron/scheduler/dispatch.rs b/crates/openhuman-core/src/cron/scheduler/dispatch.rs
index ba46851255..bb539fb600 100644
--- a/crates/openhuman-core/src/cron/scheduler/dispatch.rs
+++ b/crates/openhuman-core/src/cron/scheduler/dispatch.rs
@@ -33,7 +33,7 @@ use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::core::runtime::CoreContext;
use crate::cron::policy::policy_or_default;
-use crate::cron::{next_run_for_schedule, record_run, update_job, CronJob, CronJobPatch, Schedule};
+use {tinyflows_schedule::schedule::next_run_for_schedule, crate::cron::record_run, crate::cron::update_job, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::CronJobPatch, tinyflows_schedule::types::Schedule};
use crate::security::SecurityPolicy;
/// Output recorded for a single-flight slot missed while a run was in flight.
diff --git a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
index 9edde682b3..a7c9fddc77 100644
--- a/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
+++ b/crates/openhuman-core/src/cron/scheduler/failure_classification.rs
@@ -2,7 +2,7 @@
//! the permanent-halt predicates that stop the retry loop early.
use crate::agent::error::AgentError;
-use crate::cron::JobType;
+use {tinyflows_schedule::types::JobType};
pub(super) const AGENT_JOB_USER_FAILURE_MESSAGE: &str = "Something went wrong. Please try again.";
// Actionable, static failure copy for the three permanent cron halt states
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_context.rs b/crates/openhuman-core/src/cron/scheduler/origin_context.rs
index 6a45c7e295..f499c6adbd 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_context.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_context.rs
@@ -3,7 +3,7 @@
//! preamble saying the run is unattended.
use crate::config::Config;
-use crate::cron::{channel_bridge, CronJob, JobOrigin};
+use {crate::cron::channel_bridge, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::JobOrigin};
/// At most this many trailing messages of the origin conversation.
pub(crate) const CONTEXT_MAX_MESSAGES: usize = 10;
@@ -98,7 +98,7 @@ pub(crate) fn compose_current_prompt(job_id: &str, name: &str, prompt: &str, tai
/// plain tagged prompt; `current` and `main` get the context and preamble.
pub(crate) async fn build_run_prompt(config: &Config, job: &CronJob, name: &str) -> String {
let prompt = job.prompt.clone().unwrap_or_default();
- use crate::cron::SessionTarget;
+ use {tinyflows_schedule::types::SessionTarget};
match (&job.session_target, &job.origin) {
(SessionTarget::Isolated, _) => format!("[cron:{} {name}] {prompt}", job.id),
(target, 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..4afc2397e7 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery.rs
@@ -13,7 +13,7 @@
use super::delivery::strip_openhuman_link_markup;
use crate::config::Config;
-use crate::cron::{channel_bridge, CronJob, DeliveryStatus, JobOrigin};
+use {crate::cron::channel_bridge, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::DeliveryStatus, tinyflows_schedule::types::JobOrigin};
use crate::web_chat::{publish_web_channel_event, WebChannelEvent};
use anyhow::{anyhow, Result};
use std::path::Path;
diff --git a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
index b383a33b1f..a166916495 100644
--- a/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler/origin_delivery_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::cron::{DeliveryConfig, JobType, Schedule, SessionTarget};
+use {tinyflows_schedule::types::DeliveryConfig, tinyflows_schedule::types::JobType, tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
use crate::threads::store::{self as conversations, CreateConversationThread};
use tinyagents_session::transcript::{
read_transcript, resolve_keyed_transcript_path, session_stem, FileTranscriptLocator,
diff --git a/crates/openhuman-core/src/cron/scheduler/retry.rs b/crates/openhuman-core/src/cron/scheduler/retry.rs
index d26d53a607..7f2a934474 100644
--- a/crates/openhuman-core/src/cron/scheduler/retry.rs
+++ b/crates/openhuman-core/src/cron/scheduler/retry.rs
@@ -8,7 +8,7 @@ use super::failure_classification::{
};
use super::shell_job::run_job_command;
use crate::config::Config;
-use crate::cron::{CronJob, JobType, SessionTarget};
+use {tinyflows_schedule::types::CronJob, tinyflows_schedule::types::JobType, tinyflows_schedule::types::SessionTarget};
use crate::security::SecurityPolicy;
use chrono::Utc;
use tokio::time::{self, Duration};
diff --git a/crates/openhuman-core/src/cron/scheduler/run_record.rs b/crates/openhuman-core/src/cron/scheduler/run_record.rs
index b83a95e250..f4cb3e9ec4 100644
--- a/crates/openhuman-core/src/cron/scheduler/run_record.rs
+++ b/crates/openhuman-core/src/cron/scheduler/run_record.rs
@@ -3,11 +3,7 @@
use super::delivery::deliver_run;
use crate::config::Config;
-use crate::cron::{
- record_last_run, record_run_with_delivery, remove_job, reschedule_after_run, runs_closer_than,
- update_job, CronJob, CronJobPatch, DeliveryStatus, JobType, Schedule, TooFrequent,
- MIN_AGENT_JOB_INTERVAL,
-};
+use {crate::cron::record_last_run, crate::cron::record_run_with_delivery, crate::cron::remove_job, crate::cron::reschedule_after_run, tinyflows_schedule::schedule::runs_closer_than, crate::cron::update_job, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::CronJobPatch, tinyflows_schedule::types::DeliveryStatus, tinyflows_schedule::types::JobType, tinyflows_schedule::types::Schedule, tinyflows_schedule::schedule::TooFrequent, tinyflows_schedule::schedule::MIN_AGENT_JOB_INTERVAL};
use chrono::{DateTime, Utc};
/// [`persist_job_result_for_run`] under a fresh run id.
diff --git a/crates/openhuman-core/src/cron/scheduler/shell_job.rs b/crates/openhuman-core/src/cron/scheduler/shell_job.rs
index 66d4aa35ff..15b5be31c3 100644
--- a/crates/openhuman-core/src/cron/scheduler/shell_job.rs
+++ b/crates/openhuman-core/src/cron/scheduler/shell_job.rs
@@ -2,7 +2,7 @@
//! forbidden-path argument scan and a hard timeout.
use crate::config::Config;
-use crate::cron::CronJob;
+use {tinyflows_schedule::types::CronJob};
use crate::security::SecurityPolicy;
use std::process::Stdio;
use tokio::time::{self, Duration};
diff --git a/crates/openhuman-core/src/cron/tools/add.rs b/crates/openhuman-core/src/cron/tools/add.rs
index 2e2c0b28bf..a8ac3c9bb6 100644
--- a/crates/openhuman-core/src/cron/tools/add.rs
+++ b/crates/openhuman-core/src/cron/tools/add.rs
@@ -1,7 +1,7 @@
use crate::config::Config;
use crate::cron::job_builder::{create_agent_job, AgentJobInput};
use crate::cron::origin::{current_job_origin, current_turn_may_skip_approval};
-use crate::cron::{self, DeliveryConfig, JobType, Schedule, SessionTarget};
+use {crate::cron::self, tinyflows_schedule::types::DeliveryConfig, tinyflows_schedule::types::JobType, tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
use crate::security::SecurityPolicy;
use crate::tools::schema_cache::static_schema;
use async_trait::async_trait;
diff --git a/crates/openhuman-core/src/cron/tools/add_tests.rs b/crates/openhuman-core/src/cron/tools/add_tests.rs
index fab09006a6..3f5ed7ae86 100644
--- a/crates/openhuman-core/src/cron/tools/add_tests.rs
+++ b/crates/openhuman-core/src/cron/tools/add_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use crate::config::Config;
use crate::cron::job_builder::validate_delivery;
-use crate::cron::ActiveHours;
+use {tinyflows_schedule::types::ActiveHours};
use crate::security::AutonomyLevel;
use tempfile::TempDir;
diff --git a/crates/openhuman-core/src/cron/tools/list.rs b/crates/openhuman-core/src/cron/tools/list.rs
index b4ffe720c7..ab73863bbc 100644
--- a/crates/openhuman-core/src/cron/tools/list.rs
+++ b/crates/openhuman-core/src/cron/tools/list.rs
@@ -1,6 +1,6 @@
use crate::config::Config;
use crate::cron;
-use crate::cron::CronJob;
+use {tinyflows_schedule::types::CronJob};
use async_trait::async_trait;
use serde_json::json;
use std::fmt::Write as _;
diff --git a/crates/openhuman-core/src/cron/tools/update.rs b/crates/openhuman-core/src/cron/tools/update.rs
index 669410b2e2..d46eb444b4 100644
--- a/crates/openhuman-core/src/cron/tools/update.rs
+++ b/crates/openhuman-core/src/cron/tools/update.rs
@@ -1,5 +1,5 @@
use crate::config::Config;
-use crate::cron::{self, CronJobPatch};
+use {crate::cron::self, tinyflows_schedule::types::CronJobPatch};
use crate::security::SecurityPolicy;
use async_trait::async_trait;
use serde_json::json;
diff --git a/crates/openhuman-core/src/cron/tools/update_tests.rs b/crates/openhuman-core/src/cron/tools/update_tests.rs
index 9f3d36336a..57303d22c8 100644
--- a/crates/openhuman-core/src/cron/tools/update_tests.rs
+++ b/crates/openhuman-core/src/cron/tools/update_tests.rs
@@ -110,7 +110,7 @@ fn cron_update_permission_level_is_execute() {
#[tokio::test]
async fn rejects_tightening_an_agent_job_below_five_minutes() {
- use crate::cron::{Schedule, SessionTarget};
+ use {tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
let tmp = TempDir::new().unwrap();
let cfg = test_config(&tmp).await;
diff --git a/crates/openhuman-core/src/flows/ops/triggers.rs b/crates/openhuman-core/src/flows/ops/triggers.rs
index 2fc64bdc2e..4acdc11eff 100644
--- a/crates/openhuman-core/src/flows/ops/triggers.rs
+++ b/crates/openhuman-core/src/flows/ops/triggers.rs
@@ -163,7 +163,7 @@ pub(super) fn bind_schedule_trigger(config: &Config, flow: &Flow) {
tracing::warn!(target: "flows", flow_id = %flow.id, "[flows] schedule trigger config is missing `schedule` — cannot bind cron job");
return;
};
- let schedule: crate::cron::Schedule = match serde_json::from_value(schedule_raw) {
+ let schedule: tinyflows_schedule::types::Schedule = match serde_json::from_value(schedule_raw) {
Ok(s) => s,
Err(e) => {
tracing::warn!(target: "flows", flow_id = %flow.id, error = %e, "[flows] invalid schedule trigger config — cannot bind cron job");
@@ -173,7 +173,7 @@ pub(super) fn bind_schedule_trigger(config: &Config, flow: &Flow) {
match crate::cron::find_flow_schedule_job(config, &flow.id) {
Ok(Some(existing)) => {
- let patch = crate::cron::CronJobPatch {
+ let patch = tinyflows_schedule::types::CronJobPatch {
enabled: Some(true),
schedule: Some(schedule),
..Default::default()
diff --git a/crates/openhuman-core/src/tools/impl/system/schedule.rs b/crates/openhuman-core/src/tools/impl/system/schedule.rs
index fd258d1660..46126d346e 100644
--- a/crates/openhuman-core/src/tools/impl/system/schedule.rs
+++ b/crates/openhuman-core/src/tools/impl/system/schedule.rs
@@ -1,7 +1,7 @@
use crate::config::Config;
use crate::cron::job_builder::{create_agent_job, AgentJobInput};
use crate::cron::origin::{current_job_origin, current_turn_may_skip_approval};
-use crate::cron::{self, Schedule};
+use {crate::cron::self, tinyflows_schedule::types::Schedule};
use crate::security::SecurityPolicy;
use crate::tools::schema_cache::static_schema;
use anyhow::Result;