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 crates

Steven Enamakel89d928a2c5e9
diff --git a/crates/openhuman-core/src/cron/job_builder.rs b/crates/openhuman-core/src/cron/job_builder.rs
index 6b1f8916b5..2c608e0271 100644
--- a/crates/openhuman-core/src/cron/job_builder.rs
+++ b/crates/openhuman-core/src/cron/job_builder.rs
@@ -8,9 +8,7 @@
//! delivery the caller states explicitly always wins.
use crate::config::Config;
-use crate::cron::{
- self, delivery_mode, AgentJobSpec, CronJob, DeliveryConfig, JobOrigin, Schedule, SessionTarget,
-};
+use {crate::cron::self, tinyflows_schedule::types::delivery_mode, tinyflows_sqlite::schedule::AgentJobSpec, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::DeliveryConfig, tinyflows_schedule::types::JobOrigin, tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
/// What an agent job creation request carries; everything defaults.
pub struct AgentJobInput {
diff --git a/crates/openhuman-core/src/cron/ops.rs b/crates/openhuman-core/src/cron/ops.rs
index 2d1cdb94b3..1d4ef98fc1 100644
--- a/crates/openhuman-core/src/cron/ops.rs
+++ b/crates/openhuman-core/src/cron/ops.rs
@@ -1,8 +1,6 @@
use crate::config::Config;
use crate::core::Outcome;
-use crate::cron::{
- self, add_shell_job, get_job, update_job, CronJob, CronJobPatch, CronRun, Schedule,
-};
+use {crate::cron::self, crate::cron::add_shell_job, crate::cron::get_job, crate::cron::update_job, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::CronJobPatch, tinyflows_schedule::types::CronRun, tinyflows_schedule::types::Schedule};
use crate::security::SecurityPolicy;
use anyhow::Result;
use once_cell::sync::Lazy;
diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rs
index 332e267e11..4e5708e319 100644
--- a/crates/openhuman-core/src/cron/ops_tests.rs
+++ b/crates/openhuman-core/src/cron/ops_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::cron::ActiveHours;
+use {tinyflows_schedule::types::ActiveHours};
use tempfile::TempDir;
fn test_config(tmp: &TempDir) -> Config {
diff --git a/crates/openhuman-core/src/cron/origin.rs b/crates/openhuman-core/src/cron/origin.rs
index 2b208b5c83..ea3e940a04 100644
--- a/crates/openhuman-core/src/cron/origin.rs
+++ b/crates/openhuman-core/src/cron/origin.rs
@@ -8,7 +8,7 @@
//! external-effect tools stay gated exactly like its creator's were.
use crate::agent::turn_origin::{self, AgentTurnOrigin};
-use crate::cron::{delivery_mode, CronJob, JobOrigin};
+use {tinyflows_schedule::types::delivery_mode, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::JobOrigin};
use serde_json::Value;
/// Map a live turn origin onto the origin a job created in it records.
diff --git a/crates/openhuman-core/src/cron/origin_tests.rs b/crates/openhuman-core/src/cron/origin_tests.rs
index 8e5bae9ad2..b6fc094dfc 100644
--- a/crates/openhuman-core/src/cron/origin_tests.rs
+++ b/crates/openhuman-core/src/cron/origin_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::agent::turn_origin::{with_origin, TrustedAutomationSource};
-use crate::cron::Schedule;
+use {tinyflows_schedule::types::Schedule};
use serde_json::json;
fn channel_turn(history_key: Option<&str>) -> AgentTurnOrigin {
@@ -84,12 +84,12 @@ fn job_with_origin(origin: Option<JobOrigin>) -> CronJob {
command: String::new(),
prompt: Some("p".into()),
name: None,
- job_type: crate::cron::JobType::Agent,
- session_target: crate::cron::SessionTarget::Current,
+ job_type: tinyflows_schedule::types::JobType::Agent,
+ session_target: tinyflows_schedule::types::SessionTarget::Current,
model: None,
agent_id: None,
enabled: true,
- delivery: crate::cron::DeliveryConfig::default(),
+ delivery: tinyflows_schedule::types::DeliveryConfig::default(),
delete_after_run: false,
created_at: chrono::Utc::now(),
next_run: chrono::Utc::now(),
diff --git a/crates/openhuman-core/src/cron/policy_tests.rs b/crates/openhuman-core/src/cron/policy_tests.rs
index ef7a576c8f..ea5b62da5c 100644
--- a/crates/openhuman-core/src/cron/policy_tests.rs
+++ b/crates/openhuman-core/src/cron/policy_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::cron::Schedule;
+use {tinyflows_schedule::types::Schedule};
use tempfile::TempDir;
fn config(tmp: &TempDir) -> Config {
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rs
index 10ca80561d..88b82a8271 100644
--- a/crates/openhuman-core/src/cron/scheduler.rs
+++ b/crates/openhuman-core/src/cron/scheduler.rs
@@ -41,7 +41,7 @@ pub(crate) use slot::SchedulerSlot;
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
-use crate::cron::{due_jobs, CronJob};
+use {crate::cron::due_jobs, tinyflows_schedule::types::CronJob};
use crate::security::SecurityPolicy;
use anyhow::Result;
use chrono::Utc;
diff --git a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
index 1152a036b7..eec929af5e 100644
--- a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
@@ -6,7 +6,7 @@ use super::*;
use crate::cron::policy::{set_policy, JobPolicy};
use crate::cron::system_job_handlers::{register, SystemJobContext};
use crate::cron::system_jobs::ensure_system_job;
-use crate::cron::Schedule;
+use {tinyflows_schedule::types::Schedule};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Duration;
use tempfile::TempDir;
@@ -33,7 +33,7 @@ fn due_system_job(config: &Config, name: &str) -> CronJob {
crate::cron::update_job(
config,
&job.id,
- crate::cron::CronJobPatch {
+ tinyflows_schedule::types::CronJobPatch {
schedule: Some(Schedule::Every {
every_ms: 3_600_000,
}),
diff --git a/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs b/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs
index 3a58529388..467c707690 100644
--- a/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs
@@ -1,9 +1,9 @@
use super::*;
-use crate::cron::JobType;
-use crate::cron::Schedule;
-use crate::cron::TooFrequent;
-use crate::cron::MIN_AGENT_JOB_INTERVAL;
+use {tinyflows_schedule::types::JobType};
+use {tinyflows_schedule::types::Schedule};
+use {tinyflows_schedule::schedule::TooFrequent};
+use {tinyflows_schedule::schedule::MIN_AGENT_JOB_INTERVAL};
#[tokio::test]
async fn deliver_if_configured_empty_success_skips_chat_and_alert() {
let tmp = TempDir::new().unwrap();
diff --git a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
index 2e1044c0de..a6276e6124 100644
--- a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
@@ -1,8 +1,8 @@
use super::*;
-use crate::cron::JobType;
-use crate::cron::Schedule;
-use crate::cron::SessionTarget;
+use {tinyflows_schedule::types::JobType};
+use {tinyflows_schedule::types::Schedule};
+use {tinyflows_schedule::types::SessionTarget};
// TAURI-RUST-514 — a BYO provider insufficient-credits 402 ("requires more
// credits") leaks from a cron-fired agent job through `last_agent_error`.
// `is_insufficient_credits_failure` must consult the message classifier so the
@@ -437,7 +437,7 @@ async fn persist_job_result_success_deletes_one_shot() {
let job = cron::add_agent_job(
&config,
Some("one-shot".into()),
- crate::cron::Schedule::At { at },
+ tinyflows_schedule::types::Schedule::At { at },
"Hello",
SessionTarget::Isolated,
None,
@@ -462,7 +462,7 @@ async fn persist_job_result_failure_disables_one_shot() {
let job = cron::add_agent_job(
&config,
Some("one-shot".into()),
- crate::cron::Schedule::At { at },
+ tinyflows_schedule::types::Schedule::At { at },
"Hello",
SessionTarget::Isolated,
None,
@@ -493,7 +493,7 @@ async fn persist_job_result_disables_at_job_without_delete_flag() {
let job = cron::add_agent_job(
&config,
Some("at-no-delete".into()),
- crate::cron::Schedule::At { at },
+ tinyflows_schedule::types::Schedule::At { at },
"Hello",
SessionTarget::Isolated,
None,
diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rs
index 012b0200b4..1d6ed18fe0 100644
--- a/crates/openhuman-core/src/cron/scheduler_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs
@@ -1,9 +1,9 @@
use super::*;
use crate::agent::error::AgentError;
use crate::config::Config;
-use crate::cron::JobType;
-use crate::cron::SessionTarget;
-use crate::cron::{self, ActiveHours, DeliveryConfig};
+use {tinyflows_schedule::types::JobType};
+use {tinyflows_schedule::types::SessionTarget};
+use {crate::cron::self, tinyflows_schedule::types::ActiveHours, tinyflows_schedule::types::DeliveryConfig};
use crate::security::SecurityPolicy;
use chrono::{Duration as ChronoDuration, Timelike, Utc};
use std::sync::Arc;
@@ -27,7 +27,7 @@ fn test_job(command: &str) -> CronJob {
CronJob {
id: "test-job".into(),
expression: "* * * * *".into(),
- schedule: crate::cron::Schedule::Cron {
+ schedule: tinyflows_schedule::types::Schedule::Cron {
expr: "* * * * *".into(),
tz: None,
active_hours: None,
diff --git a/crates/openhuman-core/src/cron/schemas.rs b/crates/openhuman-core/src/cron/schemas.rs
index 944ac9da2f..5ddf048847 100644
--- a/crates/openhuman-core/src/cron/schemas.rs
+++ b/crates/openhuman-core/src/cron/schemas.rs
@@ -5,7 +5,7 @@ use crate::config::rpc as config_rpc;
use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::Outcome;
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
-use crate::cron::CronJobPatch;
+use {tinyflows_schedule::types::CronJobPatch};
fn job_id_input(comment: &'static str) -> FieldSchema {
FieldSchema {
@@ -285,7 +285,7 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
- let schedule: crate::cron::Schedule = read_required(&params, "schedule")?;
+ let schedule: tinyflows_schedule::types::Schedule = read_required(&params, "schedule")?;
let name = params
.get("name")
.and_then(|v| v.as_str())
@@ -303,9 +303,9 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
.and_then(|v| v.as_str())
.unwrap_or("isolated");
let session_target = match session_target_str {
- "main" => crate::cron::SessionTarget::Main,
- "isolated" => crate::cron::SessionTarget::Isolated,
- "current" => crate::cron::SessionTarget::Current,
+ "main" => tinyflows_schedule::types::SessionTarget::Main,
+ "isolated" => tinyflows_schedule::types::SessionTarget::Isolated,
+ "current" => tinyflows_schedule::types::SessionTarget::Current,
other => return Err(format!("invalid 'session_target': {other}")),
};
let model = params
@@ -316,7 +316,7 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
.get("agent_id")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
- let delivery: Option<crate::cron::DeliveryConfig> = match params.get("delivery") {
+ let delivery: Option<tinyflows_schedule::types::DeliveryConfig> = match params.get("delivery") {
None | Some(Value::Null) => None,
Some(v) => Some(
serde_json::from_value(v.clone())
@@ -327,7 +327,7 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
.get("delete_after_run")
.and_then(|v| v.as_bool())
.unwrap_or(false);
- let origin: Option<crate::cron::JobOrigin> = match params.get("origin") {
+ let origin: Option<tinyflows_schedule::types::JobOrigin> = match params.get("origin") {
None | Some(Value::Null) => None,
Some(v) => Some(
serde_json::from_value(v.clone()).map_err(|e| format!("invalid 'origin': {e}"))?,
@@ -361,7 +361,7 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
let delivery = delivery.or_else(|| {
origin
.is_none()
- .then(crate::cron::DeliveryConfig::default)
+ .then(tinyflows_schedule::types::DeliveryConfig::default)
.or_else(|| {
Some(crate::cron::job_builder::default_delivery(origin.as_ref()))
})
@@ -372,7 +372,7 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
&delivery_cfg,
origin.as_ref(),
)?;
- let mut spec = crate::cron::AgentJobSpec::new(schedule, p);
+ let mut spec = tinyflows_sqlite::schedule::AgentJobSpec::new(schedule, p);
spec.name = name;
spec.session_target = session_target;
spec.model = model;
diff --git a/crates/openhuman-core/src/cron/seed.rs b/crates/openhuman-core/src/cron/seed.rs
index 640ffd95b4..18336ed9fe 100644
--- a/crates/openhuman-core/src/cron/seed.rs
+++ b/crates/openhuman-core/src/cron/seed.rs
@@ -18,10 +18,7 @@
//! scheduler can't double-deliver.
use crate::config::Config;
-use crate::cron::{
- add_agent_job_with_definition, dedup_named_jobs, list_jobs, remove_job, DeliveryConfig,
- Schedule, SessionTarget,
-};
+use {crate::cron::add_agent_job_with_definition, crate::cron::dedup_named_jobs, crate::cron::list_jobs, crate::cron::remove_job, tinyflows_schedule::types::DeliveryConfig, tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
use anyhow::Result;
/// Well-known job names used to detect whether seeding has already run.
@@ -128,7 +125,7 @@ pub fn prune_retired_jobs(config: &Config) -> Result<usize> {
/// cron entry fire alongside that would double-deliver. Best-effort:
/// log but don't fail seeding on a prune error, and scan all entries
/// because the ID is a UUID — we key on the stable `name` field.
-fn prune_legacy_welcome(config: &Config, existing: &[crate::cron::CronJob]) {
+fn prune_legacy_welcome(config: &Config, existing: &[tinyflows_schedule::types::CronJob]) {
let stale_ids: Vec<String> = existing
.iter()
.filter(|j| j.name.as_deref() == Some(LEGACY_WELCOME_JOB_NAME))
diff --git a/crates/openhuman-core/src/cron/seed_tests.rs b/crates/openhuman-core/src/cron/seed_tests.rs
index 39a068cd2b..ae042fe365 100644
--- a/crates/openhuman-core/src/cron/seed_tests.rs
+++ b/crates/openhuman-core/src/cron/seed_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::cron::{add_agent_job_with_definition, list_jobs, Schedule, SessionTarget};
+use {crate::cron::add_agent_job_with_definition, crate::cron::list_jobs, tinyflows_schedule::types::Schedule, tinyflows_schedule::types::SessionTarget};
use chrono::{Duration as ChronoDuration, Utc};
use tempfile::TempDir;
@@ -40,7 +40,7 @@ fn seeds_morning_briefing_disabled_and_idempotent() {
let jobs = list_jobs(&config).unwrap();
assert!(
jobs.iter()
- .filter(|j| matches!(j.job_type, crate::cron::JobType::Agent))
+ .filter(|j| matches!(j.job_type, tinyflows_schedule::types::JobType::Agent))
.all(|j| !j.enabled),
"fresh onboarding seed must not create enabled billable agent cron jobs: {jobs:?}"
);
diff --git a/crates/openhuman-core/src/cron/system_jobs.rs b/crates/openhuman-core/src/cron/system_jobs.rs
index f5181cea45..0e253043d2 100644
--- a/crates/openhuman-core/src/cron/system_jobs.rs
+++ b/crates/openhuman-core/src/cron/system_jobs.rs
@@ -20,10 +20,7 @@ use crate::config::Config;
use crate::memory::bus::{RETIRED_CONTEXT_REFRESH_JOB, SOURCES_SYNC_JOB};
use crate::memory::lifecycle::jobs::{BACKGROUND_INTERVAL_MINS, BACKGROUND_JOB};
-use super::{
- add_flow_schedule_job, list_jobs, remove_job, update_job, CronJob, CronJobPatch, JobType,
- Schedule,
-};
+use {super::add_flow_schedule_job, super::list_jobs, super::remove_job, super::update_job, tinyflows_schedule::types::CronJob, tinyflows_schedule::types::CronJobPatch, tinyflows_schedule::types::JobType, tinyflows_schedule::types::Schedule};
/// Command prefix that marks a `flow` row as a system job.
pub const SYSTEM_COMMAND_PREFIX: &str = "system:";
diff --git a/crates/openhuman-core/src/security/mod.rs b/crates/openhuman-core/src/security/mod.rs
index ae9073cb85..59fbf5ffae 100644
--- a/crates/openhuman-core/src/security/mod.rs
+++ b/crates/openhuman-core/src/security/mod.rs
@@ -39,10 +39,7 @@ pub use egress::{
pub use ops as rpc;
pub use ops::*;
#[allow(unused_imports)]
-pub use pairing::{
- ensure_core_rpc_token_for_bind, is_public_bind, CoreBindTokenError, PairingGuard,
- CORE_TOKEN_ENV_VAR,
-};
+pub use {pairing::ensure_core_rpc_token_for_bind, pairing::is_public_bind, pairing::CoreBindTokenError, tinychannels_runtime::security::PairingGuard, pairing::CORE_TOKEN_ENV_VAR};
pub use policy::validate_path_within_root;
#[allow(unused_imports)]
pub use policy::AutonomyLevel;
diff --git a/crates/openhuman-embed/src/agent/approval_handler.rs b/crates/openhuman-embed/src/agent/approval_handler.rs
index 68e4174f38..1d0fc91bfa 100644
--- a/crates/openhuman-embed/src/agent/approval_handler.rs
+++ b/crates/openhuman-embed/src/agent/approval_handler.rs
@@ -1,6 +1,6 @@
//! Callback-based approvals, using the same agent-scoped gate as polling.
use crate::{ApprovalDecision, Approvals, CancellationToken, PendingApproval};
-use openhuman_core::core::bus::{EventHandler, SubscriptionHandle, BUS};
+use {tinybus::EventHandler, tinybus::SubscriptionHandle, openhuman_core::core::bus::BUS};
use openhuman_core::core::events::DomainEvent;
use std::sync::Arc;
diff --git a/crates/openhuman-embed/src/cron.rs b/crates/openhuman-embed/src/cron.rs
index fc686923d4..4f9934ecc1 100644
--- a/crates/openhuman-embed/src/cron.rs
+++ b/crates/openhuman-embed/src/cron.rs
@@ -61,7 +61,7 @@ use std::time::SystemTime;
use openhuman_core::config::Config;
use openhuman_core::cron::policy::{self, JobPolicy};
use openhuman_core::cron::system_jobs::SYSTEM_COMMAND_PREFIX;
-use openhuman_core::cron::{CronJob, CronJobPatch, JobType, Schedule};
+use {tinyflows_schedule::types::CronJob, tinyflows_schedule::types::CronJobPatch, tinyflows_schedule::types::JobType, tinyflows_schedule::types::Schedule};
pub use openhuman_core::cron::system_job_handlers::SystemJobContext;
@@ -528,7 +528,7 @@ fn create(
Some(name.to_string()),
schedule,
prompt,
- openhuman_core::cron::SessionTarget::Isolated,
+ tinyflows_schedule::types::SessionTarget::Isolated,
None,
None,
false,
diff --git a/crates/openhuman-embed/src/cron_tests.rs b/crates/openhuman-embed/src/cron_tests.rs
index d662ea6c7e..f8da1f95c6 100644
--- a/crates/openhuman-embed/src/cron_tests.rs
+++ b/crates/openhuman-embed/src/cron_tests.rs
@@ -11,7 +11,7 @@ fn core_job(job_type: JobType, command: &str) -> CronJob {
prompt: Some("check in".into()),
name: Some("named".into()),
job_type,
- session_target: openhuman_core::cron::SessionTarget::Isolated,
+ session_target: tinyflows_schedule::types::SessionTarget::Isolated,
model: None,
agent_id: Some("teeny".into()),
enabled: true,
@@ -46,7 +46,7 @@ fn a_cron_schedule_drops_active_hours_it_cannot_express() {
let core = Schedule::Cron {
expr: "0 * * * *".into(),
tz: None,
- active_hours: Some(openhuman_core::cron::ActiveHours {
+ active_hours: Some(tinyflows_schedule::types::ActiveHours {
start: "09:00".into(),
end: "17:00".into(),
}),
diff --git a/crates/openhuman-embed/src/events.rs b/crates/openhuman-embed/src/events.rs
index 5a2dd8162e..a5b0b60dc2 100644
--- a/crates/openhuman-embed/src/events.rs
+++ b/crates/openhuman-embed/src/events.rs
@@ -1,7 +1,7 @@
//! Content-free runtime observations with bounded, explicit backpressure.
use futures_core::Stream;
-use openhuman_core::core::bus::{EventHandler, SubscriptionHandle, BUS};
+use {tinybus::EventHandler, tinybus::SubscriptionHandle, openhuman_core::core::bus::BUS};
use openhuman_core::core::events::DomainEvent;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet};