wayflow/core

The plain-data graph model, serialization, and the primitives to build a graph without the editor.

The lowest layer — generic graph primitives with no workflow vocabulary. Most apps touch it only for serialize/deserialize and the model types.

The graph model

A workflow is plain data: the shapes the editor produces and the runtime consumes.

Graph

FieldTypeNotes
nodesRecord<string, Node>The nodes, keyed by id.
edgesRecord<string, Edge>The edges, keyed by id.
metadataGraphMetadataThe workflow’s name and description (optional).

Node

FieldTypeNotes
idstringUnique within the graph.
typestringThe node type — llm, imageGeneration, a custom type, …
namestringA user-given display name (optional).
dataNodeDataThe node’s config — Record<string, unknown>.
portsPort[]Its input and output ports.
positionPositionWhere it sits on the canvas.
label / iconstringDisplay label and icon (from the node type).
size / zIndex / dataPreviewEditor layout and the inline preview.

Edge

FieldTypeNotes
idstringUnique within the graph.
sourceNodeId / sourcePortIdstringThe output port it leaves from.
targetNodeId / targetPortIdstringThe input port it arrives at.

Port

FieldTypeNotes
idstringUnique within the node.
side'input' / 'output'Which side of the node it’s on.
dataTypestringThe data type it carries — drives its color and what it can connect to.
label / colorstringOptional overrides.

GraphMetadata

FieldTypeNotes
namestringThe workflow’s name.
descriptionstringA longer description.

Position is { x, y }; Viewport is { x, y, zoom }.

Serialization

FunctionNotes
serialize(graph): stringTurn a Graph into a versioned JSON string ({ version, graph }) you can store anywhere.
deserialize(json): GraphParse a serialized string back into a Graph; throws if it can’t be parsed or is missing its nodes/edges.

Construction

Build a graph without the editor — handy for generating workflows programmatically, then running them with the runtime.

createNode(params): Node

FieldTypeNotes
position{ x, y }Where it sits on the canvas. Required.
portsPort[]Its input and output ports. Required.
typestringThe node type.
dataNodeDataInitial config.
idstringAuto-generated when omitted.
label / icon / size / dataPreviewOptional display and layout.

createEdge(params): Edge

FieldTypeNotes
sourceNodeId / sourcePortIdstringThe output port to connect from. Required.
targetNodeId / targetPortIdstringThe input port to connect to. Required.
idstringAuto-generated when omitted.