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
refactor(flows): move shared schema handler helpers into handlers module
Steven Enamakel025caab71934
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rsindex c6835666ed..a4014d169b 100644--- a/crates/openhuman-core/src/cron/scheduler.rs+++ b/crates/openhuman-core/src/cron/scheduler.rs@@ -107,4 +107,4 @@ pub(crate) use dispatcher::{execute_job_now, 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::{try_acquire_run, RunGuard, ALREADY_RUNNING};+pub(crate) use manual_run::{scheduler_config, try_acquire_run, RunGuard, ALREADY_RUNNING};diff --git a/crates/openhuman-core/src/cron/scheduler/manual_run.rs b/crates/openhuman-core/src/cron/scheduler/manual_run.rsindex 2c1b032074..51858c9048 100644--- a/crates/openhuman-core/src/cron/scheduler/manual_run.rs+++ b/crates/openhuman-core/src/cron/scheduler/manual_run.rs@@ -58,3 +58,13 @@ pub(crate) fn try_acquire_run(job_id: &str) -> Option<RunGuard> {.insert(job_id.to_string()).then(|| RunGuard(job_id.to_string()))}++/// The module's retry settings from the operator's reliability config.+pub(crate) fn scheduler_config(config: &crate::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/flows/schemas.rs b/crates/openhuman-core/src/flows/schemas.rsindex d2da11d975..d5150920e1 100644--- a/crates/openhuman-core/src/flows/schemas.rs+++ b/crates/openhuman-core/src/flows/schemas.rs@@ -8,6 +8,7 @@use serde::de::DeserializeOwned;use serde_json::{Map, Value};+use crate::core::runtime::DispatchCtx;use crate::core::all::{ControllerFuture, RegisteredController};use crate::core::Outcome;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};diff --git a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs b/crates/openhuman-core/src/flows/schemas/handlers/builder.rsindex 7489045859..2902ce180f 100644--- a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs+++ b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs@@ -1,3 +1,5 @@+use crate::core::runtime::DispatchCtx;+use super::{read_required, to_json};use super::super::*;pub(super) fn handle_build(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {diff --git a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs b/crates/openhuman-core/src/flows/schemas/handlers/definition.rsindex dbe08bb29f..e23005507d 100644--- a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs+++ b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs@@ -1,3 +1,5 @@+use crate::core::runtime::DispatchCtx;+use super::{read_required, to_json};use super::super::*;pub(super) fn handle_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {diff --git a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs b/crates/openhuman-core/src/flows/schemas/handlers/draft.rsindex e04eea1acd..b679b4f47f 100644--- a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs+++ b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs@@ -1,3 +1,5 @@+use crate::core::runtime::DispatchCtx;+use super::{read_required, to_json};use super::super::*;pub(super) fn handle_draft_create(@@ -88,33 +90,6 @@ pub(super) fn handle_draft_promote(})}-pub(super) fn read_required<T: DeserializeOwned>(- params: &Map<String, Value>,- key: &str,-) -> Result<T, String> {- let value = params- .get(key)- .cloned()- .ok_or_else(|| format!("missing required param '{key}'"))?;- serde_json::from_value(value).map_err(|e| format!("invalid '{key}': {e}"))-}--fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {- outcome.into_cli_compatible_json()-}--/// Parses `draft_update`'s `flow_id` param (R-m7). The outer `Option`-/// mirrors `ops::flows_draft_update`'s "present vs absent" contract — absent-/// leaves the draft's existing link untouched; the inner `Option` is the new-/// link (`None` unlinks).-///-/// A present-but-non-string `flow_id` (a number, or an object from a buggy-/// client) is REJECTED rather than silently coerced into `Some(None)` via-/// `Value::as_str()` returning `None` on a type mismatch — that shape used-/// to be indistinguishable from an explicit `flow_id: null` unlink, and-/// `update_draft` treats `Some(None)` as exactly that: unlinking the draft-/// from its flow. A later `draft_promote` then creates a brand-new flow-/// instead of updating the one the caller actually meant.pub(super) fn parse_draft_update_flow_id(params: &Map<String, Value>,) -> Result<Option<Option<String>>, String> {diff --git a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs b/crates/openhuman-core/src/flows/schemas/handlers/mod.rsindex 199abad436..51a3e0b2fd 100644--- a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs+++ b/crates/openhuman-core/src/flows/schemas/handlers/mod.rs@@ -7,3 +7,36 @@ pub(super) use builder::*;pub(super) use definition::*;pub(super) use draft::*;pub(super) use run::*;++use crate::core::Outcome;+use serde::de::DeserializeOwned;+use serde_json::{Map, Value};++pub(super) fn read_required<T: DeserializeOwned>(+ params: &Map<String, Value>,+ key: &str,+) -> Result<T, String> {+ let value = params+ .get(key)+ .cloned()+ .ok_or_else(|| format!("missing required param '{key}'"))?;+ serde_json::from_value(value).map_err(|e| format!("invalid '{key}': {e}"))+}++fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {+ outcome.into_cli_compatible_json()+}++/// Parses `draft_update`'s `flow_id` param (R-m7). The outer `Option`+/// mirrors `ops::flows_draft_update`'s "present vs absent" contract — absent+/// leaves the draft's existing link untouched; the inner `Option` is the new+/// link (`None` unlinks).+///+/// A present-but-non-string `flow_id` (a number, or an object from a buggy+/// client) is REJECTED rather than silently coerced into `Some(None)` via+/// `Value::as_str()` returning `None` on a type mismatch — that shape used+/// to be indistinguishable from an explicit `flow_id: null` unlink, and+/// `update_draft` treats `Some(None)` as exactly that: unlinking the draft+/// from its flow. A later `draft_promote` then creates a brand-new flow+/// instead of updating the one the caller actually meant.+diff --git a/crates/openhuman-core/src/flows/schemas/handlers/run.rs b/crates/openhuman-core/src/flows/schemas/handlers/run.rsindex 6b25d355d7..9ac070e9bc 100644--- a/crates/openhuman-core/src/flows/schemas/handlers/run.rs+++ b/crates/openhuman-core/src/flows/schemas/handlers/run.rs@@ -1,3 +1,5 @@+use crate::core::runtime::DispatchCtx;+use super::{read_required, to_json};use super::super::*;pub(super) fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {