WorkflowEvent
Type Alias: WorkflowEvent#
type WorkflowEvent =
| {
audience?: string;
runId: string;
threadId?: string;
ts: number;
type: "RUN_STARTED";
}
| {
audience?: string;
output: unknown;
runId: string;
ts: number;
type: "RUN_FINISHED";
}
| {
audience?: string;
code: string;
error: SerializedError;
runId: string;
ts: number;
type: "RUN_ERRORED";
}
| {
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "STEP_STARTED";
}
| {
attempts?: ReadonlyArray<StepAttempt>;
audience?: string;
meta?: WorkflowMetadata;
result: unknown;
stepId: string;
ts: number;
type: "STEP_FINISHED";
}
| {
attempts?: ReadonlyArray<StepAttempt>;
audience?: string;
error: SerializedError;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "STEP_FAILED";
}
| {
audience?: string;
deadline?: number;
meta?: Record<string, unknown>;
name: string;
stepId: string;
ts: number;
type: "SIGNAL_AWAITED";
}
| {
audience?: string;
meta?: WorkflowMetadata;
name: string;
payload: unknown;
signalId?: string;
stepId: string;
ts: number;
type: "SIGNAL_RESOLVED";
}
| {
approvalId: string;
audience?: string;
description?: string;
meta?: WorkflowMetadata;
stepId: string;
title: string;
ts: number;
type: "APPROVAL_REQUESTED";
}
| {
approvalId: string;
approved: boolean;
audience?: string;
feedback?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "APPROVAL_RESOLVED";
}
| {
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "NOW_RECORDED";
value: number;
}
| {
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "UUID_RECORDED";
value: string;
}
| {
audience?: string;
delta: ReadonlyArray<Operation>;
ts: number;
type: "STATE_DELTA";
}
| {
audience?: string;
name: string;
ts: number;
type: "CUSTOM";
value: Record<string, unknown>;
};Defined in: packages/workflow-core/src/types.ts:70
The shape of every event the engine appends to a run's log.
Two consumers, one shape:
- Durability: the engine appends events to the run's log. Replay reads the log and short-circuits primitives that have a matching CHECKPOINT event by stepId.
- Observability: the engine emits the same events through runWorkflow's AsyncIterable<WorkflowEvent> and (if wired) through stream subscribers. A browser/UI subscribes to the same log a Durable Streams URL would expose.
Events fall into two categories internally:
Checkpoint events — replay uses these to skip already- completed work. Indexed by stepId. STEP_FINISHED, STEP_FAILED, SIGNAL_RESOLVED, APPROVAL_RESOLVED, NOW_RECORDED, UUID_RECORDED, RUN_FINISHED, RUN_ERRORED.
Coordination events — persisted so hosts and resume calls can identify the pending wait. SIGNAL_AWAITED, APPROVAL_REQUESTED.
Observability events — engine emits but replay ignores. RUN_STARTED, STEP_STARTED, STATE_DELTA, CUSTOM.
The optional audience field is engine-ignored. Adapters/views (e.g., a Durable Streams projection layer) may filter on it to produce internal vs client vs admin views of the same log.
Type Declaration#
{
audience?: string;
runId: string;
threadId?: string;
ts: number;
type: "RUN_STARTED";
}audience?#
optional audience: string;runId#
runId: string;threadId?#
optional threadId: string;ts#
ts: number;type#
type: "RUN_STARTED";{
audience?: string;
output: unknown;
runId: string;
ts: number;
type: "RUN_FINISHED";
}audience?#
optional audience: string;output#
output: unknown;runId#
runId: string;ts#
ts: number;type#
type: "RUN_FINISHED";{
audience?: string;
code: string;
error: SerializedError;
runId: string;
ts: number;
type: "RUN_ERRORED";
}audience?#
optional audience: string;code#
code: string;error#
error: SerializedError;runId#
runId: string;ts#
ts: number;type#
type: "RUN_ERRORED";{
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "STEP_STARTED";
}audience?#
optional audience: string;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;ts#
ts: number;type#
type: "STEP_STARTED";{
attempts?: ReadonlyArray<StepAttempt>;
audience?: string;
meta?: WorkflowMetadata;
result: unknown;
stepId: string;
ts: number;
type: "STEP_FINISHED";
}attempts?#
optional attempts: ReadonlyArray<StepAttempt>;audience?#
optional audience: string;meta?#
optional meta: WorkflowMetadata;result#
result: unknown;stepId#
stepId: string;ts#
ts: number;type#
type: "STEP_FINISHED";{
attempts?: ReadonlyArray<StepAttempt>;
audience?: string;
error: SerializedError;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "STEP_FAILED";
}attempts?#
optional attempts: ReadonlyArray<StepAttempt>;audience?#
optional audience: string;error#
error: SerializedError;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;ts#
ts: number;type#
type: "STEP_FAILED";{
audience?: string;
deadline?: number;
meta?: Record<string, unknown>;
name: string;
stepId: string;
ts: number;
type: "SIGNAL_AWAITED";
}audience?#
optional audience: string;deadline?#
optional deadline: number;meta?#
optional meta: Record<string, unknown>;name#
name: string;stepId#
stepId: string;ts#
ts: number;type#
type: "SIGNAL_AWAITED";{
audience?: string;
meta?: WorkflowMetadata;
name: string;
payload: unknown;
signalId?: string;
stepId: string;
ts: number;
type: "SIGNAL_RESOLVED";
}audience?#
optional audience: string;meta?#
optional meta: WorkflowMetadata;name#
name: string;payload#
payload: unknown;signalId?#
optional signalId: string;Host-supplied idempotency token. Same signalId at the same stepId is a no-op (idempotent retry); different signalId is a lost race.
stepId#
stepId: string;ts#
ts: number;type#
type: "SIGNAL_RESOLVED";{
approvalId: string;
audience?: string;
description?: string;
meta?: WorkflowMetadata;
stepId: string;
title: string;
ts: number;
type: "APPROVAL_REQUESTED";
}approvalId#
approvalId: string;audience?#
optional audience: string;description?#
optional description: string;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;title#
title: string;ts#
ts: number;type#
type: "APPROVAL_REQUESTED";{
approvalId: string;
approved: boolean;
audience?: string;
feedback?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "APPROVAL_RESOLVED";
}approvalId#
approvalId: string;approved#
approved: boolean;audience?#
optional audience: string;feedback?#
optional feedback: string;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;ts#
ts: number;type#
type: "APPROVAL_RESOLVED";{
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "NOW_RECORDED";
value: number;
}audience?#
optional audience: string;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;ts#
ts: number;type#
type: "NOW_RECORDED";value#
value: number;{
audience?: string;
meta?: WorkflowMetadata;
stepId: string;
ts: number;
type: "UUID_RECORDED";
value: string;
}audience?#
optional audience: string;meta?#
optional meta: WorkflowMetadata;stepId#
stepId: string;ts#
ts: number;type#
type: "UUID_RECORDED";value#
value: string;{
audience?: string;
delta: ReadonlyArray<Operation>;
ts: number;
type: "STATE_DELTA";
}audience?#
optional audience: string;delta#
delta: ReadonlyArray<Operation>;ts#
ts: number;type#
type: "STATE_DELTA";{
audience?: string;
name: string;
ts: number;
type: "CUSTOM";
value: Record<string, unknown>;
}audience?#
optional audience: string;name#
name: string;ts#
ts: number;type#
type: "CUSTOM";value#
value: Record<string, unknown>;