@workflow/world-testing 5.0.0-beta.43 → 5.0.0-beta.44

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.
@@ -50,6 +50,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
50
50
  mod
51
51
  ));
52
52
 
53
+ // ../utils/dist/global-singleton.js
54
+ function globalSingleton(name, shapeVersion, create) {
55
+ const key = /* @__PURE__ */ Symbol.for(`${name}/v${shapeVersion}`);
56
+ const store = globalThis;
57
+ const existing = store[key];
58
+ if (existing !== void 0) {
59
+ return existing;
60
+ }
61
+ const created = create();
62
+ store[key] = created;
63
+ return created;
64
+ }
65
+ var init_global_singleton = __esm({
66
+ "../utils/dist/global-singleton.js"() {
67
+ "use strict";
68
+ __name(globalSingleton, "globalSingleton");
69
+ }
70
+ });
71
+
53
72
  // ../utils/dist/parse-name.js
54
73
  function parseName(tag, name) {
55
74
  if (typeof name !== "string") {
@@ -319,30 +338,15 @@ var init_time = __esm({
319
338
  }
320
339
  });
321
340
 
322
- // ../utils/dist/workflow-routes.js
323
- var init_workflow_routes = __esm({
324
- "../utils/dist/workflow-routes.js"() {
325
- "use strict";
326
- }
327
- });
328
-
329
- // ../utils/dist/world-target.js
330
- var init_world_target = __esm({
331
- "../utils/dist/world-target.js"() {
332
- "use strict";
333
- }
334
- });
335
-
336
341
  // ../utils/dist/index.js
337
342
  var init_dist = __esm({
338
343
  "../utils/dist/index.js"() {
339
344
  "use strict";
345
+ init_global_singleton();
340
346
  init_parse_name();
341
347
  init_pluralize();
342
348
  init_promise();
343
349
  init_time();
344
- init_workflow_routes();
345
- init_world_target();
346
350
  }
347
351
  });
348
352
 
@@ -556,7 +560,7 @@ Caused by: ${options.cause.stack}`;
556
560
  }
557
561
  hint;
558
562
  /**
559
- * Serialization errors are deterministic — if a step returns a non-POJO,
563
+ * Serialization errors are deterministic: if a step returns a non-POJO,
560
564
  * replaying the step will always produce the same non-serializable value.
561
565
  * Retrying is guaranteed to fail, so these errors are surfaced as fatal
562
566
  * and skip the step-retry loop. `FatalError.is()` recognizes any error
@@ -16548,7 +16552,7 @@ var init_serialization = __esm({
16548
16552
  });
16549
16553
 
16550
16554
  // ../world/dist/events.js
16551
- var EventTypeSchema, RunEventTypeSchema, RUN_EVENT_TYPES, TerminalRunEventTypeSchema, TERMINAL_RUN_EVENT_TYPES, StepEventTypeSchema, STEP_EVENT_TYPES, TerminalStepEventTypeSchema, TERMINAL_STEP_EVENT_TYPES, HookLifecycleEventTypeSchema, HOOK_LIFECYCLE_EVENT_TYPES, HookEventRequiringExistenceTypeSchema, HOOK_EVENTS_REQUIRING_EXISTENCE, WaitEventTypeSchema, WAIT_EVENT_TYPES, ChildEntityCreationEventTypeSchema, CHILD_ENTITY_CREATION_EVENT_TYPES, EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE, EVENT_DATA_REF_FIELDS, BaseEventSchema, stepLatencyTelemetryFields, StepCompletedEventSchema, StepFailedEventSchema, StepRetryingEventSchema, StepStartedEventSchema, StepCreatedEventSchema, HookCreatedEventSchema, HookReceivedEventSchema, HookDisposedEventSchema, HookConflictEventSchema, WaitCreatedEventSchema, WaitCompletedEventSchema, AttributeWriterSchema, AttrSetEventSchema, RunCreatedEventSchema, RunStartedEventSchema, RunCompletedEventSchema, RunFailedEventSchema, RunCancelledEventSchema, CreateEventSchema, AllEventsSchema, EventSchema;
16555
+ var EventTypeSchema, RunEventTypeSchema, RUN_EVENT_TYPES, TerminalRunEventTypeSchema, TERMINAL_RUN_EVENT_TYPES, StepEventTypeSchema, STEP_EVENT_TYPES, TerminalStepEventTypeSchema, TERMINAL_STEP_EVENT_TYPES, HookLifecycleEventTypeSchema, HOOK_LIFECYCLE_EVENT_TYPES, HookEventRequiringExistenceTypeSchema, HOOK_EVENTS_REQUIRING_EXISTENCE, WaitEventTypeSchema, WAIT_EVENT_TYPES, ChildEntityCreationEventTypeSchema, CHILD_ENTITY_CREATION_EVENT_TYPES, EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE, EVENT_DATA_REF_FIELDS, BaseEventSchema, stepLatencyTelemetryFields, StepCompletedEventSchema, StepFailedEventSchema, StepRetryingEventSchema, StepStartedEventSchema, StepCreatedEventSchema, HookCreatedEventSchema, HookReceivedEventSchema, HookDisposedEventSchema, HookConflictEventSchema, NoopEventSchema, WaitCreatedEventSchema, WaitCompletedEventSchema, AttributeWriterSchema, AttrSetEventSchema, RunCreatedEventSchema, RunStartedEventSchema, RunCompletedEventSchema, RunFailedEventSchema, RunCancelledEventSchema, CreateEventSchema, AllEventsSchema, EventSchema;
16552
16556
  var init_events = __esm({
16553
16557
  "../world/dist/events.js"() {
16554
16558
  "use strict";
@@ -16577,7 +16581,11 @@ var init_events = __esm({
16577
16581
  "hook_conflict",
16578
16582
  // Wait lifecycle events
16579
16583
  "wait_created",
16580
- "wait_completed"
16584
+ "wait_completed",
16585
+ // Sealed-log filler (specVersion >= 7): written ONLY by the World's backend
16586
+ // to occupy a slot whose writer allocated it and died. Carries no workflow
16587
+ // meaning; replay skips it (see EventsConsumer). Never user-creatable.
16588
+ "noop"
16581
16589
  ]);
16582
16590
  RunEventTypeSchema = EventTypeSchema.extract([
16583
16591
  "run_created",
@@ -16674,7 +16682,7 @@ var init_events = __esm({
16674
16682
  rsfs: external_exports.number().optional(),
16675
16683
  // Synchronous workflow-function replay duration of only the FINAL replay
16676
16684
  // pass within the rsfs window (the pass that scheduled the first step),
16677
- // excluding awaited network I/O — not accumulated across earlier
16685
+ // excluding awaited network I/O. Not accumulated across earlier
16678
16686
  // pre-first-step passes, so it is not "the replay portion of rsfs". Only
16679
16687
  // present alongside rsfs, and only for the run's first step.
16680
16688
  finalSchedulingReplay: external_exports.number().optional(),
@@ -16734,7 +16742,7 @@ var init_events = __esm({
16734
16742
  // handler is executing this step's body inline. Stamped on the lazy
16735
16743
  // step_started (and re-stamped on an owner-recovery bare start) so
16736
16744
  // that a wake replay can tell "this attempt is in flight in a live
16737
- // invocation" apart from "this attempt died with its process" — the
16745
+ // invocation" apart from "this attempt died with its process": the
16738
16746
  // owner's queue message doubles as the liveness lease (a crash means
16739
16747
  // the queue redelivers that same messageId, which is allowed to
16740
16748
  // re-execute). Ownership derives from the step's LATEST step_started:
@@ -16790,6 +16798,12 @@ var init_events = __esm({
16790
16798
  conflictingRunId: external_exports.string().optional()
16791
16799
  })
16792
16800
  });
16801
+ NoopEventSchema = BaseEventSchema.extend({
16802
+ eventType: external_exports.literal("noop"),
16803
+ eventData: external_exports.object({
16804
+ sealed: external_exports.boolean().optional()
16805
+ }).passthrough().optional()
16806
+ });
16793
16807
  WaitCreatedEventSchema = BaseEventSchema.extend({
16794
16808
  eventType: external_exports.literal("wait_created"),
16795
16809
  correlationId: external_exports.string(),
@@ -16836,7 +16850,7 @@ var init_events = __esm({
16836
16850
  * The run's X25519 public key (base64), stamped by SDKs that support
16837
16851
  * sealed (`encp`) envelopes. Persisted onto the run entity so that
16838
16852
  * cross-run writers can seal payloads to this run without holding its
16839
- * symmetric key. Not secret — see `WorkflowRunBaseSchema`.
16853
+ * symmetric key. Not secret. See `WorkflowRunBaseSchema`.
16840
16854
  */
16841
16855
  encryptionPublicKey: external_exports.string().optional()
16842
16856
  })
@@ -16930,7 +16944,8 @@ var init_events = __esm({
16930
16944
  HookConflictEventSchema,
16931
16945
  // Wait lifecycle events
16932
16946
  WaitCreatedEventSchema,
16933
- WaitCompletedEventSchema
16947
+ WaitCompletedEventSchema,
16948
+ NoopEventSchema
16934
16949
  ]);
16935
16950
  EventSchema = AllEventsSchema.and(external_exports.object({
16936
16951
  runId: external_exports.string(),
@@ -16999,7 +17014,7 @@ var init_runs = __esm({
16999
17014
  * ```
17000
17015
  */
17001
17016
  workflowName: external_exports.string(),
17002
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
17017
+ // Optional in database for backward compatibility, defaults to 1 (legacy) when reading
17003
17018
  specVersion: external_exports.number().optional(),
17004
17019
  executionContext: external_exports.record(external_exports.string(), external_exports.any()).optional(),
17005
17020
  input: SerializedDataSchema.optional(),
@@ -17027,12 +17042,12 @@ var init_runs = __esm({
17027
17042
  *
17028
17043
  * Defaults to `{}` after schema parsing so consumers always receive
17029
17044
  * a record regardless of world. World adapters need not initialize
17030
- * the field on disk — `world-local` JSON files written before this
17045
+ * the field on disk: `world-local` JSON files written before this
17031
17046
  * field existed, and rows from any other adapter that omits the
17032
17047
  * column, both read as `{}` after Zod parses them.
17033
17048
  *
17034
17049
  * EXPERIMENTAL (MVP): the full Workflow Attributes feature replaces
17035
- * the direct-mutation MVP path with an event-sourced model — see
17050
+ * the direct-mutation MVP path with an event-sourced model. See
17036
17051
  * the attributes-mvp changelog entry.
17037
17052
  */
17038
17053
  attributes: external_exports.record(external_exports.string(), external_exports.string()).default({}),
@@ -17040,12 +17055,12 @@ var init_runs = __esm({
17040
17055
  * The run's X25519 public key, base64-encoded (~44 chars).
17041
17056
  *
17042
17057
  * Lets any party that can read this run seal a payload *to* it without
17043
- * being able to read the run's data — used for cross-run writes such as a
17044
- * hook resumption from another deployment, or a child workflow writing into
17045
- * a forwarded stream. The matching private scalar is never stored: it is
17046
- * re-derived on demand from the deployment's own key material, so this
17047
- * field is not secret and its presence does not weaken the run's
17048
- * confidentiality.
17058
+ * being able to read the run's data. This is used for cross-run writes
17059
+ * such as a hook resumption from another deployment, or a child workflow
17060
+ * writing into a forwarded stream. The matching private scalar is never
17061
+ * stored: it is re-derived on demand from the deployment's own key
17062
+ * material, so this field is not secret and its presence does not weaken
17063
+ * the run's confidentiality.
17049
17064
  *
17050
17065
  * Stamped at run creation by SDKs that support sealed (`encp`) envelopes.
17051
17066
  * **Presence is the writer-side gate**: a run only carries a public key if
@@ -17378,11 +17393,13 @@ function envNumber(name, fallback, options = {}) {
17378
17393
  }
17379
17394
  return parsed;
17380
17395
  }
17381
- var warnedEnvValues;
17396
+ var WarnedEnvValuesKey, globalStore, warnedEnvValues;
17382
17397
  var init_env_config = __esm({
17383
17398
  "../world/dist/env-config.js"() {
17384
17399
  "use strict";
17385
- warnedEnvValues = /* @__PURE__ */ new Set();
17400
+ WarnedEnvValuesKey = /* @__PURE__ */ Symbol.for("@workflow/world//warnedEnvValues/v1");
17401
+ globalStore = globalThis;
17402
+ warnedEnvValues = globalStore[WarnedEnvValuesKey] ??= /* @__PURE__ */ new Set();
17386
17403
  __name(warnOnce, "warnOnce");
17387
17404
  __name(envNumber, "envNumber");
17388
17405
  }
@@ -17457,12 +17474,12 @@ var init_queue = __esm({
17457
17474
  * two can disagree: if the message is consumed by a deployment in a
17458
17475
  * DIFFERENT environment, that consumer's `run_started` re-creates the run
17459
17476
  * under ITS tenant, so the same client-minted `wrun_` id ends up existing
17460
- * in two environments — one stuck pending forever, the other executing.
17477
+ * in two environments: one stuck pending forever, the other executing.
17461
17478
  * Carrying the creator's environment lets the consumer compare it against
17462
17479
  * its own and refuse the delivery instead of forking the run.
17463
17480
  *
17464
17481
  * Absent for worlds with no environment dimension (local, Postgres), and
17465
- * for older SDKs — consumers must treat it as advisory and skip the check
17482
+ * for older SDKs. Consumers must treat it as advisory and skip the check
17466
17483
  * when it is missing.
17467
17484
  */
17468
17485
  environment: external_exports.string().optional()
@@ -17487,8 +17504,8 @@ var init_queue = __esm({
17487
17504
  hookId: external_exports.string(),
17488
17505
  /**
17489
17506
  * The hook's token, written into the `hook_received` event's `eventData` so
17490
- * the consumer's re-ensured event carries the same token the producer would
17491
- * — replay validates `eventData.token` against the `createHook` token.
17507
+ * the consumer's re-ensured event carries the same token the producer
17508
+ * would. Replay validates `eventData.token` against the `createHook` token.
17492
17509
  */
17493
17510
  token: external_exports.string(),
17494
17511
  /** The serialized resume payload, reused verbatim from the direct write. */
@@ -17498,7 +17515,7 @@ var init_queue = __esm({
17498
17515
  * serialized bytes and forwarded verbatim on both the direct `events.create`
17499
17516
  * and this queue message. The consumer forwards it back to the server so both
17500
17517
  * writers of the same `resumeId` record an identical digest on the
17501
- * `(runId, resumeId)` constraint — required because the v4 payload ref is not
17518
+ * `(runId, resumeId)` constraint, required because the v4 payload ref is not
17502
17519
  * content-stable server-side.
17503
17520
  */
17504
17521
  payloadDigest: external_exports.string(),
@@ -17506,15 +17523,15 @@ var init_queue = __esm({
17506
17523
  * The deployment the run is pinned to, from the producer's resume context.
17507
17524
  * Lets the consumer detect a misrouted delivery with a cheap ambient
17508
17525
  * deployment-id comparison BEFORE its hoisted `hook_received` replay-preload
17509
- * write — only a detected mismatch pays for the authoritative run fetch and
17526
+ * write: only a detected mismatch pays for the authoritative run fetch and
17510
17527
  * the deployment-affinity guard. Optional for queued-message compatibility:
17511
- * messages from older producers omit it and simply skip the pre-write
17528
+ * messages from older producers omit it and skip the pre-write
17512
17529
  * check (the authoritative guard before replay still protects them).
17513
17530
  */
17514
17531
  deploymentId: external_exports.string().optional()
17515
17532
  });
17516
17533
  HookResumeTimingSchema = external_exports.object({
17517
- /** Epoch ms at entry into `resumeHook()` — the start of the TTR window. */
17534
+ /** Epoch ms at entry into `resumeHook()`: the start of the TTR window. */
17518
17535
  resumeRequestedAtMs: external_exports.number(),
17519
17536
  /** Epoch ms immediately before the queue publish was requested. */
17520
17537
  queuePublishRequestedAtMs: external_exports.number(),
@@ -17550,10 +17567,41 @@ var init_queue = __esm({
17550
17567
  serverErrorRetryCount: external_exports.number().int().optional(),
17551
17568
  /** Number of times this message has been re-routed after a deployment mismatch */
17552
17569
  deploymentMismatchRetryCount: external_exports.number().int().nonnegative().optional(),
17570
+ /**
17571
+ * The wait this message is the delayed continuation for, and which attempt
17572
+ * in that wait's chain it is.
17573
+ *
17574
+ * Present only on wait-continuation messages. It exists so the invocation a
17575
+ * continuation wakes can recognize itself as that continuation: if the wait
17576
+ * is STILL pending when it replays — the continuation arrived before its
17577
+ * deadline — then its own idempotency key is already spent, and re-enqueueing
17578
+ * under the same key is silently dropped by the world's dedupe window. The
17579
+ * attempt number is what makes the next key fresh, so an early delivery
17580
+ * costs one extra hop instead of losing the wait's timer permanently.
17581
+ *
17582
+ * Counted on the message for the same reason as
17583
+ * {@link WorkflowInvokePayloadSchema.shape.preconditionReinvocations}: the
17584
+ * budget has to survive across invocations, and a fresh enqueue resets
17585
+ * anything the queue tracks itself. Absent on the first continuation, so a
17586
+ * producer that predates this field is indistinguishable from attempt 0 and
17587
+ * a consumer that predates it simply ignores the field.
17588
+ */
17589
+ /**
17590
+ * `.catch(undefined)` for the reason `hookResumeTiming` has it: this field
17591
+ * must never be able to fail the parse of the invocation payload. A
17592
+ * malformed value would otherwise throw on every delivery of the message
17593
+ * and burn the run's delivery budget. Degrading to `undefined` reads as
17594
+ * "not a continuation", which costs at worst the pre-attempt behavior for
17595
+ * that one wait rather than killing the run.
17596
+ */
17597
+ waitContinuation: external_exports.object({
17598
+ correlationId: external_exports.string(),
17599
+ attempt: external_exports.number().int().nonnegative()
17600
+ }).optional().catch(void 0),
17553
17601
  /** Step ID for inline step execution in combined handler. If provided, the flow execution
17554
17602
  * will jump directly to execute the step with the given ID before doing an event replay. */
17555
17603
  stepId: external_exports.string().optional(),
17556
- /** Step name, sent alongside stepId to avoid loading the event log just to resolve the name. */
17604
+ /** Step name, sent alongside stepId to avoid loading the event log to resolve the name. */
17557
17605
  stepName: external_exports.string().optional(),
17558
17606
  /** Run creation data, only present on the first queue delivery from start() */
17559
17607
  runInput: RunInputSchema.optional(),
@@ -17574,8 +17622,8 @@ var init_queue = __esm({
17574
17622
  * Hook-resume TTR timing. Present on both `resumeHook()` dispatch paths
17575
17623
  * (unlike `hookInput`, which only rides the parallel fast path), and
17576
17624
  * forwarded onto a dispatched step message when the resuming invocation
17577
- * hands the next durable step to another invocation. Purely observational —
17578
- * see {@link HookResumeTimingSchema}.
17625
+ * hands the next durable step to another invocation. Purely observational.
17626
+ * See {@link HookResumeTimingSchema}.
17579
17627
  *
17580
17628
  * `.catch(undefined)` because this field must never be able to fail the
17581
17629
  * parse of the invocation payload: a malformed value (a NaN boundary, a
@@ -17633,7 +17681,7 @@ var init_hooks = __esm({
17633
17681
  // `@workflow/core` re-ensures the `hook_received` event from the queue
17634
17682
  // message's `hookInput` on replay, so `resumeHook()`'s parallel fast path is
17635
17683
  // safe to use. Because a run is pinned to its creating deployment, this
17636
- // marker is a reliable per-run attestation — unlike inferring support from a
17684
+ // marker is a reliable per-run attestation, unlike inferring support from a
17637
17685
  // version compare against a predicted release cutoff. Absent on runs created
17638
17686
  // before the marker existed (fall back to the sequential path).
17639
17687
  hookResumeInputVersion: external_exports.number().optional()
@@ -17656,7 +17704,7 @@ var init_hooks = __esm({
17656
17704
  environment: external_exports.string(),
17657
17705
  metadata: SerializedDataSchema.optional(),
17658
17706
  createdAt: external_exports.coerce.date(),
17659
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
17707
+ // Optional in database for backward compatibility, defaults to 1 (legacy) when reading
17660
17708
  specVersion: external_exports.number().optional(),
17661
17709
  isWebhook: external_exports.boolean().optional(),
17662
17710
  isSystem: external_exports.boolean().optional(),
@@ -17668,9 +17716,9 @@ var init_hooks = __esm({
17668
17716
  // falls back to `runs.get`.
17669
17717
  resumeContext: HookResumeContextSchema.optional(),
17670
17718
  // Backend dedup capability, computed FRESH by the server on every by-token
17671
- // lookup — RESPONSE-ONLY and TRANSIENT. Never persisted on the hook entity
17719
+ // lookup: RESPONSE-ONLY and TRANSIENT. Never persisted on the hook entity
17672
17720
  // and never part of `resumeContext`, so a server rollback or kill switch
17673
- // takes effect on the very next lookup (the field simply stops appearing).
17721
+ // takes effect on the next lookup (the field stops appearing).
17674
17722
  // `resumeHook()` gates its parallel fast path on this being present and
17675
17723
  // current. Absent against an older/rolled-back server or when the kill switch
17676
17724
  // is active.
@@ -17739,17 +17787,19 @@ var init_slot_identity = __esm({
17739
17787
  function isLegacySpecVersion(v) {
17740
17788
  return v === void 0 || v === null || v <= SPEC_VERSION_LEGACY;
17741
17789
  }
17742
- var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_SUPPORTS_SLOT_IDENTITY, SPEC_VERSION_CURRENT, SPEC_VERSION_MAX_SUPPORTED;
17790
+ var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_SUPPORTS_SLOT_IDENTITY, SPEC_VERSION_SUPPORTS_SEALED_LOG, SPEC_VERSION_CURRENT, SPEC_VERSION_MAX_SUPPORTED;
17743
17791
  var init_spec_version = __esm({
17744
17792
  "../world/dist/spec-version.js"() {
17745
17793
  "use strict";
17794
+ init_env_config();
17746
17795
  SPEC_VERSION_LEGACY = 1;
17747
17796
  SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
17748
17797
  SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
17749
17798
  SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
17750
17799
  SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
17751
- SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17752
- SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17800
+ SPEC_VERSION_SUPPORTS_SEALED_LOG = 7;
17801
+ SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SEALED_LOG;
17802
+ SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SEALED_LOG;
17753
17803
  __name(isLegacySpecVersion, "isLegacySpecVersion");
17754
17804
  }
17755
17805
  });
@@ -18098,7 +18148,7 @@ function importPublicKey(publicKey) {
18098
18148
  },
18099
18149
  /* extractable */
18100
18150
  true,
18101
- // Public keys carry no usages for X25519 — the private key does the
18151
+ // Public keys carry no usages for X25519: the private key does the
18102
18152
  // deriving; the public key is only ever an argument to it.
18103
18153
  []
18104
18154
  );
@@ -18412,7 +18462,7 @@ var init_types = __esm({
18412
18462
  /** Encrypted payload (inner payload has its own format prefix) */
18413
18463
  ENCRYPTED: "encr",
18414
18464
  /**
18415
- * Sealed payload — asymmetrically encrypted to a run's X25519 public key
18465
+ * Sealed payload: asymmetrically encrypted to a run's X25519 public key
18416
18466
  * (inner payload has its own format prefix).
18417
18467
  *
18418
18468
  * Used for *cross-run* writes (hook payloads, forwarded stream frames),
@@ -19623,7 +19673,6 @@ var RegisteredStepsKey, globalSymbols, registeredSteps, BUILTIN_RESPONSE_STEP_NA
19623
19673
  var init_private = __esm({
19624
19674
  "../core/dist/private.js"() {
19625
19675
  "use strict";
19626
- init_dist();
19627
19676
  RegisteredStepsKey = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps");
19628
19677
  globalSymbols = globalThis;
19629
19678
  registeredSteps = globalSymbols[RegisteredStepsKey] ??= /* @__PURE__ */ new Map();
@@ -19641,11 +19690,11 @@ var init_private = __esm({
19641
19690
  // ../core/dist/runtime/world-compatibility.js
19642
19691
  function assertWorldSupportsRuntimeProtocol(world) {
19643
19692
  const declared = world.specVersion;
19644
- if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_CURRENT && declared <= SPEC_VERSION_MAX_SUPPORTED) {
19693
+ if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_SUPPORTS_SLOT_IDENTITY && declared <= SPEC_VERSION_MAX_SUPPORTED) {
19645
19694
  return;
19646
19695
  }
19647
19696
  const supportedVersion = declared ?? "none";
19648
- throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_CURRENT} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
19697
+ throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_SUPPORTS_SLOT_IDENTITY} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
19649
19698
  }
19650
19699
  var init_world_compatibility = __esm({
19651
19700
  "../core/dist/runtime/world-compatibility.js"() {
@@ -19703,7 +19752,7 @@ function withGuestCodeStats(stats, fn) {
19703
19752
  }
19704
19753
  }
19705
19754
  function isUseStepClosureFn(fn) {
19706
- return typeof fn === "function" && useStepClosureFns.has(fn);
19755
+ return typeof fn === "function" && useStepClosures.fns.has(fn);
19707
19756
  }
19708
19757
  function recordGuestCode(kind, detail) {
19709
19758
  if (!activeStats) return;
@@ -19866,15 +19915,18 @@ function readToStringTag(value) {
19866
19915
  const tag = readProperty(value, Symbol.toStringTag);
19867
19916
  return typeof tag === "string" ? tag : void 0;
19868
19917
  }
19869
- var activeStats, reportedProxies, useStepClosureFns, uncurryThis, dateGetDate, dateGetTime, dateToISOString, regExpSource, regExpFlags, arrayBufferByteLength, mapEntries, setValues, numberValueOf, stringValueOf, booleanValueOf, bigIntValueOf, TypedArrayPrototype, typedArrayTag, typedArrayBuffer, typedArrayByteOffset, typedArrayByteLength, typedArrayLength, dataViewBuffer, dataViewByteOffset, dataViewByteLength, sharedArrayBufferByteLength, headersIterator, urlHrefGetter, urlSearchParamsToStringMethod, isProxy, functionToString, KNOWN_VIEW_TAGS, BRAND_DECIDED_TAGS, hardenedStringifyOperations;
19918
+ var activeStats, reportedProxies, useStepClosures, uncurryThis, dateGetDate, dateGetTime, dateToISOString, regExpSource, regExpFlags, arrayBufferByteLength, mapEntries, setValues, numberValueOf, stringValueOf, booleanValueOf, bigIntValueOf, TypedArrayPrototype, typedArrayTag, typedArrayBuffer, typedArrayByteOffset, typedArrayByteLength, typedArrayLength, dataViewBuffer, dataViewByteOffset, dataViewByteLength, sharedArrayBufferByteLength, headersIterator, urlHrefGetter, urlSearchParamsToStringMethod, isProxy, functionToString, KNOWN_VIEW_TAGS, BRAND_DECIDED_TAGS, hardenedStringifyOperations;
19870
19919
  var init_hardened = __esm({
19871
19920
  "../core/dist/serialization/hardened.js"() {
19872
19921
  "use strict";
19922
+ init_dist();
19873
19923
  init_devalue();
19874
19924
  activeStats = null;
19875
19925
  reportedProxies = null;
19876
19926
  __name(withGuestCodeStats, "withGuestCodeStats");
19877
- useStepClosureFns = /* @__PURE__ */ new WeakSet();
19927
+ useStepClosures = globalSingleton("@workflow/core//useStepClosures.fns", 1, () => ({
19928
+ fns: /* @__PURE__ */ new WeakSet()
19929
+ }));
19878
19930
  __name(isUseStepClosureFn, "isUseStepClosureFn");
19879
19931
  __name(recordGuestCode, "recordGuestCode");
19880
19932
  __name(recordProxy, "recordProxy");
@@ -20169,7 +20221,7 @@ function getCommonReducers(_global = globalThis) {
20169
20221
  return {
20170
20222
  ArrayBuffer: /* @__PURE__ */ __name((value) => types2.isArrayBuffer(value) && arrayBufferToBase64(value, 0, arrayBufferByteLength(value)), "ArrayBuffer"),
20171
20223
  BigInt: /* @__PURE__ */ __name((value) => (
20172
- // String(bigint) is a spec-internal numeric conversion — unlike
20224
+ // String(bigint) is a spec-internal numeric conversion: unlike
20173
20225
  // `value.toString()`, it never consults BigInt.prototype.
20174
20226
  typeof value === "bigint" && String(value)
20175
20227
  ), "BigInt"),
@@ -20282,7 +20334,7 @@ function getCommonReducers(_global = globalThis) {
20282
20334
  errors: readProperty(value, "errors")
20283
20335
  };
20284
20336
  }, "AggregateError"),
20285
- // Base Error reducer — catch-all for any Error instance not matched by a
20337
+ // Base Error reducer: catch-all for any Error instance not matched by a
20286
20338
  // specific subclass reducer above (including user Error subclasses without
20287
20339
  // WORKFLOW_SERIALIZE). Preserves `name` so the error's identity is retained
20288
20340
  // even though the exact class cannot be reconstructed.
@@ -20301,7 +20353,7 @@ function getCommonReducers(_global = globalThis) {
20301
20353
  Float32Array: /* @__PURE__ */ __name((value) => types2.isFloat32Array(value) && viewToBase64(value), "Float32Array"),
20302
20354
  Float64Array: /* @__PURE__ */ __name((value) => types2.isFloat64Array(value) && viewToBase64(value), "Float64Array"),
20303
20355
  // Headers is a host class injected into the sandbox, so its (shared)
20304
- // prototype is reachable from workflow code — iterate through the
20356
+ // prototype is reachable from workflow code; iterate through the
20305
20357
  // boot-captured iterator instead of a live Symbol.iterator lookup.
20306
20358
  Headers: /* @__PURE__ */ __name((value) => isInstanceOfPrototype(value, Headers.prototype) && headersToEntries(value), "Headers"),
20307
20359
  Int8Array: /* @__PURE__ */ __name((value) => types2.isInt8Array(value) && viewToBase64(value), "Int8Array"),
@@ -20413,7 +20465,7 @@ function getCommonRevivers(global2 = globalThis) {
20413
20465
  if (value.stack !== void 0) error48.stack = value.stack;
20414
20466
  return error48;
20415
20467
  }, "AggregateError"),
20416
- // Base Error reviver — used for plain Error instances and unrecognized
20468
+ // Base Error reviver: used for plain Error instances and unrecognized
20417
20469
  // Error subclasses. Preserves `name` so the error's identity is retained.
20418
20470
  Error: /* @__PURE__ */ __name((value) => {
20419
20471
  const opts = "cause" in value ? {
@@ -21150,7 +21202,7 @@ function SemanticConvention(...names) {
21150
21202
  value
21151
21203
  ]));
21152
21204
  }
21153
- var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21205
+ var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowStepsFailedSerialization, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21154
21206
  var init_semantic_conventions = __esm({
21155
21207
  "../core/dist/telemetry/semantic-conventions.js"() {
21156
21208
  "use strict";
@@ -21183,6 +21235,7 @@ var init_semantic_conventions = __esm({
21183
21235
  WorkflowStepsCreated = SemanticConvention("workflow.steps.created");
21184
21236
  WorkflowHooksCreated = SemanticConvention("workflow.hooks.created");
21185
21237
  WorkflowWaitsCreated = SemanticConvention("workflow.waits.created");
21238
+ WorkflowStepsFailedSerialization = SemanticConvention("workflow.steps.failed_serialization");
21186
21239
  WorkflowOwnedRecoverySteps = SemanticConvention("workflow.inline_ownership.owned_recovery_steps");
21187
21240
  WorkflowBackstopWakesArmed = SemanticConvention("workflow.inline_ownership.backstop_wakes_armed");
21188
21241
  WorkflowRouteType = SemanticConvention("workflow.route.type");
@@ -23437,7 +23490,7 @@ async function linkToTraceCarrier(carrier) {
23437
23490
  context
23438
23491
  };
23439
23492
  }
23440
- var OtelApi, Tracer, StepExecutionDurationHistogram, otelDiagLogged;
23493
+ var traceModeWarnings, OtelApi, Tracer, StepExecutionDurationHistogram, otelDiagLogged;
23441
23494
  var init_telemetry = __esm({
23442
23495
  "../core/dist/telemetry.js"() {
23443
23496
  "use strict";
@@ -23445,6 +23498,9 @@ var init_telemetry = __esm({
23445
23498
  init_global();
23446
23499
  init_logger();
23447
23500
  init_semantic_conventions();
23501
+ traceModeWarnings = globalSingleton("@workflow/core//traceModeWarnings", 1, () => ({
23502
+ unrecognized: /* @__PURE__ */ new Set()
23503
+ }));
23448
23504
  __name(serializeTraceCarrier, "serializeTraceCarrier");
23449
23505
  __name(deserializeTraceCarrier, "deserializeTraceCarrier");
23450
23506
  OtelApi = once(async () => {
@@ -23739,7 +23795,6 @@ function getAbortStreamId(id) {
23739
23795
  var init_util2 = __esm({
23740
23796
  "../core/dist/util.js"() {
23741
23797
  "use strict";
23742
- init_dist();
23743
23798
  __name(getWorkflowRunStreamId, "getWorkflowRunStreamId");
23744
23799
  __name(getAbortStreamId, "getAbortStreamId");
23745
23800
  }
@@ -23797,7 +23852,7 @@ var init_abort_controller = __esm({
23797
23852
  /**
23798
23853
  * @internal Sets aborted state and fires listeners.
23799
23854
  * Called by abort() on first-run, or by the events consumer on replay.
23800
- * Idempotent — second call is a no-op.
23855
+ * Idempotent: second call is a no-op.
23801
23856
  */
23802
23857
  _setAborted(reason) {
23803
23858
  if (this.aborted) return;
@@ -25840,7 +25895,7 @@ var init_capabilities = __esm({
25840
25895
  // bump to the next beta. A too-low cutoff makes new producers write
25841
25896
  // compressed payloads to consumers that cannot decompress them; too-high
25842
25897
  // merely delays the optimization (safe). gzip and zstd ship together, so
25843
- // they share a min version — a run that can read one can read both.
25898
+ // they share a min version: a run that can read one can read both.
25844
25899
  {
25845
25900
  format: SerializationFormat.GZIP,
25846
25901
  minVersion: "5.0.0-beta.18"
@@ -25923,7 +25978,7 @@ var version2;
25923
25978
  var init_version = __esm({
25924
25979
  "../core/dist/version.js"() {
25925
25980
  "use strict";
25926
- version2 = "5.0.0-beta.43";
25981
+ version2 = "5.0.0-beta.44";
25927
25982
  }
25928
25983
  });
25929
25984
 
@@ -32020,7 +32075,7 @@ function getWorkflowReducers(global2 = globalThis) {
32020
32075
  return {
32021
32076
  ...getAllBaseReducers(global2),
32022
32077
  // Readable/Writable streams from within the workflow execution environment
32023
- // are simply "handles" that can be passed around to other steps.
32078
+ // are "handles" that can be passed around to other steps.
32024
32079
  ReadableStream: /* @__PURE__ */ __name((value) => {
32025
32080
  if (!isInstanceOfPrototype(value, readableStreamPrototype.value)) return false;
32026
32081
  const bodyInit = readProperty(value, BODY_INIT_SYMBOL);
@@ -32063,7 +32118,7 @@ function getWorkflowReducers(global2 = globalThis) {
32063
32118
  }
32064
32119
  return s;
32065
32120
  }, "WritableStream"),
32066
- // AbortController/AbortSignal in workflow context — just read symbols (handles).
32121
+ // AbortController/AbortSignal in workflow context: read only symbols (handles).
32067
32122
  // In the workflow VM, global.AbortController is a class but global.AbortSignal
32068
32123
  // is a plain object (not a class), so instanceof checks won't work for signals.
32069
32124
  // Detect instances by the presence of the ABORT_STREAM_NAME symbol instead.
@@ -32420,7 +32475,7 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
32420
32475
  // arrow steps). The wrapper invokes the body via
32421
32476
  // `stepFn.apply(boundThis, args)` so the body sees the same
32422
32477
  // `this` it would have had in the workflow bundle. Property
32423
- // presence — not truthiness — is significant because
32478
+ // presence, not truthiness, is significant because
32424
32479
  // `bind(null)` and `bind(undefined)` are both legal and should
32425
32480
  // round-trip faithfully.
32426
32481
  // - `boundArgs`: prefilled args from
@@ -33208,6 +33263,7 @@ init_helpers();
33208
33263
 
33209
33264
  // ../core/dist/runtime/start.js
33210
33265
  init_dist2();
33266
+ init_dist();
33211
33267
  init_parse_name();
33212
33268
  init_dist4();
33213
33269
  init_node();
@@ -33284,7 +33340,9 @@ function resolveLineageAttributes() {
33284
33340
  };
33285
33341
  }
33286
33342
  __name(resolveLineageAttributes, "resolveLineageAttributes");
33287
- var hasWarnedLatestNoOp = false;
33343
+ var latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1, () => ({
33344
+ warned: false
33345
+ }));
33288
33346
  async function start(workflow, argsOrOptions, options) {
33289
33347
  return await waitedUntil(() => {
33290
33348
  const workflowName = workflow?.workflowId;
@@ -33317,8 +33375,8 @@ async function start(workflow, argsOrOptions, options) {
33317
33375
  if (world.resolveLatestDeploymentId) {
33318
33376
  deploymentId = await world.resolveLatestDeploymentId();
33319
33377
  } else {
33320
- if (!hasWarnedLatestNoOp) {
33321
- hasWarnedLatestNoOp = true;
33378
+ if (!latestNoOpWarning.warned) {
33379
+ latestNoOpWarning.warned = true;
33322
33380
  runtimeLogger.warn("deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.", {
33323
33381
  currentDeploymentId
33324
33382
  });
@@ -33419,7 +33477,7 @@ async function start(workflow, argsOrOptions, options) {
33419
33477
  // resumeContext by the server) to decide whether the parallel fast
33420
33478
  // path is safe. For a cross-deployment start the consumer is the
33421
33479
  // target deployment, so we stamp the *target's* value carried back on
33422
- // the health-check probe — never the caller's. Omitted when we could
33480
+ // the health-check probe, never the caller's. Omitted when we could
33423
33481
  // not attest the target (older target, timeout, or no probe channel),
33424
33482
  // which fails the resume gate closed to the sequential path.
33425
33483
  ...targetHookResumeInputVersion !== void 0 ? {
@@ -33528,7 +33586,7 @@ __name(start, "start");
33528
33586
  value: "start",
33529
33587
  configurable: true
33530
33588
  });
33531
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.43//start");
33589
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.44//start");
33532
33590
 
33533
33591
  // ../core/dist/runtime/runs.js
33534
33592
  async function wakeUpRun(world, runId, options) {
@@ -33626,6 +33684,28 @@ function getReturnValuePollIntervalMs() {
33626
33684
  });
33627
33685
  }
33628
33686
  __name(getReturnValuePollIntervalMs, "getReturnValuePollIntervalMs");
33687
+ var RETURN_VALUE_WAIT_TIMEOUT_MS = 5e4;
33688
+ function getReturnValueWaitTimeoutMs() {
33689
+ return envNumber("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS, {
33690
+ integer: true,
33691
+ min: 1
33692
+ });
33693
+ }
33694
+ __name(getReturnValueWaitTimeoutMs, "getReturnValueWaitTimeoutMs");
33695
+ var RETURN_VALUE_MAX_LONG_POLLS = 10;
33696
+ function getReturnValueMaxLongPolls() {
33697
+ return envNumber("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS, {
33698
+ integer: true,
33699
+ min: 1
33700
+ });
33701
+ }
33702
+ __name(getReturnValueMaxLongPolls, "getReturnValueMaxLongPolls");
33703
+ function isReturnValueLongPollEnabled() {
33704
+ const raw = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
33705
+ if (raw === void 0 || raw === "") return true;
33706
+ return !(raw === "0" || raw.toLowerCase() === "false");
33707
+ }
33708
+ __name(isReturnValueLongPollEnabled, "isReturnValueLongPollEnabled");
33629
33709
  var Run = class _Run {
33630
33710
  static {
33631
33711
  __name(this, "Run");
@@ -33750,7 +33830,7 @@ var Run = class _Run {
33750
33830
  }
33751
33831
  /**
33752
33832
  * The return value of the workflow run.
33753
- * Polls the workflow return value until it is completed.
33833
+ * Polls the workflow return value until the workflow run completes.
33754
33834
  */
33755
33835
  get returnValue() {
33756
33836
  return this.#pollReturnValue();
@@ -33841,7 +33921,7 @@ var Run = class _Run {
33841
33921
  throw new WorkflowRunNotCompletedError(this.runId, run2.status);
33842
33922
  }
33843
33923
  /**
33844
- * Polls the workflow return value until it is completed.
33924
+ * Polls the workflow return value until the workflow run completes.
33845
33925
  * @internal
33846
33926
  * @returns The workflow return value.
33847
33927
  */
@@ -33854,9 +33934,18 @@ var Run = class _Run {
33854
33934
  3e3,
33855
33935
  6e3
33856
33936
  ];
33937
+ const waitForTerminalStatus = isReturnValueLongPollEnabled() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
33938
+ let longPolls = 0;
33939
+ const maxLongPolls = getReturnValueMaxLongPolls();
33857
33940
  while (true) {
33941
+ const iterationStartedAt = Date.now();
33858
33942
  try {
33859
- const runMetadata = await world.runs.get(this.runId, {
33943
+ const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
33944
+ if (useLongPoll) longPolls++;
33945
+ const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
33946
+ timeoutMs: getReturnValueWaitTimeoutMs(),
33947
+ resolveData: "none"
33948
+ }) : await world.runs.get(this.runId, {
33860
33949
  resolveData: "none"
33861
33950
  });
33862
33951
  if (runMetadata.status === "cancelled") {
@@ -33871,7 +33960,10 @@ var Run = class _Run {
33871
33960
  throw new WorkflowRunNotCompletedError(this.runId, runMetadata.status);
33872
33961
  } catch (error48) {
33873
33962
  if (WorkflowRunNotCompletedError.is(error48)) {
33874
- await new Promise((resolve) => setTimeout(resolve, getReturnValuePollIntervalMs()));
33963
+ const remainingIntervalMs = getReturnValuePollIntervalMs() - (Date.now() - iterationStartedAt);
33964
+ if (remainingIntervalMs > 0) {
33965
+ await new Promise((resolve) => setTimeout(resolve, remainingIntervalMs));
33966
+ }
33875
33967
  continue;
33876
33968
  }
33877
33969
  if (WorkflowRunNotFoundError.is(error48) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
@@ -33893,7 +33985,7 @@ var Run = class _Run {
33893
33985
  value: "wakeUp",
33894
33986
  configurable: true
33895
33987
  });
33896
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#wakeUp");
33988
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#wakeUp");
33897
33989
  (function(__wf_fn, __wf_id) {
33898
33990
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33899
33991
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33902,7 +33994,7 @@ var Run = class _Run {
33902
33994
  value: "cancel",
33903
33995
  configurable: true
33904
33996
  });
33905
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#cancel");
33997
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#cancel");
33906
33998
  (function(__wf_fn, __wf_id) {
33907
33999
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33908
34000
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33911,7 +34003,7 @@ var Run = class _Run {
33911
34003
  value: "getReadable",
33912
34004
  configurable: true
33913
34005
  });
33914
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#getReadable");
34006
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#getReadable");
33915
34007
  (function(__wf_fn, __wf_id) {
33916
34008
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33917
34009
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33920,7 +34012,7 @@ var Run = class _Run {
33920
34012
  value: "exists",
33921
34013
  configurable: true
33922
34014
  });
33923
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#exists");
34015
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#exists");
33924
34016
  (function(__wf_fn, __wf_id) {
33925
34017
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33926
34018
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33929,7 +34021,7 @@ var Run = class _Run {
33929
34021
  value: "status",
33930
34022
  configurable: true
33931
34023
  });
33932
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#status");
34024
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#status");
33933
34025
  (function(__wf_fn, __wf_id) {
33934
34026
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33935
34027
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33938,7 +34030,7 @@ var Run = class _Run {
33938
34030
  value: "returnValue",
33939
34031
  configurable: true
33940
34032
  });
33941
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#returnValue");
34033
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#returnValue");
33942
34034
  (function(__wf_fn, __wf_id) {
33943
34035
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33944
34036
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33947,7 +34039,7 @@ var Run = class _Run {
33947
34039
  value: "workflowName",
33948
34040
  configurable: true
33949
34041
  });
33950
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#workflowName");
34042
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#workflowName");
33951
34043
  (function(__wf_fn, __wf_id) {
33952
34044
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33953
34045
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33956,7 +34048,7 @@ var Run = class _Run {
33956
34048
  value: "createdAt",
33957
34049
  configurable: true
33958
34050
  });
33959
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#createdAt");
34051
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#createdAt");
33960
34052
  (function(__wf_fn, __wf_id) {
33961
34053
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33962
34054
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33965,7 +34057,7 @@ var Run = class _Run {
33965
34057
  value: "startedAt",
33966
34058
  configurable: true
33967
34059
  });
33968
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#startedAt");
34060
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#startedAt");
33969
34061
  (function(__wf_fn, __wf_id) {
33970
34062
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33971
34063
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33974,7 +34066,7 @@ var Run = class _Run {
33974
34066
  value: "completedAt",
33975
34067
  configurable: true
33976
34068
  });
33977
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.43//Run#completedAt");
34069
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.44//Run#completedAt");
33978
34070
  (function(__wf_cls, __wf_id) {
33979
34071
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33980
34072
  __wf_reg.set(__wf_id, __wf_cls);
@@ -33984,7 +34076,7 @@ var Run = class _Run {
33984
34076
  enumerable: false,
33985
34077
  configurable: false
33986
34078
  });
33987
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.43//Run");
34079
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.44//Run");
33988
34080
 
33989
34081
  // ../workflow/dist/stdlib.js
33990
34082
  async function fetch2(...args) {
@@ -34107,7 +34199,7 @@ var ContextViolationError = class extends Error {
34107
34199
  static {
34108
34200
  __name(this, "ContextViolationError");
34109
34201
  }
34110
- /** Non-retryable — see class doc. */
34202
+ /** Non-retryable, see class doc. */
34111
34203
  fatal = true;
34112
34204
  #content;
34113
34205
  constructor(content) {