workflow 4.4.0 → 4.5.0

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 (110) hide show
  1. package/docs/api-reference/index.mdx +24 -0
  2. package/docs/api-reference/meta.json +8 -0
  3. package/docs/api-reference/vitest/index.mdx +0 -6
  4. package/docs/api-reference/workflow/create-hook.mdx +32 -0
  5. package/docs/api-reference/workflow/create-webhook.mdx +1 -0
  6. package/docs/api-reference/workflow-api/index.mdx +6 -8
  7. package/docs/api-reference/workflow-errors/meta.json +5 -0
  8. package/docs/api-reference/workflow-serde/index.mdx +0 -1
  9. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +1 -2
  10. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +1 -2
  11. package/docs/deploying/world/vercel-world.mdx +2 -0
  12. package/docs/errors/index.mdx +3 -0
  13. package/docs/foundations/hooks.mdx +29 -0
  14. package/docs/foundations/streaming.mdx +7 -1
  15. package/docs/foundations/versioning.mdx +1 -1
  16. package/docs/how-it-works/encryption.mdx +2 -2
  17. package/docs/how-it-works/event-sourcing.mdx +2 -2
  18. package/docs/v4/api-reference/workflow-astro/index.mdx +18 -0
  19. package/docs/v4/api-reference/workflow-astro/meta.json +4 -0
  20. package/docs/v4/api-reference/workflow-astro/workflow.mdx +37 -0
  21. package/docs/v4/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  22. package/docs/v4/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  23. package/docs/v4/api-reference/workflow-errors/workflow-error.mdx +52 -0
  24. package/docs/v4/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  25. package/docs/v4/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  26. package/docs/v4/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  27. package/docs/v4/api-reference/workflow-nest/index.mdx +31 -0
  28. package/docs/v4/api-reference/workflow-nest/meta.json +9 -0
  29. package/docs/v4/api-reference/workflow-nest/nest-local-builder.mdx +63 -0
  30. package/docs/v4/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  31. package/docs/v4/api-reference/workflow-nest/workflow-module.mdx +73 -0
  32. package/docs/v4/api-reference/workflow-nitro/index.mdx +57 -0
  33. package/docs/v4/api-reference/workflow-nuxt/index.mdx +47 -0
  34. package/docs/v4/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  35. package/docs/v4/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  36. package/docs/v4/api-reference/workflow-observability/index.mdx +64 -0
  37. package/docs/v4/api-reference/workflow-observability/meta.json +11 -0
  38. package/docs/v4/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  39. package/docs/v4/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  40. package/docs/v4/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  41. package/docs/v4/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  42. package/docs/v4/api-reference/workflow-runtime/create-world.mdx +43 -0
  43. package/docs/v4/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  44. package/docs/v4/api-reference/workflow-runtime/get-world.mdx +124 -0
  45. package/docs/v4/api-reference/workflow-runtime/health-check.mdx +50 -0
  46. package/docs/v4/api-reference/workflow-runtime/index.mdx +46 -0
  47. package/docs/v4/api-reference/workflow-runtime/meta.json +13 -0
  48. package/docs/v4/api-reference/workflow-runtime/set-world.mdx +49 -0
  49. package/docs/v4/api-reference/workflow-runtime/step-entrypoint.mdx +39 -0
  50. package/docs/v4/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
  51. package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/index.mdx +5 -8
  52. package/docs/v4/api-reference/workflow-runtime/world/meta.json +4 -0
  53. package/docs/v4/api-reference/workflow-runtime/world/queue.mdx +86 -0
  54. package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/storage.mdx +4 -4
  55. package/docs/v4/api-reference/workflow-runtime/world/streams.mdx +216 -0
  56. package/docs/v4/api-reference/workflow-sveltekit/index.mdx +18 -0
  57. package/docs/v4/api-reference/workflow-sveltekit/meta.json +4 -0
  58. package/docs/v4/api-reference/workflow-sveltekit/workflow-plugin.mdx +34 -0
  59. package/docs/v4/api-reference/workflow-vite/index.mdx +18 -0
  60. package/docs/v4/api-reference/workflow-vite/meta.json +4 -0
  61. package/docs/v4/api-reference/workflow-vite/workflow.mdx +47 -0
  62. package/docs/v4/errors/step-executed-multiple-times.mdx +23 -0
  63. package/docs/v5/api-reference/workflow-astro/index.mdx +18 -0
  64. package/docs/v5/api-reference/workflow-astro/meta.json +4 -0
  65. package/docs/v5/api-reference/workflow-astro/workflow.mdx +45 -0
  66. package/docs/v5/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  67. package/docs/v5/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  68. package/docs/v5/api-reference/workflow-errors/workflow-error.mdx +52 -0
  69. package/docs/v5/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  70. package/docs/v5/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  71. package/docs/v5/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  72. package/docs/v5/api-reference/workflow-nest/index.mdx +31 -0
  73. package/docs/v5/api-reference/workflow-nest/meta.json +9 -0
  74. package/docs/v5/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
  75. package/docs/v5/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  76. package/docs/v5/api-reference/workflow-nest/workflow-module.mdx +74 -0
  77. package/docs/v5/api-reference/workflow-nitro/index.mdx +59 -0
  78. package/docs/v5/api-reference/workflow-nuxt/index.mdx +47 -0
  79. package/docs/v5/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  80. package/docs/v5/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  81. package/docs/v5/api-reference/workflow-observability/index.mdx +64 -0
  82. package/docs/v5/api-reference/workflow-observability/meta.json +11 -0
  83. package/docs/v5/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  84. package/docs/v5/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  85. package/docs/v5/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  86. package/docs/v5/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  87. package/docs/v5/api-reference/workflow-runtime/create-world.mdx +39 -0
  88. package/docs/v5/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  89. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/get-world.mdx +7 -10
  90. package/docs/v5/api-reference/workflow-runtime/health-check.mdx +50 -0
  91. package/docs/v5/api-reference/workflow-runtime/index.mdx +43 -0
  92. package/docs/v5/api-reference/workflow-runtime/meta.json +12 -0
  93. package/docs/v5/api-reference/workflow-runtime/set-world.mdx +49 -0
  94. package/docs/v5/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
  95. package/docs/v5/api-reference/workflow-runtime/world/index.mdx +55 -0
  96. package/docs/v5/api-reference/workflow-runtime/world/meta.json +4 -0
  97. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/queue.mdx +2 -2
  98. package/docs/v5/api-reference/workflow-runtime/world/storage.mdx +409 -0
  99. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/streams.mdx +2 -2
  100. package/docs/v5/api-reference/workflow-sveltekit/index.mdx +18 -0
  101. package/docs/v5/api-reference/workflow-sveltekit/meta.json +4 -0
  102. package/docs/v5/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
  103. package/docs/v5/api-reference/workflow-vite/index.mdx +18 -0
  104. package/docs/v5/api-reference/workflow-vite/meta.json +4 -0
  105. package/docs/v5/api-reference/workflow-vite/workflow.mdx +48 -0
  106. package/docs/v5/errors/index.mdx +3 -0
  107. package/docs/v5/errors/step-executed-multiple-times.mdx +23 -0
  108. package/package.json +10 -10
  109. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  110. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: observabilityRevivers
