workflow 5.0.0-beta.34 → 5.0.0-beta.36

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 (71) hide show
  1. package/dist/internal/errors.d.ts +1 -1
  2. package/dist/internal/errors.d.ts.map +1 -1
  3. package/dist/internal/errors.js +2 -2
  4. package/dist/nest-builder.d.ts +2 -0
  5. package/dist/nest-builder.d.ts.map +1 -0
  6. package/dist/nest-builder.js +2 -0
  7. package/dist/nest-vercel-builder.d.ts +2 -0
  8. package/dist/nest-vercel-builder.d.ts.map +1 -0
  9. package/dist/nest-vercel-builder.js +2 -0
  10. package/docs/api-reference/workflow/create-hook.mdx +43 -2
  11. package/docs/api-reference/workflow/define-hook.mdx +26 -24
  12. package/docs/api-reference/workflow/fatal-error.mdx +29 -7
  13. package/docs/api-reference/workflow/fetch.mdx +3 -4
  14. package/docs/api-reference/workflow/sleep.mdx +1 -1
  15. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +2 -0
  16. package/docs/api-reference/workflow-api/resume-hook.mdx +2 -0
  17. package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
  18. package/docs/api-reference/workflow-api/start.mdx +1 -1
  19. package/docs/api-reference/workflow-errors/index.mdx +3 -0
  20. package/docs/api-reference/workflow-errors/meta.json +1 -0
  21. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +62 -0
  22. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +1 -1
  23. package/docs/comparisons/index.mdx +66 -0
  24. package/docs/comparisons/meta.json +11 -0
  25. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
  26. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
  27. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
  28. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
  29. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
  30. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +103 -0
  31. package/docs/configuration/runtime-tuning.mdx +26 -0
  32. package/docs/configuration/worlds.mdx +6 -7
  33. package/docs/cookbook/common-patterns/idempotency.mdx +1 -1
  34. package/docs/{deploying/index.mdx → deploying.mdx} +6 -8
  35. package/docs/foundations/hooks.mdx +1 -1
  36. package/docs/foundations/idempotency.mdx +16 -9
  37. package/docs/getting-started/astro.mdx +1 -1
  38. package/docs/getting-started/express.mdx +1 -1
  39. package/docs/getting-started/fastify.mdx +1 -1
  40. package/docs/getting-started/hono.mdx +1 -1
  41. package/docs/getting-started/index.mdx +10 -3
  42. package/docs/getting-started/meta.json +3 -1
  43. package/docs/getting-started/nestjs.mdx +63 -2
  44. package/docs/getting-started/next.mdx +2 -2
  45. package/docs/getting-started/nitro.mdx +1 -1
  46. package/docs/getting-started/nuxt.mdx +1 -1
  47. package/docs/getting-started/python.mdx +19 -17
  48. package/docs/getting-started/react-router/index.mdx +33 -0
  49. package/docs/getting-started/react-router/meta.json +5 -0
  50. package/docs/getting-started/react-router/v7.mdx +237 -0
  51. package/docs/getting-started/react-router/v8.mdx +232 -0
  52. package/docs/getting-started/sveltekit.mdx +1 -1
  53. package/docs/getting-started/vite.mdx +1 -1
  54. package/docs/how-it-works/encryption.mdx +3 -3
  55. package/docs/how-it-works/event-sourcing.mdx +6 -6
  56. package/docs/how-it-works/framework-integrations.mdx +3 -3
  57. package/docs/meta.json +1 -1
  58. package/docs/observability/attributes.mdx +9 -0
  59. package/package.json +13 -11
  60. package/docs/deploying/building-a-world.mdx +0 -251
  61. package/docs/deploying/meta.json +0 -4
  62. package/docs/deploying/world/local-world.mdx +0 -101
  63. package/docs/deploying/world/meta.json +0 -4
  64. package/docs/deploying/world/postgres-world.mdx +0 -288
  65. package/docs/deploying/world/vercel-world.mdx +0 -275
  66. package/docs/migration-guides/index.mdx +0 -34
  67. package/docs/migration-guides/meta.json +0 -9
  68. package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -362
  69. package/docs/migration-guides/migrating-from-inngest.mdx +0 -308
  70. package/docs/migration-guides/migrating-from-temporal.mdx +0 -317
  71. package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -332
