workflow 5.0.0-beta.5 → 5.0.0-beta.50
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.
- package/README.md +68 -23
- package/dist/api-workflow.d.ts +1 -1
- package/dist/api-workflow.d.ts.map +1 -1
- package/dist/api-workflow.js +1 -1
- package/dist/api.d.ts +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/internal/builtins.d.ts +20 -3
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +68 -4
- package/dist/internal/errors.d.ts +1 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +2 -2
- package/dist/nest-builder.d.ts +2 -0
- package/dist/nest-builder.d.ts.map +1 -0
- package/dist/nest-builder.js +2 -0
- package/dist/nest-vercel-builder.d.ts +2 -0
- package/dist/nest-vercel-builder.d.ts.map +1 -0
- package/dist/nest-vercel-builder.js +2 -0
- package/dist/observability.d.ts +1 -1
- package/dist/observability.js +2 -2
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -1
- package/docs/ai/chat-session-modeling.mdx +29 -26
- package/docs/ai/defining-tools.mdx +6 -7
- package/docs/ai/human-in-the-loop.mdx +11 -11
- package/docs/ai/index.mdx +50 -45
- package/docs/ai/message-queueing.mdx +16 -16
- package/docs/ai/meta.json +1 -0
- package/docs/ai/resumable-streams.mdx +40 -28
- package/docs/ai/sleep-and-delays.mdx +10 -10
- package/docs/ai/streaming-updates-from-tools.mdx +6 -6
- package/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +9 -15
- package/docs/api-reference/workflow/create-hook.mdx +89 -10
- package/docs/api-reference/workflow/create-webhook.mdx +16 -15
- package/docs/api-reference/workflow/define-hook.mdx +35 -33
- package/docs/api-reference/workflow/fatal-error.mdx +30 -8
- package/docs/api-reference/workflow/fetch.mdx +14 -10
- package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
- package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
- package/docs/api-reference/workflow/get-writable.mdx +7 -7
- package/docs/api-reference/workflow/index.mdx +4 -1
- package/docs/api-reference/workflow/retryable-error.mdx +1 -1
- package/docs/api-reference/workflow/set-attributes.mdx +61 -0
- package/docs/api-reference/workflow/sleep.mdx +4 -4
- package/docs/api-reference/workflow-ai/durable-agent.mdx +48 -86
- package/docs/api-reference/workflow-ai/index.mdx +3 -3
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +26 -12
- package/docs/api-reference/workflow-api/get-run.mdx +43 -8
- package/docs/api-reference/workflow-api/index.mdx +6 -10
- package/docs/api-reference/workflow-api/resume-hook.mdx +73 -12
- package/docs/api-reference/workflow-api/resume-webhook.mdx +11 -9
- package/docs/api-reference/workflow-api/start.mdx +60 -13
- package/docs/api-reference/workflow-astro/index.mdx +18 -0
- package/docs/api-reference/workflow-astro/meta.json +4 -0
- package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
- package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
- package/docs/api-reference/workflow-errors/index.mdx +88 -0
- package/docs/api-reference/workflow-errors/meta.json +6 -0
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
- package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
- package/docs/api-reference/workflow-globals.mdx +14 -10
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
- package/docs/api-reference/workflow-nest/index.mdx +31 -0
- package/docs/api-reference/workflow-nest/meta.json +9 -0
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
- package/docs/api-reference/workflow-nest/workflow-controller.mdx +40 -0
- package/docs/api-reference/workflow-nest/workflow-module.mdx +74 -0
- package/docs/api-reference/workflow-next/with-workflow.mdx +39 -17
- package/docs/api-reference/workflow-nitro/index.mdx +60 -0
- package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
- package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
- package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
- package/docs/api-reference/workflow-observability/index.mdx +62 -0
- package/docs/api-reference/workflow-observability/meta.json +11 -0
- package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
- package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
- package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
- package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
- package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
- package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +11 -14
- package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/api-reference/workflow-runtime/index.mdx +41 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +51 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +43 -0
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +315 -0
- package/docs/api-reference/workflow-runtime/world/index.mdx +60 -0
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/workflow-runtime/world/queue.mdx +88 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +98 -34
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +8 -8
- package/docs/api-reference/workflow-serde/index.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +3 -4
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +8 -8
- package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
- package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
- package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
- package/docs/api-reference/workflow-vite/index.mdx +18 -0
- package/docs/api-reference/workflow-vite/meta.json +4 -0
- package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
- package/docs/changelog/attributes-mvp.mdx +380 -0
- package/docs/changelog/batched-event-writes.mdx +79 -0
- package/docs/changelog/eager-processing.mdx +110 -436
- package/docs/changelog/index.mdx +4 -2
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/lazy-hook-resume.mdx +78 -0
- package/docs/changelog/meta.json +11 -1
- package/docs/changelog/resilient-resume.mdx +32 -0
- package/docs/changelog/resilient-start.mdx +33 -285
- package/docs/changelog/step-message-ownership.mdx +360 -0
- package/docs/changelog/turbo-mode.md +87 -0
- package/docs/comparisons/index.mdx +66 -0
- package/docs/comparisons/meta.json +11 -0
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +104 -0
- package/docs/configuration/build-and-diagnostics.mdx +70 -0
- package/docs/configuration/cli-and-web-ui.mdx +241 -0
- package/docs/configuration/framework-options.mdx +165 -0
- package/docs/configuration/index.mdx +32 -0
- package/docs/configuration/meta.json +12 -0
- package/docs/configuration/runtime-tuning.mdx +376 -0
- package/docs/configuration/worlds.mdx +313 -0
- package/docs/cookbook/advanced/child-workflows.mdx +211 -264
- package/docs/cookbook/advanced/meta.json +6 -1
- package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
- package/docs/cookbook/advanced/serializable-steps.mdx +28 -20
- package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +27 -19
- package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +30 -22
- package/docs/cookbook/common-patterns/batching.mdx +18 -14
- package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
- package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
- package/docs/cookbook/common-patterns/saga.mdx +23 -19
- package/docs/cookbook/common-patterns/scheduling.mdx +34 -22
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
- package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
- package/docs/cookbook/common-patterns/webhooks.mdx +10 -6
- package/docs/cookbook/common-patterns/workflow-composition.mdx +30 -27
- package/docs/cookbook/index.mdx +22 -21
- package/docs/cookbook/integrations/ai-sdk.mdx +85 -47
- package/docs/cookbook/integrations/chat-sdk.mdx +50 -33
- package/docs/cookbook/integrations/sandbox.mdx +62 -45
- package/docs/deploying.mdx +95 -0
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
- package/docs/errors/corrupted-event-log.mdx +29 -18
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +11 -7
- package/docs/errors/hook-conflict.mdx +69 -13
- package/docs/errors/index.mdx +2 -36
- package/docs/errors/node-js-module-in-workflow.mdx +9 -5
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/run-expired.mdx +85 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +44 -12
- package/docs/errors/start-invalid-workflow-function.mdx +9 -5
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +6 -6
- package/docs/errors/timeout-in-workflow.mdx +12 -8
- package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
- package/docs/errors/webhook-response-not-sent.mdx +20 -16
- package/docs/errors/workflow-not-registered.mdx +5 -5
- package/docs/foundations/cancellation.mdx +31 -32
- package/docs/foundations/errors-and-retries.mdx +42 -11
- package/docs/foundations/hooks.mdx +64 -35
- package/docs/foundations/idempotency.mdx +244 -12
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +2 -1
- package/docs/foundations/serialization.mdx +21 -22
- package/docs/foundations/starting-workflows.mdx +106 -30
- package/docs/foundations/streaming.mdx +107 -59
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/getting-started/astro.mdx +22 -18
- package/docs/getting-started/express.mdx +15 -11
- package/docs/getting-started/fastify.mdx +15 -11
- package/docs/getting-started/hono.mdx +15 -11
- package/docs/getting-started/index.mdx +10 -3
- package/docs/getting-started/meta.json +3 -1
- package/docs/getting-started/nestjs.mdx +87 -20
- package/docs/getting-started/next.mdx +22 -16
- package/docs/getting-started/nitro.mdx +22 -18
- package/docs/getting-started/nuxt.mdx +15 -11
- package/docs/getting-started/python.mdx +135 -40
- package/docs/getting-started/react-router/index.mdx +33 -0
- package/docs/getting-started/react-router/meta.json +5 -0
- package/docs/getting-started/react-router/v7.mdx +237 -0
- package/docs/getting-started/react-router/v8.mdx +232 -0
- package/docs/getting-started/sveltekit.mdx +20 -16
- package/docs/getting-started/tanstack-start.mdx +17 -13
- package/docs/getting-started/vite.mdx +15 -11
- package/docs/how-it-works/cancellation.mdx +63 -63
- package/docs/how-it-works/code-transform.mdx +83 -67
- package/docs/how-it-works/encryption.mdx +30 -26
- package/docs/how-it-works/event-sourcing.mdx +98 -34
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/understanding-directives.mdx +22 -22
- package/docs/internal/index.mdx +6 -4
- package/docs/internal/meta.json +6 -1
- package/docs/internal/nitro-native-build.mdx +38 -0
- package/docs/internal/nitro-web-ui.mdx +24 -0
- package/docs/internal/serializable-abort-controller.mdx +7 -7
- package/docs/meta.json +3 -2
- package/docs/observability/attributes.mdx +134 -0
- package/docs/observability/index.mdx +32 -10
- package/docs/observability/meta.json +1 -1
- package/docs/observability/retention.mdx +93 -0
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +36 -36
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +186 -0
- package/package.json +17 -14
- package/docs/api-reference/workflow-api/world/index.mdx +0 -58
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
- package/docs/deploying/building-a-world.mdx +0 -251
- package/docs/deploying/index.mdx +0 -95
- package/docs/deploying/meta.json +0 -4
- package/docs/deploying/world/local-world.mdx +0 -84
- package/docs/deploying/world/meta.json +0 -4
- package/docs/deploying/world/postgres-world.mdx +0 -224
- package/docs/deploying/world/vercel-world.mdx +0 -179
- package/docs/migration-guides/index.mdx +0 -34
- package/docs/migration-guides/meta.json +0 -9
- package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -363
- package/docs/migration-guides/migrating-from-inngest.mdx +0 -314
- package/docs/migration-guides/migrating-from-temporal.mdx +0 -318
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -337
|
@@ -0,0 +1,51 @@
|
|
|
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 to the build-injected World.
|
|
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, or pass `undefined` to clear the cache so the next `getWorld()` call reconstructs the World that was statically injected into the bundle at build time.
|
|
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 so the next access reconstructs the build-injected World |
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
This function does not return a value.
|
|
34
|
+
|
|
35
|
+
## Example: inject a specific World
|
|
36
|
+
|
|
37
|
+
The build selects the target World via `WORKFLOW_TARGET_WORLD` and statically injects it into the bundle. Changing the environment variable at runtime has no effect. To use a different World at runtime, construct it explicitly with the World package's `createWorld()` factory and inject it:
|
|
38
|
+
|
|
39
|
+
```typescript lineNumbers
|
|
40
|
+
import { setWorld } from "workflow/runtime";
|
|
41
|
+
import { createWorld } from "@workflow/world-local";
|
|
42
|
+
|
|
43
|
+
setWorld(createWorld({ dataDir: "/tmp/workflow-test" })); // [!code highlight]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Calling `setWorld(undefined)` afterwards restores the build-injected World on the next `getWorld()` call.
|
|
47
|
+
|
|
48
|
+
## Related functions
|
|
49
|
+
|
|
50
|
+
- [`getWorld()`](/docs/api-reference/workflow-runtime/get-world): Resolve the cached World instance.
|
|
51
|
+
- [`createWorld()`](/docs/api-reference/workflow-runtime/create-world): Construct a fresh instance of the build-injected World.
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
- [`getWorld()`](/docs/api-reference/workflow-runtime/get-world): Resolve the runtime World instance this handler shares with workflow execution.
|
|
42
|
+
- [`getWorldHandlers()`](/docs/api-reference/workflow-runtime/get-world-handlers): Access build-time-safe World handlers for framework tooling.
|
|
43
|
+
- [`healthCheck()`](/docs/api-reference/workflow-runtime/health-check): Verify the entrypoint processes queue messages end-to-end.
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Analytics
|
|
3
|
+
description: Metadata-only read APIs for runs, steps, events, hooks, waits, and attributes, backed by the observability pipeline.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: "Interfaces: world.analytics.runs, .attributes, .steps, .events, .hooks, .waits. Metadata-only listings with plan-based lookback windows; filter runs by attribute key=value. Page limits are 1000 run-scoped, 100 cross-run."
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-runtime/world/storage
|
|
10
|
+
- /docs/observability/attributes
|
|
11
|
+
keywords:
|
|
12
|
+
- world.analytics
|
|
13
|
+
- analytics.runs
|
|
14
|
+
- analytics.attributes
|
|
15
|
+
- attribute filter
|
|
16
|
+
- getMany
|
|
17
|
+
- pagination limit
|
|
18
|
+
- lookback window
|
|
19
|
+
- observability-upgrade-required
|
|
20
|
+
- pageInfo
|
|
21
|
+
- metadata-only
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
`world.analytics` is an optional, read-only namespace for observability surfaces: dashboards, command-line interface (CLI) tools, and admin tools that list large numbers of runs without touching payload data.
|
|
25
|
+
|
|
26
|
+
Prefer this namespace for observability: listing, filtering, and inspecting
|
|
27
|
+
workflow state. Use the [Storage](/docs/api-reference/workflow-runtime/world/storage)
|
|
28
|
+
API for payload-bearing reads, and for anything operational that has to see the
|
|
29
|
+
canonical, up-to-the-moment record.
|
|
30
|
+
|
|
31
|
+
It differs from [Storage](/docs/api-reference/workflow-runtime/world/storage) in two ways:
|
|
32
|
+
|
|
33
|
+
- **Metadata only**: Results never include run input/output, step data, or hook tokens. There is no `resolveData` option.
|
|
34
|
+
- **Served from the observability pipeline**: On Vercel, queries are served from the Vercel observability data pipeline, so large listings do not compete with workflow execution. Data is ingested asynchronously and may trail the live state by a few seconds.
|
|
35
|
+
|
|
36
|
+
The namespace is optional: worlds that don't implement it (such as the local development world) leave it `undefined`, so feature-detect before use:
|
|
37
|
+
|
|
38
|
+
```typescript lineNumbers
|
|
39
|
+
import { getWorld } from "workflow/runtime";
|
|
40
|
+
|
|
41
|
+
const world = await getWorld();
|
|
42
|
+
if (world.analytics) { // [!code highlight]
|
|
43
|
+
const page = await world.analytics.runs.list();
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## analytics.runs
|
|
50
|
+
|
|
51
|
+
### runs.list()
|
|
52
|
+
|
|
53
|
+
List runs with metadata, current status, and attributes. Without an explicit time window, the listing defaults to the trailing 24 hours; pass `startTime`/`endTime` to reach older runs within your plan window.
|
|
54
|
+
|
|
55
|
+
```typescript lineNumbers
|
|
56
|
+
const page = await world.analytics.runs.list({
|
|
57
|
+
workflowName: "orderWorkflow",
|
|
58
|
+
status: "failed",
|
|
59
|
+
attributes: { source: "checkout" }, // [!code highlight]
|
|
60
|
+
pagination: { limit: 50, sortOrder: "desc" },
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
| Parameter | Type | Description |
|
|
65
|
+
|-----------|------|-------------|
|
|
66
|
+
| `params.workflowName` | `string` | Filter to one workflow |
|
|
67
|
+
| `params.status` | `string` | `pending`, `running`, `completed`, `failed`, or `cancelled` |
|
|
68
|
+
| `params.startTime` / `params.endTime` | `string` | ISO 8601 window; must be provided together |
|
|
69
|
+
| `params.attributes` | `Record<string, string>` | Only return runs whose latest attributes match every pair (up to 8) |
|
|
70
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination |
|
|
71
|
+
|
|
72
|
+
**Returns:** `PaginatedResponse<AnalyticsRun>`. Each run includes `runId`, `status`, `workflowName`, `deploymentId`, `attributes`, and lifecycle timestamps.
|
|
73
|
+
|
|
74
|
+
Attribute matching is latest-write-wins: a run whose attribute moved from `"v1"` to `"v2"` no longer matches `{ key: "v1" }`. Reserved `$`-prefixed keys may be used in filters even though user code cannot write them.
|
|
75
|
+
|
|
76
|
+
### runs.get()
|
|
77
|
+
|
|
78
|
+
Fetch one run by ID. Point lookups search the full plan window rather than only the trailing 24 hours.
|
|
79
|
+
|
|
80
|
+
```typescript lineNumbers
|
|
81
|
+
const run = await world.analytics.runs.get(runId);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## analytics.attributes
|
|
87
|
+
|
|
88
|
+
Discover which [attributes](/docs/observability/attributes) exist on your runs, for example to build filter dropdowns over arbitrary user-defined keys.
|
|
89
|
+
|
|
90
|
+
### attributes.list()
|
|
91
|
+
|
|
92
|
+
List the distinct attribute keys observed on runs in the window, ordered alphabetically.
|
|
93
|
+
|
|
94
|
+
```typescript lineNumbers
|
|
95
|
+
const page = await world.analytics.attributes.list({ // [!code highlight]
|
|
96
|
+
workflowName: "orderWorkflow",
|
|
97
|
+
});
|
|
98
|
+
for (const { key, runCount, lastSeenAt } of page.data) {
|
|
99
|
+
console.log(key, runCount, lastSeenAt);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Parameter | Type | Description |
|
|
104
|
+
|-----------|------|-------------|
|
|
105
|
+
| `params.workflowName` | `string` | Only count runs of one workflow |
|
|
106
|
+
| `params.startTime` / `params.endTime` | `string` | ISO 8601 window; must be provided together |
|
|
107
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination |
|
|
108
|
+
|
|
109
|
+
**Returns:** `PaginatedResponse<AnalyticsAttributeKey>`: `{ key, runCount, firstSeenAt, lastSeenAt }`
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## analytics.steps
|
|
114
|
+
|
|
115
|
+
Run-scoped step listings mirroring their [Storage](/docs/api-reference/workflow-runtime/world/storage) counterparts, minus payload data.
|
|
116
|
+
|
|
117
|
+
### steps.list()
|
|
118
|
+
|
|
119
|
+
```typescript lineNumbers
|
|
120
|
+
const steps = await world.analytics.steps.list({
|
|
121
|
+
runId,
|
|
122
|
+
pagination: { limit: 200, sortOrder: "asc" },
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Parameter | Type | Description |
|
|
127
|
+
|-----------|------|-------------|
|
|
128
|
+
| `params.runId` | `string` | Required. The run to list steps for |
|
|
129
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination, `limit` up to 1000 |
|
|
130
|
+
|
|
131
|
+
**Returns:** `PaginatedResponse<AnalyticsStep>`. Each step includes `stepId`, `stepName`, `status`, `attempt`, lifecycle timestamps, `errorCode`, and the `computeInstanceId` of the latest attempt.
|
|
132
|
+
|
|
133
|
+
### steps.get()
|
|
134
|
+
|
|
135
|
+
```typescript lineNumbers
|
|
136
|
+
const step = await world.analytics.steps.get(runId, stepId);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Returns:** `AnalyticsStep`. A step id is only unique within its run, so both arguments are required.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## analytics.events
|
|
144
|
+
|
|
145
|
+
### events.list()
|
|
146
|
+
|
|
147
|
+
```typescript lineNumbers
|
|
148
|
+
const events = await world.analytics.events.list({
|
|
149
|
+
runId,
|
|
150
|
+
eventType: "step_failed", // [!code highlight]
|
|
151
|
+
pagination: { limit: 1000 },
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Parameter | Type | Description |
|
|
156
|
+
|-----------|------|-------------|
|
|
157
|
+
| `params.runId` | `string` | Required. The run to list events for |
|
|
158
|
+
| `params.eventType` | `string` | One event type, for example `run_failed` or `step_retrying` |
|
|
159
|
+
| `params.correlationId` | `string` | Narrow to one entity: a step, hook, wait, or attribute id |
|
|
160
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination, `limit` up to 1000 |
|
|
161
|
+
|
|
162
|
+
**Returns:** `PaginatedResponse<AnalyticsEvent>`. Each event includes `eventId`, `eventType`, `correlationId`, `stepName`, `createdAt`, and provenance fields (`region`, `requestId`, `computeInstanceId`).
|
|
163
|
+
|
|
164
|
+
Pass a step id as `correlationId` to build that step's timeline: `step_created` through `step_completed`, `step_failed`, or `step_retrying`.
|
|
165
|
+
|
|
166
|
+
### events.get()
|
|
167
|
+
|
|
168
|
+
```typescript lineNumbers
|
|
169
|
+
const event = await world.analytics.events.get(runId, eventId);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Returns:** `AnalyticsEvent`.
|
|
173
|
+
|
|
174
|
+
### events.getMany()
|
|
175
|
+
|
|
176
|
+
Look up a bounded set of event ids in one run with a single request.
|
|
177
|
+
|
|
178
|
+
```typescript lineNumbers
|
|
179
|
+
const events = await world.analytics.events.getMany(runId, eventIds); // [!code highlight]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Returns:** `AnalyticsEvent[]` — not paginated, and no `pageInfo`. Duplicate ids are looked up once, and ids with no analytics row yet are **omitted rather than erroring**, since ingestion can trail canonical storage. Compare the returned length against your input to detect that.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## analytics.hooks
|
|
187
|
+
|
|
188
|
+
### hooks.list()
|
|
189
|
+
|
|
190
|
+
```typescript lineNumbers
|
|
191
|
+
const hooks = await world.analytics.hooks.list({ runId });
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
| Parameter | Type | Description |
|
|
195
|
+
|-----------|------|-------------|
|
|
196
|
+
| `params.runId` | `string` | Required. The run to list hooks for |
|
|
197
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination, `limit` up to 100 |
|
|
198
|
+
|
|
199
|
+
**Returns:** `PaginatedResponse<AnalyticsHook>`: `hookId`, `status` (`created`, `received`, `disposed`, or `conflict`), `receivedAt`, `disposedAt`, `isWebhook`, `isSystem`.
|
|
200
|
+
|
|
201
|
+
### hooks.get()
|
|
202
|
+
|
|
203
|
+
```typescript lineNumbers
|
|
204
|
+
const hook = await world.analytics.hooks.get(hookId);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Unlike steps and waits, a hook id identifies one hook on its own, so no `runId` is needed. Pass `{ runId }` to scope the lookup when you already know it.
|
|
208
|
+
|
|
209
|
+
<Callout>
|
|
210
|
+
Hook listings never include the hook token. Resolve it separately through the
|
|
211
|
+
runtime APIs if you need to deliver a payload.
|
|
212
|
+
</Callout>
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## analytics.waits
|
|
217
|
+
|
|
218
|
+
### waits.list()
|
|
219
|
+
|
|
220
|
+
```typescript lineNumbers
|
|
221
|
+
const waits = await world.analytics.waits.list({
|
|
222
|
+
runId,
|
|
223
|
+
status: "waiting", // [!code highlight]
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
| Parameter | Type | Description |
|
|
228
|
+
|-----------|------|-------------|
|
|
229
|
+
| `params.runId` | `string` | Required. The run to list waits for |
|
|
230
|
+
| `params.status` | `string` | `waiting` or `completed` |
|
|
231
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination, `limit` up to 1000 |
|
|
232
|
+
|
|
233
|
+
**Returns:** `PaginatedResponse<AnalyticsWait>`: `waitId`, `status`, `resumeAt`, `completedAt`.
|
|
234
|
+
|
|
235
|
+
### waits.get()
|
|
236
|
+
|
|
237
|
+
```typescript lineNumbers
|
|
238
|
+
const wait = await world.analytics.waits.get(runId, waitId);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Returns:** `AnalyticsWait`. A wait id is only unique within its run, so both arguments are required.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Limits and validation
|
|
246
|
+
|
|
247
|
+
Arguments are validated in your process before a request goes out. An
|
|
248
|
+
out-of-range or malformed argument throws a `RangeError` naming the bound it
|
|
249
|
+
broke, rather than reaching the backend and coming back as a 400 — which
|
|
250
|
+
matters because analytics is optional and callers commonly wrap it in a
|
|
251
|
+
`try`/`catch`, where a rejected request is easy to mistake for "no data".
|
|
252
|
+
|
|
253
|
+
### Page limits
|
|
254
|
+
|
|
255
|
+
`pagination.limit` defaults to 40 everywhere. The maximum depends on whether
|
|
256
|
+
the listing scans within one run or across runs:
|
|
257
|
+
|
|
258
|
+
| Method | Max `limit` |
|
|
259
|
+
|--------|-------------|
|
|
260
|
+
| `steps.list()`, `events.list()`, `waits.list()` | 1000 |
|
|
261
|
+
| `runs.list()`, `attributes.list()`, `hooks.list()` | 100 |
|
|
262
|
+
|
|
263
|
+
`events.getMany()` is not paginated; it accepts 1 to 100 event ids per call.
|
|
264
|
+
|
|
265
|
+
<Callout type="warn">
|
|
266
|
+
The two page caps differ by a factor of ten, and `hooks.list()` takes the
|
|
267
|
+
lower one despite being run-scoped. Reusing one page size across listings is
|
|
268
|
+
the most common way to trip this.
|
|
269
|
+
</Callout>
|
|
270
|
+
|
|
271
|
+
### Identifiers
|
|
272
|
+
|
|
273
|
+
Every id is a prefix plus a ULID, and each is checked before the request:
|
|
274
|
+
|
|
275
|
+
| Parameter | Shape |
|
|
276
|
+
|-----------|-------|
|
|
277
|
+
| `runId` | `wrun_` |
|
|
278
|
+
| `stepId` | `step_` |
|
|
279
|
+
| `eventId` | `evnt_` |
|
|
280
|
+
| `hookId` | `hook_` |
|
|
281
|
+
| `waitId` | `wait_` |
|
|
282
|
+
| `correlationId` | `step_`, `hook_`, `wait_`, or `attr_` |
|
|
283
|
+
|
|
284
|
+
Step, event, and wait ids are only unique **within** their run, so the methods that take them require a `runId` too. A hook id stands alone.
|
|
285
|
+
|
|
286
|
+
### Time windows
|
|
287
|
+
|
|
288
|
+
`startTime` and `endTime` must be supplied **together** and be parseable ISO 8601 timestamps with `startTime` no later than `endTime`. Passing one without the other throws: it used to be dropped silently, which turned a listing you meant to bound into a scan of the whole retention window that looked like a successful answer.
|
|
289
|
+
|
|
290
|
+
### Attribute filters
|
|
291
|
+
|
|
292
|
+
`runs.list({ attributes })` accepts 1 to 8 pairs. Keys are 1 to 256 characters; values are at most 256 UTF-8 bytes. Reserved `$`-prefixed keys are valid in a filter even though user code cannot write them.
|
|
293
|
+
|
|
294
|
+
### Pagination
|
|
295
|
+
|
|
296
|
+
`cursor` is an opaque token from the previous response; do not construct or parse one. Branch on `hasMore`, not on `cursor` being non-null, and do not change `sortOrder` mid-walk — the cursor encodes the sort position, so reversing it can skip or repeat rows.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Lookback windows and pageInfo
|
|
301
|
+
|
|
302
|
+
Every paginated response carries `pageInfo` describing the window the query was allowed to scan:
|
|
303
|
+
|
|
304
|
+
{/* @skip-typecheck: shape illustration, not runnable code */}
|
|
305
|
+
```typescript
|
|
306
|
+
{
|
|
307
|
+
currentLookbackDays: 2, // what your plan allows today
|
|
308
|
+
maxLookbackDays: 30, // ceiling with Observability Plus on Vercel
|
|
309
|
+
currentWindowStart: Date,
|
|
310
|
+
maxWindowStart: Date,
|
|
311
|
+
upgradeAvailable: true, // for Vercel deployed workflows
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Requests for a window older than `currentWindowStart` fail with an `observability-upgrade-required` error; windows older than `maxWindowStart` return not-found. Use `pageInfo` to size date pickers and to decide whether to surface an upgrade prompt.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: World SDK
|
|
3
|
+
description: Low-level API for inspecting and managing workflow runs, steps, events, hooks, streams, and queues, with an analytics namespace for metadata listings and attribute search.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Access workflow infrastructure via await getWorld() for building observability dashboards, admin tools, and custom integrations.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
keywords:
|
|
9
|
+
- getWorld
|
|
10
|
+
- World SDK
|
|
11
|
+
- workflow runtime
|
|
12
|
+
- observability dashboard
|
|
13
|
+
- admin panel
|
|
14
|
+
- workflow management
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
The World SDK provides direct access to workflow infrastructure, including runs, steps, events, hooks, streams, and queues. It also provides a metadata-only [Analytics](/docs/api-reference/workflow-runtime/world/analytics) namespace with attribute discovery and filtering. Use it to build observability dashboards, admin panels, debugging tools, and custom workflow management logic.
|
|
18
|
+
|
|
19
|
+
```typescript lineNumbers
|
|
20
|
+
import { getWorld } from "workflow/runtime";
|
|
21
|
+
|
|
22
|
+
const world = await getWorld(); // [!code highlight]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Interfaces
|
|
26
|
+
|
|
27
|
+
<Cards>
|
|
28
|
+
<Card href="/docs/api-reference/workflow-runtime/world/storage" title="Storage">
|
|
29
|
+
Query runs, steps, hooks, and the underlying event log.
|
|
30
|
+
</Card>
|
|
31
|
+
<Card href="/docs/api-reference/workflow-runtime/world/analytics" title="Analytics">
|
|
32
|
+
Metadata-only listings with attribute discovery and filtering, built for observability dashboards.
|
|
33
|
+
</Card>
|
|
34
|
+
<Card href="/docs/api-reference/workflow-runtime/world/streams" title="Streams">
|
|
35
|
+
Read, write, and manage real-time data streams for workflow runs.
|
|
36
|
+
</Card>
|
|
37
|
+
<Card href="/docs/api-reference/workflow-runtime/world/queue" title="Queue">
|
|
38
|
+
Low-level queue dispatch (internal SDK infrastructure).
|
|
39
|
+
</Card>
|
|
40
|
+
</Cards>
|
|
41
|
+
|
|
42
|
+
<Callout type="info">
|
|
43
|
+
The World SDK is the low-level foundation that higher-level functions like [`getRun()`](/docs/api-reference/workflow-api/get-run) and [`start()`](/docs/api-reference/workflow-api/start) are built on. Use it when you need capabilities beyond what those functions provide.
|
|
44
|
+
</Callout>
|
|
45
|
+
|
|
46
|
+
Beyond these namespaces, the `World` interface carries several top-level members for World authors: `specVersion`, `capabilities`, lifecycle hooks (`start()`/`close()`), `getEncryptionKeyForRun()`, and the optional `createRunId()` / `describeRun()` hooks behind regional run placement and World-specific `inspect` output. [Building a World](/worlds/building-a-world) documents these members.
|
|
47
|
+
|
|
48
|
+
## Data hydration
|
|
49
|
+
|
|
50
|
+
The [devalue](https://github.com/Rich-Harris/devalue) format serializes step input/output data. To display this data in your UI, use the hydration utilities from `workflow/observability`:
|
|
51
|
+
|
|
52
|
+
```typescript lineNumbers
|
|
53
|
+
import { hydrateResourceIO, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
54
|
+
|
|
55
|
+
const step = await world.steps.get(runId, stepId);
|
|
56
|
+
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
57
|
+
console.log(hydrated.input, hydrated.output);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See [`workflow/observability`](/docs/api-reference/workflow-observability) for the full API.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Queue
|
|
3
|
+
description: Low-level queue interface for dispatching workflow invocations.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: "Methods: getDeploymentId(), queue(), createQueueHandler(). The SDK normally handles internal queue dispatch."
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-api/start
|
|
10
|
+
- /docs/foundations/starting-workflows
|
|
11
|
+
keywords:
|
|
12
|
+
- world.queue
|
|
13
|
+
- getDeploymentId
|
|
14
|
+
- queue
|
|
15
|
+
- createQueueHandler
|
|
16
|
+
- ValidQueueName
|
|
17
|
+
- queue dispatch
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Queue methods live directly on the `world` object (not nested). They dispatch internal workflow invocations, including queued step work, to the queue backend.
|
|
21
|
+
|
|
22
|
+
<Callout type="warn">
|
|
23
|
+
The Workflow SDK uses these methods internally to dispatch execution. In normal operations, use [`start()`](/docs/api-reference/workflow-api/start) to trigger workflows instead. You only need direct queue access to start the initial execution of a run you programmatically created via `world.events.create()` with a `run_created` event, or to debug flow resumption.
|
|
24
|
+
</Callout>
|
|
25
|
+
|
|
26
|
+
## Import
|
|
27
|
+
|
|
28
|
+
```typescript lineNumbers
|
|
29
|
+
import { getWorld } from "workflow/runtime";
|
|
30
|
+
|
|
31
|
+
const world = await getWorld(); // [!code highlight]
|
|
32
|
+
// Call queue methods directly on world, for example, world.queue()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Methods
|
|
36
|
+
|
|
37
|
+
### getDeploymentId()
|
|
38
|
+
|
|
39
|
+
Get the current deployment ID. The SDK uses it internally to route queue messages to the correct deployment.
|
|
40
|
+
|
|
41
|
+
```typescript lineNumbers
|
|
42
|
+
const deploymentId = await world.getDeploymentId(); // [!code highlight]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Returns:** `string`. The current deployment ID.
|
|
46
|
+
|
|
47
|
+
### queue()
|
|
48
|
+
|
|
49
|
+
Dispatch a message to a named queue. The message payload is an internal SDK type (`WorkflowInvokePayload` or `HealthCheckPayload`). Queued steps use `WorkflowInvokePayload` with `stepId` and `stepName`.
|
|
50
|
+
|
|
51
|
+
```typescript lineNumbers
|
|
52
|
+
const { messageId } = await world.queue(queueName, payload, opts); // [!code highlight]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Parameters:**
|
|
56
|
+
|
|
57
|
+
| Parameter | Type | Description |
|
|
58
|
+
|-----------|------|-------------|
|
|
59
|
+
| `queueName` | `ValidQueueName` | The queue name (branded string) |
|
|
60
|
+
| `message` | `QueuePayload` | Internal SDK payload |
|
|
61
|
+
| `opts` | `QueueOptions` | Optional: `deploymentId`, `idempotencyKey`, `delaySeconds`, `headers`, `region` (regional routing hint), `specVersion` |
|
|
62
|
+
|
|
63
|
+
**Returns:** `{ messageId: MessageId | null }`
|
|
64
|
+
|
|
65
|
+
### createQueueHandler()
|
|
66
|
+
|
|
67
|
+
Create an HTTP handler that processes messages from a queue. Use it to set up the queue consumer endpoint.
|
|
68
|
+
|
|
69
|
+
```typescript lineNumbers
|
|
70
|
+
const handler = world.createQueueHandler(prefix, callback); // [!code highlight]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
|
|
75
|
+
| Parameter | Type | Description |
|
|
76
|
+
|-----------|------|-------------|
|
|
77
|
+
| `prefix` | `QueuePrefix` | Queue name prefix to match |
|
|
78
|
+
| `callback` | `(message, meta) => Promise<void \| { timeoutSeconds: number }>` | Handler called for each message. `meta` contains `attempt`, `queueName`, `messageId`, `requestId`. |
|
|
79
|
+
|
|
80
|
+
**Returns:** `(req: Request) => Promise<Response>`
|
|
81
|
+
|
|
82
|
+
`meta.messageId` should be stable across redeliveries of the same message (one ID per enqueued message, reused on every delivery attempt). The runtime records it on inline `step_started` events as a liveness lease so that only a redelivery of the owning message re-executes a crashed inline step before the lease expires (see [Inline step message ownership](/docs/changelog/step-message-ownership)). A World whose queue mints a fresh ID per delivery degrades gracefully. Crashed inline steps recover via the delayed backstop instead of immediately on redelivery, but never wedge or duplicate.
|
|
83
|
+
|
|
84
|
+
## Related
|
|
85
|
+
|
|
86
|
+
- [start()](/docs/api-reference/workflow-api/start): The standard way to start workflow runs
|
|
87
|
+
- [Starting Workflows](/docs/foundations/starting-workflows): Core concepts for workflow invocation
|
|
88
|
+
- [Storage](/docs/api-reference/workflow-runtime/world/storage): Create events that trigger queue dispatch
|