workflow 5.0.0-beta.43 → 5.0.0-beta.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +6 -4
  2. package/dist/internal/builtins.d.ts +4 -4
  3. package/dist/internal/builtins.js +6 -6
  4. package/docs/ai/chat-session-modeling.mdx +23 -24
  5. package/docs/ai/defining-tools.mdx +5 -6
  6. package/docs/ai/human-in-the-loop.mdx +11 -11
  7. package/docs/ai/index.mdx +20 -20
  8. package/docs/ai/message-queueing.mdx +6 -6
  9. package/docs/ai/meta.json +1 -0
  10. package/docs/ai/resumable-streams.mdx +28 -28
  11. package/docs/ai/sleep-and-delays.mdx +9 -9
  12. package/docs/ai/streaming-updates-from-tools.mdx +4 -4
  13. package/docs/api-reference/vitest/index.mdx +8 -8
  14. package/docs/api-reference/workflow/create-hook.mdx +15 -15
  15. package/docs/api-reference/workflow/create-webhook.mdx +15 -15
  16. package/docs/api-reference/workflow/define-hook.mdx +10 -10
  17. package/docs/api-reference/workflow/fatal-error.mdx +2 -2
  18. package/docs/api-reference/workflow/fetch.mdx +7 -7
  19. package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
  20. package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
  21. package/docs/api-reference/workflow/get-writable.mdx +7 -7
  22. package/docs/api-reference/workflow/index.mdx +1 -1
  23. package/docs/api-reference/workflow/retryable-error.mdx +1 -1
  24. package/docs/api-reference/workflow/set-attributes.mdx +2 -2
  25. package/docs/api-reference/workflow/sleep.mdx +3 -3
  26. package/docs/api-reference/workflow-ai/durable-agent.mdx +42 -42
  27. package/docs/api-reference/workflow-ai/index.mdx +3 -3
  28. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +28 -28
  29. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +11 -11
  30. package/docs/api-reference/workflow-api/get-run.mdx +10 -10
  31. package/docs/api-reference/workflow-api/index.mdx +2 -4
  32. package/docs/api-reference/workflow-api/resume-hook.mdx +16 -16
  33. package/docs/api-reference/workflow-api/resume-webhook.mdx +4 -4
  34. package/docs/api-reference/workflow-api/start.mdx +16 -15
  35. package/docs/api-reference/workflow-astro/workflow.mdx +3 -3
  36. package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
  37. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +4 -4
  38. package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
  39. package/docs/api-reference/workflow-errors/index.mdx +6 -6
  40. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +9 -9
  41. package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
  42. package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +4 -4
  43. package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
  44. package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
  45. package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
  46. package/docs/api-reference/workflow-errors/workflow-error.mdx +4 -4
  47. package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
  48. package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
  49. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
  50. package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +4 -4
  51. package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
  52. package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +2 -2
  53. package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
  54. package/docs/api-reference/workflow-globals.mdx +12 -11
  55. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +2 -2
  56. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +4 -4
  57. package/docs/api-reference/workflow-nest/workflow-controller.mdx +1 -1
  58. package/docs/api-reference/workflow-nest/workflow-module.mdx +4 -4
  59. package/docs/api-reference/workflow-next/with-workflow.mdx +16 -16
  60. package/docs/api-reference/workflow-nitro/index.mdx +6 -6
  61. package/docs/api-reference/workflow-nuxt/index.mdx +4 -4
  62. package/docs/api-reference/workflow-observability/hydrate-data.mdx +5 -5
  63. package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +4 -4
  64. package/docs/api-reference/workflow-observability/index.mdx +6 -8
  65. package/docs/api-reference/workflow-observability/observability-revivers.mdx +2 -2
  66. package/docs/api-reference/workflow-observability/parse-class-name.mdx +3 -3
  67. package/docs/api-reference/workflow-observability/parse-step-name.mdx +4 -4
  68. package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +4 -4
  69. package/docs/api-reference/workflow-runtime/create-world.mdx +8 -8
  70. package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +6 -6
  71. package/docs/api-reference/workflow-runtime/get-world.mdx +4 -4
  72. package/docs/api-reference/workflow-runtime/health-check.mdx +1 -1
  73. package/docs/api-reference/workflow-runtime/index.mdx +2 -4
  74. package/docs/api-reference/workflow-runtime/set-world.mdx +15 -13
  75. package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +6 -5
  76. package/docs/api-reference/workflow-runtime/world/analytics.mdx +9 -9
  77. package/docs/api-reference/workflow-runtime/world/index.mdx +5 -3
  78. package/docs/api-reference/workflow-runtime/world/queue.mdx +11 -11
  79. package/docs/api-reference/workflow-runtime/world/storage.mdx +62 -28
  80. package/docs/api-reference/workflow-runtime/world/streams.mdx +7 -7
  81. package/docs/api-reference/workflow-serde/index.mdx +1 -1
  82. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +2 -2
  83. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +7 -7
  84. package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +3 -3
  85. package/docs/api-reference/workflow-vite/workflow.mdx +5 -5
  86. package/docs/changelog/attributes-mvp.mdx +39 -39
  87. package/docs/changelog/batched-event-writes.mdx +12 -12
  88. package/docs/changelog/eager-processing.mdx +63 -63
  89. package/docs/changelog/index.mdx +4 -3
  90. package/docs/changelog/lazy-event-creation.md +27 -27
  91. package/docs/changelog/lazy-hook-resume.mdx +51 -0
  92. package/docs/changelog/meta.json +1 -0
  93. package/docs/changelog/resilient-resume.mdx +13 -5
  94. package/docs/changelog/resilient-start.mdx +14 -14
  95. package/docs/changelog/step-message-ownership.mdx +47 -47
  96. package/docs/changelog/turbo-mode.md +20 -20
  97. package/docs/comparisons/index.mdx +13 -13
  98. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +15 -15
  99. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +12 -12
  100. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +11 -11
  101. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +19 -19
  102. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +23 -23
  103. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +18 -17
  104. package/docs/configuration/build-and-diagnostics.mdx +5 -5
  105. package/docs/configuration/cli-and-web-ui.mdx +4 -4
  106. package/docs/configuration/runtime-tuning.mdx +87 -23
  107. package/docs/configuration/worlds.mdx +28 -14
  108. package/docs/cookbook/advanced/child-workflows.mdx +25 -25
  109. package/docs/cookbook/advanced/publishing-libraries.mdx +40 -40
  110. package/docs/cookbook/advanced/serializable-steps.mdx +21 -21
  111. package/docs/cookbook/advanced/upgrading-workflows.mdx +31 -31
  112. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +20 -20
  113. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +22 -22
  114. package/docs/cookbook/common-patterns/batching.mdx +14 -14
  115. package/docs/cookbook/common-patterns/idempotency.mdx +9 -9
  116. package/docs/cookbook/common-patterns/rate-limiting.mdx +3 -3
  117. package/docs/cookbook/common-patterns/saga.mdx +19 -19
  118. package/docs/cookbook/common-patterns/scheduling.mdx +23 -23
  119. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +26 -26
  120. package/docs/cookbook/common-patterns/timeouts.mdx +23 -23
  121. package/docs/cookbook/common-patterns/webhooks.mdx +6 -6
  122. package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -19
  123. package/docs/cookbook/index.mdx +22 -22
  124. package/docs/cookbook/integrations/ai-sdk.mdx +43 -41
  125. package/docs/cookbook/integrations/chat-sdk.mdx +34 -34
  126. package/docs/cookbook/integrations/sandbox.mdx +46 -46
  127. package/docs/deploying.mdx +15 -15
  128. package/docs/errors/abort-signal-timeout-in-workflow.mdx +12 -12
  129. package/docs/errors/corrupted-event-log.mdx +11 -11
  130. package/docs/errors/deployment-mismatch.mdx +14 -14
  131. package/docs/errors/fetch-in-workflow.mdx +8 -8
  132. package/docs/errors/hook-conflict.mdx +11 -11
  133. package/docs/errors/index.mdx +1 -1
  134. package/docs/errors/node-js-module-in-workflow.mdx +5 -5
  135. package/docs/errors/replay-divergence.mdx +2 -2
  136. package/docs/errors/runtime-decryption-failed.mdx +12 -12
  137. package/docs/errors/serialization-failed.mdx +40 -12
  138. package/docs/errors/start-invalid-workflow-function.mdx +5 -5
  139. package/docs/errors/step-executed-multiple-times.mdx +2 -2
  140. package/docs/errors/step-not-registered.mdx +5 -5
  141. package/docs/errors/timeout-in-workflow.mdx +8 -8
  142. package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
  143. package/docs/errors/webhook-response-not-sent.mdx +16 -16
  144. package/docs/errors/workflow-not-registered.mdx +5 -5
  145. package/docs/foundations/cancellation.mdx +31 -31
  146. package/docs/foundations/errors-and-retries.mdx +42 -11
  147. package/docs/foundations/hooks.mdx +35 -35
  148. package/docs/foundations/idempotency.mdx +9 -9
  149. package/docs/foundations/serialization.mdx +21 -22
  150. package/docs/foundations/starting-workflows.mdx +36 -37
  151. package/docs/foundations/streaming.mdx +46 -41
  152. package/docs/foundations/versioning.mdx +3 -3
  153. package/docs/foundations/workflows-and-steps.mdx +9 -9
  154. package/docs/getting-started/astro.mdx +16 -16
  155. package/docs/getting-started/express.mdx +8 -8
  156. package/docs/getting-started/fastify.mdx +8 -8
  157. package/docs/getting-started/hono.mdx +8 -8
  158. package/docs/getting-started/nestjs.mdx +18 -17
  159. package/docs/getting-started/next.mdx +11 -11
  160. package/docs/getting-started/nitro.mdx +16 -16
  161. package/docs/getting-started/nuxt.mdx +8 -8
  162. package/docs/getting-started/python.mdx +4 -4
  163. package/docs/getting-started/react-router/v7.mdx +1 -1
  164. package/docs/getting-started/react-router/v8.mdx +1 -1
  165. package/docs/getting-started/sveltekit.mdx +14 -14
  166. package/docs/getting-started/tanstack-start.mdx +12 -12
  167. package/docs/getting-started/vite.mdx +8 -8
  168. package/docs/how-it-works/cancellation.mdx +62 -62
  169. package/docs/how-it-works/code-transform.mdx +66 -54
  170. package/docs/how-it-works/encryption.mdx +25 -21
  171. package/docs/how-it-works/event-sourcing.mdx +53 -35
  172. package/docs/how-it-works/framework-integrations.mdx +12 -12
  173. package/docs/how-it-works/understanding-directives.mdx +21 -21
  174. package/docs/internal/index.mdx +6 -6
  175. package/docs/internal/nitro-native-build.mdx +2 -2
  176. package/docs/internal/nitro-web-ui.mdx +4 -4
  177. package/docs/internal/serializable-abort-controller.mdx +7 -7
  178. package/docs/observability/attributes.mdx +3 -3
  179. package/docs/observability/index.mdx +14 -10
  180. package/docs/observability/tracing.mdx +10 -10
  181. package/docs/testing/index.mdx +33 -33
  182. package/docs/testing/server-based.mdx +10 -10
  183. package/docs/whats-new.mdx +185 -0
  184. package/package.json +12 -12
@@ -31,8 +31,8 @@ keywords:
31
31
 
32
32
  The World storage interface exposes four sub-interfaces for querying workflow data:
33
33
 
34
- - **`world.events`** The append-only event log. This is the source of truth for all workflow state. See [Event Sourcing](/docs/how-it-works/event-sourcing) for background.
35
- - **`world.runs`**, **`world.steps`**, **`world.hooks`** Materialized views derived from the event log, provided as convenience accessors for the most common query patterns.
34
+ - **`world.events`**: The append-only event log. This is the source of truth for all workflow state. See [Event Sourcing](/docs/how-it-works/event-sourcing) for background.
35
+ - **`world.runs`**, **`world.steps`**, **`world.hooks`**: Materialized views derived from the event log, provided as convenience accessors for the most common query patterns.
36
36
 
37
37
  ```typescript lineNumbers
38
38
  import { getWorld } from "workflow/runtime";
@@ -62,7 +62,7 @@ await world.events.create(runId, { // [!code highlight]
62
62
  | `data` | `CreateEventRequest` | Event data including `eventType` |
63
63
  | `params` | `object` | Optional parameters |
64
64
 
65
- **Returns:** `EventResult` The created event and the affected entity (run/step/hook)
65
+ **Returns:** `EventResult`, the created event and the affected entity (run/step/hook)
66
66
 
67
67
  ### events.get()
68
68
 
@@ -119,7 +119,7 @@ const result = await world.events.listByCorrelationId({ // [!code highlight]
119
119
 
120
120
  **Returns:** `{ data: Event[], cursor?: string }`
121
121
 
122
- ### Event Types
122
+ ### Event types
123
123
 
124
124
  | Category | Types |
125
125
  |----------|-------|
@@ -151,6 +151,40 @@ const run = await world.runs.get(runId); // [!code highlight]
151
151
 
152
152
  **Returns:** `WorkflowRun` (or `WorkflowRunWithoutData` when `resolveData: 'none'`)
153
153
 
154
+ ### runs.waitForTerminalStatus()
155
+
156
+ Optional. Long poll for a run to reach a terminal status (`completed`,
157
+ `failed`, or `cancelled`) instead of re-reading it on an interval. This is what
158
+ `await run.returnValue` uses, so a run's result reaches the awaiting side as
159
+ soon as it finishes rather than at the next poll tick.
160
+
161
+ ```typescript lineNumbers
162
+ const run = await world.runs.waitForTerminalStatus?.(runId, { // [!code highlight]
163
+ timeoutMs: 25_000, // [!code highlight]
164
+ }); // [!code highlight]
165
+ ```
166
+
167
+ | Parameter | Type | Description |
168
+ |-----------|------|-------------|
169
+ | `runId` | `string` | The workflow run ID |
170
+ | `params.timeoutMs` | `number` | Upper bound on the wait. The call returns earlier, the moment the run is terminal |
171
+ | `params.signal` | `AbortSignal` | Abandons the wait |
172
+ | `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
173
+
174
+ **Returns:** the same `WorkflowRun` as `runs.get()`: terminal if the run
175
+ finished within the budget, otherwise the latest snapshot. An expired budget is
176
+ a normal return, not an error, and a missing run throws
177
+ `WorkflowRunNotFoundError` exactly as `runs.get()` does.
178
+
179
+ <Callout>
180
+ Not every backend can hold a read open, so this method is optional and may
181
+ also return a non-terminal snapshot before `timeoutMs` is up. Callers pace
182
+ their own retries (`await run.returnValue` keeps consecutive non-terminal
183
+ observations at least one `WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS` apart), and
184
+ worlds that omit the method are polled on that interval instead. Set
185
+ `WORKFLOW_RETURN_VALUE_LONG_POLL=0` to force interval polling everywhere.
186
+ </Callout>
187
+
154
188
  ### runs.list()
155
189
 
156
190
  ```typescript lineNumbers
@@ -174,13 +208,13 @@ const result = await world.runs.list({ // [!code highlight]
174
208
  reads.
175
209
  </Callout>
176
210
 
177
- ### Cancelling Runs
211
+ ### Cancelling runs
178
212
 
179
- To cancel a run, create a `run_cancelled` event via `world.events.create()` (see [world.events](#worldevents) above), or use the CLI or Web UI helpers.
213
+ To cancel a run, create a `run_cancelled` event through `world.events.create()` (see [world.events](#worldevents) above), or use the Workflow CLI or web interface helpers.
180
214
 
181
215
  To cancel a batch in one call, a world may implement the optional `runs.cancelMany({ runIds })`. It returns a summary plus a per-run outcome (`cancelled`, `already_cancelled`, `not_cancellable`, `not_found`, or `failed`). Backends that omit it fall back to per-run cancellation automatically.
182
216
 
183
- ### WorkflowRun Type
217
+ ### WorkflowRun type
184
218
 
185
219
  | Field | Type | Description |
186
220
  |-------|------|-------------|
@@ -211,7 +245,7 @@ const step = await world.steps.get(runId, stepId); // [!code highlight]
211
245
 
212
246
  | Parameter | Type | Description |
213
247
  |-----------|------|-------------|
214
- | `runId` | `string \| undefined` | The workflow run ID |
248
+ | `runId` | `string` | The workflow run ID that owns the step |
215
249
  | `stepId` | `string` | The step ID |
216
250
  | `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data. Default: `'all'` |