@@ -1,275 +0,0 @@
1
- ---
2
- title: Vercel World
3
- description: Fully-managed world for Vercel deployments with automatic storage, queuing, and authentication.
4
- type: integration
5
- summary: Deploy workflows to Vercel with fully-managed storage, queuing, and authentication.
6
- prerequisites:
7
- - /docs/deploying
8
- related:
9
- - /docs/how-it-works/encryption
10
- - /docs/deploying/world/local-world
11
- - /docs/deploying/world/postgres-world
12
- ---
13
-
14
- The Vercel World is a fully-managed workflow backend for applications deployed on Vercel. It provides scalable storage, distributed queuing, and automatic authentication with zero configuration.
15
-
16
- When you deploy to Vercel, workflows automatically use the Vercel World - no setup required.
17
-
18
- ## Usage
19
-
20
- Deploy your application to Vercel:
21
-
22
- ```bash
23
- vercel deploy
24
- ```
25
-
26
- That's it. Vercel automatically:
27
-
28
- - Selects the Vercel World backend
29
- - Configures authentication using OIDC tokens
30
- - Provisions storage and queuing infrastructure
31
- - Isolates data per environment (production, preview, development)
32
-
33
- <FluidComputeCallout />
34
-
35
- ## Vercel platform documentation
36
-
37
- For complete details on pricing, usage limits, and included allotments on Vercel, see the official Vercel documentation:
38
-
39
- - **[Vercel Workflow](https://vercel.com/docs/workflows)** — Pricing details, concepts, and observability for Workflow on Vercel
40
- - **[Vercel limits](https://vercel.com/docs/limits)** — Platform-wide limits including Workflow-specific constraints
41
- - **[Vercel Hobby plan](https://vercel.com/docs/plans/hobby)** — Free tier included usage for Workflow and other resources
42
-
43
- For self-hosted deployments, use the [Postgres World](/worlds/postgres). For local development, use the [Local World](/worlds/local).
44
-
45
- ## Multi-region
46
-
47
- The Vercel World runs in every [Vercel Function region](https://vercel.com/docs/regions). Each workflow run is pinned to a single region at creation time: its stored state, queue dispatch, and streams are all served from that region — no cross-region round trips on the hot path. When your application is deployed in the run's region (the automatic case below), step execution is region-local too.
48
-
49
- <Callout type="info">
50
- Multi-region requires `workflow` version **5.0.0-beta.33** or later.
51
- The 4.x release line does not support region pinning — runs created by
52
- 4.x always live in `iad1`.
53
- </Callout>
54
-
55
- ### Automatic region pinning
56
-
57
- No configuration is needed. A run is pinned to the region of the function that creates it:
58
-
59
- - Deploy your app to a single region (via [`regions`](https://vercel.com/docs/project-configuration/vercel-json#regions) in `vercel.json` or the project settings), and every run lives there.
60
- - Deploy to multiple regions for a globally distributed audience, and each run is pinned to the region that served the user who triggered it — workflow data and streaming stay close to that user.
61
-
62
- ### Explicit region selection
63
-
64
- To pin a specific run somewhere else, pass the `region` option to [`start()`](/docs/api-reference/workflow-api/start):
65
-
66
- ```typescript
67
- import { start } from "workflow/api";
68
- import { myWorkflow } from "@/workflows/my-workflow";
69
-
70
- const run = await start(myWorkflow, [input], { region: "sfo1" });
71
- ```
72
-
73
- <Callout type="warn">
74
- The `region` option controls where the run's **data is stored** and where
75
- its **queue messages are dispatched from** — it does not deploy your code
76
- there. Your workflow and step functions execute in the regions your
77
- application is deployed to. For execution to actually happen in the
78
- specified region, your app must be deployed there — via
79
- [`regions`](https://vercel.com/docs/project-configuration/vercel-json#regions) in
80
- `vercel.json` or the Function Regions setting in your project settings.
81
- If it isn't, the run's data lives in the requested region but its steps
82
- execute in the nearest region your app is deployed to.
83
- </Callout>
84
-
85
- ### Good to know
86
-
87
- - Reads, hook resumes, and stream consumers can come from anywhere — the platform routes them to the run's region automatically.
88
- - Runs created by 4.x SDKs (and any runs that existed before you upgraded) live in `iad1` and are unaffected by an upgrade; there is no migration.
89
- - **Hook tokens are currently stored in `iad1`** for every run, regardless of the run's region: the token-to-run mapping that powers [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token) and [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) lives there so tokens — which carry no region information — can always be resolved. Hook *payloads* are not affected: a received payload is recorded on the run's event log, which lives in the run's region like all other run data. This token placement may become a project-level setting in the future.
90
-
91
- ## Limitations
92
-
93
- - **No run migration** - A run's region is fixed at creation. Existing runs cannot be moved to a different region.
94
-
95
- ## Observability
96
-
97
- Workflow observability is built into the Vercel dashboard on your project page. It respects your existing authentication and project permission settings.
98
-
99
- The `workflow` CLI commands open a browser window deeplinked to the Vercel dashboard:
100
-
101
- ```bash
102
- # List workflow runs (opens Vercel dashboard)
103
- npx workflow inspect runs --backend vercel
104
-
105
- # Launch the web UI (opens Vercel dashboard)
106
- npx workflow web --backend vercel
107
- ```
108
-
109
- The CLI automatically retrieves authentication from the Vercel CLI (`vercel login`) and infers project/team IDs from your local Vercel project linking.
110
-
111
- To use the local observability UI instead of the Vercel dashboard:
112
-
113
- ```bash
114
- npx workflow web --backend vercel --localUi
115
- ```
116
-
117
- To override the automatic configuration:
118
-
119
- ```bash
120
- npx workflow inspect runs \
121
- --backend vercel \
122
- --env production \
123
- --project my-project \
124
- --team my-team \
125
- --authToken <your-token>
126
- ```
127
-
128
- Learn more in the [Observability](/docs/observability) documentation.
129
-
130
- ## Testing & Compatibility
131
-
132
- <WorldTestingPerformance worldId="vercel" />
133
-
134
- ## Configuration
135
-
136
- In a Vercel deployment, you do not configure the Vercel World yourself. The platform injects everything the runtime needs, including `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, per-request OIDC tokens, and `VERCEL_DEPLOYMENT_KEY` for encryption.
137
-
138
- Do not set those platform-provided values yourself.
139
-
140
- Most users never need to set the `WORKFLOW_VERCEL_*` variables below. They are only overrides for tools running outside Vercel, such as your laptop or CI, when those tools need to inspect or test a remote Vercel Workflow project and cannot infer the project, team, token, or target environment automatically.
141
-
142
- For example, you might set them when running `workflow inspect runs --backend vercel` from CI without an interactive `vercel login`, or when running tests against a specific preview deployment. In normal local development, the CLI infers these values from your `.vercel` directory and Vercel CLI login. In a deployed Vercel function, these variables have no effect on runtime configuration, and the runtime warns if they are set there.
143
-
144
- ### `WORKFLOW_VERCEL_ENV`
145
-
146
- The Vercel environment to target. Options: `production`, `preview`. Default: `production`.
147
-
148
- ### `WORKFLOW_VERCEL_AUTH_TOKEN`
149
-
150
- Vercel API authentication token (secret — keep it in your environment, not in code). Falls back to `VERCEL_TOKEN`, then to your Vercel CLI login.
151
-
152
- ### `WORKFLOW_VERCEL_PROJECT`
153
-
154
- Vercel project ID (`prj_...`).
155
-
156
- ### `WORKFLOW_VERCEL_PROJECT_NAME`
157
-
158
- Vercel project name/slug, used for dashboard links.
159
-
160
- ### `WORKFLOW_VERCEL_TEAM`
161
-
162
- Vercel team ID.
163
-
164
- ### `WORKFLOW_VERCEL_BACKEND_URL`
165
-
166
- Custom base URL for the Vercel workflow API proxy. Default: `https://api.vercel.com/v1/workflow`.
167
-
168
- ### `VERCEL_WORKFLOW_SERVER_URL`
169
-
170
- Custom workflow-server URL for direct runtime requests, or for the proxy to forward to via `WORKFLOW_VERCEL_BACKEND_URL`. Default: unset; normal deployments should not need this.
171
-
172
- ### `WORKFLOW_SEQUENTIAL_REPLAYS`
173
-
174
- Set `WORKFLOW_SEQUENTIAL_REPLAYS=1` to guarantee that **at most one orchestrator (flow) invocation runs at a time per workflow run**. This behavior is off by default; without it, the runtime relies on idempotency and the event log to tolerate concurrent flow invocations of the same run. It is also enabled by `WORKFLOW_SAFE_MODE=1` when `WORKFLOW_SEQUENTIAL_REPLAYS` is not set explicitly.
175
-
176
- When enabled, each run's orchestrator messages are given their own queue topic and the flow trigger is configured with `maxConcurrency: 1`, so [Vercel Queues](https://vercel.com/docs/queues) processes replays for a given run strictly one at a time. Step executions (which ride the flow topic in the combined handler model) get a per-step topic, so steps keep full parallelism.
177
-
178
- <Callout type="warn">
179
- This variable is read at **both build time and runtime**, so it must be set as a project-level environment variable that applies to your build and your deployed functions. Setting it for only one will produce an inconsistent configuration. The same applies to framework integrations that write their own queue trigger configuration instead of using `getWorkflowQueueTrigger()` from `@workflow/builders`: they only get the runtime half (per-run topics) unless they also emit `maxConcurrency: 1` on their flow trigger.
180
-
181
- Enabling sequential replays has a cost. Per [Vercel Queues pricing](https://vercel.com/docs/queues/pricing), push deliveries under `maxConcurrency` are billed at **2x units** for that operation, so every flow-route delivery costs double while this is enabled. It also creates one queue topic per run, which increases the number of distinct queues surfaced in queue observability, and each flow invocation waits for a per-run concurrency slot before delivery, which can add queueing latency. Leave it off unless you specifically need the per-run serialization guarantee.
182
-
183
-
184
- While a replay holds a run's slot — including time spent executing steps inline — other wake messages for that run (hook resumes, aborts and cancellations, and run-timeout enforcement) wait for the slot. Expect aborts and timeouts to be delayed by up to the duration of the longest single invocation.
185
-
186
- The guarantee covers messages sent by the Workflow SDK itself. External producers that compute a flow topic name directly (rather than enqueueing through the SDK) still deliver, but bypass the per-run serialization slot.
187
- </Callout>
188
-
189
- ### `VERCEL_QUEUE_MAX_DELAY_SECONDS`
190
-
191
- Maximum delay, in seconds, that Workflow uses for one Vercel Queues continuation message when implementing `sleep()`. If a workflow sleeps longer than this, the runtime schedules another continuation message when the first one fires, repeating until the sleep's target time is reached. Default: `82800` (23 hours).
192
-
193
- Vercel Queues can delay messages for up to 7 days, capped by the message TTL. Because the default TTL is 24 hours, Workflow uses a 23-hour continuation hop to stay safely inside that default.
194
-
195
- ### `WORKFLOW_REQUEST_TIMEOUT_MS`
196
-
197
- Per-request timeout, in milliseconds, for Vercel World HTTP calls to workflow-server. Default: `60000`. Minimum: `1`.
198
-
199
- ### `WORKFLOW_MAX_CHUNKS_PER_REQUEST`
200
-
201
- Maximum stream chunks written in one Vercel World request. Larger batches are split across multiple requests. Default: `1000`. Minimum: `1`.
202
-
203
- ### Programmatic configuration
204
-
205
- `createWorld()` accepts explicit API configuration. It does not read `WORKFLOW_VERCEL_*` automatically, so pass the environment values yourself when you want a configured World module:
206
-
207
- {/*@skip-typecheck: incomplete code sample*/}
208
-
209
- ```typescript title="my-world.ts" lineNumbers
210
- import { createWorld } from "@workflow/world-vercel";
211
-
212
- export default createWorld({
213
- token: process.env.WORKFLOW_VERCEL_AUTH_TOKEN,
214
- projectConfig: {
215
- projectId: "prj_...",
216
- teamId: "team_...",
217
- environment: "production",
218
- },
219
- });
220
- ```
221
-
222
- ```bash title=".env"
223
- WORKFLOW_TARGET_WORLD="./my-world.ts"
224
- ```
225
-
226
- ## Versioning
227
-
228
- On Vercel, workflow runs are pegged to the deployment that started them. This means:
229
-
230
- - Existing workflow runs continue executing on their original deployment, even as new code is deployed
231
- - New workflow runs start on the latest deployment
232
- - Code changes won't break in-flight workflows
233
-
234
- This ensures long-running workflows complete reliably without being affected by subsequent deployments.
235
-
236
- For the full model, including rerunning on latest and explicit upgrade boundaries, see [Versioning](/docs/foundations/versioning).
237
-
238
- ## Security
239
-
240
- ### Consumer function security
241
-
242
- Workflow handler functions on Vercel are not accessible through public endpoints. During the build step, the Workflow SDK registers each handler as only reachable by [Vercel Queue](https://vercel.com/docs/queues), by using the `experimentalTriggers` configuration in `.vc-config.json`:
243
-
244
- ```json title=".vc-config.json (step handler)"
245
- {
246
- "experimentalTriggers": [
247
- {
248
- "type": "queue/v2beta",
249
- "topic": "__wkf_step_*",
250
- "consumer": "default",
251
- }
252
- ]
253
- }
254
- ```
255
-
256
- Practically, this means:
257
-
258
- - You don't need to add authentication or authorization logic to workflow handlers
259
- - Unauthorized requests can never reach the step or workflow functions
260
- - Only messages delivered through Vercel Queues can trigger execution
261
- - Handlers receive only a message ID that must be retrieved from Vercel's backend, making it impossible to craft custom payloads
262
-
263
- <Callout>
264
- This configuration is managed entirely by the Workflow SDK build step. You should not need to write this yourself. If you are writing a custom integration, see [Framework Integrations — Security](/docs/how-it-works/framework-integrations#security) for more details.
265
- </Callout>
266
-
267
- ## How It Works
268
-
269
- The Vercel World uses Vercel's infrastructure for workflow execution:
270
-
271
- - **Storage** - Workflow data is stored in Vercel's cloud with automatic replication and [end-to-end encryption](/docs/how-it-works/encryption)
272
- - **Queuing** - Steps are distributed across serverless functions via [Vercel Queues](https://vercel.com/docs/queues) with automatic retries and [consumer function security](#consumer-function-security)
273
- - **Authentication** - OIDC tokens provide secure, automatic authentication
274
-
275
- For more details, see the [Vercel Workflow documentation](https://vercel.com/docs/workflows).
@@ -1,34 +0,0 @@
1
- ---
2
- title: Migration Guides
3
- description: Move your existing durable workflow system to the Workflow SDK with side-by-side code comparisons and a realistic migration example.
4
- type: overview
5
- summary: Migrate from Temporal, Inngest, AWS Step Functions, or trigger.dev to the Workflow SDK.
6
- related:
7
- - /docs/foundations/workflows-and-steps
8
- - /docs/getting-started
9
- ---
10
-
11
- <Callout type="info">
12
- Install the Workflow SDK migration skill:
13
-
14
- ```bash
15
- npx skills add https://github.com/vercel/workflow --skill migrating-to-workflow-sdk
16
- ```
17
- </Callout>
18
-
19
- Move an existing orchestration system to the Workflow SDK. Each guide pairs a concept-mapping table with side-by-side code, so you can translate one piece of your codebase at a time.
20
-
21
- <Cards>
22
- <Card href="/docs/migration-guides/migrating-from-temporal" title="Migrating from Temporal">
23
- Map Activities, Workers, Signals, and Child Workflows onto workflows, steps, hooks, and `start()` / `getRun()`.
24
- </Card>
25
- <Card href="/docs/migration-guides/migrating-from-inngest" title="Migrating from Inngest">
26
- Map `createFunction`, `step.run`, `step.sleep`, `step.waitForEvent`, and `step.invoke` onto workflows, steps, and hooks.
27
- </Card>
28
- <Card href="/docs/migration-guides/migrating-from-aws-step-functions" title="Migrating from AWS Step Functions">
29
- Replace ASL JSON states, Task / Choice / Wait / Parallel states, and `.waitForTaskToken` callbacks with TypeScript.
30
- </Card>
31
- <Card href="/docs/migration-guides/migrating-from-trigger-dev" title="Migrating from trigger.dev">
32
- Map `task()`, `schemaTask()`, `wait.for` / `wait.forToken`, `triggerAndWait`, and `metadata.stream` onto workflows, steps, hooks, and `start()` / `getRun()`.
33
- </Card>
34
- </Cards>
@@ -1,9 +0,0 @@
1
- {
2
- "title": "Migration Guides",
3
- "pages": [
4
- "migrating-from-temporal",
5
- "migrating-from-inngest",
6
- "migrating-from-aws-step-functions",
7
- "migrating-from-trigger-dev"
8
- ]
9
- }