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): update error handling across flow components
Steven Enamakelce8c6b235905
diff --git a/crates/openhuman-core/src/flows/caps_host/memory.rs b/crates/openhuman-core/src/flows/caps_host/memory.rsindex 3cd81b24cb..194da31b1c 100644--- a/crates/openhuman-core/src/flows/caps_host/memory.rs+++ b/crates/openhuman-core/src/flows/caps_host/memory.rs@@ -45,7 +45,7 @@ use crate::flows::{};use crate::memory::types::{FetchParams, RecallParams};use crate::security::approval::{- redact_args, summarize_action, ApprovalGate, ExecutionOutcome, GateOutcome,+ redact_args, summarize_action, GateOutcome,};use crate::security::SecurityPolicy;use tinybox_bus::CommandClass;@@ -53,7 +53,7 @@ use tinymemory_api::wrap_untrusted_for_agent;use tinymemory_api::Error;use tinymemory_api::{Hit, LearningKind, MemoryMeta, MetaFilter, SourceKind};-use super::caps::{enforce_current_node_tier_gate, gate_call_for_tier};+use super::{enforce_current_node_tier_gate, gate_call_for_tier, EngineError, Result};/// Stable `tracing` grep prefix for every log line this adapter emits. Never/// logs memory *content* or PII — only operation names, scopes, resolved@@ -206,8 +206,7 @@ fn capability_error(op: &str, error: &Error) -> EngineError {EngineError::Capability(format!("memory node: {op} failed: {error}"))}-#[async_trait]-impl MemoryProvider for OpenHumanMemory {+impl OpenHumanMemory {/// Backs both `recall` and `search`. `recall` returns the engine's/// synthesised `answer` plus its citations as `results`; `search` returns/// raw ranked hits as `results`. Each row is `{ id, key, text, score,diff --git a/crates/openhuman-core/src/flows/ops/updates.rs b/crates/openhuman-core/src/flows/ops/updates.rsindex 0460095d17..532d5334f7 100644--- a/crates/openhuman-core/src/flows/ops/updates.rs+++ b/crates/openhuman-core/src/flows/ops/updates.rs@@ -1,22 +1,23 @@use super::*;-/// Maps a store-level [`FlowUpdateError`](tinyflows_catalog::store::FlowUpdateError) to the RPC+/// Maps the Catalog bus [`FlowUpdateError`](tinyflows_bus::catalog::FlowUpdateError) to the RPC/// error string. A concurrency conflict is encoded as a JSON object the UI can/// parse (`{ code: "version_conflict", message, current }`) so it can offer a/// reload/diff instead of silently clobbering; other variants are plain text.-fn map_flow_update_error(e: tinyflows_catalog::store::FlowUpdateError) -> String {+fn map_flow_update_error(e: tinyflows_bus::catalog::FlowUpdateError) -> String {match e {- tinyflows_catalog::store::FlowUpdateError::NotFound => "flow not found".to_string(),- tinyflows_catalog::store::FlowUpdateError::Conflict(current) => {+ tinyflows_bus::catalog::FlowUpdateError::NotFound { .. } => {+ "flow not found".to_string()+ }+ tinyflows_bus::catalog::FlowUpdateError::VersionConflict { message, current } => {serde_json::to_string(&json!({"code": "version_conflict",- "message": "This flow changed since you loaded it. Reload to see the latest \- version, then reapply your change.",- "current": *current,+ "message": message,+ "current": current,})).unwrap_or_else(|_| "version_conflict".to_string())}- tinyflows_catalog::store::FlowUpdateError::Store(err) => err.to_string(),+ tinyflows_bus::catalog::FlowUpdateError::Store { message } => message,}}diff --git a/crates/openhuman-core/src/flows/store.rs b/crates/openhuman-core/src/flows/store.rsindex bcc532a5d3..50a764d7f3 100644--- a/crates/openhuman-core/src/flows/store.rs+++ b/crates/openhuman-core/src/flows/store.rs@@ -15,7 +15,7 @@ use tinyflows_bus::catalog::{SetEnabledRequest, Workflow, WorkflowRevision,};use tinyflows_catalog::{- Flow, FlowRevision, FlowSuggestion, SuggestionStatus, store::FlowUpdateError,+ Flow, FlowRevision, FlowSuggestion, SuggestionStatus,};use crate::config::Config;@@ -66,17 +66,6 @@ whereserde_json::from_value(serde_json::to_value(value)?).map_err(Into::into)}-fn update_error_from_wire(error: BusUpdateError) -> FlowUpdateError {- match error {- BusUpdateError::NotFound { .. } => FlowUpdateError::NotFound,- BusUpdateError::VersionConflict { current, .. } => match flow_from_wire(*current) {- Ok(current) => FlowUpdateError::Conflict(Box::new(current)),- Err(error) => FlowUpdateError::Store(error),- },- BusUpdateError::Store { message } => FlowUpdateError::Store(anyhow!(message)),- }-}-fn put_result(response: PutWorkflowResponse) -> Result<Flow> {match response {PutWorkflowResponse::Ok(result) => flow_from_wire(result.workflow),@@ -253,27 +242,35 @@ pub fn update_flow_graph(_enabled_override: Option<bool>,force_disarm_if_automatic: bool,expected_updated_at: Option<&str>,-) -> std::result::Result<Flow, FlowUpdateError> {+) -> std::result::Result<Flow, BusUpdateError> {let storage = super::catalog_storage::register_blocking(config)- .map_err(|error| FlowUpdateError::Store(error.into()))?;+ .map_err(|error| BusUpdateError::Store {+ message: error.to_string(),+ })?;let request = PutWorkflowRequest::Update {storage,id: id.to_owned(),name,graph: serde_json::to_value(graph)- .map_err(|error| FlowUpdateError::Store(anyhow!(error)))?,+ .map_err(|error| BusUpdateError::Store {+ message: error.to_string(),+ })?,require_approval,expected_version: expected_updated_at.map(str::to_owned),force_disarm_automatic: force_disarm_if_automatic,};let response: PutWorkflowResponse =call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))- .map_err(FlowUpdateError::Store)?;+ .map_err(|error| BusUpdateError::Store {+ message: error.to_string(),+ })?;match response {- PutWorkflowResponse::Ok(result) => {- flow_from_wire(result.workflow).map_err(FlowUpdateError::Store)- }- PutWorkflowResponse::Error(error) => Err(update_error_from_wire(error)),+ PutWorkflowResponse::Ok(result) => flow_from_wire(result.workflow).map_err(|error| {+ BusUpdateError::Store {+ message: error.to_string(),+ }+ }),+ PutWorkflowResponse::Error(error) => Err(error),}}