workflow 5.0.0-beta.4 → 5.0.0-beta.40

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 (227) hide show
  1. package/README.md +63 -20
  2. package/dist/api-workflow.d.ts +1 -1
  3. package/dist/api-workflow.d.ts.map +1 -1
  4. package/dist/api-workflow.js +1 -1
  5. package/dist/api.d.ts +5 -1
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.js +12 -2
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +6 -1
  11. package/dist/internal/builtins.d.ts +17 -0
  12. package/dist/internal/builtins.d.ts.map +1 -1
  13. package/dist/internal/builtins.js +65 -1
  14. package/dist/internal/errors.d.ts +1 -1
  15. package/dist/internal/errors.d.ts.map +1 -1
  16. package/dist/internal/errors.js +2 -2
  17. package/dist/nest-builder.d.ts +2 -0
  18. package/dist/nest-builder.d.ts.map +1 -0
  19. package/dist/nest-builder.js +2 -0
  20. package/dist/nest-vercel-builder.d.ts +2 -0
  21. package/dist/nest-vercel-builder.d.ts.map +1 -0
  22. package/dist/nest-vercel-builder.js +2 -0
  23. package/dist/observability.d.ts +1 -1
  24. package/dist/observability.js +2 -2
  25. package/dist/runtime.d.ts +2 -1
  26. package/dist/runtime.d.ts.map +1 -1
  27. package/dist/runtime.js +5 -2
  28. package/docs/ai/chat-session-modeling.mdx +7 -3
  29. package/docs/ai/defining-tools.mdx +2 -2
  30. package/docs/ai/index.mdx +30 -25
  31. package/docs/ai/message-queueing.mdx +10 -10
  32. package/docs/ai/resumable-streams.mdx +9 -1
  33. package/docs/api-reference/index.mdx +24 -0
  34. package/docs/api-reference/meta.json +8 -0
  35. package/docs/api-reference/vitest/index.mdx +28 -7
  36. package/docs/api-reference/workflow/create-hook.mdx +79 -0
  37. package/docs/api-reference/workflow/create-webhook.mdx +1 -0
  38. package/docs/api-reference/workflow/define-hook.mdx +26 -24
  39. package/docs/api-reference/workflow/fatal-error.mdx +29 -7
  40. package/docs/api-reference/workflow/fetch.mdx +8 -4
  41. package/docs/api-reference/workflow/index.mdx +3 -0
  42. package/docs/api-reference/workflow/set-attributes.mdx +61 -0
  43. package/docs/api-reference/workflow/sleep.mdx +1 -1
  44. package/docs/api-reference/workflow-ai/durable-agent.mdx +7 -45
  45. package/docs/api-reference/workflow-ai/index.mdx +2 -2
  46. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +44 -1
  47. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +9 -0
  48. package/docs/api-reference/workflow-api/get-run.mdx +25 -0
  49. package/docs/api-reference/workflow-api/index.mdx +6 -8
  50. package/docs/api-reference/workflow-api/resume-hook.mdx +60 -1
  51. package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
  52. package/docs/api-reference/workflow-api/start.mdx +39 -6
  53. package/docs/api-reference/workflow-astro/index.mdx +18 -0
  54. package/docs/api-reference/workflow-astro/meta.json +4 -0
  55. package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
  56. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  57. package/docs/api-reference/workflow-errors/index.mdx +88 -0
  58. package/docs/api-reference/workflow-errors/meta.json +6 -0
  59. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
  60. package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  61. package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
  62. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +16 -6
  63. package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  64. package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  65. package/docs/api-reference/workflow-globals.mdx +4 -1
  66. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  67. package/docs/api-reference/workflow-nest/index.mdx +31 -0
  68. package/docs/api-reference/workflow-nest/meta.json +9 -0
  69. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
  70. package/docs/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  71. package/docs/api-reference/workflow-nest/workflow-module.mdx +74 -0
  72. package/docs/api-reference/workflow-next/with-workflow.mdx +56 -2
  73. package/docs/api-reference/workflow-nitro/index.mdx +60 -0
  74. package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
  75. package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  76. package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  77. package/docs/api-reference/workflow-observability/index.mdx +64 -0
  78. package/docs/api-reference/workflow-observability/meta.json +11 -0
  79. package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  80. package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  81. package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  82. package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  83. package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
  84. package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  85. package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +7 -10
  86. package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
  87. package/docs/api-reference/workflow-runtime/index.mdx +43 -0
  88. package/docs/api-reference/workflow-runtime/meta.json +12 -0
  89. package/docs/api-reference/workflow-runtime/set-world.mdx +49 -0
  90. package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
  91. package/docs/api-reference/workflow-runtime/world/analytics.mdx +138 -0
  92. package/docs/api-reference/{workflow-api → workflow-runtime}/world/index.mdx +10 -10
  93. package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
  94. package/docs/api-reference/{workflow-api → workflow-runtime}/world/queue.mdx +8 -6
  95. package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +18 -5
  96. package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +2 -2
  97. package/docs/api-reference/workflow-serde/index.mdx +0 -1
  98. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +1 -2
  99. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +2 -2
  100. package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
  101. package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
  102. package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
  103. package/docs/api-reference/workflow-vite/index.mdx +18 -0
  104. package/docs/api-reference/workflow-vite/meta.json +4 -0
  105. package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
  106. package/docs/changelog/attributes-mvp.mdx +380 -0
  107. package/docs/changelog/eager-processing.mdx +269 -0
  108. package/docs/changelog/index.mdx +3 -1
  109. package/docs/changelog/lazy-event-creation.md +127 -0
  110. package/docs/changelog/meta.json +9 -1
  111. package/docs/changelog/resilient-resume.mdx +22 -0
  112. package/docs/changelog/resilient-start.mdx +31 -283
  113. package/docs/changelog/step-message-ownership.mdx +360 -0
  114. package/docs/changelog/turbo-mode.md +87 -0
  115. package/docs/comparisons/index.mdx +66 -0
  116. package/docs/comparisons/meta.json +11 -0
  117. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
  118. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
  119. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
  120. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
  121. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
  122. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +103 -0
  123. package/docs/configuration/build-and-diagnostics.mdx +70 -0
  124. package/docs/configuration/cli-and-web-ui.mdx +182 -0
  125. package/docs/configuration/framework-options.mdx +165 -0
  126. package/docs/configuration/index.mdx +32 -0
  127. package/docs/configuration/meta.json +12 -0
  128. package/docs/configuration/runtime-tuning.mdx +276 -0
  129. package/docs/configuration/worlds.mdx +275 -0
  130. package/docs/cookbook/advanced/child-workflows.mdx +203 -256
  131. package/docs/cookbook/advanced/meta.json +1 -1
  132. package/docs/cookbook/advanced/publishing-libraries.mdx +33 -24
  133. package/docs/cookbook/advanced/serializable-steps.mdx +12 -4
  134. package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
  135. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +34 -75
  136. package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
  137. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +11 -3
  138. package/docs/cookbook/common-patterns/batching.mdx +4 -0
  139. package/docs/cookbook/common-patterns/idempotency.mdx +40 -52
  140. package/docs/cookbook/common-patterns/rate-limiting.mdx +5 -1
  141. package/docs/cookbook/common-patterns/saga.mdx +6 -2
  142. package/docs/cookbook/common-patterns/scheduling.mdx +12 -0
  143. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +4 -0
  144. package/docs/cookbook/common-patterns/timeouts.mdx +6 -1
  145. package/docs/cookbook/common-patterns/webhooks.mdx +4 -0
  146. package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -16
  147. package/docs/cookbook/index.mdx +3 -3
  148. package/docs/cookbook/integrations/ai-sdk.mdx +64 -28
  149. package/docs/cookbook/integrations/chat-sdk.mdx +17 -0
  150. package/docs/cookbook/integrations/sandbox.mdx +17 -0
  151. package/docs/{deploying/index.mdx → deploying.mdx} +7 -7
  152. package/docs/errors/abort-signal-timeout-in-workflow.mdx +84 -0
  153. package/docs/errors/corrupted-event-log.mdx +5 -5
  154. package/docs/errors/deployment-mismatch.mdx +71 -0
  155. package/docs/errors/fetch-in-workflow.mdx +4 -0
  156. package/docs/errors/hook-conflict.mdx +60 -4
  157. package/docs/errors/index.mdx +1 -35
  158. package/docs/errors/node-js-module-in-workflow.mdx +4 -0
  159. package/docs/errors/replay-divergence.mdx +27 -0
  160. package/docs/errors/runtime-decryption-failed.mdx +77 -0
  161. package/docs/errors/serialization-failed.mdx +4 -0
  162. package/docs/errors/start-invalid-workflow-function.mdx +4 -0
  163. package/docs/errors/step-executed-multiple-times.mdx +23 -0
  164. package/docs/errors/step-not-registered.mdx +1 -1
  165. package/docs/errors/timeout-in-workflow.mdx +4 -0
  166. package/docs/errors/webhook-response-not-sent.mdx +4 -0
  167. package/docs/foundations/cancellation.mdx +459 -0
  168. package/docs/foundations/errors-and-retries.mdx +7 -3
  169. package/docs/foundations/hooks.mdx +29 -0
  170. package/docs/foundations/idempotency.mdx +243 -11
  171. package/docs/foundations/index.mdx +1 -23
  172. package/docs/foundations/meta.json +3 -1
  173. package/docs/foundations/serialization.mdx +77 -41
  174. package/docs/foundations/starting-workflows.mdx +79 -2
  175. package/docs/foundations/streaming.mdx +14 -23
  176. package/docs/foundations/versioning.mdx +263 -0
  177. package/docs/getting-started/astro.mdx +12 -2
  178. package/docs/getting-started/express.mdx +6 -2
  179. package/docs/getting-started/fastify.mdx +6 -2
  180. package/docs/getting-started/hono.mdx +6 -2
  181. package/docs/getting-started/index.mdx +16 -10
  182. package/docs/getting-started/meta.json +4 -1
  183. package/docs/getting-started/nestjs.mdx +77 -3
  184. package/docs/getting-started/next.mdx +12 -6
  185. package/docs/getting-started/nitro.mdx +28 -2
  186. package/docs/getting-started/nuxt.mdx +6 -2
  187. package/docs/getting-started/python.mdx +24 -18
  188. package/docs/getting-started/react-router/index.mdx +33 -0
  189. package/docs/getting-started/react-router/meta.json +5 -0
  190. package/docs/getting-started/react-router/v7.mdx +237 -0
  191. package/docs/getting-started/react-router/v8.mdx +232 -0
  192. package/docs/getting-started/sveltekit.mdx +12 -2
  193. package/docs/getting-started/tanstack-start.mdx +245 -0
  194. package/docs/getting-started/vite.mdx +6 -2
  195. package/docs/how-it-works/cancellation.mdx +287 -0
  196. package/docs/how-it-works/code-transform.mdx +21 -17
  197. package/docs/how-it-works/encryption.mdx +5 -5
  198. package/docs/how-it-works/event-sourcing.mdx +6 -6
  199. package/docs/how-it-works/framework-integrations.mdx +96 -337
  200. package/docs/how-it-works/meta.json +2 -1
  201. package/docs/internal/index.mdx +21 -0
  202. package/docs/internal/meta.json +10 -0
  203. package/docs/internal/nitro-native-build.mdx +38 -0
  204. package/docs/internal/nitro-web-ui.mdx +24 -0
  205. package/docs/internal/serializable-abort-controller.mdx +148 -0
  206. package/docs/meta.json +2 -2
  207. package/docs/observability/attributes.mdx +112 -0
  208. package/docs/observability/index.mdx +20 -1
  209. package/docs/observability/meta.json +1 -1
  210. package/docs/observability/tracing.mdx +124 -0
  211. package/docs/testing/index.mdx +2 -2
  212. package/package.json +17 -13
  213. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  214. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
  215. package/docs/cookbook/advanced/distributed-abort-controller.mdx +0 -318
  216. package/docs/deploying/building-a-world.mdx +0 -251
  217. package/docs/deploying/meta.json +0 -4
  218. package/docs/deploying/world/local-world.mdx +0 -84
  219. package/docs/deploying/world/meta.json +0 -4
  220. package/docs/deploying/world/postgres-world.mdx +0 -222
  221. package/docs/deploying/world/vercel-world.mdx +0 -179
  222. package/docs/migration-guides/index.mdx +0 -34
  223. package/docs/migration-guides/meta.json +0 -9
  224. package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -363
  225. package/docs/migration-guides/migrating-from-inngest.mdx +0 -314
  226. package/docs/migration-guides/migrating-from-temporal.mdx +0 -318
  227. package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -337
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  title: Queue
3
- description: Low-level queue interface for dispatching workflow and step invocations.
3
+ description: Low-level queue interface for dispatching workflow invocations.
4
4
  type: reference
