@humain/workflow
v0.1.0
Published
HUMAIN's React workflow editor runtime and product workflow components
Maintainers
Readme
@humain/workflow
@humain/workflow owns the React editor and standalone visual primitives.
React-only; no Web Components. Supports React 18/19. Start with its semantic
preset catalog, then add only the product definitions and adapters your
application owns.
Install
npm install @humain/ui @humain/workflow lucide-reactImport the two public stylesheets once at the application entrypoint:
import '@humain/ui/styles.css';
import '@humain/workflow/styles.css';Do not import package source paths, internal graph modules, or @xyflow/react.
The graph engine is a private implementation detail.
Layered imports
The root entry remains supported for existing consumers. New code can import from the narrowest public layer so its bundler does not retain the editor stack for domain-only or non-visual runtime usage:
import {
createWorkflowPresetRegistry,
validateWorkflowDocument,
} from '@humain/workflow/domain';
import { createWorkflowExecutionController } from '@humain/workflow/runtime';
import { WorkflowEditor } from '@humain/workflow/editor';
import { WorkflowNode as VisualNode } from '@humain/workflow/primitives';@humain/workflow/domaincontains JSON-safe contracts and pure workflow behavior.@humain/workflow/runtimecontains non-React controllers and adapter state.@humain/workflow/editorcontains React hooks, messages, and editor components.@humain/workflow/primitivescontains all six standalone visual families and public props/types without loading the editor/graph engine. Its visualWorkflowNodeis distinct from the root/domain document type.
The coordinated ownership migration pairs UI 2.8.0 and Workflow 0.1.0, requiring UI ^2.8.0. This intentionally breaks the old UI minor-release exports and six Workflow WC/WC-React families; there are no compatibility re-exports or replacement WC package. Generic UI Web Components remain supported. See the ownership guide in the dedicated reference at /workflow/storybook/?path=/docs/workflow-docs-package-ownership-migration--docs; the overview is /workflow/storybook/?path=/docs/workflow-docs-overview--docs and AI reference is /workflow/storybook/docs/workflow-llms.txt. Use the coordinated versions together when migrating an existing Workflow integration.
Import @humain/workflow/styles.css when rendering the editor or primitives, alongside @humain/ui/styles.css. Emitted files
outside these documented entry points are private implementation details.
Preset-first quick start
include preserves the product-supplied order. It does not sort presets into
the package's default catalog order.
import { ThemeProvider } from '@humain/ui';
import {
createWorkflowNodeRegistry,
createWorkflowPresetDefinitions,
type WorkflowDocument,
WorkflowEditor,
} from '@humain/workflow';
import { useState } from 'react';
const definitions = createWorkflowPresetDefinitions({
include: ['manual-trigger', 'ai-agent', 'http-request', 'workflow-end'],
});
const registry = createWorkflowNodeRegistry(definitions);
const initialDocument: WorkflowDocument = {
schemaVersion: 1,
id: 'support-flow',
name: 'Support flow',
nodes: [
{
id: 'start',
type: 'manual-trigger',
position: { x: 80, y: 220 },
configuration: {},
},
{
id: 'agent',
type: 'ai-agent',
position: { x: 360, y: 220 },
configuration: {},
},
{
id: 'http',
type: 'http-request',
position: { x: 360, y: 460 },
configuration: {},
},
{
id: 'end',
type: 'workflow-end',
position: { x: 660, y: 220 },
configuration: {},
},
],
edges: [
{
id: 'start-to-agent',
sourceNodeId: 'start',
sourcePortId: 'output',
targetNodeId: 'agent',
targetPortId: 'input',
},
{
id: 'agent-tool-to-http',
sourceNodeId: 'agent',
sourcePortId: 'tool-primary',
targetNodeId: 'http',
targetPortId: 'tool-input',
},
{
id: 'agent-to-end',
sourceNodeId: 'agent',
sourcePortId: 'output',
targetNodeId: 'end',
targetPortId: 'input',
},
],
};
export function SupportWorkflow() {
const [document, setDocument] = useState(initialDocument);
return (
<ThemeProvider>
<WorkflowEditor
document={document}
registry={registry}
nodeCatalogDefinitions={definitions}
onDocumentChange={({ document: nextDocument }) =>
setDocument(nextDocument)
}
/>
</ThemeProvider>
);
}The first and third edges are semantic data flow (output to input). The
middle edge is the named AI tool relationship (tool-primary to tool-input).
Persist this JSON-only document shape; React elements, functions, clients,
credentials, and secrets belong outside it.
Use defaultDocument instead of document when the editor should own its
local state. Use document with onDocumentChange when the host owns state
and acknowledges every proposal. Do not mix the two ownership models.
Configurable default UI
The default editor renders its own header, left tool rail, centered empty-state cards, bottom AI composer, and history/zoom controls. A minimal integration needs only a document and registry:
<WorkflowEditor defaultDocument={initialDocument} registry={registry} />
<WorkflowEditor document={initialDocument} registry={registry} readOnly />The registry supplies the catalog when no explicit catalog is passed. The
first picker accepts any registered node; restrict it in the host when your
product requires an entry point. Explicit catalog.items takes precedence
over legacy nodeCatalogDefinitions, then registry order. Catalog items
override presentation, not registered behavior.
import { Badge } from '@humain/ui';
import { Plus } from 'lucide-react';
import type { WorkflowDocument } from '@humain/workflow';
declare const exportWorkflow: (document: Readonly<WorkflowDocument>) => void;
<WorkflowEditor
document={document}
registry={registry}
onDocumentChange={({ document: next }) => setDocument(next)}
onExport={exportWorkflow}
catalog={{
items: [
{ typeId: 'manual-trigger', label: 'Start manually', group: 'Triggers' },
{ typeId: 'ai-agent', group: 'Steps' },
{ typeId: 'workflow-end', group: 'Steps' },
],
groupOrder: ['Triggers', 'Steps'],
filter: (definition, context) =>
context.kind !== 'first' || Boolean(definition.entryPoint),
}}
ui={{
header: { items: ['export', 'save', 'publish'], showSearch: false },
canvasTools: { items: [
{ id: 'add-step', label: 'Add a step', icon: <Plus />, mutates: true,
onSelect: ({ openPicker }) => openPicker() },
] },
emptyState: { items: ['add'] },
aiComposer: false,
corner: { render: ({ readOnly }) =>
<Badge>{readOnly ? 'Read only' : 'Editing'}</Badge> },
}}
/>Use false to hide any configured section. A section's render callback
receives its context and defaultContent when you need composition rather
than action ordering. Mark custom mutating actions mutates: true; custom
rendered content must use context.readOnly to disable its own mutations.
Back, export, AI, templates, attachment, text, and more controls appear only
when their handlers are supplied. Save and publish require their adapters.
AI submit is labeled as submit; a voice action requires ui.aiComposer.onVoice.
The title becomes a project menu only when projects contains another
enabled project. The host owns project navigation and unsaved-change policy.
Dragging an output to empty canvas or using its trailing plus opens connected
insertion. Candidates must satisfy kind, optional semantic connectionType,
capacity, and host validation. A node definition's preferredInputPortId
selects an eligible input; otherwise multiple eligible inputs require an
explicit choice. Untyped custom ports retain kind-only compatibility; specify
channels on both ends or use host validation for stricter semantics.
Insertion submits one atomic node-and-edge proposal and one history entry. Escape cancels without changing the graph and restores focus. Controlled hosts must acknowledge the complete proposed document; rejection never falls back to a disconnected node.
Single click selects. Double-click or Configure opens the inspector, including
for read-only documents. Picker and inspector do not remain open together.
Use openInspectorOnAdd to opt into inspection after insertion.
readOnly blocks package-mediated graph changes, history mutations, saves,
publication, and execution, including late asynchronous outcomes. Selection,
inspection, search, pan/zoom, and a supplied export handler remain available.
Custom inspectors receive readOnly; disable host-owned configuration fields
and actions. This is a UI permission boundary, not backend authorization.
Adapters must honor cancellation; UI guards cannot roll back host side effects
already started.
See default UI migration for changed defaults.
Ownership and extension
The package owns editing, graph projection, structural validation, history,
accessibility behavior, and package-created copy. The host owns persistence,
product validation, publication, execution, authentication, authorization,
credentials, secret storage, and service clients. Supply the host-owned
adapters through WorkflowEditor rather than embedding services in a node
definition or workflow document.
Adapter replacement lifecycle
During an active durable operation, replacing the validation adapter cancels
validation-dependent saves and publications; replacing the publication adapter
cancels only publication; and replacing the persistence adapter cancels only
saves. Pending autosave is rescheduled against the replacement validation
adapter. Obsolete outcomes are ignored, and cleanup removes only the
operation's own busy feedback so newer unrelated notices remain visible.
Updating messages.controllerErrors alone only refreshes fallback copy and
does not cancel active host work.
Live announcements
useWorkflowAnnouncements accepts an optional reannounceKey. Change that
key when an otherwise identical message represents a new event; the hook first
clears both live regions, then publishes the message again so assistive
technology can announce it reliably. First-time and changed messages remain
available immediately without that repeat transition. Clearing message
empties the regions but retains the prior event identity, so a later identical
event with a new key still receives the repeat transition.
Execution safety
WorkflowEditor defaults executionMode to "simulation". When an
execution adapter can cause side effects, pass executionMode="live" and keep
that prop current whenever the host's execution configuration changes.
@humain/workflow does not inspect an adapter or workflow to infer safety,
authorization, or product policy.
In live mode, WorkflowEditor owns the confirmation boundary for every editor
execution entry point. A standalone WorkflowGraphOutline still uses
mode-aware labels, but its callbacks remain the consumer's confirmation
policy.
Activated connections show a one-shot execution tracer by default. Its core
uses the source port tone and its halo uses the source node tone. Pass
showExecutionFlowAnimation={false} to keep execution state colors while
removing spatial motion; the tracer is also hidden automatically for users
who prefer reduced motion.
See the preset, custom-registry, and linear HTTP Request examples in Node registry, message and accessibility requirements in Accessibility and theming, and adapter contracts in Editor quickstart.
Coding-agent skill
npx @humain/workflow@latest skill
npx @humain/workflow@latest skill --global
npx @humain/workflow@latest skill --project --agent codex --yesThe skill installer requires Node.js 22.20.0 or newer; this is separate from the Workflow library's runtime support.
The bare interactive command delegates agent selection, Project/Global scope,
and confirmation to the native [email protected] wizard. Use arrow keys to navigate,
Space to toggle agents, Enter to confirm, and typing to search. Review the
selected agents and destinations before installing. There are no typed wrapper
prompts. Native detection may skip agent selection
when only one agent is detected. --global without --agent fixes global scope
while leaving native agent selection enabled. Explicit --agent options
without a scope leave scope selection to the native wizard.
Partial-project migration: interactive --project without --agent is
rejected before installation. The pinned native installer has no add --project
flag, so silently forwarding it would allow a different scope. Run the bare
command and choose Project, or add an explicit --agent <name> (repeatable).
Noninteractive runs and --yes require both --project or --global and at
least one explicit --agent. Fully specified commands retain the wrapper's
completion summary. Native interactive output owns its summary; cancellation
also exits successfully, so the wrapper does not claim installation completed.
Installs keep --copy and the selected agents' native skill destinations.
Coding-agent environments require explicit --yes, scope, and agent flags even
with a TTY, preventing inherited agent markers from bypassing confirmation and
overwriting existing skill directories.
The Workflow skill mirrors the public
React-only contract: presets, documents, registries, copy, adapters,
accessibility, and verification. The 0.1.x line is a preview API; pin the
minor version until the package is promoted to a stable release.
