@workflow/world-testing 5.0.0-beta.20 → 5.0.0-beta.21

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.
@@ -19192,7 +19192,7 @@ var version4;
19192
19192
  var init_version3 = __esm({
19193
19193
  "../core/dist/version.js"() {
19194
19194
  "use strict";
19195
- version4 = "5.0.0-beta.20";
19195
+ version4 = "5.0.0-beta.21";
19196
19196
  }
19197
19197
  });
19198
19198
 
@@ -21663,18 +21663,23 @@ function createCreateAbortController(ctx) {
21663
21663
  }
21664
21664
  if (event.eventType === "hook_received") {
21665
21665
  const rawPayload = event.eventData?.payload;
21666
+ ctx.pendingDeliveries++;
21666
21667
  ctx.promiseQueue = ctx.promiseQueue.then(async () => {
21667
21668
  let reason;
21668
- if (rawPayload !== void 0) {
21669
- try {
21670
- const hydrated = await hydrateStepReturnValue(rawPayload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
21671
- if (hydrated && typeof hydrated === "object" && "reason" in hydrated) {
21672
- reason = hydrated.reason;
21669
+ try {
21670
+ if (rawPayload !== void 0) {
21671
+ try {
21672
+ const hydrated = await hydrateStepReturnValue(rawPayload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
21673
+ if (hydrated && typeof hydrated === "object" && "reason" in hydrated) {
21674
+ reason = hydrated.reason;
21675
+ }
21676
+ } catch {
21673
21677
  }
21674
- } catch {
21675
21678
  }
21679
+ this.signal._setAborted(reason);
21680
+ } finally {
21681
+ ctx.pendingDeliveries--;
21676
21682
  }
21677
- this.signal._setAborted(reason);
21678
21683
  });
21679
21684
  ctx.invocationsQueue.delete(correlationId);
21680
21685
  return EventConsumerResult2.Consumed;
@@ -25798,7 +25803,7 @@ function reviveAbortController2(value, ops, runId) {
25798
25803
  }
25799
25804
  })());
25800
25805
  if (value.hookToken) {
25801
- ctx.ops.push((async () => {
25806
+ const hookResume = (async () => {
25802
25807
  try {
25803
25808
  const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => (init_resume_hook2(), resume_hook_exports2));
25804
25809
  await resumeHookFn(value.hookToken, {
@@ -25807,7 +25812,8 @@ function reviveAbortController2(value, ops, runId) {
25807
25812
  });
25808
25813
  } catch {
25809
25814
  }
25810
- })());
25815
+ })();
25816
+ ctx.preCompletionOps.push(hookResume);
25811
25817
  }
25812
25818
  }
25813
25819
  };
@@ -79542,7 +79548,7 @@ var version2;
79542
79548
  var init_version = __esm2({
79543
79549
  "../core/dist/version.js"() {
79544
79550
  "use strict";
79545
- version2 = "5.0.0-beta.20";
79551
+ version2 = "5.0.0-beta.21";
79546
79552
  }
79547
79553
  });
79548
79554
  function getWorkflowQueueName(workflowName, namespace) {
@@ -81767,7 +81773,7 @@ function reviveAbortController(value, ops, runId) {
81767
81773
  }
81768
81774
  })());
81769
81775
  if (value.hookToken) {
81770
- ctx.ops.push((async () => {
81776
+ const hookResume = (async () => {
81771
81777
  try {
81772
81778
  const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => (init_resume_hook(), resume_hook_exports));
81773
81779
  await resumeHookFn(value.hookToken, {
@@ -81776,7 +81782,8 @@ function reviveAbortController(value, ops, runId) {
81776
81782
  });
81777
81783
  } catch {
81778
81784
  }
81779
- })());
81785
+ })();
81786
+ ctx.preCompletionOps.push(hookResume);
81780
81787
  }
81781
81788
  }
81782
81789
  };
@@ -82772,7 +82779,7 @@ __name2(start, "start");
82772
82779
  value: "start",
82773
82780
  configurable: true
82774
82781
  });
82775
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.20//start");
82782
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.21//start");
82776
82783
  function isRetryableStartError(err) {
82777
82784
  if (ThrottleError.is(err)) return true;
82778
82785
  if (WorkflowWorldError.is(err) && err.status && err.status >= 500) return true;
@@ -83106,7 +83113,7 @@ var Run = class _Run {
83106
83113
  value: "wakeUp",
83107
83114
  configurable: true
83108
83115
  });
