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/flows/ops/definitions.rs,crates/openhuman-core/src/fl

Steven Enamakel1d6f2f126ec7
diff --git a/crates/openhuman-core/src/flows/ops/definitions.rs b/crates/openhuman-core/src/flows/ops/definitions.rs
index 8546772df0..9c8d61dd29 100644
--- a/crates/openhuman-core/src/flows/ops/definitions.rs
+++ b/crates/openhuman-core/src/flows/ops/definitions.rs
@@ -1,5 +1,4 @@
use super::*;
-use tinyflows_catalog::graph_policy::{enforce_side_effect_approval, trigger_is_automatic};
/// Publishes a [`DomainEvent::FlowChanged`](crate::core::events::DomainEvent::FlowChanged)
/// so an open Workflows list/canvas refetches (bridged to a `flow:changed`
@@ -81,31 +80,16 @@ pub(crate) async fn flows_create_with_context(
// Rule 1: automatic triggers create DISABLED — the user must arm them
// explicitly.
- let enabled = !trigger_is_automatic(&graph);
-
- // Rule 2: any outbound side-effect node forces require_approval, no
- // matter what the caller asked for.
- let (effective_require_approval, side_effect_forced) =
- enforce_side_effect_approval(&graph, require_approval);
- if side_effect_forced {
- tracing::info!(
- target: "flows",
- %name,
- "[flows] flows_create: forcing require_approval=true — graph contains outbound \
- side-effect node(s) (tool_call / http_request / code)"
- );
- }
-
tracing::debug!(
target: "flows",
%name,
- node_count = graph.nodes.len(),
- enabled,
- require_approval = effective_require_approval,
+ node_count = graph.get("nodes").and_then(Value::as_array).map_or(0, Vec::len),
+ require_approval,
"[flows] flows_create: persisting new flow"
);
- let flow = store::create_flow(config, name, graph, effective_require_approval, enabled)
+ let result = store::create_flow(config, name, graph, require_approval)
.map_err(|e| e.to_string())?;
+ let flow = result.workflow;
if flow.enabled {
tracing::debug!(target: "flows", flow_id = %flow.id, "[flows] flows_create: flow is enabled — binding automatic-dispatch trigger");
@@ -113,7 +97,7 @@ pub(crate) async fn flows_create_with_context(
}
let mut logs = vec!["flow created".to_string()];
- if !enabled {
+ if result.born_disabled {
let trigger_label = match bus::describe_trigger(config, &flow) {
Ok(details) => details
.kind
@@ -128,7 +112,7 @@ pub(crate) async fn flows_create_with_context(
Enable it explicitly (flows_set_enabled) when you are ready for it to fire."
));
}
- if side_effect_forced {
+ if result.approval_forced {
logs.push(
"require_approval forced to true because the graph contains outbound side-effect \
nodes (tool_call / http_request / code)."
@@ -182,7 +166,7 @@ pub async fn flows_get(config: &Config, id: &str) -> Result<Outcome<Flow>, Strin
/// Returns `Ok(None)` when no flow with that id exists (the resolver turns that
/// into a capability error naming the missing id), and `Err` only on a store
/// failure. Kept sync because the underlying [`store::get_flow`] is sync.
-pub fn load_flow_graph(config: &Config, id: &str) -> Result<Option<WorkflowGraph>, String> {
+pub fn load_flow_graph(config: &Config, id: &str) -> Result<Option<Value>, String> {
tracing::debug!(target: "flows", flow_id = %id, "[flows] load_flow_graph: loading saved flow graph for sub_workflow resolver");
let graph = store::get_flow(config, id)
.map_err(|e| e.to_string())?
@@ -203,7 +187,7 @@ pub(crate) async fn load_engine_compatible_flow_graph(
ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
id: &str,
-) -> Result<Option<WorkflowGraph>, String> {
+ ) -> Result<Option<Value>, String> {
let graph = load_flow_graph(config, id)?;
if let Some(graph) = graph.as_ref() {
ensure_config_aware_engine_compatible(ctx, config, graph)
diff --git a/crates/openhuman-core/src/flows/ops/validation.rs b/crates/openhuman-core/src/flows/ops/validation.rs
index a3149514a1..b8bf709563 100644
--- a/crates/openhuman-core/src/flows/ops/validation.rs
+++ b/crates/openhuman-core/src/flows/ops/validation.rs
@@ -58,7 +58,7 @@ pub(crate) async fn validate_and_migrate_graph(
ctx: &DispatchCtx,
config: &Config,
graph: Value,
-) -> Result<WorkflowGraph, String> {
+) -> Result<Value, String> {
let report = validate_over_bus(ctx, config, graph).await?;
if let Some(error) = report
.errors
@@ -70,7 +70,6 @@ pub(crate) async fn validate_and_migrate_graph(
report
.graph
.ok_or_else(|| "TinyFlows validation returned no graph".to_string())
- .and_then(|graph| serde_json::from_value(graph).map_err(|error| error.to_string()))
}
/// Host-aware compatibility errors for graphs that can reference saved flows.
@@ -91,9 +90,8 @@ pub(crate) async fn config_aware_engine_compatibility_errors(
pub(super) async fn ensure_config_aware_engine_compatible(
ctx: &DispatchCtx,
config: &Config,
- graph: &WorkflowGraph,
+ graph: &Value,
) -> Result<(), String> {
- let graph = serde_json::to_value(graph).map_err(|error| error.to_string())?;
match config_aware_engine_compatibility_errors(ctx, config, graph)
.await?
.into_iter()
@@ -110,8 +108,8 @@ pub async fn flows_validate(
ctx: &DispatchCtx,
config: &Config,
graph_json: Value,
-) -> Outcome<tinyflows_catalog::FlowValidation> {
- use tinyflows_catalog::{FlowValidation, FlowValidationError};
+) -> Outcome<tinyflows_bus::copilot::FlowValidation> {
+ use tinyflows_bus::copilot::{FlowValidation, FlowValidationError};
let report = match validate_over_bus(ctx, config, graph_json).await {
Ok(report) => report,
Err(error) => {
@@ -153,13 +151,8 @@ pub async fn flows_validate(
"flow validation failed",
);
}
- let _graph: WorkflowGraph = match report
- .graph
- .ok_or_else(|| "TinyFlows validation returned no graph".to_string())
- .and_then(|graph| serde_json::from_value(graph).map_err(|error| error.to_string()))
- {
- Ok(graph) => graph,
- Err(error) => {
+ if report.graph.is_none() {
+ let error = "TinyFlows validation returned no graph".to_string();
return Outcome::single_log(
FlowValidation {
valid: false,
@@ -174,8 +167,7 @@ pub async fn flows_validate(
},
"flow validation failed",
);
- }
- };
+ }
let warnings = report.warnings;
Outcome::single_log(
FlowValidation {
@@ -195,8 +187,7 @@ pub async fn flows_import(
config: &Config,
graph_json: Value,
format: Option<String>,
-) -> Result<Outcome<tinyflows_catalog::FlowImport>, String> {
- use tinyflows_catalog::FlowImport;
+) -> Result<Outcome<FlowImport>, String> {
let requested = format
.as_deref()
.unwrap_or("auto")
@@ -224,10 +215,9 @@ pub async fn flows_import(
if let Some(error) = imported.errors.first() {
return Err(error.message.clone());
}
- let graph: WorkflowGraph = imported
+ let graph: Value = imported
.graph
- .ok_or_else(|| "TinyFlows import returned no graph".to_string())
- .and_then(|graph| serde_json::from_value(graph).map_err(|error| error.to_string()))?;
+ .ok_or_else(|| "TinyFlows import returned no graph".to_string())?;
let warnings = imported.warnings;
Ok(Outcome::single_log(
FlowImport { graph, warnings },
@@ -235,6 +225,13 @@ pub async fn flows_import(
))
}
+/// OpenHuman RPC projection of the module's imported graph and warnings.
+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq)]
+pub struct FlowImport {
+ pub graph: Value,
+ pub warnings: Vec<String>,
+}
+
/// Compatibility diagnostics for a portable Copilot graph payload.
pub(crate) async fn engine_compatibility_errors_json(
ctx: &DispatchCtx,
diff --git a/crates/openhuman-core/src/flows/store.rs b/crates/openhuman-core/src/flows/store.rs
index 41b7145404..02235743bd 100644
--- a/crates/openhuman-core/src/flows/store.rs
+++ b/crates/openhuman-core/src/flows/store.rs
@@ -10,6 +10,7 @@ use serde::{de::DeserializeOwned, Serialize};
use tinyflows_bus::catalog::{
self, DeleteWorkflowResult, FlowUpdateError as BusUpdateError, GetRevisionRequest,
ListRevisionsRequest, ListWorkflowsResult, PutWorkflowRequest, PutWorkflowResponse,
+ PutWorkflowResult,
SetEnabledRequest, Workflow, WorkflowRevision,
};
use tinyflows_bus::catalog::{
@@ -48,9 +49,9 @@ where
serde_json::from_value(serde_json::to_value(value)?).map_err(Into::into)
}
-fn put_result(response: PutWorkflowResponse) -> Result<Flow> {
+fn put_result(response: PutWorkflowResponse) -> Result<PutWorkflowResult> {
match response {
- PutWorkflowResponse::Ok(result) => flow_from_wire(result.workflow),
+ PutWorkflowResponse::Ok(result) => Ok(result),
PutWorkflowResponse::Error(error) => Err(anyhow!(match error {
BusUpdateError::NotFound { message }
| BusUpdateError::VersionConflict { message, .. }
@@ -69,7 +70,7 @@ pub fn insert_duplicate_flow(config: &Config, source: &Flow, new_name: String) -
};
let response: PutWorkflowResponse =
call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
- put_result(response)
+ put_result(response).map(|result| result.workflow)
}
/// Create a workflow through the module's Catalog contract.
@@ -78,8 +79,7 @@ pub fn create_flow(
name: String,
graph: Value,
require_approval: bool,
- enabled: bool,
-) -> Result<Flow> {
+) -> Result<PutWorkflowResult> {
let storage = super::catalog_storage::register_blocking(config)?;
let request = PutWorkflowRequest::Create {
storage,
@@ -89,12 +89,7 @@ pub fn create_flow(
};
let response: PutWorkflowResponse =
call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
- let flow = put_result(response)?;
- if !enabled && flow.enabled {
- set_enabled(config, &flow.id, false)
- } else {
- Ok(flow)
- }
+ put_result(response)
}
/// Read one workflow by id.
@@ -176,7 +171,7 @@ pub fn update_flow_graph(
_enabled_override: Option<bool>,
force_disarm_if_automatic: bool,
expected_updated_at: Option<&str>,
-) -> std::result::Result<Flow, BusUpdateError> {
+) -> std::result::Result<PutWorkflowResult, BusUpdateError> {
let storage = super::catalog_storage::register_blocking(config).map_err(|error| {
BusUpdateError::Store {
message: error.to_string(),
@@ -198,7 +193,7 @@ pub fn update_flow_graph(
}
})?;
match response {
- PutWorkflowResponse::Ok(result) => Ok(result.workflow),
+ PutWorkflowResponse::Ok(result) => Ok(result),
PutWorkflowResponse::Error(error) => Err(error),
}
}