@workflow/core 5.2.3 → 5.4.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/README.md +27 -0
- package/dist/capabilities.d.ts +2 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +7 -1
- package/dist/classify-error.d.ts.map +1 -1
- package/dist/classify-error.js +3 -2
- package/dist/create-hook.d.ts +15 -0
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/events-consumer.d.ts +98 -6
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +198 -13
- package/dist/flushable-stream.js +11 -2
- package/dist/global.d.ts +6 -0
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +65 -35
- package/dist/private.d.ts +41 -2
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +39 -4
- package/dist/replay-payload-cache.d.ts +13 -2
- package/dist/replay-payload-cache.d.ts.map +1 -1
- package/dist/replay-payload-cache.js +20 -10
- package/dist/runtime/after-terminal-write.d.ts +33 -0
- package/dist/runtime/after-terminal-write.d.ts.map +1 -0
- package/dist/runtime/after-terminal-write.js +23 -0
- package/dist/runtime/child-run-completion-notify.d.ts +36 -0
- package/dist/runtime/child-run-completion-notify.d.ts.map +1 -0
- package/dist/runtime/child-run-completion-notify.js +97 -0
- package/dist/runtime/child-run-completion.d.ts +45 -0
- package/dist/runtime/child-run-completion.d.ts.map +1 -0
- package/dist/runtime/child-run-completion.js +192 -0
- package/dist/runtime/constants.d.ts +161 -176
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +194 -273
- package/dist/runtime/delivery.d.ts +270 -0
- package/dist/runtime/delivery.d.ts.map +1 -0
- package/dist/runtime/delivery.js +325 -0
- package/dist/runtime/deployment-guard.d.ts +8 -1
- package/dist/runtime/deployment-guard.d.ts.map +1 -1
- package/dist/runtime/deployment-guard.js +12 -6
- package/dist/runtime/get-port-lazy.d.ts.map +1 -1
- package/dist/runtime/get-port-lazy.js +77 -14
- package/dist/runtime/helpers.d.ts +50 -4
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +88 -10
- package/dist/runtime/hook-creation.d.ts +45 -0
- package/dist/runtime/hook-creation.d.ts.map +1 -0
- package/dist/runtime/hook-creation.js +98 -0
- package/dist/runtime/hook-wake.d.ts +16 -14
- package/dist/runtime/hook-wake.d.ts.map +1 -1
- package/dist/runtime/hook-wake.js +31 -18
- package/dist/runtime/invocations.d.ts.map +1 -1
- package/dist/runtime/invocations.js +9 -3
- package/dist/runtime/out-of-band-observation.d.ts +28 -17
- package/dist/runtime/out-of-band-observation.d.ts.map +1 -1
- package/dist/runtime/out-of-band-observation.js +12 -3
- package/dist/runtime/quickjs-delivery-shared.d.ts +126 -0
- package/dist/runtime/quickjs-delivery-shared.d.ts.map +1 -0
- package/dist/runtime/quickjs-delivery-shared.js +176 -0
- package/dist/runtime/quickjs-log-view.d.ts +17 -0
- package/dist/runtime/quickjs-log-view.d.ts.map +1 -1
- package/dist/runtime/quickjs-log-view.js +31 -1
- package/dist/runtime/quickjs-pending-ops.d.ts +181 -0
- package/dist/runtime/quickjs-pending-ops.d.ts.map +1 -0
- package/dist/runtime/quickjs-pending-ops.js +633 -0
- package/dist/runtime/quickjs-runtime.d.ts +30 -5
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +546 -169
- package/dist/runtime/quickjs-serde.d.ts.map +1 -1
- package/dist/runtime/quickjs-serde.js +96 -5
- package/dist/runtime/replay-budget.d.ts +8 -1
- package/dist/runtime/replay-budget.d.ts.map +1 -1
- package/dist/runtime/replay-budget.js +12 -8
- package/dist/runtime/resume-hook.d.ts +15 -10
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +211 -65
- package/dist/runtime/run-spec-routing.d.ts +52 -0
- package/dist/runtime/run-spec-routing.d.ts.map +1 -0
- package/dist/runtime/run-spec-routing.js +78 -0
- package/dist/runtime/run-spec-version.d.ts +8 -4
- package/dist/runtime/run-spec-version.d.ts.map +1 -1
- package/dist/runtime/run-spec-version.js +11 -7
- package/dist/runtime/run.d.ts +29 -3
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +116 -11
- package/dist/runtime/runs.d.ts +58 -2
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +228 -30
- package/dist/runtime/spec8/constants.d.ts +177 -0
- package/dist/runtime/spec8/constants.d.ts.map +1 -0
- package/dist/runtime/spec8/constants.js +232 -0
- package/dist/runtime/spec8/count-step-started-events.d.ts.map +1 -0
- package/dist/runtime/spec8/count-step-started-events.js +72 -0
- package/dist/runtime/spec8/delivery.d.ts +6 -0
- package/dist/runtime/spec8/delivery.d.ts.map +1 -0
- package/dist/runtime/spec8/delivery.js +4250 -0
- package/dist/runtime/spec8/inline-steps-in-flight.d.ts +58 -0
- package/dist/runtime/spec8/inline-steps-in-flight.d.ts.map +1 -0
- package/dist/runtime/spec8/inline-steps-in-flight.js +104 -0
- package/dist/runtime/spec8/open-hook-wait-state.d.ts.map +1 -0
- package/dist/runtime/spec8/open-hook-wait-state.js +93 -0
- package/dist/runtime/{quickjs-entrypoint.d.ts → spec8/quickjs-entrypoint.d.ts} +0 -20
- package/dist/runtime/spec8/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/spec8/quickjs-entrypoint.js +1779 -0
- package/dist/runtime/{step-executor.d.ts → spec8/step-executor.d.ts} +11 -7
- package/dist/runtime/spec8/step-executor.d.ts.map +1 -0
- package/dist/runtime/spec8/step-executor.js +1134 -0
- package/dist/runtime/{step-ownership.d.ts → spec8/step-ownership.d.ts} +1 -1
- package/dist/runtime/spec8/step-ownership.d.ts.map +1 -0
- package/dist/runtime/spec8/step-ownership.js +114 -0
- package/dist/runtime/spec8/step-single-flight.d.ts +34 -0
- package/dist/runtime/spec8/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/spec8/step-single-flight.js +36 -0
- package/dist/runtime/{suspension-handler.d.ts → spec8/suspension-handler.d.ts} +68 -24
- package/dist/runtime/spec8/suspension-handler.d.ts.map +1 -0
- package/dist/runtime/spec8/suspension-handler.js +1291 -0
- package/dist/runtime/spec9/consume-after-commit.d.ts +33 -0
- package/dist/runtime/spec9/consume-after-commit.d.ts.map +1 -0
- package/dist/runtime/spec9/consume-after-commit.js +13 -0
- package/dist/runtime/spec9/consumed-position.d.ts +38 -0
- package/dist/runtime/spec9/consumed-position.d.ts.map +1 -0
- package/dist/runtime/spec9/consumed-position.js +48 -0
- package/dist/runtime/spec9/creator-rules.d.ts +220 -0
- package/dist/runtime/spec9/creator-rules.d.ts.map +1 -0
- package/dist/runtime/spec9/creator-rules.js +357 -0
- package/dist/runtime/spec9/deadline.d.ts +18 -0
- package/dist/runtime/spec9/deadline.d.ts.map +1 -0
- package/dist/runtime/spec9/deadline.js +27 -0
- package/dist/runtime/spec9/delivery.d.ts +17 -0
- package/dist/runtime/spec9/delivery.d.ts.map +1 -0
- package/dist/runtime/spec9/delivery.js +3837 -0
- package/dist/runtime/spec9/fence-refusals.d.ts +20 -0
- package/dist/runtime/spec9/fence-refusals.d.ts.map +1 -0
- package/dist/runtime/spec9/fence-refusals.js +55 -0
- package/dist/runtime/spec9/in-band-writer.d.ts +275 -0
- package/dist/runtime/spec9/in-band-writer.d.ts.map +1 -0
- package/dist/runtime/spec9/in-band-writer.js +831 -0
- package/dist/runtime/spec9/live-feed.d.ts +151 -0
- package/dist/runtime/spec9/live-feed.d.ts.map +1 -0
- package/dist/runtime/spec9/live-feed.js +311 -0
- package/dist/runtime/spec9/log-state.d.ts +137 -0
- package/dist/runtime/spec9/log-state.d.ts.map +1 -0
- package/dist/runtime/spec9/log-state.js +176 -0
- package/dist/runtime/spec9/quickjs-entrypoint.d.ts +185 -0
- package/dist/runtime/spec9/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/spec9/quickjs-entrypoint.js +2332 -0
- package/dist/runtime/spec9/read-deadline.d.ts +46 -0
- package/dist/runtime/spec9/read-deadline.d.ts.map +1 -0
- package/dist/runtime/spec9/read-deadline.js +88 -0
- package/dist/runtime/spec9/run-ahead.d.ts +65 -0
- package/dist/runtime/spec9/run-ahead.d.ts.map +1 -0
- package/dist/runtime/spec9/run-ahead.js +102 -0
- package/dist/runtime/spec9/step-delivery.d.ts +111 -0
- package/dist/runtime/spec9/step-delivery.d.ts.map +1 -0
- package/dist/runtime/spec9/step-delivery.js +149 -0
- package/dist/runtime/spec9/step-executor.d.ts +217 -0
- package/dist/runtime/spec9/step-executor.d.ts.map +1 -0
- package/dist/runtime/spec9/step-executor.js +782 -0
- package/dist/runtime/spec9/step-handler.d.ts +92 -0
- package/dist/runtime/spec9/step-handler.d.ts.map +1 -0
- package/dist/runtime/spec9/step-handler.js +375 -0
- package/dist/runtime/spec9/step-message.d.ts +42 -0
- package/dist/runtime/spec9/step-message.d.ts.map +1 -0
- package/dist/runtime/spec9/step-message.js +81 -0
- package/dist/runtime/spec9/step-retention.d.ts +44 -0
- package/dist/runtime/spec9/step-retention.d.ts.map +1 -0
- package/dist/runtime/spec9/step-retention.js +51 -0
- package/dist/runtime/spec9/step-single-flight.d.ts +19 -0
- package/dist/runtime/spec9/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/spec9/step-single-flight.js +24 -0
- package/dist/runtime/spec9/step-wait-creation.d.ts +162 -0
- package/dist/runtime/spec9/step-wait-creation.d.ts.map +1 -0
- package/dist/runtime/spec9/step-wait-creation.js +450 -0
- package/dist/runtime/spec9/suspension-handler.d.ts +125 -0
- package/dist/runtime/spec9/suspension-handler.d.ts.map +1 -0
- package/dist/runtime/spec9/suspension-handler.js +327 -0
- package/dist/runtime/spec9/wait-timer.d.ts +143 -0
- package/dist/runtime/spec9/wait-timer.d.ts.map +1 -0
- package/dist/runtime/spec9/wait-timer.js +173 -0
- package/dist/runtime/start-hook-binding.d.ts +50 -0
- package/dist/runtime/start-hook-binding.d.ts.map +1 -0
- package/dist/runtime/start-hook-binding.js +85 -0
- package/dist/runtime/start-hook-delivery.d.ts +47 -0
- package/dist/runtime/start-hook-delivery.d.ts.map +1 -0
- package/dist/runtime/start-hook-delivery.js +94 -0
- package/dist/runtime/start-hook-holder.d.ts +50 -0
- package/dist/runtime/start-hook-holder.d.ts.map +1 -0
- package/dist/runtime/start-hook-holder.js +149 -0
- package/dist/runtime/start.d.ts +76 -4
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +451 -62
- package/dist/runtime/step-latency.d.ts +3 -3
- package/dist/runtime/step-latency.js +1 -1
- package/dist/runtime/step-single-flight.d.ts +4 -8
- package/dist/runtime/step-single-flight.d.ts.map +1 -1
- package/dist/runtime/step-single-flight.js +23 -36
- package/dist/runtime/step-streams.d.ts +6 -0
- package/dist/runtime/step-streams.d.ts.map +1 -0
- package/dist/runtime/step-streams.js +40 -0
- package/dist/runtime/suspension-hooks.d.ts +84 -0
- package/dist/runtime/suspension-hooks.d.ts.map +1 -0
- package/dist/runtime/suspension-hooks.js +310 -0
- package/dist/runtime/wait-continuation.d.ts +27 -0
- package/dist/runtime/wait-continuation.d.ts.map +1 -1
- package/dist/runtime/wait-continuation.js +27 -2
- package/dist/runtime/world-compatibility.d.ts +22 -3
- package/dist/runtime/world-compatibility.d.ts.map +1 -1
- package/dist/runtime/world-compatibility.js +37 -2
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +2 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +118 -4154
- package/dist/serialization/abort-stream.d.ts +11 -0
- package/dist/serialization/abort-stream.d.ts.map +1 -0
- package/dist/serialization/abort-stream.js +86 -0
- package/dist/serialization/reducers/common-vm.d.ts.map +1 -1
- package/dist/serialization/reducers/common-vm.js +39 -2
- package/dist/serialization/reducers/common.d.ts.map +1 -1
- package/dist/serialization/reducers/common.js +26 -3
- package/dist/serialization/types.d.ts +10 -1
- package/dist/serialization/types.d.ts.map +1 -1
- package/dist/serialization/types.js +1 -1
- package/dist/serialization.d.ts +21 -5
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +136 -79
- package/dist/set-attributes.d.ts.map +1 -1
- package/dist/set-attributes.js +9 -14
- package/dist/step/context-storage.d.ts +2 -0
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js +1 -1
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +23 -16
- package/dist/telemetry/semantic-conventions.d.ts +218 -3
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +161 -2
- package/dist/test-support/append-only-world.d.ts +437 -0
- package/dist/test-support/append-only-world.d.ts.map +1 -0
- package/dist/test-support/append-only-world.js +816 -0
- package/dist/test-support/fence-snapshot.d.ts +11 -0
- package/dist/test-support/fence-snapshot.d.ts.map +1 -0
- package/dist/test-support/fence-snapshot.js +12 -0
- package/dist/test-support/load-events.d.ts +8 -0
- package/dist/test-support/load-events.d.ts.map +1 -0
- package/dist/test-support/load-events.js +27 -0
- package/dist/test-support/orchestrator-harness.d.ts +502 -0
- package/dist/test-support/orchestrator-harness.d.ts.map +1 -0
- package/dist/test-support/orchestrator-harness.js +116 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/workflow/abort-controller.d.ts.map +1 -1
- package/dist/workflow/abort-controller.js +7 -5
- package/dist/workflow/hook.d.ts +5 -0
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +83 -19
- package/dist/workflow.d.ts +45 -16
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +111 -50
- package/docs/api-reference/create-hook.mdx +8 -0
- package/docs/api-reference/create-webhook.mdx +1 -1
- package/docs/api-reference/fetch.mdx +2 -0
- package/docs/foundations/errors-and-retries.mdx +6 -0
- package/docs/foundations/hooks.mdx +3 -1
- package/docs/foundations/idempotency.mdx +190 -60
- package/docs/foundations/starting-workflows.mdx +3 -7
- package/docs/how-it-works/event-sourcing.mdx +6 -0
- package/package.json +5 -5
- package/dist/runtime/count-step-started-events.d.ts.map +0 -1
- package/dist/runtime/count-step-started-events.js +0 -72
- package/dist/runtime/open-hook-wait-state.d.ts.map +0 -1
- package/dist/runtime/open-hook-wait-state.js +0 -93
- package/dist/runtime/quickjs-entrypoint.d.ts.map +0 -1
- package/dist/runtime/quickjs-entrypoint.js +0 -2314
- package/dist/runtime/step-executor.d.ts.map +0 -1
- package/dist/runtime/step-executor.js +0 -1156
- package/dist/runtime/step-ownership.d.ts.map +0 -1
- package/dist/runtime/step-ownership.js +0 -114
- package/dist/runtime/suspension-handler.d.ts.map +0 -1
- package/dist/runtime/suspension-handler.js +0 -1562
- /package/dist/runtime/{count-step-started-events.d.ts → spec8/count-step-started-events.d.ts} +0 -0
- /package/dist/runtime/{open-hook-wait-state.d.ts → spec8/open-hook-wait-state.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type WorkflowInvokePayload, type WorkflowRun } from '@workflow/world';
|
|
2
|
+
/** The spec version of a message's run, and the run when it had to be read. */
|
|
3
|
+
export interface RunSpec {
|
|
4
|
+
specVersion: number;
|
|
5
|
+
/** The run (`resolveData: 'none'`), when routing read it. */
|
|
6
|
+
run?: WorkflowRun;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The spec version of the run `message` belongs to, which picks the
|
|
10
|
+
* orchestrator that handles it. In order:
|
|
11
|
+
*
|
|
12
|
+
* 1. `runInput.specVersion` (a run's first delivery, from `start()`) or
|
|
13
|
+
* `runContext.specVersion` (a step message), which the run's creator or
|
|
14
|
+
* its orchestrator wrote from the run itself.
|
|
15
|
+
* 2. The `runSpecVersion` hint, which every other producer in this runtime
|
|
16
|
+
* stamps on the orchestrator messages it sends, from the run row or from
|
|
17
|
+
* the delivery that sends them.
|
|
18
|
+
* 3. `runs.get`, for a message that carries neither. That covers a producer
|
|
19
|
+
* that does not know the run's version (`resumeHook()` on a hook that
|
|
20
|
+
* records none), a World's own message for a run that records none, and
|
|
21
|
+
* producers that predate the fields. A run without a stored version is
|
|
22
|
+
* `SPEC_VERSION_LEGACY`. A run that cannot be found takes the World's own
|
|
23
|
+
* version, and the orchestrator then handles the missing run as it would
|
|
24
|
+
* any other. The run read here is handed on, so the orchestrator does not
|
|
25
|
+
* read it again.
|
|
26
|
+
*
|
|
27
|
+
* A wrong hint routes the message to the other orchestrator, which finds the
|
|
28
|
+
* run's own version on the row it loads and hands the message on (see
|
|
29
|
+
* `handOffToRunOrchestrator`).
|
|
30
|
+
*
|
|
31
|
+
* Producers outside this runtime (an older SDK, or another client of the
|
|
32
|
+
* World) may send a message for a spec 9 run that is unstamped or stamped
|
|
33
|
+
* below 9. Nothing here can prevent that. Such a message is routed to the
|
|
34
|
+
* right orchestrator: an unstamped one through `runs.get`, a low hint
|
|
35
|
+
* through the hand-off once the run is loaded. But the World has already
|
|
36
|
+
* treated it as a message of an earlier run (see `messageRunSpecVersion` in
|
|
37
|
+
* `@workflow/world`): world-vercel sends it without the run's concurrency key,
|
|
38
|
+
* and world-local and world-postgres do not serialize it, so it can run beside
|
|
39
|
+
* the run's serialized orchestrator. The in-band fence keeps the run's log
|
|
40
|
+
* correct: the second writer's in-band write is refused. The cost is wasted
|
|
41
|
+
* orchestrator work, which can include running the body of an inline step
|
|
42
|
+
* the other delivery is still running; it does not corrupt the log.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveRunSpec(message: WorkflowInvokePayload): Promise<RunSpec>;
|
|
45
|
+
/**
|
|
46
|
+
* `payload` with `specVersion` as its routing hint (`runSpecVersion`), for an
|
|
47
|
+
* orchestrator message whose producer passed the run's version as a queue
|
|
48
|
+
* option. Unchanged when no version was passed, when it is not a run's
|
|
49
|
+
* message, or when it already carries the hint.
|
|
50
|
+
*/
|
|
51
|
+
export declare function withRunSpecVersion<T>(payload: T, specVersion?: number): T;
|
|
52
|
+
//# sourceMappingURL=run-spec-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-spec-routing.d.ts","sourceRoot":"","sources":["../../src/runtime/run-spec-routing.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,+EAA+E;AAC/E,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAmBlB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,CAQzE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { WorkflowRunNotFoundError } from '@workflow/errors';
|
|
2
|
+
import { SPEC_VERSION_LEGACY, } from '@workflow/world';
|
|
3
|
+
import { trace } from '../telemetry.js';
|
|
4
|
+
import { getWorld } from './world.js';
|
|
5
|
+
/**
|
|
6
|
+
* The spec version of the run `message` belongs to, which picks the
|
|
7
|
+
* orchestrator that handles it. In order:
|
|
8
|
+
*
|
|
9
|
+
* 1. `runInput.specVersion` (a run's first delivery, from `start()`) or
|
|
10
|
+
* `runContext.specVersion` (a step message), which the run's creator or
|
|
11
|
+
* its orchestrator wrote from the run itself.
|
|
12
|
+
* 2. The `runSpecVersion` hint, which every other producer in this runtime
|
|
13
|
+
* stamps on the orchestrator messages it sends, from the run row or from
|
|
14
|
+
* the delivery that sends them.
|
|
15
|
+
* 3. `runs.get`, for a message that carries neither. That covers a producer
|
|
16
|
+
* that does not know the run's version (`resumeHook()` on a hook that
|
|
17
|
+
* records none), a World's own message for a run that records none, and
|
|
18
|
+
* producers that predate the fields. A run without a stored version is
|
|
19
|
+
* `SPEC_VERSION_LEGACY`. A run that cannot be found takes the World's own
|
|
20
|
+
* version, and the orchestrator then handles the missing run as it would
|
|
21
|
+
* any other. The run read here is handed on, so the orchestrator does not
|
|
22
|
+
* read it again.
|
|
23
|
+
*
|
|
24
|
+
* A wrong hint routes the message to the other orchestrator, which finds the
|
|
25
|
+
* run's own version on the row it loads and hands the message on (see
|
|
26
|
+
* `handOffToRunOrchestrator`).
|
|
27
|
+
*
|
|
28
|
+
* Producers outside this runtime (an older SDK, or another client of the
|
|
29
|
+
* World) may send a message for a spec 9 run that is unstamped or stamped
|
|
30
|
+
* below 9. Nothing here can prevent that. Such a message is routed to the
|
|
31
|
+
* right orchestrator: an unstamped one through `runs.get`, a low hint
|
|
32
|
+
* through the hand-off once the run is loaded. But the World has already
|
|
33
|
+
* treated it as a message of an earlier run (see `messageRunSpecVersion` in
|
|
34
|
+
* `@workflow/world`): world-vercel sends it without the run's concurrency key,
|
|
35
|
+
* and world-local and world-postgres do not serialize it, so it can run beside
|
|
36
|
+
* the run's serialized orchestrator. The in-band fence keeps the run's log
|
|
37
|
+
* correct: the second writer's in-band write is refused. The cost is wasted
|
|
38
|
+
* orchestrator work, which can include running the body of an inline step
|
|
39
|
+
* the other delivery is still running; it does not corrupt the log.
|
|
40
|
+
*/
|
|
41
|
+
export async function resolveRunSpec(message) {
|
|
42
|
+
const stamped = message.runInput?.specVersion ??
|
|
43
|
+
message.runContext?.specVersion ??
|
|
44
|
+
message.runSpecVersion;
|
|
45
|
+
if (stamped !== undefined)
|
|
46
|
+
return { specVersion: stamped };
|
|
47
|
+
const world = await getWorld();
|
|
48
|
+
try {
|
|
49
|
+
const run = (await trace('workflow.route.resolve_spec', () => world.runs.get(message.runId, { resolveData: 'none' })));
|
|
50
|
+
if (!run)
|
|
51
|
+
return { specVersion: world.specVersion };
|
|
52
|
+
return { specVersion: run.specVersion ?? SPEC_VERSION_LEGACY, run };
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (WorkflowRunNotFoundError.is(error)) {
|
|
56
|
+
return { specVersion: world.specVersion };
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `payload` with `specVersion` as its routing hint (`runSpecVersion`), for an
|
|
63
|
+
* orchestrator message whose producer passed the run's version as a queue
|
|
64
|
+
* option. Unchanged when no version was passed, when it is not a run's
|
|
65
|
+
* message, or when it already carries the hint.
|
|
66
|
+
*/
|
|
67
|
+
export function withRunSpecVersion(payload, specVersion) {
|
|
68
|
+
if (specVersion === undefined)
|
|
69
|
+
return payload;
|
|
70
|
+
if (typeof payload !== 'object' || payload === null)
|
|
71
|
+
return payload;
|
|
72
|
+
const message = payload;
|
|
73
|
+
if (typeof message.runId !== 'string' || 'runSpecVersion' in message) {
|
|
74
|
+
return payload;
|
|
75
|
+
}
|
|
76
|
+
return { ...message, runSpecVersion: specVersion };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVuLXNwZWMtcm91dGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydW50aW1lL3J1bi1zcGVjLXJvdXRpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDNUQsT0FBTyxFQUNMLG1CQUFtQixHQUdwQixNQUFNLGlCQUFpQixDQUFDO0FBQ3pCLE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN4QyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBU3RDOzs7Ozs7Ozs7Ozs7Ozs7Ozs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UgcHJvZHVjZXIgcGFzc2VkIHRoZSBydW4ncyB2ZXJzaW9uIGFzIGEgcXVldWVcbiAqIG9wdGlvbi4gVW5jaGFuZ2VkIHdoZW4gbm8gdmVyc2lvbiB3YXMgcGFzc2VkLCB3aGVuIGl0IGlzIG5vdCBhIHJ1bidzXG4gKiBtZXNzYWdlLCBvciB3aGVuIGl0IGFscmVhZHkgY2FycmllcyB0aGUgaGludC5cbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIHdpdGhSdW5TcGVjVmVyc2lvbjxUPihwYXlsb2FkOiBULCBzcGVjVmVyc2lvbj86IG51bWJlcik6IFQge1xuICBpZiAoc3BlY1ZlcnNpb24gPT09IHVuZGVmaW5lZCkgcmV0dXJuIHBheWxvYWQ7XG4gIGlmICh0eXBlb2YgcGF5bG9hZCAhPT0gJ29iamVjdCcgfHwgcGF5bG9hZCA9PT0gbnVsbCkgcmV0dXJuIHBheWxvYWQ7XG4gIGNvbnN0IG1lc3NhZ2UgPSBwYXlsb2FkIGFzIFJlY29yZDxzdHJpbmcsIHVua25vd24+O1xuICBpZiAodHlwZW9mIG1lc3NhZ2UucnVuSWQgIT09ICdzdHJpbmcnIHx8ICdydW5TcGVjVmVyc2lvbicgaW4gbWVzc2FnZSkge1xuICAgIHJldHVybiBwYXlsb2FkO1xuICB9XG4gIHJldHVybiB7IC4uLm1lc3NhZ2UsIHJ1blNwZWNWZXJzaW9uOiBzcGVjVmVyc2lvbiB9IGFzIFQ7XG59XG4iXX0=
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
* The runtime executing a run reads every event in its log, and one built
|
|
7
7
|
* against a lower spec version (an older deployment, or another SDK) rejects an
|
|
8
8
|
* event stamped above what it supports. The Python SDK rejects the run's whole
|
|
9
|
-
* event log over a single such event. Capped at
|
|
10
|
-
*
|
|
9
|
+
* event log over a single such event. Capped at the highest version this SDK
|
|
10
|
+
* can drive, `SPEC_VERSION_MAX_SUPPORTED`, not at the version it mints: a
|
|
11
|
+
* process that creates spec 8 runs still stamps 9 on the `hook_received`,
|
|
12
|
+
* `run_cancelled` and wake events it writes to a spec 9 run, which may have
|
|
13
|
+
* been created by a process with `WORKFLOW_SPEC_VERSION=9` set.
|
|
11
14
|
*
|
|
12
|
-
* `whenUnknown` is used for a run with no recorded version. It defaults to
|
|
13
|
-
*
|
|
15
|
+
* `whenUnknown` is used for a run with no recorded version. It defaults to the
|
|
16
|
+
* version this SDK mints by default (`SPEC_VERSION_CURRENT`); callers that
|
|
17
|
+
* treat such a run as legacy pass `SPEC_VERSION_LEGACY`.
|
|
14
18
|
*/
|
|
15
19
|
export declare function specVersionForRunWrite(runSpecVersion: number | undefined, whenUnknown?: number): number;
|
|
16
20
|
//# sourceMappingURL=run-spec-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-spec-version.d.ts","sourceRoot":"","sources":["../../src/runtime/run-spec-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-spec-version.d.ts","sourceRoot":"","sources":["../../src/runtime/run-spec-version.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,WAAW,GAAE,MAA6B,GACzC,MAAM,CAER"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SPEC_VERSION_CURRENT } from '@workflow/world/spec-version';
|
|
1
|
+
import { SPEC_VERSION_CURRENT, SPEC_VERSION_MAX_SUPPORTED, } from '@workflow/world/spec-version';
|
|
2
2
|
/**
|
|
3
3
|
* The spec version to stamp on an event written to a run by a process that may
|
|
4
4
|
* not be the one executing it: the run's own version when it is lower than this
|
|
@@ -7,13 +7,17 @@ import { SPEC_VERSION_CURRENT } from '@workflow/world/spec-version';
|
|
|
7
7
|
* The runtime executing a run reads every event in its log, and one built
|
|
8
8
|
* against a lower spec version (an older deployment, or another SDK) rejects an
|
|
9
9
|
* event stamped above what it supports. The Python SDK rejects the run's whole
|
|
10
|
-
* event log over a single such event. Capped at
|
|
11
|
-
*
|
|
10
|
+
* event log over a single such event. Capped at the highest version this SDK
|
|
11
|
+
* can drive, `SPEC_VERSION_MAX_SUPPORTED`, not at the version it mints: a
|
|
12
|
+
* process that creates spec 8 runs still stamps 9 on the `hook_received`,
|
|
13
|
+
* `run_cancelled` and wake events it writes to a spec 9 run, which may have
|
|
14
|
+
* been created by a process with `WORKFLOW_SPEC_VERSION=9` set.
|
|
12
15
|
*
|
|
13
|
-
* `whenUnknown` is used for a run with no recorded version. It defaults to
|
|
14
|
-
*
|
|
16
|
+
* `whenUnknown` is used for a run with no recorded version. It defaults to the
|
|
17
|
+
* version this SDK mints by default (`SPEC_VERSION_CURRENT`); callers that
|
|
18
|
+
* treat such a run as legacy pass `SPEC_VERSION_LEGACY`.
|
|
15
19
|
*/
|
|
16
20
|
export function specVersionForRunWrite(runSpecVersion, whenUnknown = SPEC_VERSION_CURRENT) {
|
|
17
|
-
return Math.min(
|
|
21
|
+
return Math.min(SPEC_VERSION_MAX_SUPPORTED, runSpecVersion ?? whenUnknown);
|
|
18
22
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVuLXNwZWMtdmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydW50aW1lL3J1bi1zcGVjLXZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLG9CQUFvQixFQUNwQiwwQkFBMEIsR0FDM0IsTUFBTSw4QkFBOEIsQ0FBQztBQUV0Qzs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCxNQUFNLFVBQVUsc0JBQXNCLENBQ3BDLGNBQWtDLEVBQ2xDLGNBQXNCLG9CQUFvQjtJQUUxQyxPQUFPL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XMgc3BlYyA4IHJ1bnMgc3RpbGwgc3RhbXBzIDkgb24gdGhlIGBob29rX3JlY2VpdmVkYCxcbiAqIGBydW5fY2FuY2VsbGVkYCBhbmQgd2FrZSBldmVudHMgaXQgd3JpdGVzIHRvIGEgc3BlYyA5IHJ1biwgd2hpY2ggbWF5IGhhdmVcbiAqIGJlZW4gY3JlYXRlZCBieSBhIHByb2Nlc3Mgd2l0aCBgV09SS0ZMT1dfU1BFQ19WRVJTSU9OPTlgIHNldC5cbiAqXG4gKiBgd2hlblVua25vd25gIGlzIHVzZWQgZm9yIGEgcnVuIHdpdGggbm8gcmVjb3JkZWQgdmVyc2lvbi4gSXQgZGVmYXVsdHMgdG8gdGhlXG4gKiB2ZXJzaW9uIHRoaXMgU0RLIG1pbnRzIGJ5IGRlZmF1bHQgKGBTUEVDX1ZFUlNJT05fQ1VSUkVOVGApOyBjYWxsZXJzIHRoYXRcbiAqIHRyZWF0IHN1Y2ggYSBydW4gYXMgbGVnYWN5IHBhc3MgYFNQRUNfVkVSU0lPTl9MRUdBQ1lgLlxuICovXG5leHBvcnQgZnVuY3Rpb24gc3BlY1ZlcnNpb25Gb3JSdW5Xcml0ZShcbiAgcnVuU3BlY1ZlcnNpb246IG51bWJlciB8IHVuZGVmaW5lZCxcbiAgd2hlblVua25vd246IG51bWJlciA9IFNQRUNfVkVSU0lPTl9DVVJSRU5UXG4pOiBudW1iZXIge1xuICByZXR1cm4gTWF0aC5taW4oU1BFQ19WRVJTSU9OX01BWF9TVVBQT1JURUQsIHJ1blNwZWNWZXJzaW9uID8/IHdoZW5Vbmtub3duKTtcbn1cbiJdfQ==
|
package/dist/runtime/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from '@workflow/serde';
|
|
2
|
-
import type
|
|
2
|
+
import { type WorkflowRunStatus } from '@workflow/world';
|
|
3
3
|
import { type CancelRunOptions, type StopSleepOptions, type StopSleepResult } from './runs.js';
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare function getReturnValuePollIntervalMs(): number;
|
|
@@ -93,12 +93,14 @@ export interface WorkflowRunWritableStreamOptions {
|
|
|
93
93
|
export declare class Run<TResult> {
|
|
94
94
|
#private;
|
|
95
95
|
static [WORKFLOW_SERIALIZE](instance: Run<unknown>): {
|
|
96
|
+
parentRunId?: string | undefined;
|
|
96
97
|
runId: string;
|
|
97
98
|
resilientStart: boolean;
|
|
98
99
|
};
|
|
99
100
|
static [WORKFLOW_DESERIALIZE](data: {
|
|
100
101
|
runId: string;
|
|
101
102
|
resilientStart?: boolean;
|
|
103
|
+
parentRunId?: string;
|
|
102
104
|
}): Run<unknown>;
|
|
103
105
|
/**
|
|
104
106
|
* The ID of the workflow run.
|
|
@@ -106,6 +108,7 @@ export declare class Run<TResult> {
|
|
|
106
108
|
runId: string;
|
|
107
109
|
constructor(runId: string, opts?: {
|
|
108
110
|
resilientStart?: boolean;
|
|
111
|
+
parentRunId?: string;
|
|
109
112
|
});
|
|
110
113
|
/**
|
|
111
114
|
* Interrupts pending `sleep()` calls, resuming the workflow early.
|
|
@@ -113,6 +116,9 @@ export declare class Run<TResult> {
|
|
|
113
116
|
* @param options - Optional settings to target specific sleep calls by correlation ID.
|
|
114
117
|
* If not provided, all pending sleep calls will be interrupted.
|
|
115
118
|
* @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
|
|
119
|
+
* On a single-orchestrator run it is the number of sleep calls the run's
|
|
120
|
+
* orchestrator was asked to complete, which is best-effort while an
|
|
121
|
+
* orchestrator invocation of the run is live (see `wakeUpRun`).
|
|
116
122
|
*/
|
|
117
123
|
wakeUp(options?: StopSleepOptions): Promise<StopSleepResult>;
|
|
118
124
|
/**
|
|
@@ -132,10 +138,30 @@ export declare class Run<TResult> {
|
|
|
132
138
|
*/
|
|
133
139
|
get status(): Promise<WorkflowRunStatus>;
|
|
134
140
|
/**
|
|
135
|
-
* The return value of the workflow run.
|
|
136
|
-
*
|
|
141
|
+
* The return value of the workflow run, once it completes. Rejects with
|
|
142
|
+
* `WorkflowRunFailedError` or `WorkflowRunCancelledError` if the run fails
|
|
143
|
+
* or is cancelled.
|
|
144
|
+
*
|
|
145
|
+
* Inside the workflow that started this run, the parent suspends on a system
|
|
146
|
+
* hook the run resumes when it finishes, so waiting costs no compute and
|
|
147
|
+
* resumes as soon as the run is done. Everywhere else (host code, steps,
|
|
148
|
+
* a workflow handed another run's handle) it polls until the run finishes.
|
|
137
149
|
*/
|
|
138
150
|
get returnValue(): Promise<TResult>;
|
|
151
|
+
/**
|
|
152
|
+
* The step behind {@link returnValue}: polls until the run is terminal.
|
|
153
|
+
* Use `returnValue` instead.
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
readReturnValue(): Promise<TResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Which of `runIds` have finished (completed, failed, or cancelled), in one
|
|
159
|
+
* step: the batched status read behind the child-run completion hook. A run
|
|
160
|
+
* that cannot be found is reported as finished, so the caller's
|
|
161
|
+
* `returnValue` read surfaces the not-found (or retries a resilient start).
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
static readFinishedRunIds(runIds: string[]): Promise<string[]>;
|
|
139
165
|
/**
|
|
140
166
|
* The name of the workflow.
|
|
141
167
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/runtime/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/runtime/run.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGrB,MAAM,WAAW,CAAC;AAcnB,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