83109
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#wakeUp");
83116
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#wakeUp");
83110
83117
  (function(__wf_fn, __wf_id) {
83111
83118
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83112
83119
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83115,7 +83122,7 @@ var Run = class _Run {
83115
83122
  value: "cancel",
83116
83123
  configurable: true
83117
83124
  });
83118
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#cancel");
83125
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#cancel");
83119
83126
  (function(__wf_fn, __wf_id) {
83120
83127
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83121
83128
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83124,7 +83131,7 @@ var Run = class _Run {
83124
83131
  value: "getReadable",
83125
83132
  configurable: true
83126
83133
  });
83127
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#getReadable");
83134
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#getReadable");
83128
83135
  (function(__wf_fn, __wf_id) {
83129
83136
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83130
83137
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83133,7 +83140,7 @@ var Run = class _Run {
83133
83140
  value: "exists",
83134
83141
  configurable: true
83135
83142
  });
83136
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#exists");
83143
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#exists");
83137
83144
  (function(__wf_fn, __wf_id) {
83138
83145
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83139
83146
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83142,7 +83149,7 @@ var Run = class _Run {
83142
83149
  value: "status",
83143
83150
  configurable: true
83144
83151
  });
83145
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#status");
83152
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#status");
83146
83153
  (function(__wf_fn, __wf_id) {
83147
83154
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83148
83155
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83151,7 +83158,7 @@ var Run = class _Run {
83151
83158
  value: "returnValue",
83152
83159
  configurable: true
83153
83160
  });
83154
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#returnValue");
83161
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#returnValue");
83155
83162
  (function(__wf_fn, __wf_id) {
83156
83163
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83157
83164
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83160,7 +83167,7 @@ var Run = class _Run {
83160
83167
  value: "workflowName",
83161
83168
  configurable: true
83162
83169
  });
83163
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#workflowName");
83170
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#workflowName");
83164
83171
  (function(__wf_fn, __wf_id) {
83165
83172
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83166
83173
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83169,7 +83176,7 @@ var Run = class _Run {
83169
83176
  value: "createdAt",
83170
83177
  configurable: true
83171
83178
  });
83172
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#createdAt");
83179
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#createdAt");
83173
83180
  (function(__wf_fn, __wf_id) {
83174
83181
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83175
83182
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83178,7 +83185,7 @@ var Run = class _Run {
83178
83185
  value: "startedAt",
83179
83186
  configurable: true
83180
83187
  });
83181
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#startedAt");
83188
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#startedAt");
83182
83189
  (function(__wf_fn, __wf_id) {
83183
83190
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83184
83191
  __wf_reg.set(__wf_id, __wf_fn);
@@ -83187,7 +83194,7 @@ var Run = class _Run {
83187
83194
  value: "completedAt",
83188
83195
  configurable: true
83189
83196
  });
83190
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#completedAt");
83197
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#completedAt");
83191
83198
  (function(__wf_cls, __wf_id) {
83192
83199
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
83193
83200
  __wf_reg.set(__wf_id, __wf_cls);
@@ -83197,7 +83204,7 @@ var Run = class _Run {
83197
83204
  enumerable: false,
83198
83205
  configurable: false
83199
83206
  });
83200
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.20//Run");
83207
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.21//Run");
83201
83208
  async function fetch2(...args) {
83202
83209
  return globalThis.fetch(...args);
83203
83210
  }
@@ -84039,6 +84046,20 @@ function isOptimisticInlineStartEnabled() {
84039
84046
  return raw === "1" || raw.toLowerCase() === "true";
84040
84047
  }
84041
84048
  __name(isOptimisticInlineStartEnabled, "isOptimisticInlineStartEnabled");
84049
+ function isOptimisticInlineStartExplicitlyDisabled() {
84050
+ const raw = process.env.WORKFLOW_OPTIMISTIC_INLINE_START;
84051
+ if (raw === void 0 || raw === "")
84052
+ return false;
84053
+ return raw === "0" || raw.toLowerCase() === "false";
84054
+ }
84055
+ __name(isOptimisticInlineStartExplicitlyDisabled, "isOptimisticInlineStartExplicitlyDisabled");
84056
+ function isTurboEnabled() {
84057
+ const raw = process.env.WORKFLOW_TURBO;
84058
+ if (raw === void 0 || raw === "")
84059
+ return true;
84060
+ return !(raw === "0" || raw.toLowerCase() === "false");
84061
+ }
84062
+ __name(isTurboEnabled, "isTurboEnabled");
84042
84063
  var REPLAY_DIVERGENCE_MAX_RETRIES = 3;
84043
84064
 
84044
84065
  // ../core/dist/runtime.js
@@ -96291,6 +96312,10 @@ async function executeStep(params) {
96291
96312
  });
96292
96313
  if (params.lazyStepInput !== void 0) {
96293
96314
  try {
96315
+ if (params.runReadyBarrier) {
96316
+ await params.runReadyBarrier.catch(() => {
96317
+ });
96318
+ }
96294
96319
  await world.events.create(workflowRunId, {
96295
96320
  eventType: "step_started",
96296
96321
  specVersion: SPEC_VERSION_CURRENT2,
@@ -96369,7 +96394,7 @@ async function executeStep(params) {
96369
96394
  }
96370
96395
  return void 0;
96371
96396
  }, "startErrorToResult");
96372
- const optimisticStart = params.lazyStepInput !== void 0 && isOptimisticInlineStartEnabled();
96397
+ const optimisticStart = params.lazyStepInput !== void 0 && (isOptimisticInlineStartEnabled() || params.forceOptimisticStart === true && !isOptimisticInlineStartExplicitlyDisabled());
96373
96398
  let step;
96374
96399
  let optimisticStartSettled;
96375
96400
  const reconcileOptimisticStart = /* @__PURE__ */ __name(async () => {
@@ -96384,12 +96409,12 @@ async function executeStep(params) {
96384
96409
  return mapped;
96385
96410
  }, "reconcileOptimisticStart");
96386
96411
  if (optimisticStart) {
96387
- const startedPromise = world.events.create(workflowRunId, {
96412
+ const startedPromise = (params.runReadyBarrier ?? Promise.resolve()).then(() => world.events.create(workflowRunId, {
96388
96413
  eventType: "step_started",
96389
96414
  specVersion: SPEC_VERSION_CURRENT2,
96390
96415
  correlationId: stepId,
96391
96416
  eventData: { stepName, workflowName, input: params.lazyStepInput }
96392
- });
96417
+ }));
96393
96418
  optimisticStartSettled = startedPromise.then(() => ({ ok: true }), (err) => ({ ok: false, err }));
96394
96419
  const now = /* @__PURE__ */ new Date();
96395
96420
  step = {
@@ -96475,6 +96500,7 @@ async function executeStep(params) {
96475
96500
  });
96476
96501
  return { type: "failed" };
96477
96502
  }
96503
+ const preCompletionOps = [];
96478
96504
  try {
96479
96505
  const attempt = step.attempt;
96480
96506
  if (!step.startedAt) {
@@ -96514,6 +96540,7 @@ async function executeStep(params) {
96514
96540
  },
96515
96541
  workflowDeploymentId: params.workflowDeploymentId,
96516
96542
  ops,
96543
+ preCompletionOps,
96517
96544
  closureVars: hydratedInput.closureVars,
96518
96545
  encryptionKey
96519
96546
  }, () => stepFn.apply(thisVal, args));
@@ -96557,6 +96584,10 @@ async function executeStep(params) {
96557
96584
  if (reconcile)
96558
96585
  return reconcile;
96559
96586
  }
96587
+ if (preCompletionOps.length > 0) {
96588
+ await Promise.all(preCompletionOps).catch(() => {
96589
+ });
96590
+ }
96560
96591
  let stepCompleted409 = false;
96561
96592
  const completedResult = await world.events.create(workflowRunId, {
96562
96593
  eventType: "step_completed",
@@ -96602,6 +96633,10 @@ async function executeStep(params) {
96602
96633
  if (reconcile)
96603
96634
  return reconcile;
96604
96635
  }
96636
+ if (preCompletionOps.length > 0) {
96637
+ await Promise.all(preCompletionOps).catch(() => {
96638
+ });
96639
+ }
96605
96640
  const effectiveErr = promoteAbortErrorToFatal(err);
96606
96641
  const normalizedError = await normalizeUnknownError(effectiveErr);
96607
96642
  const normalizedStack = normalizedError.stack || getErrorStack(effectiveErr) || "";
@@ -96804,8 +96839,16 @@ async function createHookEvent({ world, runId, hookEvent, queueItem, requestId }
96804
96839
  }
96805
96840
  }
96806
96841
  __name(createHookEvent, "createHookEvent");
96807
- async function handleSuspension({ suspension, world, run: run3, span, requestId }) {
96842
+ async function handleSuspension({ suspension, world, run: run3, span, requestId, runReadyBarrier }) {
96808
96843
  const runId = run3.runId;
96844
+ const ensureRunReady = /* @__PURE__ */ __name(async () => {
96845
+ if (runReadyBarrier) {
96846
+ try {
96847
+ await runReadyBarrier;
96848
+ } catch {
96849
+ }
96850
+ }
96851
+ }, "ensureRunReady");
96809
96852
  const stepItems = suspension.steps.filter((item) => item.type === "step");
96810
96853
  const allHookItems = suspension.steps.filter((item) => item.type === "hook");
96811
96854
  const waitItems = suspension.steps.filter((item) => item.type === "wait");
@@ -96835,6 +96878,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96835
96878
  let hasHookConflict = false;
96836
96879
  let hasAwaitedHookCreation = false;
96837
96880
  if (hookEvents.length > 0) {
96881
+ await ensureRunReady();
96838
96882
  const results = await Promise.all(hookEvents.map(({ hookEvent, queueItem }) => createHookEvent({
96839
96883
  world,
96840
96884
  runId,
@@ -96846,6 +96890,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96846
96890
  hasAwaitedHookCreation = results.some((result) => result.hasAwaitedHookCreation);
96847
96891
  }
96848
96892
  if (hooksNeedingDisposal.length > 0) {
96893
+ await ensureRunReady();
96849
96894
  await Promise.all(hooksNeedingDisposal.map(async (queueItem) => {
96850
96895
  const hookDisposedEvent = {
96851
96896
  eventType: "hook_disposed",
@@ -96884,6 +96929,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96884
96929
  }
96885
96930
  const hooksNeedingAbort = allHookItems.filter((item) => item.abortRequested && !item.disposed);
96886
96931
  if (hooksNeedingAbort.length > 0) {
96932
+ await ensureRunReady();
96887
96933
  await Promise.all(hooksNeedingAbort.map(async (queueItem) => {
96888
96934
  try {
96889
96935
  const abortPayload = await dehydrateStepArguments2({ aborted: true, reason: queueItem.abortReason }, runId, encryptionKey, suspension.globalThis, false, compression);
@@ -96951,6 +96997,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96951
96997
  }
96952
96998
  };
96953
96999
  try {
97000
+ await ensureRunReady();
96954
97001
  await world.events.create(runId, stepEvent, { requestId });
96955
97002
  createdStepCorrelationIds.add(queueItem.correlationId);
96956
97003
  } catch (err) {
@@ -96979,6 +97026,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96979
97026
  }
96980
97027
  };
96981
97028
  try {
97029
+ await ensureRunReady();
96982
97030
  await world.events.create(runId, waitEvent, { requestId });
96983
97031
  } catch (err) {
96984
97032
  if (EntityConflictError2.is(err)) {
@@ -96997,6 +97045,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
96997
97045
  for (const queueItem of attributeItems) {
96998
97046
  ops.push((async () => {
96999
97047
  try {
97048
+ await ensureRunReady();
97000
97049
  await world.events.create(runId, {
97001
97050
  eventType: "attr_set",
97002
97051
  specVersion: SPEC_VERSION_CURRENT2,
@@ -97059,7 +97108,8 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
97059
97108
  waitTimeout: hasHookConflict ? void 0 : soonestWait,
97060
97109
  hasHookConflict,
97061
97110
  hasAwaitedHookCreation,
97062
- hasAttributeEvents: attributeItems.length > 0
97111
+ hasAttributeEvents: attributeItems.length > 0,
97112
+ hasHookEvents: hookEvents.length > 0
97063
97113
  };
97064
97114
  }
97065
97115
  __name(handleSuspension, "handleSuspension");
@@ -97697,6 +97747,42 @@ function remapErrorStack(stack, filename, workflowCode2) {
97697
97747
  }
97698
97748
  __name(remapErrorStack, "remapErrorStack");
97699
97749
 
97750
+ // ../core/dist/step-hydration-cache.js
97751
+ var MAX_MEMOIZED_PRIMITIVE_LENGTH = 4096;
97752
+ function isMemoizablePrimitive(value) {
97753
+ if (value === null)
97754
+ return true;
97755
+ const t = typeof value;
97756
+ if (t === "object" || t === "function")
97757
+ return false;
97758
+ if (t === "string") {
97759
+ return value.length <= MAX_MEMOIZED_PRIMITIVE_LENGTH;
97760
+ }
97761
+ if (t === "bigint") {
97762
+ return value.toString().length <= MAX_MEMOIZED_PRIMITIVE_LENGTH;
97763
+ }
97764
+ return true;
97765
+ }
97766
+ __name(isMemoizablePrimitive, "isMemoizablePrimitive");
97767
+ function createStepHydrationCache() {
97768
+ return /* @__PURE__ */ new Map();
97769
+ }
97770
+ __name(createStepHydrationCache, "createStepHydrationCache");
97771
+ async function getOrHydrateStepReturnValue(cache, eventId, hydrate) {
97772
+ if (!cache || eventId === void 0) {
97773
+ return hydrate();
97774
+ }
97775
+ if (cache.has(eventId)) {
97776
+ return cache.get(eventId);
97777
+ }
97778
+ const value = await hydrate();
97779
+ if (isMemoizablePrimitive(value)) {
97780
+ cache.set(eventId, value);
97781
+ }
97782
+ return value;
97783
+ }
97784
+ __name(getOrHydrateStepReturnValue, "getOrHydrateStepReturnValue");
97785
+
97700
97786
  // ../core/dist/runtime.js
97701
97787
  init_semantic_conventions2();
97702
97788
  init_telemetry2();
@@ -97844,10 +97930,12 @@ function createUseStep(ctx) {
97844
97930
  }
97845
97931
  if (event.eventType === "step_completed") {
97846
97932
  ctx.invocationsQueue.delete(event.correlationId);
97933
+ const completedEventId = event.eventId;
97934
+ const serializedResult = event.eventData.result;
97847
97935
  ctx.pendingDeliveries++;
97848
97936
  ctx.promiseQueue = ctx.promiseQueue.then(async () => {
97849
97937
  try {
97850
- const hydratedResult = await hydrateStepReturnValue(event.eventData.result, ctx.runId, ctx.encryptionKey, ctx.globalThis);
97938
+ const hydratedResult = await getOrHydrateStepReturnValue(ctx.stepHydrationCache, completedEventId, () => hydrateStepReturnValue(serializedResult, ctx.runId, ctx.encryptionKey, ctx.globalThis));
97851
97939
  resolve3(hydratedResult);
97852
97940
  } catch (error95) {
97853
97941
  reject(error95);
@@ -98862,7 +98950,7 @@ async function drainPendingQueueItems(runId, pendingQueue, vmGlobalThis, workflo
98862
98950
  }
98863
98951
  }
98864
98952
  __name(drainPendingQueueItems, "drainPendingQueueItems");
98865
- async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
98953
+ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey, stepHydrationCache) {
98866
98954
  return trace3(`workflow.run ${workflowRun.workflowName}`, async (span) => {
98867
98955
  span?.setAttributes({
98868
98956
  ...WorkflowName2(workflowRun.workflowName),
@@ -98900,7 +98988,16 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
98900
98988
  globalThis: vmGlobalThis,
98901
98989
  onWorkflowError: workflowDiscontinuation.reject,
98902
98990
  eventsConsumer,
98903
- generateUlid: /* @__PURE__ */ __name(() => ulid8(+startedAt), "generateUlid"),
98991
+ // Correlation IDs (step_/wait_/hook_) are derived from `generateUlid`, so
98992
+ // the time prefix fed to `ulid()` MUST be replay-stable across every
98993
+ // delivery — otherwise a redelivery regenerates different correlation IDs
98994
+ // and replay throws ReplayDivergenceError. `startedAt` is NOT safe here:
98995
+ // under turbo the first delivery synthesizes `startedAt` from the local
98996
+ // clock, but later (non-turbo) deliveries load the server-canonical
98997
+ // `startedAt`, which differs by >=1ms. Use the same replay-stable value
98998
+ // that already seeds the RNG and the VM clock (`fixedTimestamp`, recovered
98999
+ // from the run ID's ULID and known the instant the message arrives).
99000
+ generateUlid: /* @__PURE__ */ __name(() => ulid8(fixedTimestamp), "generateUlid"),
98904
99001
  generateNanoid,
98905
99002
  invocationsQueue: /* @__PURE__ */ new Map(),
98906
99003
  // Use getter/setter so the EventsConsumer's getPromiseQueue() always
@@ -98912,7 +99009,8 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
98912
99009
  promiseQueueHolder.current = value;
98913
99010
  },
98914
99011
  pendingDeliveries: 0,
98915
- pendingDeliveryBarriers: /* @__PURE__ */ new Map()
99012
+ pendingDeliveryBarriers: /* @__PURE__ */ new Map(),
99013
+ stepHydrationCache
98916
99014
  };
98917
99015
  workflowContext.eventsConsumer.subscribe((event) => {
98918
99016
  if (!event) {
@@ -99877,11 +99975,32 @@ function workflowEntrypoint(workflowCode2, options) {
99877
99975
  let loopIteration = 0;
99878
99976
  let cachedEvents = null;
99879
99977
  let eventsCursor = null;
99978
+ const stepHydrationCache = createStepHydrationCache();
99880
99979
  let pendingInlineDelta = null;
99881
99980
  let workflowRun;
99882
99981
  let workflowStartedAt = -1;
99883
99982
  let preloadedEvents;
99884
99983
  let preloadedEventsCursor;
99984
+ const turbo = isTurboEnabled() && runInput !== void 0 && metadata.attempt === 1 && incomingStepId === void 0 && !replayDivergence;
99985
+ let runReadyBarrier;
99986
+ const awaitRunReady = /* @__PURE__ */ __name(async () => {
99987
+ if (runReadyBarrier) {
99988
+ try {
99989
+ await runReadyBarrier;
99990
+ } catch {
99991
+ }
99992
+ }
99993
+ }, "awaitRunReady");
99994
+ const reinvoke = /* @__PURE__ */ __name(async (delaySeconds) => {
99995
+ if (!turbo)
99996
+ return { timeoutSeconds: delaySeconds };
99997
+ await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
99998
+ runId,
99999
+ traceCarrier: await nextTraceCarrier(),
100000
+ requestedAt: /* @__PURE__ */ new Date()
100001
+ }, delaySeconds > 0 ? { delaySeconds } : void 0);
100002
+ return void 0;
100003
+ }, "reinvoke");
99885
100004
  if (incomingStepId && incomingStepName) {
99886
100005
  try {
99887
100006
  const bgRun = await world.runs.get(runId);
@@ -99968,72 +100087,112 @@ function workflowEntrypoint(workflowCode2, options) {
99968
100087
  }
99969
100088
  }
99970
100089
  if (!workflowRun) {
99971
- try {
99972
- const result = await world.events.create(runId, {
99973
- eventType: "run_started",
99974
- // Use the spec version from the original start() call
99975
- // when available, so the resilient start path creates
99976
- // the run with the correct version (not always current).
99977
- specVersion: runInput?.specVersion ?? SPEC_VERSION_CURRENT2,
99978
- // Pass run input from queue so the server can
99979
- // create the run if run_created was missed.
99980
- // Uint8Array values survive the queue natively
99981
- // (CBOR on world-vercel, JSON reviver on world-local).
99982
- ...runInput ? {
99983
- eventData: {
99984
- input: runInput.input,
99985
- deploymentId: runInput.deploymentId,
99986
- workflowName: runInput.workflowName,
99987
- executionContext: runInput.executionContext,
99988
- attributes: runInput.attributes,
99989
- allowReservedAttributes: runInput.allowReservedAttributes
100090
+ const runStartedEvent = {
100091
+ eventType: "run_started",
100092
+ // Use the spec version from the original start() call
100093
+ // when available, so the resilient start path creates
100094
+ // the run with the correct version (not always current).
100095
+ specVersion: runInput?.specVersion ?? SPEC_VERSION_CURRENT2,
100096
+ // Pass run input from queue so the server can
100097
+ // create the run if run_created was missed.
100098
+ // Uint8Array values survive the queue natively
100099
+ // (CBOR on world-vercel, JSON reviver on world-local).
100100
+ ...runInput ? {
100101
+ eventData: {
100102
+ input: runInput.input,
100103
+ deploymentId: runInput.deploymentId,
100104
+ workflowName: runInput.workflowName,
100105
+ executionContext: runInput.executionContext,
100106
+ attributes: runInput.attributes,
100107
+ allowReservedAttributes: runInput.allowReservedAttributes
100108
+ }
100109
+ } : {}
100110
+ };
100111
+ if (turbo && runInput) {
100112
+ const startedPromise = world.events.create(runId, runStartedEvent, { requestId });
100113
+ runReadyBarrier = startedPromise;
100114
+ startedPromise.catch(() => {
100115
+ });
100116
+ preloadedEvents = [];
100117
+ const now = /* @__PURE__ */ new Date();
100118
+ workflowRun = {
100119
+ runId,
100120
+ status: "running",
100121
+ deploymentId: runInput.deploymentId,
100122
+ workflowName: runInput.workflowName,
100123
+ specVersion: runInput.specVersion,
100124
+ executionContext: runInput.executionContext,
100125
+ input: runInput.input,
100126
+ // Seed attributes from start() ride along in `runInput`
100127
+ // (they live in `run_created`'s eventData, not separate
100128
+ // `attr_set` events), so the synthesized snapshot carries
100129
+ // them even though we skip the initial events.list. This
100130
+ // is correct ONLY while attributes are write-only:
100131
+ // there is no in-workflow read API today (see workflow.ts
100132
+ // "structural until a read API is introduced"), so the
100133
+ // empty preloaded log can't diverge on a read. If a read
100134
+ // API is ever added it MUST read from this snapshot, not
100135
+ // by replaying run_created/attr_set events — otherwise
100136
+ // turbo's empty initial log would surface seed attributes
100137
+ // as `{}` on the first delivery only.
100138
+ attributes: runInput.attributes ?? {},
100139
+ startedAt: now,
100140
+ createdAt: now,
100141
+ updatedAt: now
100142
+ };
100143
+ workflowStartedAt = +now;
100144
+ span?.setAttributes({
100145
+ ...WorkflowRunStatus2("running"),
100146
+ ...WorkflowStartedAt2(workflowStartedAt)
100147
+ });
100148
+ } else {
100149
+ try {
100150
+ const result = await world.events.create(runId, runStartedEvent, { requestId });
100151
+ if (!result.run) {
100152
+ throw new WorkflowRuntimeError2(`Event creation for 'run_started' did not return the run entity for run "${runId}"`);
100153
+ }
100154
+ workflowRun = result.run;
100155
+ if (result.events && result.events.length > 0 && result.hasMore !== true) {
100156
+ preloadedEvents = result.events;
100157
+ preloadedEventsCursor = result.cursor;
100158
+ }
100159
+ if (!workflowRun.startedAt) {
100160
+ throw new WorkflowRuntimeError2(`Workflow run "${runId}" has no "startedAt" timestamp`);
100161
+ }
100162
+ } catch (err) {
100163
+ if (EntityConflictError2.is(err) || RunExpiredError.is(err)) {
100164
+ runtimeLogger2.info("Run already finished during setup, skipping", { workflowRunId: runId, message: err.message });
100165
+ return;
100166
+ } else {
100167
+ const errorCode = getWorkflowSetupErrorCode(err);
100168
+ if (!errorCode) {
100169
+ throw err;
99990
100170
  }
99991
- } : {}
99992
- }, { requestId });
99993
- if (!result.run) {
99994
- throw new WorkflowRuntimeError2(`Event creation for 'run_started' did not return the run entity for run "${runId}"`);
99995
- }
99996
- workflowRun = result.run;
99997
- if (result.events && result.events.length > 0 && result.hasMore !== true) {
99998
- preloadedEvents = result.events;
99999
- preloadedEventsCursor = result.cursor;
100000
- }
100001
- if (!workflowRun.startedAt) {
100002
- throw new WorkflowRuntimeError2(`Workflow run "${runId}" has no "startedAt" timestamp`);
100003
- }
100004
- } catch (err) {
100005
- if (EntityConflictError2.is(err) || RunExpiredError.is(err)) {
100006
- runtimeLogger2.info("Run already finished during setup, skipping", { workflowRunId: runId, message: err.message });
100007
- return;
100008
- } else {
100009
- const errorCode = getWorkflowSetupErrorCode(err);
100010
- if (!errorCode) {
100011
- throw err;
100171
+ await recordFatalRunError({
100172
+ world,
100173
+ workflowRun,
100174
+ runId,
100175
+ requestId,
100176
+ err,
100177
+ errorCode,
100178
+ logMessage: "Fatal runtime error during workflow setup"
100179
+ });
100180
+ return;
100012
100181
  }
100013
- await recordFatalRunError({
100014
- world,
100015
- workflowRun,
100016
- runId,
100017
- requestId,
100018
- err,
100019
- errorCode,
100020
- logMessage: "Fatal runtime error during workflow setup"
100182
+ }
100183
+ workflowStartedAt = +workflowRun.startedAt;
100184
+ span?.setAttributes({
100185
+ ...WorkflowRunStatus2(workflowRun.status),
100186
+ ...WorkflowStartedAt2(workflowStartedAt)
100187
+ });
100188
+ if (workflowRun.status !== "running") {
100189
+ runtimeLogger2.info("Workflow already completed or failed, skipping", {
100190
+ workflowRunId: runId,
100191
+ status: workflowRun.status
100021
100192
  });
100022
100193
  return;
100023
100194
  }
100024
100195
  }
100025
- workflowStartedAt = +workflowRun.startedAt;
100026
- span?.setAttributes({
100027
- ...WorkflowRunStatus2(workflowRun.status),
100028
- ...WorkflowStartedAt2(workflowStartedAt)
100029
- });
100030
- if (workflowRun.status !== "running") {
100031
- runtimeLogger2.info("Workflow already completed or failed, skipping", {
100032
- workflowRunId: runId,
100033
- status: workflowRun.status
100034
- });
100035
- return;
100036
- }
100037
100196
  }
100038
100197
  const getEncryptionKey = memoizeEncryptionKey(world, workflowRun);
100039
100198
  const encryptionKey = await getEncryptionKey();
@@ -100180,13 +100339,14 @@ function workflowEntrypoint(workflowCode2, options) {
100180
100339
  eventCount: events.length
100181
100340
  });
100182
100341
  replayStart = Date.now();
100183
- const result = await runWorkflow(workflowCode2, workflowRun, events, encryptionKey);
100342
+ const result = await runWorkflow(workflowCode2, workflowRun, events, encryptionKey, stepHydrationCache);
100184
100343
  runtimeLogger2.debug("Workflow replay completed", {
100185
100344
  workflowRunId: runId,
100186
100345
  loopIteration,
100187
100346
  replayMs: Date.now() - replayStart
100188
100347
  });
100189
100348
  try {
100349
+ await awaitRunReady();
100190
100350
  await world.events.create(runId, {
100191
100351
  eventType: "run_completed",
100192
100352
  specVersion: SPEC_VERSION_CURRENT2,
@@ -100225,7 +100385,8 @@ function workflowEntrypoint(workflowCode2, options) {
100225
100385
  world,
100226
100386
  run: workflowRun,
100227
100387
  span,
100228
- requestId
100388
+ requestId,
100389
+ runReadyBarrier
100229
100390
  });
100230
100391
  } catch (suspensionError) {
100231
100392
  if (!FatalError2.is(suspensionError)) {
@@ -100239,6 +100400,7 @@ function workflowEntrypoint(workflowCode2, options) {
100239
100400
  errorMessage: suspensionError.message
100240
100401
  });
100241
100402
  try {
100403
+ await awaitRunReady();
100242
100404
  await world.events.create(runId, {
100243
100405
  eventType: "run_failed",
100244
100406
  specVersion: SPEC_VERSION_CURRENT2,
@@ -100276,10 +100438,10 @@ function workflowEntrypoint(workflowCode2, options) {
100276
100438
  hasAttributeEvents: suspensionResult.hasAttributeEvents
100277
100439
  });
100278
100440
  if (suspensionResult.hasHookConflict) {
100279
- return { timeoutSeconds: 0 };
100441
+ return await reinvoke(0);
100280
100442
  }
100281
100443
  if (suspensionResult.hasAttributeEvents) {
100282
- return { timeoutSeconds: 0 };
100444
+ return await reinvoke(0);
100283
100445
  }
100284
100446
  const pendingSteps = suspensionResult.pendingSteps;
100285
100447
  const lazyInlineSteps = suspensionResult.lazyInlineSteps;
@@ -100310,11 +100472,12 @@ function workflowEntrypoint(workflowCode2, options) {
100310
100472
  await Promise.all(dispatches);
100311
100473
  if (lazyInlineSteps.length === 0) {
100312
100474
  if (suspensionResult.hasAwaitedHookCreation) {
100313
- return { timeoutSeconds: 0 };
100475
+ return await reinvoke(0);
100314
100476
  }
100315
100477
  return;
100316
100478
  }
100317
100479
  const requestInlineDelta = typeof preInlineWriteCursor === "string" && err.stepCount === 1 && err.hookCount === 0 && err.waitCount === 0 && pendingSteps.length === 1 && lazyInlineSteps.length === 1 && !suspensionResult.waitTimeout && !hasOpenHookOrWait(cachedEvents ?? []);
100480
+ const forceOptimisticStart = turbo && !suspensionResult.waitTimeout && !suspensionResult.hasHookEvents && !suspensionResult.hasAttributeEvents && !suspensionResult.hasAwaitedHookCreation && !hasOpenHookOrWait(cachedEvents ?? []);
100318
100481
  replayBudget.pause();
100319
100482
  let stepResults;
100320
100483
  try {
@@ -100331,6 +100494,12 @@ function workflowEntrypoint(workflowCode2, options) {
100331
100494
  // input on step_started so the world creates the
100332
100495
  // step on the fly.
100333
100496
  lazyStepInput: s.dehydratedInput,
100497
+ // Turbo: force optimistic start and hold the lazy
100498
+ // step_started until the backgrounded run_started
100499
+ // lands (the body still runs immediately). Both
100500
+ // are undefined/false outside turbo.
100501
+ forceOptimisticStart,
100502
+ runReadyBarrier,
100334
100503
  ...requestInlineDelta && preInlineWriteCursor ? {
100335
100504
  inlineDeltaSinceCursor: preInlineWriteCursor
100336
100505
  } : {}
@@ -100356,7 +100525,7 @@ function workflowEntrypoint(workflowCode2, options) {
100356
100525
  }
100357
100526
  }
100358
100527
  if (throttleTimeout !== void 0) {
100359
- return { timeoutSeconds: throttleTimeout };
100528
+ return await reinvoke(throttleTimeout);
100360
100529
  }
100361
100530
  if (toRetry.length > 0) {
100362
100531
  const retryTraceCarrier = await nextTraceCarrier();
@@ -100465,6 +100634,7 @@ function workflowEntrypoint(workflowCode2, options) {
100465
100634
  terminalError.stack = errorStack;
100466
100635
  }
100467
100636
  try {
100637
+ await awaitRunReady();
100468
100638
  await world.events.create(runId, {
100469
100639
  eventType: "run_failed",
100470
100640
  specVersion: SPEC_VERSION_CURRENT2,
@@ -116794,10 +116964,10 @@ var Run = class _Run {
116794
116964
  return this.getReadable();
116795
116965
  }
116796
116966
  };
116797
- Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#wakeUp");
116798
- Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#cancel");
116799
- Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#getReadable");
116800
- var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#exists");
116967
+ Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#wakeUp");
116968
+ Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#cancel");
116969
+ Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#getReadable");
116970
+ var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#exists");
116801
116971
  Object.defineProperty(Run.prototype, "exists", {
116802
116972
  get() {
116803
116973
  return __step_Run$exists.call(this);
@@ -116805,7 +116975,7 @@ Object.defineProperty(Run.prototype, "exists", {
116805
116975
  configurable: true,
116806
116976
  enumerable: false
116807
116977
  });
116808
- var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#status");
116978
+ var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#status");
116809
116979
  Object.defineProperty(Run.prototype, "status", {
116810
116980
  get() {
116811
116981
  return __step_Run$status.call(this);
@@ -116813,7 +116983,7 @@ Object.defineProperty(Run.prototype, "status", {
116813
116983
  configurable: true,
116814
116984
  enumerable: false
116815
116985
  });
116816
- var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#returnValue");
116986
+ var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#returnValue");
116817
116987
  Object.defineProperty(Run.prototype, "returnValue", {
116818
116988
  get() {
116819
116989
  return __step_Run$returnValue.call(this);
@@ -116821,7 +116991,7 @@ Object.defineProperty(Run.prototype, "returnValue", {
116821
116991
  configurable: true,
116822
116992
  enumerable: false
116823
116993
  });
116824
- var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#workflowName");
116994
+ var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#workflowName");
116825
116995
  Object.defineProperty(Run.prototype, "workflowName", {
116826
116996
  get() {
116827
116997
  return __step_Run$workflowName.call(this);
@@ -116829,7 +116999,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
116829
116999
  configurable: true,
116830
117000
  enumerable: false
116831
117001
  });
116832
- var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#createdAt");
117002
+ var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#createdAt");
116833
117003
  Object.defineProperty(Run.prototype, "createdAt", {
116834
117004
  get() {
116835
117005
  return __step_Run$createdAt.call(this);
@@ -116837,7 +117007,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
116837
117007
  configurable: true,
116838
117008
  enumerable: false
116839
117009
  });
116840
- var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#startedAt");
117010
+ var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#startedAt");
116841
117011
  Object.defineProperty(Run.prototype, "startedAt", {
116842
117012
  get() {
116843
117013
  return __step_Run$startedAt.call(this);
@@ -116845,7 +117015,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
116845
117015
  configurable: true,
116846
117016
  enumerable: false
116847
117017
  });
116848
- var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.20//Run#completedAt");
117018
+ var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.21//Run#completedAt");
116849
117019
  Object.defineProperty(Run.prototype, "completedAt", {
116850
117020
  get() {
116851
117021
  return __step_Run$completedAt.call(this);
@@ -116862,7 +117032,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
116862
117032
  enumerable: false,
116863
117033
  configurable: false
116864
117034
  });
116865
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.20//Run");
117035
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.21//Run");
116866
117036
 
116867
117037
  // ../core/dist/workflow/create-hook.js
116868
117038
  aliasSerializationClass(RUN_CLASS_ID, Run);
@@ -1,14 +1,6 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
- "workflows/retriable-and-fatal.ts": {
5
- "stepThatFails": {
6
- "stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
7
- },
8
- "stepThatThrowsRetryableError": {
9
- "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
10
- }
11
- },
12
4
  "workflows/noop.ts": {
13
5
  "noop": {
14
6
  "stepId": "step//./workflows/noop//noop"
@@ -19,9 +11,31 @@
19
11
  "stepId": "step//./workflows/null-byte//nullByteStep"
20
12
  }
21
13
  },
22
- "workflows/hooks.ts": {
23
- "writeEvent": {
24
- "stepId": "step//./workflows/hooks//writeEvent"
14
+ "workflows/addition.ts": {
15
+ "add": {
16
+ "stepId": "step//./workflows/addition//add"
17
+ }
18
+ },
19
+ "workflow/dist/internal/builtins.js": {
20
+ "__builtin_response_array_buffer": {
21
+ "stepId": "__builtin_response_array_buffer"
22
+ },
23
+ "__builtin_response_json": {
24
+ "stepId": "__builtin_response_json"
25
+ },
26
+ "__builtin_response_text": {
27
+ "stepId": "__builtin_response_text"
28
+ },
29
+ "__builtin_set_attributes": {
30
+ "stepId": "__builtin_set_attributes"
31
+ }
32
+ },
33
+ "workflows/retriable-and-fatal.ts": {
34
+ "stepThatFails": {
35
+ "stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
36
+ },
37
+ "stepThatThrowsRetryableError": {
38
+ "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
25
39
  }
26
40
  },
27
41
  "workflows/inline-execution.ts": {
@@ -35,79 +49,65 @@
35
49
  "stepId": "step//./workflows/inline-execution//writeToStream"
36
50
  }
37
51
  },
38
- "workflows/addition.ts": {
39
- "add": {
40
- "stepId": "step//./workflows/addition//add"
41
- }
42
- },
43
52
  "workflow/dist/stdlib.js": {
44
53
  "fetch": {
45
54
  "stepId": "step//./workflow/dist/stdlib//fetch"
46
55
  }
47
56
  },
48
- "workflow/dist/internal/builtins.js": {
49
- "__builtin_response_array_buffer": {
50
- "stepId": "__builtin_response_array_buffer"
51
- },
52
- "__builtin_response_json": {
53
- "stepId": "__builtin_response_json"
54
- },
55
- "__builtin_response_text": {
56
- "stepId": "__builtin_response_text"
57
- },
58
- "__builtin_set_attributes": {
59
- "stepId": "__builtin_set_attributes"
57
+ "workflows/hooks.ts": {
58
+ "writeEvent": {
59
+ "stepId": "step//./workflows/hooks//writeEvent"
60
60
  }
61
61
  },
62
62
  "core/dist/runtime/start.js": {
63
63
  "start": {
64
- "stepId": "step//@workflow/core/runtime/start@5.0.0-beta.20//start"
64
+ "stepId": "step//@workflow/core/runtime/start@5.0.0-beta.21//start"
65
65
  }
66
66
  },
67
67
  "core/dist/runtime/run.js": {
68
68
  "Run#cancel": {
69
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#cancel"
69
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#cancel"
70
70
  },
71
71
  "Run#completedAt": {
72
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#completedAt"
72
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#completedAt"
73
73
  },
74
74
  "Run#createdAt": {
75
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#createdAt"
75
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#createdAt"
76
76
  },
77
77
  "Run#exists": {
78
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#exists"
78
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#exists"
79
79
  },
80
80
  "Run#getReadable": {
81
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#getReadable"
81
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#getReadable"
82
82
  },
83
83
  "Run#returnValue": {
84
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#returnValue"
84
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#returnValue"
85
85
  },
86
86
  "Run#startedAt": {
87
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#startedAt"
87
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#startedAt"
88
88
  },
89
89
  "Run#status": {
90
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#status"
90
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#status"
91
91
  },
92
92
  "Run#wakeUp": {
93
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#wakeUp"
93
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#wakeUp"
94
94
  },
95
95
  "Run#workflowName": {
96
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#workflowName"
96
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#workflowName"
97
97
  }
98
98
  }
99
99
  },
100
100
  "workflows": {
101
- "workflows/retriable-and-fatal.ts": {
102
- "retryableAndFatalErrorWorkflow": {
103
- "workflowId": "workflow//./workflows/retriable-and-fatal//retryableAndFatalErrorWorkflow",
101
+ "workflows/noop.ts": {
102
+ "brokenWf": {
103
+ "workflowId": "workflow//./workflows/noop//brokenWf",
104
104
  "graph": {
105
105
  "nodes": [
106
106
  {
107
107
  "id": "start",
108
108
  "type": "workflowStart",
109
109
  "data": {
110
- "label": "Start: retryableAndFatalErrorWorkflow",
110
+ "label": "Start: brokenWf",
111
111
  "nodeKind": "workflow_start"
112
112
  }
113
113
  },
@@ -131,16 +131,16 @@
131
131
  }
132
132
  }
133
133
  },
134
- "workflows/noop.ts": {
135
- "brokenWf": {
136
- "workflowId": "workflow//./workflows/noop//brokenWf",
134
+ "workflows/null-byte.ts": {
135
+ "nullByteWorkflow": {
136
+ "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
137
137
  "graph": {
138
138
  "nodes": [
139
139
  {
140
140
  "id": "start",
141
141
  "type": "workflowStart",
142
142
  "data": {
143
- "label": "Start: brokenWf",
143
+ "label": "Start: nullByteWorkflow",
144
144
  "nodeKind": "workflow_start"
145
145
  }
146
146
  },
@@ -164,16 +164,47 @@
164
164
  }
165
165
  }
166
166
  },
167
- "workflows/null-byte.ts": {
168
- "nullByteWorkflow": {
169
- "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
167
+ "workflows/addition.ts": {
168
+ "addTenWorkflow": {
169
+ "workflowId": "workflow//./workflows/addition//addTenWorkflow",
170
170
  "graph": {
171
171
  "nodes": [
172
172
  {
173
173
  "id": "start",
174
174
  "type": "workflowStart",
175
175
  "data": {
176
- "label": "Start: nullByteWorkflow",
176
+ "label": "Start: addTenWorkflow",
177
+ "nodeKind": "workflow_start"
178
+ }
179
+ },
180
+ {
181
+ "id": "end",
182
+ "type": "workflowEnd",
183
+ "data": {
184
+ "label": "Return",
185
+ "nodeKind": "workflow_end"
186
+ }
187
+ }
188
+ ],
189
+ "edges": [
190
+ {
191
+ "id": "e_start_end",
192
+ "source": "start",
193
+ "target": "end",
194
+ "type": "default"
195
+ }
196
+ ]
197
+ }
198
+ },
199
+ "addition": {
200
+ "workflowId": "workflow//./workflows/addition//addition",
201
+ "graph": {
202
+ "nodes": [
203
+ {
204
+ "id": "start",
205
+ "type": "workflowStart",
206
+ "data": {
207
+ "label": "Start: addition",
177
208
  "nodeKind": "workflow_start"
178
209
  }
179
210
  },
@@ -197,16 +228,16 @@
197
228
  }
198
229
  }
199
230
  },
200
- "workflows/hooks.ts": {
201
- "collectWithHook": {
202
- "workflowId": "workflow//./workflows/hooks//collectWithHook",
231
+ "workflows/retriable-and-fatal.ts": {
232
+ "retryableAndFatalErrorWorkflow": {
233
+ "workflowId": "workflow//./workflows/retriable-and-fatal//retryableAndFatalErrorWorkflow",
203
234
  "graph": {
204
235
  "nodes": [
205
236
  {
206
237
  "id": "start",
207
238
  "type": "workflowStart",
208
239
  "data": {
209
- "label": "Start: collectWithHook",
240
+ "label": "Start: retryableAndFatalErrorWorkflow",
210
241
  "nodeKind": "workflow_start"
211
242
  }
212
243
  },
@@ -432,47 +463,16 @@
432
463
  }
433
464
  }
434
465
  },
435
- "workflows/addition.ts": {
436
- "addTenWorkflow": {
437
- "workflowId": "workflow//./workflows/addition//addTenWorkflow",
438
- "graph": {
439
- "nodes": [
440
- {
441
- "id": "start",
442
- "type": "workflowStart",
443
- "data": {
444
- "label": "Start: addTenWorkflow",
445
- "nodeKind": "workflow_start"
446
- }
447
- },
448
- {
449
- "id": "end",
450
- "type": "workflowEnd",
451
- "data": {
452
- "label": "Return",
453
- "nodeKind": "workflow_end"
454
- }
455
- }
456
- ],
457
- "edges": [
458
- {
459
- "id": "e_start_end",
460
- "source": "start",
461
- "target": "end",
462
- "type": "default"
463
- }
464
- ]
465
- }
466
- },
467
- "addition": {
468
- "workflowId": "workflow//./workflows/addition//addition",
466
+ "workflows/hooks.ts": {
467
+ "collectWithHook": {
468
+ "workflowId": "workflow//./workflows/hooks//collectWithHook",
469
469
  "graph": {
470
470
  "nodes": [
471
471
  {
472
472
  "id": "start",
473
473
  "type": "workflowStart",
474
474
  "data": {
475
- "label": "Start: addition",
475
+ "label": "Start: collectWithHook",
476
476
  "nodeKind": "workflow_start"
477
477
  }
478
478
  },
@@ -500,7 +500,7 @@
500
500
  "classes": {
501
501
  "core/dist/runtime/run.js": {
502
502
  "Run": {
503
- "classId": "class//@workflow/core/runtime/run@5.0.0-beta.20//Run"
503
+ "classId": "class//@workflow/core/runtime/run@5.0.0-beta.21//Run"
504
504
  }
505
505
  }
506
506
  }
@@ -23995,7 +23995,7 @@ var version2;
23995
23995
  var init_version = __esm({
23996
23996
  "../core/dist/version.js"() {
23997
23997
  "use strict";
23998
- version2 = "5.0.0-beta.20";
23998
+ version2 = "5.0.0-beta.21";
23999
23999
  }
24000
24000
  });
24001
24001
 
@@ -26190,7 +26190,7 @@ function reviveAbortController(value, ops, runId) {
26190
26190
  }
26191
26191
  })());
26192
26192
  if (value.hookToken) {
26193
- ctx.ops.push((async () => {
26193
+ const hookResume = (async () => {
26194
26194
  try {
26195
26195
  const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => (init_resume_hook(), resume_hook_exports));
26196
26196
  await resumeHookFn(value.hookToken, {
@@ -26199,7 +26199,8 @@ function reviveAbortController(value, ops, runId) {
26199
26199
  });
26200
26200
  } catch {
26201
26201
  }
26202
- })());
26202
+ })();
26203
+ ctx.preCompletionOps.push(hookResume);
26203
26204
  }
26204
26205
  }
26205
26206
  };
@@ -27171,7 +27172,7 @@ __name(start, "start");
27171
27172
  value: "start",
27172
27173
  configurable: true
27173
27174
  });
27174
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.20//start");
27175
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.21//start");
27175
27176
  function isRetryableStartError(err) {
27176
27177
  if (ThrottleError.is(err)) return true;
27177
27178
  if (WorkflowWorldError.is(err) && err.status && err.status >= 500) return true;
@@ -27504,7 +27505,7 @@ var Run = class _Run {
27504
27505
  value: "wakeUp",
27505
27506
  configurable: true
27506
27507
  });
27507
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#wakeUp");
27508
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#wakeUp");
27508
27509
  (function(__wf_fn, __wf_id) {
27509
27510
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27510
27511
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27513,7 +27514,7 @@ var Run = class _Run {
27513
27514
  value: "cancel",
27514
27515
  configurable: true
27515
27516
  });
27516
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#cancel");
27517
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#cancel");
27517
27518
  (function(__wf_fn, __wf_id) {
27518
27519
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27519
27520
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27522,7 +27523,7 @@ var Run = class _Run {
27522
27523
  value: "getReadable",
27523
27524
  configurable: true
27524
27525
  });
27525
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#getReadable");
27526
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#getReadable");
27526
27527
  (function(__wf_fn, __wf_id) {
27527
27528
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27528
27529
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27531,7 +27532,7 @@ var Run = class _Run {
27531
27532
  value: "exists",
27532
27533
  configurable: true
27533
27534
  });
27534
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#exists");
27535
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#exists");
27535
27536
  (function(__wf_fn, __wf_id) {
27536
27537
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27537
27538
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27540,7 +27541,7 @@ var Run = class _Run {
27540
27541
  value: "status",
27541
27542
  configurable: true
27542
27543
  });
27543
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#status");
27544
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#status");
27544
27545
  (function(__wf_fn, __wf_id) {
27545
27546
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27546
27547
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27549,7 +27550,7 @@ var Run = class _Run {
27549
27550
  value: "returnValue",
27550
27551
  configurable: true
27551
27552
  });
27552
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#returnValue");
27553
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#returnValue");
27553
27554
  (function(__wf_fn, __wf_id) {
27554
27555
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27555
27556
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27558,7 +27559,7 @@ var Run = class _Run {
27558
27559
  value: "workflowName",
27559
27560
  configurable: true
27560
27561
  });
27561
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#workflowName");
27562
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#workflowName");
27562
27563
  (function(__wf_fn, __wf_id) {
27563
27564
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27564
27565
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27567,7 +27568,7 @@ var Run = class _Run {
27567
27568
  value: "createdAt",
27568
27569
  configurable: true
27569
27570
  });
27570
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#createdAt");
27571
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#createdAt");
27571
27572
  (function(__wf_fn, __wf_id) {
27572
27573
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27573
27574
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27576,7 +27577,7 @@ var Run = class _Run {
27576
27577
  value: "startedAt",
27577
27578
  configurable: true
27578
27579
  });
27579
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#startedAt");
27580
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#startedAt");
27580
27581
  (function(__wf_fn, __wf_id) {
27581
27582
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27582
27583
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27585,7 +27586,7 @@ var Run = class _Run {
27585
27586
  value: "completedAt",
27586
27587
  configurable: true
27587
27588
  });
27588
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.20//Run#completedAt");
27589
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.21//Run#completedAt");
27589
27590
  (function(__wf_cls, __wf_id) {
27590
27591
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27591
27592
  __wf_reg.set(__wf_id, __wf_cls);
@@ -27595,7 +27596,7 @@ var Run = class _Run {
27595
27596
  enumerable: false,
27596
27597
  configurable: false
27597
27598
  });
27598
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.20//Run");
27599
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.21//Run");
27599
27600
 
27600
27601
  // ../workflow/dist/stdlib.js
27601
27602
  async function fetch2(...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/world-testing",
3
- "version": "5.0.0-beta.20",
3
+ "version": "5.0.0-beta.21",
4
4
  "description": "Testing utilities and World implementation for Workflow SDK",
5
5
  "main": "dist/src/index.mjs",
6
6
  "files": [
@@ -21,10 +21,10 @@
21
21
  "hono": "4.12.25",
22
22
  "jsonlines": "0.1.1",
23
23
  "zod": "4.3.6",
24
- "@workflow/cli": "5.0.0-beta.20",
25
- "@workflow/core": "5.0.0-beta.20",
24
+ "@workflow/cli": "5.0.0-beta.21",
25
+ "@workflow/core": "5.0.0-beta.21",
26
26
  "@workflow/world": "5.0.0-beta.12",
27
- "workflow": "5.0.0-beta.20"
27
+ "workflow": "5.0.0-beta.21"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/jsonlines": "0.1.5",