workflow 5.7.1 → 5.7.2

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.
@@ -54,6 +54,7 @@ export default defineConfig({
54
54
  | `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for integrated development environment (IDE) IntelliSense. |
55
55
  | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (for example, `'nodejs22.x'` or `'nodejs24.x'`). Only applies when deploying to Vercel. |
56
56
  | `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
57
+ | `dashboard` | `boolean \| { enabled?: boolean; path?: string; allowedHosts?: string[] \| true }` | `true` (dev) / `false` (prod) | Embeds the observability web UI at `/_workflow` (or `path`). Never mounted on Vercel. `allowedHosts` lists host names the dashboard accepts besides `localhost`, `*.localhost`, and IP addresses; defaults to `WORKFLOW_WEB_ALLOWED_HOSTS`. |
57
58
 
58
59
  ## Vite-based Nitro
59
60
 
@@ -69,6 +69,12 @@ Whichever way they are resolved, the CLI ends up building a Vercel World from an
69
69
  - Default: `3456`
70
70
  - Port for the local web UI server.
71
71
 
72
+ ### `--webAllowedHosts`
73
+
74
+ - Environment variable: `WORKFLOW_WEB_ALLOWED_HOSTS`
75
+ - Default: none
76
+ - Comma-separated host names the local web UI accepts in the `Host` header, in addition to `localhost`, `*.localhost`, and IP addresses, which are always accepted. An entry starting with a dot (`.example.com`) matches the domain and all of its subdomains; `*` accepts any host name. Requests under any other host name are rejected with `403`, which protects the UI from DNS rebinding by web pages you visit. Set this when you reach the UI under a domain name, for example behind a reverse proxy or through a hostname on your network.
77
+
72
78
  ### `--noBrowser`
73
79
 
74
80
  - Environment variable: `WORKFLOW_DISABLE_BROWSER_OPEN`
@@ -184,6 +190,15 @@ per flag.
184
190
  - Default: disabled
185
191
  - Decrypts encrypted values. Triggers an audit-logged key retrieval.
186
192
 
193
+ ### `--usage`
194
+
195
+ - Command: `workflow inspect run <run-id>`
196
+ - Default: disabled
197
+ - Prints the run's [usage](/docs/observability/usage) instead of the run: its events by type, and its storage. With `--json`, prints the same numbers as JSON.
198
+ - Only the Local World counts usage; on other backends the command fails rather than printing the run.
199
+ - Cannot be combined with `--url`/`--web`, `--withData`, or `--decrypt`.
200
+ - Prints in color only to a terminal; output is plain text when piped, with `NO_COLOR` set, or with `TERM=dumb`.
201
+
187
202
  ## Bulk cancel
188
203
 
189
204
  `workflow cancel <run-id>` cancels one run. Given a filter instead, it bulk-cancels a batch; bulk mode requires `--status` or `--workflowName`.
@@ -81,6 +81,12 @@ Configure Workflow through the Nitro `workflow` module options.
81
81
  - Default: `inline` in development, `false` in production
82
82
  - Controls source maps for generated workflow bundles.
83
83
 
84
+ ### `workflow.dashboard`
85
+
86
+ - Environment override: `WORKFLOW_WEB_ALLOWED_HOSTS` (for `allowedHosts`)
87
+ - Default: enabled in development, disabled in production builds, never mounted on Vercel
88
+ - Embeds the observability web UI in the Nitro server at `/_workflow`. Pass `true` or `false` to force it on or off, or an object `{ enabled, path, allowedHosts }`. `allowedHosts` lists host names the dashboard accepts in the `Host` header besides `localhost`, `*.localhost`, and IP addresses (`.example.com` matches the domain and its subdomains, `true` accepts any host); requests under any other name get a `403`. See [`--webAllowedHosts`](/docs/configuration/cli-and-web-ui#--weballowedhosts).
89
+
84
90
  ## NestJS
85
91
 
86
92
  Configure Workflow through `WorkflowModule.forRoot()`.
@@ -63,7 +63,7 @@ If a run doesn't need to be a single long-lived run, start [child workflows](/co
63
63
 
64
64
  ### Fix unbounded loops
65
65
 
66
- If the run wasn't expected to grow this large, check the workflow function for loops that create steps, hooks, or sleeps without terminating.
66
+ If the run wasn't expected to grow this large, check the workflow function for loops that create steps, hooks, or sleeps without terminating. A run's [usage](/docs/observability/usage) shows which steps and hooks write its events.
67
67
 
68
68
  ## This error cannot be caught
69
69
 
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "title": "Observability",
3
- "pages": ["tracing", "attributes", "retention", "lifecycle-hooks"]
3
+ "pages": ["tracing", "attributes", "retention", "usage", "lifecycle-hooks"]
4
4
  }
@@ -59,7 +59,8 @@ error; the payloads on the event log; and stream contents.
59
59
  status, step names, and any [attributes](/docs/observability/attributes) you
60
60
  set. They are kept for the World's default period so the run stays visible in
61
61
  the CLI and web UI. A purged run is still listed and still traceable; its
62
- payloads simply read back as expired.
62
+ payloads simply read back as expired. Its [usage](/docs/observability/usage)
63
+ still reports what it wrote.
63
64
 
64
65
  Inspecting a purged run shows it as expired rather than failing. The Workflow
65
66
  CLI renders the run's own input, output and error as `<data expired>`:
@@ -0,0 +1,83 @@
1
+ ---
2
+ title: Usage
3
+ description: See where a run's events come from and how much it stores.
4
+ type: reference
5
+ summary: See a run's events, by step and hook, and its storage, counted the way Vercel bills them.
6
+ prerequisites:
7
+ - /docs/foundations/workflows-and-steps
8
+ related:
9
+ - /docs/observability
10
+ - /docs/observability/retention
11
+ ---
12
+
13
+ A run's usage shows where its events come from (which steps and hooks drive them) and how much it stores, counted the way Vercel bills them, so you can estimate a workflow's cost before you deploy it. Usage is available on the Local World.
14
+
15
+ ## See a run's usage
16
+
17
+ ```bash
18
+ npx workflow inspect run <run_id> --usage
19
+ ```
20
+
21
+ ```
22
+ processOrder wrun_01M7V5GYES4PYRWR5STNZ6G5ME ● completed
23
+
24
+ Events 19
25
+ Storage (local) 3.52 KB
26
+
27
+ TYPE NAME EVENTS SHARE
28
+ Steps 3 calls ↻ 1 retry 11 58% ██████░░░░
29
+ ├─ sendEmail 2 calls 6 32% ███░░░░░░░
30
+ └─ chargeCard 1 call ↻ 1 retry 5 26% ███░░░░░░░
31
+ Hooks 1 hook 3 16% ██░░░░░░░░
32
+ └─ approval:order-1042 3 16% ██░░░░░░░░
33
+ Sleeps 1 sleep 2 11% █░░░░░░░░░
34
+ Run 3 16% ██░░░░░░░░
35
+ TOTAL 19 100%
36
+
37
+ How usage is counted: https://workflow-sdk.dev/docs/observability/usage
38
+
39
+ STORAGE (LOCAL) SIZE
40
+ Run 500 B
41
+ Steps 2.82 KB
42
+ Hooks 200 B
43
+ TOTAL 3.52 KB
44
+
45
+ Local runs aren't billed. Counted from this run's log in your local data directory.
46
+ Machine-readable: --json
47
+ ```
48
+
49
+ In the web UI, a run's header shows its **Events** and **Storage (local)**. Select either one, or the run's **Usage** tab, to open its Usage page (`/run/<run_id>/usage`), which shows the same table.
50
+
51
+ `--json` prints the same numbers as JSON. Its shape is experimental and may change.
52
+
53
+ The output includes hook tokens, and a token resumes its hook. Share it, `--json` included, only where you would share the run's data.
54
+
55
+ ## What's counted
56
+
57
+ ### Events
58
+
59
+ Every event in the run's log counts once. [Event sourcing](/docs/how-it-works/event-sourcing) describes which events a run, its steps, hooks and sleeps write.
60
+
61
+ ### Storage
62
+
63
+ **Storage (local)** counts the bytes of the run's payloads as the SDK sent them (compressed when that saves space, and encrypted when encryption is on): run inputs and outputs, step inputs and results, errors, and hook metadata and payloads. It adds the bytes the run wrote to its streams. Event metadata, such as ids and timestamps, isn't counted. A run started with `experimental_retention: 0` reports what it wrote before its data was deleted.
64
+
65
+ When a run's data is deleted, its sizes stay in the local data directory, so usage can still report them.
66
+
67
+ Two kinds of data aren't counted locally:
68
+
69
+ - **QuickJS VM snapshots.**
70
+ - **A dynamic workflow's code.**
71
+
72
+ The numbers describe this run. The same workflow can record a different number of events on another run, for example with more or fewer retries.
73
+
74
+ ## On Vercel
75
+
76
+ A run's events are its Workflow Events, and **Storage (local)** is counted the way Data Written is, except that Data Written also includes QuickJS VM snapshots and a dynamic workflow's code. Usage doesn't show Data Retained, function compute, or queues; see [Workflow pricing](https://vercel.com/docs/workflows/pricing), and open a run on the Workflows page in the [Vercel dashboard](https://vercel.com/dashboard) for what it was billed.
77
+
78
+ ## Reduce a run's usage
79
+
80
+ - [Batching](/cookbook/common-patterns/batching)
81
+ - [Child workflows](/cookbook/advanced/child-workflows)
82
+ - [QuickJS runtime](/docs/advanced/quickjs-runtime)
83
+ - [Data retention](/docs/observability/retention)
@@ -30,6 +30,8 @@ npx workflow inspect runs
30
30
  npx workflow web
31
31
  ```
32
32
 
33
+ `npx workflow inspect run <run_id> --usage` shows where a run's events come from and how much it stores; see [Usage](/docs/observability/usage).
34
+
33
35
  Learn more in the [Observability](/docs/observability) documentation.
34
36
 
35
37
  ## Testing & compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "5.7.1",
3
+ "version": "5.7.2",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -60,19 +60,19 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@workflow/astro": "5.0.13",
64
- "@workflow/cli": "5.3.1",
65
- "@workflow/core": "5.7.1",
66
- "@workflow/errors": "5.1.5",
63
+ "@workflow/astro": "5.0.14",
64
+ "@workflow/cli": "5.3.2",
65
+ "@workflow/core": "5.7.2",
66
+ "@workflow/errors": "5.1.6",
67
67
  "@workflow/typescript-plugin": "5.0.1",
68
68
  "@workflow/utils": "5.1.1",
69
69
  "ms": "2.1.3",
70
- "@workflow/next": "5.1.4",
71
- "@workflow/nest": "5.1.11",
72
- "@workflow/nitro": "5.0.13",
73
- "@workflow/nuxt": "5.0.13",
74
- "@workflow/sveltekit": "5.0.13",
75
- "@workflow/rollup": "5.0.13"
70
+ "@workflow/next": "5.1.5",
71
+ "@workflow/nest": "5.1.12",
72
+ "@workflow/nitro": "5.0.14",
73
+ "@workflow/nuxt": "5.0.14",
74
+ "@workflow/sveltekit": "5.0.14",
75
+ "@workflow/rollup": "5.0.14"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@types/ms": "2.1.0",