@workflow/core 5.0.0-beta.4 → 5.0.0-beta.40
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 +7 -0
- package/dist/attribute-changes.d.ts.map +1 -0
- package/dist/attribute-changes.js +25 -0
- package/dist/capabilities.d.ts +33 -1
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +71 -4
- package/dist/capture-stack.d.ts +16 -0
- package/dist/capture-stack.d.ts.map +1 -0
- package/dist/capture-stack.js +21 -0
- 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 +26 -3
- package/dist/classify-error.d.ts.map +1 -1
- package/dist/classify-error.js +109 -6
- package/dist/context-errors.d.ts +27 -0
- package/dist/context-errors.d.ts.map +1 -0
- package/dist/context-errors.js +101 -0
- package/dist/context-violation-error.d.ts +97 -0
- package/dist/context-violation-error.d.ts.map +1 -0
- package/dist/context-violation-error.js +149 -0
- package/dist/correlation-id.d.ts +109 -0
- package/dist/correlation-id.d.ts.map +1 -0
- package/dist/correlation-id.js +139 -0
- package/dist/create-hook.d.ts +62 -4
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +4 -3
- package/dist/define-hook.d.ts.map +1 -1
- package/dist/define-hook.js +20 -5
- package/dist/describe-error.d.ts +70 -0
- package/dist/describe-error.d.ts.map +1 -0
- package/dist/describe-error.js +189 -0
- package/dist/encryption.d.ts +37 -3
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +97 -31
- package/dist/events-consumer.d.ts +26 -1
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +105 -18
- package/dist/flushable-stream.d.ts +65 -10
- package/dist/flushable-stream.d.ts.map +1 -1
- package/dist/flushable-stream.js +131 -18
- package/dist/global.d.ts +37 -1
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +21 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/log-format.d.ts +25 -0
- package/dist/log-format.d.ts.map +1 -0
- package/dist/log-format.js +250 -0
- package/dist/logger.d.ts +29 -30
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +82 -32
- package/dist/private.d.ts +178 -9
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +273 -9
- package/dist/replay-payload-cache.d.ts +68 -0
- package/dist/replay-payload-cache.d.ts.map +1 -0
- package/dist/replay-payload-cache.js +160 -0
- package/dist/runtime/compute-instance.d.ts +12 -0
- package/dist/runtime/compute-instance.d.ts.map +1 -0
- package/dist/runtime/compute-instance.js +13 -0
- package/dist/runtime/constants.d.ts +237 -0
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +405 -15
- 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 +25 -0
- package/dist/runtime/get-port-lazy.d.ts.map +1 -0
- package/dist/runtime/get-port-lazy.js +92 -0
- package/dist/runtime/get-world-lazy.d.ts +23 -0
- package/dist/runtime/get-world-lazy.d.ts.map +1 -0
- package/dist/runtime/get-world-lazy.js +46 -0
- package/dist/runtime/helpers.d.ts +219 -10
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +414 -40
- 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 +124 -0
- package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/quickjs-entrypoint.js +1429 -0
- package/dist/runtime/quickjs-runtime.d.ts +193 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +1944 -0
- package/dist/runtime/replay-budget.d.ts +98 -0
- package/dist/runtime/replay-budget.d.ts.map +1 -0
- package/dist/runtime/replay-budget.js +192 -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 +27 -4
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +448 -76
- 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 +8 -2
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +62 -15
- package/dist/runtime/runs.d.ts +54 -3
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +117 -10
- package/dist/runtime/start.d.ts +70 -1
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +312 -54
- package/dist/runtime/step-executor.d.ts +177 -0
- package/dist/runtime/step-executor.d.ts.map +1 -0
- package/dist/runtime/step-executor.js +949 -0
- package/dist/runtime/step-latency.d.ts +197 -0
- package/dist/runtime/step-latency.d.ts.map +1 -0
- package/dist/runtime/step-latency.js +207 -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 +69 -0
- package/dist/runtime/suspension-handler.d.ts +102 -7
- package/dist/runtime/suspension-handler.d.ts.map +1 -1
- package/dist/runtime/suspension-handler.js +439 -140
- 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 +84 -0
- package/dist/runtime/wait-continuation.d.ts.map +1 -0
- package/dist/runtime/wait-continuation.js +105 -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 +5 -0
- package/dist/runtime/world-compatibility.d.ts.map +1 -0
- package/dist/runtime/world-compatibility.js +12 -0
- package/dist/runtime/world-init.d.ts +50 -0
- package/dist/runtime/world-init.d.ts.map +1 -0
- package/dist/runtime/world-init.js +50 -0
- package/dist/runtime/world.d.ts +14 -2
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +101 -26
- package/dist/runtime.d.ts +17 -12
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3078 -327
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +1 -1
- 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 +17 -0
- package/dist/serialization/client.d.ts.map +1 -0
- package/dist/serialization/client.js +48 -0
- package/dist/serialization/codec-devalue-vm.d.ts +9 -0
- package/dist/serialization/codec-devalue-vm.d.ts.map +1 -0
- package/dist/serialization/codec-devalue-vm.js +137 -0
- package/dist/serialization/codec-devalue.d.ts +14 -0
- package/dist/serialization/codec-devalue.d.ts.map +1 -0
- package/dist/serialization/codec-devalue.js +105 -0
- package/dist/serialization/codec.d.ts +125 -0
- package/dist/serialization/codec.d.ts.map +1 -0
- package/dist/serialization/codec.js +17 -0
- package/dist/serialization/compression.d.ts +104 -0
- package/dist/serialization/compression.d.ts.map +1 -0
- package/dist/serialization/compression.js +260 -0
- package/dist/serialization/encryption.d.ts +134 -0
- package/dist/serialization/encryption.d.ts.map +1 -0
- package/dist/serialization/encryption.js +186 -0
- package/dist/serialization/errors.d.ts +34 -0
- package/dist/serialization/errors.d.ts.map +1 -0
- package/dist/serialization/errors.js +59 -0
- package/dist/serialization/format.d.ts +60 -0
- package/dist/serialization/format.d.ts.map +1 -0
- package/dist/serialization/format.js +97 -0
- package/dist/serialization/hardened.d.ts +155 -0
- package/dist/serialization/hardened.d.ts.map +1 -0
- package/dist/serialization/hardened.js +523 -0
- package/dist/serialization/index.d.ts +20 -0
- package/dist/serialization/index.d.ts.map +1 -0
- package/dist/serialization/index.js +22 -0
- 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 +11 -0
- package/dist/serialization/reducers/class.d.ts.map +1 -0
- package/dist/serialization/reducers/class.js +73 -0
- 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 +579 -0
- package/dist/serialization/reducers/common.d.ts +16 -0
- package/dist/serialization/reducers/common.d.ts.map +1 -0
- package/dist/serialization/reducers/common.js +478 -0
- 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 +35 -0
- package/dist/serialization/reducers/step-function.d.ts.map +1 -0
- package/dist/serialization/reducers/step-function.js +104 -0
- package/dist/serialization/step.d.ts +17 -0
- package/dist/serialization/step.d.ts.map +1 -0
- package/dist/serialization/step.js +48 -0
- package/dist/serialization/types.d.ts +273 -0
- package/dist/serialization/types.d.ts.map +1 -0
- package/dist/serialization/types.js +35 -0
- package/dist/serialization/vm-bundle-entry.d.ts +12 -0
- package/dist/serialization/vm-bundle-entry.d.ts.map +1 -0
- package/dist/serialization/vm-bundle-entry.js +58 -0
- package/dist/serialization/workflow-vm.d.ts +24 -0
- package/dist/serialization/workflow-vm.d.ts.map +1 -0
- package/dist/serialization/workflow-vm.js +66 -0
- package/dist/serialization/workflow.d.ts +29 -0
- package/dist/serialization/workflow.d.ts.map +1 -0
- package/dist/serialization/workflow.js +54 -0
- package/dist/serialization-format.d.ts +60 -4
- package/dist/serialization-format.d.ts.map +1 -1
- package/dist/serialization-format.js +276 -56
- package/dist/serialization.d.ts +374 -221
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +2300 -783
- 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/sleep.d.ts.map +1 -1
- package/dist/sleep.js +3 -2
- package/dist/source-map.d.ts +25 -0
- package/dist/source-map.d.ts.map +1 -1
- package/dist/source-map.js +148 -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/get-closure-vars.d.ts.map +1 -1
- package/dist/step/get-closure-vars.js +3 -2
- package/dist/step/get-step-metadata.d.ts.map +1 -1
- package/dist/step/get-step-metadata.js +3 -2
- package/dist/step/get-workflow-metadata.d.ts.map +1 -1
- package/dist/step/get-workflow-metadata.js +3 -2
- package/dist/step/writable-stream.d.ts.map +1 -1
- package/dist/step/writable-stream.js +71 -7
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +226 -30
- package/dist/symbols.d.ts +54 -0
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +55 -1
- package/dist/telemetry/semantic-conventions.d.ts +242 -2
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +173 -1
- package/dist/telemetry.d.ts +73 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +153 -16
- 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 +16 -6
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +25 -16
- 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 +77 -9
- package/dist/vm/script-cache.d.ts +28 -0
- package/dist/vm/script-cache.d.ts.map +1 -0
- package/dist/vm/script-cache.js +140 -0
- package/dist/workflow/abort-controller.d.ts +65 -0
- package/dist/workflow/abort-controller.d.ts.map +1 -0
- package/dist/workflow/abort-controller.js +314 -0
- 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 +48 -0
- package/dist/workflow/create-hook.d.ts.map +1 -1
- package/dist/workflow/create-hook.js +25 -3
- package/dist/workflow/define-hook.d.ts +1 -1
- package/dist/workflow/define-hook.d.ts.map +1 -1
- package/dist/workflow/define-hook.js +8 -4
- package/dist/workflow/get-workflow-metadata.d.ts.map +1 -1
- package/dist/workflow/get-workflow-metadata.js +14 -3
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +303 -37
- package/dist/workflow/index.d.ts +1 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +5 -3
- 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 -9
- package/dist/workflow/world-init-stub.d.ts +15 -0
- package/dist/workflow/world-init-stub.d.ts.map +1 -0
- package/dist/workflow/world-init-stub.js +15 -0
- package/dist/workflow.d.ts +69 -3
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +791 -554
- package/docs/api-reference/create-hook.mdx +79 -0
- package/docs/api-reference/create-webhook.mdx +1 -0
- package/docs/api-reference/define-hook.mdx +26 -24
- package/docs/api-reference/fatal-error.mdx +29 -7
- package/docs/api-reference/fetch.mdx +8 -4
- package/docs/api-reference/index.mdx +3 -0
- package/docs/api-reference/set-attributes.mdx +61 -0
- package/docs/api-reference/sleep.mdx +1 -1
- package/docs/foundations/cancellation.mdx +459 -0
- package/docs/foundations/errors-and-retries.mdx +7 -3
- package/docs/foundations/hooks.mdx +29 -0
- package/docs/foundations/idempotency.mdx +243 -11
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +3 -1
- package/docs/foundations/serialization.mdx +77 -41
- package/docs/foundations/starting-workflows.mdx +79 -2
- package/docs/foundations/streaming.mdx +14 -23
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/how-it-works/cancellation.mdx +287 -0
- package/docs/how-it-works/code-transform.mdx +21 -17
- package/docs/how-it-works/encryption.mdx +5 -5
- package/docs/how-it-works/event-sourcing.mdx +6 -6
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/meta.json +2 -1
- package/package.json +31 -13
- 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 -678
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Event, SerializedData, World } from '@workflow/world';
|
|
2
|
+
import type { PayloadKey } from '../serialization/encryption.js';
|
|
3
|
+
import { type PreconditionSnapshotParams } from './helpers.js';
|
|
4
|
+
import { ReplayRecoveryReporter } from './replay-recovery-reporter.js';
|
|
5
|
+
import { type StepLatencyTracking } from './step-latency.js';
|
|
6
|
+
export declare const DEFAULT_STEP_MAX_RETRIES = 3;
|
|
7
|
+
export interface StepExecutorParams {
|
|
8
|
+
world: World;
|
|
9
|
+
workflowRunId: string;
|
|
10
|
+
/** Deployment that owns the workflow run, for forwarded writable streams. */
|
|
11
|
+
workflowDeploymentId?: string;
|
|
12
|
+
workflowName: string;
|
|
13
|
+
workflowStartedAt: number;
|
|
14
|
+
/** Root run id of this run's lineage, carried into the step context. */
|
|
15
|
+
rootRunId?: string;
|
|
16
|
+
stepId: string;
|
|
17
|
+
stepName: string;
|
|
18
|
+
encryptionKey?: PayloadKey;
|
|
19
|
+
/**
|
|
20
|
+
* The workflow run's specVersion, used to gate payload compression.
|
|
21
|
+
* Step outputs/errors are only compressed when the run is marked as
|
|
22
|
+
* compression-capable (specVersion >= 5).
|
|
23
|
+
*/
|
|
24
|
+
runSpecVersion?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Lazy step start: the already-dehydrated step input. When provided, the
|
|
27
|
+
* `step_started` event carries this input so the world creates the step on
|
|
28
|
+
* the fly (no separate `step_created` round-trip). Set by the owned-inline
|
|
29
|
+
* path for the step whose `step_created` the suspension handler deferred.
|
|
30
|
+
* The world's atomic create-claim is the exactly-one-owner gate: losing it
|
|
31
|
+
* surfaces as `EntityConflictError` → `{ type: 'skipped' }`, so a handler
|
|
32
|
+
* that did not win the create never runs the body. Omitted on every other
|
|
33
|
+
* path, where the step already has a `step_created` and `step_started`
|
|
34
|
+
* carries no payload (the legacy contract).
|
|
35
|
+
*/
|
|
36
|
+
lazyStepInput?: SerializedData;
|
|
37
|
+
/**
|
|
38
|
+
* Inline step ownership: the queue message ID of the invocation this
|
|
39
|
+
* executeStep call runs in (from the queue handler's meta). When set, the
|
|
40
|
+
* `step_started` this call sends is stamped with it — on the lazy paths
|
|
41
|
+
* (where `lazyStepInput` is present) and on the owned-recovery
|
|
42
|
+
* payload-less start (where it is not; the re-stamp keeps a recovered
|
|
43
|
+
* step readable as owned by this message, since ownership derives from
|
|
44
|
+
* the LATEST start — so a recovery start is never bare). Wake
|
|
45
|
+
* replays that observe an actively-owned step suppress the immediate
|
|
46
|
+
* requeue and enqueue a delayed backstop instead. Omitted on the
|
|
47
|
+
* background-step path, whose bare start intentionally clears ownership
|
|
48
|
+
* (the step is queue-owned from that point).
|
|
49
|
+
*/
|
|
50
|
+
ownerMessageId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Inline-delta optimization (opt-in). When provided, the cursor of the
|
|
53
|
+
* event log as observed by the caller *before* this step's events were
|
|
54
|
+
* written. It is threaded into the step-terminal `events.create` so a
|
|
55
|
+
* supporting World can return the delta of events written since (see
|
|
56
|
+
* {@link import('@workflow/world').CreateEventParams.sinceCursor}).
|
|
57
|
+
* Only set this when `correlationId`-based ownership guarantees this
|
|
58
|
+
* handler is the sole inline writer for the run on this iteration.
|
|
59
|
+
*/
|
|
60
|
+
inlineDeltaSinceCursor?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Precondition-guard snapshot of the event log the caller's replay loaded, to
|
|
63
|
+
* attach to this step's `step_started` claim. On the lazy inline path the
|
|
64
|
+
* claim is the step's FIRST durable write (its `step_created` is deferred),
|
|
65
|
+
* so without this the claim would bypass the optimistic-concurrency guard
|
|
66
|
+
* entirely: a replay working from a stale view could claim — and then commit
|
|
67
|
+
* — a step scheduled without observing an event it never loaded. A
|
|
68
|
+
* guard-enforcing World rejects a stale claim with `PreconditionFailedError`
|
|
69
|
+
* (412); executeStep does NOT translate that rejection (re-claiming in place
|
|
70
|
+
* would still commit the stale schedule), so it propagates for the caller to
|
|
71
|
+
* abandon the batch and restart its replay. Undefined when the guard is
|
|
72
|
+
* disabled or the caller has no snapshot; Worlds that don't enforce the guard
|
|
73
|
+
* ignore it.
|
|
74
|
+
*/
|
|
75
|
+
preconditionSnapshot?: PreconditionSnapshotParams;
|
|
76
|
+
/**
|
|
77
|
+
* Suppress optimistic inline start for this step regardless of
|
|
78
|
+
* `WORKFLOW_OPTIMISTIC_INLINE_START` / `forceOptimisticStart`: take the
|
|
79
|
+
* await-then-run path so the body only runs after the `step_started` claim
|
|
80
|
+
* succeeds. Set by the runtime for guard-enforced batches that are
|
|
81
|
+
* stale-sensitive (an open hook means an out-of-band event can make the
|
|
82
|
+
* scheduling view stale): the guard's 412 fence can reject a stale claim's
|
|
83
|
+
* durable writes, but it cannot un-run a body that optimistic start began
|
|
84
|
+
* before the claim settled — awaiting the claim extends the fence to user
|
|
85
|
+
* code. Wins over `forceOptimisticStart` and the env flag.
|
|
86
|
+
*/
|
|
87
|
+
suppressOptimisticStart?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Force optimistic inline start regardless of
|
|
90
|
+
* `WORKFLOW_OPTIMISTIC_INLINE_START`. Set by turbo mode on the first delivery
|
|
91
|
+
* of the first invocation, where forcing it is safe: there is no concurrent
|
|
92
|
+
* peer handler to race the create-claim, so the body runs exactly once. Only
|
|
93
|
+
* meaningful together with `lazyStepInput` (a brand-new lazy step).
|
|
94
|
+
*/
|
|
95
|
+
forceOptimisticStart?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Turbo mode only: a promise that resolves once the backgrounded
|
|
98
|
+
* `run_started` has landed. When set, the lazy/optimistic `step_started` is
|
|
99
|
+
* chained on it so the step is never created before its run exists. The body
|
|
100
|
+
* still runs immediately against locally-synthesized state — only the network
|
|
101
|
+
* write waits — so the `run_started` round-trip overlaps the body. `undefined`
|
|
102
|
+
* outside turbo, where `run_started` was already awaited up front.
|
|
103
|
+
*/
|
|
104
|
+
runReadyBarrier?: Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* Latency telemetry (TTFS / STSO): eligibility and anchor timestamps decided
|
|
107
|
+
* by the orchestrator. When set, this executor computes the final values
|
|
108
|
+
* against the wall clock taken immediately before user code runs and
|
|
109
|
+
* attaches them to the step's terminal event. Set only for the first step of
|
|
110
|
+
* an inline batch, and only on first-attempt executions that qualify — see
|
|
111
|
+
* runtime/step-latency.ts.
|
|
112
|
+
*/
|
|
113
|
+
latencyTracking?: StepLatencyTracking;
|
|
114
|
+
/**
|
|
115
|
+
* Authoritative attempt number for this execution, used to bound retries
|
|
116
|
+
* against `maxRetries` BEFORE the body runs. In order to also catch
|
|
117
|
+
* step timeouts (which we can't have catch handlers for), we determine
|
|
118
|
+
* the attempt count based as follows:
|
|
119
|
+
* - Inline (combined handler): the number of `step_started` events already
|
|
120
|
+
* in the event log for this step, plus one for the attempt about to run.
|
|
121
|
+
* - Background (queue-dispatched): the queue delivery count
|
|
122
|
+
* (`metadata.attempt`), which increments on every redelivery.
|
|
123
|
+
*/
|
|
124
|
+
authoritativeAttempt?: number;
|
|
125
|
+
/** One-shot recovery telemetry activated by the orchestrator replay. */
|
|
126
|
+
replayRecoveryReporter?: ReplayRecoveryReporter;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Inline-delta returned by a step-terminal write when the caller passed
|
|
130
|
+
* {@link StepExecutorParams.inlineDeltaSinceCursor} and the World supports
|
|
131
|
+
* the optimization. `events` are the events written strictly after that
|
|
132
|
+
* cursor (this step's events plus anything interleaved in-band), `cursor`
|
|
133
|
+
* is the position past the last one, and `hasMore` signals a further page
|
|
134
|
+
* (the caller then falls back to a full incremental fetch). Absent when
|
|
135
|
+
* the World did not return a delta.
|
|
136
|
+
*/
|
|
137
|
+
export interface InlineEventDelta {
|
|
138
|
+
events: Event[];
|
|
139
|
+
cursor: string | null;
|
|
140
|
+
hasMore: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Result of a step execution attempt. The caller decides what to do
|
|
144
|
+
* based on the result type (e.g., queue workflow continuation, replay inline, etc.).
|
|
145
|
+
*
|
|
146
|
+
* `inlineDelta` is attached to a `completed` result when the caller
|
|
147
|
+
* requested it via {@link StepExecutorParams.inlineDeltaSinceCursor} and
|
|
148
|
+
* the World returned one. Step failures are rare and not the inline
|
|
149
|
+
* optimization's target, so the `failed` path leaves it to the normal
|
|
150
|
+
* incremental fetch.
|
|
151
|
+
*/
|
|
152
|
+
export type StepExecutionResult = {
|
|
153
|
+
type: 'completed';
|
|
154
|
+
hasPendingOps?: boolean;
|
|
155
|
+
inlineDelta?: InlineEventDelta;
|
|
156
|
+
} | {
|
|
157
|
+
type: 'failed';
|
|
158
|
+
} | {
|
|
159
|
+
type: 'retry';
|
|
160
|
+
timeoutSeconds: number;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'skipped';
|
|
163
|
+
} | {
|
|
164
|
+
type: 'gone';
|
|
165
|
+
} | {
|
|
166
|
+
type: 'throttled';
|
|
167
|
+
timeoutSeconds: number;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Executes a single step: creates step_started event, hydrates input,
|
|
171
|
+
* runs the step function, creates step_completed/step_failed/step_retrying events.
|
|
172
|
+
*
|
|
173
|
+
* Does NOT queue workflow continuation messages — the caller decides what to do next.
|
|
174
|
+
* Used by the combined workflow handler for step execution.
|
|
175
|
+
*/
|
|
176
|
+
export declare function executeStep(params: StepExecutorParams): Promise<StepExecutionResult>;
|
|
177
|
+
//# sourceMappingURL=step-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../../src/runtime/step-executor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,KAAK,EAEL,cAAc,EAEd,KAAK,EACN,MAAM,iBAAiB,CAAC;AAOzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAuBjE,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAuB1C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;;;;;;;;OAaG;IACH,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;IAClD;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,GACD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAgkC9B"}
|