Skip to content

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

feat(flows): add builder host and schema handlers

Steven Enamakelca5fd7db334f
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rs
index 6c53940d71..9888576a02 100644
--- a/crates/openhuman-core/src/flows/builder_host.rs
+++ b/crates/openhuman-core/src/flows/builder_host.rs
@@ -35,6 +35,13 @@ impl FlowsHost {
pub fn new(config: Arc<Config>) -> Arc<Self> {
Arc::new(Self { config })
}
+
+ /// The context a port call runs under. The copilot ports carry none, so
+ /// this is the one place the host reads the calling task's ambient scope
+ /// (#7801) until the ports take a carrier.
+ fn ctx(&self) -> crate::core::runtime::DispatchCtx {
+ crate::core::runtime::DispatchCtx::ambient()
+ }
}
#[async_trait]
@@ -132,8 +139,7 @@ impl FlowStore for FlowsHost {
approve: Vec<String>,
reject: Vec<String>,
) -> PortResult<Value> {
- // Transitional (#7801): the builder host (`FlowsHost`) carries no context yet.
- let ctx = crate::core::runtime::DispatchCtx::ambient();
+ let ctx = self.ctx();
ops::flows_resume(&ctx, &self.config, flow_id, run_id, approve, reject)
.await
.map(|o| o.value)
@@ -153,11 +159,11 @@ impl BuilderGates for FlowsHost {
}
async fn run_gates(&self, graph: &WorkflowGraph) -> Vec<String> {
- ops::run_builder_gates(&self.config, graph).await
+ ops::run_builder_gates(&self.ctx(), &self.config, graph).await
}
async fn strict_gate(&self, graph: &Value) -> PortResult<()> {
- ops::strict_gate(&self.config, graph).await
+ ops::strict_gate(&self.ctx(), &self.config, graph).await
}
async fn engine_compatibility_errors(&self, graph: &WorkflowGraph) -> Vec<String> {
@@ -184,6 +190,7 @@ impl BuilderGates for FlowsHost {
flow_id: Option<String>,
) -> Result<Value, String> {
ops::build_builder_proposal(
+ &self.ctx(),
&self.config,
retry_tool,
name,
@@ -224,11 +231,8 @@ impl BuilderGates for FlowsHost {
#[async_trait]
impl AgentDirectory for FlowsHost {
async fn list(&self) -> PortResult<Vec<AgentDefinition>> {
- let agents = crate::agent::registry::list_agents(
- &crate::core::runtime::DispatchCtx::ambient(),
- false,
- )
- .await
+ let agents = crate::agent::registry::list_agents(&self.ctx(), false)
+ .await
.map_err(|e| e.to_string())?;
Ok(agents
.iter()
diff --git a/crates/openhuman-core/src/flows/schemas_handlers.rs b/crates/openhuman-core/src/flows/schemas_handlers.rs
index 8c238c2fd6..4ce35b47de 100644
--- a/crates/openhuman-core/src/flows/schemas_handlers.rs
+++ b/crates/openhuman-core/src/flows/schemas_handlers.rs
@@ -99,7 +99,7 @@ fn handle_update(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFutu
.unwrap_or(false)
{
if let Some(graph_json) = graph.as_ref() {
- ops::strict_gate(&config, graph_json).await?;
+ ops::strict_gate(&ctx, &config, graph_json).await?;
}
}
to_json(