3
+ description: Standard reviver functions for deserializing workflow data types in observability tools.
4
+ type: reference
5
+ summary: Pass observabilityRevivers to hydrateResourceIO or hydrateData to deserialize standard workflow data types.
6
+ related:
7
+ - /docs/api-reference/workflow-observability/hydrate-resource-io
8
+ - /docs/api-reference/workflow-observability/hydrate-data
9
+ ---
10
+
11
+ A set of reviver functions that handle the workflow serialization format's workflow-specific types — streams, step/workflow function references, class instances, `AbortController`/`AbortSignal`, and `DOMException` — reviving them as display-friendly marker objects or strings. Built-in JavaScript types (`Date`, `Map`, `Set`, `RegExp`, etc.) are handled by the devalue format itself and need no revivers.
12
+
13
+ Pass it as the `revivers` argument to [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) or [`hydrateData()`](/docs/api-reference/workflow-observability/hydrate-data).
14
+
15
+ ```typescript lineNumbers
16
+ import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
17
+ import type { Step } from "@workflow/world";
18
+ declare const step: Step; // @setup
19
+
20
+ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
21
+ ```
22
+
23
+ ## API Signature
24
+
25
+ ```typescript
26
+ import type { Revivers } from "workflow/observability";
27
+
28
+ declare const observabilityRevivers: Revivers;
29
+ ```
30
+
31
+ Where `Revivers` is:
32
+
33
+ ```typescript
34
+ type Revivers = Record<string, (value: any) => any>;
35
+ ```
36
+
37
+ Each key is a serialized type tag, and each function revives a serialized value of that type. You can spread `observabilityRevivers` into a custom reviver map to override how specific types are displayed:
38
+
39
+ ```typescript lineNumbers
40
+ import { hydrateData, observabilityRevivers } from "workflow/observability";
41
+ declare const value: unknown; // @setup
42
+
43
+ const customRevivers = {
44
+ ...observabilityRevivers,
45
+ // Render stream references as plain strings instead of marker objects
46
+ ReadableStream: () => "<stream>",
47
+ };
48
+
49
+ const hydrated = hydrateData(value, customRevivers);
50
+ ```
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: parseClassName
3
+ description: Parse a machine-readable class ID into display-friendly components.
4
+ type: reference
5
+ summary: Use parseClassName to extract a display-friendly class name from a serialized class instance identifier.
6
+ related:
7
+ - /docs/api-reference/workflow-observability/parse-step-name
8
+ - /docs/api-reference/workflow-observability/parse-workflow-name
9
+ - /docs/api-reference/workflow-serde
10
+ ---
11
+
12
+ Serialized class instances reference their class with machine-readable IDs like `class//./src/models//User`. This function parses them into components suitable for display in a UI.
13
+
14
+ ```typescript lineNumbers
15
+ import { parseClassName } from "workflow/observability"; // [!code highlight]
16
+
17
+ const parsed = parseClassName("class//./src/models//User"); // [!code highlight]
18
+ // parsed?.shortName → "User"
19
+ // parsed?.moduleSpecifier → "./src/models"
20
+ // parsed?.functionName → "User"
21
+ ```
22
+
23
+ ## API Signature
24
+
25
+ ### Parameters
26
+
27
+ | Parameter | Type | Description |
28
+ |-----------|------|-------------|
29
+ | `name` | `string` | The machine-readable class ID |
30
+
31
+ ### Returns
32
+
33
+ `{ shortName: string; moduleSpecifier: string; functionName: string } | null`
34
+
35
+ | Property | Description |
36
+ |----------|-------------|
37
+ | `shortName` | The display name of the class (e.g. `"User"`). |
38
+ | `moduleSpecifier` | The module the class is defined in — a relative path (`./src/models`) or a package specifier (`point@0.0.1`). |
39
+ | `functionName` | The class name as recorded by the compiler. |
40
+
41
+ Returns `null` when the input is not a valid class ID.
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: parseStepName
3
+ description: Parse a machine-readable step name into display-friendly components.
4
+ type: reference
5
+ summary: Use parseStepName to extract a display-friendly short name from a step's machine-readable identifier.
6
+ related:
7
+ - /docs/api-reference/workflow-observability/parse-workflow-name
8
+ - /docs/api-reference/workflow-observability/parse-class-name
9
+ ---
10
+
11
+ Step names are stored as machine-readable identifiers like `step//./src/workflows/order//processPayment`. This function parses them into components suitable for display in a UI.
12
+
13
+ ```typescript lineNumbers
14
+ import { parseStepName } from "workflow/observability"; // [!code highlight]
15
+
16
+ const parsed = parseStepName("step//./src/workflows/order//processPayment"); // [!code highlight]
17
+ // parsed?.shortName → "processPayment"
18
+ // parsed?.moduleSpecifier → "./src/workflows/order"
19
+ // parsed?.functionName → "processPayment"
20
+ ```
21
+
22
+ ## API Signature
23
+
24
+ ### Parameters
25
+
26
+ | Parameter | Type | Description |
27
+ |-----------|------|-------------|
28
+ | `name` | `string` | The machine-readable step name (e.g. from `step.stepName`) |
29
+
30
+ ### Returns
31
+
32
+ `{ shortName: string; moduleSpecifier: string; functionName: string } | null`
33
+
34
+ | Property | Description |
35
+ |----------|-------------|
36
+ | `shortName` | The display name — the last segment of the function name. For nested steps like `processOrder/chargeCard`, this is `"chargeCard"`. |
37
+ | `moduleSpecifier` | The module the step is defined in — a relative path (`./src/workflows/order`) or a package specifier (`@myorg/tasks@2.0.0`). |
38
+ | `functionName` | The full function name including nesting (e.g. `processOrder/chargeCard`). |
39
+
40
+ Returns `null` when the input is not a valid step name.
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: parseWorkflowName
3
+ description: Parse a machine-readable workflow name into display-friendly components.
4
+ type: reference
5
+ summary: Use parseWorkflowName to extract a display-friendly short name from a run's workflowName identifier.
6
+ related:
7
+ - /docs/api-reference/workflow-observability/parse-step-name
8
+ - /docs/api-reference/workflow-observability/parse-class-name
9
+ ---
10
+
11
+ Workflow names are stored as machine-readable identifiers like `workflow//./src/workflows/order//processOrder`. This function parses them into components suitable for display in a UI — for example when listing runs from the [World SDK](/docs/api-reference/workflow-runtime/world/storage), where `run.workflowName` holds the machine-readable form.
12
+
13
+ ```typescript lineNumbers
14
+ import { parseWorkflowName } from "workflow/observability"; // [!code highlight]
15
+
16
+ const parsed = parseWorkflowName("workflow//./src/workflows/order//processOrder"); // [!code highlight]
17
+ // parsed?.shortName → "processOrder"
18
+ // parsed?.moduleSpecifier → "./src/workflows/order"
19
+ // parsed?.functionName → "processOrder"
20
+ ```
21
+
22
+ ## API Signature
23
+
24
+ ### Parameters
25
+
26
+ | Parameter | Type | Description |
27
+ |-----------|------|-------------|
28
+ | `name` | `string` | The machine-readable workflow name (e.g. from `run.workflowName`) |
29
+
30
+ ### Returns
31
+
32
+ `{ shortName: string; moduleSpecifier: string; functionName: string } | null`
33
+
34
+ | Property | Description |
35
+ |----------|-------------|
36
+ | `shortName` | The display name. For default exports, falls back to the module's short name (e.g. `"order"` for `./src/workflows/order`). |
37
+ | `moduleSpecifier` | The module the workflow is defined in — a relative path (`./src/workflows/order`) or a package specifier (`@myorg/flows@1.0.0`). |
38
+ | `functionName` | The full exported function name. |
39
+
40
+ Returns `null` when the input is not a valid workflow name.
41
+
42
+ ## Example: List Runs with Display Names
43
+
44
+ ```typescript lineNumbers
45
+ import { getWorld } from "workflow/runtime";
46
+ import { parseWorkflowName } from "workflow/observability"; // [!code highlight]
47
+
48
+ const world = await getWorld();
49
+ const runs = await world.runs.list({ resolveData: "none" });
50
+
51
+ for (const run of runs.data) {
52
+ const parsed = parseWorkflowName(run.workflowName); // [!code highlight]
53
+ console.log(`${parsed?.shortName ?? run.workflowName}: ${run.status}`);
54
+ }
55
+ ```
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: createWorld
3
+ description: Create a new World instance from environment configuration.
4
+ type: reference
5
+ summary: Use createWorld to instantiate a World from WORKFLOW_TARGET_WORLD environment configuration, bypassing the cached instance.
6
+ prerequisites:
7
+ - /docs/api-reference/workflow-runtime/get-world
8
+ related:
9
+ - /docs/api-reference/workflow-runtime/set-world
10
+ ---
11
+
12
+ Creates a new [World](/docs/api-reference/workflow-runtime/world) instance based on environment configuration. The `WORKFLOW_TARGET_WORLD` environment variable determines which World implementation is instantiated (for example the local development World or the Vercel production World).
13
+
14
+ Unlike [`getWorld()`](/docs/api-reference/workflow-runtime/get-world), which caches a singleton instance, `createWorld()` constructs a fresh instance on every call. Application code should almost always use `getWorld()` — `createWorld()` is for infrastructure code that manages World lifecycles itself.
15
+
16
+ ```typescript lineNumbers
17
+ import { createWorld } from "workflow/runtime";
18
+
19
+ const world = await createWorld(); // [!code highlight]
20
+ ```
21
+
22
+ ## API Signature
23
+
24
+ ### Parameters
25
+
26
+ This function does not accept any parameters. Configuration is read from environment variables.
27
+
28
+ ### Returns
29
+
30
+ Returns a newly constructed `World` instance.
31
+
32
+ <Callout type="info">
33
+ In workflow 4.x, `createWorld()` is synchronous and returns `World` directly. It becomes async in 5.x, so writing `await createWorld()` works on both versions.
34
+ </Callout>
35
+
36
+ <Callout type="info">
37
+ Tooling that needs to construct a World with explicit (non-environment) configuration should instantiate the specific World implementation directly and register it with [`setWorld()`](/docs/api-reference/workflow-runtime/set-world).
38
+ </Callout>
39
+
40
+ ## Related Functions
41
+
42
+ - [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the cached World instance (preferred in application code).
43
+ - [`setWorld()`](/docs/api-reference/workflow-runtime/set-world) - Override the cached World instance.
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: getWorldHandlers
3
+ description: Build-time-safe access to the World's queue handlers without binding to runtime environment variables.
4
+ type: reference
5
+ summary: Use getWorldHandlers at build time to access queue handler creation without caching an environment-bound World.
6
+ prerequisites:
7
+ - /docs/api-reference/workflow-runtime/get-world
8
+ ---
9
+
10
+ Returns a restricted view of the [World](/docs/api-reference/workflow-runtime/world) exposing only the members that are safe to use at build time: `createQueueHandler` and `specVersion`. Framework adapters use it while generating workflow route handlers, before the deployment's runtime environment variables exist.
11
+
12
+ Unlike [`getWorld()`](/docs/api-reference/workflow-runtime/get-world), this function does not cache a fully configured World instance — caching at build time would lock in incomplete environment configuration.
13
+
14
+ ```typescript lineNumbers
15
+ import { getWorldHandlers } from "workflow/runtime";
16
+
17
+ const handlers = await getWorldHandlers(); // [!code highlight]
18
+ console.log(handlers.specVersion);
19
+ ```
20
+
21
+ ## API Signature
22
+
23
+ ### Parameters
24
+
25
+ This function does not accept any parameters.
26
+
27
+ ### Returns
28
+
29
+ Returns a `WorldHandlers` object (synchronously in workflow 4.x; async in 5.x), where:
30
+
31
+ ```typescript
32
+ import type { World } from "@workflow/world";
33
+
34
+ type WorldHandlers = Pick<World, "createQueueHandler" | "specVersion">;
35
+ ```
36
+
37
+ <Callout type="warn">
38
+ This is SDK infrastructure used by framework adapters and the workflow entrypoint. Application code should use [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) instead.
39
+ </Callout>
40
+
41
+ ## Related Functions
42
+
43
+ - [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the full World instance at runtime.
44
+ - [`workflowEntrypoint()`](/docs/api-reference/workflow-runtime/workflow-entrypoint) - The route handler factory built on these handlers.
@@ -0,0 +1,124 @@
1
+ ---
2
+ title: getWorld
3
+ description: Resolves the World instance for low-level storage, queuing, and streaming operations.
4
+ type: reference
5
+ summary: Resolve the World instance for low-level workflow storage, queuing, and streaming backends.
6
+ prerequisites:
7
+ - /docs/deploying
8
+ ---
9
+
10
+ Retrieves the World instance for direct access to workflow storage, queuing, and streaming backends. The returned `World` provides low-level access to manage workflow runs, steps, events, and hooks.
11
+
12
+ Use this function when you need direct access to the underlying workflow infrastructure, such as listing all runs, querying events, or implementing custom workflow management logic.
13
+
14
+ ```typescript lineNumbers
15
+ import { getWorld } from "workflow/runtime";
16
+
17
+ const world = await getWorld(); // [!code highlight]
18
+ ```
19
+
20
+ <Callout type="info">
21
+ In workflow 4.x, `getWorld()` is synchronous and returns `World` directly. It becomes async in 5.x, so writing `await getWorld()` works on both versions.
22
+ </Callout>
23
+
24
+ ## API Signature
25
+
26
+ ### Parameters
27
+
28
+ This function does not accept any parameters.
29
+
30
+ ### Returns
31
+
32
+ Returns the `World` object:
33
+
34
+ <TSDoc
35
+ definition={`
36
+ import type { World } from "@workflow/world";
37
+ export default World;`}
38
+ showSections={["returns"]}
39
+ />
40
+
41
+ ## World SDK
42
+
43
+ The World object provides access to several entity interfaces. See the [World SDK](/docs/api-reference/workflow-runtime/world) reference for complete documentation:
44
+
45
+ <Cards>
46
+ <Card href="/docs/api-reference/workflow-runtime/world/storage" title="Storage">
47
+ Query runs, steps, hooks, and the underlying event log.
48
+ </Card>
49
+ <Card href="/docs/api-reference/workflow-runtime/world/streams" title="Streams">
50
+ Read, write, and manage data streams.
51
+ </Card>
52
+ <Card href="/docs/api-reference/workflow-runtime/world/queue" title="Queue">
53
+ Low-level queue dispatch (internal SDK infrastructure).
54
+ </Card>
55
+ </Cards>
56
+
57
+ ## Data Hydration
58
+
59
+ Step and run data is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format. Use `workflow/observability` to hydrate it for display:
60
+
61
+ ```typescript lineNumbers
62
+ import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
63
+
64
+ const step = await world.steps.get(runId, stepId);
65
+ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
66
+ ```
67
+
68
+ See [`workflow/observability`](/docs/api-reference/workflow-observability) for the full hydration and parsing API.
69
+
70
+ ### List Workflow Runs (Display Names)
71
+
72
+ List workflow runs and derive human-readable names from the `workflowName` field:
73
+
74
+ ```typescript lineNumbers
75
+ import { getWorld } from "workflow/runtime";
76
+ import { parseWorkflowName } from "workflow/observability"; // [!code highlight]
77
+
78
+ export async function GET(req: Request) {
79
+ const url = new URL(req.url);
80
+ const cursor = url.searchParams.get("cursor") ?? undefined;
81
+
82
+ try {
83
+ const world = await getWorld(); // [!code highlight]
84
+ const runs = await world.runs.list({
85
+ pagination: { cursor },
86
+ resolveData: "none",
87
+ });
88
+
89
+ return Response.json({
90
+ data: runs.data.map((run) => {
91
+ const parsed = parseWorkflowName(run.workflowName); // [!code highlight]
92
+
93
+ return {
94
+ runId: run.runId,
95
+ // Use shortName for UI display (e.g., "processOrder") // [!code highlight]
96
+ displayName: parsed?.shortName ?? run.workflowName, // [!code highlight]
97
+ // Module info available for debugging // [!code highlight]
98
+ module: parsed?.moduleSpecifier, // [!code highlight]
99
+ status: run.status,
100
+ startedAt: run.startedAt,
101
+ completedAt: run.completedAt,
102
+ };
103
+ }),
104
+ cursor: runs.cursor,
105
+ });
106
+ } catch (error) {
107
+ return Response.json(
108
+ { error: "Failed to list workflow runs" },
109
+ { status: 500 }
110
+ );
111
+ }
112
+ }
113
+ ```
114
+
115
+ <Callout type="info">
116
+ The `workflowName` field contains a machine-readable identifier like `workflow//./src/workflows/order//processOrder`.
117
+ Use [`parseWorkflowName()`](/docs/api-reference/workflow-observability/parse-workflow-name) to extract the `shortName` (e.g., `"processOrder"`)
118
+ and `moduleSpecifier` for display in your UI.
119
+ </Callout>
120
+
121
+ ## Related Functions
122
+
123
+ - [`getRun()`](/docs/api-reference/workflow-api/get-run) - Higher-level API for working with individual runs by ID.
124
+ - [`start()`](/docs/api-reference/workflow-api/start) - Start a new workflow run.
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: healthCheck
3
+ description: Verify a deployment's workflow infrastructure by sending a message through the queue pipeline.
4
+ type: reference
5
+ summary: Use healthCheck to verify the workflow endpoint of a deployment processes queue messages end-to-end.
6
+ prerequisites:
7
+ - /docs/api-reference/workflow-runtime/get-world
8
+ ---
9
+
10
+ Performs an end-to-end health check of a deployment's workflow infrastructure by sending a message through the queue pipeline and verifying it is processed by the workflow endpoint. Because it goes through the queue rather than direct HTTP, it works even when the deployment is behind Deployment Protection on Vercel.
11
+
12
+ ```typescript lineNumbers
13
+ import { getWorld, healthCheck } from "workflow/runtime";
14
+
15
+ const world = await getWorld();
16
+ const result = await healthCheck(world, "workflow"); // [!code highlight]
17
+
18
+ if (!result.healthy) {
19
+ console.error("Workflow infrastructure unhealthy:", result.error);
20
+ }
21
+ ```
22
+
23
+ ## API Signature
24
+
25
+ ### Parameters
26
+
27
+ | Parameter | Type | Description |
28
+ |-----------|------|-------------|
29
+ | `world` | `World` | The World instance to send the health check through |
30
+ | `endpoint` | `"workflow" \| "step"` | Which endpoint to check |
31
+ | `options` | `HealthCheckOptions & { namespace?: string }` | Optional configuration |
32
+
33
+ Where `HealthCheckOptions` is:
34
+
35
+ | Option | Type | Description |
36
+ |--------|------|-------------|
37
+ | `timeout` | `number` | Milliseconds to wait for the health check response. Default: `30000`. |
38
+ | `deploymentId` | `string` | Deployment to target. Falls back to `process.env.VERCEL_DEPLOYMENT_ID`. |
39
+
40
+ ### Returns
41
+
42
+ Returns a `Promise<HealthCheckResult>`:
43
+
44
+ | Property | Type | Description |
45
+ |----------|------|-------------|
46
+ | `healthy` | `boolean` | Whether the endpoint processed the health check message |
47
+ | `error` | `string \| undefined` | Error message when the check failed |
48
+ | `latencyMs` | `number \| undefined` | Round-trip latency when the check succeeded |
49
+ | `specVersion` | `number \| undefined` | Workflow spec version of the responding deployment |
50
+ | `workflowCoreVersion` | `string \| undefined` | `@workflow/core` version of the responding deployment |
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: "workflow/runtime"
3
+ description: Runtime functions for accessing the World instance and wiring up workflow infrastructure.
4
+ type: overview
5
+ summary: Explore runtime functions for resolving the World instance and configuring workflow infrastructure.
6
+ ---
7
+
8
+ API reference for runtime functions from the `workflow/runtime` package.
9
+
10
+ The runtime package provides low-level access to the workflow runtime — resolving the [World](/docs/api-reference/workflow-runtime/world) instance that backs storage, queuing, and streaming, and wiring up workflow infrastructure in custom server environments.
11
+
12
+ ## Functions
13
+
14
+ <Cards>
15
+ <Card href="/docs/api-reference/workflow-runtime/get-world" title="getWorld()">
16
+ Async: resolve the World instance for storage, queuing, and streaming backends.
17
+ </Card>
18
+ <Card href="/docs/api-reference/workflow-runtime/world" title="World SDK">
19
+ Low-level API for inspecting runs, steps, events, hooks, streams, and queues.
20
+ </Card>
21
+ </Cards>
22
+
23
+ ## Infrastructure Functions
24
+
25
+ These functions are primarily used by framework adapters and custom world setups, and are rarely needed in application code:
26
+
27
+ <Cards>
28
+ <Card href="/docs/api-reference/workflow-runtime/create-world" title="createWorld()">
29
+ Create a World instance from environment configuration.
30
+ </Card>
31
+ <Card href="/docs/api-reference/workflow-runtime/set-world" title="setWorld()">
32
+ Override the cached World instance with a custom World.
33
+ </Card>
34
+ <Card href="/docs/api-reference/workflow-runtime/get-world-handlers" title="getWorldHandlers()">
35
+ Build-time-safe access to the World's queue handlers.
36
+ </Card>
37
+ <Card href="/docs/api-reference/workflow-runtime/workflow-entrypoint" title="workflowEntrypoint()">
38
+ Create the HTTP route handler that executes workflow runs.
39
+ </Card>
40
+ <Card href="/docs/api-reference/workflow-runtime/step-entrypoint" title="stepEntrypoint">
41
+ The HTTP route handler that executes step functions.
42
+ </Card>
43
+ <Card href="/docs/api-reference/workflow-runtime/health-check" title="healthCheck()">
44
+ Check the health of a deployment's workflow infrastructure.
45
+ </Card>
46
+ </Cards>
@@ -0,0 +1,13 @@
1
+ {
2
+ "title": "workflow/runtime",
3
+ "pages": [
4
+ "get-world",
5
+ "world",
6
+ "create-world",
7
+ "set-world",
8
+ "get-world-handlers",
9
+ "workflow-entrypoint",
10
+ "step-entrypoint",
11
+ "health-check"
12
+ ]
13
+ }
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: setWorld
3
+ description: Override or reset the cached World instance used by the workflow runtime.
4
+ type: reference
5
+ summary: Use setWorld to inject a custom World instance or reset the cache after environment configuration changes.
6
+ prerequisites:
7
+ - /docs/api-reference/workflow-runtime/get-world
8
+ related:
9
+ - /docs/api-reference/workflow-runtime/create-world
10
+ ---
11
+
12
+ Overrides the cached [World](/docs/api-reference/workflow-runtime/world) instance that [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) returns. Use it to inject a World constructed with explicit configuration (rather than environment variables), or pass `undefined` to clear the cache so the next `getWorld()` call reinitializes from the current environment.
13
+
14
+ ```typescript lineNumbers
15
+ import { setWorld, getWorld } from "workflow/runtime";
16
+ import type { World } from "@workflow/world";
17
+ declare const customWorld: World; // @setup
18
+
19
+ setWorld(customWorld); // [!code highlight]
20
+ const world = await getWorld(); // resolves customWorld
21
+ ```
22
+
23
+ ## API Signature
24
+
25
+ ### Parameters
26
+
27
+ | Parameter | Type | Description |
28
+ |-----------|------|-------------|
29
+ | `world` | `World \| undefined` | The World instance to use, or `undefined` to reset the cache and reinitialize from environment variables on next access |
30
+
31
+ ### Returns
32
+
33
+ This function does not return a value.
34
+
35
+ ## Example: Reset After Environment Changes
36
+
37
+ ```typescript lineNumbers
38
+ import { setWorld, getWorld } from "workflow/runtime";
39
+
40
+ process.env.WORKFLOW_TARGET_WORLD = "@workflow/world-local";
41
+ setWorld(undefined); // clear the cached instance // [!code highlight]
42
+
43
+ const world = await getWorld(); // reinitialized with new configuration
44
+ ```
45
+
46
+ ## Related Functions
47
+
48
+ - [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the cached World instance.
49
+ - [`createWorld()`](/docs/api-reference/workflow-runtime/create-world) - Construct a fresh World from environment configuration.
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: stepEntrypoint
3
+ description: The HTTP route handler that executes step functions.
4
+ type: reference
5
+ summary: Mount stepEntrypoint as the route that executes step functions in custom server environments.
6
+ prerequisites:
7
+ - /docs/how-it-works/code-transform
8
+ related:
9
+ - /docs/api-reference/workflow-runtime/workflow-entrypoint
10
+ ---
11
+
12
+ The HTTP route handler that executes step functions. It receives step execution requests from the queue, routes them to the appropriate step function, and reports results back to the workflow run.
13
+
14
+ Unlike [`workflowEntrypoint()`](/docs/api-reference/workflow-runtime/workflow-entrypoint), this is the handler itself rather than a factory — step bundles register their step functions globally, and the handler routes by step name.
15
+
16
+ Framework adapters mount this for you at `/.well-known/workflow/v1/step` — you only need it when wiring workflow support into a custom server environment.
17
+
18
+ {/* @skip-typecheck: stepEntrypoint exists in workflow@4 only; docs samples are type-checked against the v5 packages on main */}
19
+
20
+ ```typescript lineNumbers
21
+ import { stepEntrypoint } from "workflow/runtime";
22
+
23
+ // Mount on your server, e.g. a fetch-style route:
24
+ export const POST = stepEntrypoint; // [!code highlight]
25
+ ```
26
+
27
+ ## API Signature
28
+
29
+ {/* @skip-typecheck: type-only signature snippet, not compilable code */}
30
+
31
+ ```typescript
32
+ const stepEntrypoint: (req: Request) => Promise<Response>;
33
+ ```
34
+
35
+ A fetch-style request handler.
36
+
37
+ <Callout type="info">
38
+ `stepEntrypoint` exists in workflow 4.x only. In 5.x the combined handler created by [`workflowEntrypoint()`](/docs/api-reference/workflow-runtime/workflow-entrypoint) executes steps inline, and the separate step endpoint was removed.
39
+ </Callout>
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: workflowEntrypoint
3
+ description: Create the HTTP route handler that executes workflow runs from a workflow bundle.
4
+ type: reference
5
+ summary: Use workflowEntrypoint to wire a compiled workflow bundle into an HTTP route in custom server environments.
6
+ prerequisites:
7
+ - /docs/how-it-works/code-transform
8
+ related:
9
+ - /docs/api-reference/workflow-runtime/health-check
10
+ ---
11
+
12
+ Creates the HTTP route handler that executes workflow runs. The handler receives queue messages, replays the workflow from its event log, executes steps inline where possible, and suspends when the workflow waits on sleeps or hooks.
13
+
14
+ Framework adapters (Next.js, Nitro, SvelteKit, etc.) call this for you and mount the result at `/.well-known/workflow/v1/flow` — you only need it when wiring workflow support into a custom server environment.
15
+
16
+ ```typescript lineNumbers
17
+ import { workflowEntrypoint } from "workflow/runtime";
18
+ declare const workflowBundleCode: string; // @setup
19
+
20
+ const handler = workflowEntrypoint(workflowBundleCode); // [!code highlight]
21
+
22
+ // Mount on your server, e.g. a fetch-style route:
23
+ export const POST = (req: Request) => handler(req);
24
+ ```
25
+
26
+ ## API Signature
27
+
28
+ ### Parameters
29
+
30
+ | Parameter | Type | Description |
31
+ |-----------|------|-------------|
32
+ | `workflowCode` | `string` | The compiled workflow bundle code containing all workflow functions |
33
+ | `options` | `{ namespace?: string }` | Optional. `namespace` scopes the queue topics this handler consumes. |
34
+
35
+ ### Returns
36
+
37
+ Returns a fetch-style request handler: `(req: Request) => Promise<Response>`.
38
+
39
+ ## Related Functions
40
+
41
+ - [`getWorldHandlers()`](/docs/api-reference/workflow-runtime/get-world-handlers) - The build-time World access this handler is built on.
42
+ - [`healthCheck()`](/docs/api-reference/workflow-runtime/health-check) - Verify the entrypoint processes queue messages end-to-end.