5
5
  summary: "Methods: getDeploymentId(), queue(), createQueueHandler(). Internal queue dispatch — normally handled by the SDK."
6
6
  prerequisites:
7
- - /docs/api-reference/workflow-api/get-world
7
+ - /docs/api-reference/workflow-runtime/get-world
8
8
  related:
9
9
  - /docs/api-reference/workflow-api/start
10
10
  - /docs/foundations/starting-workflows
@@ -17,10 +17,10 @@ keywords:
17
17
  - queue dispatch
18
18
  ---
19
19
 
20
- Queue methods live directly on the `world` object (not nested). They dispatch internal workflow and step invocations to the queue backend.
20
+ Queue methods live directly on the `world` object (not nested). They dispatch internal workflow invocations, including queued step work, to the queue backend.
21
21
 
22
22
  <Callout type="warn">
23
- These methods are used internally by the Workflow SDK to dispatch execution. You do not need to call them in normal operations — use [`start()`](/docs/api-reference/workflow-api/start) to trigger workflows instead. Direct queue access is only needed if you programmatically create a run via `world.events.create()` with a `run_created` event and need to kick off its initial execution, or for debugging resumption of a flow or step route.
23
+ These methods are used internally by the Workflow SDK to dispatch execution. You do not need to call them in normal operations — use [`start()`](/docs/api-reference/workflow-api/start) to trigger workflows instead. Direct queue access is only needed if you programmatically create a run via `world.events.create()` with a `run_created` event and need to kick off its initial execution, or for debugging flow resumption.
24
24
  </Callout>
25
25
 
26
26
  ## Import
@@ -46,7 +46,7 @@ const deploymentId = await world.getDeploymentId(); // [!code highlight]
46
46
 
47
47
  ### queue()
48
48
 
49
- Dispatch a message to a named queue. The message payload is an internal SDK type (`WorkflowInvokePayload`, `StepInvokePayload`, or `HealthCheckPayload`).
49
+ Dispatch a message to a named queue. The message payload is an internal SDK type (`WorkflowInvokePayload` or `HealthCheckPayload`). Queued steps use `WorkflowInvokePayload` with `stepId` and `stepName`.
50
50
 
51
51
  ```typescript lineNumbers
52
52
  const { messageId } = await world.queue(queueName, payload, opts); // [!code highlight]
@@ -79,8 +79,10 @@ const handler = world.createQueueHandler(prefix, callback); // [!code highlight]
79
79
 
80
80
  **Returns:** `(req: Request) => Promise<Response>`
81
81
 
82
+ `meta.messageId` should be stable across redeliveries of the same message (one ID per enqueued message, reused on every delivery attempt). The runtime records it on inline `step_started` events as a liveness lease so that only a redelivery of the owning message re-executes a crashed inline step before the lease expires (see [Inline step message ownership](/v5/docs/changelog/step-message-ownership)). A World whose queue mints a fresh ID per delivery degrades gracefully — crashed inline steps recover via the delayed backstop instead of immediately on redelivery — but never wedges or duplicates.
83
+
82
84
  ## Related
83
85
 
84
86
  - [start()](/docs/api-reference/workflow-api/start) — The standard way to start workflow runs
85
87
  - [Starting Workflows](/docs/foundations/starting-workflows) — Core concepts for workflow invocation
86
- - [Storage](/docs/api-reference/workflow-api/world/storage) — Create events that trigger queue dispatch
88
+ - [Storage](/docs/api-reference/workflow-runtime/world/storage) — Create events that trigger queue dispatch
@@ -4,11 +4,11 @@ description: Query workflow runs, steps, hooks, and the underlying event log via
4
4
  type: reference
5
5
  summary: "Interfaces: world.events, world.runs, world.steps, world.hooks. Events are the source of truth; runs, steps, and hooks are materialized views."
6
6
  prerequisites:
7
- - /docs/api-reference/workflow-api/get-world
7
+ - /docs/api-reference/workflow-runtime/get-world
8
8
  related:
9
9
  - /docs/api-reference/workflow-api/get-run
10
10
  - /docs/how-it-works/event-sourcing
11
- - /docs/api-reference/workflow-api/world/observability
11
+ - /docs/api-reference/workflow-observability
12
12
  keywords:
13
13
  - world.events
14
14
  - world.runs
@@ -96,16 +96,20 @@ const result = await world.events.list({ runId, pagination: { cursor } }); // [!
96
96
 
97
97
  ### events.listByCorrelationId()
98
98
 
99
- List events that share a correlation ID, useful for tracing related events across runs.
99
+ List one run's events that share a correlation ID, useful for tracing a single step, hook or wait through its lifecycle.
100
+
101
+ A correlation ID is unique within its run, not across runs: two runs can each hold a `step_…`, `hook_…` or `wait_…` ID that reads the same. `runId` is therefore required, and it is also what makes the pagination cursor unambiguous.
100
102
 
101
103
  ```typescript lineNumbers
102
104
  const result = await world.events.listByCorrelationId({ // [!code highlight]
105
+ runId,
103
106
  correlationId: "order-123",
104
107
  }); // [!code highlight]
105
108
  ```
106
109
 
107
110
  | Parameter | Type | Description |
108
111
  |-----------|------|-------------|
112
+ | `params.runId` | `string` | The run the correlation ID belongs to |
109
113
  | `params.correlationId` | `string` | The correlation ID to filter by |
110
114
  | `params.pagination.cursor` | `string` | Cursor for the next page |
111
115
 
@@ -116,6 +120,7 @@ const result = await world.events.listByCorrelationId({ // [!code highlight]
116
120
  | Category | Types |
117
121
  |----------|-------|
118
122
  | Run | `run_created`, `run_started`, `run_completed`, `run_failed`, `run_cancelled` |
123
+ | Attribute | `attr_set` |
119
124
  | Step | `step_created`, `step_started`, `step_completed`, `step_failed`, `step_retrying` |
120
125
  | Hook | `hook_created`, `hook_received`, `hook_disposed`, `hook_conflict` |
121
126
  | Wait | `wait_created`, `wait_completed` |
@@ -158,6 +163,8 @@ const result = await world.runs.list({ // [!code highlight]
158
163
 
159
164
  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.
160
165
 
166
+ 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.
167
+
161
168
  ### WorkflowRun Type
162
169
 
163
170
  | Field | Type | Description |
@@ -229,7 +236,7 @@ const result = await world.steps.list({ // [!code highlight]
229
236
  | `retryAfter` | `string \| null` | ISO timestamp for next retry attempt |
230
237
 
231
238
  <Callout type="info">
232
- 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 [Observability Utilities](/docs/api-reference/workflow-api/world/observability).
239
+ 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).
233
240
  </Callout>
234
241
 
235
242
  <Callout type="warn">
@@ -258,6 +265,12 @@ const hook = await world.hooks.get(hookId); // [!code highlight]
258
265
 
259
266
  Look up a hook by its token. Useful in webhook resume flows where you receive a token in the callback URL.
260
267
 
268
+ <Callout type="info">
269
+ 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.
270
+
271
+ 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).
272
+ </Callout>
273
+
261
274
  ```typescript lineNumbers
262
275
  const hook = await world.hooks.getByToken(token); // [!code highlight]
263
276
  ```
@@ -402,7 +415,7 @@ for (const event of events.data) {
402
415
 
403
416
  - [Event Sourcing](/docs/how-it-works/event-sourcing) — How the event log powers workflow replay and state
404
417
  - [getRun()](/docs/api-reference/workflow-api/get-run) — Higher-level API for working with individual runs
405
- - [Observability Utilities](/docs/api-reference/workflow-api/world/observability) — Hydrate step I/O, parse display names, decrypt data
418
+ - [`workflow/observability`](/docs/api-reference/workflow-observability) — Hydrate step I/O and parse display names
406
419
  - [resumeHook()](/docs/api-reference/workflow-api/resume-hook) — Resume a workflow by sending a payload to a hook
407
420
  - [Hooks](/docs/foundations/hooks) — Core concepts for hooks and pause points
408
421
  - [Workflows and Steps](/docs/foundations/workflows-and-steps) — Core concepts for steps
@@ -4,7 +4,7 @@ description: Read, write, and manage real-time data streams for workflow runs.
4
4
  type: reference
5
5
  summary: "Methods: streams.write(), streams.writeMulti(), streams.get(), streams.close(), streams.list(), streams.getChunks(), streams.getInfo(). Stream methods live on world.streams."
6
6
  prerequisites:
7
- - /docs/api-reference/workflow-api/get-world
7
+ - /docs/api-reference/workflow-runtime/get-world
8
8
  related:
9
9
  - /docs/foundations/streaming
10
10
  - /docs/api-reference/workflow/get-writable
@@ -213,4 +213,4 @@ do {
213
213
 
214
214
  - [Streaming](/docs/foundations/streaming) — Core concepts for streaming data from workflows
215
215
  - [getWritable()](/docs/api-reference/workflow/get-writable) — The standard way to write to streams from within steps
216
- - [Storage](/docs/api-reference/workflow-api/world/storage) — Query runs, steps, hooks, and events
216
+ - [Storage](/docs/api-reference/workflow-runtime/world/storage) — Query runs, steps, hooks, and events
@@ -29,7 +29,6 @@ The `@workflow/serde` package provides two symbols that allow you to define cust
29
29
 
30
30
  ## Quick Example
31
31
 
32
- {/* @expect-error:2351 */}
33
32
 
34
33
  ```typescript lineNumbers
