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): serve copilot tool ports over tinybus
Steven Enamakela763275262c5
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rsindex 8082c2d451..372bf5e687 100644--- a/crates/openhuman-core/src/flows/builder_host.rs+++ b/crates/openhuman-core/src/flows/builder_host.rs@@ -1,270 +1,342 @@-//! The host half of the workflow-builder tool belt.-//!-//! The tools themselves (`edit_workflow`, `dry_run_workflow`, `save_workflow`,-//! ...) live in `tinyflows_copilot::tools` and run over ports. [`FlowsHost`] is-//! the one implementation of those ports for this process: it binds them to the-//! workspace's draft and flow stores, the config-aware gate stack, the agent-//! registry and the suggestion table, and adds no behaviour of its own.-//! [`OverlayNodeKinds`] is the node-kind catalog with this host's caveats-//! appended.+//! Scope-bound host callbacks for TinyFlows Copilot over TinyBus.+use std::future::Future;use std::sync::Arc;-use async_trait::async_trait;-use serde_json::Value;-use tinyflows::caps::Capabilities;-use tinyflows::catalog::NodeKindContract;-use tinyflows::model::WorkflowGraph;-use tinyflows_catalog::types::FlowSuggestion;-use tinyflows_catalog::{DraftOrigin, Flow, FlowDraft, FlowRevision, FlowRun, FlowValidation};-use tinyflows_copilot::tools::ports::{- AgentDefinition, AgentDirectory, BuilderGates, DraftStore, FlowStore, NodeKindSource,- PortResult, SuggestionStore, Written,-};+use serde::de::DeserializeOwned;+use serde::Serialize;+use serde_json::{Value, json};+use tinybus::Result as BusResult;+use tinyflows_bus::copilot::{self, CopilotHost, PortOperation};use crate::config::Config;-use crate::flows::{ops, store};+use crate::core::runtime::{CoreContext, DispatchCtx};+use crate::modules::tinyflows as module;-/// The workspace-bound implementation of every copilot tool port.-pub struct FlowsHost {+#[derive(Clone)]+struct FlowsHost {config: Arc<Config>,+ context: DispatchCtx,+ runtime: Option<tokio::runtime::Handle>,}impl FlowsHost {- /// Binds the ports to `config`'s workspace.- pub fn new(config: Arc<Config>) -> Arc<Self> {- Arc::new(Self { config })- }-- /// The context a port call runs under. The copilot ports carry none, so- /// this is the one place the host reads the calling task's ambient scope- /// (#7801) until the ports take a carrier.- fn ctx(&self) -> crate::core::runtime::DispatchCtx {- crate::core::runtime::DispatchCtx::ambient()+ async fn in_context<T, F>(&self, work: F) -> Result<T, String>+ where+ T: Send + 'static,+ F: Future<Output = Result<T, String>> + Send + 'static,+ {+ let context = self.context.clone();+ let work = async move {+ if let Some(core) = context.core().cloned() {+ CoreContext::scope(core, work).await+ } else {+ work.await+ }+ };+ match &self.runtime {+ Some(runtime) => runtime+ .spawn(work)+ .await+ .map_err(|error| format!("the Copilot host callback did not finish: {error}"))?,+ None => work.await,+ }}-}-#[async_trait]-impl DraftStore for FlowsHost {- async fn get(&self, id: &str) -> PortResult<FlowDraft> {- ops::flows_draft_get(&self.config, id).map(|o| o.value)+ async fn dispatch_call_port(&self, request: copilot::PortCallRequest) -> Result<Value, String> {+ let config = Arc::clone(&self.config);+ let context = self.context.clone();+ self.in_context(async move {+ let payload = request.payload;+ let value = match request.operation {+ PortOperation::DraftGet => {+ ops::flows_draft_get(&config, &required::<String>(&payload, "id")?)?.value+ }+ PortOperation::DraftCreate => {+ let origin = decode::<tinyflows_catalog::DraftOrigin>(field(&payload, "origin")?)?;+ ops::flows_draft_create(+ &config,+ optional_field(&payload, "flow_id")?,+ required(&payload, "name")?,+ required(&payload, "graph")?,+ origin,+ )?+ .value+ }+ PortOperation::DraftUpdate => {+ ops::flows_draft_update(+ &config,+ &required::<String>(&payload, "id")?,+ optional_field(&payload, "name")?,+ optional_field(&payload, "graph")?,+ None,+ )?+ .value+ }+ PortOperation::FlowsGet => {+ ops::flows_get(&config, &required::<String>(&payload, "id")?)+ .await?+ .value+ }+ PortOperation::FlowsList => ops::flows_list(&config).await?.value,+ PortOperation::FlowsLoadGraph => {+ ops::load_flow_graph(&config, &required::<String>(&payload, "id")?)?+ }+ PortOperation::FlowsCreate => {+ ops::flows_create(+ &config,+ required(&payload, "name")?,+ required(&payload, "graph")?,+ optional_field::<bool>(&payload, "require_approval")?.unwrap_or(true),+ )+ .await?+ .value+ }+ PortOperation::FlowsUpdate => {+ let outcome = ops::flows_update(+ &config,+ &required::<String>(&payload, "id")?,+ optional_field(&payload, "name")?,+ optional_field(&payload, "graph")?,+ None,+ None,+ )+ .await?;+ json!({"value": outcome.value, "logs": outcome.logs})+ }+ PortOperation::FlowsSetEnabled => {+ ops::flows_set_enabled(+ &config,+ &required::<String>(&payload, "id")?,+ required(&payload, "enabled")?,+ )+ .await?+ .value+ }+ PortOperation::FlowsDuplicate => {+ ops::flows_duplicate(&config, &required::<String>(&payload, "id")?)+ .await?+ .value+ }+ PortOperation::FlowsHistory => ops::flows_get_history(+ &config,+ &required::<String>(&payload, "id")?,+ optional_field::<usize>(&payload, "limit")?.unwrap_or(20),+ )?+ .value,+ PortOperation::FlowsListRuns => ops::flows_list_runs(+ &config,+ &required::<String>(&payload, "flow_id")?,+ optional_field::<usize>(&payload, "limit")?.unwrap_or(20),+ )+ .await?+ .value,+ PortOperation::FlowsGetRun => {+ ops::flows_get_run(&config, &required::<String>(&payload, "run_id")?)+ .await?+ .value+ }+ PortOperation::FlowsResume => {+ ops::flows_resume(+ &context,+ &config,+ &required::<String>(&payload, "flow_id")?,+ &required::<String>(&payload, "run_id")?,+ optional_field(&payload, "approve")?.unwrap_or_default(),+ optional_field(&payload, "reject")?.unwrap_or_default(),+ )+ .await?+ .value+ }+ PortOperation::FlowsCancelRun => {+ ops::flows_cancel_run(&config, &required::<String>(&payload, "run_id")?)+ .await?+ .value+ }+ PortOperation::AgentsList => {+ let agents = crate::agent::registry::list_agents(&context, false)+ .await+ .map_err(|error| error.to_string())?;+ agents+ .iter()+ .map(|agent| {+ json!({+ "id": agent.id,+ "name": agent.name,+ "description": agent.description,+ "model": serde_json::to_value(&agent.model).unwrap_or(Value::Null),+ "tools": serde_json::to_value(&agent.tool_allowlist).unwrap_or(Value::Null),+ "tags": serde_json::to_value(&agent.tags).unwrap_or(Value::Null),+ })+ })+ .collect::<Vec<_>>()+ }+ PortOperation::SuggestionsUpsert => {+ let suggestions = decode::<Vec<tinyflows_catalog::FlowSuggestion>>(+ payload.clone(),+ )?;+ crate::flows::store::upsert_suggestions(&config, &suggestions)+ .map_err(|error| error.to_string())?+ }+ PortOperation::GatesValidate => ops::flows_validate(payload).value,+ PortOperation::GatesRun => {+ ops::run_builder_gates_json(&context, &config, payload).await?+ }+ PortOperation::GatesStrict => {+ ops::strict_gate(&context, &config, &payload).await?;+ true+ }+ PortOperation::GatesEngineCompatibility => {+ ops::engine_compatibility_errors_json(&config, payload)?+ }+ PortOperation::GatesWiringWarnings => {+ ops::wiring_warnings_json(&config, payload).await?+ }+ PortOperation::GatesApprovalManifest => {+ ops::approval_manifest_json(&config, payload).await?+ }+ };+ encode(value)+ })+ .await}- async fn create(+ async fn dispatch_build_proposal(&self,- flow_id: Option<String>,- name: String,- graph: Value,- origin: DraftOrigin,- ) -> PortResult<FlowDraft> {- ops::flows_draft_create(&self.config, flow_id, name, graph, origin).map(|o| o.value)+ request: copilot::BuildProposalRequest,+ ) -> Result<Value, String> {+ let config = Arc::clone(&self.config);+ let context = self.context.clone();+ self.in_context(async move {+ ops::build_builder_proposal_json(+ &context,+ &config,+ request.retry_tool,+ request.name,+ request.graph,+ request.require_approval,+ request.revision,+ request.instruction,+ request.draft_id,+ request.flow_id,+ )+ .await+ })+ .await}- async fn update(- &self,- id: &str,- name: Option<String>,- graph: Option<Value>,- ) -> PortResult<FlowDraft> {- ops::flows_draft_update(&self.config, id, name, graph, None).map(|o| o.value)+ async fn dispatch_run_flow(&self, request: copilot::RunFlowRequest) -> Result<Value, String> {+ let config = Arc::clone(&self.config);+ let context = self.context.clone();+ self.in_context(async move {+ ops::flows_run_copilot(+ &context,+ &config,+ &request.flow_id,+ request.input,+ request.inputs,+ )+ .await+ .map(|outcome| outcome.value)+ })+ .await}}-#[async_trait]-impl FlowStore for FlowsHost {- async fn get(&self, id: &str) -> PortResult<Flow> {- ops::flows_get(&self.config, id).await.map(|o| o.value)- }-- async fn list(&self) -> PortResult<Vec<Flow>> {- ops::flows_list(&self.config).await.map(|o| o.value)- }-- async fn load_graph(&self, id: &str) -> PortResult<Option<WorkflowGraph>> {- ops::load_flow_graph(&self.config, id)- }-- async fn create(&self, name: String, graph: Value, require_approval: bool) -> PortResult<Flow> {- ops::flows_create(&self.config, name, graph, require_approval)- .await- .map(|o| o.value)- }+fn required<T: DeserializeOwned>(value: &Value, key: &str) -> Result<T, String> {+ field(value, key)?.ok_or_else(|| format!("missing `{key}`"))+}- async fn update(- &self,- id: &str,- name: Option<String>,- graph: Option<Value>,- ) -> PortResult<Written<Flow>> {- ops::flows_update(&self.config, id, name, graph, None, None)- .await- .map(|o| Written {- value: o.value,- logs: o.logs,- })+fn optional_field<T: DeserializeOwned>(value: &Value, key: &str) -> Result<Option<T>, String> {+ match value.get(key) {+ None | Some(Value::Null) => Ok(None),+ Some(value) => serde_json::from_value(value.clone())+ .map(Some)+ .map_err(|error| format!("bad `{key}`: {error}")),}+}- async fn set_enabled(&self, id: &str, enabled: bool) -> PortResult<Flow> {- ops::flows_set_enabled(&self.config, id, enabled)- .await- .map(|o| o.value)- }+fn field<T: DeserializeOwned>(value: &Value, key: &str) -> Result<Option<T>, String> {+ optional_field(value, key)+}- async fn duplicate(&self, id: &str) -> PortResult<Flow> {- ops::flows_duplicate(&self.config, id)- .await- .map(|o| o.value)- }+fn decode<T: DeserializeOwned>(value: Value) -> Result<T, String> {+ serde_json::from_value(value).map_err(|error| error.to_string())+}- async fn history(&self, id: &str, limit: usize) -> PortResult<Vec<FlowRevision>> {- ops::flows_get_history(&self.config, id, limit).map(|o| o.value)- }+fn encode(value: impl Serialize) -> Result<Value, String> {+ serde_json::to_value(value).map_err(|error| error.to_string())+}- async fn list_runs(&self, flow_id: &str, limit: usize) -> PortResult<Vec<FlowRun>> {- ops::flows_list_runs(&self.config, flow_id, limit)- .await- .map(|o| o.value)- }+fn bus_error(member: &str, error: impl std::fmt::Display) -> tinybus::Error {+ tracing::debug!(callback = member, %error, "[flows:copilot] host callback failed");+ tinybus::Error::failed(error)+}- async fn get_run(&self, run_id: &str) -> PortResult<FlowRun> {- ops::flows_get_run(&self.config, run_id)+#[tinybus::interface(name = "ai.tinyhumans.tinyflows.CopilotHost")]+impl FlowsHost {+ async fn call_port(&self, request: copilot::PortCallRequest) -> BusResult<Value> {+ self.dispatch_call_port(request).await- .map(|o| o.value)+ .map_err(|error| bus_error("CallPort", error))}- async fn resume(- &self,- flow_id: &str,- run_id: &str,- approve: Vec<String>,- reject: Vec<String>,- ) -> PortResult<Value> {- let ctx = self.ctx();- ops::flows_resume(&ctx, &self.config, flow_id, run_id, approve, reject)+ async fn build_proposal(&self, request: copilot::BuildProposalRequest) -> BusResult<Value> {+ self.dispatch_build_proposal(request).await- .map(|o| o.value)+ .map_err(|error| bus_error("BuildProposal", error))}- async fn cancel_run(&self, run_id: &str) -> PortResult<Value> {- ops::flows_cancel_run(&self.config, run_id)+ async fn run_flow(&self, request: copilot::RunFlowRequest) -> BusResult<Value> {+ self.dispatch_run_flow(request).await- .map(|o| o.value)+ .map_err(|error| bus_error("RunFlow", error))}}-#[async_trait]-impl BuilderGates for FlowsHost {- async fn validate(&self, graph: Value) -> FlowValidation {- ops::flows_validate(graph).value- }-- async fn run_gates(&self, graph: &WorkflowGraph) -> Vec<String> {- ops::run_builder_gates(&self.ctx(), &self.config, graph).await- }-- async fn strict_gate(&self, graph: &Value) -> PortResult<()> {- ops::strict_gate(&self.ctx(), &self.config, graph).await- }-- async fn engine_compatibility_errors(&self, graph: &WorkflowGraph) -> Vec<String> {- ops::config_aware_engine_compatibility_errors(&self.config, graph)- }-- async fn wiring_warnings(&self, graph: &WorkflowGraph) -> Vec<String> {- ops::graph_wiring_warnings(&self.config, graph).await- }-- async fn approval_manifest(&self, graph: &WorkflowGraph) -> Vec<Value> {- ops::compute_approval_manifest(&self.config, graph).await- }-- async fn build_proposal(- &self,- retry_tool: &str,- name: &str,- graph: &WorkflowGraph,- require_approval: bool,- revision: bool,- instruction: Option<String>,- draft_id: Option<String>,- flow_id: Option<String>,- ) -> Result<Value, String> {- ops::build_builder_proposal(- &self.ctx(),- &self.config,- retry_tool,- name,- graph,- require_approval,- revision,- instruction,- draft_id,- flow_id,- )- .await- }-- fn sandbox_capabilities(&self) -> Capabilities {- use crate::flows::tinyflows::caps::{- PreflightToolInvoker, SchemaAwareMockAgentRunner, SchemaAwareMockLlm,- };- // The schema-aware mock `AgentRunner` makes a draft with `agent` nodes- // exercise the agent-node path instead of erroring on a missing- // capability, and honors `config.output_parser.schema` so the- // null-resolution check does not false-positive on an agent node that- // declared a schema. Plain agent nodes (no `agent_ref`) never reach the- // runner; they go to the `llm` slot, so that is swapped for the- // schema-aware mock too. The tool invoker is wrapped in the wiring- // preflight, so a Composio `tool_call` whose required arg is missing or- // null fails the dry run even over the echo mocks.- let mut caps =- tinyflows::caps::mock::mock_capabilities_with_agent(SchemaAwareMockAgentRunner);- caps.llm = Arc::new(SchemaAwareMockLlm);- caps.tools = Arc::new(PreflightToolInvoker {- config: self.config.clone(),- inner: caps.tools.clone(),- });- caps- }+/// A served Copilot host callback. Its address is passed in the invocation+/// envelope and remains fixed for the entire tool call.+pub(crate) struct HostRegistration {+ path: String,+ address: CopilotHost,}-#[async_trait]-impl AgentDirectory for FlowsHost {- async fn list(&self) -> PortResult<Vec<AgentDefinition>> {- let agents = crate::agent::registry::list_agents(&self.ctx(), false)- .await- .map_err(|e| e.to_string())?;- Ok(agents- .iter()- .map(|a| AgentDefinition {- id: a.id.clone(),- name: a.name.clone(),- description: a.description.clone(),- model: serde_json::to_value(&a.model).unwrap_or(Value::Null),- tools: serde_json::to_value(&a.tool_allowlist).unwrap_or(Value::Null),- tags: serde_json::to_value(&a.tags).unwrap_or(Value::Null),- })- .collect())+impl HostRegistration {+ pub(crate) fn address(&self) -> CopilotHost {+ self.address.clone()}}-#[async_trait]-impl SuggestionStore for FlowsHost {- async fn upsert(&self, suggestions: &[FlowSuggestion]) -> PortResult<usize> {- store::upsert_suggestions(&self.config, suggestions).map_err(|e| e.to_string())+impl Drop for HostRegistration {+ fn drop(&mut self) {+ module::unserve(std::mem::take(&mut self.path));}}-/// The portable node-kind catalog with this host's overlay applied-/// ([`node_contracts`](super::node_contracts)).-pub struct OverlayNodeKinds;--impl NodeKindSource for OverlayNodeKinds {- fn all(&self) -> Vec<NodeKindContract> {- super::node_contracts::all_node_kind_contracts()- }-- fn get(&self, kind: &str) -> Option<NodeKindContract> {- super::node_contracts::node_kind_contract(kind)- }+pub(crate) async fn register(+ config: Arc<Config>,+ context: DispatchCtx,+) -> Result<HostRegistration, String> {+ let path = format!(+ "/ai/tinyhumans/openhuman/CopilotHost/h{}",+ uuid::Uuid::new_v4().simple()+ );+ module::serve(+ path.clone(),+ FlowsHost {+ config,+ context,+ runtime: tokio::runtime::Handle::try_current().ok(),+ },+ )+ .await?;+ Ok(HostRegistration {+ path: path.clone(),+ address: CopilotHost {+ bus_name: module::HOST_BUS_NAME.to_string(),+ object_path: path,+ },+ })}++use super::ops;diff --git a/crates/openhuman-core/src/flows/registration.rs b/crates/openhuman-core/src/flows/registration.rsindex f7baa67387..4f37df301b 100644--- a/crates/openhuman-core/src/flows/registration.rs+++ b/crates/openhuman-core/src/flows/registration.rs@@ -1,152 +1,87 @@-//! Registration of the flow authoring, execution, discovery, and memory tools.+//! Registration of flow authoring, execution, discovery, and memory tools.-use super::builder_host::{FlowsHost, OverlayNodeKinds};+use super::copilot_bus::CopilotToolCatalog;use super::builder_tools_connection_reads::FlowsConnectionProvider;use super::memory_tools::{FlowMemoryRecallTool, FlowMemoryRememberTool};-use super::tools::{ProposeWorkflowTool, RunFlowTool};use crate::config::Config;-use crate::integrations::composio::builder_tools::{- GetToolContractTool, GetToolOutputSampleTool, ListConnectableToolkitsTool,- ListFlowConnectionsTool, SearchToolCatalogTool,-};use crate::security::SecurityPolicy;use std::sync::Arc;-use tinyflows_copilot::tools::{- CancelFlowRunTool, CreateWorkflowTool, DryRunWorkflowTool, DuplicateFlowTool, EditWorkflowTool,- GetFlowHistoryTool, GetFlowRunTool, GetFlowTool, GetNodeKindContractTool,- ListAgentDefinitionsTool, ListFlowRunsTool, ListFlowsTool, ListNodeKindsTool,- ResumeFlowRunTool, ReviseWorkflowTool, SaveWorkflowTool, SuggestWorkflowsTool,- ValidateWorkflowTool,-};use tinytools::Tool;+fn push_copilot_tool(+ tools: &mut Vec<Box<dyn Tool>>,+ catalog: Option<&CopilotToolCatalog>,+ name: &str,+) {+ let Some(catalog) = catalog else {+ return;+ };+ match catalog.tool(name) {+ Ok(tool) => tools.push(Box::new(tool)),+ Err(error) => tracing::error!(tool = name, %error, "[flows] Copilot tool missing from module catalogue"),+ }+}+/// Build the flow tool family in its persisted catalogue order.pub(crate) fn tools(config: Arc<Config>, security: &Arc<SecurityPolicy>) -> Vec<Box<dyn Tool>> {- // One host binds every copilot port (drafts, flows, gates, agents,- // suggestions) to this workspace.- let host = FlowsHost::new(config.clone());- let kinds = Arc::new(OverlayNodeKinds);- vec![- // Agent-first Workflow authoring (issue B4): validates a candidate- // graph and returns a proposal summary — never creates/enables a- // flow itself. Only the chat UI's WorkflowProposalCard "Save &- // enable" action calls `flows_create`.- Box::new(ProposeWorkflowTool::new(config.clone())),- // workflow-builder agent tool belt (Phase 5b). A deliberately narrow,- // propose-or-read surface: revise a draft (validate-only), read saved- // flows/runs/connections, ground tool_call slugs in the real catalog,- // and dry-run a draft against MOCK capabilities. None of these persist- // or enable a flow (only the user's own `flows_create` click does); the- // read tools are `PermissionLevel::None`, and `dry_run_workflow` is- // autonomy-tier gated + wired to deterministic mock capabilities.- Box::new(ReviseWorkflowTool::new(host.clone())),- // Structured incremental edits (F1): apply a small ops[] list to a base- // graph (saved flow or inline) instead of re-emitting the whole graph,- // then validate + gate + return a proposal (same contract as revise).- // Proposal-only — never persists.- Box::new(EditWorkflowTool::new(- host.clone(),- host.clone(),- host.clone(),- )),- // Standalone validate (F3): run the SAME structural + hard-gate stack- // the propose/save tools use, without emitting a proposal — a pure- // check so the agent can self-verify a draft mid-build. Read-only.- Box::new(ValidateWorkflowTool::new(- host.clone(),- host.clone(),- host.clone(),- )),- // Read a saved flow's revision history (F6) — prior graph snapshots the- // agent can inspect / pick a rollback target from. Read-only.- Box::new(GetFlowHistoryTool::new(host.clone())),- // Phase 4 self-debug loop (F4): find a failing run, resume a parked- // run (approval-gated), or cancel a runaway one.- Box::new(ListFlowRunsTool::new(host.clone())),- Box::new(ResumeFlowRunTool::new(host.clone())),- Box::new(CancelFlowRunTool::new(host.clone())),- // Gated create (F4/F12): create a NEW flow — born disabled, approval- // gated — and duplicate an existing one (disabled copy) for- // clone-then-edit. Behind the Phase 3 safety rails.- Box::new(CreateWorkflowTool::new(host.clone(), host.clone())),- Box::new(DuplicateFlowTool::new(host.clone())),- Box::new(ListFlowsTool::new(host.clone())),- Box::new(GetFlowTool::new(host.clone())),- Box::new(GetFlowRunTool::new(host.clone())),- Box::new(ListFlowConnectionsTool::new(- config.clone(),- Arc::new(FlowsConnectionProvider),- )),- Box::new(SearchToolCatalogTool::new(config.clone())),- // Full live contract (schemas, real required_args/output_fields,- // primary_array_path) for one action slug found via- // search_tool_catalog — the grounding step before WIRING a node's- // args/downstream bindings (systemic tool-contract fix, Part 1).- Box::new(GetToolContractTool::new(config.clone())),- // B12: ONE bounded, READ-ONLY, REAL Composio call to derive the real- // primary_array_path/output_fields when the live listing publishes no- // output schema at all (verified for every GitHub action) — overrides- // get_tool_contract's schema-derived hint for that slug from then on.- // Read-scope actions only (hard-refused otherwise), connected- // toolkits only — see builder_tools.rs's module doc for the carve-out- // this makes in the workflow-builder agent's "no composio_execute"- // invariant.- Box::new(GetToolOutputSampleTool::new(config.clone())),- // Ground an `agent` node's `agent_ref` in real registered agent-kind ids- // (code_executor / critic / …) — the agent analogue of- // search_tool_catalog. Read-only.- Box::new(ListAgentDefinitionsTool::new(host.clone())),- // Steer toolkit choice toward what's already connected + surface which- // toolkits a flow still needs (Phase 5, item 19). Read-only.- Box::new(ListConnectableToolkitsTool::new(- config.clone(),- Arc::new(FlowsConnectionProvider),- )),- // Queryable DSL schema (F2): enumerate the 13 node kinds and fetch one- // kind's full config-field/port/example/gotcha contract — the DSL- // analogue of search_tool_catalog + get_tool_contract, so an agent need- // not rely on prompt prose or memory for node config shapes. Read-only.- Box::new(ListNodeKindsTool::new(kinds.clone())),- Box::new(GetNodeKindContractTool::new(kinds)),- Box::new(DryRunWorkflowTool::new(- host.clone(),- host.clone(),- host.clone(),- )),- // Real end-to-end test run of a SAVED flow (Write / external-effect). The- // workflow-builder prompt requires it to ask the user for confirmation- // first, and the flow's own approval gate still pauses outbound nodes.- Box::new(RunFlowTool::new(config.clone())),- // Persist a built graph onto an EXISTING saved flow (Write). Used only- // when the USER explicitly asks the agent to save; the seeded build- // turn from the Flows prompt bar is propose-only (see #4596) — Accept- // + the canvas's own Save persist the graph. The tool itself can- // never create a flow or change enabled/require_approval.- Box::new(SaveWorkflowTool::new(- host.clone(),- host.clone(),- host.clone(),- )),- // Flow Scout discovery: the `flow_discovery` agent's terminal emit- // sink. Read-only reasoning over the user's data ends by calling- // `suggest_workflows`, which persists workflow ideas for the Flows page- // "Suggested for you" section. `PermissionLevel::None`, no external- // effect — writes only to the agent's own suggestions store.- Box::new(SuggestWorkflowsTool::new(host)),- // Per-flow sandboxed memory (issue #5173): lets a running flow- // (e.g. a scheduled newsletter-digest) remember what it already did- // — dedupe across runs — without ever touching the user's own- // memory. Namespace is derived internally from `flow_id`.- // `flow_memory_remember` (write) only resolves that `flow_id` from- // the run's own trusted `TrustedAutomation { Workflow }` turn origin- // (T-M2 fix) — a chat/orchestrator turn with no trusted run origin- // is refused outright, never routed to a model-supplied `flow_id`.- // `flow_memory_recall`'s `scope: "flows"` is a deliberate read-only- // cross-flow exception — it can see every flow's namespace by- // design, but can never be used to write outside a flow's own.- Box::new(FlowMemoryRecallTool::new()),- Box::new(FlowMemoryRememberTool::new(security.clone())),- ]+ let copilot = match CopilotToolCatalog::load(config.clone()) {+ Ok(catalog) => Some(catalog),+ Err(error) => {+ tracing::warn!(%error, "[flows] TinyFlows Copilot tools unavailable");+ None+ }+ };+ let mut tools: Vec<Box<dyn Tool>> = Vec::new();++ // The owning module supplies these descriptors and executes every call.+ // Keep their existing catalogue order because transcripts persist it.+ for name in [+ "propose_workflow",+ "revise_workflow",+ "edit_workflow",+ "validate_workflow",+ "get_flow_history",+ "list_flow_runs",+ "resume_flow_run",+ "cancel_flow_run",+ "create_workflow",+ "duplicate_flow",+ "list_flows",+ "get_flow",+ ] {+ push_copilot_tool(&mut tools, copilot.as_ref(), name);+ }++ tools.push(Box::new(crate::integrations::composio::builder_tools::ListFlowConnectionsTool::new(+ config.clone(),+ Arc::new(FlowsConnectionProvider),+ )));+ tools.push(Box::new(+ crate::integrations::composio::builder_tools::SearchToolCatalogTool::new(config.clone()),+ ));+ tools.push(Box::new(+ crate::integrations::composio::builder_tools::GetToolContractTool::new(config.clone()),+ ));+ tools.push(Box::new(+ crate::integrations::composio::builder_tools::GetToolOutputSampleTool::new(config.clone()),+ ));++ for name in [+ "list_agent_definitions",+ "list_node_kinds",+ "get_node_kind_contract",+ "dry_run_workflow",+ "run_flow",+ "save_workflow",+ "suggest_workflows",+ ] {+ push_copilot_tool(&mut tools, copilot.as_ref(), name);+ }++ // Per-flow sandboxed memory remains a host-owned tool family.+ tools.push(Box::new(FlowMemoryRecallTool::new()));+ tools.push(Box::new(FlowMemoryRememberTool::new(security.clone())));+ tools}#[cfg(test)]