Skip to content

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

feat(flows): load node contracts through the tinyflows proxy

Steven Enamakel99eca38450cc
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rs
index c2621c3712..93c529cd5e 100644
--- a/crates/openhuman-core/src/flows/builder_host.rs
+++ b/crates/openhuman-core/src/flows/builder_host.rs
@@ -178,7 +178,7 @@ impl FlowsHost {
&config, payload
)?)
}
- PortOperation::GatesValidate => wire!(ops::flows_validate(payload).value),
+ PortOperation::GatesValidate => wire!(ops::flows_validate(&context, &config, payload).await.value),
PortOperation::GatesRun => {
wire!(ops::run_builder_gates_json(&context, &config, payload).await?)
}
@@ -187,7 +187,7 @@ impl FlowsHost {
json!(true)
}
PortOperation::GatesEngineCompatibility => {
- wire!(ops::engine_compatibility_errors_json(&config, payload)?)
+ wire!(ops::engine_compatibility_errors_json(&context, &config, payload).await?)
}
PortOperation::GatesWiringWarnings => {
wire!(ops::wiring_warnings_json(&config, payload).await?)
diff --git a/crates/openhuman-core/src/flows/node_contracts.rs b/crates/openhuman-core/src/flows/node_contracts.rs
index 653529e0c6..4bc4d3531f 100644
--- a/crates/openhuman-core/src/flows/node_contracts.rs
+++ b/crates/openhuman-core/src/flows/node_contracts.rs
@@ -14,7 +14,7 @@
//! `propose_workflow` description all read the *overlaid* view via
//! [`all_node_kind_contracts`] / [`node_kind_contract`].
-use tinyflows::catalog::NodeKindContract;
+use tinyflows_bus::node_kinds::NodeKindContract;
/// Appends this host's vendor-specific caveats to a portable tinyflows
/// contract. One arm per kind that has host-owned facts; the rest pass through
@@ -155,17 +155,22 @@ fn apply_host_overlay(contract: NodeKindContract) -> NodeKindContract {
/// Every node-kind contract with this host's overlay applied, in
/// [`tinyflows::catalog::NODE_KINDS`] order.
-pub fn all_node_kind_contracts() -> Vec<NodeKindContract> {
- tinyflows::catalog::all_contracts()
- .into_iter()
- .map(apply_host_overlay)
- .collect()
+pub async fn all_node_kind_contracts(config: &crate::config::Config) -> Result<Vec<NodeKindContract>, String> {
+ let proxy = crate::modules::tinyflows::catalog_proxy(config).await?;
+ let contracts: Vec<NodeKindContract> = proxy
+ .call(tinyflows_bus::catalog::members::NODE_KINDS, ())
+ .await
+ .map_err(|error| error.wire_message())?;
+ Ok(contracts.into_iter().map(apply_host_overlay).collect())
}
/// The overlaid contract for one node kind, or `None` when `kind` is not one
/// of [`tinyflows::catalog::NODE_KINDS`].
-pub fn node_kind_contract(kind: &str) -> Option<NodeKindContract> {
- tinyflows::catalog::contract_for(kind).map(apply_host_overlay)
+pub async fn node_kind_contract(config: &crate::config::Config, kind: &str) -> Result<Option<NodeKindContract>, String> {
+ Ok(all_node_kind_contracts(config)
+ .await?
+ .into_iter()
+ .find(|contract| contract.kind == kind))
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
index f1cbe9dfbd..22c0aac43d 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
@@ -29,13 +29,13 @@ pub(in crate::flows::schemas) fn handle_create(
}
pub(in crate::flows::schemas) fn handle_validate(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- // No config load: validation is pure (no persistence, no workspace).
+ let config = ctx.load_config().await?;
let graph = read_required::<Value>(&params, "graph")?;
- to_json(ops::flows_validate(graph))
+ to_json(ops::flows_validate(&ctx, &config, graph).await)
})
}
@@ -44,7 +44,6 @@ pub(in crate::flows::schemas) fn handle_import(
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
- // No config load: import is pure (no persistence, no workspace).
let graph = read_required::<Value>(&params, "graph")?;
let format = params
.get("format")
@@ -52,7 +51,7 @@ pub(in crate::flows::schemas) fn handle_import(
.map(|v| serde_json::from_value::<String>(v.clone()))
.transpose()
.map_err(|e| format!("invalid 'format': {e}"))?;
- to_json(ops::flows_import(graph, format)?)
+ to_json(ops::flows_import(graph, format).await?)
})
}