35
34
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
@@ -6,7 +6,6 @@ A symbol used to define custom deserialization for user-defined class instances.
6
6
 
7
7
  ## Usage
8
8
 
9
- {/* @expect-error:2351 */}
10
9
 
11
10
  ```typescript lineNumbers
12
11
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
@@ -26,7 +25,7 @@ class Point {
26
25
 
27
26
  ## API Signature
28
27
 
29
- {/* @skip-typecheck */}
28
+ {/* @skip-typecheck: type-only signature snippet, not compilable code */}
30
29
 
31
30
  ```typescript
32
31
  static [WORKFLOW_DESERIALIZE](data: SerializableData): T
@@ -6,7 +6,6 @@ A symbol used to define custom serialization for user-defined class instances. T
6
6
 
7
7
  ## Usage
8
8
 
9
- {/* @expect-error:2351 */}
10
9
 
11
10
  ```typescript lineNumbers
12
11
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from "@workflow/serde";
@@ -26,7 +25,7 @@ class Point {
26
25
 
27
26
  ## API Signature
28
27
 
29
- {/* @skip-typecheck */}
28
+ {/* @skip-typecheck: type-only signature snippet, not compilable code */}
30
29
 
31
30
  ```typescript
32
31
  static [WORKFLOW_SERIALIZE](instance: T): SerializableData
@@ -70,6 +69,7 @@ This method runs inside the workflow context and is subject to the same constrai
70
69
  - No Node.js-specific APIs (like `fs`, `path`, `crypto`, etc.)
71
70
  - No non-deterministic operations (like `Math.random()` or `Date.now()`)
72
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
73
73
 
74
74
  Keep this method simple and focused on extracting data from the instance.
