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): route draft operations through the catalog bus
Steven Enamakelc7b3411db282
diff --git a/crates/openhuman-core/src/flows/draft_store.rs b/crates/openhuman-core/src/flows/draft_store.rsindex e2a518b09f..7301a0f240 100644--- a/crates/openhuman-core/src/flows/draft_store.rs+++ b/crates/openhuman-core/src/flows/draft_store.rs@@ -1,18 +1,16 @@-//! This host's binding of the authoring-draft store to its workspace.-//!-//! Same shape and same reason as [`super::store`]: drafts are documents in the-//! flow catalog (`FlowCatalogDocuments`), in the acting scope of the storage-//! backend. Drafts the retired JSON store kept in-//! `<workspace_dir>/flows/drafts/<id>.json` are imported on first use.+//! Host clients for TinyFlows Catalog draft operations.-use super::store::{documents, run};-use crate::config::Config;use anyhow::Result;use serde_json::Value;-use tinyflows_catalog::{DraftOrigin, FlowDraft};+use tinyflows_bus::catalog::{+ self, CreateDraftRequest, DraftIdRequest, FlowDraft as WireDraft, UpdateDraftRequest,+};+use tinyflows_catalog::DraftOrigin;++use crate::config::Config;+use crate::flows::{catalog_storage, store};-/// The catalog `create_draft` for this call.-#[inline]+/// Create a module-owned editable workflow draft.pub fn create_draft(config: &Config,flow_id: Option<String>,@@ -20,20 +18,37 @@ pub fn create_draft(graph: Value,origin: DraftOrigin,) -> Result<FlowDraft> {- let docs = documents(config)?;- run(async move { docs.create_draft(flow_id, name, graph, origin).await })+ let storage = catalog_storage::register_blocking(config)?;+ let request = CreateDraftRequest {+ storage,+ flow_id,+ name,+ graph,+ origin: store::roundtrip(origin)?,+ };+ store::roundtrip(store::call_catalog::<WireDraft, _>(+ config,+ catalog::members::CREATE_DRAFT,+ (request,),+ )?)}-/// The catalog `get_draft` for this call.-#[inline]+/// Read one module-owned draft.pub fn get_draft(config: &Config, id: &str) -> Result<Option<FlowDraft>> {- let docs = documents(config)?;- let id = id.to_string();- run(async move { docs.get_draft(&id).await })+ let storage = catalog_storage::register_blocking(config)?;+ let request = DraftIdRequest {+ storage,+ id: id.to_owned(),+ };+ let draft: Option<WireDraft> = store::call_catalog(+ config,+ catalog::members::GET_DRAFT,+ (request,),+ )?;+ draft.map(store::roundtrip).transpose()}-/// The catalog `update_draft` for this call.-#[inline]+/// Patch a module-owned draft.pub fn update_draft(config: &Config,id: &str,@@ -41,22 +56,35 @@ pub fn update_draft(graph: Option<Value>,flow_id: Option<Option<String>>,) -> Result<FlowDraft> {- let docs = documents(config)?;- let id = id.to_string();- run(async move { docs.update_draft(&id, name, graph, flow_id).await })+ let storage = catalog_storage::register_blocking(config)?;+ let request = UpdateDraftRequest {+ storage,+ id: id.to_owned(),+ name,+ graph,+ flow_id,+ };+ let draft: WireDraft = store::call_catalog(config, catalog::members::UPDATE_DRAFT, (request,))?;+ store::roundtrip(draft)}-/// The catalog `list_drafts` for this call.-#[inline]+/// List module-owned drafts.pub fn list_drafts(config: &Config) -> Result<Vec<FlowDraft>> {- let docs = documents(config)?;- run(async move { docs.list_drafts().await })+ let storage = catalog_storage::register_blocking(config)?;+ let drafts: Vec<WireDraft> =+ store::call_catalog(config, catalog::members::LIST_DRAFTS, (storage,))?;+ drafts+ .into_iter()+ .map(store::roundtrip)+ .collect::<Result<Vec<_>>>()}-/// The catalog `delete_draft` for this call.-#[inline]+/// Delete one draft, returning whether a record was removed.pub fn delete_draft(config: &Config, id: &str) -> Result<bool> {- let docs = documents(config)?;- let id = id.to_string();- run(async move { docs.delete_draft(&id).await })+ let storage = catalog_storage::register_blocking(config)?;+ let request = DraftIdRequest {+ storage,+ id: id.to_owned(),+ };+ store::call_catalog(config, catalog::members::DELETE_DRAFT, (request,))}diff --git a/crates/openhuman-core/src/flows/store.rs b/crates/openhuman-core/src/flows/store.rsindex da80f2712d..a72131c012 100644--- a/crates/openhuman-core/src/flows/store.rs+++ b/crates/openhuman-core/src/flows/store.rs@@ -27,7 +27,7 @@ pub fn dir(config: &Config) -> PathBuf {config.workspace_dir.join("flows")}-fn call_catalog<T, A>(config: &Config, member: &'static str, args: A) -> Result<T>+pub(crate) fn call_catalog<T, A>(config: &Config, member: &'static str, args: A) -> Result<T>whereT: DeserializeOwned + Send + 'static,A: Serialize + Send + 'static,@@ -60,7 +60,7 @@ fn flow_from_wire(workflow: Workflow) -> Result<Flow> {}-fn roundtrip<T, U>(value: T) -> Result<U>+pub(crate) fn roundtrip<T, U>(value: T) -> Result<U>whereT: Serialize,U: DeserializeOwned,