How tahash/wayflow works
Purpose and public entry points
Wayflow is an embeddable, framework-agnostic TypeScript/DOM visual workflow editor and workflow execution stack. The package façade is src/index.ts; consumers primarily mount an editor through createWorkflowEditor, then attach a local or remote runtime. The monorepo separates graph semantics, editor rendering, UI composition, agent nodes, model adapters, and runtime transport.
Graph domain and execution planning
packages/core/src/model.ts defines the workflow graph model; analysis and execution ordering live in packages/core/src/graph-analysis.ts and packages/core/src/execution.ts. This layer owns graph structure, node/edge predicates, selection, history, viewport state, text utilities, and serialization. It is the provider- and UI-independent boundary: editors and runtimes consume the same workflow representation.
• packages/core/src/model.ts
• packages/core/src/graph-analysis.ts
• packages/core/src/serializer.ts
Editor shell, canvas, and interaction
The DOM package mounts and operates the editor without React/Vue/Svelte dependencies. packages/dom/src/editor.ts is the editor-facing integration point; rendering, pointer interaction, keyboard behavior, and persistence are split below it. It transforms core graph state into an interactive DOM canvas and emits edits/run requests toward the UI/runtime boundary.
• packages/dom/src/editor.ts
• packages/dom/src/renderer.ts
• packages/dom/src/interaction.ts
Product UI composition
The UI package supplies the complete workspace around the canvas: workflow editor shell, palette, inspector/configuration, run/result surfaces, approval UI, theming, responsive behavior, and mounting. It composes DOM editor capabilities with domain-specific controls rather than depending on an application framework.
• packages/ui/src/workflow-editor.ts
• packages/ui/src/mount.ts
• packages/ui/src/result-panel.ts
Agent workflow nodes
packages/agent provides higher-level node types for LLMs, images, tools, arrays/maps, operators, and validation. Its execution adapter interprets agent-oriented nodes on top of the generic graph executor. This is the bridge from visual AI/logic workflows to model dispatch and tool execution, while allowing custom node types and editor extensions.
• packages/agent/src/node-types.ts
• packages/agent/src/execution.ts
• packages/agent/src/tools.ts
Model-provider boundary
packages/models normalizes chat and image model invocation behind provider interfaces and dispatchers. OpenAI support and mock implementations are included, but graph/agent layers target the abstraction rather than a vendor. Handler logic covers streaming/tool-call accumulation and request/response schema/template concerns.
• packages/models/src/provider.ts
• packages/models/src/dispatch.ts
• packages/models/src/openai.ts
Local/server runtime and human-in-the-loop
packages/runtime runs graphs, manages sessions, exposes tools, and supports browser-to-server execution through a client/protocol/SSE boundary. The runtime is responsible for lifecycle events, async coordination, resumable sessions, handlers, logging, and graph workflows callable as tools. A browser editor can therefore execute locally or delegate the same graph to a backend runtime.
• packages/runtime/src/runtime.ts
• packages/runtime/src/client.ts
• packages/runtime/src/sessions.ts
Delivery surfaces
Runnable Vite examples demonstrate standalone embedding and server-backed execution; the backend example places runtime ownership in a Node server. Astro documentation is a separate site package and is not part of the library runtime.
• examples/with-backend/server/index.ts
• examples/quickstart/main.ts
• docs/src/pages/docs/[...slug].astro
Main entry points: editor.ts DOM editor · model.ts Workflow graph model · execution.ts Agent execution adapter · runtime.ts Runtime
Components 23
Graph Core
Provider- and UI-independent workflow representation and planning.
- Workflow graph model · Shared graph, state, and workflow representation.
packages/core/src/model.ts - Graph analysis · Analyzes graph structure and execution order.
packages/core/src/graph-analysis.ts - Generic executor · Executes planned generic workflows.
packages/core/src/execution.ts - Workflow serialization
packages/core/src/serializer.ts
Editor & UI
Framework-agnostic DOM editing and workspace composition.
- DOM editor · Mounts the interactive editor and emits edits or run requests.
packages/dom/src/editor.ts - Canvas renderer
packages/dom/src/renderer.ts - Editor interaction · Pointer and keyboard editing behavior.
packages/dom/src/interaction.ts - Workflow workspace · Composes canvas, palette, inspector, approval, and run surfaces.
packages/ui/src/workflow-editor.ts - UI mounting
packages/ui/src/mount.ts - Run results
packages/ui/src/result-panel.ts
Execution Stack
Agent interpretation, model dispatch, and local or remote runtime.
- Agent node types · LLM, image, tool, collection, operator, and validation nodes.
packages/agent/src/node-types.ts - Agent execution adapter · Maps agent-oriented nodes onto generic execution.
packages/agent/src/execution.ts - Agent tools
packages/agent/src/tools.ts - Model provider interfaces · Vendor-neutral chat and image invocation contracts.
packages/models/src/provider.ts - Model dispatcher · Handles provider calls, streaming, and tool-call accumulation.
packages/models/src/dispatch.ts - OpenAI adapter
packages/models/src/openai.ts - Runtime · Runs graphs and coordinates handlers, lifecycle, logging, and tools.
packages/runtime/src/runtime.ts - Runtime client · Browser-to-server execution client and protocol boundary.
packages/runtime/src/client.ts - Resumable sessions · Maintains runtime session state across async and approval flows.
packages/runtime/src/sessions.ts
Delivery Surfaces
Embedding examples and separate documentation site.
- Backend example · Places runtime ownership on a server.
examples/with-backend/server/index.ts - Quickstart example · Demonstrates standalone embedding.
examples/quickstart/main.ts - Documentation site · Separate documentation delivery surface.
docs/src/pages/docs/[...slug].astro
Other components
- Package facade · Primary consumer entry point.
src/index.ts
Connections 24
- Package facade → Workflow graph model: exports shared graph API
- Package facade → DOM editor: exposes editor
- Workflow graph model → Graph analysis: analyzed as
- Graph analysis → Generic executor: plans execution
- Workflow graph model → Workflow serialization: serialized
- Workflow graph model → DOM editor: editor state
- DOM editor → Canvas renderer: renders through
- DOM editor → Editor interaction: handles edits through
- UI mounting → Workflow workspace: mounts
- Workflow workspace → DOM editor: composes canvas
- Workflow workspace → Run results: shows run output
- Workflow graph model → Agent node types: defines agent graph nodes
- Agent node types → Agent execution adapter: interpreted by
- Agent execution adapter → Generic executor: uses generic executor
- Agent execution adapter → Agent tools: invokes
- Agent execution adapter → Model dispatcher: dispatches model nodes
- Model dispatcher → Model provider interfaces: targets interfaces
- OpenAI adapter → Model provider interfaces: implements
- Runtime → Agent execution adapter: runs agent workflows
- Runtime → Resumable sessions: manages
- Runtime client → Runtime: remote execution protocol
- DOM editor → Runtime client: delegates remote runs
- Quickstart example → UI mounting: embeds
- Backend example → Runtime: hosts