workflow 5.0.0-beta.4 → 5.0.0-beta.41
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 +63 -20
- 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 +5 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +12 -2
- 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 +17 -0
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +65 -1
- 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 +5 -2
- package/docs/ai/chat-session-modeling.mdx +7 -3
- package/docs/ai/defining-tools.mdx +2 -2
- package/docs/ai/index.mdx +30 -25
- package/docs/ai/message-queueing.mdx +10 -10
- package/docs/ai/resumable-streams.mdx +9 -1
- package/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +28 -7
- package/docs/api-reference/workflow/create-hook.mdx +79 -0
- package/docs/api-reference/workflow/create-webhook.mdx +1 -0
- package/docs/api-reference/workflow/define-hook.mdx +26 -24
- package/docs/api-reference/workflow/fatal-error.mdx +29 -7
- package/docs/api-reference/workflow/fetch.mdx +8 -4
- package/docs/api-reference/workflow/index.mdx +3 -0
- package/docs/api-reference/workflow/set-attributes.mdx +61 -0
- package/docs/api-reference/workflow/sleep.mdx +1 -1
- package/docs/api-reference/workflow-ai/durable-agent.mdx +7 -45
- package/docs/api-reference/workflow-ai/index.mdx +2 -2
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +44 -1
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +9 -0
- package/docs/api-reference/workflow-api/get-run.mdx +25 -0
- package/docs/api-reference/workflow-api/index.mdx +6 -8
- package/docs/api-reference/workflow-api/resume-hook.mdx +60 -1
- package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
- package/docs/api-reference/workflow-api/start.mdx +39 -6
- 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/hook-conflict-error.mdx +60 -0
- 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-not-supported-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +16 -6
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-globals.mdx +4 -1
- 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 +56 -2
- 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 +64 -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 +7 -10
- package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/api-reference/workflow-runtime/index.mdx +43 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +49 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +138 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/index.mdx +10 -10
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/queue.mdx +8 -6
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +24 -7
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +2 -2
- package/docs/api-reference/workflow-serde/index.mdx +0 -1
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +2 -2
- 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/eager-processing.mdx +269 -0
- package/docs/changelog/index.mdx +3 -1
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/meta.json +9 -1
- package/docs/changelog/resilient-resume.mdx +22 -0
- package/docs/changelog/resilient-start.mdx +31 -283
- 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 +103 -0
- package/docs/configuration/build-and-diagnostics.mdx +70 -0
- package/docs/configuration/cli-and-web-ui.mdx +182 -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 +281 -0
- package/docs/configuration/worlds.mdx +283 -0
- package/docs/cookbook/advanced/child-workflows.mdx +203 -256
- package/docs/cookbook/advanced/meta.json +1 -1
- package/docs/cookbook/advanced/publishing-libraries.mdx +33 -24
- package/docs/cookbook/advanced/serializable-steps.mdx +12 -4
- package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +34 -75
- package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +11 -3
- package/docs/cookbook/common-patterns/batching.mdx +4 -0
- package/docs/cookbook/common-patterns/idempotency.mdx +40 -52
- package/docs/cookbook/common-patterns/rate-limiting.mdx +5 -1
- package/docs/cookbook/common-patterns/saga.mdx +6 -2
- package/docs/cookbook/common-patterns/scheduling.mdx +12 -0
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +4 -0
- package/docs/cookbook/common-patterns/timeouts.mdx +6 -1
- package/docs/cookbook/common-patterns/webhooks.mdx +4 -0
- package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -16
- package/docs/cookbook/index.mdx +3 -3
- package/docs/cookbook/integrations/ai-sdk.mdx +64 -28
- package/docs/cookbook/integrations/chat-sdk.mdx +17 -0
- package/docs/cookbook/integrations/sandbox.mdx +17 -0
- package/docs/{deploying/index.mdx → deploying.mdx} +7 -7
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +84 -0
- package/docs/errors/corrupted-event-log.mdx +11 -8
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +4 -0
- package/docs/errors/hook-conflict.mdx +60 -4
- package/docs/errors/index.mdx +1 -35
- package/docs/errors/node-js-module-in-workflow.mdx +4 -0
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +4 -0
- package/docs/errors/start-invalid-workflow-function.mdx +4 -0
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +1 -1
- package/docs/errors/timeout-in-workflow.mdx +4 -0
- package/docs/errors/webhook-response-not-sent.mdx +4 -0
- package/docs/foundations/cancellation.mdx +459 -0
- package/docs/foundations/errors-and-retries.mdx +7 -3
- package/docs/foundations/hooks.mdx +29 -0
- package/docs/foundations/idempotency.mdx +243 -11
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +3 -1
- package/docs/foundations/serialization.mdx +77 -41
- package/docs/foundations/starting-workflows.mdx +79 -2
- package/docs/foundations/streaming.mdx +14 -23
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/getting-started/astro.mdx +12 -2
- package/docs/getting-started/express.mdx +6 -2
- package/docs/getting-started/fastify.mdx +6 -2
- package/docs/getting-started/hono.mdx +6 -2
- package/docs/getting-started/index.mdx +16 -10
- package/docs/getting-started/meta.json +4 -1
- package/docs/getting-started/nestjs.mdx +77 -3
- package/docs/getting-started/next.mdx +12 -6
- package/docs/getting-started/nitro.mdx +28 -2
- package/docs/getting-started/nuxt.mdx +6 -2
- package/docs/getting-started/python.mdx +24 -18
- 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 +12 -2
- package/docs/getting-started/tanstack-start.mdx +245 -0
- package/docs/getting-started/vite.mdx +6 -2
- package/docs/how-it-works/cancellation.mdx +287 -0
- package/docs/how-it-works/code-transform.mdx +21 -17
- package/docs/how-it-works/encryption.mdx +5 -5
- package/docs/how-it-works/event-sourcing.mdx +17 -9
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/meta.json +2 -1
- package/docs/internal/index.mdx +21 -0
- package/docs/internal/meta.json +10 -0
- 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 +148 -0
- package/docs/meta.json +2 -2
- package/docs/observability/attributes.mdx +112 -0
- package/docs/observability/index.mdx +20 -1
- package/docs/observability/meta.json +1 -1
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +2 -2
- package/package.json +17 -13
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/cookbook/advanced/distributed-abort-controller.mdx +0 -318
- package/docs/deploying/building-a-world.mdx +0 -251
- 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 -222
- 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,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.
|
|
@@ -36,21 +36,18 @@ showSections={["returns"]}
|
|
|
36
36
|
|
|
37
37
|
## World SDK
|
|
38
38
|
|
|
39
|
-
The World object provides access to several entity interfaces. See the [World SDK](/docs/api-reference/workflow-
|
|
39
|
+
The World object provides access to several entity interfaces. See the [World SDK](/docs/api-reference/workflow-runtime/world) reference for complete documentation:
|
|
40
40
|
|
|
41
41
|
<Cards>
|
|
42
|
-
<Card href="/docs/api-reference/workflow-
|
|
42
|
+
<Card href="/docs/api-reference/workflow-runtime/world/storage" title="Storage">
|
|
43
43
|
Query runs, steps, hooks, and the underlying event log.
|
|
44
44
|
</Card>
|
|
45
|
-
<Card href="/docs/api-reference/workflow-
|
|
45
|
+
<Card href="/docs/api-reference/workflow-runtime/world/streams" title="Streams">
|
|
46
46
|
Read, write, and manage data streams.
|
|
47
47
|
</Card>
|
|
48
|
-
<Card href="/docs/api-reference/workflow-
|
|
48
|
+
<Card href="/docs/api-reference/workflow-runtime/world/queue" title="Queue">
|
|
49
49
|
Low-level queue dispatch (internal SDK infrastructure).
|
|
50
50
|
</Card>
|
|
51
|
-
<Card href="/docs/api-reference/workflow-api/world/observability" title="Observability">
|
|
52
|
-
Hydrate step I/O, parse display names, decrypt data.
|
|
53
|
-
</Card>
|
|
54
51
|
</Cards>
|
|
55
52
|
|
|
56
53
|
## Data Hydration
|
|
@@ -64,7 +61,7 @@ const step = await world.steps.get(runId, stepId);
|
|
|
64
61
|
const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highlight]
|
|
65
62
|
```
|
|
66
63
|
|
|
67
|
-
See [
|
|
64
|
+
See [`workflow/observability`](/docs/api-reference/workflow-observability) for the full hydration and parsing API.
|
|
68
65
|
|
|
69
66
|
### List Workflow Runs (Display Names)
|
|
70
67
|
|
|
@@ -72,7 +69,7 @@ List workflow runs and derive human-readable names from the `workflowName` field
|
|
|
72
69
|
|
|
73
70
|
```typescript lineNumbers
|
|
74
71
|
import { getWorld } from "workflow/runtime";
|
|
75
|
-
import { parseWorkflowName } from "
|
|
72
|
+
import { parseWorkflowName } from "workflow/observability"; // [!code highlight]
|
|
76
73
|
|
|
77
74
|
export async function GET(req: Request) {
|
|
78
75
|
const url = new URL(req.url);
|
|
@@ -113,7 +110,7 @@ export async function GET(req: Request) {
|
|
|
113
110
|
|
|
114
111
|
<Callout type="info">
|
|
115
112
|
The `workflowName` field contains a machine-readable identifier like `workflow//./src/workflows/order//processOrder`.
|
|
116
|
-
Use `parseWorkflowName()`
|
|
113
|
+
Use [`parseWorkflowName()`](/docs/api-reference/workflow-observability/parse-workflow-name) to extract the `shortName` (e.g., `"processOrder"`)
|
|
117
114
|
and `moduleSpecifier` for display in your UI.
|
|
118
115
|
</Callout>
|
|
119
116
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: healthCheck
|
|
3
|
+
description: Verify a deployment's workflow infrastructure by sending a message through the queue pipeline.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use healthCheck to verify the workflow endpoint of a deployment processes queue messages end-to-end.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Performs an end-to-end health check of a deployment's workflow infrastructure by sending a message through the queue pipeline and verifying it is processed by the workflow endpoint. Because it goes through the queue rather than direct HTTP, it works even when the deployment is behind Deployment Protection on Vercel.
|
|
11
|
+
|
|
12
|
+
```typescript lineNumbers
|
|
13
|
+
import { getWorld, healthCheck } from "workflow/runtime";
|
|
14
|
+
|
|
15
|
+
const world = await getWorld();
|
|
16
|
+
const result = await healthCheck(world); // [!code highlight]
|
|
17
|
+
|
|
18
|
+
if (!result.healthy) {
|
|
19
|
+
console.error("Workflow infrastructure unhealthy:", result.error);
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `world` | `World` | The World instance to send the health check through |
|
|
30
|
+
| `options` | `HealthCheckOptions` | Optional configuration |
|
|
31
|
+
|
|
32
|
+
Where `HealthCheckOptions` is:
|
|
33
|
+
|
|
34
|
+
| Option | Type | Description |
|
|
35
|
+
|--------|------|-------------|
|
|
36
|
+
| `timeout` | `number` | Milliseconds to wait for the health check response. Default: `30000`. |
|
|
37
|
+
| `deploymentId` | `string` | Deployment to target. Falls back to `process.env.VERCEL_DEPLOYMENT_ID`. |
|
|
38
|
+
| `namespace` | `string` | Queue namespace of the target deployment. Falls back to `WORKFLOW_QUEUE_NAMESPACE`. |
|
|
39
|
+
|
|
40
|
+
### Returns
|
|
41
|
+
|
|
42
|
+
Returns a `Promise<HealthCheckResult>`:
|
|
43
|
+
|
|
44
|
+
| Property | Type | Description |
|
|
45
|
+
|----------|------|-------------|
|
|
46
|
+
| `healthy` | `boolean` | Whether the combined workflow endpoint processed the health check message |
|
|
47
|
+
| `error` | `string \| undefined` | Error message when the check failed |
|
|
48
|
+
| `latencyMs` | `number \| undefined` | Round-trip latency when the check succeeded |
|
|
49
|
+
| `specVersion` | `number \| undefined` | Workflow spec version of the responding deployment |
|
|
50
|
+
| `workflowCoreVersion` | `string \| undefined` | `@workflow/core` version of the responding deployment |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/runtime"
|
|
3
|
+
description: Runtime functions for accessing the World instance and wiring up workflow infrastructure.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore runtime functions for resolving the World instance and configuring workflow infrastructure.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
API reference for runtime functions from the `workflow/runtime` package.
|
|
9
|
+
|
|
10
|
+
The runtime package provides low-level access to the workflow runtime — resolving the [World](/docs/api-reference/workflow-runtime/world) instance that backs storage, queuing, and streaming, and wiring up workflow infrastructure in custom server environments.
|
|
11
|
+
|
|
12
|
+
## Functions
|
|
13
|
+
|
|
14
|
+
<Cards>
|
|
15
|
+
<Card href="/docs/api-reference/workflow-runtime/get-world" title="getWorld()">
|
|
16
|
+
Async: resolve the World instance for storage, queuing, and streaming backends.
|
|
17
|
+
</Card>
|
|
18
|
+
<Card href="/docs/api-reference/workflow-runtime/world" title="World SDK">
|
|
19
|
+
Low-level API for inspecting runs, steps, events, hooks, streams, and queues, plus metadata-only analytics with attribute search.
|
|
20
|
+
</Card>
|
|
21
|
+
</Cards>
|
|
22
|
+
|
|
23
|
+
## Infrastructure Functions
|
|
24
|
+
|
|
25
|
+
These functions are primarily used by framework adapters and custom world setups, and are rarely needed in application code:
|
|
26
|
+
|
|
27
|
+
<Cards>
|
|
28
|
+
<Card href="/docs/api-reference/workflow-runtime/create-world" title="createWorld()">
|
|
29
|
+
Create a World instance from environment configuration.
|
|
30
|
+
</Card>
|
|
31
|
+
<Card href="/docs/api-reference/workflow-runtime/set-world" title="setWorld()">
|
|
32
|
+
Override the cached World instance with a custom World.
|
|
33
|
+
</Card>
|
|
34
|
+
<Card href="/docs/api-reference/workflow-runtime/get-world-handlers" title="getWorldHandlers()">
|
|
35
|
+
Build-time-safe access to the World's queue handlers.
|
|
36
|
+
</Card>
|
|
37
|
+
<Card href="/docs/api-reference/workflow-runtime/workflow-entrypoint" title="workflowEntrypoint()">
|
|
38
|
+
Create the HTTP route handler that executes workflow runs.
|
|
39
|
+
</Card>
|
|
40
|
+
<Card href="/docs/api-reference/workflow-runtime/health-check" title="healthCheck()">
|
|
41
|
+
Check the health of a deployment's workflow infrastructure.
|
|
42
|
+
</Card>
|
|
43
|
+
</Cards>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: setWorld
|
|
3
|
+
description: Override or reset the cached World instance used by the workflow runtime.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use setWorld to inject a custom World instance or reset the cache after environment configuration changes.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-runtime/create-world
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Overrides the cached [World](/docs/api-reference/workflow-runtime/world) instance that [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) returns. Use it to inject a World constructed with explicit configuration (rather than environment variables), or pass `undefined` to clear the cache so the next `getWorld()` call reinitializes from the current environment.
|
|
13
|
+
|
|
14
|
+
```typescript lineNumbers
|
|
15
|
+
import { setWorld, getWorld } from "workflow/runtime";
|
|
16
|
+
import type { World } from "@workflow/world";
|
|
17
|
+
declare const customWorld: World; // @setup
|
|
18
|
+
|
|
19
|
+
setWorld(customWorld); // [!code highlight]
|
|
20
|
+
const world = await getWorld(); // resolves customWorld
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
|-----------|------|-------------|
|
|
29
|
+
| `world` | `World \| undefined` | The World instance to use, or `undefined` to reset the cache and reinitialize from environment variables on next access |
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
This function does not return a value.
|
|
34
|
+
|
|
35
|
+
## Example: Reset After Environment Changes
|
|
36
|
+
|
|
37
|
+
```typescript lineNumbers
|
|
38
|
+
import { setWorld, getWorld } from "workflow/runtime";
|
|
39
|
+
|
|
40
|
+
process.env.WORKFLOW_TARGET_WORLD = "@workflow/world-local";
|
|
41
|
+
setWorld(undefined); // clear the cached instance // [!code highlight]
|
|
42
|
+
|
|
43
|
+
const world = await getWorld(); // reinitialized with new configuration
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Related Functions
|
|
47
|
+
|
|
48
|
+
- [`getWorld()`](/docs/api-reference/workflow-runtime/get-world) - Resolve the cached World instance.
|
|
49
|
+
- [`createWorld()`](/docs/api-reference/workflow-runtime/create-world) - Construct a fresh World from environment configuration.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: workflowEntrypoint
|
|
3
|
+
description: Create the HTTP route handler that executes workflow runs from a workflow bundle.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use workflowEntrypoint to wire a compiled workflow bundle into an HTTP route in custom server environments.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/how-it-works/code-transform
|
|
8
|
+
related:
|
|
9
|
+
- /docs/api-reference/workflow-runtime/health-check
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Creates the HTTP route handler that executes workflow runs. The handler receives queue messages, replays the workflow from its event log, executes steps inline where possible, and suspends when the workflow waits on sleeps or hooks.
|
|
13
|
+
|
|
14
|
+
Framework adapters (Next.js, Nitro, SvelteKit, etc.) call this for you and mount the result at `/.well-known/workflow/v1/flow` — you only need it when wiring workflow support into a custom server environment.
|
|
15
|
+
|
|
16
|
+
```typescript lineNumbers
|
|
17
|
+
import { workflowEntrypoint } from "workflow/runtime";
|
|
18
|
+
declare const workflowBundleCode: string; // @setup
|
|
19
|
+
|
|
20
|
+
const handler = workflowEntrypoint(workflowBundleCode); // [!code highlight]
|
|
21
|
+
|
|
22
|
+
// Mount on your server, e.g. a fetch-style route:
|
|
23
|
+
export const POST = (req: Request) => handler(req);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Signature
|
|
27
|
+
|
|
28
|
+
### Parameters
|
|
29
|
+
|
|
30
|
+
| Parameter | Type | Description |
|
|
31
|
+
|-----------|------|-------------|
|
|
32
|
+
| `workflowCode` | `string` | The compiled workflow bundle code containing all workflow functions |
|
|
33
|
+
| `options` | `{ namespace?: string }` | Optional. `namespace` scopes the queue topics this handler consumes. |
|
|
34
|
+
|
|
35
|
+
### Returns
|
|
36
|
+
|
|
37
|
+
Returns a fetch-style request handler: `(req: Request) => Promise<Response>`.
|
|
38
|
+
|
|
39
|
+
## Related Functions
|
|
40
|
+
|
|
41
|
+
- [`getWorldHandlers()`](/docs/api-reference/workflow-runtime/get-world-handlers) - The build-time World access this handler is built on.
|
|
42
|
+
- [`healthCheck()`](/docs/api-reference/workflow-runtime/health-check) - Verify the entrypoint processes queue messages end-to-end.
|
|
@@ -0,0 +1,138 @@
|
|
|
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."
|
|
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
|
+
- listValues
|
|
17
|
+
- lookback window
|
|
18
|
+
- observability-upgrade-required
|
|
19
|
+
- pageInfo
|
|
20
|
+
- metadata-only
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
`world.analytics` is an optional, read-only namespace for observability surfaces — dashboards, CLIs, and admin tools that list large numbers of runs without touching payload data.
|
|
24
|
+
|
|
25
|
+
It differs from [Storage](/docs/api-reference/workflow-runtime/world/storage) in two ways:
|
|
26
|
+
|
|
27
|
+
- **Metadata only.** Results never include run input/output, step data, or hook tokens. There is no `resolveData` option.
|
|
28
|
+
- **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.
|
|
29
|
+
|
|
30
|
+
The namespace is optional — worlds that don't implement it (such as the local development world) leave it `undefined`, so feature-detect before use:
|
|
31
|
+
|
|
32
|
+
```typescript lineNumbers
|
|
33
|
+
import { getWorld } from "workflow/runtime";
|
|
34
|
+
|
|
35
|
+
const world = await getWorld();
|
|
36
|
+
if (world.analytics) { // [!code highlight]
|
|
37
|
+
const page = await world.analytics.runs.list();
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## analytics.runs
|
|
44
|
+
|
|
45
|
+
### runs.list()
|
|
46
|
+
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
```typescript lineNumbers
|
|
50
|
+
const page = await world.analytics.runs.list({
|
|
51
|
+
workflowName: "orderWorkflow",
|
|
52
|
+
status: "failed",
|
|
53
|
+
attributes: { source: "checkout" }, // [!code highlight]
|
|
54
|
+
pagination: { limit: 50, sortOrder: "desc" },
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| Parameter | Type | Description |
|
|
59
|
+
|-----------|------|-------------|
|
|
60
|
+
| `params.workflowName` | `string` | Filter to one workflow |
|
|
61
|
+
| `params.status` | `string` | `pending`, `running`, `completed`, `failed`, or `cancelled` |
|
|
62
|
+
| `params.startTime` / `params.endTime` | `string` | ISO 8601 window; must be provided together |
|
|
63
|
+
| `params.attributes` | `Record<string, string>` | Only return runs whose latest attributes match every pair (up to 8) |
|
|
64
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination |
|
|
65
|
+
|
|
66
|
+
**Returns:** `PaginatedResponse<AnalyticsRun>` — each run includes `runId`, `status`, `workflowName`, `deploymentId`, `attributes`, and lifecycle timestamps.
|
|
67
|
+
|
|
68
|
+
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.
|
|
69
|
+
|
|
70
|
+
### runs.get()
|
|
71
|
+
|
|
72
|
+
Fetch one run by ID. Point lookups search the full plan window, not just the trailing 24 hours.
|
|
73
|
+
|
|
74
|
+
```typescript lineNumbers
|
|
75
|
+
const run = await world.analytics.runs.get(runId);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## analytics.attributes
|
|
81
|
+
|
|
82
|
+
Discover which [attributes](/docs/observability/attributes) exist on your runs — for example to build filter dropdowns over arbitrary user-defined keys.
|
|
83
|
+
|
|
84
|
+
### attributes.list()
|
|
85
|
+
|
|
86
|
+
List the distinct attribute keys observed on runs in the window, ordered alphabetically.
|
|
87
|
+
|
|
88
|
+
```typescript lineNumbers
|
|
89
|
+
const page = await world.analytics.attributes.list({ // [!code highlight]
|
|
90
|
+
workflowName: "orderWorkflow",
|
|
91
|
+
});
|
|
92
|
+
for (const { key, runCount, lastSeenAt } of page.data) {
|
|
93
|
+
console.log(key, runCount, lastSeenAt);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Description |
|
|
98
|
+
|-----------|------|-------------|
|
|
99
|
+
| `params.workflowName` | `string` | Only count runs of one workflow |
|
|
100
|
+
| `params.startTime` / `params.endTime` | `string` | ISO 8601 window; must be provided together |
|
|
101
|
+
| `params.pagination` | `PaginationOptions` | Cursor pagination |
|
|
102
|
+
|
|
103
|
+
**Returns:** `PaginatedResponse<AnalyticsAttributeKey>` — `{ key, runCount, firstSeenAt, lastSeenAt }`
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## analytics.steps, analytics.events, analytics.hooks, analytics.waits
|
|
108
|
+
|
|
109
|
+
Run-scoped listings mirroring their [Storage](/docs/api-reference/workflow-runtime/world/storage) counterparts, minus payload data:
|
|
110
|
+
|
|
111
|
+
```typescript lineNumbers
|
|
112
|
+
const steps = await world.analytics.steps.list({ runId });
|
|
113
|
+
const events = await world.analytics.events.list({ runId, eventType: "step_failed" });
|
|
114
|
+
const related = await world.analytics.events.listByCorrelationId({ runId, correlationId });
|
|
115
|
+
const hooks = await world.analytics.hooks.list({ runId });
|
|
116
|
+
const waits = await world.analytics.waits.list({ runId, status: "waiting" });
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Each namespace also has a `get()` for point lookups (`steps.get(runId, stepId)`, `events.get(runId, eventId)`, `hooks.get(hookId)`, `waits.get(runId, waitId)`). Hook listings never include the hook token — resolve it separately through the runtime APIs if you need to deliver a payload.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Lookback windows and pageInfo
|
|
124
|
+
|
|
125
|
+
Every paginated response carries `pageInfo` describing the window the query was allowed to scan:
|
|
126
|
+
|
|
127
|
+
{/* @skip-typecheck: shape illustration, not runnable code */}
|
|
128
|
+
```typescript
|
|
129
|
+
{
|
|
130
|
+
currentLookbackDays: 2, // what your plan allows today
|
|
131
|
+
maxLookbackDays: 30, // ceiling with Observability Plus on Vercel
|
|
132
|
+
currentWindowStart: Date,
|
|
133
|
+
maxWindowStart: Date,
|
|
134
|
+
upgradeAvailable: true, // for Vercel deployed workflows
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
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.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: World SDK
|
|
3
|
-
description: Low-level API for inspecting and managing workflow runs, steps, events, hooks, streams, and queues.
|
|
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
4
|
type: overview
|
|
5
5
|
summary: Access workflow infrastructure via await getWorld() for building observability dashboards, admin tools, and custom integrations.
|
|
6
6
|
prerequisites:
|
|
7
|
-
- /docs/api-reference/workflow-
|
|
7
|
+
- /docs/api-reference/workflow-runtime/get-world
|
|
8
8
|
keywords:
|
|
9
9
|
- getWorld
|
|
10
10
|
- World SDK
|
|
@@ -14,7 +14,7 @@ keywords:
|
|
|
14
14
|
- workflow management
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
The World SDK provides direct access to workflow infrastructure — runs, steps, events, hooks, streams, and queues. Use it to build observability dashboards, admin panels, debugging tools, and custom workflow management logic.
|
|
17
|
+
The World SDK provides direct access to workflow infrastructure — runs, steps, events, hooks, streams, and queues — plus 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
18
|
|
|
19
19
|
```typescript lineNumbers
|
|
20
20
|
import { getWorld } from "workflow/runtime";
|
|
@@ -25,18 +25,18 @@ const world = await getWorld(); // [!code highlight]
|
|
|
25
25
|
## Interfaces
|
|
26
26
|
|
|
27
27
|
<Cards>
|
|
28
|
-
<Card href="/docs/api-reference/workflow-
|
|
28
|
+
<Card href="/docs/api-reference/workflow-runtime/world/storage" title="Storage">
|
|
29
29
|
Query runs, steps, hooks, and the underlying event log.
|
|
30
30
|
</Card>
|
|
31
|
-
<Card href="/docs/api-reference/workflow-
|
|
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">
|
|
32
35
|
Read, write, and manage real-time data streams for workflow runs.
|
|
33
36
|
</Card>
|
|
34
|
-
<Card href="/docs/api-reference/workflow-
|
|
37
|
+
<Card href="/docs/api-reference/workflow-runtime/world/queue" title="Queue">
|
|
35
38
|
Low-level queue dispatch (internal SDK infrastructure).
|
|
36
39
|
</Card>
|
|
37
|
-
<Card href="/docs/api-reference/workflow-api/world/observability" title="Observability Utilities">
|
|
38
|
-
Hydrate step I/O, parse display names, and decrypt workflow data.
|
|
39
|
-
</Card>
|
|
40
40
|
</Cards>
|
|
41
41
|
|
|
42
42
|
<Callout type="info">
|
|
@@ -55,4 +55,4 @@ const hydrated = hydrateResourceIO(step, observabilityRevivers); // [!code highl
|
|
|
55
55
|
console.log(hydrated.input, hydrated.output);
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
See [
|
|
58
|
+
See [`workflow/observability`](/docs/api-reference/workflow-observability) for the full API.
|