@workflow/core 5.0.0-beta.5 → 5.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attribute-changes.d.ts +5 -0
- package/dist/attribute-changes.d.ts.map +1 -0
- package/dist/attribute-changes.js +25 -0
- package/dist/capabilities.d.ts +35 -2
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +74 -5
- package/dist/capture-stack.d.ts +1 -1
- package/dist/capture-stack.js +2 -2
- package/dist/class-serialization.d.ts +32 -0
- package/dist/class-serialization.d.ts.map +1 -1
- package/dist/class-serialization.js +37 -1
- package/dist/classify-error.d.ts +19 -3
- package/dist/classify-error.d.ts.map +1 -1
- package/dist/classify-error.js +98 -6
- package/dist/context-violation-error.d.ts +5 -5
- package/dist/context-violation-error.d.ts.map +1 -1
- package/dist/context-violation-error.js +8 -6
- package/dist/create-hook.d.ts +72 -7
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/define-hook.js +2 -2
- package/dist/describe-error.d.ts +7 -7
- package/dist/describe-error.d.ts.map +1 -1
- package/dist/describe-error.js +97 -12
- package/dist/encryption.d.ts +38 -4
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +96 -14
- package/dist/events-consumer.d.ts +271 -0
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +646 -42
- package/dist/flushable-stream.d.ts +56 -1
- package/dist/flushable-stream.d.ts.map +1 -1
- package/dist/flushable-stream.js +123 -11
- package/dist/global.d.ts +36 -2
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +21 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/log-format.d.ts +2 -2
- package/dist/log-format.js +7 -7
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +10 -6
- package/dist/private.d.ts +226 -9
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +626 -7
- package/dist/replay-payload-cache.d.ts +64 -0
- package/dist/replay-payload-cache.d.ts.map +1 -0
- package/dist/replay-payload-cache.js +158 -0
- package/dist/runtime/compute-instance.d.ts +13 -0
- package/dist/runtime/compute-instance.d.ts.map +1 -0
- package/dist/runtime/compute-instance.js +14 -0
- package/dist/runtime/constants.d.ts +315 -0
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +502 -16
- package/dist/runtime/count-step-started-events.d.ts +52 -0
- package/dist/runtime/count-step-started-events.d.ts.map +1 -0
- package/dist/runtime/count-step-started-events.js +72 -0
- package/dist/runtime/deployment-guard.d.ts +99 -0
- package/dist/runtime/deployment-guard.d.ts.map +1 -0
- package/dist/runtime/deployment-guard.js +154 -0
- package/dist/runtime/get-port-lazy.d.ts +15 -0
- package/dist/runtime/get-port-lazy.d.ts.map +1 -1
- package/dist/runtime/get-port-lazy.js +75 -6
- package/dist/runtime/get-world-lazy.d.ts +5 -14
- package/dist/runtime/get-world-lazy.d.ts.map +1 -1
- package/dist/runtime/get-world-lazy.js +19 -29
- package/dist/runtime/helpers.d.ts +341 -29
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +559 -57
- package/dist/runtime/quickjs-assets.generated.d.ts +14 -0
- package/dist/runtime/quickjs-assets.generated.d.ts.map +1 -0
- package/dist/runtime/quickjs-assets.generated.js +30 -0
- package/dist/runtime/quickjs-entrypoint.d.ts +136 -0
- package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/quickjs-entrypoint.js +1686 -0
- package/dist/runtime/quickjs-runtime.d.ts +244 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +2427 -0
- package/dist/runtime/quickjs-serde.d.ts +107 -0
- package/dist/runtime/quickjs-serde.d.ts.map +1 -0
- package/dist/runtime/quickjs-serde.js +2159 -0
- package/dist/runtime/replay-budget.d.ts +97 -0
- package/dist/runtime/replay-budget.d.ts.map +1 -0
- package/dist/runtime/replay-budget.js +139 -0
- package/dist/runtime/replay-recovery-reporter.d.ts +36 -0
- package/dist/runtime/replay-recovery-reporter.d.ts.map +1 -0
- package/dist/runtime/replay-recovery-reporter.js +64 -0
- package/dist/runtime/resume-hook.d.ts +91 -8
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +512 -89
- package/dist/runtime/resume-latency.d.ts +150 -0
- package/dist/runtime/resume-latency.d.ts.map +1 -0
- package/dist/runtime/resume-latency.js +155 -0
- package/dist/runtime/run-id-time.d.ts +19 -0
- package/dist/runtime/run-id-time.d.ts.map +1 -0
- package/dist/runtime/run-id-time.js +42 -0
- package/dist/runtime/run.d.ts +72 -7
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +280 -53
- package/dist/runtime/runs.d.ts +54 -3
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +126 -16
- package/dist/runtime/start.d.ts +101 -2
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +352 -61
- package/dist/runtime/step-executor.d.ts +205 -5
- package/dist/runtime/step-executor.d.ts.map +1 -1
- package/dist/runtime/step-executor.js +760 -127
- package/dist/runtime/step-latency.d.ts +220 -0
- package/dist/runtime/step-latency.d.ts.map +1 -0
- package/dist/runtime/step-latency.js +215 -0
- package/dist/runtime/step-ownership.d.ts +72 -0
- package/dist/runtime/step-ownership.d.ts.map +1 -0
- package/dist/runtime/step-ownership.js +114 -0
- package/dist/runtime/step-single-flight.d.ts +12 -0
- package/dist/runtime/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/step-single-flight.js +75 -0
- package/dist/runtime/suspension-handler.d.ts +269 -7
- package/dist/runtime/suspension-handler.d.ts.map +1 -1
- package/dist/runtime/suspension-handler.js +1253 -125
- package/dist/runtime/unserializable-step.d.ts +34 -0
- package/dist/runtime/unserializable-step.d.ts.map +1 -0
- package/dist/runtime/unserializable-step.js +52 -0
- package/dist/runtime/vm-mode.d.ts +44 -0
- package/dist/runtime/vm-mode.d.ts.map +1 -0
- package/dist/runtime/vm-mode.js +62 -0
- package/dist/runtime/vm-serde-bundle.generated.d.ts +14 -0
- package/dist/runtime/vm-serde-bundle.generated.d.ts.map +1 -0
- package/dist/runtime/vm-serde-bundle.generated.js +16 -0
- package/dist/runtime/wait-continuation.d.ts +106 -0
- package/dist/runtime/wait-continuation.d.ts.map +1 -0
- package/dist/runtime/wait-continuation.js +136 -0
- package/dist/runtime/wait-until.d.ts +18 -0
- package/dist/runtime/wait-until.d.ts.map +1 -0
- package/dist/runtime/wait-until.js +42 -0
- package/dist/runtime/world-compatibility.d.ts +32 -0
- package/dist/runtime/world-compatibility.d.ts.map +1 -0
- package/dist/runtime/world-compatibility.js +44 -0
- package/dist/runtime/world-init.d.ts +17 -42
- package/dist/runtime/world-init.d.ts.map +1 -1
- package/dist/runtime/world-init.js +18 -43
- package/dist/runtime/world.d.ts +14 -2
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +75 -19
- package/dist/runtime.d.ts +10 -6
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3741 -490
- package/dist/sealed-box.d.ts +167 -0
- package/dist/sealed-box.d.ts.map +1 -0
- package/dist/sealed-box.js +571 -0
- package/dist/serialization/client.d.ts +3 -3
- package/dist/serialization/client.d.ts.map +1 -1
- package/dist/serialization/client.js +8 -4
- package/dist/serialization/codec-devalue-vm.d.ts +16 -0
- package/dist/serialization/codec-devalue-vm.d.ts.map +1 -0
- package/dist/serialization/codec-devalue-vm.js +148 -0
- package/dist/serialization/codec-devalue.d.ts +1 -1
- package/dist/serialization/codec-devalue.d.ts.map +1 -1
- package/dist/serialization/codec-devalue.js +24 -6
- package/dist/serialization/codec.d.ts +37 -2
- package/dist/serialization/codec.d.ts.map +1 -1
- package/dist/serialization/codec.js +2 -2
- package/dist/serialization/compression.d.ts +105 -0
- package/dist/serialization/compression.d.ts.map +1 -0
- package/dist/serialization/compression.js +261 -0
- package/dist/serialization/encryption.d.ts +119 -17
- package/dist/serialization/encryption.d.ts.map +1 -1
- package/dist/serialization/encryption.js +152 -17
- package/dist/serialization/errors.d.ts +13 -0
- package/dist/serialization/errors.d.ts.map +1 -1
- package/dist/serialization/errors.js +20 -2
- package/dist/serialization/format.d.ts +6 -6
- package/dist/serialization/format.js +7 -7
- package/dist/serialization/hardened.d.ts +156 -0
- package/dist/serialization/hardened.d.ts.map +1 -0
- package/dist/serialization/hardened.js +538 -0
- package/dist/serialization/index.d.ts +10 -8
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +10 -8
- package/dist/serialization/reducers/class-vm.d.ts +20 -0
- package/dist/serialization/reducers/class-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/class-vm.js +77 -0
- package/dist/serialization/reducers/class.d.ts.map +1 -1
- package/dist/serialization/reducers/class.js +11 -6
- package/dist/serialization/reducers/common-vm.d.ts +15 -0
- package/dist/serialization/reducers/common-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/common-vm.js +616 -0
- package/dist/serialization/reducers/common.d.ts +1 -1
- package/dist/serialization/reducers/common.d.ts.map +1 -1
- package/dist/serialization/reducers/common.js +202 -62
- package/dist/serialization/reducers/step-function-vm.d.ts +44 -0
- package/dist/serialization/reducers/step-function-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/step-function-vm.js +97 -0
- package/dist/serialization/reducers/step-function.d.ts.map +1 -1
- package/dist/serialization/reducers/step-function.js +25 -9
- package/dist/serialization/step.d.ts +4 -4
- package/dist/serialization/step.d.ts.map +1 -1
- package/dist/serialization/step.js +9 -5
- package/dist/serialization/types.d.ts +80 -1
- package/dist/serialization/types.d.ts.map +1 -1
- package/dist/serialization/types.js +15 -1
- package/dist/serialization/workflow-vm.d.ts +29 -0
- package/dist/serialization/workflow-vm.d.ts.map +1 -0
- package/dist/serialization/workflow-vm.js +74 -0
- package/dist/serialization-format.d.ts +64 -8
- package/dist/serialization-format.d.ts.map +1 -1
- package/dist/serialization-format.js +225 -73
- package/dist/serialization.d.ts +262 -34
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +1879 -274
- package/dist/set-attributes.d.ts +13 -0
- package/dist/set-attributes.d.ts.map +1 -0
- package/dist/set-attributes.js +60 -0
- package/dist/source-map.d.ts +25 -0
- package/dist/source-map.d.ts.map +1 -1
- package/dist/source-map.js +154 -10
- package/dist/step/context-storage.d.ts +61 -2
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js +7 -5
- package/dist/step/writable-stream.d.ts +3 -3
- package/dist/step/writable-stream.d.ts.map +1 -1
- package/dist/step/writable-stream.js +72 -9
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +148 -27
- package/dist/symbols.d.ts +50 -0
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +51 -1
- package/dist/telemetry/semantic-conventions.d.ts +397 -2
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +297 -3
- package/dist/telemetry.d.ts +91 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +244 -17
- package/dist/test-support/orchestrator-context.d.ts +25 -0
- package/dist/test-support/orchestrator-context.d.ts.map +1 -0
- package/dist/test-support/orchestrator-context.js +101 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +23 -1
- package/dist/util.d.ts +0 -5
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +1 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -2
- package/dist/vm/index.d.ts.map +1 -1
- package/dist/vm/index.js +84 -14
- package/dist/vm/script-cache.d.ts +26 -0
- package/dist/vm/script-cache.d.ts.map +1 -0
- package/dist/vm/script-cache.js +131 -0
- package/dist/vm/uint8array-base64.js +1 -1
- package/dist/workflow/abort-controller.d.ts +2 -2
- package/dist/workflow/abort-controller.d.ts.map +1 -1
- package/dist/workflow/abort-controller.js +88 -21
- package/dist/workflow/attribute-dispatcher.d.ts +6 -0
- package/dist/workflow/attribute-dispatcher.d.ts.map +1 -0
- package/dist/workflow/attribute-dispatcher.js +45 -0
- package/dist/workflow/create-hook.d.ts.map +1 -1
- package/dist/workflow/create-hook.js +24 -3
- package/dist/workflow/get-workflow-metadata.js +2 -2
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +304 -47
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +2 -1
- package/dist/workflow/set-attributes.d.ts +68 -0
- package/dist/workflow/set-attributes.d.ts.map +1 -0
- package/dist/workflow/set-attributes.js +60 -0
- package/dist/workflow/sleep.d.ts.map +1 -1
- package/dist/workflow/sleep.js +58 -12
- package/dist/workflow/world-init-stub.d.ts +3 -3
- package/dist/workflow/world-init-stub.js +4 -4
- package/dist/workflow.d.ts +95 -3
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +895 -561
- package/docs/api-reference/create-hook.mdx +89 -10
- package/docs/api-reference/create-webhook.mdx +16 -15
- package/docs/api-reference/define-hook.mdx +35 -33
- package/docs/api-reference/fatal-error.mdx +30 -8
- package/docs/api-reference/fetch.mdx +14 -10
- package/docs/api-reference/get-step-metadata.mdx +2 -2
- package/docs/api-reference/get-workflow-metadata.mdx +3 -3
- package/docs/api-reference/get-writable.mdx +7 -7
- package/docs/api-reference/index.mdx +4 -1
- package/docs/api-reference/retryable-error.mdx +1 -1
- package/docs/api-reference/set-attributes.mdx +61 -0
- package/docs/api-reference/sleep.mdx +4 -4
- package/docs/foundations/cancellation.mdx +31 -32
- package/docs/foundations/errors-and-retries.mdx +42 -11
- package/docs/foundations/hooks.mdx +64 -35
- package/docs/foundations/idempotency.mdx +244 -12
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +2 -1
- package/docs/foundations/serialization.mdx +21 -22
- package/docs/foundations/starting-workflows.mdx +106 -30
- package/docs/foundations/streaming.mdx +107 -59
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/how-it-works/cancellation.mdx +63 -63
- package/docs/how-it-works/code-transform.mdx +83 -67
- package/docs/how-it-works/encryption.mdx +30 -26
- package/docs/how-it-works/event-sourcing.mdx +98 -34
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/understanding-directives.mdx +22 -22
- package/package.json +24 -15
- package/dist/runtime/step-handler.d.ts +0 -2
- package/dist/runtime/step-handler.d.ts.map +0 -1
- package/dist/runtime/step-handler.js +0 -776
|
@@ -1,21 +1,221 @@
|
|
|
1
|
-
import type { World } from '@workflow/world';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Event, SerializedData, StartedStep, World } from '@workflow/world';
|
|
2
|
+
import type { PayloadKey } from '../serialization/encryption.js';
|
|
3
|
+
import { type SlotSnapshotParams } from './helpers.js';
|
|
4
|
+
import { ReplayRecoveryReporter } from './replay-recovery-reporter.js';
|
|
5
|
+
import { type ResumeTtrTracking } from './resume-latency.js';
|
|
6
|
+
import { type StepLatencyTracking } from './step-latency.js';
|
|
7
|
+
export declare const DEFAULT_STEP_MAX_RETRIES = 3;
|
|
3
8
|
export interface StepExecutorParams {
|
|
4
9
|
world: World;
|
|
5
10
|
workflowRunId: string;
|
|
11
|
+
/** Deployment that owns the workflow run, for forwarded writable streams. */
|
|
12
|
+
workflowDeploymentId?: string;
|
|
6
13
|
workflowName: string;
|
|
7
14
|
workflowStartedAt: number;
|
|
15
|
+
/** Request ID of the invocation executing this step, when provided by its queue. */
|
|
16
|
+
requestId?: string;
|
|
17
|
+
/** Root run id of this run's lineage, carried into the step context. */
|
|
18
|
+
rootRunId?: string;
|
|
8
19
|
stepId: string;
|
|
9
20
|
stepName: string;
|
|
10
|
-
encryptionKey?:
|
|
21
|
+
encryptionKey?: PayloadKey;
|
|
22
|
+
/**
|
|
23
|
+
* The workflow run's specVersion, used to gate payload compression.
|
|
24
|
+
* Step outputs/errors are only compressed when the run is marked as
|
|
25
|
+
* compression-capable (specVersion >= 5).
|
|
26
|
+
*/
|
|
27
|
+
runSpecVersion?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Lazy step start: the already-dehydrated step input. When provided, the
|
|
30
|
+
* `step_started` event carries this input so the world creates the step on
|
|
31
|
+
* the fly (no separate `step_created` round-trip). Set by the owned-inline
|
|
32
|
+
* path for the step whose `step_created` the suspension handler deferred.
|
|
33
|
+
* The world's atomic create-claim is the exactly-one-owner gate: losing it
|
|
34
|
+
* surfaces as `EntityConflictError` → `{ type: 'skipped' }`, so a handler
|
|
35
|
+
* that did not win the create never runs the body. Omitted on every other
|
|
36
|
+
* path, where the step already has a `step_created` and `step_started`
|
|
37
|
+
* carries no payload (the legacy contract).
|
|
38
|
+
*/
|
|
39
|
+
lazyStepInput?: SerializedData;
|
|
40
|
+
/**
|
|
41
|
+
* Pre-claimed inline start: the suspension handler committed (or lost) this
|
|
42
|
+
* step's `step_created` + `step_started` pair inside its batched fan-out
|
|
43
|
+
* write, so the start this executor would otherwise send has already been
|
|
44
|
+
* decided. `owned: false` returns `{ type: 'skipped' }` before any write,
|
|
45
|
+
* the same outcome as losing the lazy claim's atomic create. `owned: true`
|
|
46
|
+
* skips both start paths (no start write at all) and runs the body against
|
|
47
|
+
* the claimed step. Mutually exclusive with `lazyStepInput`: the input
|
|
48
|
+
* already rode the pair's `step_created`, and the claimed step carries it.
|
|
49
|
+
*/
|
|
50
|
+
preclaimedStart?: PreclaimedInlineStart;
|
|
51
|
+
/**
|
|
52
|
+
* Inline step ownership: the queue message ID of the invocation this
|
|
53
|
+
* executeStep call runs in (from the queue handler's meta). When set, the
|
|
54
|
+
* `step_started` this call sends is stamped with it: on the lazy paths
|
|
55
|
+
* (where `lazyStepInput` is present) and on the owned-recovery
|
|
56
|
+
* payload-less start (where it is not; the re-stamp keeps a recovered
|
|
57
|
+
* step readable as owned by this message, since ownership derives from
|
|
58
|
+
* the LATEST start, so a recovery start is never bare). Wake
|
|
59
|
+
* replays that observe an actively-owned step suppress the immediate
|
|
60
|
+
* requeue and enqueue a delayed backstop instead. Omitted on the
|
|
61
|
+
* background-step path, whose bare start intentionally clears ownership
|
|
62
|
+
* (the step is queue-owned from that point).
|
|
63
|
+
*/
|
|
64
|
+
ownerMessageId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Inline-delta optimization (opt-in). When provided, the cursor of the
|
|
67
|
+
* event log as observed by the caller *before* this step's events were
|
|
68
|
+
* written. It is threaded into the step-terminal `events.create` so a
|
|
69
|
+
* supporting World can return the delta of events written since (see
|
|
70
|
+
* {@link import('@workflow/world').CreateEventParams.sinceCursor}).
|
|
71
|
+
* Only set this when `correlationId`-based ownership guarantees this
|
|
72
|
+
* handler is the sole inline writer for the run on this iteration.
|
|
73
|
+
*/
|
|
74
|
+
inlineDeltaSinceCursor?: string;
|
|
75
|
+
/**
|
|
76
|
+
* How much of the run's log the caller's replay had loaded when it scheduled
|
|
77
|
+
* this step, as the highest slot that log occupies. Seeds the snapshot every
|
|
78
|
+
* write this executor makes carries; each committed event advances it to its
|
|
79
|
+
* own slot, so a later write never names a position that predates an earlier
|
|
80
|
+
* one from the same step.
|
|
81
|
+
*
|
|
82
|
+
* It matters most on the lazy inline path, where the `step_started` claim is
|
|
83
|
+
* the step's FIRST durable write (its `step_created` is deferred): without a
|
|
84
|
+
* seed the claim would name no position at all, and a replay working from a
|
|
85
|
+
* stale view could claim (and then commit) a step scheduled without
|
|
86
|
+
* observing an event it never loaded.
|
|
87
|
+
*
|
|
88
|
+
* A World that fences rejects a stale claim with `PreconditionFailedError`
|
|
89
|
+
* (412); executeStep does NOT translate that rejection (re-claiming in place
|
|
90
|
+
* would still commit the stale schedule), so it propagates for the caller to
|
|
91
|
+
* abandon the batch and restart its replay. Undefined for a caller with
|
|
92
|
+
* nothing loaded.
|
|
93
|
+
*/
|
|
94
|
+
slotSnapshot?: SlotSnapshotParams;
|
|
95
|
+
/**
|
|
96
|
+
* Suppress optimistic inline start for this step regardless of
|
|
97
|
+
* `WORKFLOW_OPTIMISTIC_INLINE_START` / `forceOptimisticStart`: take the
|
|
98
|
+
* await-then-run path so the body only runs after the `step_started` claim
|
|
99
|
+
* succeeds. Set by the runtime for guard-enforced batches that are
|
|
100
|
+
* stale-sensitive (an open hook means an out-of-band event can make the
|
|
101
|
+
* scheduling view stale): the guard's 412 fence can reject a stale claim's
|
|
102
|
+
* durable writes, but it cannot un-run a body that optimistic start began
|
|
103
|
+
* before the claim settled; awaiting the claim extends the fence to user
|
|
104
|
+
* code. Wins over `forceOptimisticStart` and the env flag.
|
|
105
|
+
*/
|
|
106
|
+
suppressOptimisticStart?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Force optimistic inline start regardless of
|
|
109
|
+
* `WORKFLOW_OPTIMISTIC_INLINE_START`. Set by turbo mode on the first delivery
|
|
110
|
+
* of the first invocation, where forcing it is safe: there is no concurrent
|
|
111
|
+
* peer handler to race the create-claim, so the body runs exactly once. Only
|
|
112
|
+
* meaningful together with `lazyStepInput` (a brand-new lazy step).
|
|
113
|
+
*/
|
|
114
|
+
forceOptimisticStart?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Turbo mode only: a promise that resolves once the backgrounded
|
|
117
|
+
* `run_started` has landed. When set, the lazy/optimistic `step_started` is
|
|
118
|
+
* chained on it so the step is never created before its run exists. The body
|
|
119
|
+
* still runs immediately against locally-synthesized state (only the network
|
|
120
|
+
* write waits), so the `run_started` round-trip overlaps the body. `undefined`
|
|
121
|
+
* outside turbo, where `run_started` was already awaited up front.
|
|
122
|
+
*/
|
|
123
|
+
runReadyBarrier?: Promise<unknown>;
|
|
124
|
+
/**
|
|
125
|
+
* Latency telemetry (TTFS / STSO): eligibility and anchor timestamps decided
|
|
126
|
+
* by the orchestrator. When set, this executor computes the final values
|
|
127
|
+
* against the wall clock taken immediately before user code runs and
|
|
128
|
+
* attaches them to the step's terminal event. Set only for the first step of
|
|
129
|
+
* an inline batch, and only on first-attempt executions that qualify; see
|
|
130
|
+
* runtime/step-latency.ts.
|
|
131
|
+
*/
|
|
132
|
+
latencyTracking?: StepLatencyTracking;
|
|
133
|
+
/**
|
|
134
|
+
* Hook-resume TTR telemetry: the boundaries of a hook resumption whose next
|
|
135
|
+
* durable step is the one this call is about to execute. When set, the
|
|
136
|
+
* executor closes the measurement against the `step_started` claim and the
|
|
137
|
+
* wall clock taken immediately before user code, and attaches the total plus
|
|
138
|
+
* its phase breakdown to this step's `step.execute` span. Set by the runtime
|
|
139
|
+
* for exactly one step per resumption; see runtime/resume-latency.ts.
|
|
140
|
+
*/
|
|
141
|
+
resumeTracking?: ResumeTtrTracking;
|
|
142
|
+
/**
|
|
143
|
+
* Authoritative attempt number for this execution, used to bound retries
|
|
144
|
+
* against `maxRetries` BEFORE the body runs. To also catch
|
|
145
|
+
* step timeouts (which we can't have catch handlers for), we determine
|
|
146
|
+
* the attempt count based as follows:
|
|
147
|
+
* - Inline (combined handler): the number of `step_started` events already
|
|
148
|
+
* in the event log for this step, plus one for the attempt about to run.
|
|
149
|
+
* - Background (queue-dispatched): the queue delivery count
|
|
150
|
+
* (`metadata.attempt`), which increments on every redelivery.
|
|
151
|
+
*/
|
|
152
|
+
authoritativeAttempt?: number;
|
|
153
|
+
/** One-shot recovery telemetry activated by the orchestrator replay. */
|
|
154
|
+
replayRecoveryReporter?: ReplayRecoveryReporter;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The settled outcome of a `step_created` + `step_started` pair the
|
|
158
|
+
* suspension handler folded into its batched fan-out write (see
|
|
159
|
+
* `SuspensionHandlerResult.inlineClaims`). Handed to executeStep as
|
|
160
|
+
* {@link StepExecutorParams.preclaimedStart} so the executor runs (or skips)
|
|
161
|
+
* the body off the batch's verdict instead of sending a start of its own.
|
|
162
|
+
*/
|
|
163
|
+
export type PreclaimedInlineStart = {
|
|
164
|
+
/** The pair committed: this execution owns the step and runs the body. */
|
|
165
|
+
owned: true;
|
|
166
|
+
/**
|
|
167
|
+
* The started step entity from the batch result, with the locally
|
|
168
|
+
* dehydrated input attached by the suspension handler (batch responses
|
|
169
|
+
* return refs lazily; the body's hydration wants the same bytes the
|
|
170
|
+
* pair's `step_created` carried).
|
|
171
|
+
*/
|
|
172
|
+
step: StartedStep;
|
|
173
|
+
/**
|
|
174
|
+
* `Date.now()` taken right before the batch POST that carried the pair:
|
|
175
|
+
* the claim's "start POST sent" instant, anchoring RSFS exactly like
|
|
176
|
+
* the lazy claim's own POST would.
|
|
177
|
+
*/
|
|
178
|
+
batchPostSentAtMs?: number;
|
|
179
|
+
/**
|
|
180
|
+
* `Date.now()` taken right after that batch POST returned: the
|
|
181
|
+
* claim's completion instant (T6 of the hook-resume TTR window).
|
|
182
|
+
*/
|
|
183
|
+
claimCompletedAtMs?: number;
|
|
184
|
+
} | {
|
|
185
|
+
/**
|
|
186
|
+
* The pair lost its atomic create-claim (per-event 409): a concurrent
|
|
187
|
+
* writer owns the step, so the body must not run here.
|
|
188
|
+
*/
|
|
189
|
+
owned: false;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Inline-delta returned by a step-terminal write when the caller passed
|
|
193
|
+
* {@link StepExecutorParams.inlineDeltaSinceCursor} and the World supports
|
|
194
|
+
* the optimization. `events` are the events written strictly after that
|
|
195
|
+
* cursor (this step's events plus anything interleaved in-band), `cursor`
|
|
196
|
+
* is the position past the last one, and `hasMore` signals a further page
|
|
197
|
+
* (the caller then falls back to a full incremental fetch). Absent when
|
|
198
|
+
* the World did not return a delta.
|
|
199
|
+
*/
|
|
200
|
+
export interface InlineEventDelta {
|
|
201
|
+
events: Event[];
|
|
202
|
+
cursor: string | null;
|
|
203
|
+
hasMore: boolean;
|
|
11
204
|
}
|
|
12
205
|
/**
|
|
13
206
|
* Result of a step execution attempt. The caller decides what to do
|
|
14
207
|
* based on the result type (e.g., queue workflow continuation, replay inline, etc.).
|
|
208
|
+
*
|
|
209
|
+
* `inlineDelta` is attached to a `completed` result when the caller
|
|
210
|
+
* requested it via {@link StepExecutorParams.inlineDeltaSinceCursor} and
|
|
211
|
+
* the World returned one. Step failures are rare and not the inline
|
|
212
|
+
* optimization's target, so the `failed` path leaves it to the normal
|
|
213
|
+
* incremental fetch.
|
|
15
214
|
*/
|
|
16
215
|
export type StepExecutionResult = {
|
|
17
216
|
type: 'completed';
|
|
18
217
|
hasPendingOps?: boolean;
|
|
218
|
+
inlineDelta?: InlineEventDelta;
|
|
19
219
|
} | {
|
|
20
220
|
type: 'failed';
|
|
21
221
|
} | {
|
|
@@ -33,8 +233,8 @@ export type StepExecutionResult = {
|
|
|
33
233
|
* Executes a single step: creates step_started event, hydrates input,
|
|
34
234
|
* runs the step function, creates step_completed/step_failed/step_retrying events.
|
|
35
235
|
*
|
|
36
|
-
* Does NOT queue workflow continuation messages
|
|
37
|
-
* Used by
|
|
236
|
+
* Does NOT queue workflow continuation messages; the caller decides what to do next.
|
|
237
|
+
* Used by the combined workflow handler for step execution.
|
|
38
238
|
*/
|
|
39
239
|
export declare function executeStep(params: StepExecutorParams): Promise<StepExecutionResult>;
|
|
40
240
|
//# sourceMappingURL=step-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/step-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/step-executor.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAGV,KAAK,EAEL,cAAc,EACd,WAAW,EACX,KAAK,EACN,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAwBjE,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAEL,KAAK,i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