Skip to content

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

chore: files changed crates/openhuman-core/src/cron/job_builder.rs,crates/openhuman-core/src/cron/sc

Steven Enamakeld07e26999816
diff --git a/crates/openhuman-core/src/cron/job_builder.rs b/crates/openhuman-core/src/cron/job_builder.rs
index 4818e06011..bedad1f338 100644
--- a/crates/openhuman-core/src/cron/job_builder.rs
+++ b/crates/openhuman-core/src/cron/job_builder.rs
@@ -48,7 +48,7 @@ fn allowed_users_for_channel<'a>(config: &'a Config, channel: &str) -> Option<&'
/// Validate `delivery` at creation time: the module rules
/// (the module's `ValidateDelivery`) plus the channel's
/// configured `allowed_users`, which only the host knows.
-fn validate_delivery_for_config(
+pub(crate) fn validate_delivery_for_config(
config: &Config,
delivery: &DeliveryConfig,
origin: Option<&JobOrigin>,
diff --git a/crates/openhuman-core/src/cron/schemas.rs b/crates/openhuman-core/src/cron/schemas.rs
index 16908bc7a8..07d49cabe0 100644
--- a/crates/openhuman-core/src/cron/schemas.rs
+++ b/crates/openhuman-core/src/cron/schemas.rs
@@ -284,6 +284,9 @@ pub fn schemas(function: &str) -> ControllerSchema {
fn handle_add(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
+ if !config.cron.enabled {
+ return Err("cron is disabled by config (cron.enabled=false)".to_string());
+ }
crate::core::runtime::components::require_config(&config, "tinyflows")?;
let schedule: tinyflows_bus::schedule::types::Schedule =
@@ -380,6 +383,13 @@ fn handle_add(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture
),
};
let delivery_cfg = delivery.clone().unwrap_or_default();
+ // RPC `origin` is request data, not a verified turn context;
+ // it cannot exempt a target from the configured allowlist.
+ crate::cron::job_builder::validate_delivery_for_config(
+ &config,
+ &delivery_cfg,
+ None,
+ )?;
crate::cron::client::check_origin_requirements(
&config,
&session_target,
diff --git a/crates/openhuman-core/src/cron/store.rs b/crates/openhuman-core/src/cron/store.rs
index 5bbdabec48..4bd154850b 100644
--- a/crates/openhuman-core/src/cron/store.rs
+++ b/crates/openhuman-core/src/cron/store.rs
@@ -194,7 +194,33 @@ pub fn due_jobs(config: &Config, now: DateTime<Utc>) -> Result<Vec<CronJob>> {
}
pub fn update_job(config: &Config, job_id: &str, patch: CronJobPatch) -> Result<CronJob> {
+ update_job_with_origin(config, job_id, patch, None)
+}
+
+/// Update a job, using only a host-verified conversation origin for delivery
+/// validation. Raw origins stored on jobs or supplied by RPC are not trusted.
+pub(crate) fn update_job_with_origin(
+ config: &Config,
+ job_id: &str,
+ patch: CronJobPatch,
+ trusted_origin: Option<tinyflows_bus::schedule::types::JobOrigin>,
+) -> Result<CronJob> {
limits::check_patch(config, &patch)?;
+ if patch.delivery.is_some() || patch.origin.is_some() {
+ let existing = get_job(config, job_id)?;
+ let delivery = patch
+ .delivery
+ .clone()
+ .unwrap_or_else(|| existing.delivery.clone());
+ // Validation only needs a verified current-turn origin. A persisted
+ // or request-provided origin may have come from an untrusted RPC.
+ crate::cron::job_builder::validate_delivery_for_config(
+ config,
+ &delivery,
+ trusted_origin.as_ref(),
+ )
+ .map_err(anyhow::Error::msg)?;
+ }
store_blocking(
config,
StoreOperation::Update {
diff --git a/crates/openhuman-core/src/cron/tools/update.rs b/crates/openhuman-core/src/cron/tools/update.rs
index b863328de6..82a6ceb18f 100644
--- a/crates/openhuman-core/src/cron/tools/update.rs
+++ b/crates/openhuman-core/src/cron/tools/update.rs
@@ -69,6 +69,15 @@ impl Tool for CronUpdateTool {
&self,
args: serde_json::Value,
options: ToolCallOptions,
+ ) -> anyhow::Result<ToolResult> {
+ self.execute_with_context(args, options, None).await
+ }
+
+ async fn execute_with_context(
+ &self,
+ args: serde_json::Value,
+ options: ToolCallOptions,
+ tool_context: Option<&dyn tinytools::ToolRunContext>,
) -> anyhow::Result<ToolResult> {
if !self.config.cron.enabled {
return Ok(ToolResult::error(
@@ -109,7 +118,9 @@ impl Tool for CronUpdateTool {
}
}
- match cron::update_job(&self.config, job_id, patch) {
+ 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)?);
if options.prefer_markdown {