The whole loop, end to end: an agent turns intent into a canonical workflow spec, asks when it needs a decision, then runs the compiled graph with schema validation and an observable execution lifecycle. Hover to pause; pick a scenario below.
Design Principles
Six commitments that make workflows safe for humans to maintain — and for agents to operate.
Workflows as Graphs
Logic is explicit steps and edges, not hidden control flow. Every transition is deterministic and type-checked, so complex flows stay understandable, testable, and safe for an agent to reason about.
Type-Safety End-to-End
Zod schemas validate inputs, outputs, configs, and API calls at runtime; TypeScript infers everything statically. The same schemas that protect your code become the contract an LLM plans against.
Immutability
State updates are immutable by default, so every change is predictable and replayable — the foundation for time-travel debugging, snapshots, and safe rewind-and-retry recovery.
Co-location
Each step owns its schemas, state, and API in one place — business rules live inside the step, not scattered across UI handlers. Steps stay pure, portable, and testable in isolation.
Framework Agnostic
The engine has zero UI or AI-SDK dependencies. It runs anywhere JavaScript runs; thin adapters bind it to React, Vue, or Svelte, and a callback binds it to whichever model provider you choose.
Agent Native
You own the LLM calls — motif-ts never talks to a model. Instead it hands your agent a precise, typed surface: describe the workflow, list invokable actions, emit tool catalogs, and drive a budgeted, approval-aware loop.
The Step Model
One primitive underneath everything: encapsulated logic with strict, schema-checked IO and reactive private state.
Explore the anatomy of a step
Hover or tap any part of the diagram — or any highlighted token in the code — to see how each piece maps to a runtime schema and its inferred TypeScript type.
Shape the Workflow
Loops, scopes, and nesting — three composition patterns that grow a graph without changing how any single step behaves.
Workflow Shape · 01
RepeatGroup
Make a fresh lane for each iteration.
Expands a declared template into a single linear sequence of new step instances. Input and ID validation finishes before a new lane is committed. History spans the lanes; edge direction still controls back-navigation.
Edit the Spec. Run the Graph.
This playground runs the real engine in your browser: edit the canonical workflow spec on the left, watch the generated code update, then run it and drive every step by hand.
Workflow
Editing6 steps, 5 edges
One Stack, Layered
Core executes the graph. Agentic adds agent interactions and host run controls. Spec and Runtime provide canonical workflow data, trusted execution, and durability. Add middleware, tooling, and UI adapters as needed.
Workflow Engine
The in-memory workflow engine: typed steps and edges, lifecycle control, graph validation, and state observation. Repeat groups, context scopes, composed workflows, streaming, cancellation, and local state restore share the same execution model.
@motif-ts/core@conf-ts/expressionCanonical Spec & Durable Runs
Spec defines the canonical JSON workflow format and revision-checked edits. Runtime validates and compiles it against trusted implementations, authorizes actions, and provides the durable run kernel: replayable events, JSON checkpoints, and an effect journal for recovery.
@motif-ts/spec@motif-ts/runtimeAgentic Layer
Agent-facing descriptions, validated actions, tool catalogs, planner prompts, and a budgeted agent loop. Also owns goals, host run status and commands, failure classification, fallback decisions, and checkpoint, approval, and recovery hooks. Snapshots support local rewind; your application supplies LLM calls and dispatches host hooks.
@motif-ts/agentic (private preview)Visualizer & Run Replay
Live workflow graphs, a visual spec editor, and durable-run tooling: scrub any run frame by frame from its event log, review planner re-decides as a visual spec diff, and fold many runs into visit counts and failure heat.
@motif-ts/visualizer (private preview)Production Middleware
Composable wrappers for timeouts, retry with backoff, tracing, cost budgets, approval gates, rate limits, DevTools, and state persistence. Retry uses Agentic’s failure classifier; wrappers subscribe to Core’s lifecycle and events.
@motif-ts/middlewareFramework Adapters
Bind the same workflow to any UI with one hook, composable, or store. The engine never imports a framework — adapters subscribe to it.
@motif-ts/react@motif-ts/vue@motif-ts/svelteQuick Start
Install, define steps, and run your workflow.
Install core and its dependencies.