Skip to content

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

feat(flows): add copilot bus adapters for draft and suggestion ops

Steven Enamakel4d5ab94e4677
diff --git a/crates/openhuman-core/src/flows/ops/discovery.rs b/crates/openhuman-core/src/flows/ops/discovery.rs
index ff243ece8c..efdc72392a 100644
--- a/crates/openhuman-core/src/flows/ops/discovery.rs
+++ b/crates/openhuman-core/src/flows/ops/discovery.rs
@@ -1,6 +1,16 @@
use super::*;
use crate::core::runtime::DispatchCtx;
+/// Persist suggestions received through the Copilot bus's portable wire shape.
+pub(crate) fn flows_suggestions_upsert_from_copilot(
+ config: &Config,
+ suggestions: Value,
+) -> Result<usize, String> {
+ let suggestions = serde_json::from_value(suggestions)
+ .map_err(|error| format!("invalid Copilot suggestions: {error}"))?;
+ store::upsert_suggestions(config, &suggestions).map_err(|error| error.to_string())
+}
+
// ─────────────────────────────────────────────────────────────────────────────
// Flow Scout — workflow discovery + suggestion lifecycle
// ─────────────────────────────────────────────────────────────────────────────
diff --git a/crates/openhuman-core/src/flows/ops/drafts.rs b/crates/openhuman-core/src/flows/ops/drafts.rs
index bcd567bc46..d70a87a0b3 100644
--- a/crates/openhuman-core/src/flows/ops/drafts.rs
+++ b/crates/openhuman-core/src/flows/ops/drafts.rs
@@ -17,6 +17,20 @@ pub fn flows_draft_create(
Ok(Outcome::single_log(draft, "draft created"))
}
+/// Create a draft from the Copilot bus's portable JSON payload.
+pub(crate) fn flows_draft_create_from_copilot(
+ config: &Config,
+ flow_id: Option<String>,
+ name: String,
+ graph: Value,
+ origin: Value,
+) -> Result<Value, String> {
+ let origin = serde_json::from_value(origin)
+ .map_err(|error| format!("bad `origin`: {error}"))?;
+ let draft = flows_draft_create(config, flow_id, name, graph, origin)?.value;
+ serde_json::to_value(draft).map_err(|error| error.to_string())
+}
+
/// Reads a draft by id (errors if it does not exist).
pub fn flows_draft_get(
config: &Config,