@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,217 @@
|
|
|
1
|
+
import type { CreateEventParams, CreateEventRequest, EventResult, SerializedData, World } from '@workflow/world';
|
|
2
|
+
import type { PayloadKey } from '../../serialization/encryption.js';
|
|
3
|
+
import { type ResumeTtrTracking } from '../resume-latency.js';
|
|
4
|
+
import { type StepLatencyTracking } from '../step-latency.js';
|
|
5
|
+
/**
|
|
6
|
+
* Whether a step's body may start before its `step_started` is durable: on
|
|
7
|
+
* turbo's optimistic start, and under run-ahead's speculative creation. A
|
|
8
|
+
* step that allows retries (`maxRetries > 0`, the default) is taken to be
|
|
9
|
+
* idempotent and to survive running again after a lost write. One declared
|
|
10
|
+
* with `maxRetries: 0` is not: its body starts only once its start has
|
|
11
|
+
* committed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mayRunBeforeItsStart(stepName: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Writes one step event for the executor. The orchestrator passes its
|
|
16
|
+
* in-band writer (inline steps are in-band, and fenced); a background step's
|
|
17
|
+
* queue handler passes a plain out-of-band writer.
|
|
18
|
+
*/
|
|
19
|
+
export type StepEventWriter = <T extends CreateEventRequest>(data: T, params?: CreateEventParams) => Promise<EventResult>;
|
|
20
|
+
/** A `step_started` the caller wrote for this attempt. */
|
|
21
|
+
export interface CallerStart {
|
|
22
|
+
startedAt: Date;
|
|
23
|
+
/** `Date.now()` right before the write was sent. */
|
|
24
|
+
postSentAtMs?: number;
|
|
25
|
+
/** `Date.now()` once it returned. */
|
|
26
|
+
completedAtMs?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface StepExecutorParams {
|
|
29
|
+
world: World;
|
|
30
|
+
/** Writes this step's events. See {@link StepEventWriter}. */
|
|
31
|
+
createEvent: StepEventWriter;
|
|
32
|
+
workflowRunId: string;
|
|
33
|
+
/** Deployment that owns the workflow run, for forwarded writable streams. */
|
|
34
|
+
workflowDeploymentId?: string;
|
|
35
|
+
workflowName: string;
|
|
36
|
+
workflowStartedAt: number;
|
|
37
|
+
/** Request ID of the invocation executing this step, when provided by its queue. */
|
|
38
|
+
requestId?: string;
|
|
39
|
+
/** Root run id of this run's lineage, carried into the step context. */
|
|
40
|
+
rootRunId?: string;
|
|
41
|
+
stepId: string;
|
|
42
|
+
stepName: string;
|
|
43
|
+
encryptionKey?: PayloadKey;
|
|
44
|
+
/**
|
|
45
|
+
* The workflow run's specVersion, used to gate payload compression.
|
|
46
|
+
* Step outputs/errors are only compressed when the run is marked as
|
|
47
|
+
* compression-capable (specVersion >= 5).
|
|
48
|
+
*/
|
|
49
|
+
runSpecVersion?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The attempt this execution is. The caller decides it: the queue message's
|
|
52
|
+
* attempt on a first delivery, the count of `step_started` events plus one
|
|
53
|
+
* after a log read, or the orchestrator's own count for an inline step.
|
|
54
|
+
*/
|
|
55
|
+
attempt: number;
|
|
56
|
+
/**
|
|
57
|
+
* When the step's first attempt started, for a retry. The step context's
|
|
58
|
+
* `stepStartedAt` is the step's first start, not this attempt's.
|
|
59
|
+
*/
|
|
60
|
+
firstStartedAt?: Date;
|
|
61
|
+
/** The step's serialized input, as written on its creation. */
|
|
62
|
+
input: SerializedData;
|
|
63
|
+
/**
|
|
64
|
+
* Epoch ms of the step's `step_created`, for a background step started by
|
|
65
|
+
* its own message. Passed on attempt 1's `step_started` as
|
|
66
|
+
* `CreateEventParams.stepCreatedAt`, and on no other write.
|
|
67
|
+
*/
|
|
68
|
+
stepCreatedAt?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Set when the caller already wrote this attempt's `step_started` (an
|
|
71
|
+
* inline step, created by that start). The executor then writes no start
|
|
72
|
+
* of its own.
|
|
73
|
+
*/
|
|
74
|
+
started?: CallerStart;
|
|
75
|
+
/**
|
|
76
|
+
* The World's refusal of the `step_started` the caller wrote for this
|
|
77
|
+
* attempt (an inline step's creation-bearing start, refused for a throttle
|
|
78
|
+
* or a finished run). Acted on as a refusal of the executor's own start;
|
|
79
|
+
* the executor writes no start.
|
|
80
|
+
*/
|
|
81
|
+
startRefusal?: unknown;
|
|
82
|
+
/** Params for the outcome write (`step_completed` / `step_failed`). */
|
|
83
|
+
terminalEventParams?: CreateEventParams;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a retry at `retryAtMs` would land after the step's queue message
|
|
86
|
+
* expires. The step is then failed instead of retried. For an inline step
|
|
87
|
+
* the message is the one its retry is about to be sent on, so the check is
|
|
88
|
+
* measured from now.
|
|
89
|
+
*/
|
|
90
|
+
retryOutlivesMessage?: (retryAtMs: number) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Called right before user code runs. The orchestrator throws from it when
|
|
93
|
+
* its in-band writer has stopped, so a superseded orchestrator never starts
|
|
94
|
+
* a body.
|
|
95
|
+
*/
|
|
96
|
+
beforeBody?: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Start the body before this attempt's `step_started` commits (optimistic
|
|
99
|
+
* start), for a step that allows retries (see {@link mayRunBeforeItsStart}).
|
|
100
|
+
* Set by turbo mode for the inline steps of a run's first delivery, where
|
|
101
|
+
* no other orchestrator of the run can exist yet, so the start cannot be
|
|
102
|
+
* refused by the in-band fence after the body ran; under run-ahead; and,
|
|
103
|
+
* only with the opt-in `WORKFLOW_OPTIMISTIC_BACKGROUND_START`, by a
|
|
104
|
+
* background step's plain first delivery, whose start is out-of-band and
|
|
105
|
+
* fence-free. The `step_started` write still goes out, after
|
|
106
|
+
* {@link runReadyBarrier} and {@link startAfter}, and the outcome write
|
|
107
|
+
* waits for it: if the start fails, the body's outcome is discarded and the
|
|
108
|
+
* start's error (or its mapped result: throttled, gone) is what the caller
|
|
109
|
+
* sees. An explicit `WORKFLOW_OPTIMISTIC_INLINE_START=0` wins and takes the
|
|
110
|
+
* awaited path.
|
|
111
|
+
*/
|
|
112
|
+
forceOptimisticStart?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Turbo mode only: settles once the backgrounded `run_started` has
|
|
115
|
+
* landed (rejects if it failed). This attempt's `step_started` is sent only
|
|
116
|
+
* after it, on both the optimistic and the awaited path, and an optimistic
|
|
117
|
+
* body's stream and attribute writes wait for it too, so nothing this step
|
|
118
|
+
* writes reaches the World before the run's start. `undefined` outside
|
|
119
|
+
* turbo, where `run_started` was already awaited.
|
|
120
|
+
*/
|
|
121
|
+
runReadyBarrier?: Promise<unknown>;
|
|
122
|
+
/**
|
|
123
|
+
* Settles once this step's creation has committed (rejects if it failed).
|
|
124
|
+
* Set when the caller wrote the creation without waiting for it (turbo's
|
|
125
|
+
* optimistic inline start). Resolves with the start when the creation was
|
|
126
|
+
* this attempt's `step_started` (an inline step); otherwise the executor
|
|
127
|
+
* sends `step_started` after it. A failure is the start's failure.
|
|
128
|
+
*/
|
|
129
|
+
startAfter?: Promise<CallerStart | undefined | void>;
|
|
130
|
+
/**
|
|
131
|
+
* Latency telemetry (TTFS / STSO): eligibility and anchor timestamps decided
|
|
132
|
+
* by the orchestrator. See runtime/step-latency.ts.
|
|
133
|
+
*/
|
|
134
|
+
latencyTracking?: StepLatencyTracking;
|
|
135
|
+
/**
|
|
136
|
+
* Hook-resume TTR telemetry for the step that follows a resumption. See
|
|
137
|
+
* runtime/resume-latency.ts.
|
|
138
|
+
*/
|
|
139
|
+
resumeTracking?: ResumeTtrTracking;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Result of a step execution attempt. The caller decides what happens next
|
|
143
|
+
* (wake the orchestrator, redeliver the message, continue the replay).
|
|
144
|
+
*
|
|
145
|
+
* `result` is the committed outcome write, so the orchestrator can consume
|
|
146
|
+
* its own resolving event only after the commit (see
|
|
147
|
+
* `orchestrator/consume-after-commit.ts`).
|
|
148
|
+
*/
|
|
149
|
+
export type StepExecutionResult = {
|
|
150
|
+
type: 'completed';
|
|
151
|
+
hasPendingOps?: boolean;
|
|
152
|
+
result: EventResult;
|
|
153
|
+
} | {
|
|
154
|
+
type: 'failed';
|
|
155
|
+
result: EventResult;
|
|
156
|
+
} | {
|
|
157
|
+
type: 'retry';
|
|
158
|
+
timeoutSeconds: number;
|
|
159
|
+
retryAt: Date;
|
|
160
|
+
result: EventResult;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'gone';
|
|
163
|
+
} | {
|
|
164
|
+
type: 'throttled';
|
|
165
|
+
timeoutSeconds: number;
|
|
166
|
+
};
|
|
167
|
+
/** Message of the `step_failed` written when a step exhausts its retries. */
|
|
168
|
+
export declare function exceededMaxRetriesMessage(stepName: string, maxRetries: number): string;
|
|
169
|
+
/**
|
|
170
|
+
* Writes `step_failed` for a step whose next attempt would exceed its retry
|
|
171
|
+
* budget, without running the body. Used when the log shows the step already
|
|
172
|
+
* started `maxRetries + 1` times, including a `maxRetries: 0` step that is
|
|
173
|
+
* redelivered after its single start.
|
|
174
|
+
*/
|
|
175
|
+
export declare function failStepForExhaustedRetries(params: {
|
|
176
|
+
createEvent: StepEventWriter;
|
|
177
|
+
workflowRunId: string;
|
|
178
|
+
stepId: string;
|
|
179
|
+
stepName: string;
|
|
180
|
+
attempt: number;
|
|
181
|
+
maxRetries: number;
|
|
182
|
+
encryptionKey: PayloadKey | undefined;
|
|
183
|
+
runSpecVersion?: number;
|
|
184
|
+
}): Promise<StepExecutionResult>;
|
|
185
|
+
/**
|
|
186
|
+
* Writes `step_failed` for a step whose message was delivered past the
|
|
187
|
+
* delivery cap (`WORKFLOW_MAX_QUEUE_DELIVERIES`) without any delivery
|
|
188
|
+
* getting the step started (see `stepDeliveryStalled`), so the workflow sees
|
|
189
|
+
* a failure it can catch instead of a step that never ends. The error is a
|
|
190
|
+
* `FatalError` whose message names `MAX_DELIVERIES_EXCEEDED`.
|
|
191
|
+
*/
|
|
192
|
+
export declare function failStepForExhaustedDeliveries(params: {
|
|
193
|
+
createEvent: StepEventWriter;
|
|
194
|
+
workflowRunId: string;
|
|
195
|
+
stepId: string;
|
|
196
|
+
stepName: string;
|
|
197
|
+
attempt: number;
|
|
198
|
+
deliveries: number;
|
|
199
|
+
maxDeliveries: number;
|
|
200
|
+
encryptionKey: PayloadKey | undefined;
|
|
201
|
+
runSpecVersion?: number;
|
|
202
|
+
}): Promise<StepExecutionResult>;
|
|
203
|
+
/** The message of a step failed by {@link failStepForExhaustedDeliveries}. */
|
|
204
|
+
export declare function exceededMaxDeliveriesMessage(stepName: string, deliveries: number, maxDeliveries: number): string;
|
|
205
|
+
/**
|
|
206
|
+
* Executes one attempt of a step: writes `step_started` (unless the caller
|
|
207
|
+
* already did), hydrates the input, runs the step function, and writes
|
|
208
|
+
* exactly one of `step_completed`, `step_failed` or `step_retrying`.
|
|
209
|
+
*
|
|
210
|
+
* It decides nothing about ownership. The caller already established that
|
|
211
|
+
* this invocation owns the attempt (an inline step in its orchestrator, or
|
|
212
|
+
* the delivery of the step's own message after the log check). No refusal
|
|
213
|
+
* from the World is read as "someone else did it": a refusal propagates, and
|
|
214
|
+
* the queue's redelivery re-checks the log.
|
|
215
|
+
*/
|
|
216
|
+
export declare function executeStep(params: StepExecutorParams): Promise<StepExecutionResult>;
|
|
217
|
+
//# sourceMappingURL=step-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../../src/runtime/spec9/step-executor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,KAAK,EACN,MAAM,iBAAiB,CAAC;AASzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAyBpE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAQ5B;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,SAAS,kBAAkB,EACzD,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,iBAAiB,KACvB,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,8DAA8D;IAC9D,WAAW,EAAE,eAAe,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM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