217
251
 
@@ -234,7 +268,7 @@ const result = await world.steps.list({ // [!code highlight]
234
268
 
235
269
  **Returns:** `{ data: Step[], cursor?: string }`
236
270
 
237
- ### Step Type
271
+ ### Step type
238
272
 
239
273
  | Field | Type | Description |
240
274
  |-------|------|-------------|
@@ -251,11 +285,11 @@ const result = await world.steps.list({ // [!code highlight]
251
285
  | `retryAfter` | `string \| null` | ISO timestamp for next retry attempt |
252
286
 
253
287
  <Callout type="info">
254
- Step I/O is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format. Use `hydrateResourceIO()` from `workflow/observability` to deserialize it for display. See [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io).
288
+ Step input/output (I/O) is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format. Use `hydrateResourceIO()` from `workflow/observability` to deserialize it for display. See [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io).
255
289
  </Callout>
256
290
 
257
291
  <Callout type="warn">
258
- `stepName` is a machine-readable identifier like `step//./src/workflows/order//processPayment`. Use `parseStepName()` from `workflow/observability` to extract the `shortName` for UI display.
292
+ `stepName` is a machine-readable identifier like `step//./src/workflows/order//processPayment`. Use `parseStepName()` from `workflow/observability` to extract the `shortName` for display in a user interface.
259
293
  </Callout>
260
294
 
261
295
  ---
@@ -283,7 +317,7 @@ Look up a hook by its token. Useful in webhook resume flows where you receive a
283
317
  <Callout type="info">
284
318
  For runtime application code, prefer [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token). Use `world.hooks.getByToken()` when you are working directly with the World storage interface for custom tooling, admin views, or low-level integrations.
285
319
 
286
- Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's `runId` or resume that hook instead of starting another run. If no hook exists yet, start a workflow that creates the deterministic hook near the beginning and checks `await hook.getConflict()` to detect whether another run claimed the token first on a conflict it resolves with the run that owns the token. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
320
+ Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's `runId` or resume that hook instead of starting another run. If no hook exists yet, start a workflow that creates the deterministic hook near the beginning and checks `await hook.getConflict()` to detect whether another run claimed the token first. On a conflict it resolves with the run that owns the token. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
287
321
  </Callout>
288
322
 
289
323
  ```typescript lineNumbers
@@ -310,7 +344,7 @@ const result = await world.hooks.list({ // [!code highlight]
310
344
 
311
345
  **Returns:** `{ data: Hook[], cursor?: string }`
312
346
 
313
- ### Hook Type
347
+ ### Hook type
314
348
 
315
349
  | Field | Type | Description |
316
350
  |-------|------|-------------|
@@ -327,7 +361,7 @@ const result = await world.hooks.list({ // [!code highlight]
327
361
 
328
362
  ## Examples
329
363
 
330
- ### List Runs with Pagination
364
+ ### List runs with pagination
331
365
 
332
366
  ```typescript lineNumbers
333
367
  import { getWorld } from "workflow/runtime";
@@ -342,23 +376,23 @@ const runs = await world.runs.list({ // [!code highlight]
342
376
  cursor = runs.cursor; // pass to next call for pagination
343
377
  ```
344
378
 
345
- ### Get a Run Full Data vs. Metadata Only
379
+ ### Get a run: full data vs. metadata only
346
380
 
347
381
  ```typescript lineNumbers
348
382
  import { getWorld } from "workflow/runtime";
349
383
 
350
384
  const world = await getWorld();
351
385
 
352
- // Full data (default) includes serialized input/output
386
+ // Full data (default): includes serialized input/output
353
387
  const run = await world.runs.get(runId); // [!code highlight]
354
388
 
355
- // Metadata only lighter, no I/O loaded
389
+ // Metadata only: lighter, no I/O loaded
356
390
  const lightweight = await world.runs.get(runId, { // [!code highlight]
357
391
  resolveData: "none", // [!code highlight]
358
392
  }); // [!code highlight]
359
393
  ```
360
394
 
361
- ### List Steps for a Progress Dashboard
395
+ ### List steps for a progress dashboard
362
396
 
363
397
  ```typescript lineNumbers
364
398
  import { getWorld } from "workflow/runtime";
@@ -380,7 +414,7 @@ const progress = steps.data.map((step) => {
380
414
  });
381
415
  ```
382
416
 
383
- ### Hydrate Step I/O
417
+ ### Hydrate step I/O
384
418
 
385
419
  ```typescript lineNumbers
386
420
  import { getWorld } from "workflow/runtime";
@@ -392,7 +426,7 @@ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highl
392
426
  console.log(hydrated.input, hydrated.output);
393
427
  ```
394
428
 
395
- ### Cancel a Run
429
+ ### Cancel a run
396
430
 
397
431
  ```typescript lineNumbers
398
432
  import { getWorld } from "workflow/runtime";
@@ -403,7 +437,7 @@ await world.events.create(runId, { // [!code highlight]
403
437
  }); // [!code highlight]
404
438
  ```
405
439
 
406
- ### Look Up Hook by Token
440
+ ### Look up hook by token
407
441
 
408
442
  ```typescript lineNumbers
409
443
  import { getWorld } from "workflow/runtime";
@@ -413,7 +447,7 @@ const hook = await world.hooks.getByToken(token); // [!code highlight]
413
447
  console.log(hook.runId, hook.metadata); // [!code highlight]
414
448
  ```
415
449
 
416
- ### List Events for Audit Trail
450
+ ### List events for audit trail
417
451
 
418
452
  ```typescript lineNumbers
419
453
  import { getWorld } from "workflow/runtime";
@@ -428,9 +462,9 @@ for (const event of events.data) {
428
462
 
429
463
  ## Related
430
464
 
431
- - [Event Sourcing](/docs/how-it-works/event-sourcing) How the event log powers workflow replay and state
432
- - [getRun()](/docs/api-reference/workflow-api/get-run) Higher-level API for working with individual runs
433
- - [`workflow/observability`](/docs/api-reference/workflow-observability) Hydrate step I/O and parse display names
434
- - [resumeHook()](/docs/api-reference/workflow-api/resume-hook) Resume a workflow by sending a payload to a hook
435
- - [Hooks](/docs/foundations/hooks) Core concepts for hooks and pause points
436
- - [Workflows and Steps](/docs/foundations/workflows-and-steps) Core concepts for steps
465
+ - [Event sourcing](/docs/how-it-works/event-sourcing): How the event log powers workflow replay and state
466
+ - [`getRun()`](/docs/api-reference/workflow-api/get-run): Higher-level API for working with individual runs
467
+ - [`workflow/observability`](/docs/api-reference/workflow-observability): Hydrate step I/O and parse display names
468
+ - [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook): Resume a workflow by sending a payload to a hook
469
+ - [Hooks](/docs/foundations/hooks): Core concepts for hooks and pause points
470
+ - [Workflows and steps](/docs/foundations/workflows-and-steps): Core concepts for steps
@@ -33,7 +33,7 @@ Stream methods live on `world.streams` (the `streams` sub-object of the `World`
33
33
  import { getWorld } from "workflow/runtime";
34
34
 
35
35
  const world = await getWorld(); // [!code highlight]
36
- // Stream methods are called on world.streams e.g. world.streams.write()
36
+ // Stream methods are called on world.streams, e.g. world.streams.write()
37
37
  ```
38
38
 
39
39
  ## Methods
@@ -56,7 +56,7 @@ await world.streams.write(runId, "default", chunk); // [!code highlight]
56
56
 
57
57
  ### writeMulti()
58
58
 
59
- Write multiple chunks in a single operation. Optional optimization not all World implementations support it. Falls back to sequential `write()` calls if unavailable.
59
+ Write multiple chunks in a single operation. Optional optimization: not all World implementations support it. Falls back to sequential `write()` calls if unavailable.
60
60
 
61
61
  ```typescript lineNumbers
62
62
  await world.streams.writeMulti?.(runId, "default", [chunk1, chunk2]); // [!code highlight]
@@ -173,7 +173,7 @@ const info = await world.streams.getInfo(runId, "default"); // [!code highlight]
173
173
 
174
174
  ## Examples
175
175
 
176
- ### Read a Stream as a Response
176
+ ### Read a stream as a response
177
177
 
178
178
  ```typescript lineNumbers
179
179
  // app/api/workflow-streams/read/route.ts
@@ -192,7 +192,7 @@ export async function GET(req: Request) {
192
192
  }
193
193
  ```
194
194
 
195
- ### Paginate Through Stream Chunks
195
+ ### Paginate through stream chunks
196
196
 
197
197
  ```typescript lineNumbers
198
198
  import { getWorld } from "workflow/runtime";
@@ -211,6 +211,6 @@ do {
211
211
 
212
212
  ## Related
213
213
 
214
- - [Streaming](/docs/foundations/streaming) Core concepts for streaming data from workflows
215
- - [getWritable()](/docs/api-reference/workflow/get-writable) The standard way to write to streams from within steps
216
- - [Storage](/docs/api-reference/workflow-runtime/world/storage) Query runs, steps, hooks, and events
214
+ - [Streaming](/docs/foundations/streaming): Core concepts for streaming data from workflows
215
+ - [`getWritable()`](/docs/api-reference/workflow/get-writable): The standard way to write to streams from within steps
216
+ - [Storage](/docs/api-reference/workflow-runtime/world/storage): Query runs, steps, hooks, and events
@@ -27,7 +27,7 @@ The `@workflow/serde` package provides two symbols that allow you to define cust
27
27
  </Card>
28
28
  </Cards>
29
29
 
30
- ## Quick Example
30
+ ## Quick example
31
31
 
32
32
 
33
33
  ```typescript lineNumbers
@@ -23,7 +23,7 @@ class Point {
23
23
  }
24
24
  ```
25
25
 
26
- ## API Signature
26
+ ## API signature
27
27
 
28
28
  {/* @skip-typecheck: type-only signature snippet, not compilable code */}
29
29
 
@@ -65,5 +65,5 @@ This method runs inside the workflow context and is subject to the same constrai
65
65
  - No non-deterministic operations (like `Math.random()` or `Date.now()`)
66
66
  - No external network calls
67
67
 
68
- Keep this method simple and focused on reconstructing the instance from the provided data.
68
+ Keep this method focused on reconstructing the instance from the provided data.
69
69
  </Callout>
@@ -2,7 +2,7 @@
2
2
  title: WORKFLOW_SERIALIZE
3
3
  ---
4
4
 
5
- A symbol used to define custom serialization for user-defined class instances. The static method should accept an instance and return serializable data.
5
+ `WORKFLOW_SERIALIZE` defines custom serialization for user-defined class instances. The static method accepts an instance and returns serializable data.
6
6
 
7
7
  ## Usage
8
8
 
@@ -23,7 +23,7 @@ class Point {
23
23
  }
24
24
  ```
25
25
 
26
- ## API Signature
26
+ ## API signature
27
27
 
28
28
  {/* @skip-typecheck: type-only signature snippet, not compilable code */}
29
29
 
@@ -60,16 +60,16 @@ The method should return serializable data. This can be:
60
60
  The method must be implemented as a **static** method on the class. Instance methods are not supported.
61
61
  </Callout>
62
62
 
63
- - Both `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` must be implemented together
64
- - The returned data must itself be serializable
65
- - The SWC compiler plugin automatically detects and registers classes that implement these symbols
63
+ - Both `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` must be implemented together.
64
+ - The returned data must itself be serializable.
65
+ - The SWC compiler plugin automatically detects and registers classes that implement these symbols.
66
66
 
67
67
  <Callout type="warn">
68
68
  This method runs inside the workflow context and is subject to the same constraints as `"use workflow"` functions:
69
69
  - No Node.js-specific APIs (like `fs`, `path`, `crypto`, etc.)
70
70
  - No non-deterministic operations (like `Math.random()` or `Date.now()`)
71
71
  - No external network calls
72
- - No side effects on workflow state the method may run outside deterministic replay, so mutations would not be reconstructed
72
+ - No side effects on workflow state: the method may run outside deterministic replay, so mutations would not be reconstructed
73
73
 
74
- Keep this method simple and focused on extracting data from the instance.
74
+ Keep this method focused on extracting data from the instance.
75
75
  </Callout>
@@ -23,7 +23,7 @@ export default defineConfig({
23
23
  });
24
24
  ```
25
25
 
26
- ## API Signature
26
+ ## API signature
27
27
 
28
28
  ### Parameters
29
29
 
@@ -35,8 +35,8 @@ export default defineConfig({
35
35
 
36
36
  | Option | Type | Default | Description |
37
37
  | --- | --- | --- | --- |
38
- | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles helps stay under the Vercel 250MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
38
+ | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
39
39
 
40
40
  ### Returns
41
41
 
42
- Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config Vite flattens nested plugin arrays automatically.
42
+ Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config. Vite flattens nested plugin arrays automatically.
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  });
27
27
  ```
28
28
 
29
- ## API Signature
29
+ ## API signature
30
30
 
31
31
  ### Parameters
32
32
 
@@ -39,10 +39,10 @@ export default defineConfig({
39
39
  | Option | Type | Default | Description |
40
40
  | --- | --- | --- | --- |
41
41
  | `dirs` | `string[]` | — | Directories to scan for workflows and steps. By default, the `workflows/` directory is scanned from the project root and all layer source directories. |
42
- | `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. |
43
- | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). Only applies when deploying to Vercel. |
44
- | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles helps stay under the Vercel 250MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
42
+ | `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for integrated development environment (IDE) IntelliSense. |
43
+ | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (for example, `'nodejs22.x'` or `'nodejs24.x'`). Only applies when deploying to Vercel. |
44
+ | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
45
45
 
46
46
  ### Returns
47
47
 
48
- Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config Vite flattens nested plugin arrays automatically.
48
+ Returns an array of Vite `Plugin` objects. Spread or pass the array directly to the `plugins` option of your Vite config. Vite flattens nested plugin arrays automatically.