WorkflowRun instance is created via workflow.createRun(runId?). It encapsulates execution state, event observation, and human-step management.
Methods
watch(listener)
workflow:start, step:success, step:event, step:human:*, …). Returns a disposer to stop watching.
cancel(reason?)
AbortSignal. The final result has status "cancelled" and the error contains WorkflowAbortError when no custom reason is provided.
start(options)
stream(options)
final promise resolves when the run finishes (success, failed, cancelled, waiting_human). When awaiting human input, the stream stays open until the workflow resumes.
resumeWithHumanInput({ stepId, data, runId? })
WorkflowResumeError if no interaction is pending or the identifiers don’t match.
Telemetry & events
- Events include
workflowId,runId,timestamp,metadata, and type-specific payloads. - Telemetry (OTEL/Langfuse) is configured via the workflow or per-run
telemetryoption.WorkflowRunautomatically records step spans and human interaction events.
History & context
Step handlers receive aWorkflowStepRuntimeContext that provides:
getMetadata()/updateMetadata()– shared mutable metadata.store– aMap<string, unknown>for temporary references (useful forresumeWithHumanInput).getCtx()/updateCtx()– shared typed context.emit(event)– custom events (step:event) forwarded towatch/stream.
WorkflowRunResult.steps collection stores snapshots for every step (status, timestamps, occurrence, branch taken, next step).