75
75
  </Callout>
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: "workflow/sveltekit"
3
+ description: SvelteKit integration for automatic workflow bundling via Vite.
4
+ type: overview
5
+ summary: Explore the SvelteKit integration for automatic workflow bundling and runtime support.
6
+ related:
7
+ - /docs/getting-started/sveltekit
8
+ ---
9
+
10
+ SvelteKit integration for Workflow SDK that configures Vite to transform workflow code and build the workflow bundles.
11
+
12
+ ## Functions
13
+
14
+ <Cards>
15
+ <Card title="workflowPlugin()" href="/docs/api-reference/workflow-sveltekit/workflow-plugin">
16
+ Vite plugin that transforms workflow code (`"use step"`/`"use workflow"` directives) in SvelteKit apps
17
+ </Card>
18
+ </Cards>
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "workflow/sveltekit",
3
+ "pages": ["workflow-plugin"]
4
+ }
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: workflowPlugin
3
+ description: Configure Vite to transform workflow directives in SvelteKit.
4
+ type: reference
5
+ summary: Add workflowPlugin to your Vite config to enable workflow directive transformation in SvelteKit apps.
6
+ prerequisites:
7
+ - /docs/getting-started/sveltekit
8
+ ---
9
+
10
+ Returns the Vite plugins that transform workflow code (`"use step"`/`"use workflow"` directives) and build the workflow bundles in a SvelteKit app.
11
+
12
+ ## Usage
13
+
14
+ To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, add `workflowPlugin()` to the `plugins` array of your Vite config.
15
+
16
+ ```typescript title="vite.config.ts" lineNumbers
17
+ import { sveltekit } from "@sveltejs/kit/vite";
18
+ import { defineConfig } from "vite";
19
+ import { workflowPlugin } from "workflow/sveltekit"; // [!code highlight]
20
+
21
+ export default defineConfig({
22
+ plugins: [sveltekit(), workflowPlugin()], // [!code highlight]
23
+ });
24
+ ```
25
+
26
+ ## API Signature
27
+
28
+ ### Parameters
29
+
30
+ | Parameter | Type | Description |
31
+ | --- | --- | --- |
32
+ | `options` | `WorkflowPluginOptions` | Optional. Configures the workflow build. |
33
+
34
+ #### WorkflowPluginOptions
35
+
36
+ | Option | Type | Default | Description |
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. |
39
+
40
+ ### Returns
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.
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: "workflow/vite"
3
+ description: Vite plugin for automatic workflow bundling in Vite + Nitro apps.
4
+ type: overview
5
+ summary: Explore the Vite plugin for automatic workflow bundling and runtime support.
6
+ related:
7
+ - /docs/getting-started/vite
8
+ ---
9
+
10
+ Vite integration for Workflow SDK. It wraps the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module as a Vite plugin, for apps using Nitro's Vite plugin (`nitro/vite`).
11
+
12
+ ## Functions
13
+
14
+ <Cards>
15
+ <Card title="workflow()" href="/docs/api-reference/workflow-vite/workflow">
16
+ Vite plugin that transforms workflow code (`"use step"`/`"use workflow"` directives) and configures the Nitro server
17
+ </Card>
18
+ </Cards>
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "workflow/vite",
3
+ "pages": ["workflow"]
4
+ }
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: workflow
3
+ description: Configure Vite and Nitro to transform workflow directives.
4
+ type: reference
5
+ summary: Add the workflow plugin to your Vite config to enable workflow directive transformation in Vite + Nitro apps.
6
+ prerequisites:
7
+ - /docs/getting-started/vite
8
+ ---
9
+
10
+ Returns the Vite plugins that transform workflow code (`"use step"`/`"use workflow"` directives) and configure the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module on the Nitro server. It is designed to be used alongside `nitro()` from `nitro/vite`, which provides the server framework for API routes and deployment.
11
+
12
+ ## Usage
13
+
14
+ To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, add `workflow()` to the `plugins` array of your Vite config, together with `nitro()`.
15
+
16
+ ```typescript title="vite.config.ts" lineNumbers
17
+ import { nitro } from "nitro/vite";
18
+ import { defineConfig } from "vite";
19
+ import { workflow } from "workflow/vite"; // [!code highlight]
20
+
21
+ export default defineConfig({
22
+ plugins: [nitro(), workflow()], // [!code highlight]
23
+ nitro: {
24
+ serverDir: "./",
25
+ },
26
+ });
27
+ ```
28
+
29
+ ## API Signature
30
+
31
+ ### Parameters
32
+
33
+ | Parameter | Type | Description |
34
+ | --- | --- | --- |
35
+ | `options` | `ModuleOptions` | Optional. Forwarded to the `workflow/nitro` module as its module options. |
36
+
37
+ #### ModuleOptions
38
+
39
+ | Option | Type | Default | Description |
40
+ | --- | --- | --- | --- |
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. |
45
+
46
+ ### Returns
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.