Skip to content

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

refactor(flows): reorganize schema modules into dedicated directory

Steven Enamakel986058d7adaa
diff --git a/crates/openhuman-core/src/flows/flows_schema_part_01.rs b/crates/openhuman-core/src/flows/flows_schema_part_01.rs
deleted file mode 100644
index caf574b56b..0000000000
--- a/crates/openhuman-core/src/flows/flows_schema_part_01.rs
+++ /dev/null
@@ -1,621 +0,0 @@
-use super::*;
-
-pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
- match function {
-"create" => Some( ControllerSchema {
- namespace: "flows",
- function: "create",
- description: "Create a new saved automation workflow from a tinyflows graph.",
- inputs: vec![
- FieldSchema {
- name: "name",
- ty: TypeSchema::String,
- comment: "Human-readable flow name.",
- required: true,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment:
- "A tinyflows WorkflowGraph (nodes + edges); validated and migrated on save.",
- required: true,
- },
- require_approval_input(),
- strict_input(),
- ],
- outputs: vec![flow_output()],
- }),
-"duplicate" => Some( ControllerSchema {
- namespace: "flows",
- function: "duplicate",
- description: "Duplicate a saved flow: create an independent copy of its graph under a \
- new id, with the name suffixed \" (copy)\". The copy is created DISABLED \
- and is NOT schedule/trigger-bound, so it never immediately fires — the \
- user enables it explicitly once reviewed. Run history does not carry over.",
- inputs: vec![id_input("Identifier of the flow to duplicate.")],
- outputs: vec![flow_output()],
- }),
-"validate" => Some( ControllerSchema {
- namespace: "flows",
- function: "validate",
- description: "Validate a tinyflows graph without saving it: reports structural \
- validity plus non-fatal warnings (e.g. a trigger kind that does not \
- fire automatically yet).",
- inputs: vec![FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment: "A tinyflows WorkflowGraph (nodes + edges) to validate and migrate.",
- required: true,
- }],
- outputs: vec![
- FieldSchema {
- name: "valid",
- ty: TypeSchema::Bool,
- comment: "True when the graph is structurally valid.",
- required: true,
- },
- FieldSchema {
- name: "errors",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Structural validation errors; empty when `valid`.",
- required: true,
- },
- FieldSchema {
- name: "warnings",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Non-fatal warnings (e.g. an unfired trigger kind); the graph is \
- still saveable/enable-able.",
- required: true,
- },
- ],
- }),
-"import" => Some( ControllerSchema {
- namespace: "flows",
- function: "import",
- description: "Import a workflow definition WITHOUT saving it: parse a native tinyflows \
- graph or an n8n workflow export, migrate + validate it, and return the \
- normalized WorkflowGraph plus non-fatal import warnings. The caller opens \
- the result on the canvas as a draft and Saves via the normal gate — \
- import never persists or enables anything.",
- inputs: vec![
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment: "The workflow JSON to import: a tinyflows WorkflowGraph (native) or \
- an n8n workflow export.",
- required: true,
- },
- FieldSchema {
- name: "format",
- ty: TypeSchema::Option(Box::new(TypeSchema::Enum {
- variants: vec!["native", "n8n", "auto"],
- })),
- comment: "Source format: `native` (tinyflows), `n8n`, or `auto` (default — \
- detect by shape).",
- required: false,
- },
- ],
- outputs: vec![
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment: "The normalized, migrated + validated WorkflowGraph, ready to open \
- as an editable draft.",
- required: true,
- },
- FieldSchema {
- name: "warnings",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Non-fatal import warnings (unmapped n8n node types, untranslated \
- expressions, a synthesized/demoted trigger). Empty for a clean \
- native import.",
- required: true,
- },
- ],
- }),
-"get" => Some( ControllerSchema {
- namespace: "flows",
- function: "get",
- description: "Load one saved flow by id.",
- inputs: vec![id_input("Identifier of the flow to load.")],
- outputs: vec![flow_output()],
- }),
-"list" => Some( ControllerSchema {
- namespace: "flows",
- function: "list",
- description: "List all saved flows.",
- inputs: vec![],
- outputs: vec![FieldSchema {
- name: "flows",
- ty: TypeSchema::Array(Box::new(TypeSchema::Ref("Flow"))),
- comment: "Flows currently stored in the workspace.",
- required: true,
- }],
- }),
-"list_connections" => Some( ControllerSchema {
- namespace: "flows",
- function: "list_connections",
- description: "List the connection sources a flow node's `connection_ref` can attach \
- to: Composio connected accounts (kind `composio`) and stored HTTP \
- credentials (kind `http`). Returns only non-secret metadata — ids, \
- display labels, kind, and (for Composio) the connected account's own \
- `platform_user_id` — never any secret material (OAuth/bearer tokens, \
- passwords, and API keys stay server-side and are injected only at \
- execution time).",
- inputs: vec![],
- outputs: vec![FieldSchema {
- name: "connections",
- ty: TypeSchema::Array(Box::new(TypeSchema::Object {
- fields: flow_connection_fields(),
- })),
- comment: "Resolvable connections for the flows picker (composio + http), \
- secret-free.",
- required: true,
- }],
- }),
-"update" => Some( ControllerSchema {
- namespace: "flows",
- function: "update",
- description: "Update a saved flow's name and/or graph; re-validates before persisting.",
- inputs: vec![
- id_input("Identifier of the flow to update."),
- FieldSchema {
- name: "name",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "New name, if changing it.",
- required: false,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Replacement WorkflowGraph, if changing it.",
- required: false,
- },
- require_approval_input(),
- strict_input(),
- expected_version_input(),
- ],
- outputs: vec![flow_output()],
- }),
-"delete" => Some( ControllerSchema {
- namespace: "flows",
- function: "delete",
- description: "Delete a saved flow by id.",
- inputs: vec![id_input("Identifier of the flow to delete.")],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: vec![
- FieldSchema {
- name: "id",
- ty: TypeSchema::String,
- comment: "Identifier that was requested for removal.",
- required: true,
- },
- FieldSchema {
- name: "removed",
- ty: TypeSchema::Bool,
- comment: "True when the flow was removed.",
- required: true,
- },
- ],
- },
- comment: "Removal result payload.",
- required: true,
- }],
- }),
-"set_enabled" => Some( ControllerSchema {
- namespace: "flows",
- function: "set_enabled",
- description: "Enable or disable a saved flow.",
- inputs: vec![
- id_input("Identifier of the flow to toggle."),
- FieldSchema {
- name: "enabled",
- ty: TypeSchema::Bool,
- comment: "New enabled state.",
- required: true,
- },
- ],
- outputs: vec![flow_output()],
- }),
-"run" => Some( ControllerSchema {
- namespace: "flows",
- function: "run",
- description:
- "Run a saved flow to completion (or until it pauses on a human-approval gate).",
- inputs: vec![
- id_input("Identifier of the flow to run."),
- FieldSchema {
- name: "input",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Trigger payload seeded into the run; defaults to null.",
- required: false,
- },
- FieldSchema {
- name: "inputs",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Values for the flow's declared workflow inputs, keyed by name \
- (read the flow's `graph.inputs` for the declarations). Missing \
- required values, wrong types, and undeclared names are rejected \
- before the run starts. Distinct from `input`, which is the \
- free-form trigger payload.",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: run_output_fields(),
- },
- comment: "Run outcome payload.",
- required: true,
- }],
- }),
-"run_detached" => Some( ControllerSchema {
- namespace: "flows",
- function: "run_detached",
- description: "Start a saved flow WITHOUT waiting for it to finish: validates + \
- compile-checks the flow, registers the run, inserts its `running` row, \
- and returns the run id immediately. Use this from any UI that wants to \
- show live per-node progress (`flow:run_progress`) or that must not block \
- on a run that can take minutes — poll `flows_get_run(run_id)` or the \
- progress event stream for completion. `run` remains available for callers \
- that genuinely want to await the final result.",
- inputs: vec![
- id_input("Identifier of the flow to run."),
- FieldSchema {
- name: "input",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Trigger payload seeded into the run; defaults to null.",
- required: false,
- },
- FieldSchema {
- name: "inputs",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Values for the flow's declared workflow inputs, keyed by name (read the flow's `graph.inputs` for the declarations). Validated synchronously, so a bad set is refused here rather than surfacing later as a failed background run. Distinct from `input`, which is the free-form trigger payload.",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: run_detached_output_fields(),
- },
- comment: "Immediate start-of-run payload — returned as soon as the run is \
- registered, without waiting for it to finish.",
- required: true,
- }],
- }),
-"resume" => Some( ControllerSchema {
- namespace: "flows",
- function: "resume",
- description: "Resume a flow run paused at a human-in-the-loop approval gate, \
- continuing from its durable checkpoint.",
- inputs: vec![
- id_input("Identifier of the flow to resume."),
- FieldSchema {
- name: "thread_id",
- ty: TypeSchema::String,
- comment:
- "The checkpoint thread id returned by `flows_run` / a prior `flows_resume`.",
- required: true,
- },
- FieldSchema {
- name: "approvals",
- ty: TypeSchema::Option(Box::new(TypeSchema::Array(Box::new(
- TypeSchema::String,
- )))),
- comment: "Node ids being approved; defaults to an empty list.",
- required: false,
- },
- FieldSchema {
- name: "rejections",
- ty: TypeSchema::Option(Box::new(TypeSchema::Array(Box::new(
- TypeSchema::String,
- )))),
- comment: "Node ids being denied; each routes to its `error` port (or fails \
- the run if it has none). Defaults to an empty list.",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: run_output_fields(),
- },
- comment: "Resume outcome payload (same shape as `run`'s).",
- required: true,
- }],
- }),
-"cancel_run" => Some( ControllerSchema {
- namespace: "flows",
- function: "cancel_run",
- description: "Cancel a flow run: settle it to a terminal `cancelled` status, abort \
- the in-flight run task if one is executing, and drop its durable \
- checkpoint so it can't be resumed.",
- inputs: vec![FieldSchema {
- name: "run_id",
- ty: TypeSchema::String,
- comment: "Identifier of the run to cancel (== its checkpoint thread id).",
- required: true,
- }],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: vec![
- FieldSchema {
- name: "run_id",
- ty: TypeSchema::String,
- comment: "Identifier of the run that was cancelled.",
- required: true,
- },
- FieldSchema {
- name: "cancelled",
- ty: TypeSchema::Bool,
- comment:
- "True once the run is cancelled or its cancellation requested.",
- required: true,
- },
- FieldSchema {
- name: "was_in_flight",
- ty: TypeSchema::Bool,
- comment:
- "True when a live run task was signalled to abort; false when \
- a parked/stale run row was settled directly.",
- required: true,
- },
- ],
- },
- comment: "Cancellation result payload.",
- required: true,
- }],
- }),
-"list_runs" => Some( ControllerSchema {
- namespace: "flows",
- function: "list_runs",
- description: "List the most recent runs for a flow, newest first.",
- inputs: vec![
- id_input("Identifier of the flow whose runs to list."),
- FieldSchema {
- name: "limit",
- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
- comment: "Maximum number of runs to return; defaults to 20.",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "runs",
- ty: TypeSchema::Array(Box::new(TypeSchema::Ref("FlowRun"))),
- comment: "Persisted run records for this flow, newest first.",
- required: true,
- }],
- }),
-"list_all_runs" => Some( ControllerSchema {
- namespace: "flows",
- function: "list_all_runs",
- description: "List the most recent runs across all flows, newest first.",
- inputs: vec![FieldSchema {
- name: "limit",
- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
- comment: "Maximum number of runs to return; defaults to 100.",
- required: false,
- }],
- outputs: vec![FieldSchema {
- name: "runs",
- ty: TypeSchema::Array(Box::new(TypeSchema::Ref("FlowRun"))),
- comment: "Persisted run records across all flows, newest first.",
- required: true,
- }],
- }),
-"get_run" => Some( ControllerSchema {
- namespace: "flows",
- function: "get_run",
- description: "Load one persisted flow run record by its (checkpoint thread) id.",
- inputs: vec![FieldSchema {
- name: "run_id",
- ty: TypeSchema::String,
- comment: "Identifier of the run to load (== its checkpoint thread id).",
- required: true,
- }],
- outputs: vec![FieldSchema {
- name: "run",
- ty: TypeSchema::Ref("FlowRun"),
- comment: "The persisted run record.",
- required: true,
- }],
- }),
-"prune_runs" => Some( ControllerSchema {
- namespace: "flows",
- function: "prune_runs",
- description: "Manually prune a flow's run history down to the retention cap, deleting \
- only terminal runs (completed/failed/cancelled) outside the newest-N \
- window. Never removes a running or pending_approval run. Pruning also \
- happens automatically on every new run; this is an explicit on-demand \
- sweep.",
- inputs: vec![id_input("Identifier of the flow whose run history to prune.")],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: vec![
- FieldSchema {
- name: "flow_id",
- ty: TypeSchema::String,
- comment: "Identifier of the flow whose runs were pruned.",
- required: true,
- },
- FieldSchema {
- name: "pruned",
- ty: TypeSchema::U64,
- comment: "Number of run records removed.",
- required: true,
- },
- FieldSchema {
- name: "kept",
- ty: TypeSchema::U64,
- comment: "The retention cap (most-recent runs kept).",
- required: true,
- },
- ],
- },
- comment: "Prune result payload.",
- required: true,
- }],
- }),
-"build" => Some( ControllerSchema {
- namespace: "flows",
- function: "build",
- description: "Run the workflow_builder agent for one authoring turn. `mode` selects \
- create (first draft from `instruction`), revise (refine the injected \
- `graph`), repair (diagnose a failed `run_id` and fix), or build \
- (instant-create: build + dry-run + propose against `flow_id`; \
- propose-only, see #4596). The server renders the agent's brief — the \
- frontend no longer crafts prompts. Returns `{ proposal, assistant_text, \
- error }`, where `proposal` is the `{ type: 'workflow_proposal', name, \
- graph, require_approval, summary, warnings }` the agent produced (or \
- null). No mode auto-persists a graph; save/enable/run stay behind the \
- user's explicit action.",
- inputs: vec![
- FieldSchema {
- name: "mode",
- ty: TypeSchema::String,
- comment: "One of: `create` | `revise` | `repair` | `build`.",
- required: true,
- },
- FieldSchema {
- name: "instruction",
- ty: TypeSchema::String,
- comment: "The user's ask: description (create/build) or change instruction \
- (revise); optional note for repair.",
- required: false,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "The current draft WorkflowGraph, injected as context for \
- revise/repair/build.",
- required: false,
- },
- FieldSchema {
- name: "flow_id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Saved flow id — required for `build` (save target); optional \
- elsewhere (lets the agent run_flow it to test, with confirmation).",
- required: false,
- },
- FieldSchema {
- name: "run_id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Failed run id (== thread id) for `repair`, so the agent can \
- get_flow_run it.",
- required: false,
- },
- FieldSchema {
- name: "error",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Run-level error message for `repair`, if known.",
- required: false,
- },
- FieldSchema {
- name: "failing_node_ids",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Node ids implicated in the failure, for `repair` (array of strings).",
- required: false,
- },
- stream_thread_id_input(),
- stream_request_id_input(),
- ],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Json,
- comment: "`{ proposal, assistant_text, error }` — `proposal` is the workflow \
- proposal the agent produced (or null); `error` is set if the run failed \
- but a prior proposal was still captured.",
- required: true,
- }],
- }),
-"build_cancel" => Some( ControllerSchema {
- namespace: "flows",
- function: "build_cancel",
- description: "Cancel the in-flight `flows_build` (Workflow Copilot) turn streaming \
- into `thread_id` — the real cancellation behind the composer's Stop \
- button. When `request_id` is given, the cancel only fires if it \
- matches the turn currently registered on the thread (a stale Stop for \
- a superseded request can't kill a newer turn); omit it to cancel \
- whatever turn is on the thread. `cancelled: false` is not an error — it \
- just means nothing was in flight (already settled, or never started).",
- inputs: vec![
- FieldSchema {
- name: "thread_id",
- ty: TypeSchema::String,
- comment: "The copilot's dedicated chat thread id (the same `thread_id` \
- passed to `flows.build`'s streaming params).",
- required: true,
- },
- FieldSchema {
- name: "request_id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Per-turn correlation id to scope the cancel to (matches the \
- `request_id` `flows.build` streamed with). Omit to cancel \
- unscoped.",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Object {
- fields: vec![FieldSchema {
- name: "cancelled",
- ty: TypeSchema::Bool,
- comment: "True when an in-flight build turn was found and signalled to \
- cancel.",
- required: true,
- }],
- },
- comment: "Cancellation result payload.",
- required: true,
- }],
- }),
-"discover" => Some( ControllerSchema {
- namespace: "flows",
- function: "discover",
- description: "Run the read-only Flow Scout: it reads the user's \
- memory/threads/people/connections/existing flows and records a handful \
- of concrete, buildable workflow suggestions for the Flows page. It never \
- creates, enables, or runs a flow — turning a suggestion into a real flow \
- is the user's separate 'Build this' action. Returns the active (new) \
- suggestions after the run.",
- inputs: vec![stream_thread_id_input(), stream_request_id_input()],
- outputs: vec![suggestions_output()],
- }),
-"list_suggestions" => Some( ControllerSchema {
- namespace: "flows",
- function: "list_suggestions",
- description: "List persisted workflow suggestions. Filter by lifecycle `status` \
- (`new` | `dismissed` | `built`); omit to return every status.",
- inputs: vec![FieldSchema {
- name: "status",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Lifecycle filter: `new` (active cards) | `dismissed` | `built`. \
- Omit for all.",
- required: false,
- }],
- outputs: vec![suggestions_output()],
- }),
-"dismiss_suggestion" => Some( ControllerSchema {
- namespace: "flows",
- function: "dismiss_suggestion",
- description: "Dismiss a workflow suggestion (the user rejected the card). The row is \
- kept so a later discovery run dedupes against it and won't re-surface \
- the idea.",
- inputs: vec![id_input("Identifier of the suggestion to dismiss.")],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Json,
- comment: "`{ id, dismissed }` — `dismissed` is false if the id was unknown.",
- required: true,
- }],
- }),
- _ => None,
- }
-}
diff --git a/crates/openhuman-core/src/flows/flows_schema_part_02.rs b/crates/openhuman-core/src/flows/flows_schema_part_02.rs
deleted file mode 100644
index d726277c9d..0000000000
--- a/crates/openhuman-core/src/flows/flows_schema_part_02.rs
+++ /dev/null
@@ -1,287 +0,0 @@
-use super::*;
-
-pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
- match function {
-"mark_suggestion_built" => Some( ControllerSchema {
- namespace: "flows",
- function: "mark_suggestion_built",
- description: "Mark a suggestion as built — called after the user saves a flow authored \
- from it, so it drops out of the active cards.",
- inputs: vec![id_input("Identifier of the suggestion that was built.")],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Json,
- comment: "`{ id, built }` — `built` is false if the id was unknown.",
- required: true,
- }],
- }),
-"approval_manifest" => Some( ControllerSchema {
- namespace: "flows",
- function: "approval_manifest",
- description:
- "Compute the approval manifest for a saved flow (by id) or a candidate graph: \
- every ApprovalGate permission a run will prompt for, joined against the flow's \
- existing flow_tool_trust grants — the data behind the consolidated save+enable \
- pre-authorization card. Entries carry kind approvable|blocked|dynamic|agent.",
- inputs: vec![
- FieldSchema {
- name: "id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Saved flow id. Provide this or 'graph'.",
- required: false,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "Candidate WorkflowGraph to inspect (no trust join without an id).",
- required: false,
- },
- ],
- outputs: vec![
- FieldSchema {
- name: "entries",
- ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
- comment:
- "One per relevant node/tool: {kind: approvable|blocked|dynamic|agent, \
- node_id, tool_name?, label, class?}.",
- required: true,
- },
- FieldSchema {
- name: "missing",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Approvable trust keys the flow does not yet hold.",
- required: true,
- },
- FieldSchema {
- name: "already_trusted",
- ty: TypeSchema::Array(Box::new(TypeSchema::String)),
- comment: "Approvable trust keys already granted to this flow. Empty when \
- gate_installed is false — no gate means no grant was ever made.",
- required: true,
- },
- FieldSchema {
- name: "gate_installed",
- ty: TypeSchema::Bool,
- comment:
- "False when the approval gate is disabled — nothing ever prompts, so \
- missing is empty by definition.",
- required: true,
- },
- ],
- }),
-"required_connections" => Some( ControllerSchema {
- namespace: "flows",
- function: "required_connections",
- description: "Compute which Composio toolkits a candidate graph needs and whether each \
- is connected — the data behind the canvas/proposal \"Connect <toolkit>\" \
- CTAs. Native oh: tools and http_request nodes need no connection.",
- inputs: vec![FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment: "The WorkflowGraph to inspect.",
- required: true,
- }],
- outputs: vec![FieldSchema {
- name: "required_connections",
- ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
- comment: "One per needed toolkit: { toolkit, status: connected|missing }.",
- required: true,
- }],
- }),
-"search_tool_catalog" => Some( ControllerSchema {
- namespace: "flows",
- function: "search_tool_catalog",
- description: "Search the live Composio tool catalog (secret-free) for the in-canvas \
- tool browser — the same core as the agent's search_tool_catalog tool.",
- inputs: vec![
- FieldSchema {
- name: "query",
- ty: TypeSchema::String,
- comment: "Keyword query matched against slug / toolkit / description.",
- required: true,
- },
- FieldSchema {
- name: "toolkit",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Restrict to one toolkit slug (e.g. `gmail`); omit to search all.",
- required: false,
- },
- FieldSchema {
- name: "limit",
- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
- comment: "Max results (default 25).",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "tools",
- ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
- comment: "Matches: { slug, toolkit, description, required_args, output_fields, primary_array_path, featured }.",
- required: true,
- }],
- }),
-"get_tool_contract" => Some( ControllerSchema {
- namespace: "flows",
- function: "get_tool_contract",
- description: "Fetch one Composio action's full contract (secret-free) for the canvas \
- tool browser — the same core as the agent's get_tool_contract tool.",
- inputs: vec![FieldSchema {
- name: "slug",
- ty: TypeSchema::String,
- comment: "The exact Composio action slug (e.g. `GMAIL_SEND_EMAIL`).",
- required: true,
- }],
- outputs: vec![FieldSchema {
- name: "contract",
- ty: TypeSchema::Json,
- comment: "The action contract: { slug, toolkit, description, required_args, input_schema, output_fields, output_schema, primary_array_path, is_curated }.",
- required: true,
- }],
- }),
-"get_history" => Some( ControllerSchema {
- namespace: "flows",
- function: "get_history",
- description: "List a flow's revision history — prior graph snapshots captured on each \
- update (capped, newest first). The safety rail behind rollback.",
- inputs: vec![
- id_input("Identifier of the flow whose history to list."),
- FieldSchema {
- name: "limit",
- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
- comment: "Max revisions to return (defaults to the retention cap).",
- required: false,
- },
- ],
- outputs: vec![FieldSchema {
- name: "revisions",
- ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
- comment: "Revision snapshots: { id, flow_id, graph, name, require_approval, created_at }.",
- required: true,
- }],
- }),
-"rollback" => Some( ControllerSchema {
- namespace: "flows",
- function: "rollback",
- description: "Roll a flow back to a prior revision (restores that revision's graph \
- through the normal update path — itself snapshotted, so rollback is \
- undoable). Honours optimistic concurrency via expected_version.",
- inputs: vec![
- id_input("Identifier of the flow to roll back."),
- FieldSchema {
- name: "revision_id",
- ty: TypeSchema::String,
- comment: "The revision (from get_history) to restore.",
- required: true,
- },
- expected_version_input(),
- ],
- outputs: vec![flow_output()],
- }),
-"draft_create" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_create",
- description: "Create a core-managed draft (a durable, non-live working copy of a graph) \
- shared by the agent tools and the canvas. Never persists a flow.",
- inputs: vec![
- FieldSchema {
- name: "name",
- ty: TypeSchema::String,
- comment: "Human-readable draft name (carried into the flow on promote).",
- required: true,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Json,
- comment: "The (possibly incomplete) WorkflowGraph JSON to hold in the draft.",
- required: true,
- },
- FieldSchema {
- name: "flow_id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "The saved flow this draft edits, if any (promote → update vs create).",
- required: false,
- },
- FieldSchema {
- name: "origin",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Where the draft came from: `chat` | `canvas` | `import`. Defaults to `canvas`.",
- required: false,
- },
- ],
- outputs: vec![draft_output()],
- }),
-"draft_get" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_get",
- description: "Fetch a draft by id.",
- inputs: vec![id_input("Identifier of the draft to fetch.")],
- outputs: vec![draft_output()],
- }),
-"draft_update" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_update",
- description: "Patch a draft's name/graph/flow_id (any provided field) and bump its \
- updated_at. Never persists a flow.",
- inputs: vec![
- id_input("Identifier of the draft to update."),
- FieldSchema {
- name: "name",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "New name, if changing it.",
- required: false,
- },
- FieldSchema {
- name: "graph",
- ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
- comment: "New graph JSON, if changing it.",
- required: false,
- },
- FieldSchema {
- name: "flow_id",
- ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "New linked flow id, if changing it.",
- required: false,
- },
- ],
- outputs: vec![draft_output()],
- }),
-"draft_list" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_list",
- description: "List all drafts, newest-updated first.",
- inputs: vec![],
- outputs: vec![FieldSchema {
- name: "drafts",
- ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
- comment: "The drafts (each { id, flow_id?, name, graph, origin, created_at, updated_at }).",
- required: true,
- }],
- }),
-"draft_delete" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_delete",
- description: "Delete a draft by id (idempotent).",
- inputs: vec![id_input("Identifier of the draft to delete.")],
- outputs: vec![FieldSchema {
- name: "result",
- ty: TypeSchema::Json,
- comment: "`{ id, deleted }` — `deleted` is false if the id was already absent.",
- required: true,
- }],
- }),
-"draft_promote" => Some( ControllerSchema {
- namespace: "flows",
- function: "draft_promote",
- description: "Promote a draft into a saved flow through the same create/update gates \
- (structural validation, forced require_approval floor, born-disabled for \
- automatic triggers), then delete the draft file. A draft with a flow_id \
- updates that flow; otherwise it creates a new one.",
- inputs: vec![
- id_input("Identifier of the draft to promote."),
- require_approval_input(),
- ],
- outputs: vec![flow_output()],
- }),
- _ => None,
- }
-}
diff --git a/crates/openhuman-core/src/flows/schemas.rs b/crates/openhuman-core/src/flows/schemas.rs
index 9ce7b32ccf..3216d8b650 100644
--- a/crates/openhuman-core/src/flows/schemas.rs
+++ b/crates/openhuman-core/src/flows/schemas.rs
@@ -496,16 +496,25 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
]
}
-#[path = "flows_schema_part_01.rs"]
-mod flows_schema_part_01;
-#[path = "flows_schema_part_02.rs"]
-mod flows_schema_part_02;
+mod builder_schemas;
+mod definition_schemas;
+mod draft_schemas;
+mod run_schemas;
+/// Builds the `ControllerSchema` for one `flows.<function>`. Each schema
+/// group owns a disjoint set of function names; an unknown name yields the
+/// placeholder schema below.
pub fn schemas(function: &str) -> ControllerSchema {
- if let Some(schema) = flows_schema_part_01::lookup(function) {
+ if let Some(schema) = definition_schemas::lookup(function) {
return schema;
}
- if let Some(schema) = flows_schema_part_02::lookup(function) {
+ if let Some(schema) = run_schemas::lookup(function) {
+ return schema;
+ }
+ if let Some(schema) = builder_schemas::lookup(function) {
+ return schema;
+ }
+ if let Some(schema) = draft_schemas::lookup(function) {
return schema;
}
ControllerSchema {
diff --git a/crates/openhuman-core/src/flows/schemas/builder_schemas.rs b/crates/openhuman-core/src/flows/schemas/builder_schemas.rs
new file mode 100644
index 0000000000..06007cea17
--- /dev/null
+++ b/crates/openhuman-core/src/flows/schemas/builder_schemas.rs
@@ -0,0 +1,231 @@
+//! Schemas for the authoring copilot (`build`/`build_cancel`), the tool
+//! catalog it browses, and workflow discovery suggestions.
+
+use super::{
+ id_input, stream_request_id_input, stream_thread_id_input, suggestions_output,
+ ControllerSchema, FieldSchema, TypeSchema,
+};
+
+/// Builds the schema for `function` when this group owns it.
+pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
+ match function {
+"build" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "build",
+ description: "Run the workflow_builder agent for one authoring turn. `mode` selects \
+ create (first draft from `instruction`), revise (refine the injected \
+ `graph`), repair (diagnose a failed `run_id` and fix), or build \
+ (instant-create: build + dry-run + propose against `flow_id`; \
+ propose-only, see #4596). The server renders the agent's brief — the \
+ frontend no longer crafts prompts. Returns `{ proposal, assistant_text, \
+ error }`, where `proposal` is the `{ type: 'workflow_proposal', name, \
+ graph, require_approval, summary, warnings }` the agent produced (or \
+ null). No mode auto-persists a graph; save/enable/run stay behind the \
+ user's explicit action.",
+ inputs: vec![
+ FieldSchema {
+ name: "mode",
+ ty: TypeSchema::String,
+ comment: "One of: `create` | `revise` | `repair` | `build`.",
+ required: true,
+ },
+ FieldSchema {
+ name: "instruction",
+ ty: TypeSchema::String,
+ comment: "The user's ask: description (create/build) or change instruction \
+ (revise); optional note for repair.",
+ required: false,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "The current draft WorkflowGraph, injected as context for \
+ revise/repair/build.",
+ required: false,
+ },
+ FieldSchema {
+ name: "flow_id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Saved flow id — required for `build` (save target); optional \
+ elsewhere (lets the agent run_flow it to test, with confirmation).",
+ required: false,
+ },
+ FieldSchema {
+ name: "run_id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Failed run id (== thread id) for `repair`, so the agent can \
+ get_flow_run it.",
+ required: false,
+ },
+ FieldSchema {
+ name: "error",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Run-level error message for `repair`, if known.",
+ required: false,
+ },
+ FieldSchema {
+ name: "failing_node_ids",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Node ids implicated in the failure, for `repair` (array of strings).",
+ required: false,
+ },
+ stream_thread_id_input(),
+ stream_request_id_input(),
+ ],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Json,
+ comment: "`{ proposal, assistant_text, error }` — `proposal` is the workflow \
+ proposal the agent produced (or null); `error` is set if the run failed \
+ but a prior proposal was still captured.",
+ required: true,
+ }],
+ }),
+"build_cancel" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "build_cancel",
+ description: "Cancel the in-flight `flows_build` (Workflow Copilot) turn streaming \
+ into `thread_id` — the real cancellation behind the composer's Stop \
+ button. When `request_id` is given, the cancel only fires if it \
+ matches the turn currently registered on the thread (a stale Stop for \
+ a superseded request can't kill a newer turn); omit it to cancel \
+ whatever turn is on the thread. `cancelled: false` is not an error — it \
+ just means nothing was in flight (already settled, or never started).",
+ inputs: vec![
+ FieldSchema {
+ name: "thread_id",
+ ty: TypeSchema::String,
+ comment: "The copilot's dedicated chat thread id (the same `thread_id` \
+ passed to `flows.build`'s streaming params).",
+ required: true,
+ },
+ FieldSchema {
+ name: "request_id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Per-turn correlation id to scope the cancel to (matches the \
+ `request_id` `flows.build` streamed with). Omit to cancel \
+ unscoped.",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: vec![FieldSchema {
+ name: "cancelled",
+ ty: TypeSchema::Bool,
+ comment: "True when an in-flight build turn was found and signalled to \
+ cancel.",
+ required: true,
+ }],
+ },
+ comment: "Cancellation result payload.",
+ required: true,
+ }],
+ }),
+"search_tool_catalog" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "search_tool_catalog",
+ description: "Search the live Composio tool catalog (secret-free) for the in-canvas \
+ tool browser — the same core as the agent's search_tool_catalog tool.",
+ inputs: vec![
+ FieldSchema {
+ name: "query",
+ ty: TypeSchema::String,
+ comment: "Keyword query matched against slug / toolkit / description.",
+ required: true,
+ },
+ FieldSchema {
+ name: "toolkit",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Restrict to one toolkit slug (e.g. `gmail`); omit to search all.",
+ required: false,
+ },
+ FieldSchema {
+ name: "limit",
+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
+ comment: "Max results (default 25).",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "tools",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
+ comment: "Matches: { slug, toolkit, description, required_args, output_fields, primary_array_path, featured }.",
+ required: true,
+ }],
+ }),
+"get_tool_contract" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "get_tool_contract",
+ description: "Fetch one Composio action's full contract (secret-free) for the canvas \
+ tool browser — the same core as the agent's get_tool_contract tool.",
+ inputs: vec![FieldSchema {
+ name: "slug",
+ ty: TypeSchema::String,
+ comment: "The exact Composio action slug (e.g. `GMAIL_SEND_EMAIL`).",
+ required: true,
+ }],
+ outputs: vec![FieldSchema {
+ name: "contract",
+ ty: TypeSchema::Json,
+ comment: "The action contract: { slug, toolkit, description, required_args, input_schema, output_fields, output_schema, primary_array_path, is_curated }.",
+ required: true,
+ }],
+ }),
+"discover" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "discover",
+ description: "Run the read-only Flow Scout: it reads the user's \
+ memory/threads/people/connections/existing flows and records a handful \
+ of concrete, buildable workflow suggestions for the Flows page. It never \
+ creates, enables, or runs a flow — turning a suggestion into a real flow \
+ is the user's separate 'Build this' action. Returns the active (new) \
+ suggestions after the run.",
+ inputs: vec![stream_thread_id_input(), stream_request_id_input()],
+ outputs: vec![suggestions_output()],
+ }),
+"list_suggestions" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "list_suggestions",
+ description: "List persisted workflow suggestions. Filter by lifecycle `status` \
+ (`new` | `dismissed` | `built`); omit to return every status.",
+ inputs: vec![FieldSchema {
+ name: "status",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Lifecycle filter: `new` (active cards) | `dismissed` | `built`. \
+ Omit for all.",
+ required: false,
+ }],
+ outputs: vec![suggestions_output()],
+ }),
+"dismiss_suggestion" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "dismiss_suggestion",
+ description: "Dismiss a workflow suggestion (the user rejected the card). The row is \
+ kept so a later discovery run dedupes against it and won't re-surface \
+ the idea.",
+ inputs: vec![id_input("Identifier of the suggestion to dismiss.")],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Json,
+ comment: "`{ id, dismissed }` — `dismissed` is false if the id was unknown.",
+ required: true,
+ }],
+ }),
+"mark_suggestion_built" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "mark_suggestion_built",
+ description: "Mark a suggestion as built — called after the user saves a flow authored \
+ from it, so it drops out of the active cards.",
+ inputs: vec![id_input("Identifier of the suggestion that was built.")],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Json,
+ comment: "`{ id, built }` — `built` is false if the id was unknown.",
+ required: true,
+ }],
+ }),
+ _ => None,
+ }
+}
diff --git a/crates/openhuman-core/src/flows/schemas/definition_schemas.rs b/crates/openhuman-core/src/flows/schemas/definition_schemas.rs
new file mode 100644
index 0000000000..03d4839350
--- /dev/null
+++ b/crates/openhuman-core/src/flows/schemas/definition_schemas.rs
@@ -0,0 +1,344 @@
+//! Schemas for the saved-flow definition lifecycle: create, import,
+//! validate, read, update, enable/disable, delete, revision history and the
+//! approval/connection manifests derived from a graph.
+
+use super::{
+ expected_version_input, flow_connection_fields, flow_output, id_input, require_approval_input,
+ strict_input, ControllerSchema, FieldSchema, TypeSchema,
+};
+
+/// Builds the schema for `function` when this group owns it.
+pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
+ match function {
+"create" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "create",
+ description: "Create a new saved automation workflow from a tinyflows graph.",
+ inputs: vec![
+ FieldSchema {
+ name: "name",
+ ty: TypeSchema::String,
+ comment: "Human-readable flow name.",
+ required: true,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment:
+ "A tinyflows WorkflowGraph (nodes + edges); validated and migrated on save.",
+ required: true,
+ },
+ require_approval_input(),
+ strict_input(),
+ ],
+ outputs: vec![flow_output()],
+ }),
+"duplicate" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "duplicate",
+ description: "Duplicate a saved flow: create an independent copy of its graph under a \
+ new id, with the name suffixed \" (copy)\". The copy is created DISABLED \
+ and is NOT schedule/trigger-bound, so it never immediately fires — the \
+ user enables it explicitly once reviewed. Run history does not carry over.",
+ inputs: vec![id_input("Identifier of the flow to duplicate.")],
+ outputs: vec![flow_output()],
+ }),
+"validate" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "validate",
+ description: "Validate a tinyflows graph without saving it: reports structural \
+ validity plus non-fatal warnings (e.g. a trigger kind that does not \
+ fire automatically yet).",
+ inputs: vec![FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment: "A tinyflows WorkflowGraph (nodes + edges) to validate and migrate.",
+ required: true,
+ }],
+ outputs: vec![
+ FieldSchema {
+ name: "valid",
+ ty: TypeSchema::Bool,
+ comment: "True when the graph is structurally valid.",
+ required: true,
+ },
+ FieldSchema {
+ name: "errors",
+ ty: TypeSchema::Array(Box::new(TypeSchema::String)),
+ comment: "Structural validation errors; empty when `valid`.",
+ required: true,
+ },
+ FieldSchema {
+ name: "warnings",
+ ty: TypeSchema::Array(Box::new(TypeSchema::String)),
+ comment: "Non-fatal warnings (e.g. an unfired trigger kind); the graph is \
+ still saveable/enable-able.",
+ required: true,
+ },
+ ],
+ }),
+"import" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "import",
+ description: "Import a workflow definition WITHOUT saving it: parse a native tinyflows \
+ graph or an n8n workflow export, migrate + validate it, and return the \
+ normalized WorkflowGraph plus non-fatal import warnings. The caller opens \
+ the result on the canvas as a draft and Saves via the normal gate — \
+ import never persists or enables anything.",
+ inputs: vec![
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment: "The workflow JSON to import: a tinyflows WorkflowGraph (native) or \
+ an n8n workflow export.",
+ required: true,
+ },
+ FieldSchema {
+ name: "format",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Enum {
+ variants: vec!["native", "n8n", "auto"],
+ })),
+ comment: "Source format: `native` (tinyflows), `n8n`, or `auto` (default — \
+ detect by shape).",
+ required: false,
+ },
+ ],
+ outputs: vec![
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment: "The normalized, migrated + validated WorkflowGraph, ready to open \
+ as an editable draft.",
+ required: true,
+ },
+ FieldSchema {
+ name: "warnings",
+ ty: TypeSchema::Array(Box::new(TypeSchema::String)),
+ comment: "Non-fatal import warnings (unmapped n8n node types, untranslated \
+ expressions, a synthesized/demoted trigger). Empty for a clean \
+ native import.",
+ required: true,
+ },
+ ],
+ }),
+"get" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "get",
+ description: "Load one saved flow by id.",
+ inputs: vec![id_input("Identifier of the flow to load.")],
+ outputs: vec![flow_output()],
+ }),
+"list" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "list",
+ description: "List all saved flows.",
+ inputs: vec![],
+ outputs: vec![FieldSchema {
+ name: "flows",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Ref("Flow"))),
+ comment: "Flows currently stored in the workspace.",
+ required: true,
+ }],
+ }),
+"list_connections" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "list_connections",
+ description: "List the connection sources a flow node's `connection_ref` can attach \
+ to: Composio connected accounts (kind `composio`) and stored HTTP \
+ credentials (kind `http`). Returns only non-secret metadata — ids, \
+ display labels, kind, and (for Composio) the connected account's own \
+ `platform_user_id` — never any secret material (OAuth/bearer tokens, \
+ passwords, and API keys stay server-side and are injected only at \
+ execution time).",
+ inputs: vec![],
+ outputs: vec![FieldSchema {
+ name: "connections",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Object {
+ fields: flow_connection_fields(),
+ })),
+ comment: "Resolvable connections for the flows picker (composio + http), \
+ secret-free.",
+ required: true,
+ }],
+ }),
+"update" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "update",
+ description: "Update a saved flow's name and/or graph; re-validates before persisting.",
+ inputs: vec![
+ id_input("Identifier of the flow to update."),
+ FieldSchema {
+ name: "name",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "New name, if changing it.",
+ required: false,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Replacement WorkflowGraph, if changing it.",
+ required: false,
+ },
+ require_approval_input(),
+ strict_input(),
+ expected_version_input(),
+ ],
+ outputs: vec![flow_output()],
+ }),
+"delete" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "delete",
+ description: "Delete a saved flow by id.",
+ inputs: vec![id_input("Identifier of the flow to delete.")],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: vec![
+ FieldSchema {
+ name: "id",
+ ty: TypeSchema::String,
+ comment: "Identifier that was requested for removal.",
+ required: true,
+ },
+ FieldSchema {
+ name: "removed",
+ ty: TypeSchema::Bool,
+ comment: "True when the flow was removed.",
+ required: true,
+ },
+ ],
+ },
+ comment: "Removal result payload.",
+ required: true,
+ }],
+ }),
+"set_enabled" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "set_enabled",
+ description: "Enable or disable a saved flow.",
+ inputs: vec![
+ id_input("Identifier of the flow to toggle."),
+ FieldSchema {
+ name: "enabled",
+ ty: TypeSchema::Bool,
+ comment: "New enabled state.",
+ required: true,
+ },
+ ],
+ outputs: vec![flow_output()],
+ }),
+"get_history" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "get_history",
+ description: "List a flow's revision history — prior graph snapshots captured on each \
+ update (capped, newest first). The safety rail behind rollback.",
+ inputs: vec![
+ id_input("Identifier of the flow whose history to list."),
+ FieldSchema {
+ name: "limit",
+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
+ comment: "Max revisions to return (defaults to the retention cap).",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "revisions",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
+ comment: "Revision snapshots: { id, flow_id, graph, name, require_approval, created_at }.",
+ required: true,
+ }],
+ }),
+"rollback" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "rollback",
+ description: "Roll a flow back to a prior revision (restores that revision's graph \
+ through the normal update path — itself snapshotted, so rollback is \
+ undoable). Honours optimistic concurrency via expected_version.",
+ inputs: vec![
+ id_input("Identifier of the flow to roll back."),
+ FieldSchema {
+ name: "revision_id",
+ ty: TypeSchema::String,
+ comment: "The revision (from get_history) to restore.",
+ required: true,
+ },
+ expected_version_input(),
+ ],
+ outputs: vec![flow_output()],
+ }),
+"required_connections" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "required_connections",
+ description: "Compute which Composio toolkits a candidate graph needs and whether each \
+ is connected — the data behind the canvas/proposal \"Connect <toolkit>\" \
+ CTAs. Native oh: tools and http_request nodes need no connection.",
+ inputs: vec![FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment: "The WorkflowGraph to inspect.",
+ required: true,
+ }],
+ outputs: vec![FieldSchema {
+ name: "required_connections",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
+ comment: "One per needed toolkit: { toolkit, status: connected|missing }.",
+ required: true,
+ }],
+ }),
+"approval_manifest" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "approval_manifest",
+ description:
+ "Compute the approval manifest for a saved flow (by id) or a candidate graph: \
+ every ApprovalGate permission a run will prompt for, joined against the flow's \
+ existing flow_tool_trust grants — the data behind the consolidated save+enable \
+ pre-authorization card. Entries carry kind approvable|blocked|dynamic|agent.",
+ inputs: vec![
+ FieldSchema {
+ name: "id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Saved flow id. Provide this or 'graph'.",
+ required: false,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Candidate WorkflowGraph to inspect (no trust join without an id).",
+ required: false,
+ },
+ ],
+ outputs: vec![
+ FieldSchema {
+ name: "entries",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
+ comment:
+ "One per relevant node/tool: {kind: approvable|blocked|dynamic|agent, \
+ node_id, tool_name?, label, class?}.",
+ required: true,
+ },
+ FieldSchema {
+ name: "missing",
+ ty: TypeSchema::Array(Box::new(TypeSchema::String)),
+ comment: "Approvable trust keys the flow does not yet hold.",
+ required: true,
+ },
+ FieldSchema {
+ name: "already_trusted",
+ ty: TypeSchema::Array(Box::new(TypeSchema::String)),
+ comment: "Approvable trust keys already granted to this flow. Empty when \
+ gate_installed is false — no gate means no grant was ever made.",
+ required: true,
+ },
+ FieldSchema {
+ name: "gate_installed",
+ ty: TypeSchema::Bool,
+ comment:
+ "False when the approval gate is disabled — nothing ever prompts, so \
+ missing is empty by definition.",
+ required: true,
+ },
+ ],
+ }),
+ _ => None,
+ }
+}
diff --git a/crates/openhuman-core/src/flows/schemas/draft_schemas.rs b/crates/openhuman-core/src/flows/schemas/draft_schemas.rs
new file mode 100644
index 0000000000..17ca8b766c
--- /dev/null
+++ b/crates/openhuman-core/src/flows/schemas/draft_schemas.rs
@@ -0,0 +1,119 @@
+//! Schemas for unsaved flow drafts: the copilot's scratch space before a
+//! graph is promoted into a saved flow.
+
+use super::{
+ draft_output, flow_output, id_input, require_approval_input, ControllerSchema, FieldSchema,
+ TypeSchema,
+};
+
+/// Builds the schema for `function` when this group owns it.
+pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
+ match function {
+"draft_create" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_create",
+ description: "Create a core-managed draft (a durable, non-live working copy of a graph) \
+ shared by the agent tools and the canvas. Never persists a flow.",
+ inputs: vec![
+ FieldSchema {
+ name: "name",
+ ty: TypeSchema::String,
+ comment: "Human-readable draft name (carried into the flow on promote).",
+ required: true,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Json,
+ comment: "The (possibly incomplete) WorkflowGraph JSON to hold in the draft.",
+ required: true,
+ },
+ FieldSchema {
+ name: "flow_id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "The saved flow this draft edits, if any (promote → update vs create).",
+ required: false,
+ },
+ FieldSchema {
+ name: "origin",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "Where the draft came from: `chat` | `canvas` | `import`. Defaults to `canvas`.",
+ required: false,
+ },
+ ],
+ outputs: vec![draft_output()],
+ }),
+"draft_get" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_get",
+ description: "Fetch a draft by id.",
+ inputs: vec![id_input("Identifier of the draft to fetch.")],
+ outputs: vec![draft_output()],
+ }),
+"draft_update" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_update",
+ description: "Patch a draft's name/graph/flow_id (any provided field) and bump its \
+ updated_at. Never persists a flow.",
+ inputs: vec![
+ id_input("Identifier of the draft to update."),
+ FieldSchema {
+ name: "name",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "New name, if changing it.",
+ required: false,
+ },
+ FieldSchema {
+ name: "graph",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "New graph JSON, if changing it.",
+ required: false,
+ },
+ FieldSchema {
+ name: "flow_id",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "New linked flow id, if changing it.",
+ required: false,
+ },
+ ],
+ outputs: vec![draft_output()],
+ }),
+"draft_list" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_list",
+ description: "List all drafts, newest-updated first.",
+ inputs: vec![],
+ outputs: vec![FieldSchema {
+ name: "drafts",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Json)),
+ comment: "The drafts (each { id, flow_id?, name, graph, origin, created_at, updated_at }).",
+ required: true,
+ }],
+ }),
+"draft_delete" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_delete",
+ description: "Delete a draft by id (idempotent).",
+ inputs: vec![id_input("Identifier of the draft to delete.")],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Json,
+ comment: "`{ id, deleted }` — `deleted` is false if the id was already absent.",
+ required: true,
+ }],
+ }),
+"draft_promote" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "draft_promote",
+ description: "Promote a draft into a saved flow through the same create/update gates \
+ (structural validation, forced require_approval floor, born-disabled for \
+ automatic triggers), then delete the draft file. A draft with a flow_id \
+ updates that flow; otherwise it creates a new one.",
+ inputs: vec![
+ id_input("Identifier of the draft to promote."),
+ require_approval_input(),
+ ],
+ outputs: vec![flow_output()],
+ }),
+ _ => None,
+ }
+}
diff --git a/crates/openhuman-core/src/flows/schemas/run_schemas.rs b/crates/openhuman-core/src/flows/schemas/run_schemas.rs
new file mode 100644
index 0000000000..1c431d4ea5
--- /dev/null
+++ b/crates/openhuman-core/src/flows/schemas/run_schemas.rs
@@ -0,0 +1,256 @@
+//! Schemas for executing saved flows and inspecting their run history.
+
+use super::{
+ id_input, run_detached_output_fields, run_output_fields, ControllerSchema, FieldSchema,
+ TypeSchema,
+};
+
+/// Builds the schema for `function` when this group owns it.
+pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
+ match function {
+"run" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "run",
+ description:
+ "Run a saved flow to completion (or until it pauses on a human-approval gate).",
+ inputs: vec![
+ id_input("Identifier of the flow to run."),
+ FieldSchema {
+ name: "input",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Trigger payload seeded into the run; defaults to null.",
+ required: false,
+ },
+ FieldSchema {
+ name: "inputs",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Values for the flow's declared workflow inputs, keyed by name \
+ (read the flow's `graph.inputs` for the declarations). Missing \
+ required values, wrong types, and undeclared names are rejected \
+ before the run starts. Distinct from `input`, which is the \
+ free-form trigger payload.",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: run_output_fields(),
+ },
+ comment: "Run outcome payload.",
+ required: true,
+ }],
+ }),
+"run_detached" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "run_detached",
+ description: "Start a saved flow WITHOUT waiting for it to finish: validates + \
+ compile-checks the flow, registers the run, inserts its `running` row, \
+ and returns the run id immediately. Use this from any UI that wants to \
+ show live per-node progress (`flow:run_progress`) or that must not block \
+ on a run that can take minutes — poll `flows_get_run(run_id)` or the \
+ progress event stream for completion. `run` remains available for callers \
+ that genuinely want to await the final result.",
+ inputs: vec![
+ id_input("Identifier of the flow to run."),
+ FieldSchema {
+ name: "input",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Trigger payload seeded into the run; defaults to null.",
+ required: false,
+ },
+ FieldSchema {
+ name: "inputs",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Json)),
+ comment: "Values for the flow's declared workflow inputs, keyed by name (read the flow's `graph.inputs` for the declarations). Validated synchronously, so a bad set is refused here rather than surfacing later as a failed background run. Distinct from `input`, which is the free-form trigger payload.",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: run_detached_output_fields(),
+ },
+ comment: "Immediate start-of-run payload — returned as soon as the run is \
+ registered, without waiting for it to finish.",
+ required: true,
+ }],
+ }),
+"resume" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "resume",
+ description: "Resume a flow run paused at a human-in-the-loop approval gate, \
+ continuing from its durable checkpoint.",
+ inputs: vec![
+ id_input("Identifier of the flow to resume."),
+ FieldSchema {
+ name: "thread_id",
+ ty: TypeSchema::String,
+ comment:
+ "The checkpoint thread id returned by `flows_run` / a prior `flows_resume`.",
+ required: true,
+ },
+ FieldSchema {
+ name: "approvals",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Array(Box::new(
+ TypeSchema::String,
+ )))),
+ comment: "Node ids being approved; defaults to an empty list.",
+ required: false,
+ },
+ FieldSchema {
+ name: "rejections",
+ ty: TypeSchema::Option(Box::new(TypeSchema::Array(Box::new(
+ TypeSchema::String,
+ )))),
+ comment: "Node ids being denied; each routes to its `error` port (or fails \
+ the run if it has none). Defaults to an empty list.",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: run_output_fields(),
+ },
+ comment: "Resume outcome payload (same shape as `run`'s).",
+ required: true,
+ }],
+ }),
+"cancel_run" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "cancel_run",
+ description: "Cancel a flow run: settle it to a terminal `cancelled` status, abort \
+ the in-flight run task if one is executing, and drop its durable \
+ checkpoint so it can't be resumed.",
+ inputs: vec![FieldSchema {
+ name: "run_id",
+ ty: TypeSchema::String,
+ comment: "Identifier of the run to cancel (== its checkpoint thread id).",
+ required: true,
+ }],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: vec![
+ FieldSchema {
+ name: "run_id",
+ ty: TypeSchema::String,
+ comment: "Identifier of the run that was cancelled.",
+ required: true,
+ },
+ FieldSchema {
+ name: "cancelled",
+ ty: TypeSchema::Bool,
+ comment:
+ "True once the run is cancelled or its cancellation requested.",
+ required: true,
+ },
+ FieldSchema {
+ name: "was_in_flight",
+ ty: TypeSchema::Bool,
+ comment:
+ "True when a live run task was signalled to abort; false when \
+ a parked/stale run row was settled directly.",
+ required: true,
+ },
+ ],
+ },
+ comment: "Cancellation result payload.",
+ required: true,
+ }],
+ }),
+"list_runs" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "list_runs",
+ description: "List the most recent runs for a flow, newest first.",
+ inputs: vec![
+ id_input("Identifier of the flow whose runs to list."),
+ FieldSchema {
+ name: "limit",
+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
+ comment: "Maximum number of runs to return; defaults to 20.",
+ required: false,
+ },
+ ],
+ outputs: vec![FieldSchema {
+ name: "runs",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Ref("FlowRun"))),
+ comment: "Persisted run records for this flow, newest first.",
+ required: true,
+ }],
+ }),
+"list_all_runs" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "list_all_runs",
+ description: "List the most recent runs across all flows, newest first.",
+ inputs: vec![FieldSchema {
+ name: "limit",
+ ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
+ comment: "Maximum number of runs to return; defaults to 100.",
+ required: false,
+ }],
+ outputs: vec![FieldSchema {
+ name: "runs",
+ ty: TypeSchema::Array(Box::new(TypeSchema::Ref("FlowRun"))),
+ comment: "Persisted run records across all flows, newest first.",
+ required: true,
+ }],
+ }),
+"get_run" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "get_run",
+ description: "Load one persisted flow run record by its (checkpoint thread) id.",
+ inputs: vec![FieldSchema {
+ name: "run_id",
+ ty: TypeSchema::String,
+ comment: "Identifier of the run to load (== its checkpoint thread id).",
+ required: true,
+ }],
+ outputs: vec![FieldSchema {
+ name: "run",
+ ty: TypeSchema::Ref("FlowRun"),
+ comment: "The persisted run record.",
+ required: true,
+ }],
+ }),
+"prune_runs" => Some( ControllerSchema {
+ namespace: "flows",
+ function: "prune_runs",
+ description: "Manually prune a flow's run history down to the retention cap, deleting \
+ only terminal runs (completed/failed/cancelled) outside the newest-N \
+ window. Never removes a running or pending_approval run. Pruning also \
+ happens automatically on every new run; this is an explicit on-demand \
+ sweep.",
+ inputs: vec![id_input("Identifier of the flow whose run history to prune.")],
+ outputs: vec![FieldSchema {
+ name: "result",
+ ty: TypeSchema::Object {
+ fields: vec![
+ FieldSchema {
+ name: "flow_id",
+ ty: TypeSchema::String,
+ comment: "Identifier of the flow whose runs were pruned.",
+ required: true,
+ },
+ FieldSchema {
+ name: "pruned",
+ ty: TypeSchema::U64,
+ comment: "Number of run records removed.",
+ required: true,
+ },
+ FieldSchema {
+ name: "kept",
+ ty: TypeSchema::U64,
+ comment: "The retention cap (most-recent runs kept).",
+ required: true,
+ },
+ ],
+ },
+ comment: "Prune result payload.",
+ required: true,
+ }],
+ }),
+ _ => None,
+ }
+}