workflow 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-workflow.js +1 -1
- package/dist/api.js +1 -1
- package/dist/astro.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/builtins.js +1 -1
- package/dist/internal/class-serialization.js +1 -1
- package/dist/internal/errors.js +1 -1
- package/dist/nest-builder.js +1 -1
- package/dist/nest-vercel-builder.js +1 -1
- package/dist/nest.js +1 -1
- package/dist/next.cjs +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/observability.d.ts +1 -1
- package/dist/observability.js +2 -2
- package/dist/runtime.js +1 -1
- package/dist/stdlib.js +1 -1
- package/dist/sveltekit.js +1 -1
- package/dist/typescript-plugin.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/workflow.js +1 -1
- package/docs/ai/chat-session-modeling.mdx +1 -1
- package/docs/ai/resumable-streams.mdx +1 -1
- package/docs/api-reference/workflow/create-hook.mdx +2 -2
- package/docs/api-reference/workflow/get-step-metadata.mdx +19 -0
- package/docs/api-reference/workflow-ai/durable-agent.mdx +2 -1
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +4 -4
- package/docs/api-reference/workflow-api/get-run.mdx +0 -4
- package/docs/api-reference/workflow-api/resume-hook.mdx +1 -1
- package/docs/api-reference/workflow-api/start.mdx +1 -1
- package/docs/api-reference/workflow-errors/in-band-superseded-error.mdx +0 -3
- package/docs/api-reference/workflow-errors/index.mdx +1 -1
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +0 -2
- package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +1 -1
- package/docs/api-reference/workflow-next/with-workflow.mdx +57 -0
- package/docs/api-reference/workflow-observability/create-state-resolver.mdx +56 -0
- package/docs/api-reference/workflow-observability/index.mdx +5 -0
- package/docs/api-reference/workflow-observability/meta.json +1 -0
- package/docs/api-reference/workflow-runtime/world/queue.mdx +70 -3
- package/docs/api-reference/workflow-runtime/world/storage.mdx +1 -2
- package/docs/comparisons/index.mdx +4 -1
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +3 -1
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +4 -1
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +271 -28
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +6 -2
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +2 -0
- package/docs/configuration/build-and-diagnostics.mdx +2 -0
- package/docs/configuration/cli-and-web-ui.mdx +40 -1
- package/docs/configuration/framework-options.mdx +7 -0
- package/docs/configuration/runtime-tuning.mdx +31 -85
- package/docs/configuration/worlds.mdx +69 -40
- package/docs/cookbook/advanced/child-workflows.mdx +3 -3
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +1 -1
- package/docs/cookbook/common-patterns/batching.mdx +1 -1
- package/docs/cookbook/integrations/ai-sdk.mdx +2 -2
- package/docs/errors/corrupted-event-log.mdx +1 -1
- package/docs/errors/hook-force-claimed.mdx +1 -1
- package/docs/errors/index.mdx +1 -0
- package/docs/errors/max-events-exceeded.mdx +2 -2
- package/docs/errors/replay-timeout.mdx +2 -2
- package/docs/errors/runtime-decryption-failed.mdx +1 -1
- package/docs/errors/workflow-not-registered.mdx +1 -1
- package/docs/foundations/errors-and-retries.mdx +4 -5
- package/docs/foundations/serialization.mdx +80 -0
- package/docs/getting-started/next.mdx +2 -0
- package/docs/how-it-works/event-sourcing.mdx +4 -7
- package/docs/how-it-works/framework-integrations.mdx +2 -2
- package/docs/internal/index.mdx +1 -0
- package/docs/internal/nitro-native-build.mdx +1 -0
- package/docs/internal/nitro-web-ui.mdx +1 -0
- package/docs/internal/serializable-abort-controller.mdx +1 -0
- package/docs/observability/index.mdx +4 -0
- package/docs/whats-new.mdx +5 -5
- package/docs/worlds/building-a-world.mdx +63 -6
- package/docs/worlds/local.mdx +115 -26
- package/docs/worlds/postgres.mdx +110 -33
- package/docs/worlds/upgrading-to-v5.mdx +6 -6
- package/docs/worlds/vercel.mdx +194 -81
- package/package.json +17 -15
- package/dist/api-workflow.d.ts.map +0 -1
- package/dist/api.d.ts.map +0 -1
- package/dist/astro.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/builtins.d.ts.map +0 -1
- package/dist/internal/class-serialization.d.ts.map +0 -1
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/nest-builder.d.ts.map +0 -1
- package/dist/nest-vercel-builder.d.ts.map +0 -1
- package/dist/nest.d.ts.map +0 -1
- package/dist/nitro.d.ts.map +0 -1
- package/dist/nuxt.d.ts.map +0 -1
- package/dist/observability.d.ts.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/stdlib.d.ts.map +0 -1
- package/dist/sveltekit.d.ts.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/workflow.d.ts.map +0 -1
- package/docs/changelog/attributes-mvp.mdx +0 -380
- package/docs/changelog/batched-event-writes.mdx +0 -79
- package/docs/changelog/eager-processing.mdx +0 -273
- package/docs/changelog/index.mdx +0 -19
- package/docs/changelog/lazy-event-creation.md +0 -127
- package/docs/changelog/lazy-hook-resume.mdx +0 -78
- package/docs/changelog/meta.json +0 -16
- package/docs/changelog/resilient-resume.mdx +0 -32
- package/docs/changelog/resilient-start.mdx +0 -77
- package/docs/changelog/spec-9.mdx +0 -4019
- package/docs/changelog/step-message-ownership.mdx +0 -360
- package/docs/changelog/turbo-mode.md +0 -91
package/dist/api-workflow.js
CHANGED
|
@@ -11,4 +11,4 @@ export const runStep = () => workflowStub('runStep');
|
|
|
11
11
|
export const registerLifecycleHooks = () => {
|
|
12
12
|
throw new Error('registerLifecycleHooks must be called at host startup, not inside a workflow or step function. Register before handling workflow requests (for example, in instrumentation.ts on Next.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ElBQUksS0FBSyxDQUNiLDRMQUE0TCxDQUM3TCxDQUFDO0FBQ0osQ0FBQyxDQUFDIn0=
|
package/dist/api.js
CHANGED
|
@@ -10,4 +10,4 @@ export { registerLifecycleHooks, } from '@workflow/core/runtime/lifecycle-hooks'
|
|
|
10
10
|
export { getHookByToken, resumeHook, resumeWebhook, } from '@workflow/core/runtime/resume-hook';
|
|
11
11
|
export { getRun, Run, } from '@workflow/core/runtime/run';
|
|
12
12
|
export { start, } from '@workflow/core/runtime/start';
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxxRUFBcUU7QUFDckUseUVBQXlFO0FBQ3pFLDJFQUEyRTtBQUMzRSw0RUFBNEU7QUFDNUUsNkVBQTZFO0FBQzdFLG1CQUFtQjtBQUNuQix5RUFBeUU7QUFDekUsT0FBTyxtQ0FBbUMsQ0FBQztBQVMzQyxPQUFPLEVBR0wsc0JBQXNCLEdBRXZCLE1BQU0sd0NBQXdDLENBQUM7QUFDaEQsT0FBTyxFQUNMLGNBQWMsRUFHZCxVQUFVLEVBQ1YsYUFBYSxHQUNkLE1BQU0sb0NBQW9DLENBQUM7QUFDNUMsT0FBTyxFQUNMLE1BQU0sRUFDTixHQUFHLEdBSUosTUFBTSw0QkFBNEIsQ0FBQztBQUNwQyxPQUFPLEVBTUwsS0FBSyxHQUNOLE1BQU0sOEJBQThCLENBQUMifQ==
|
package/dist/astro.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@workflow/astro';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN0cm8uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYXN0cm8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxpQkFBaUIsQ0FBQyJ9
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
import '@workflow/core/runtime/world-init';
|
|
6
6
|
export * from '@workflow/core';
|
|
7
7
|
export * from './stdlib.js';
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsK0VBQStFO0FBQy9FLCtFQUErRTtBQUMvRSw0RUFBNEU7QUFDNUUscUVBQXFFO0FBQ3JFLE9BQU8sbUNBQW1DLENBQUM7QUFFM0MsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLGFBQWEsQ0FBQyJ9
|
|
@@ -79,4 +79,4 @@ export async function __builtin_set_attributes(changes, options) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
__builtin_set_attributes.maxRetries = INTERNAL_ATTRIBUTES_MAX_ATTEMPTS - 1;
|
|
82
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
82
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbHRpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW50ZXJuYWwvYnVpbHRpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUVILE1BQU0sQ0FBQyxLQUFLLFVBQVUsK0JBQStCO0lBR25ELFVBQVUsQ0FBQztJQUNYLE9BQU8sSUFBSSxDQUFDLFd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TSxLQUFLLENBQUMsSUFBSSxDQUFDLHlCQUF5QixDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsT0FBTyxDQUFDLENBQUM7SUFDdEUsQ0FBQztJQUFDLE9BQU8sS0FBSyxFQUFFLENBQUM7UUFDZixJQUFJLE9BQU8sR0FBRyxnQ0FBZ0MsRUFBRSxDQUFDO1lBQy9DLE1BQU0sS0FBSyxDQUFDO1FBQ2QsQ0FBQztRQUVELDRFQUE0RTtRQUM1RSxzRUFBc0U7UUFDdEUsK0RBQStEO1FBQy9ELE9BQU8sQ0FBQyxLQUFLLENBQ1gsdURBQXVELGdDQUFnQyxxREFBcUQsa0JBQWtCLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FDeEssQ0FBQztJQUNKLENBQUM7QUFDSCxDQUFDO0FBR0Msd0JBR0QsQ0FBQyxVQUFVLEdBQUcsZ0NBQWdDLEdBQUcsQ0FBQyxDQUFDIn0=
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* dependencies (like async_hooks) when used in workflow bundles.
|
|
6
6
|
*/
|
|
7
7
|
export * from '@workflow/core/class-serialization';
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Mtc2VyaWFsaXphdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9pbnRlcm5hbC9jbGFzcy1zZXJpYWxpemF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7OztHQUtHO0FBRUgsY0FBYyxvQ0FBb0MsQ0FBQyJ9
|
package/dist/internal/errors.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { EntityConflictError, HookConflictError, HookForceClaimedError, HookNotFoundError, InBandSupersededError, PreconditionFailedError, RunExpiredError, RunNotSupportedError, StepNotRegisteredError, StreamError, ThrottleError, TooEarlyError, WorkflowError, WorkflowNotRegisteredError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRunNotFoundError, WorkflowRuntimeError, WorkflowStartError, WorkflowWorldError, } from '@workflow/errors';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ludGVybmFsL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsbUJBQW1CLEVBQ25CLGlCQUFpQixFQUNqQixxQkFBcUIsRUFDckIsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQix1QkFBdUIsRUFDdkIsZUFBZSxFQUNmLG9CQUFvQixFQUNwQixzQkFBc0IsRUFDdEIsV0FBVyxFQUNYLGFBQWEsRUFDYixhQUFhLEVBQ2IsYUFBYSxFQUNiLDBCQUEwQixFQUMxQix5QkFBeUIsRUFDekIsc0JBQXNCLEVBQ3RCLDRCQUE0QixFQUM1Qix3QkFBd0IsRUFDeEIsb0JBQW9CLEVBQ3BCLGtCQUFrQixFQUNsQixrQkFBa0IsR0FDbkIsTUFBTSxrQkFBa0IsQ0FBQyJ9
|
package/dist/nest-builder.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@workflow/nest/builder';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdC1idWlsZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL25lc3QtYnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHdCQUF3QixDQUFDIn0=
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@workflow/nest/vercel-builder';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdC12ZXJjZWwtYnVpbGRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9uZXN0LXZlcmNlbC1idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsK0JBQStCLENBQUMifQ==
|
package/dist/nest.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@workflow/nest';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9uZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZ0JBQWdCLENBQUMifQ==
|
package/dist/next.cjs
CHANGED
|
@@ -5,4 +5,4 @@ exports.withWorkflow = void 0;
|
|
|
5
5
|
// `next.config.js` using CommonJS syntax is still common.
|
|
6
6
|
const nextPlugin = require("@workflow/next");
|
|
7
7
|
exports.withWorkflow = nextPlugin.withWorkflow;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV4dC5janMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbmV4dC5jdHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsMkRBQTJEO0FBQzNELDBEQUEwRDtBQUMxRCw2Q0FBOEM7QUFDakMsUUFBQSxZQUFZLEdBQUcsVUFBVSxDQUFDLFlBQVksQ0FBQyJ9
|
package/dist/nitro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import workflowNitro from '@workflow/nitro';
|
|
2
2
|
export * from '@workflow/nitro';
|
|
3
3
|
export default workflowNitro;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibml0cm8uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbml0cm8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxhQUFhLE1BQU0saUJBQWlCLENBQUM7QUFFNUMsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxlQUFlLGFBQWEsQ0FBQyJ9
|
package/dist/nuxt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import workflowNuxt from '@workflow/nuxt';
|
|
2
2
|
export * from '@workflow/nuxt';
|
|
3
3
|
export default workflowNuxt;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9udXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sWUFBWSxNQUFNLGdCQUFnQixDQUFDO0FBRTFDLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsZUFBZSxZQUFZLENBQUMifQ==
|
package/dist/observability.d.ts
CHANGED
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* // hydrated.input and hydrated.output are now plain JS objects
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export { hydrateData, hydrateResourceIO, observabilityRevivers, type Revivers, } from '@workflow/core/serialization-format';
|
|
18
|
+
export { createStateResolver, hydrateData, hydrateResourceIO, observabilityRevivers, type Revivers, type StateResolver, stateSourceId, } from '@workflow/core/serialization-format';
|
|
19
19
|
export { parseClassName, parseStepName, parseWorkflowName, } from '@workflow/utils';
|
|
20
20
|
//# sourceMappingURL=observability.d.ts.map
|
package/dist/observability.js
CHANGED
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* // hydrated.input and hydrated.output are now plain JS objects
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export { hydrateData, hydrateResourceIO, observabilityRevivers, } from '@workflow/core/serialization-format';
|
|
18
|
+
export { createStateResolver, hydrateData, hydrateResourceIO, observabilityRevivers, stateSourceId, } from '@workflow/core/serialization-format';
|
|
19
19
|
export { parseClassName, parseStepName, parseWorkflowName, } from '@workflow/utils';
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib2JzZXJ2YWJpbGl0eS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vYnNlcnZhYmlsaXR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7Ozs7O0dBZ0JHO0FBQ0gsT0FBTyxFQUNMLG1CQUFtQixFQUNuQixXQUFXLEVBQ1gsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUdyQixhQUFhLEdBQ2QsTUFBTSxxQ0FBcUMsQ0FBQztBQUU3QyxPQUFPLEVBQ0wsY0FBYyxFQUNkLGFBQWEsRUFDYixpQkFBaUIsR0FDbEIsTUFBTSxpQkFBaUIsQ0FBQyJ9
|
package/dist/runtime.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// through stream helpers, so register getWorld before exporting runtime APIs.
|
|
3
3
|
import '@workflow/core/runtime/world-init';
|
|
4
4
|
export { createWorld, getWorld, getWorldHandlers, healthCheck, setWorld, workflowEntrypoint, } from '@workflow/core/runtime';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9ydW50aW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZFQUE2RTtBQUM3RSw4RUFBOEU7QUFDOUUsT0FBTyxtQ0FBbUMsQ0FBQztBQUUzQyxPQUFPLEVBQ0wsV0FBVyxFQUNYLFFBQVEsRUFDUixnQkFBZ0IsRUFHaEIsV0FBVyxFQUNYLFFBQVEsRUFDUixrQkFBa0IsR0FDbkIsTUFBTSx3QkFBd0IsQ0FBQyJ9
|
package/dist/stdlib.js
CHANGED
|
@@ -14,4 +14,4 @@ export async function fetch(...args) {
|
|
|
14
14
|
'use step';
|
|
15
15
|
return globalThis.fetch(...args);
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RkbGliLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3N0ZGxpYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7R0FLRztBQUVIOzs7OztHQUtHO0FBQ0gsTUFBTSxDQUFDLEtBQUssVUFBVSxLQUFLLENBQUMsR0FBRyxJQUF5QztJQUN0RSxVQUFVLENBQUM7SUFDWCxPQUFPLFVBQVUsQ0FBQyxLQUFLLENBQUMsR0FBRyxJQUFJLENBQUMsQ0FBQztBQUNuQyxDQUFDIn0=
|
package/dist/sveltekit.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from '@workflow/sveltekit';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3ZlbHRla2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3N2ZWx0ZWtpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHFCQUFxQixDQUFDIn0=
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// so we need to export the plugin as a CommonJS module
|
|
4
4
|
const typescriptPlugin = require("@workflow/typescript-plugin");
|
|
5
5
|
module.exports = typescriptPlugin;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXNjcmlwdC1wbHVnaW4uY2pzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3R5cGVzY3JpcHQtcGx1Z2luLmN0cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsZ0VBQWdFO0FBQ2hFLHVEQUF1RDtBQUN2RCxnRUFBaUU7QUFDakUsaUJBQVMsZ0JBQWdCLENBQUMifQ==
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { workflow } from '@workflow/nitro/vite';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidml0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy92aXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQyJ9
|
package/dist/workflow.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from '@workflow/core/_workflow';
|
|
2
2
|
export * from './stdlib.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ya2Zsb3cuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvd29ya2Zsb3cudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLGFBQWEsQ0FBQyJ9
|
|
@@ -76,7 +76,7 @@ export async function POST(request: Request) {
|
|
|
76
76
|
"use client";
|
|
77
77
|
|
|
78
78
|
import { useChat } from "@ai-sdk/react";
|
|
79
|
-
import { WorkflowChatTransport } from "@ai-sdk/workflow";
|
|
79
|
+
import { WorkflowChatTransport } from "@ai-sdk/workflow/client";
|
|
80
80
|
import { useMemo } from "react";
|
|
81
81
|
|
|
82
82
|
export function Chat({ initialMessages }) {
|
|
@@ -117,7 +117,7 @@ Replace the default transport in AI SDK's `useChat` with [`WorkflowChatTransport
|
|
|
117
117
|
"use client";
|
|
118
118
|
|
|
119
119
|
import { useChat } from "@ai-sdk/react";
|
|
120
|
-
import { WorkflowChatTransport } from "@ai-sdk/workflow"; // [!code highlight]
|
|
120
|
+
import { WorkflowChatTransport } from "@ai-sdk/workflow/client"; // [!code highlight]
|
|
121
121
|
import { useMemo, useState } from "react";
|
|
122
122
|
|
|
123
123
|
export default function ChatPage() {
|
|
@@ -180,7 +180,7 @@ On a conflict, the resolved value is a `Run` handle for the run that owns the to
|
|
|
180
180
|
|
|
181
181
|
Work started *beside* the awaiter, rather than after it, is not slowed down by it. In `await Promise.all([hook.getConflict(), prepare()])` the registration and the step are scheduled together: the runtime commits the registration, resolves the awaiter in the same invocation, and then runs `prepare()` there too, so the step does not pay an extra round trip through the queue for having been started next to a `getConflict()`.
|
|
182
182
|
|
|
183
|
-
This is a scheduling improvement, not an ordering guarantee. Only the steps the invocation runs inline start after the registration is recorded: the first [`WORKFLOW_MAX_INLINE_STEPS`](/docs/configuration/runtime-tuning#workflow_max_inline_steps) of them, less any inline steps the invocation is still running from an earlier part of the workflow
|
|
183
|
+
This is a scheduling improvement, not an ordering guarantee. Only the steps the invocation runs inline start after the registration is recorded: the first [`WORKFLOW_MAX_INLINE_STEPS`](/docs/configuration/runtime-tuning#workflow_max_inline_steps) of them, less any inline steps the invocation is still running from an earlier part of the workflow. A wider fan-out beside the awaiter has its remaining steps created and queued alongside the hook, exactly as described above, so they can start before the registration commits and can start even if it conflicts. When the ordering is what you need, await `hook.getConflict()` *before* calling the step.
|
|
184
184
|
|
|
185
185
|
<Callout type="info">
|
|
186
186
|
Custom hook tokens are the recommended way to coordinate active workflow runs. Use a deterministic token from your domain, such as an order ID or conversation ID, create the hook near the beginning of the workflow, and check `await hook.getConflict()` before work that depends on owning the token. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
|
|
@@ -266,7 +266,7 @@ With `experimental_force`, this run always ends up owning the token:
|
|
|
266
266
|
The takeover is durable. If either run's compute fails partway through, the next request for the token completes it, so the token never ends up held by nobody or by both runs. The previous owner's wake is durable too: if the new owner's compute fails between registering the Hook and waking the previous owner, the new owner's next invocation republishes the wake, whatever else the new owner has recorded since (a step it started alongside the Hook, for example). Every invocation of the new owner within 24 hours of the takeover republishes it under the same idempotency key, which collapses the repeats into one wake; a repeat that does get through only replays the previous owner, which finds nothing new.
|
|
267
267
|
|
|
268
268
|
<Callout type="info">
|
|
269
|
-
A token can only be taken from a run whose runtime understands being taken from. Runs started at a Workflow spec version below 8, which includes every run started by an older SDK release, a Python SDK run, or a deployment with `
|
|
269
|
+
A token can only be taken from a run whose runtime understands being taken from. Runs started at a Workflow spec version below 8, which includes every run started by an older SDK release, a Python SDK run, or a deployment with `WORKFLOW_SPEC_VERSION` set below 8, would never learn that their Hook was disposed. The World declines to take their token and the forced Hook rejects with the ordinary [`HookConflictError`](/docs/api-reference/workflow-errors/hook-conflict-error) instead, exactly as if `experimental_force` had not been set. Finished runs holding a retained token are taken over at any version.
|
|
270
270
|
</Callout>
|
|
271
271
|
|
|
272
272
|
`hook.getConflict()` on a forced Hook resolves with `null` once the takeover succeeds: the token is this run's by construction. If the World declines the takeover because the current owner predates spec version 8, `getConflict()` behaves as it does for an ordinary conflict and resolves with that owner's `Run`. Read `hook.claimedFrom` on the value returned by [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token) to find out which run, if any, the token was taken from.
|
|
@@ -61,6 +61,25 @@ async function chargeUser(userId: string, amount: number) {
|
|
|
61
61
|
<a href="/docs/foundations/idempotency">Idempotency</a> guide.
|
|
62
62
|
</Callout>
|
|
63
63
|
|
|
64
|
+
### Example: handle the last attempt differently
|
|
65
|
+
|
|
66
|
+
```typescript lineNumbers
|
|
67
|
+
import { getStepMetadata } from "workflow";
|
|
68
|
+
|
|
69
|
+
async function welcomeUser(userId: string) {
|
|
70
|
+
"use step";
|
|
71
|
+
const { attempt, maxAttempts } = getStepMetadata();
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return await sendWelcomeEmail(userId);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (attempt < maxAttempts) throw error; // [!code highlight]
|
|
77
|
+
console.error(`Giving up on the welcome email for ${userId}`, error);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
64
83
|
## API signature
|
|
65
84
|
|
|
66
85
|
### Parameters
|
|
@@ -13,7 +13,7 @@ related:
|
|
|
13
13
|
`DurableAgent` is deprecated. Use AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) for new durable agents. See the [migration guide](https://ai-sdk.dev/v7/docs/agents/workflow-agent#migrating-from-durableagent).
|
|
14
14
|
</Callout>
|
|
15
15
|
|
|
16
|
-
This reference is kept for existing applications that still import `DurableAgent` from `@workflow/ai/agent`. Do not use `DurableAgent` for new code.
|
|
16
|
+
This reference is kept for existing applications that still import `DurableAgent` from `@workflow/ai/agent`. Do not use `DurableAgent` for new code. `@workflow/ai` supports AI SDK 6 only (`ai@^6`); AI SDK 7 apps use `WorkflowAgent` from `@ai-sdk/workflow`.
|
|
17
17
|
|
|
18
18
|
For current examples and implementation guidance, see AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) docs. For legacy code, the API surface below documents the existing `DurableAgent` exports.
|
|
19
19
|
|
|
@@ -718,6 +718,7 @@ async function agentWithToolChoice() {
|
|
|
718
718
|
|
|
719
719
|
Use `experimental_context` to pass shared context to tool executions:
|
|
720
720
|
|
|
721
|
+
{/* @skip-typecheck: DurableAgent tools use the AI SDK 6 tool options; docs samples are checked against AI SDK 7 */}
|
|
721
722
|
```typescript
|
|
722
723
|
import { DurableAgent } from "@workflow/ai/agent";
|
|
723
724
|
import { getWritable } from "workflow";
|
|
@@ -31,7 +31,7 @@ export default function Chat() {
|
|
|
31
31
|
return (
|
|
32
32
|
<div>
|
|
33
33
|
{messages.map((m) => (
|
|
34
|
-
<div key={m.id}>{m.
|
|
34
|
+
<div key={m.id}>{m.parts.map((part) => (part.type === "text" ? part.text : "")).join("")}</div>
|
|
35
35
|
))}
|
|
36
36
|
</div>
|
|
37
37
|
);
|
|
@@ -96,7 +96,7 @@ export default function BasicChat() {
|
|
|
96
96
|
<div className="space-y-4">
|
|
97
97
|
{messages.map((m) => (
|
|
98
98
|
<div key={m.id}>
|
|
99
|
-
<strong>{m.role}:</strong> {m.
|
|
99
|
+
<strong>{m.role}:</strong> {m.parts.map((part) => (part.type === "text" ? part.text : "")).join("")}
|
|
100
100
|
</div>
|
|
101
101
|
))}
|
|
102
102
|
</div>
|
|
@@ -164,7 +164,7 @@ export default function ChatWithResumption() {
|
|
|
164
164
|
<div className="space-y-4">
|
|
165
165
|
{messages.map((m) => (
|
|
166
166
|
<div key={m.id}>
|
|
167
|
-
<strong>{m.role}:</strong> {m.
|
|
167
|
+
<strong>{m.role}:</strong> {m.parts.map((part) => (part.type === "text" ? part.text : "")).join("")}
|
|
168
168
|
</div>
|
|
169
169
|
))}
|
|
170
170
|
</div>
|
|
@@ -231,7 +231,7 @@ export default function ChatWithCustomConfig() {
|
|
|
231
231
|
<div className="space-y-4">
|
|
232
232
|
{messages.map((m) => (
|
|
233
233
|
<div key={m.id}>
|
|
234
|
-
<strong>{m.role}:</strong> {m.
|
|
234
|
+
<strong>{m.role}:</strong> {m.parts.map((part) => (part.type === "text" ? part.text : "")).join("")}
|
|
235
235
|
</div>
|
|
236
236
|
))}
|
|
237
237
|
</div>
|
|
@@ -199,10 +199,6 @@ export async function POST(req: Request) {
|
|
|
199
199
|
|
|
200
200
|
The options object is optional: `await run.cancel()` cancels the run without recording a reason.
|
|
201
201
|
|
|
202
|
-
## Spec 9 (experimental)
|
|
203
|
-
|
|
204
|
-
On runs of the experimental spec 9 runtime, `wakeUp()` asks the run's orchestrator to complete the sleeps instead of completing them itself, `stoppedCount` counts the sleeps it asked to complete, and the request is best-effort while the run is active. See [`run.wakeUp()` on spec 9 runs](/docs/changelog/spec-9#runwakeup-and-waitforsleep).
|
|
205
|
-
|
|
206
202
|
## Related functions
|
|
207
203
|
|
|
208
204
|
- [`start()`](/docs/api-reference/workflow-api/start): Start a new workflow and get its run ID.
|
|
@@ -14,7 +14,7 @@ Resumes a workflow run by sending a payload to a hook identified by its token. Y
|
|
|
14
14
|
|
|
15
15
|
It durably writes the `hook_received` event and only then publishes a workflow wake. The call resolves only after both operations succeed, in that order.
|
|
16
16
|
|
|
17
|
-
`resumeHook()` throws `HookNotFoundError` when no hook holds the token or when its `hook_received` write is refused because the hook was disposed or the run ended.
|
|
17
|
+
`resumeHook()` throws `HookNotFoundError` when no hook holds the token or when its `hook_received` write is refused because the hook was disposed or the run ended.
|
|
18
18
|
|
|
19
19
|
A run started with [`start({ experimental_hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts) has its start Hook from the moment it is admitted, so `resumeHook()` with that token works right away, even before the run starts executing. Payloads sent before the workflow calls `createHook({ token })` are kept and delivered in order once it does. See [Start or route to the owner](/docs/foundations/idempotency#start-or-route-to-the-owner).
|
|
20
20
|
|
|
@@ -119,7 +119,7 @@ export async function POST(request: Request) {
|
|
|
119
119
|
* In the workflow, `createHook({ token })` with the same token returns a handle bound to the start Hook. It doesn't register a new Hook, so it adds no step, and `getConflict()` resolves `null`. Set `metadata` and `experimental_minRetention` on `start({ experimental_hook })`; a start Hook can't be a webhook or force-claim its token. Passing any of `metadata`, `experimental_minRetention`, `isWebhook` or `experimental_force` to that `createHook()` throws. If the workflow never opens the Hook, the token is only an idempotency key: the run completes normally and unread payloads are left unread.
|
|
120
120
|
* The start Hook follows the ordinary Hook lifecycle. The token is released when the run ends, or once `experimental_minRetention` has passed if that is later. Disposing the start Hook releases it at once; see [Take care with the start Hook's lifecycle](#take-care-with-the-start-hooks-lifecycle). On a World without Hook retention, `experimental_minRetention` makes `start()` throw.
|
|
121
121
|
* If `start()` cannot confirm whether the run was queued or admitted, it asks the World again a few times with the same candidate, then throws [`WorkflowStartError`](/docs/api-reference/workflow-errors/workflow-start-error) with the candidate's `runId` and the `stage` that failed. Retrying with the same token is safe: the retry either becomes the owner or throws `HookConflictError` naming it. Inside a workflow, the `start()` step retries it automatically, while a `HookConflictError` (or a permanent rejection) reaches the workflow on the first attempt.
|
|
122
|
-
* If the run named by a `HookConflictError` is still `pending` more than a minute after it was created (its first queue message was most likely lost, so nothing will start it), the refused `start()` re-publishes that run's orchestrator message in the background, at most once a minute per run
|
|
122
|
+
* If the run named by a `HookConflictError` is still `pending` more than a minute after it was created (its first queue message was most likely lost, so nothing will start it), the refused `start()` re-publishes that run's orchestrator message in the background, at most once a minute per run, and throws without waiting for it. The run then starts; the refusal itself is unchanged.
|
|
123
123
|
* Rarely, a `HookConflictError` names a candidate that was admitted but never became a run, because the writer that admitted it died. `getRun()` doesn't find it. While the World can still create the run, resuming the token waits and may throw a retryable error with `retryAfter`; once it can't, the World releases the token and resuming throws `HookNotFoundError`. Start again with the same token then.
|
|
124
124
|
* Stream arguments (for example a webhook's `request.body`) are read only once the run is admitted, so a refused duplicate leaves them untouched. Because `start()` confirms an uncertain admission before giving up, an admitted run usually still gets its input. If it throws `WorkflowStartError` anyway, the run may have been admitted and be waiting on input that will never arrive. Cancel it with [`getRun(error.runId).cancel()`](/docs/api-reference/workflow-api/get-run), which also works when the run doesn't exist yet (see [`WorkflowStartError`](/docs/api-reference/workflow-errors/workflow-start-error)).
|
|
125
125
|
* The World must support atomic start Hooks (and Hook retention, when you set one). The Local, Postgres and Vercel Worlds do (the Postgres World after [migration `0028`](/worlds/postgres#start-hooks)). Otherwise `start()` throws before it enqueues anything. For a cross-deployment start, the target deployment must support it too. `hook` is not supported for [dynamic workflows](/docs/advanced/dynamic-workflows).
|
|
@@ -5,7 +5,6 @@ type: reference
|
|
|
5
5
|
summary: InBandSupersededError is the in-band fence's refusal. The runtime handles it by stopping the superseded orchestrator invocation, which sends the queue messages its own writes owe and then asks for a redelivery of its message.
|
|
6
6
|
related:
|
|
7
7
|
- /docs/api-reference/workflow-errors/workflow-world-error
|
|
8
|
-
- /docs/changelog/spec-9
|
|
9
8
|
---
|
|
10
9
|
|
|
11
10
|
A World throws `InBandSupersededError` (HTTP 412, code `in-band-superseded`) when it refuses a write made by a run's orchestrator because another invocation of the same run's orchestrator has written in-band since this one loaded the event log. It applies only to runs of the experimental spec 9 runtime (`WORKFLOW_SPEC_VERSION=9`).
|
|
@@ -14,8 +13,6 @@ A World throws `InBandSupersededError` (HTTP 412, code `in-band-superseded`) whe
|
|
|
14
13
|
The Workflow runtime handles this error. The refused invocation stops writing, sends the queue messages its own committed writes still owe, and asks for a redelivery of its queue message instead of acknowledging it. You will only encounter it when interacting with World storage APIs directly.
|
|
15
14
|
</Callout>
|
|
16
15
|
|
|
17
|
-
See [The in-band fence](/docs/changelog/spec-9#the-in-band-fence) on the spec 9 page.
|
|
18
|
-
|
|
19
16
|
```typescript lineNumbers
|
|
20
17
|
import { InBandSupersededError } from "workflow/errors"
|
|
21
18
|
declare const world: { events: { create(...args: any[]): Promise<any> } }; // @setup
|
|
@@ -89,7 +89,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
89
89
|
Thrown when an event creation is rejected because the client's event-log snapshot is stale.
|
|
90
90
|
</Card>
|
|
91
91
|
<Card href="/docs/api-reference/workflow-errors/in-band-superseded-error" title="InBandSupersededError">
|
|
92
|
-
Thrown
|
|
92
|
+
Thrown when a World refuses a write from a superseded orchestrator invocation.
|
|
93
93
|
</Card>
|
|
94
94
|
<Card href="/docs/api-reference/workflow-errors/too-early-error" title="TooEarlyError">
|
|
95
95
|
Thrown when a request is made before the system is ready to process it.
|
|
@@ -10,7 +10,7 @@ related:
|
|
|
10
10
|
|
|
11
11
|
`WorkflowNotRegisteredError` is thrown when the runtime tries to execute a workflow function that is not registered in the current deployment. This is an infrastructure error, not a user code error. It typically means a run was started against a deployment that does not have this workflow (e.g., the workflow was renamed or moved), or there was a build/bundling issue.
|
|
12
12
|
|
|
13
|
-
When this error occurs, the run fails with
|
|
13
|
+
When this error occurs, the run fails with the [`WORKFLOW_NOT_REGISTERED`](/docs/errors/workflow-not-registered) error code. Runs that failed on SDK versions before this code was introduced recorded `RUNTIME_ERROR` instead.
|
|
14
14
|
|
|
15
15
|
```typescript lineNumbers
|
|
16
16
|
import { WorkflowNotRegisteredError } from "workflow/errors"
|
|
@@ -12,7 +12,7 @@ related:
|
|
|
12
12
|
|
|
13
13
|
You can check for cancellation before awaiting by inspecting `run.status`.
|
|
14
14
|
|
|
15
|
-
A canceled run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue`
|
|
15
|
+
A canceled run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue` reads the result in a step, and that step fails on its first attempt instead of spending its retry budget re-reading a run that cannot change. Errors from *failing to read* the run, such as a transport blip, stay retryable.
|
|
16
16
|
|
|
17
17
|
```typescript lineNumbers
|
|
18
18
|
import { WorkflowRunCancelledError } from "workflow/errors"
|
|
@@ -13,7 +13,7 @@ related:
|
|
|
13
13
|
|
|
14
14
|
The `cause` property holds the original thrown value, hydrated through the workflow serialization pipeline so its type identity (e.g. `FatalError`, `RetryableError`, custom `Error` subclasses), `cause` chain, and custom properties are preserved. Because any JavaScript value can be thrown, `cause` is typed as `unknown`, so narrow it with `instanceof Error` (or a more specific check) before accessing fields like `message`. The high-level error classification is exposed as the top-level `errorCode` property.
|
|
15
15
|
|
|
16
|
-
A failed run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue`
|
|
16
|
+
A failed run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue` reads the result in a step, and that step fails on its first attempt instead of spending its retry budget re-reading a run that cannot change: the remote failure reaches the caller immediately, and the caller catches a `WorkflowRunFailedError` rather than a retry-exhaustion wrapper. Errors from *failing to read* the run, such as a transport blip, stay retryable.
|
|
17
17
|
|
|
18
18
|
```typescript lineNumbers
|
|
19
19
|
import { WorkflowRunFailedError } from "workflow/errors"
|
|
@@ -104,6 +104,7 @@ export default withWorkflow(nextConfig, {
|
|
|
104
104
|
| --- | --- | --- | --- |
|
|
105
105
|
| `workflows.local.port` | `number` | — | Overrides the `PORT` environment variable for local development. Has no effect when deployed to Vercel. |
|
|
106
106
|
| `workflows.sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. See [Source maps](#source-maps) below. |
|
|
107
|
+
| `workflows.experimentalRoutePrefix` | `string` | — | Serves the generated workflow routes below a route segment this app owns, such as `/dashboard`. See [Workflow route prefix](#workflow-route-prefix) below. |
|
|
107
108
|
|
|
108
109
|
### Source maps
|
|
109
110
|
|
|
@@ -129,6 +130,62 @@ The option can also be set via the `WORKFLOW_SOURCEMAP` environment variable, wh
|
|
|
129
130
|
The `workflows.local` options only affect local development. When deployed to Vercel, the runtime ignores `local` settings and uses the Vercel world automatically.
|
|
130
131
|
</Callout>
|
|
131
132
|
|
|
133
|
+
### Workflow route prefix
|
|
134
|
+
|
|
135
|
+
By default the integration generates its routes at the root of your app, so the flow route answers at `/.well-known/workflow/v1/flow`. Some deployments cannot own those paths. In a [Microfrontends](https://vercel.com/docs/microfrontends) setup, for example, a child app is routed a path such as `/dashboard/*` while requests for `/.well-known/*` go to the default app, so queue deliveries and webhooks aimed at the root never reach the child.
|
|
136
|
+
|
|
137
|
+
`workflows.experimentalRoutePrefix` moves the generated workflow routes below a segment the app does own:
|
|
138
|
+
|
|
139
|
+
```typescript title="next.config.ts" lineNumbers
|
|
140
|
+
import type { NextConfig } from "next";
|
|
141
|
+
import { withWorkflow } from "workflow/next";
|
|
142
|
+
|
|
143
|
+
const nextConfig: NextConfig = {};
|
|
144
|
+
|
|
145
|
+
export default withWorkflow(nextConfig, {
|
|
146
|
+
workflows: {
|
|
147
|
+
experimentalRoutePrefix: "/dashboard", // [!code highlight]
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
With that prefix, the build emits:
|
|
153
|
+
|
|
154
|
+
| Artifact | Path |
|
|
155
|
+
| --- | --- |
|
|
156
|
+
| Flow route | `app/dashboard/.well-known/workflow/v1/flow/route.js` |
|
|
157
|
+
| Webhook route | `app/dashboard/.well-known/workflow/v1/webhook/[token]/route.js` |
|
|
158
|
+
| Vercel function config | `app/dashboard/.well-known/workflow/v1/config.json` |
|
|
159
|
+
| Manifest | `app/dashboard/.well-known/workflow/v1/manifest.json` |
|
|
160
|
+
|
|
161
|
+
The queue trigger that makes the flow route a queue consumer is written next to the prefixed route, so deliveries reach it without any additional routing configuration. Webhook URLs, health checks, and the local and Postgres queue targets are all built from the prefix, so `createWebhook()` returns a URL under `/dashboard/.well-known/workflow/v1/webhook/:token`. `getWorkflowMetadata().url` includes the prefix too (for example `https://example.com/dashboard`), so don't build URLs to the rest of your app from it.
|
|
162
|
+
|
|
163
|
+
The prefix is a plain path of one or more segments. Leading and trailing slashes are optional. Anything Next.js would not serve at a fixed path is rejected when the config is created: dynamic segments such as `/[team]`, route groups such as `/(group)`, and `_`-prefixed segments, which Next.js excludes from routing entirely. Segments starting with `.` are rejected too, because the build could not clean up routes generated below them after the prefix changes.
|
|
164
|
+
|
|
165
|
+
<Callout type="warn">
|
|
166
|
+
If you cache your build with Turborepo, update the `outputs` globs to the prefixed paths. `app/.well-known/workflow/**` no longer matches `app/dashboard/.well-known/workflow/**`, and a cache hit would restore a build with no workflow routes in it.
|
|
167
|
+
</Callout>
|
|
168
|
+
|
|
169
|
+
<Callout type="warn">
|
|
170
|
+
If the app has `proxy.ts` or middleware, its matcher must exclude the prefixed path. A pattern such as `/((?!.well-known/workflow/).*)` only matches from the start of the path, so it no longer skips `/dashboard/.well-known/workflow/v1/flow`; exclude `dashboard/.well-known/workflow/` instead.
|
|
171
|
+
</Callout>
|
|
172
|
+
|
|
173
|
+
<Callout type="warn">
|
|
174
|
+
Your routing layer must send the prefixed paths to this app. With Microfrontends, that means choosing a prefix the child app is already routed in the group's [routing configuration](https://vercel.com/docs/microfrontends/routing).
|
|
175
|
+
</Callout>
|
|
176
|
+
|
|
177
|
+
This option is experimental and its name may change.
|
|
178
|
+
|
|
179
|
+
#### Compared with `basePath`
|
|
180
|
+
|
|
181
|
+
The integration already honors Next.js' [`basePath`](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath): Next.js serves every route, including the generated workflow routes, below it, and `withWorkflow` passes it to the runtime so webhook and queue URLs include it. That only helps when the whole app can move under one path. A Microfrontends child app usually can't: its pages already live at `app/dashboard/...`, so `basePath: "/dashboard"` would serve them at `/dashboard/dashboard/...`.
|
|
182
|
+
|
|
183
|
+
`experimentalRoutePrefix` moves only the generated workflow routes and their function config into the app tree; the rest of your routes keep their paths. The two compose: with `basePath: "/v2"` and `experimentalRoutePrefix: "/dashboard"`, the flow route answers at `/v2/dashboard/.well-known/workflow/v1/flow`.
|
|
184
|
+
|
|
185
|
+
<Callout type="info">
|
|
186
|
+
The local CLI and web UI find a prefixed manifest such as `app/dashboard/.well-known/workflow/v1/manifest.json` on their own; set [`WORKFLOW_MANIFEST_PATH`](/docs/configuration/cli-and-web-ui#workflow_manifest_path) to pick another. Pass the base path to [`workflow health`](/docs/configuration/cli-and-web-ui#--base-path), for example `workflow health --base-path /dashboard`.
|
|
187
|
+
</Callout>
|
|
188
|
+
|
|
132
189
|
## Exporting a function
|
|
133
190
|
|
|
134
191
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: createStateResolver
|
|
3
|
+
description: Rebuild frozen state that a run stored by reference, so inspection tools show actual values.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use createStateResolver to show the actual values of step inputs and outputs that hold frozen state stored by reference.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-observability/hydrate-data
|
|
8
|
+
- /docs/api-reference/workflow-observability/observability-revivers
|
|
9
|
+
- /docs/foundations/serialization
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Deeply frozen values passed between steps are stored by reference: a step input that holds one is written as a reference to an earlier step's output, and a step output as its change from the value it was made from. See [Serialization](/docs/foundations/serialization). Workflow rebuilds them during replay, so your code always receives whole values. An inspection tool reading the stored payloads directly has to rebuild them too, from the run's earlier records.
|
|
13
|
+
|
|
14
|
+
Create one resolver per run, feed it the run's persisted payloads once, in event-log order, and merge its revivers over the ones you hydrate with:
|
|
15
|
+
|
|
16
|
+
```typescript lineNumbers
|
|
17
|
+
import { createStateResolver, hydrateData, observabilityRevivers, stateSourceId } from "workflow/observability"; // [!code highlight]
|
|
18
|
+
declare const runInput: unknown; // @setup
|
|
19
|
+
declare const events: { eventId: string; eventType: string; eventData?: { payload?: unknown; result?: unknown } }[]; // @setup
|
|
20
|
+
declare const stepInput: unknown; // @setup
|
|
21
|
+
|
|
22
|
+
const resolver = createStateResolver(observabilityRevivers); // [!code highlight]
|
|
23
|
+
resolver.add(runInput, stateSourceId("run-input"));
|
|
24
|
+
for (const event of events) {
|
|
25
|
+
if (event.eventType === "hook_received") resolver.add(event.eventData?.payload, stateSourceId(event));
|
|
26
|
+
if (event.eventType === "step_completed") resolver.add(event.eventData?.result);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const input = hydrateData(stepInput, { ...observabilityRevivers, ...resolver.revivers }); // [!code highlight]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Pass decrypted payloads. Keep the resolver for the run and reuse it across inspections, so the history is read once.
|
|
33
|
+
|
|
34
|
+
A web inspector built on `@workflow/web-shared` can use `createRunStateHydrator()` instead. It reads the run's history through loaders you give it, only as far as the inspected value needs, and handles encrypted and compressed payloads. The Workflow web UI uses it for its span details, and `workflow inspect` rebuilds values the same way.
|
|
35
|
+
|
|
36
|
+
## API signature
|
|
37
|
+
|
|
38
|
+
### Parameters
|
|
39
|
+
|
|
40
|
+
| Parameter | Type | Description |
|
|
41
|
+
|-----------|------|-------------|
|
|
42
|
+
| `revivers` | `Revivers` | Optional. Revivers for the other types inside the stored payloads. Use [`observabilityRevivers`](/docs/api-reference/workflow-observability/observability-revivers) for standard use. |
|
|
43
|
+
|
|
44
|
+
### Returns
|
|
45
|
+
|
|
46
|
+
A `StateResolver`:
|
|
47
|
+
|
|
48
|
+
| Property | Type | Description |
|
|
49
|
+
|----------|------|-------------|
|
|
50
|
+
| `add(data, source?)` | `(data: unknown, source?: string) => void` | Reads one persisted payload. Pass `stateSourceId(event)` for a `hook_received` payload and `stateSourceId("run-input")` for the run input, so state can refer to their strings. A step output with no state records is skipped. |
|
|
51
|
+
| `revivers` | `Revivers` | Revivers that rebuild state records from what has been added. Merge them over your own. |
|
|
52
|
+
| `unresolved` | `number` | How many records referred to history that hasn't been added yet. Those show as `<state …>` placeholders; add more of the history and hydrate again. |
|
|
53
|
+
|
|
54
|
+
## stateSourceId
|
|
55
|
+
|
|
56
|
+
`stateSourceId(event)` returns the id a `hook_received` event's payload is registered under, and `stateSourceId("run-input")` the id for the run input. Use the same ids the runtime uses, or state that refers to those payloads' strings stays unresolved.
|