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
chore: files changed crates/openhuman-core/src/cron/ops_delivery_tests.rs,crates/openhuman-core/src/
Steven Enamakel9cf822aacf1c
diff --git a/crates/openhuman-core/src/cron/ops_delivery_tests.rs b/crates/openhuman-core/src/cron/ops_delivery_tests.rsindex 8944985042..2ec8c1387e 100644--- a/crates/openhuman-core/src/cron/ops_delivery_tests.rs+++ b/crates/openhuman-core/src/cron/ops_delivery_tests.rs@@ -1,25 +1,67 @@use super::*;use crate::cron;+use async_trait::async_trait;+use std::sync::{Arc, Mutex};use tempfile::TempDir;+use tinychannels_bus::{Channel, ChannelMessage, SendMessage};use tinyflows_bus::schedule::types::{DeliveryConfig, DeliveryStatus};+use tokio::sync::mpsc;++struct FailingTelegram;++#[async_trait]+impl Channel for FailingTelegram {+ fn name(&self) -> &str {+ "telegram"+ }++ async fn send(&self, _message: &SendMessage) -> anyhow::Result<()> {+ anyhow::bail!("mock telegram send failed")+ }++ async fn listen(&self, _tx: mpsc::Sender<ChannelMessage>) -> anyhow::Result<()> {+ Ok(())+ }+}++pub(super) fn install_failing_telegram_bridge() {+ crate::cron::channel_bridge::register_channel_bridge(+ Arc::new(Mutex::default()),+ Arc::new(std::collections::HashMap::from([(+ "telegram".to_string(),+ Arc::new(FailingTelegram) as Arc<dyn Channel>,+ )])),+ crate::cron::channel_bridge::MAX_HISTORY_MESSAGES,+ );+}#[tokio::test]async fn run_job_now_keeps_best_effort_failure_successful_and_records_failed_delivery() {+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;let tmp = TempDir::new().unwrap();- let config = tests::test_config(&tmp);+ let mut config = tests::test_config(&tmp);+ config.channels_config.telegram = Some(crate::config::TelegramConfig {+ bot_token: "test-token".into(),+ chat_id: None,+ allowed_users: vec!["target".into()],+ stream_mode: Default::default(),+ draft_update_interval_ms: 1000,+ silent_streaming: true,+ mention_only: false,+ });+ install_failing_telegram_bridge();let _handler = crate::cron::system_job_handlers::register("ops-run-now-best-effort-delivery-failure",std::sync::Arc::new(|_ctx| Box::pin(async { Ok(()) })),);let job = tests::single_flight_system_job(&config, "ops-run-now-best-effort-delivery-failure");- let missing_channel = format!("missing-{}", uuid::Uuid::new_v4());cron::update_job(&config,&job.id,CronJobPatch {delivery: Some(DeliveryConfig {mode: "announce".into(),- channel: Some(missing_channel),+ channel: Some("telegram".into()),to: Some("target".into()),best_effort: true,}),diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rsindex f32deae1a8..9e89cd0c45 100644--- a/crates/openhuman-core/src/cron/ops_tests.rs+++ b/crates/openhuman-core/src/cron/ops_tests.rs@@ -641,8 +641,19 @@ fn required_delivery_failure_only_fails_non_best_effort_runs() {#[tokio::test]async fn run_job_now_records_required_delivery_failure_as_error() {- let tmp = TempDir::new().unwrap();- let config = test_config(&tmp);+ let _bridge_lock = crate::cron::channel_bridge::TEST_BRIDGE_LOCK.lock().await;+ let tmp = TempDir::new().unwrap();+ let mut config = test_config(&tmp);+ config.channels_config.telegram = Some(crate::config::TelegramConfig {+ bot_token: "test-token".into(),+ chat_id: None,+ allowed_users: vec!["target".into()],+ stream_mode: Default::default(),+ draft_update_interval_ms: 1000,+ silent_streaming: true,+ mention_only: false,+ });+ delivery_tests::install_failing_telegram_bridge();let _handler = crate::cron::system_job_handlers::register("ops-run-now-delivery-failure",std::sync::Arc::new(|_ctx| Box::pin(async { Ok(()) })),@@ -654,7 +665,7 @@ async fn run_job_now_records_required_delivery_failure_as_error() {CronJobPatch {delivery: Some(DeliveryConfig {mode: "announce".into(),- channel: Some(format!("missing-{}", uuid::Uuid::new_v4())),+ channel: Some("telegram".into()),to: Some("target".into()),best_effort: false,}),diff --git a/crates/openhuman-core/src/cron/tools/update.rs b/crates/openhuman-core/src/cron/tools/update.rsindex 82a6ceb18f..b2e67c1923 100644--- a/crates/openhuman-core/src/cron/tools/update.rs+++ b/crates/openhuman-core/src/cron/tools/update.rs@@ -118,8 +118,9 @@ impl Tool for CronUpdateTool {}}- let origin = crate::agent::tinyagents::host::run_context::turn_origin_for_tool(tool_context)- .and_then(|origin| crate::cron::origin::current_job_origin(Some(&origin)));+ let origin =+ crate::agent::tinyagents::host::run_context::turn_origin_for_tool(tool_context)+ .and_then(|origin| crate::cron::origin::current_job_origin(Some(&origin)));match cron::store::update_job_with_origin(&self.config, job_id, patch, origin) {Ok(job) => {let mut tr = ToolResult::success(serde_json::to_string_pretty(&job)?);diff --git a/crates/openhuman-core/src/cron/tools/update_tests.rs b/crates/openhuman-core/src/cron/tools/update_tests.rsindex 1c612a1980..b79ad37b22 100644--- a/crates/openhuman-core/src/cron/tools/update_tests.rs+++ b/crates/openhuman-core/src/cron/tools/update_tests.rs@@ -53,7 +53,10 @@ fn authorized_channel_config(tmp: &TempDir) -> Arc<Config> {Arc::new(config)}-fn channel_agent_job(config: &Config, origin: JobOrigin) -> tinyflows_bus::schedule::types::CronJob {+fn channel_agent_job(+ config: &Config,+ origin: JobOrigin,+) -> tinyflows_bus::schedule::types::CronJob {let mut spec = AgentJobSpec::new(Schedule::Every { every_ms: 300_000 }, "check inbox");spec.session_target = SessionTarget::Isolated;spec.delivery = Some(DeliveryConfig::default());@@ -238,7 +241,9 @@ async fn trusted_current_channel_can_update_delivery_to_its_own_target() {.unwrap();assert!(!result.is_error, "{}", result.output());- assert_eq!(cron::get_job(&cfg, &job.id).unwrap().delivery.mode, "origin");+ let saved = cron::get_job(&cfg, &job.id).unwrap();+ assert_eq!(saved.delivery.mode, "origin");+ assert_eq!(saved.origin, Some(channel_origin("42")));}#[tokio::test]@@ -271,3 +276,26 @@ async fn trusted_current_channel_cannot_authorize_spoofed_origin_update_target()assert_eq!(saved.origin, Some(original_origin));assert_eq!(saved.delivery.mode, "none");}++#[tokio::test]+async fn clearing_origin_and_selecting_origin_delivery_is_rejected_without_persisting() {+ let tmp = TempDir::new().unwrap();+ let cfg = authorized_channel_config(&tmp);+ let original_origin = channel_origin("42");+ let job = channel_agent_job(&cfg, original_origin.clone());+ let tool = CronUpdateTool::new(cfg.clone(), test_security(&cfg));++ let result = tool+ .execute(json!({+ "job_id": job.id,+ "patch": {"delivery":{"mode":"origin"}, "origin":null}+ }))+ .await+ .unwrap();++ assert!(result.is_error, "{}", result.output());+ assert!(result.output().contains("origin"), "{}", result.output());+ let saved = cron::get_job(&cfg, &job.id).unwrap();+ assert_eq!(saved.delivery.mode, "none");+ assert_eq!(saved.origin, Some(original_origin));+}