wayflow/agent

Node-type definitions, graph validation, structured errors, and logging — the building blocks behind the node library and the custom-node API.

The layer beneath the editor and runtime: node-type definitions, validation, WayflowError, and the Logger.

Node types

ExportNotes
BUILTIN_NODE_TYPESThe registry of built-in node types; spread into the editor’s nodeTypes to extend it. See Custom node types.
PORT_TYPESThe registry of built-in data types (each a color + label); spread into portTypes to add your own.

NodeTypeDefinition

The shape of a custom node type.

FieldTypeNotes
labelstringThe node’s display name.
categorystringThe palette group it appears under.
iconstringAn icon name (optional).
portsPortsShape, or PortsResolverIts ports — { inputs, outputs } of PortDefinitions, either static or a (data) => PortsShape function of the node’s config.
configSchemaRecord<string, ConfigField>The fields shown in the config panel (below).
uniquebooleanAt most one of this type per graph (e.g. Input, Output).
mappablebooleanWhether it offers “Run once per item”. Defaults to true for nodes with both inputs and outputs.
validateNodeValidateFn(node, ctx) => ValidationWarning[] — static pre-run checks specific to this node type.
reconcileData(data: NodeData) => NodeDataCalled after each config change to sync derived fields.
configPreviewConfigPreviewFn, or nullRenders a compact preview on the node body.
hideInlinePreviewbooleanHide the default inline result preview.

ConfigField

A field in a node’s configSchema. Its type picks the control:

types.ts ts
type ConfigFieldType =
  | 'text' | 'textarea' | 'number' | 'slider' | 'select'
  | 'boolean' | 'json' | 'fields' | 'tools-select'
  | 'image-size' | 'array-op'
FieldTypeNotes
typeConfigFieldTypeWhich control to render.
labelstringThe field’s label.
defaultunknownThe initial value.
optionsstring[]Choices, for 'select'.
emptyHintstringFor 'select' — shown in place of the dropdown when options is empty.
min / max / stepnumberBounds, for 'slider' and 'number'.
withDefaultsbooleanFor 'fields' — when false, hides the default-value editor.
lockNamesbooleanFor 'fields' — rows are preset-managed; defaults are editable but rows aren’t added/renamed.
allowMultiplebooleanFor 'fields' — each row offers a “Multiple values” toggle (the field holds a list).
allowRequiredbooleanFor 'fields' — each row offers a “Required” toggle.

Validation

validateGraph(graph, registry, toolCatalog?)

Run the editor’s live checks on a graph — no Input/Output node, an orphan node, an unfilled required input, an LLM with no prompt, a tool not in the catalog — and return the warnings ([] when clean).

ParameterTypeNotes
graphGraphThe graph to check.
registryNodeTypeRegistryThe node types in play — Record<string, NodeTypeDefinition>.
toolCatalogRecord<string, ToolMetadata>The available tools, for the tool-not-in-catalog check. Optional.

ValidationWarning

FieldTypeNotes
codestringThe warning’s ERROR_CODE.
messagestringA plain-language description of the problem.
hintstringAn actionable suggestion (optional).
nodeIdsstring[]The nodes the warning points at (optional).

Errors

ExportNotes
WayflowErrorThe error class the runtime and library throw — carries code, message, and an optional hint.
createError(code, params?, cause?)Build a WayflowError from a catalog code — for throwing structured errors from a custom node handler.
createWarning(code, params?, nodeIds?)Build a ValidationWarning from a catalog code.

WayflowError extends the native Error:

error.ts ts
class WayflowError extends Error {
  readonly code: string
  readonly hint?: string
}

The full list of codes is in Error codes.

Logging

createConsoleLogger(options?)

A Logger that writes the [wayflow] LEVEL message key=value console format.

OptionTypeDefaultNotes
level'debug' / 'info' / 'warn' / 'error''debug'The lowest level to emit; quieter levels are dropped.

Implement Logger to route diagnostics to your own sink — each method takes a message and a bag of structured fields (runId, nodeId, …):

logger.ts ts
interface Logger {
  debug(message: string, fields?: Record<string, unknown>): void
  info(message: string, fields?: Record<string, unknown>): void
  warn(message: string, fields?: Record<string, unknown>): void
  error(message: string, fields?: Record<string, unknown>): void
}

See Debugging & diagnostics for the guide.