workflow 4.3.1 → 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 (114) 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/building-a-world.mdx +1 -1
  12. package/docs/deploying/world/vercel-world.mdx +2 -0
  13. package/docs/errors/hook-conflict.mdx +56 -4
  14. package/docs/errors/index.mdx +6 -0
  15. package/docs/foundations/hooks.mdx +29 -0
  16. package/docs/foundations/streaming.mdx +7 -1
  17. package/docs/foundations/versioning.mdx +1 -1
  18. package/docs/how-it-works/encryption.mdx +2 -2
  19. package/docs/how-it-works/event-sourcing.mdx +2 -2
  20. package/docs/v4/api-reference/workflow-astro/index.mdx +18 -0
  21. package/docs/v4/api-reference/workflow-astro/meta.json +4 -0
  22. package/docs/v4/api-reference/workflow-astro/workflow.mdx +37 -0
  23. package/docs/v4/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  24. package/docs/v4/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  25. package/docs/v4/api-reference/workflow-errors/workflow-error.mdx +52 -0
  26. package/docs/v4/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  27. package/docs/v4/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  28. package/docs/v4/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  29. package/docs/v4/api-reference/workflow-nest/index.mdx +31 -0
  30. package/docs/v4/api-reference/workflow-nest/meta.json +9 -0
  31. package/docs/v4/api-reference/workflow-nest/nest-local-builder.mdx +63 -0
  32. package/docs/v4/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  33. package/docs/v4/api-reference/workflow-nest/workflow-module.mdx +73 -0
  34. package/docs/v4/api-reference/workflow-nitro/index.mdx +57 -0
  35. package/docs/v4/api-reference/workflow-nuxt/index.mdx +47 -0
  36. package/docs/v4/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  37. package/docs/v4/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  38. package/docs/v4/api-reference/workflow-observability/index.mdx +64 -0
  39. package/docs/v4/api-reference/workflow-observability/meta.json +11 -0
  40. package/docs/v4/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  41. package/docs/v4/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  42. package/docs/v4/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  43. package/docs/v4/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  44. package/docs/v4/api-reference/workflow-runtime/create-world.mdx +43 -0
  45. package/docs/v4/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  46. package/docs/v4/api-reference/workflow-runtime/get-world.mdx +124 -0
  47. package/docs/v4/api-reference/workflow-runtime/health-check.mdx +50 -0
  48. package/docs/v4/api-reference/workflow-runtime/index.mdx +46 -0
  49. package/docs/v4/api-reference/workflow-runtime/meta.json +13 -0
  50. package/docs/v4/api-reference/workflow-runtime/set-world.mdx +49 -0
  51. package/docs/v4/api-reference/workflow-runtime/step-entrypoint.mdx +39 -0
  52. package/docs/v4/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
  53. package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/index.mdx +5 -8
  54. package/docs/v4/api-reference/workflow-runtime/world/meta.json +4 -0
  55. package/docs/v4/api-reference/workflow-runtime/world/queue.mdx +86 -0
  56. package/docs/{api-reference/workflow-api → v4/api-reference/workflow-runtime}/world/storage.mdx +4 -4
  57. package/docs/v4/api-reference/workflow-runtime/world/streams.mdx +216 -0
  58. package/docs/v4/api-reference/workflow-sveltekit/index.mdx +18 -0
  59. package/docs/v4/api-reference/workflow-sveltekit/meta.json +4 -0
  60. package/docs/v4/api-reference/workflow-sveltekit/workflow-plugin.mdx +34 -0
  61. package/docs/v4/api-reference/workflow-vite/index.mdx +18 -0
  62. package/docs/v4/api-reference/workflow-vite/meta.json +4 -0
  63. package/docs/v4/api-reference/workflow-vite/workflow.mdx +47 -0
  64. package/docs/v4/errors/runtime-decryption-failed.mdx +77 -0
  65. package/docs/v4/errors/step-executed-multiple-times.mdx +23 -0
  66. package/docs/v5/api-reference/workflow-astro/index.mdx +18 -0
  67. package/docs/v5/api-reference/workflow-astro/meta.json +4 -0
  68. package/docs/v5/api-reference/workflow-astro/workflow.mdx +45 -0
  69. package/docs/v5/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  70. package/docs/v5/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  71. package/docs/v5/api-reference/workflow-errors/workflow-error.mdx +52 -0
  72. package/docs/v5/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  73. package/docs/v5/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  74. package/docs/v5/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  75. package/docs/v5/api-reference/workflow-nest/index.mdx +31 -0
  76. package/docs/v5/api-reference/workflow-nest/meta.json +9 -0
  77. package/docs/v5/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
  78. package/docs/v5/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  79. package/docs/v5/api-reference/workflow-nest/workflow-module.mdx +74 -0
  80. package/docs/v5/api-reference/workflow-nitro/index.mdx +59 -0
  81. package/docs/v5/api-reference/workflow-nuxt/index.mdx +47 -0
  82. package/docs/v5/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  83. package/docs/v5/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  84. package/docs/v5/api-reference/workflow-observability/index.mdx +64 -0
  85. package/docs/v5/api-reference/workflow-observability/meta.json +11 -0
  86. package/docs/v5/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  87. package/docs/v5/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  88. package/docs/v5/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  89. package/docs/v5/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  90. package/docs/v5/api-reference/workflow-runtime/create-world.mdx +39 -0
  91. package/docs/v5/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  92. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/get-world.mdx +7 -10
  93. package/docs/v5/api-reference/workflow-runtime/health-check.mdx +50 -0
  94. package/docs/v5/api-reference/workflow-runtime/index.mdx +43 -0
  95. package/docs/v5/api-reference/workflow-runtime/meta.json +12 -0
  96. package/docs/v5/api-reference/workflow-runtime/set-world.mdx +49 -0
  97. package/docs/v5/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
  98. package/docs/v5/api-reference/workflow-runtime/world/index.mdx +55 -0
  99. package/docs/v5/api-reference/workflow-runtime/world/meta.json +4 -0
  100. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/queue.mdx +2 -2
  101. package/docs/v5/api-reference/workflow-runtime/world/storage.mdx +409 -0
  102. package/docs/{api-reference/workflow-api → v5/api-reference/workflow-runtime}/world/streams.mdx +2 -2
  103. package/docs/v5/api-reference/workflow-sveltekit/index.mdx +18 -0
  104. package/docs/v5/api-reference/workflow-sveltekit/meta.json +4 -0
  105. package/docs/v5/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
  106. package/docs/v5/api-reference/workflow-vite/index.mdx +18 -0
  107. package/docs/v5/api-reference/workflow-vite/meta.json +4 -0
  108. package/docs/v5/api-reference/workflow-vite/workflow.mdx +48 -0
  109. package/docs/v5/errors/index.mdx +59 -0
  110. package/docs/v5/errors/runtime-decryption-failed.mdx +77 -0
  111. package/docs/v5/errors/step-executed-multiple-times.mdx +23 -0
  112. package/package.json +13 -13
  113. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  114. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: WorkflowModule
