Skip to content

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

chore: tidy imports, module ordering, and formatting

Steven Enamakel02d415f7470e
diff --git a/crates/openhuman-core/src/cron/scheduler.rs b/crates/openhuman-core/src/cron/scheduler.rs
index 67464f58d2..a4014d169b 100644
--- a/crates/openhuman-core/src/cron/scheduler.rs
+++ b/crates/openhuman-core/src/cron/scheduler.rs
@@ -19,13 +19,13 @@
mod agent_run;
pub(crate) mod builtin;
mod delivery;
+mod dispatcher;
pub(crate) mod executor;
mod failure_classification;
-mod origin_context;
-mod origin_delivery;
-mod dispatcher;
mod live_agents;
mod manual_run;
+mod origin_context;
+mod origin_delivery;
pub(crate) mod run_delivery;
pub(crate) mod shell_job;
@@ -47,7 +47,6 @@ use shell_job::*;
pub use delivery::deliver_job;
use crate::config::Config;
-use manual_run::{LoopSlot, MIN_POLL_SECONDS};
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::cron::bus_host::{self, Binding, HostRegistration, CLAIM_SCOPE};
@@ -55,6 +54,7 @@ use crate::cron::documents_port::DocScope;
use crate::modules::tinyflows as module;
use crate::security::SecurityPolicy;
use anyhow::{anyhow, Result};
+use manual_run::{LoopSlot, MIN_POLL_SECONDS};
use serde_json::{json, Value};
use std::collections::{HashMap, HashSet};
use std::sync::atomic::{AtomicBool, Ordering};
@@ -103,7 +103,6 @@ pub async fn run(ctx: &crate::core::runtime::DispatchCtx, config: Config) -> Res
}
}
-
pub(crate) use dispatcher::{execute_job_now, tick_once, JobDispatcher};
pub use live_agents::run_live_agent_pass;
pub(crate) use live_agents::LiveAgentSchedulers;
diff --git a/crates/openhuman-core/src/cron/scheduler/live_agents.rs b/crates/openhuman-core/src/cron/scheduler/live_agents.rs
index d2d5d95686..be5f96815c 100644
--- a/crates/openhuman-core/src/cron/scheduler/live_agents.rs
+++ b/crates/openhuman-core/src/cron/scheduler/live_agents.rs
@@ -67,4 +67,3 @@ pub async fn run_live_agent_pass(max_concurrent: usize) {
agents.tick().await;
agents.drain().await;
}
-
diff --git a/crates/openhuman-core/src/cron/scheduler/manual_run.rs b/crates/openhuman-core/src/cron/scheduler/manual_run.rs
index 3ca7582e1e..2c1b032074 100644
--- a/crates/openhuman-core/src/cron/scheduler/manual_run.rs
+++ b/crates/openhuman-core/src/cron/scheduler/manual_run.rs
@@ -58,4 +58,3 @@ pub(crate) fn try_acquire_run(job_id: &str) -> Option<RunGuard> {
.insert(job_id.to_string())
.then(|| RunGuard(job_id.to_string()))
}
-
diff --git a/crates/openhuman-core/src/cron/schemas.rs b/crates/openhuman-core/src/cron/schemas.rs
index b8f4b72210..2a1b9abef5 100644
--- a/crates/openhuman-core/src/cron/schemas.rs
+++ b/crates/openhuman-core/src/cron/schemas.rs
@@ -1,9 +1,9 @@
use crate::core::all::{ControllerFuture, RegisteredController};
+use crate::core::runtime::DispatchCtx;
+use crate::core::Outcome;
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use serde::de::DeserializeOwned;
use serde_json::{Map, Value};
-use crate::core::runtime::DispatchCtx;
-use crate::core::Outcome;
use tinyflows_bus::schedule::types::{CronJobPatch, DeliveryConfig};
mod declarations;
diff --git a/crates/openhuman-core/src/cron/schemas/declarations.rs b/crates/openhuman-core/src/cron/schemas/declarations.rs
index 8a495c830d..24af14d96a 100644
--- a/crates/openhuman-core/src/cron/schemas/declarations.rs
+++ b/crates/openhuman-core/src/cron/schemas/declarations.rs
@@ -1,5 +1,5 @@
-use super::*;
use super::handlers::*;
+use super::*;
use crate::core::runtime::DispatchCtx;
use serde::de::DeserializeOwned;
@@ -283,4 +283,3 @@ pub fn schemas(function: &str) -> ControllerSchema {
},
}
}
-
diff --git a/crates/openhuman-core/src/cron/schemas/handlers.rs b/crates/openhuman-core/src/cron/schemas/handlers.rs
index 23dfb15071..049e5ac4b9 100644
--- a/crates/openhuman-core/src/cron/schemas/handlers.rs
+++ b/crates/openhuman-core/src/cron/schemas/handlers.rs
@@ -187,7 +187,10 @@ fn read_required<T: DeserializeOwned>(params: &Map<String, Value>, key: &str) ->
serde_json::from_value(value).map_err(|e| format!("invalid '{key}': {e}"))
}
-pub(super) fn read_optional_u64(params: &Map<String, Value>, key: &str) -> Result<Option<u64>, String> {
+pub(super) fn read_optional_u64(
+ params: &Map<String, Value>,
+ key: &str,
+) -> Result<Option<u64>, String> {
match params.get(key) {
None => Ok(None),
Some(Value::Null) => Ok(None),
diff --git a/crates/openhuman-core/src/flows/agent_route.rs b/crates/openhuman-core/src/flows/agent_route.rs
index e122f96d41..cdb39286e9 100644
--- a/crates/openhuman-core/src/flows/agent_route.rs
+++ b/crates/openhuman-core/src/flows/agent_route.rs
@@ -53,7 +53,6 @@ pub(crate) fn harness_model_default_override(node_model: &str) -> String {
format!("hint:{}", role_for_model_tier(node_model))
}
-
/// Decides how to run an `agent_ref` that has no harness definition, given
/// the (already-performed) config-backed custom registry lookup: an
/// [`AgentRoute::Harness`] for a known, *enabled* custom entry — the factory
@@ -72,4 +71,3 @@ pub(crate) fn route_custom_entry_lookup(
_ => AgentRoute::RegistryFallback,
}
}
-
diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rs
index 859856a48e..b85051b6c3 100644
--- a/crates/openhuman-core/src/flows/mod.rs
+++ b/crates/openhuman-core/src/flows/mod.rs
@@ -23,8 +23,8 @@
//! edge into this tree. If one ever gains a real `use` of `flows::`, this
//! family must convert to the facade+stub shape (see `voice/`).
-pub mod agents;
mod agent_route;
+pub mod agents;
pub mod builder_host;
pub(crate) mod builder_tools;
mod builder_tools_connection_reads;
diff --git a/crates/openhuman-core/src/flows/schemas.rs b/crates/openhuman-core/src/flows/schemas.rs
index 5d8a0a8eee..d2da11d975 100644
--- a/crates/openhuman-core/src/flows/schemas.rs
+++ b/crates/openhuman-core/src/flows/schemas.rs
@@ -350,9 +350,8 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
registered::all_registered_controllers()
}
-
-mod registered;
mod handlers;
+mod registered;
use handlers::*;
mod builder_schemas;
mod definition_schemas;
@@ -394,8 +393,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
}
}
-
-
#[cfg(test)]
#[path = "schemas_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
index a8835528e2..7489045859 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
@@ -18,7 +18,10 @@ pub(super) fn handle_build(ctx: DispatchCtx, params: Map<String, Value>) -> Cont
})
}
-pub(super) fn handle_build_cancel(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_build_cancel(
+ _ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let thread_id = read_required::<String>(&params, "thread_id")?;
let request_id = params
@@ -43,7 +46,9 @@ pub(super) fn handle_discover(ctx: DispatchCtx, params: Map<String, Value>) -> C
/// `flows.build` and `flows.discover` into an [`ops::FlowStreamTarget`].
/// Returns `None` (headless run) when no usable `thread_id` is present; a
/// missing `request_id` is filled with a fresh uuid inside `from_params`.
-pub(super) fn read_flow_stream_target(params: &Map<String, Value>) -> Option<ops::FlowStreamTarget> {
+pub(super) fn read_flow_stream_target(
+ params: &Map<String, Value>,
+) -> Option<ops::FlowStreamTarget> {
let thread_id = params
.get("thread_id")
.and_then(Value::as_str)
@@ -55,7 +60,10 @@ pub(super) fn read_flow_stream_target(params: &Map<String, Value>) -> Option<ops
ops::FlowStreamTarget::from_params(thread_id, request_id)
}
-pub(super) fn handle_list_suggestions(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_list_suggestions(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let status = params
@@ -68,7 +76,10 @@ pub(super) fn handle_list_suggestions(ctx: DispatchCtx, params: Map<String, Valu
})
}
-pub(super) fn handle_dismiss_suggestion(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_dismiss_suggestion(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -76,7 +87,10 @@ pub(super) fn handle_dismiss_suggestion(ctx: DispatchCtx, params: Map<String, Va
})
}
-pub(super) fn handle_mark_suggestion_built(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_mark_suggestion_built(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -84,7 +98,10 @@ pub(super) fn handle_mark_suggestion_built(ctx: DispatchCtx, params: Map<String,
})
}
-pub(super) fn handle_required_connections(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_required_connections(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let graph = read_required::<Value>(&params, "graph")?;
@@ -92,7 +109,10 @@ pub(super) fn handle_required_connections(ctx: DispatchCtx, params: Map<String,
})
}
-pub(super) fn handle_approval_manifest(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_approval_manifest(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = params
@@ -105,7 +125,10 @@ pub(super) fn handle_approval_manifest(ctx: DispatchCtx, params: Map<String, Val
})
}
-pub(super) fn handle_search_tool_catalog(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_search_tool_catalog(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let query = read_required::<String>(&params, "query")?;
@@ -122,7 +145,10 @@ pub(super) fn handle_search_tool_catalog(ctx: DispatchCtx, params: Map<String, V
})
}
-pub(super) fn handle_get_tool_contract(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_get_tool_contract(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let slug = read_required::<String>(&params, "slug")?;
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
index 58c81fbfb9..dbe08bb29f 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
@@ -68,7 +68,10 @@ pub(super) fn handle_list(ctx: DispatchCtx, _params: Map<String, Value>) -> Cont
})
}
-pub(super) fn handle_list_connections(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_list_connections(
+ ctx: DispatchCtx,
+ _params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
to_json(ops::flows_list_connections(&ctx, &config).await?)
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
index 26581def5e..b6e3c8834a 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
@@ -1,6 +1,9 @@
use super::super::*;
-pub(super) fn handle_draft_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_draft_create(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let name = read_required::<String>(&params, "name")?;
@@ -29,7 +32,10 @@ pub(super) fn handle_draft_get(ctx: DispatchCtx, params: Map<String, Value>) ->
})
}
-pub(super) fn handle_draft_update(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_draft_update(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -59,7 +65,10 @@ pub(super) fn handle_draft_list(ctx: DispatchCtx, _params: Map<String, Value>) -
})
}
-pub(super) fn handle_draft_delete(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_draft_delete(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -67,7 +76,10 @@ pub(super) fn handle_draft_delete(ctx: DispatchCtx, params: Map<String, Value>)
})
}
-pub(super) fn handle_draft_promote(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_draft_promote(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -119,5 +131,3 @@ pub(super) fn parse_draft_update_flow_id(
)),
}
}
-
-#[cfg(test)]
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs b/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
index 58dc933cf7..199abad436 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
@@ -1,7 +1,7 @@
-mod definition;
-mod run;
mod builder;
+mod definition;
mod draft;
+mod run;
pub(super) use builder::*;
pub(super) use definition::*;
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/run.rs b/crates/openhuman-core/src/flows/schemas/handlers/run.rs
index 8f6ca7a2a8..6b25d355d7 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/run.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/run.rs
@@ -20,7 +20,10 @@ pub(super) fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> Contro
})
}
-pub(super) fn handle_run_detached(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_run_detached(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
@@ -47,7 +50,9 @@ pub(super) fn handle_run_detached(ctx: DispatchCtx, params: Map<String, Value>)
/// inputs are all optional or defaulted. A present-but-non-object value is a
/// caller error rejected here, before it reaches `ops`, so the message names the
/// parameter rather than surfacing as a confusing per-input complaint.
-pub(super) fn read_declared_inputs(params: &Map<String, Value>) -> Result<Map<String, Value>, String> {
+pub(super) fn read_declared_inputs(
+ params: &Map<String, Value>,
+) -> Result<Map<String, Value>, String> {
match params.get("inputs") {
None | Some(Value::Null) => Ok(Map::new()),
Some(Value::Object(map)) => Ok(map.clone()),
@@ -120,7 +125,10 @@ pub(super) fn handle_list_runs(ctx: DispatchCtx, params: Map<String, Value>) ->
})
}
-pub(super) fn handle_list_all_runs(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_list_all_runs(
+ ctx: DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let config = ctx.load_config().await?;
let limit = params
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
index 1c68e2c5d5..8158fa2b87 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
@@ -17,8 +17,10 @@ use tinyflows::caps::*;
use tinyflows::error::{EngineError, Result};
use super::*;
-use crate::flows::agent_route::{harness_model_default_override, route_custom_entry_lookup, route_for_agent_ref, AgentRoute};
use crate::config::Config;
+use crate::flows::agent_route::{
+ harness_model_default_override, route_custom_entry_lookup, route_for_agent_ref, AgentRoute,
+};
/// [`AgentRunner`] backing an `agent` node's `agent_ref`. It runs the selected
/// agent kind by one of two paths, chosen by [`route_for_agent_ref`]:
@@ -118,7 +120,6 @@ fn max_parallel_harness_agents(raw: Option<&str>) -> usize {
.unwrap_or(DEFAULT_MAX_PARALLEL_HARNESS_AGENTS)
}
-
#[async_trait]
impl AgentRunner for OpenHumanAgentRunner {
async fn run_agent(
@@ -236,7 +237,6 @@ impl AgentRunner for OpenHumanAgentRunner {
}
}
-
impl OpenHumanAgentRunner {
/// Full harness turn: build a real session agent for `agent_ref` and drive
/// one `run_single` under the node's model override + timeout. See