3
+ description: NestJS module that builds workflow bundles and registers the workflow controller.
4
+ type: reference
5
+ summary: Import WorkflowModule.forRoot() in your AppModule to enable workflows in a NestJS app.
6
+ prerequisites:
7
+ - /docs/getting-started/nestjs
8
+ ---
9
+
10
+ NestJS module that provides workflow functionality. It builds the workflow bundles on module initialization (`onModuleInit`) and registers the [`WorkflowController`](/docs/api-reference/workflow-nest/workflow-controller) that serves the workflow runtime routes.
11
+
12
+ ## Usage
13
+
14
+ Add `WorkflowModule.forRoot()` to the `imports` array of your root module.
15
+
16
+ ```typescript title="src/app.module.ts" lineNumbers
17
+ import { Module } from "@nestjs/common";
18
+ import { WorkflowModule } from "workflow/nest"; // [!code highlight]
19
+
20
+ @Module({
21
+ imports: [WorkflowModule.forRoot()], // [!code highlight]
22
+ })
23
+ export class AppModule {}
24
+ ```
25
+
26
+ If your NestJS project compiles to CommonJS via SWC, pass `moduleType` and `distDir` so the builder can rewrite imports in the generated bundles:
27
+
28
+ ```typescript title="src/app.module.ts" lineNumbers
29
+ import { Module } from "@nestjs/common";
30
+ import { WorkflowModule } from "workflow/nest";
31
+
32
+ @Module({
33
+ imports: [
34
+ WorkflowModule.forRoot({
35
+ moduleType: "commonjs", // [!code highlight]
36
+ distDir: "dist", // [!code highlight]
37
+ }),
38
+ ],
39
+ })
40
+ export class AppModule {}
41
+ ```
42
+
43
+ ## API Signature
44
+
45
+ ### Static Methods
46
+
47
+ #### `forRoot(options?)`
48
+
49
+ Configures the module and returns a NestJS `DynamicModule` registered as `global`. It calls [`configureWorkflowController`](/docs/api-reference/workflow-nest/configure-workflow-controller) with the resolved output directory, and (unless `skipBuild` is set) creates a [`NestLocalBuilder`](/docs/api-reference/workflow-nest/nest-local-builder) that builds the workflow bundles when the module initializes.
50
+
51
+ ### Parameters
52
+
53
+ | Parameter | Type | Description |
54
+ | --- | --- | --- |
55
+ | `options` | `WorkflowModuleOptions` | Optional. Configures the workflow build. |
56
+
57
+ #### WorkflowModuleOptions
58
+
59
+ Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-builder#nestbuilderoptions) — all builder options are accepted, plus `skipBuild`:
60
+
61
+ | Option | Type | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `skipBuild` | `boolean` | `false` | Skip building workflow bundles on startup. Useful in production when the bundles are pre-built. |
64
+ | `workingDir` | `string` | `process.cwd()` | Working directory for the NestJS application. |
65
+ | `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
66
+ | `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
67
+ | `watch` | `boolean` | `false` | Enable watch mode for development. |
68
+ | `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. Set to `'commonjs'` if your NestJS project compiles to CJS via SWC. |
69
+ | `distDir` | `string` | `'dist'` | Directory where NestJS compiles `.ts` source files to `.js` (relative to `workingDir`). Used when `moduleType` is `'commonjs'`. Should match the `outDir` in your `tsconfig.json`. |
70
+ | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` | Controls source maps on generated workflow bundles. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
71
+
72
+ ### Returns
73
+
74
+ `forRoot()` returns a `DynamicModule` to include in the `imports` array of your root module.
@@ -0,0 +1,59 @@
1
+ ---
2
+ title: "workflow/nitro"
3
+ description: Nitro module for automatic workflow bundling and route registration.
4
+ type: overview
5
+ summary: Explore the Nitro module that enables workflow directive transformation in Nitro apps.
6
+ related:
7
+ - /docs/getting-started/nitro
8
+ ---
9
+
10
+ Nitro integration for Workflow SDK. The `workflow/nitro` entry point's default export is a [Nitro module](https://v3.nitro.build/guide/modules) — it has no callable API. You enable it by adding it to the `modules` array of your Nitro config and configure it via the `workflow` key.
11
+
12
+ ## Usage
13
+
14
+ ```typescript title="nitro.config.ts" lineNumbers
15
+ import { defineConfig } from "nitro";
16
+
17
+ export default defineConfig({
18
+ serverDir: "./server",
19
+ modules: ["workflow/nitro"], // [!code highlight]
20
+ });
21
+ ```
22
+
23
+ When enabled, the module:
24
+
25
+ - Transforms `"use workflow"` and `"use step"` directives during bundling.
26
+ - Builds the workflow, step, and webhook bundles, and rebuilds them on file changes in development.
27
+ - Registers the workflow runtime routes under `/.well-known/workflow/v1/`.
28
+ - Serves a redirect to the local observability dashboard at `/_workflow` in development.
29
+ - Configures Vercel function rules (queue triggers and `maxDuration`) for the workflow routes when deploying to Vercel.
30
+
31
+ ## Module Options
32
+
33
+ Options are read from the `workflow` key of your Nitro config. The option type is exported as `ModuleOptions`:
34
+
35
+ ```typescript title="nitro.config.ts" lineNumbers
36
+ import { defineConfig } from "nitro";
37
+ import type { ModuleOptions } from "workflow/nitro"; // [!code highlight]
38
+
39
+ const workflow: ModuleOptions = {
40
+ runtime: "nodejs22.x",
41
+ sourcemap: "inline",
42
+ };
43
+
44
+ export default defineConfig({
45
+ modules: ["workflow/nitro"],
46
+ workflow, // [!code highlight]
47
+ });
48
+ ```
49
+
50
+ | Option | Type | Default | Description |
51
+ | --- | --- | --- | --- |
52
+ | `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. |
53
+ | `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. |
54
+ | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). Only applies when deploying to Vercel. |
55
+ | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Set to `false` for smaller function bundles (useful for staying under the Vercel 250MB function size limit) at the cost of stack traces pointing at generated code. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
56
+
57
+ ## Vite-based Nitro
58
+
59
+ If you use Nitro through its Vite plugin (`nitro/vite`) instead of a standalone `nitro.config.ts`, use the [`workflow/vite`](/docs/api-reference/workflow-vite) entry point, which wraps this module as a Vite plugin and accepts the same `ModuleOptions`.
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: "workflow/nuxt"
3
+ description: Nuxt module for automatic workflow bundling and runtime configuration.
4
+ type: overview
5
+ summary: Explore the Nuxt module that enables workflow directive transformation in Nuxt apps.
6
+ related:
7
+ - /docs/getting-started/nuxt
8
+ ---
9
+
10
+ Nuxt integration for Workflow SDK. The `workflow/nuxt` entry point's default export is a Nuxt module — it has no callable API. You enable it by adding it to the `modules` array of your Nuxt config and configure it via the `workflow` key.
11
+
12
+ ## Usage
13
+
14
+ ```typescript title="nuxt.config.ts" lineNumbers
15
+ import { defineNuxtConfig } from "nuxt/config";
16
+
17
+ export default defineNuxtConfig({
18
+ modules: ["workflow/nuxt"], // [!code highlight]
19
+ compatibilityDate: "latest",
20
+ });
21
+ ```
22
+
23
+ When enabled, the module:
24
+
25
+ - Registers the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module on Nuxt's Nitro server, which transforms `"use workflow"` and `"use step"` directives, builds the workflow bundles, and registers the workflow runtime routes under `/.well-known/workflow/v1/`.
26
+ - Configures Vite to bundle (rather than externalize) the Workflow SDK packages in SSR mode so workflow code is transformed correctly.
27
+ - Enables the `workflow` TypeScript plugin by default for IDE IntelliSense.
28
+
29
+ ## Module Options
30
+
31
+ Options are read from the `workflow` key of your Nuxt config. The option type is exported as `ModuleOptions`:
32
+
33
+ ```typescript title="nuxt.config.ts" lineNumbers
34
+ import { defineNuxtConfig } from "nuxt/config";
35
+
36
+ export default defineNuxtConfig({
37
+ modules: ["workflow/nuxt"],
38
+ workflow: {
39
+ typescriptPlugin: false, // [!code highlight]
40
+ },
41
+ compatibilityDate: "latest",
42
+ });
43
+ ```
44
+
45
+ | Option | Type | Default | Description |
46
+ | --- | --- | --- | --- |
47
+ | `typescriptPlugin` | `boolean` | `true` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. Set to `false` to disable it. |
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: hydrateData
3
+ description: Hydrate a single serialized value from workflow storage into a plain JavaScript value.
4
+ type: reference
5
+ summary: Use hydrateData to deserialize a single value when hydrateResourceIO's field mapping doesn't apply.
6
+ related:
7
+ - /docs/api-reference/workflow-observability/hydrate-resource-io
8
+ - /docs/api-reference/workflow-observability/observability-revivers
9
+ ---
10
+
11
+ Hydrates (deserializes) a single value that was stored by the workflow runtime. This is the lower-level building block behind [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) — use it when you have a raw serialized value rather than a whole resource, such as a single field from an event payload.
12
+
13
+ ```typescript lineNumbers
14
+ import { hydrateData, observabilityRevivers } from "workflow/observability"; // [!code highlight]
15
+ declare const serialized: unknown; // @setup
16
+
17
+ const value = hydrateData(serialized, observabilityRevivers); // [!code highlight]
18
+ ```
19
+
20
+ ## API Signature
21
+
22
+ ### Parameters
23
+
24
+ | Parameter | Type | Description |
25
+ |-----------|------|-------------|
26
+ | `value` | `unknown` | The serialized value from workflow storage |
27
+ | `revivers` | `Revivers` | Reviver functions for deserialization. Use [`observabilityRevivers`](/docs/api-reference/workflow-observability/observability-revivers) for standard use. |
28
+
29
+ ### Returns
30
+
31
+ The hydrated plain JavaScript value. The input is handled by shape:
32
+
33
+ - Format-prefixed binary data (`Uint8Array`) is decoded and parsed from the [devalue](https://github.com/Rich-Harris/devalue) format
34
+ - Encrypted data is returned as-is (a raw `Uint8Array`) — see [Encrypted Data](/docs/api-reference/workflow-observability#encrypted-data)
35
+ - Already-plain values (numbers, strings, `null`) are returned unchanged
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: hydrateResourceIO
3
+ description: Hydrate the serialized data fields of a run, step, hook, or event for display.
4
+ type: reference
5
+ summary: Use hydrateResourceIO with observabilityRevivers to deserialize step input/output for display in observability tools.
6
+ prerequisites:
7
+ - /docs/api-reference/workflow-runtime/get-world
8
+ related:
9
+ - /docs/api-reference/workflow-observability/observability-revivers
10
+ - /docs/api-reference/workflow-runtime/world/storage
11
+ ---
12
+
13
+ Hydrates (deserializes) the data fields of a resource returned by the [World SDK](/docs/api-reference/workflow-runtime/world) — a workflow run, step, hook, or event. Workflow data is serialized using the [devalue](https://github.com/Rich-Harris/devalue) format, so this is required before displaying step input/output in a UI.
14
+
15
+ The function dispatches on the resource shape: steps get `input`/`output` hydrated, hooks get `metadata`, events get `eventData`, and runs get `input`/`output`.
16
+
17
+ ```typescript lineNumbers
18
+ import { getWorld } from "workflow/runtime";
19
+ import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
20
+ declare const runId: string; // @setup
21
+ declare const stepId: string; // @setup
22
+
23
+ const world = await getWorld();
24
+ const step = await world.steps.get(runId, stepId);
25
+ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
26
+ console.log(hydrated.input, hydrated.output);
27
+ ```
28
+
29
+ ## API Signature
30
+
31
+ ### Parameters
32
+
33
+ | Parameter | Type | Description |
34
+ |-----------|------|-------------|
35
+ | `resource` | `WorkflowRun \| Step \| Hook \| Event` | The resource with serialized data fields |
36
+ | `revivers` | `Revivers` | Reviver functions for deserialization. Use [`observabilityRevivers`](/docs/api-reference/workflow-observability/observability-revivers) for standard use. |
37
+
38
+ ### Returns
39
+
40
+ The same resource with its data fields hydrated into plain JavaScript values.
41
+
42
+ <Callout type="info">
43
+ Encrypted data fields pass through as raw `Uint8Array` values rather than being decrypted — see [Encrypted Data](/docs/api-reference/workflow-observability#encrypted-data).
44
+ </Callout>
45
+
46
+ ## Examples
47
+
48
+ ### Display a Run's Steps with Hydrated I/O
49
+
50
+ ```typescript lineNumbers
51
+ import { getWorld } from "workflow/runtime";
52
+ import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
53
+ declare const runId: string; // @setup
54
+
55
+ const world = await getWorld();
56
+ const steps = await world.steps.list({ runId, resolveData: "all" });
57
+
58
+ for (const step of steps.data) {
59
+ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
60
+ console.log(step.stepName, hydrated.input, hydrated.output);
61
+ }
62
+ ```
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: "workflow/observability"
3
+ description: Utilities to hydrate serialized step I/O and parse machine-readable workflow names for display.
4
+ type: overview
5
+ summary: Explore utilities for hydrating serialized workflow data and parsing display names in observability tools.
6
+ keywords:
7
+ - workflow/observability
8
+ - hydrateResourceIO
9
+ - observabilityRevivers
10
+ - hydrateData
11
+ - parseStepName
12
+ - parseWorkflowName
13
+ - parseClassName
14
+ - data hydration
15
+ - devalue deserialization
16
+ - display name parsing
17
+ ---
18
+
19
+ API reference for observability utilities from the `workflow/observability` package.
20
+
21
+ The observability package provides utilities for working with workflow data in observability and debugging tools — hydrating serialized step I/O for display, and parsing machine-readable names into display-friendly formats.
22
+
23
+ ```typescript lineNumbers
24
+ import { // [!code highlight]
25
+ hydrateResourceIO, // [!code highlight]
26
+ observabilityRevivers, // [!code highlight]
27
+ hydrateData, // [!code highlight]
28
+ parseStepName, // [!code highlight]
29
+ parseWorkflowName, // [!code highlight]
30
+ parseClassName, // [!code highlight]
31
+ } from "workflow/observability"; // [!code highlight]
32
+ ```
33
+
34
+ ## Data Hydration
35
+
36
+ <Cards>
37
+ <Card href="/docs/api-reference/workflow-observability/hydrate-resource-io" title="hydrateResourceIO()">
38
+ Hydrate the serialized data fields of a run, step, hook, or event for display.
39
+ </Card>
40
+ <Card href="/docs/api-reference/workflow-observability/observability-revivers" title="observabilityRevivers">
41
+ Standard revivers for deserializing workflow data types (Date, Map, Set, streams, etc.).
42
+ </Card>
43
+ <Card href="/docs/api-reference/workflow-observability/hydrate-data" title="hydrateData()">
44
+ Hydrate a single serialized value (lower-level than hydrateResourceIO).
45
+ </Card>
46
+ </Cards>
47
+
48
+ ## Name Parsing
49
+
50
+ <Cards>
51
+ <Card href="/docs/api-reference/workflow-observability/parse-step-name" title="parseStepName()">
52
+ Parse a machine-readable step name into display-friendly components.
53
+ </Card>
54
+ <Card href="/docs/api-reference/workflow-observability/parse-workflow-name" title="parseWorkflowName()">
55
+ Parse a machine-readable workflow name into display-friendly components.
56
+ </Card>
57
+ <Card href="/docs/api-reference/workflow-observability/parse-class-name" title="parseClassName()">
58
+ Parse a machine-readable class ID into display-friendly components.
59
+ </Card>
60
+ </Cards>
61
+
62
+ ## Encrypted Data
63
+
64
+ When a [World](/docs/api-reference/workflow-runtime/world) stores encrypted data, the hydration utilities intentionally leave encrypted values untouched: [`hydrateData()`](/docs/api-reference/workflow-observability/hydrate-data) and [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io) return encrypted fields as raw `Uint8Array` values so observability tools can detect them and decide how to render them (for example, the Workflow CLI shows an "Encrypted" placeholder). Decryption is handled by the runtime and the World implementation — see [Encryption](/docs/how-it-works/encryption) for how keys are managed.
@@ -0,0 +1,11 @@
1
+ {
2
+ "title": "workflow/observability",
3
+ "pages": [
4
+ "hydrate-resource-io",
5
+ "observability-revivers",
6
+ "hydrate-data",
7
+ "parse-step-name",
8
+ "parse-workflow-name",
9
+ "parse-class-name"
10
+ ]
11
+ }
@@ -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,39 @@
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 `Promise<World>` with a newly constructed World instance.
31
+
32
+ <Callout type="info">
33
+ 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).
34
+ </Callout>
35
+
36
+ ## Related Functions
37
+
38
+ - [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the cached World instance (preferred in application code).
39
+ - [`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 `Promise<WorldHandlers>`, 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.