@workflow/world-testing 5.1.3 → 5.1.4

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.
@@ -13681,7 +13681,7 @@ var init_locales2 = __esm({
13681
13681
  });
13682
13682
 
13683
13683
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
13684
- function registry2() {
13684
+ function registry3() {
13685
13685
  return new $ZodRegistry2();
13686
13686
  }
13687
13687
  var _a5, $output2, $input2, $ZodRegistry2, globalRegistry2;
@@ -13732,8 +13732,8 @@ var init_registries2 = __esm({
13732
13732
  return this._map.has(schema);
13733
13733
  }
13734
13734
  };
13735
- __name(registry2, "registry");
13736
- (_a5 = globalThis).__zod_globalRegistry ?? (_a5.__zod_globalRegistry = registry2());
13735
+ __name(registry3, "registry");
13736
+ (_a5 = globalThis).__zod_globalRegistry ?? (_a5.__zod_globalRegistry = registry3());
13737
13737
  globalRegistry2 = globalThis.__zod_globalRegistry;
13738
13738
  }
13739
13739
  });
@@ -17291,21 +17291,21 @@ function serializeDefaultValue2(value, schema, ctx, json3, params) {
17291
17291
  }
17292
17292
  function toJSONSchema2(input3, params) {
17293
17293
  if ("_idmap" in input3) {
17294
- const registry3 = input3;
17294
+ const registry5 = input3;
17295
17295
  const ctx2 = initializeContext2({ ...params, processors: allProcessors2 });
17296
17296
  const defs = {};
17297
- for (const entry of registry3._idmap.entries()) {
17297
+ for (const entry of registry5._idmap.entries()) {
17298
17298
  const [_, schema] = entry;
17299
17299
  processSchema2(schema, ctx2);
17300
17300
  }
17301
17301
  const schemas = {};
17302
17302
  const external = {
17303
- registry: registry3,
17303
+ registry: registry5,
17304
17304
  uri: params?.uri,
17305
17305
  defs
17306
17306
  };
17307
17307
  ctx2.external = external;
17308
- for (const entry of registry3._idmap.entries()) {
17308
+ for (const entry of registry5._idmap.entries()) {
17309
17309
  const [key, schema] = entry;
17310
17310
  extractDefs2(ctx2, schema);
17311
17311
  assignProp2(schemas, key, finalize2(ctx2, schema));
@@ -18327,7 +18327,7 @@ __export(core_exports3, {
18327
18327
  process: () => processSchema2,
18328
18328
  processSchema: () => processSchema2,
18329
18329
  regexes: () => regexes_exports2,
18330
- registry: () => registry2,
18330
+ registry: () => registry3,
18331
18331
  safeDecode: () => safeDecode3,
18332
18332
  safeDecodeAsync: () => safeDecodeAsync3,
18333
18333
  safeEncode: () => safeEncode3,
@@ -21545,7 +21545,7 @@ __export(external_exports2, {
21545
21545
  refine: () => refine2,
21546
21546
  regex: () => _regex2,
21547
21547
  regexes: () => regexes_exports2,
21548
- registry: () => registry2,
21548
+ registry: () => registry3,
21549
21549
  safeDecode: () => safeDecode4,
21550
21550
  safeDecodeAsync: () => safeDecodeAsync4,
21551
21551
  safeEncode: () => safeEncode4,
@@ -24299,7 +24299,7 @@ function formatErrorMessageWithDetails(title, details) {
24299
24299
  function isRunAlreadyStartedError(error123) {
24300
24300
  return EntityConflictError2.is(error123) && error123.code === RUN_ALREADY_STARTED_CODE;
24301
24301
  }
24302
- var BASE_URL2, QUICKJS_SNAPSHOT_REMEDIATION, ERROR_SLUGS2, WorkflowError2, WorkflowWorldError2, START_HOOK_ADMISSION_REJECTED2, START_HOOK_ADMISSION_DISABLED2, START_HOOK_CANDIDATE_CANCELLED2, WorkflowStartError2, WorkflowRunFailedError2, WorkflowRunNotCompletedError2, WorkflowRuntimeError2, CorruptedEventLogError2, ReplayDivergenceError, MaxEventsExceededError, RuntimeDecryptionError2, EncryptionKeyLookupError2, SerializationError2, StepNotRegisteredError2, WorkflowNotRegisteredError, WorkflowDeploymentMismatchError, WorkflowRunNotFoundError2, HookConflictError2, HookForceClaimedError2, HookNotFoundError2, EntityConflictError2, RUN_ALREADY_STARTED_CODE, RunExpiredError2, StreamError2, StreamExpiredError2, TooEarlyError2, ThrottleError2, PreconditionFailedError2, IN_BAND_SUPERSEDED_CODE2, InBandSupersededError2, WorkflowRunCancelledError2, RunNotSupportedError2, FatalError2, RetryableError2, FATAL_ERROR_KEY2, RETRYABLE_ERROR_KEY2, HOOK_CONFLICT_ERROR_KEY2, HOOK_FORCE_CLAIMED_ERROR_KEY2, RUNTIME_DECRYPTION_ERROR_KEY2, STREAM_ERROR_KEY2, WORKFLOW_START_ERROR_KEY2;
24302
+ var BASE_URL2, QUICKJS_SNAPSHOT_REMEDIATION, ERROR_SLUGS2, WorkflowError2, WorkflowWorldError2, START_HOOK_ADMISSION_REJECTED2, START_HOOK_ADMISSION_DISABLED2, START_HOOK_CANDIDATE_CANCELLED2, WorkflowStartError2, DYNAMIC_WORKFLOWS_ENV_VAR2, DYNAMIC_WORKFLOWS_DOCS_URL2, DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT2, DynamicWorkflowsNotEnabledError2, WorkflowRunFailedError2, WorkflowRunNotCompletedError2, WorkflowRuntimeError2, CorruptedEventLogError2, ReplayDivergenceError, MaxEventsExceededError, RuntimeDecryptionError2, EncryptionKeyLookupError2, SerializationError2, StepNotRegisteredError2, WorkflowNotRegisteredError, WorkflowDeploymentMismatchError, WorkflowRunNotFoundError2, HookConflictError2, HookForceClaimedError2, HookNotFoundError2, EntityConflictError2, RUN_ALREADY_STARTED_CODE, RunExpiredError2, StreamError2, StreamExpiredError2, TooEarlyError2, ThrottleError2, PreconditionFailedError2, IN_BAND_SUPERSEDED_CODE2, InBandSupersededError2, WorkflowRunCancelledError2, RunNotSupportedError2, FatalError2, RetryableError2, FATAL_ERROR_KEY2, RETRYABLE_ERROR_KEY2, HOOK_CONFLICT_ERROR_KEY2, HOOK_FORCE_CLAIMED_ERROR_KEY2, RUNTIME_DECRYPTION_ERROR_KEY2, STREAM_ERROR_KEY2, WORKFLOW_START_ERROR_KEY2;
24303
24303
  var init_dist11 = __esm({
24304
24304
  "../errors/dist/index.js"() {
24305
24305
  "use strict";
@@ -24411,6 +24411,29 @@ Caused by: ${options.cause.stack}`;
24411
24411
  return isError2(value) && value.name === "WorkflowStartError";
24412
24412
  }
24413
24413
  };
24414
+ DYNAMIC_WORKFLOWS_ENV_VAR2 = "WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS";
24415
+ DYNAMIC_WORKFLOWS_DOCS_URL2 = "https://workflow-sdk.dev/docs/advanced/dynamic-workflows#enabling-dynamic-workflows";
24416
+ DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT2 = `Set the ${DYNAMIC_WORKFLOWS_ENV_VAR2}=1 environment variable on your project, then redeploy (or restart your dev server) so the new value takes effect.`;
24417
+ DynamicWorkflowsNotEnabledError2 = class extends WorkflowError2 {
24418
+ static {
24419
+ __name(this, "DynamicWorkflowsNotEnabledError");
24420
+ }
24421
+ fatal = true;
24422
+ /**
24423
+ * @param message - What was refused, e.g. that `start()` created no run.
24424
+ * The fix-it hint and a docs link are appended to it.
24425
+ */
24426
+ constructor(message, options) {
24427
+ super(appendFramedDetails2(message, [
24428
+ { label: "hint", value: DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT2 },
24429
+ { label: "docs", value: DYNAMIC_WORKFLOWS_DOCS_URL2 }
24430
+ ]), { cause: options?.cause });
24431
+ this.name = "DynamicWorkflowsNotEnabledError";
24432
+ }
24433
+ static is(value) {
24434
+ return isError2(value) && value.name === "DynamicWorkflowsNotEnabledError";
24435
+ }
24436
+ };
24414
24437
  WorkflowRunFailedError2 = class extends WorkflowError2 {
24415
24438
  static {
24416
24439
  __name(this, "WorkflowRunFailedError");
@@ -63353,7 +63376,7 @@ var version6;
63353
63376
  var init_version4 = __esm({
63354
63377
  "../world-vercel/dist/version.js"() {
63355
63378
  "use strict";
63356
- version6 = "5.7.0";
63379
+ version6 = "5.7.1";
63357
63380
  }
63358
63381
  });
63359
63382
 
@@ -74455,11 +74478,11 @@ ${content.join(`
74455
74478
  return this._map.has(schema);
74456
74479
  }
74457
74480
  };
74458
- function registry3() {
74481
+ function registry5() {
74459
74482
  return new $ZodRegistry3();
74460
74483
  }
74461
- __name(registry3, "registry");
74462
- (_a22 = globalThis).__zod_globalRegistry ?? (_a22.__zod_globalRegistry = registry3());
74484
+ __name(registry5, "registry");
74485
+ (_a22 = globalThis).__zod_globalRegistry ?? (_a22.__zod_globalRegistry = registry5());
74463
74486
  var globalRegistry3 = globalThis.__zod_globalRegistry;
74464
74487
  function snapshotChecks3(def) {
74465
74488
  return def.checks && (def.checks = [...def.checks]), def;
@@ -86602,10 +86625,10 @@ function registerHandlerForFile2(filePath, handler, client, options) {
86602
86625
  const absolutePath = path14.isAbsolute(filePath) ? filePath : path14.resolve(process.cwd(), filePath);
86603
86626
  const fileMappings = findMappingsForFile2(absolutePath);
86604
86627
  if (fileMappings.length === 0) return false;
86605
- const registry3 = getHandlerRegistry2();
86628
+ const registry5 = getHandlerRegistry2();
86606
86629
  for (const mapping of fileMappings) {
86607
86630
  const key = mapping.topic;
86608
- const existing = registry3.get(key) ?? [];
86631
+ const existing = registry5.get(key) ?? [];
86609
86632
  const nextEntry = {
86610
86633
  consumerGroup: mapping.consumer,
86611
86634
  handler,
@@ -86620,7 +86643,7 @@ function registerHandlerForFile2(filePath, handler, client, options) {
86620
86643
  } else {
86621
86644
  existing.push(nextEntry);
86622
86645
  }
86623
- registry3.set(key, existing);
86646
+ registry5.set(key, existing);
86624
86647
  }
86625
86648
  return true;
86626
86649
  }
@@ -86662,9 +86685,9 @@ Add a trigger to vercel.json:
86662
86685
  }
86663
86686
  }
86664
86687
  function lookupHandlers2(topicName) {
86665
- const registry3 = getHandlerRegistry2();
86688
+ const registry5 = getHandlerRegistry2();
86666
86689
  const result2 = [];
86667
- for (const [pattern, handlers] of registry3) {
86690
+ for (const [pattern, handlers] of registry5) {
86668
86691
  const matches = pattern.includes("*") ? matchesWildcardPattern2(topicName, pattern) : pattern === topicName;
86669
86692
  if (matches) {
86670
86693
  result2.push(...handlers);
@@ -95790,6 +95813,9 @@ function isRetryableWorldError2(err) {
95790
95813
  return err.code !== void 0 && RETRYABLE_WORLD_ERROR_CODES2.has(err.code);
95791
95814
  }
95792
95815
  function classifyRunError(err) {
95816
+ if (DynamicWorkflowsNotEnabledError2.is(err)) {
95817
+ return RUN_ERROR_CODES2.USER_ERROR;
95818
+ }
95793
95819
  if (ReplayDivergenceError.is(err)) {
95794
95820
  return RUN_ERROR_CODES2.REPLAY_DIVERGENCE;
95795
95821
  }
@@ -96166,6 +96192,13 @@ function describeError3(err, errorCode) {
96166
96192
  hint: CONTEXT_ERROR_HINT
96167
96193
  };
96168
96194
  }
96195
+ if (DynamicWorkflowsNotEnabledError2.is(err)) {
96196
+ return {
96197
+ attribution: "user",
96198
+ errorCode: effectiveCode,
96199
+ hint: DYNAMIC_WORKFLOWS_NOT_ENABLED_DESCRIPTION_HINT
96200
+ };
96201
+ }
96169
96202
  if (CorruptedEventLogError2.is(err)) {
96170
96203
  return {
96171
96204
  attribution: "sdk",
@@ -96238,7 +96271,7 @@ function describeError3(err, errorCode) {
96238
96271
  }
96239
96272
  return { attribution: "user", errorCode: effectiveCode };
96240
96273
  }
96241
- var SERIALIZATION_ERROR_HINT, CONTEXT_ERROR_HINT, RUNTIME_ERROR_HINT, CORRUPTED_EVENT_LOG_HINT, REPLAY_TIMEOUT_HINT, MAX_DELIVERIES_HINT, MAX_EVENTS_HINT, STREAM_ERROR_HINT, WORLD_CONTRACT_HINT, DEPLOYMENT_MISMATCH_HINT, WORKFLOW_NOT_REGISTERED_HINT, CODE_DESCRIPTIONS;
96274
+ var SERIALIZATION_ERROR_HINT, CONTEXT_ERROR_HINT, RUNTIME_ERROR_HINT, CORRUPTED_EVENT_LOG_HINT, REPLAY_TIMEOUT_HINT, MAX_DELIVERIES_HINT, MAX_EVENTS_HINT, STREAM_ERROR_HINT, WORLD_CONTRACT_HINT, DEPLOYMENT_MISMATCH_HINT, DYNAMIC_WORKFLOWS_NOT_ENABLED_DESCRIPTION_HINT, WORKFLOW_NOT_REGISTERED_HINT, CODE_DESCRIPTIONS;
96242
96275
  var init_describe_error = __esm({
96243
96276
  "../core/dist/describe-error.js"() {
96244
96277
  "use strict";
@@ -96256,6 +96289,7 @@ var init_describe_error = __esm({
96256
96289
  STREAM_ERROR_HINT = "Workflow stream infrastructure failed while reading or writing data. This is an SDK or backend failure, not an error in your workflow code; please retry the run and report persistent failures with the runId.";
96257
96290
  WORLD_CONTRACT_HINT = "The workflow backend returned data that violated the SDK contract. This is not retryable; please report it with the stack trace and runId.";
96258
96291
  DEPLOYMENT_MISMATCH_HINT = "The run was delivered to a deployment other than the deployment it is pinned to, and was stopped to protect against code-skew errors after the runtime failed to re-route it there. Verify that the run's deployment is still available and that queue callbacks route to it.";
96292
+ DYNAMIC_WORKFLOWS_NOT_ENABLED_DESCRIPTION_HINT = `Dynamic workflows are not enabled for this project. ${DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT2}`;
96259
96293
  WORKFLOW_NOT_REGISTERED_HINT = "The deployment that executed this run does not have its workflow registered. Usually the run was started or replayed against a deployment where the workflow was renamed, moved, or removed, or the build did not bundle it. Check the workflowId and the deployment the run is pinned to.";
96260
96294
  CODE_DESCRIPTIONS = {
96261
96295
  [RUN_ERROR_CODES2.REPLAY_TIMEOUT]: {
@@ -101568,6 +101602,76 @@ var init_sealed_box2 = __esm({
101568
101602
  }
101569
101603
  });
101570
101604
 
101605
+ // ../core/dist/serialization/abort-local.js
101606
+ function registry4() {
101607
+ const holder = globalThis;
101608
+ holder[REGISTRY_KEY2] ??= { listeners: /* @__PURE__ */ new Map(), published: /* @__PURE__ */ new Map() };
101609
+ return holder[REGISTRY_KEY2];
101610
+ }
101611
+ function keyOf2(runId, streamName) {
101612
+ return `${runId}\0${streamName}`;
101613
+ }
101614
+ function prune2(published, now3) {
101615
+ for (const [key, entry] of published) {
101616
+ if (now3 - entry.at < PUBLISHED_TTL_MS2 && published.size <= MAX_PUBLISHED2)
101617
+ break;
101618
+ published.delete(key);
101619
+ }
101620
+ }
101621
+ function publishLocalAbort2(runId, streamName, packet) {
101622
+ const { listeners, published } = registry4();
101623
+ const key = keyOf2(runId, streamName);
101624
+ const now3 = Date.now();
101625
+ published.delete(key);
101626
+ published.set(key, { packet, at: now3 });
101627
+ prune2(published, now3);
101628
+ for (const listener of listeners.get(key) ?? []) {
101629
+ try {
101630
+ listener(packet);
101631
+ } catch {
101632
+ }
101633
+ }
101634
+ }
101635
+ function onLocalAbort2(runId, streamName, listener) {
101636
+ const { listeners, published } = registry4();
101637
+ const key = keyOf2(runId, streamName);
101638
+ prune2(published, Date.now());
101639
+ const recent = published.get(key);
101640
+ if (recent) {
101641
+ listener(recent.packet);
101642
+ return () => {
101643
+ };
101644
+ }
101645
+ let set3 = listeners.get(key);
101646
+ if (!set3) {
101647
+ set3 = /* @__PURE__ */ new Set();
101648
+ listeners.set(key, set3);
101649
+ }
101650
+ set3.add(listener);
101651
+ return () => {
101652
+ const current3 = listeners.get(key);
101653
+ if (!current3)
101654
+ return;
101655
+ current3.delete(listener);
101656
+ if (current3.size === 0)
101657
+ listeners.delete(key);
101658
+ };
101659
+ }
101660
+ var REGISTRY_KEY2, PUBLISHED_TTL_MS2, MAX_PUBLISHED2;
101661
+ var init_abort_local2 = __esm({
101662
+ "../core/dist/serialization/abort-local.js"() {
101663
+ "use strict";
101664
+ REGISTRY_KEY2 = /* @__PURE__ */ Symbol.for("@workflow/core//localAbortDelivery");
101665
+ PUBLISHED_TTL_MS2 = 6e4;
101666
+ MAX_PUBLISHED2 = 256;
101667
+ __name(registry4, "registry");
101668
+ __name(keyOf2, "keyOf");
101669
+ __name(prune2, "prune");
101670
+ __name(publishLocalAbort2, "publishLocalAbort");
101671
+ __name(onLocalAbort2, "onLocalAbort");
101672
+ }
101673
+ });
101674
+
101571
101675
  // ../core/dist/serialization/types.js
101572
101676
  function isFormatPrefix2(value) {
101573
101677
  return value.length === 4 && /^[a-z0-9]{4}$/.test(value);
@@ -102124,12 +102228,12 @@ var init_dist16 = __esm({
102124
102228
  // ../core/dist/class-serialization.js
102125
102229
  function getRegistry2(global2 = globalThis) {
102126
102230
  const g = global2;
102127
- let registry3 = g[WORKFLOW_CLASS_REGISTRY2];
102128
- if (!registry3) {
102129
- registry3 = /* @__PURE__ */ new Map();
102130
- g[WORKFLOW_CLASS_REGISTRY2] = registry3;
102231
+ let registry5 = g[WORKFLOW_CLASS_REGISTRY2];
102232
+ if (!registry5) {
102233
+ registry5 = /* @__PURE__ */ new Map();
102234
+ g[WORKFLOW_CLASS_REGISTRY2] = registry5;
102131
102235
  }
102132
- return registry3;
102236
+ return registry5;
102133
102237
  }
102134
102238
  function getSerializationClass2(classId, global2) {
102135
102239
  return getRegistry2(global2).get(classId);
@@ -106578,6 +106682,7 @@ function attachAbortListenerOnce2(signal, streamName, runId, cryptoKey, ops, fra
106578
106682
  try {
106579
106683
  const key = await resolveEncryptionKey2(cryptoKey);
106580
106684
  const payload = await dehydrateStepArguments2({ aborted: true, reason: signal.reason }, runId, key);
106685
+ publishLocalAbort2(runId, streamName, payload);
106581
106686
  const writable = new WorkflowServerWritableStream2(runId, streamName);
106582
106687
  const writer = writable.getWriter();
106583
106688
  await writer.write(framedAbortStreams ? frameAbortStreamPayload2(payload) : payload);
@@ -106881,40 +106986,76 @@ function cancelAbortReaders2(...values) {
106881
106986
  for (const v of values)
106882
106987
  walk(v);
106883
106988
  }
106884
- function setupAbortStreamReader2(controller, runId, streamName, ops, cryptoKey) {
106989
+ function setupAbortStreamReader2(controller, runId, streamName, ops, cryptoKey, untilCancelled) {
106885
106990
  const readerCancel = new AbortController();
106991
+ let resolveLocal;
106992
+ const localPacket = new Promise((resolve4) => {
106993
+ resolveLocal = resolve4;
106994
+ });
106995
+ const stopLocal = onLocalAbort2(runId, streamName, (packet) => resolveLocal?.(packet));
106886
106996
  ops.push((async () => {
106887
106997
  let reader;
106998
+ let keepListening = false;
106888
106999
  try {
106889
- const readable = new WorkflowServerReadableStream2(runId, streamName);
106890
- reader = readable.getReader();
106891
107000
  let keyPromise;
106892
107001
  let decoded;
106893
107002
  const decodePacket = /* @__PURE__ */ __name(async (packet) => {
106894
107003
  keyPromise ??= resolveEncryptionKey2(cryptoKey);
106895
107004
  decoded = await hydrateStepArguments2(packet, runId, await keyPromise);
106896
107005
  }, "decodePacket");
106897
- const result2 = await Promise.race([
106898
- readAbortStreamPacket2(reader, decodePacket),
106899
- new Promise((resolve4) => {
106900
- if (readerCancel.signal.aborted) {
106901
- resolve4(void 0);
106902
- return;
106903
- }
106904
- readerCancel.signal.addEventListener("abort", () => resolve4(void 0), { once: true });
106905
- })
106906
- ]);
106907
- if (result2) {
107006
+ const abortWith = /* @__PURE__ */ __name(async (packet, already) => {
106908
107007
  try {
107008
+ decoded = already;
106909
107009
  if (decoded === void 0)
106910
- await decodePacket(result2);
107010
+ await decodePacket(packet);
106911
107011
  controller.abort(decoded?.reason);
106912
107012
  } catch {
106913
107013
  controller.abort();
106914
107014
  }
107015
+ }, "abortWith");
107016
+ const cancelled = new Promise((resolve4) => {
107017
+ if (readerCancel.signal.aborted) {
107018
+ resolve4(void 0);
107019
+ return;
107020
+ }
107021
+ readerCancel.signal.addEventListener("abort", () => resolve4(void 0), { once: true });
107022
+ });
107023
+ let streamPacket;
107024
+ try {
107025
+ const readable = new WorkflowServerReadableStream2(runId, streamName);
107026
+ reader = readable.getReader();
107027
+ streamPacket = readAbortStreamPacket2(reader, decodePacket);
107028
+ } catch {
107029
+ streamPacket = new Promise(() => {
107030
+ });
107031
+ }
107032
+ const local = localPacket.then((packet) => ({ packet, local: true }));
107033
+ const winner = await Promise.race([
107034
+ local,
107035
+ untilCancelled ? (
107036
+ // An empty or failed stream is not the end of the abort.
107037
+ streamPacket.then((packet) => packet ? { packet, local: false } : void 0, () => void 0)
107038
+ ) : streamPacket.then((packet) => packet ? { packet, local: false } : void 0),
107039
+ cancelled
107040
+ ]);
107041
+ if (winner) {
107042
+ await abortWith(winner.packet, winner.local ? void 0 : decoded);
107043
+ } else if (untilCancelled && !readerCancel.signal.aborted) {
107044
+ keepListening = true;
107045
+ const expiry = setTimeout(stopLocal, LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS2);
107046
+ expiry.unref?.();
107047
+ void Promise.race([local, cancelled]).then(async (late) => {
107048
+ clearTimeout(expiry);
107049
+ stopLocal();
107050
+ if (late)
107051
+ await abortWith(late.packet, void 0);
107052
+ }).catch(() => {
107053
+ });
106915
107054
  }
106916
107055
  } catch {
106917
107056
  } finally {
107057
+ if (!keepListening)
107058
+ stopLocal();
106918
107059
  void reader?.cancel().catch(() => {
106919
107060
  });
106920
107061
  }
@@ -106946,13 +107087,13 @@ function copyAbortInternals2(src3, dest) {
106946
107087
  d[ABORT_READER_CANCEL2] = s[ABORT_READER_CANCEL2];
106947
107088
  }
106948
107089
  }
106949
- function reviveAbortController2(value, ops, runId, cryptoKey) {
107090
+ function reviveAbortController2(value, ops, runId, cryptoKey, untilCancelled = false) {
106950
107091
  const controller = new AbortController();
106951
107092
  if (value.aborted) {
106952
107093
  tagAbortPair2(controller, value);
106953
107094
  controller.abort(value.reason);
106954
107095
  } else if (value.streamName) {
106955
- const readerCancel = setupAbortStreamReader2(controller, runId, value.streamName, ops, cryptoKey);
107096
+ const readerCancel = setupAbortStreamReader2(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
106956
107097
  tagAbortPair2(controller, value, readerCancel);
106957
107098
  } else {
106958
107099
  tagAbortPair2(controller, value);
@@ -106967,6 +107108,7 @@ function reviveAbortController2(value, ops, runId, cryptoKey) {
106967
107108
  ctx.ops.push((async () => {
106968
107109
  try {
106969
107110
  const payload = await dehydrateStepArguments2({ aborted: true, reason }, ctx.workflowMetadata.workflowRunId, ctx.encryptionKey);
107111
+ publishLocalAbort2(ctx.workflowMetadata.workflowRunId, value.streamName, payload);
106970
107112
  const writable = new WorkflowServerWritableStream2(ctx.workflowMetadata.workflowRunId, value.streamName);
106971
107113
  const writer = writable.getWriter();
106972
107114
  await writer.write(frameAbortStreamPayload2(payload));
@@ -106991,13 +107133,13 @@ function reviveAbortController2(value, ops, runId, cryptoKey) {
106991
107133
  };
106992
107134
  return controller;
106993
107135
  }
106994
- function reviveAbortSignal2(value, ops, runId, cryptoKey) {
107136
+ function reviveAbortSignal2(value, ops, runId, cryptoKey, untilCancelled = false) {
106995
107137
  const controller = new AbortController();
106996
107138
  if (value.aborted) {
106997
107139
  tagAbortPair2(controller, value);
106998
107140
  controller.abort(value.reason);
106999
107141
  } else if (value.streamName) {
107000
- const readerCancel = setupAbortStreamReader2(controller, runId, value.streamName, ops, cryptoKey);
107142
+ const readerCancel = setupAbortStreamReader2(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
107001
107143
  tagAbortPair2(controller, value, readerCancel);
107002
107144
  } else {
107003
107145
  tagAbortPair2(controller, value);
@@ -107497,8 +107639,10 @@ function getStepRevivers2(global2 = globalThis, ops, runId, cryptoKey, deploymen
107497
107639
  }
107498
107640
  return writable;
107499
107641
  }, "WritableStream"),
107500
- AbortController: /* @__PURE__ */ __name((value) => reviveAbortController2(value, ops, runId, cryptoKey), "AbortController"),
107501
- AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal2(value, ops, runId, cryptoKey), "AbortSignal")
107642
+ // A step's readers are cancelled when the step returns
107643
+ // (`cancelAbortReaders`), so they may outlive an empty stream.
107644
+ AbortController: /* @__PURE__ */ __name((value) => reviveAbortController2(value, ops, runId, cryptoKey, true), "AbortController"),
107645
+ AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal2(value, ops, runId, cryptoKey, true), "AbortSignal")
107502
107646
  };
107503
107647
  }
107504
107648
  async function maybeEncrypt2(data3, key) {
@@ -107813,7 +107957,7 @@ function getStreamAndRequestRevivers2(allRevivers) {
107813
107957
  }
107814
107958
  return extra;
107815
107959
  }
107816
- var defaultUlid2, FRAME_HEADER_SIZE2, MAX_FRAME_SIZE2, WorkflowServerReadableStream2, FRAMED_STREAM_MAX_RECONNECTS2, getFramedStreamMaxReconnects2, FRAMED_STREAM_MAX_TOTAL_RECONNECTS2, getFramedStreamMaxTotalReconnects2, FRAMED_STREAM_MAX_STALLS_BELOW_TAIL2, FRAMED_STREAM_MIN_STALL_SESSION_MS2, STREAM_FLUSH_INTERVAL_MS2, getEnvStreamFlushIntervalMs2, WorkflowServerWritableStream2, prepareReplayPayload2, STREAM_AND_REQUEST_KEYS2;
107960
+ var defaultUlid2, FRAME_HEADER_SIZE2, MAX_FRAME_SIZE2, WorkflowServerReadableStream2, FRAMED_STREAM_MAX_RECONNECTS2, getFramedStreamMaxReconnects2, FRAMED_STREAM_MAX_TOTAL_RECONNECTS2, getFramedStreamMaxTotalReconnects2, FRAMED_STREAM_MAX_STALLS_BELOW_TAIL2, FRAMED_STREAM_MIN_STALL_SESSION_MS2, STREAM_FLUSH_INTERVAL_MS2, getEnvStreamFlushIntervalMs2, WorkflowServerWritableStream2, LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS2, prepareReplayPayload2, STREAM_AND_REQUEST_KEYS2;
107817
107961
  var init_serialization4 = __esm({
107818
107962
  "../core/dist/serialization.js"() {
107819
107963
  "use strict";
@@ -107829,6 +107973,7 @@ var init_serialization4 = __esm({
107829
107973
  init_private2();
107830
107974
  init_get_world_lazy2();
107831
107975
  init_sealed_box2();
107976
+ init_abort_local2();
107832
107977
  init_abort_stream2();
107833
107978
  init_client2();
107834
107979
  init_compression2();
@@ -108214,6 +108359,7 @@ var init_serialization4 = __esm({
108214
108359
  __name(getWorkflowReducers2, "getWorkflowReducers");
108215
108360
  __name(getStepReducers2, "getStepReducers");
108216
108361
  __name(cancelAbortReaders2, "cancelAbortReaders");
108362
+ LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS2 = 60 * 60 * 1e3;
108217
108363
  __name(setupAbortStreamReader2, "setupAbortStreamReader");
108218
108364
  __name(tagAbortPair2, "tagAbortPair");
108219
108365
  __name(copyAbortInternals2, "copyAbortInternals");
@@ -108386,7 +108532,7 @@ var version7;
108386
108532
  var init_version5 = __esm({
108387
108533
  "../core/dist/version.js"() {
108388
108534
  "use strict";
108389
- version7 = "5.7.0";
108535
+ version7 = "5.7.1";
108390
108536
  }
108391
108537
  });
108392
108538
 
@@ -116948,15 +117094,15 @@ var init_run = __esm({
116948
117094
 
116949
117095
  // ../core/dist/runtime/lifecycle-hooks.js
116950
117096
  function getRegistry3() {
116951
- if (!Object.hasOwn(globalThis, REGISTRY_KEY)) {
116952
- Object.defineProperty(globalThis, REGISTRY_KEY, {
117097
+ if (!Object.hasOwn(globalThis, REGISTRY_KEY3)) {
117098
+ Object.defineProperty(globalThis, REGISTRY_KEY3, {
116953
117099
  value: [],
116954
117100
  writable: false,
116955
117101
  enumerable: false,
116956
117102
  configurable: false
116957
117103
  });
116958
117104
  }
116959
- return globalThis[REGISTRY_KEY];
117105
+ return globalThis[REGISTRY_KEY3];
116960
117106
  }
116961
117107
  function dispatch3(runId, workflowName, event, prepare, invoke) {
116962
117108
  let lifecycleSpan;
@@ -117058,7 +117204,7 @@ function dispatchRunFailedHooks(runId, workflowName, error123, encryptionKey, er
117058
117204
  error: new WorkflowRunFailedError2(runId, await hydrateForHandlers(error123, runId, encryptionKey, ops, onHydrationError), { errorCode })
117059
117205
  }), (hooks, params) => hooks.onRunFailed?.(params));
117060
117206
  }
117061
- var REGISTRY_KEY;
117207
+ var REGISTRY_KEY3;
117062
117208
  var init_lifecycle_hooks = __esm({
117063
117209
  "../core/dist/runtime/lifecycle-hooks.js"() {
117064
117210
  "use strict";
@@ -117071,7 +117217,7 @@ var init_lifecycle_hooks = __esm({
117071
117217
  init_types4();
117072
117218
  init_run();
117073
117219
  init_wait_until2();
117074
- REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@workflow/core//lifecycleHooks");
117220
+ REGISTRY_KEY3 = /* @__PURE__ */ Symbol.for("@workflow/core//lifecycleHooks");
117075
117221
  __name(getRegistry3, "getRegistry");
117076
117222
  __name(dispatch3, "dispatch");
117077
117223
  __name(dispatchRunCompletedHooks, "dispatchRunCompletedHooks");
@@ -121246,6 +121392,9 @@ async function getMaxInlineDurationMs(world, invocationStartTime) {
121246
121392
  return (0, import_ms4.default)("2m");
121247
121393
  }
121248
121394
  function getWorkflowSetupErrorCode(err) {
121395
+ if (DynamicWorkflowsNotEnabledError2.is(err)) {
121396
+ return RUN_ERROR_CODES2.USER_ERROR;
121397
+ }
121249
121398
  if (WorkflowRuntimeError2.is(err)) {
121250
121399
  return RUN_ERROR_CODES2.RUNTIME_ERROR;
121251
121400
  }
@@ -121304,7 +121453,7 @@ async function resolveWorkflowCodeForRun(staticWorkflowCode, workflowRun, getEnc
121304
121453
  return { code: staticWorkflowCode };
121305
121454
  const runLabel = `Workflow run "${workflowRun.runId}" is a dynamic workflow run (source ${dynamicWorkflow.sourceHash.slice(0, 12)})`;
121306
121455
  if (!isDynamicWorkflowsEnabled2()) {
121307
- throw new WorkflowRuntimeError2(`${runLabel}, but this deployment has not enabled dynamic workflows, so its stored code was not executed. Set ${DYNAMIC_WORKFLOWS_ENV2}=1 on the deployment to enable them.`);
121456
+ throw new DynamicWorkflowsNotEnabledError2(`${runLabel}, but dynamic workflows are not enabled for this project on the deployment that received it, so its stored code was not executed.`);
121308
121457
  }
121309
121458
  const expectedWorkflowName = dynamicWorkflowName2(dynamicWorkflow);
121310
121459
  if (workflowRun.workflowName !== expectedWorkflowName) {
@@ -123081,6 +123230,7 @@ async function startSuspensionHookWrites({ suspension, world, run: run3, runId,
123081
123230
  });
123082
123231
  try {
123083
123232
  const streamName = getAbortStreamIdFromToken(queueItem.token);
123233
+ publishLocalAbort2(runId, streamName, abortPayload);
123084
123234
  await world.streams.write(runId, streamName, frameAbortStreamPayload2(abortPayload));
123085
123235
  await world.streams.close(runId, streamName);
123086
123236
  } catch {
@@ -123136,6 +123286,7 @@ var init_suspension_hooks = __esm({
123136
123286
  init_dist10();
123137
123287
  init_encryption5();
123138
123288
  init_logger2();
123289
+ init_abort_local2();
123139
123290
  init_abort_stream2();
123140
123291
  init_hardened2();
123141
123292
  init_serialization4();
@@ -124051,6 +124202,7 @@ async function dispatchPendingOps(params) {
124051
124202
  }
124052
124203
  if (hook.token.startsWith("abrt_") && abortPayload) {
124053
124204
  const streamName = `strm_${hook.token.slice("abrt_".length)}_system_abort`;
124205
+ publishLocalAbort2(runId, streamName, abortPayload);
124054
124206
  try {
124055
124207
  await world.streams.write(runId, streamName, frameAbortStreamPayload2(abortPayload));
124056
124208
  await world.streams.close(runId, streamName);
@@ -124377,6 +124529,7 @@ var init_quickjs_pending_ops = __esm({
124377
124529
  init_dist11();
124378
124530
  init_dist10();
124379
124531
  init_logger2();
124532
+ init_abort_local2();
124380
124533
  init_abort_stream2();
124381
124534
  init_encryption6();
124382
124535
  init_serialization4();
@@ -129230,18 +129383,18 @@ function createQuickJSSerde(vm, capturedRoot) {
129230
129383
  function lookupRegisteredClass(classId) {
129231
129384
  if (classId === void 0)
129232
129385
  return void 0;
129233
- const registry3 = own3(vm.global, sym("workflow-class-registry"));
129234
- if (!registry3 || registry3.isUndefined) {
129235
- registry3?.dispose();
129386
+ const registry5 = own3(vm.global, sym("workflow-class-registry"));
129387
+ if (!registry5 || registry5.isUndefined) {
129388
+ registry5?.dispose();
129236
129389
  return void 0;
129237
129390
  }
129238
129391
  try {
129239
- const getMethod = chained(registry3, "get");
129392
+ const getMethod = chained(registry5, "get");
129240
129393
  if (!getMethod)
129241
129394
  return void 0;
129242
129395
  try {
129243
129396
  const key = vm.newString(classId);
129244
- const cls = call(getMethod, registry3, key);
129397
+ const cls = call(getMethod, registry5, key);
129245
129398
  key.dispose();
129246
129399
  if (cls.isUndefined || cls.typeof !== "function") {
129247
129400
  cls.dispose();
@@ -129252,7 +129405,7 @@ function createQuickJSSerde(vm, capturedRoot) {
129252
129405
  getMethod.dispose();
129253
129406
  }
129254
129407
  } finally {
129255
- registry3.dispose();
129408
+ registry5.dispose();
129256
129409
  }
129257
129410
  }
129258
129411
  __name(lookupRegisteredClass, "lookupRegisteredClass");
@@ -133984,15 +134137,73 @@ var init_in_band_writer = __esm({
133984
134137
  * The slot the next write would take if no other writer appends first:
133985
134138
  * one past every position this writer knows is allocated, including the
133986
134139
  * writes still queued in it. Run-ahead places a speculative event there.
134140
+ *
134141
+ * Each position is counted once. The write being sent is in
134142
+ * `pendingPositions` until it settles, while `knownMaxSlot` can already
134143
+ * cover its positions: the live feed echoes a write before its answer
134144
+ * arrives ({@link observeEvent}), and the answer raises `knownMaxSlot` a
134145
+ * few microtasks before the write settles. Those positions are taken off
134146
+ * ({@link sending}), or the prediction would run past the slot the next
134147
+ * write takes, and a speculative event placed there shares its id with a
134148
+ * later event.
133987
134149
  */
133988
134150
  predictNextSlot() {
133989
- return this.knownMaxSlot + this.pendingPositions + 1;
134151
+ return this.knownMaxSlot + this.pendingPositions - (this.sending?.covered ?? 0) + 1;
133990
134152
  }
133991
- /** A position another writer took, seen in a load, a report or the feed. */
134153
+ /** A position another writer took, seen in a load or a report. */
133992
134154
  observeSlot(slot) {
133993
134155
  if (slot > this.knownMaxSlot)
133994
134156
  this.knownMaxSlot = slot;
133995
134157
  }
134158
+ /**
134159
+ * An event seen outside this writer's own answers (the live feed, an
134160
+ * incremental load): its position is allocated. When it is an event of the
134161
+ * write being sent (the feed's echo, ahead of the answer), that write's
134162
+ * position is now covered by `knownMaxSlot` and is not counted again by
134163
+ * {@link predictNextSlot}.
134164
+ */
134165
+ observeEvent(event) {
134166
+ const slot = eventIdToSlot2(event.eventId);
134167
+ if (slot === null || slot <= this.knownMaxSlot)
134168
+ return;
134169
+ this.knownMaxSlot = slot;
134170
+ const sending = this.sending;
134171
+ if (!sending || sending.covered >= sending.positions)
134172
+ return;
134173
+ const at3 = sending.unechoed.findIndex((sent) => sent.eventType === event.eventType && sent.correlationId === event.correlationId);
134174
+ if (at3 === -1)
134175
+ return;
134176
+ sending.unechoed.splice(at3, 1);
134177
+ sending.covered++;
134178
+ }
134179
+ /**
134180
+ * The write being sent: how many positions it asks for, how many of them
134181
+ * `knownMaxSlot` already covers, and its events the live feed has not
134182
+ * echoed yet. Cleared where the write leaves `pendingPositions`.
134183
+ */
134184
+ sending;
134185
+ beginSend(events) {
134186
+ this.sending = {
134187
+ positions: events.length,
134188
+ covered: 0,
134189
+ unechoed: events.map((event) => ({
134190
+ eventType: event.eventType,
134191
+ correlationId: event.correlationId
134192
+ }))
134193
+ };
134194
+ }
134195
+ /**
134196
+ * The write being sent was answered, or failed: whatever it allocated is
134197
+ * in `knownMaxSlot` (the caller noted the answer's slots just before), so
134198
+ * none of its positions is predicted on top of that.
134199
+ */
134200
+ answerSend() {
134201
+ const sending = this.sending;
134202
+ if (!sending)
134203
+ return;
134204
+ sending.covered = sending.positions;
134205
+ sending.unechoed = [];
134206
+ }
133996
134207
  /**
133997
134208
  * Stops the writer for good with `error`, as a failed write would: every
133998
134209
  * later write and {@link assertActive} throw it.
@@ -134034,13 +134245,16 @@ var init_in_band_writer = __esm({
134034
134245
  let result2;
134035
134246
  try {
134036
134247
  const position5 = this.sendPosition(params?.eventCount);
134248
+ const fence = this.fenceParams();
134249
+ this.beginSend([data3]);
134037
134250
  const written = await this.world.events.create(this.runId, data3, {
134038
134251
  ...params,
134039
134252
  ...position5,
134040
- ...this.fenceParams()
134253
+ ...fence
134041
134254
  });
134042
134255
  this.noteComplete(position5, written, [written.event]);
134043
134256
  const inferred = this.allocatedBy([written.event], knownAtSend);
134257
+ this.answerSend();
134044
134258
  const allocated = written.allocated ?? inferred;
134045
134259
  this.advance(allocated);
134046
134260
  result2 = written.event ? {
@@ -134048,6 +134262,7 @@ var init_in_band_writer = __esm({
134048
134262
  event: withWrittenEventData(written.event, data3, allocated > 0)
134049
134263
  } : written;
134050
134264
  } catch (error123) {
134265
+ this.answerSend();
134051
134266
  throw this.stop(error123, required3);
134052
134267
  }
134053
134268
  this.accepted(result2.event);
@@ -134157,6 +134372,7 @@ var init_in_band_writer = __esm({
134157
134372
  const knownAtSend = this.knownMaxSlot;
134158
134373
  const position5 = this.sendPosition(first.params.eventCount);
134159
134374
  let result2;
134375
+ this.beginSend(events.map(({ event }) => event));
134160
134376
  try {
134161
134377
  result2 = await this.world.events.createBatch.call(this.world.events, this.runId, events, {
134162
134378
  ...position5,
@@ -134165,6 +134381,7 @@ var init_in_band_writer = __esm({
134165
134381
  ...this.fenceParams()
134166
134382
  });
134167
134383
  } catch (error123) {
134384
+ this.answerSend();
134168
134385
  const stopped = this.stop(error123, true);
134169
134386
  for (const write of group)
134170
134387
  write.reject(stopped);
@@ -134177,6 +134394,7 @@ var init_in_band_writer = __esm({
134177
134394
  if (item.error === void 0)
134178
134395
  this.noteSlot(item.event.eventId);
134179
134396
  }
134397
+ this.answerSend();
134180
134398
  this.advance(result2.allocated ?? events.length - replayed);
134181
134399
  let offset3 = 0;
134182
134400
  let failed;
@@ -134226,6 +134444,7 @@ var init_in_band_writer = __esm({
134226
134444
  }
134227
134445
  } finally {
134228
134446
  this.pendingPositions -= total;
134447
+ this.sending = void 0;
134229
134448
  }
134230
134449
  }
134231
134450
  /**
@@ -134284,6 +134503,7 @@ var init_in_band_writer = __esm({
134284
134503
  const knownAtSend = this.knownMaxSlot;
134285
134504
  const position5 = this.sendPosition(params?.eventCount);
134286
134505
  try {
134506
+ this.beginSend(events.map(({ event }) => event));
134287
134507
  const result2 = await createBatch.call(this.world.events, this.runId, events, {
134288
134508
  ...params,
134289
134509
  ...position5,
@@ -134296,6 +134516,7 @@ var init_in_band_writer = __esm({
134296
134516
  if (item.error === void 0)
134297
134517
  this.noteSlot(item.event.eventId);
134298
134518
  }
134519
+ this.answerSend();
134299
134520
  this.advance(result2.allocated ?? events.length - replayed);
134300
134521
  const answered = {
134301
134522
  ...result2,
@@ -134320,6 +134541,7 @@ var init_in_band_writer = __esm({
134320
134541
  }
134321
134542
  return answered;
134322
134543
  } catch (error123) {
134544
+ this.answerSend();
134323
134545
  throw this.stop(error123, required3);
134324
134546
  }
134325
134547
  });
@@ -134408,6 +134630,8 @@ var init_in_band_writer = __esm({
134408
134630
  this.pendingPositions += positions;
134409
134631
  const settle3 = /* @__PURE__ */ __name(() => {
134410
134632
  this.pendingPositions -= positions;
134633
+ if (positions > 0)
134634
+ this.sending = void 0;
134411
134635
  }, "settle");
134412
134636
  const guarded = /* @__PURE__ */ __name(async () => {
134413
134637
  try {
@@ -135074,6 +135298,65 @@ var init_run_ahead = __esm({
135074
135298
  }
135075
135299
  });
135076
135300
 
135301
+ // ../core/dist/runtime/spec9/speculative-placement.js
135302
+ function isSameWrite(speculative, committed) {
135303
+ return speculative.eventType === committed.eventType && speculative.correlationId === committed.correlationId;
135304
+ }
135305
+ function speculativeSlotFor(input3) {
135306
+ let floor = input3.heldMaxSlot ?? 0;
135307
+ for (const slot of input3.unconfirmedSlots) {
135308
+ if (slot > floor)
135309
+ floor = slot;
135310
+ }
135311
+ return Math.max(input3.predicted, floor + 1);
135312
+ }
135313
+ function displacesSpeculation(event, speculativeAt) {
135314
+ const speculative = speculativeAt(event.eventId);
135315
+ return speculative !== void 0 && !isSameWrite(speculative, event);
135316
+ }
135317
+ function foldReadEvents(events, speculativeAt) {
135318
+ const fold = [];
135319
+ let displaced = false;
135320
+ for (const event of events) {
135321
+ const speculative = speculativeAt(event.eventId);
135322
+ if (speculative === void 0) {
135323
+ fold.push(event);
135324
+ } else if (!isSameWrite(speculative, event)) {
135325
+ displaced = true;
135326
+ }
135327
+ }
135328
+ return { fold, displaced };
135329
+ }
135330
+ function settledOutcomeFold(input3) {
135331
+ if (!input3.writtenAhead)
135332
+ return "fold";
135333
+ if (!input3.unconfirmed)
135334
+ return "committed";
135335
+ return input3.slotHeld ? "displaced" : "fold";
135336
+ }
135337
+ function committedBelowPrediction(aliases) {
135338
+ for (const [predicted, committed] of aliases) {
135339
+ const predictedSlot = eventIdToSlot2(predicted);
135340
+ const committedSlot = eventIdToSlot2(committed);
135341
+ if (predictedSlot !== null && committedSlot !== null && committedSlot < predictedSlot) {
135342
+ return true;
135343
+ }
135344
+ }
135345
+ return false;
135346
+ }
135347
+ var init_speculative_placement = __esm({
135348
+ "../core/dist/runtime/spec9/speculative-placement.js"() {
135349
+ "use strict";
135350
+ init_dist10();
135351
+ __name(isSameWrite, "isSameWrite");
135352
+ __name(speculativeSlotFor, "speculativeSlotFor");
135353
+ __name(displacesSpeculation, "displacesSpeculation");
135354
+ __name(foldReadEvents, "foldReadEvents");
135355
+ __name(settledOutcomeFold, "settledOutcomeFold");
135356
+ __name(committedBelowPrediction, "committedBelowPrediction");
135357
+ }
135358
+ });
135359
+
135077
135360
  // ../core/dist/runtime/spec9/step-executor.js
135078
135361
  import { types as types13 } from "node:util";
135079
135362
  function mayRunBeforeItsStart(stepName) {
@@ -138960,6 +139243,27 @@ async function runDelivery2(delivery, continuation) {
138960
139243
  const repairWrites = [];
138961
139244
  const speculativeSlots = /* @__PURE__ */ new Set();
138962
139245
  let runAheadRepair = false;
139246
+ const everSpeculative = /* @__PURE__ */ new WeakSet();
139247
+ const speculativeEventAt = /* @__PURE__ */ __name((eventId) => {
139248
+ for (const event of speculativeEvents) {
139249
+ if (event.eventId === eventId)
139250
+ return event;
139251
+ }
139252
+ return void 0;
139253
+ }, "speculativeEventAt");
139254
+ let noteDisplacedSpeculation = /* @__PURE__ */ __name((_cause) => {
139255
+ runAheadRepair = true;
139256
+ }, "noteDisplacedSpeculation");
139257
+ const foldReadIntoLog = /* @__PURE__ */ __name((events, cause) => {
139258
+ assert9(log, "The event log is loaded to fold read events");
139259
+ const { fold, displaced } = foldReadEvents(events, speculativeEventAt);
139260
+ if (displaced)
139261
+ noteDisplacedSpeculation(cause);
139262
+ for (const event of fold)
139263
+ prepareReplayEvent(event);
139264
+ indexOf(log.events).merge(fold);
139265
+ return !displaced;
139266
+ }, "foldReadIntoLog");
138963
139267
  let logBehind = false;
138964
139268
  const ownSlots = /* @__PURE__ */ new Set();
138965
139269
  let passConsumedSlot = 0;
@@ -138983,6 +139287,11 @@ async function runDelivery2(delivery, continuation) {
138983
139287
  }
138984
139288
  const own3 = result2.event;
138985
139289
  const report = (result2.events ?? []).filter((event) => event.eventId !== own3.eventId);
139290
+ if ([own3, ...report].some((event) => displacesSpeculation(event, speculativeEventAt))) {
139291
+ noteDisplacedSpeculation("response");
139292
+ repairWrites.push(result2);
139293
+ return;
139294
+ }
138986
139295
  const below = Math.max(indexOf(log.events).maxSlot() ?? 0, maxEventSlot(report) ?? 0);
138987
139296
  const ownSlot = eventIdToSlot2(own3.eventId);
138988
139297
  if (ownSlot !== null && ownSlot > below + 1) {
@@ -139034,6 +139343,7 @@ async function runDelivery2(delivery, continuation) {
139034
139343
  }
139035
139344
  logBehind = false;
139036
139345
  log = { events: loaded.events, cursor: loaded.cursor };
139346
+ writer.observeSlot(indexOf(log.events).maxSlot() ?? 0);
139037
139347
  return log;
139038
139348
  }, "fullLoad");
139039
139349
  const loadAfter = /* @__PURE__ */ __name(async () => {
@@ -139050,11 +139360,11 @@ async function runDelivery2(delivery, continuation) {
139050
139360
  label: "Incremental event log read",
139051
139361
  runId
139052
139362
  });
139053
- for (const event of page.events) {
139054
- prepareReplayEvent(event);
139363
+ for (const event of page.events)
139364
+ writer.observeEvent(event);
139365
+ if (foldReadIntoLog(page.events, "read")) {
139366
+ log.cursor = page.cursor ?? log.cursor;
139055
139367
  }
139056
- indexOf(log.events).merge(page.events);
139057
- log.cursor = page.cursor ?? log.cursor;
139058
139368
  return log;
139059
139369
  }, "loadAfter");
139060
139370
  let workflowRun;
@@ -139816,6 +140126,7 @@ async function runDelivery2(delivery, continuation) {
139816
140126
  return log?.events.some((e) => e.eventId === event.eventId) ?? false;
139817
140127
  }, "isOwnEvent");
139818
140128
  const settledInline = [];
140129
+ let awaitedOutcomeWrites = 0;
139819
140130
  const creationsInFlight = /* @__PURE__ */ new Set();
139820
140131
  const creationBatchesQueuing = /* @__PURE__ */ new Set();
139821
140132
  let trailingCreationFailure;
@@ -139842,30 +140153,23 @@ async function runDelivery2(delivery, continuation) {
139842
140153
  progressWaiter = void 0;
139843
140154
  waiter?.();
139844
140155
  }, "notifyProgress");
140156
+ const flushFeedEvents = /* @__PURE__ */ __name(() => {
140157
+ if (pendingFeedEvents.length === 0)
140158
+ return;
140159
+ const events = pendingFeedEvents.splice(0);
140160
+ for (const event of events) {
140161
+ writer.observeEvent(event);
140162
+ checkRunAheadHazard(event, "live feed");
140163
+ }
140164
+ if (!runAheadRepair)
140165
+ foldReadIntoLog(events, "feed");
140166
+ }, "flushFeedEvents");
139845
140167
  const flushPending = /* @__PURE__ */ __name(() => {
139846
140168
  if (!log)
139847
140169
  return;
139848
140170
  if (turboStartLanded)
139849
140171
  absorbWrite(turboStartLanded);
139850
- if (pendingFeedEvents.length > 0) {
139851
- const events = pendingFeedEvents.splice(0).filter((event) => {
139852
- const slot = eventIdToSlot2(event.eventId);
139853
- if (slot !== null)
139854
- writer.observeSlot(slot);
139855
- checkRunAheadHazard(event, "live feed");
139856
- if (slot !== null && speculativeSlots.has(slot)) {
139857
- const own3 = speculationsBySlot.get(slot);
139858
- if (own3 && (own3.event.eventType !== event.eventType || own3.event.correlationId !== event.correlationId)) {
139859
- markRunAheadRepair("feed");
139860
- }
139861
- return false;
139862
- }
139863
- return !runAheadRepair;
139864
- });
139865
- for (const event of events)
139866
- prepareReplayEvent(event);
139867
- indexOf(log.events).merge(events);
139868
- }
140172
+ flushFeedEvents();
139869
140173
  if (pendingAbsorbs.length > 0) {
139870
140174
  const results = pendingAbsorbs.splice(0);
139871
140175
  results.sort((a, b) => (eventIdToSlot2(a.event?.eventId ?? "") ?? 0) - (eventIdToSlot2(b.event?.eventId ?? "") ?? 0));
@@ -139896,7 +140200,11 @@ async function runDelivery2(delivery, continuation) {
139896
140200
  if (liveFeed || !log)
139897
140201
  return;
139898
140202
  liveFeed = new LiveLogFeed(world, runId, {
139899
- afterSlot: indexOf(log.events).maxSlot() ?? 0,
140203
+ // From the highest confirmed position: a speculative
140204
+ // event sits at a predicted slot, and another
140205
+ // writer's event that takes that slot must still be
140206
+ // offered.
140207
+ afterSlot: slotSnapshot().eventCount ?? 0,
139900
140208
  cursor: log.cursor,
139901
140209
  pollIntervalMs: getOrchestratorPollIntervalMs(),
139902
140210
  feedPollIntervalMs: getOrchestratorFeedPollIntervalMs(),
@@ -139978,7 +140286,13 @@ async function runDelivery2(delivery, continuation) {
139978
140286
  * Counted once per repair, by what found it first.
139979
140287
  */
139980
140288
  repairs: 0,
139981
- repairsByCause: { feed: 0, outcome: 0, creation: 0 },
140289
+ repairsByCause: {
140290
+ feed: 0,
140291
+ outcome: 0,
140292
+ creation: 0,
140293
+ response: 0,
140294
+ read: 0
140295
+ },
139982
140296
  /** Wall time spent repairing, in milliseconds. */
139983
140297
  repairMs: 0,
139984
140298
  /** Repairs whose retained session survived them. */
@@ -140001,6 +140315,12 @@ async function runDelivery2(delivery, continuation) {
140001
140315
  runAheadStats.repairsByCause[cause]++;
140002
140316
  recordRunAheadSpan();
140003
140317
  }, "markRunAheadRepair");
140318
+ noteDisplacedSpeculation = markRunAheadRepair;
140319
+ const nextSpeculativeSlot = /* @__PURE__ */ __name(() => speculativeSlotFor({
140320
+ predicted: writer.predictNextSlot(),
140321
+ heldMaxSlot: log ? indexOf(log.events).maxSlot() : void 0,
140322
+ unconfirmedSlots: speculativeSlots
140323
+ }), "nextSpeculativeSlot");
140004
140324
  const outOfBandBoundaries = {
140005
140325
  inert: 0,
140006
140326
  observedHook: 0,
@@ -140029,6 +140349,8 @@ async function runDelivery2(delivery, continuation) {
140029
140349
  "workflow.run_ahead.repairs.feed": runAheadStats.repairsByCause.feed,
140030
140350
  "workflow.run_ahead.repairs.outcome": runAheadStats.repairsByCause.outcome,
140031
140351
  "workflow.run_ahead.repairs.creation": runAheadStats.repairsByCause.creation,
140352
+ "workflow.run_ahead.repairs.response": runAheadStats.repairsByCause.response,
140353
+ "workflow.run_ahead.repairs.read": runAheadStats.repairsByCause.read,
140032
140354
  "workflow.run_ahead.repair_ms": runAheadStats.repairMs,
140033
140355
  "workflow.run_ahead.repairs_retained": runAheadStats.repairsRetained,
140034
140356
  "workflow.run_ahead.repair_reads": runAheadStats.repairReads,
@@ -140107,6 +140429,15 @@ async function runDelivery2(delivery, continuation) {
140107
140429
  return runAheadRepair ? "repair" : "clean";
140108
140430
  }
140109
140431
  __name(drainRunAhead, "drainRunAhead");
140432
+ async function repairRunAheadIfDue() {
140433
+ if (!runAheadRepair)
140434
+ return;
140435
+ await settleRunAhead();
140436
+ if (runAheadFailure !== void 0)
140437
+ throw runAheadFailure;
140438
+ await repairRunAhead();
140439
+ }
140440
+ __name(repairRunAheadIfDue, "repairRunAheadIfDue");
140110
140441
  async function repairRunAhead() {
140111
140442
  const startedAt = Date.now();
140112
140443
  await writer.idle();
@@ -140147,6 +140478,8 @@ async function runDelivery2(delivery, continuation) {
140147
140478
  runAheadStats.repairReads++;
140148
140479
  await loadAfter();
140149
140480
  }
140481
+ if (committedBelowPrediction(repairAliases))
140482
+ session = null;
140150
140483
  if (session) {
140151
140484
  const sensitive = new Set(runAheadSensitiveHookIds);
140152
140485
  pendingRebase = {
@@ -140168,7 +140501,7 @@ async function runDelivery2(delivery, continuation) {
140168
140501
  __name(repairRunAhead, "repairRunAhead");
140169
140502
  function writeOutcomeAhead(data3, params, context2) {
140170
140503
  const occurredAt = /* @__PURE__ */ new Date();
140171
- const slot = writer.predictNextSlot();
140504
+ const slot = nextSpeculativeSlot();
140172
140505
  const event = {
140173
140506
  ...data3,
140174
140507
  runId,
@@ -140177,6 +140510,7 @@ async function runDelivery2(delivery, continuation) {
140177
140510
  };
140178
140511
  speculativeSlots.add(slot);
140179
140512
  speculativeEvents.add(event);
140513
+ everSpeculative.add(event);
140180
140514
  const releaseContext = noteRunAheadContext(context2);
140181
140515
  const commit = writer.createAhead(data3, {
140182
140516
  ...params,
@@ -140225,7 +140559,7 @@ async function runDelivery2(delivery, continuation) {
140225
140559
  function writeCreationAhead(events, context2) {
140226
140560
  assert9(log, "The event log is loaded to run ahead");
140227
140561
  const occurredAt = /* @__PURE__ */ new Date();
140228
- const first = writer.predictNextSlot();
140562
+ const first = nextSpeculativeSlot();
140229
140563
  const speculative = events.map((data3, index) => ({
140230
140564
  ...data3,
140231
140565
  runId,
@@ -140313,6 +140647,7 @@ async function runDelivery2(delivery, continuation) {
140313
140647
  speculative.forEach((event, index) => {
140314
140648
  speculativeSlots.add(first + index);
140315
140649
  speculativeEvents.add(event);
140650
+ everSpeculative.add(event);
140316
140651
  speculationsBySlot.set(first + index, {
140317
140652
  event,
140318
140653
  settled: settled3
@@ -140450,16 +140785,13 @@ async function runDelivery2(delivery, continuation) {
140450
140785
  }
140451
140786
  let replayStart = 0;
140452
140787
  try {
140453
- if (runAheadRepair) {
140454
- await settleRunAhead();
140455
- if (runAheadFailure !== void 0) {
140456
- throw runAheadFailure;
140457
- }
140458
- await repairRunAhead();
140459
- }
140788
+ await repairRunAheadIfDue();
140460
140789
  flushPending();
140461
- if (logBehind)
140790
+ await repairRunAheadIfDue();
140791
+ if (logBehind) {
140462
140792
  await loadAfter();
140793
+ await repairRunAheadIfDue();
140794
+ }
140463
140795
  assert9(log, "The event log is loaded in the loop");
140464
140796
  if (hasRecordedTerminalRunEvent(log.events, runId)) {
140465
140797
  recordTerminalRun(world, runId);
@@ -140492,12 +140824,13 @@ async function runDelivery2(delivery, continuation) {
140492
140824
  assert9(log, "The event log is loaded in the loop");
140493
140825
  if (due.length > 0)
140494
140826
  await armTimers(log.events, "other-chains");
140495
- if (speculationsBySlot.size > 0 && indexOf(log.events).slotGap() !== void 0) {
140827
+ if (speculationsBySlot.size > 0 && (awaitedOutcomeWrites > 0 || indexOf(log.events).slotGap() !== void 0)) {
140496
140828
  if (await drainRunAhead() === "repair") {
140497
140829
  await repairRunAhead();
140498
140830
  }
140499
140831
  await writer.idle();
140500
140832
  flushPending();
140833
+ await repairRunAheadIfDue();
140501
140834
  }
140502
140835
  if (indexOf(log.events).slotGap() !== void 0) {
140503
140836
  const settled3 = await settleEventSlotGap(runId, { events: log.events, cursor: log.cursor }, { specVersion: SPEC_VERSION_SINGLE_ORCHESTRATOR2 });
@@ -141136,11 +141469,17 @@ async function runDelivery2(delivery, continuation) {
141136
141469
  return writeOutcomeAhead(data3, params, runAhead);
141137
141470
  }
141138
141471
  }
141139
- const result2 = await writer.create(withRetryCreator(data3, creatorMessageId), {
141140
- ...params,
141141
- ...slotSnapshot(),
141142
- resolveData: REPLAY_RESOLVE_DATA
141143
- });
141472
+ awaitedOutcomeWrites++;
141473
+ let result2;
141474
+ try {
141475
+ result2 = await writer.create(withRetryCreator(data3, creatorMessageId), {
141476
+ ...params,
141477
+ ...slotSnapshot(),
141478
+ resolveData: REPLAY_RESOLVE_DATA
141479
+ });
141480
+ } finally {
141481
+ awaitedOutcomeWrites--;
141482
+ }
141144
141483
  pendingAbsorbs.push(result2);
141145
141484
  return result2;
141146
141485
  }, "createEvent"),
@@ -141270,8 +141609,18 @@ async function runDelivery2(delivery, continuation) {
141270
141609
  pendingStreamOps = true;
141271
141610
  }
141272
141611
  assert9(log, "The event log is loaded after inline steps");
141612
+ const outcomeEvent = result2.result.event;
141613
+ const outcomeFold = settledOutcomeFold({
141614
+ writtenAhead: outcomeEvent !== void 0 && everSpeculative.has(outcomeEvent),
141615
+ unconfirmed: outcomeEvent !== void 0 && speculativeEvents.has(outcomeEvent),
141616
+ slotHeld: outcomeEvent !== void 0 && indexOf(log.events).has(outcomeEvent.eventId)
141617
+ });
141273
141618
  if (runAheadRepair) {
141274
141619
  reload = true;
141620
+ } else if (outcomeFold === "committed") {
141621
+ } else if (outcomeFold === "displaced") {
141622
+ markRunAheadRepair("outcome");
141623
+ reload = true;
141275
141624
  } else if (consumeOwnResolvingWrite(indexOf(log.events), preparedResult(result2.result)).type === "reload") {
141276
141625
  reload = true;
141277
141626
  }
@@ -141651,6 +142000,7 @@ var init_delivery2 = __esm({
141651
142000
  init_log_state();
141652
142001
  init_read_deadline();
141653
142002
  init_run_ahead();
142003
+ init_speculative_placement();
141654
142004
  init_step_executor2();
141655
142005
  init_step_handler();
141656
142006
  init_step_message();
@@ -142349,6 +142699,10 @@ var START_HOOK_ADMISSION_REJECTED;
142349
142699
  var START_HOOK_ADMISSION_DISABLED;
142350
142700
  var START_HOOK_CANDIDATE_CANCELLED;
142351
142701
  var WorkflowStartError;
142702
+ var DYNAMIC_WORKFLOWS_ENV_VAR;
142703
+ var DYNAMIC_WORKFLOWS_DOCS_URL;
142704
+ var DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT;
142705
+ var DynamicWorkflowsNotEnabledError;
142352
142706
  var WorkflowRunFailedError;
142353
142707
  var WorkflowRunNotCompletedError;
142354
142708
  var WorkflowRuntimeError;
@@ -142503,6 +142857,40 @@ Caused by: ${options.cause.stack}`;
142503
142857
  return isError(value) && value.name === "WorkflowStartError";
142504
142858
  }
142505
142859
  };
142860
+ DYNAMIC_WORKFLOWS_ENV_VAR = "WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS";
142861
+ DYNAMIC_WORKFLOWS_DOCS_URL = "https://workflow-sdk.dev/docs/advanced/dynamic-workflows#enabling-dynamic-workflows";
142862
+ DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT = `Set the ${DYNAMIC_WORKFLOWS_ENV_VAR}=1 environment variable on your project, then redeploy (or restart your dev server) so the new value takes effect.`;
142863
+ DynamicWorkflowsNotEnabledError = class extends WorkflowError {
142864
+ static {
142865
+ __name(this, "DynamicWorkflowsNotEnabledError");
142866
+ }
142867
+ static {
142868
+ __name2(this, "DynamicWorkflowsNotEnabledError");
142869
+ }
142870
+ fatal = true;
142871
+ /**
142872
+ * @param message - What was refused, e.g. that `start()` created no run.
142873
+ * The fix-it hint and a docs link are appended to it.
142874
+ */
142875
+ constructor(message, options) {
142876
+ super(appendFramedDetails(message, [
142877
+ {
142878
+ label: "hint",
142879
+ value: DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT
142880
+ },
142881
+ {
142882
+ label: "docs",
142883
+ value: DYNAMIC_WORKFLOWS_DOCS_URL
142884
+ }
142885
+ ]), {
142886
+ cause: options?.cause
142887
+ });
142888
+ this.name = "DynamicWorkflowsNotEnabledError";
142889
+ }
142890
+ static is(value) {
142891
+ return isError(value) && value.name === "DynamicWorkflowsNotEnabledError";
142892
+ }
142893
+ };
142506
142894
  WorkflowRunFailedError = class extends WorkflowError {
142507
142895
  static {
142508
142896
  __name(this, "WorkflowRunFailedError");
@@ -161675,24 +162063,24 @@ function serializeDefaultValue(value, schema, ctx, json22, params) {
161675
162063
  __name(serializeDefaultValue, "serializeDefaultValue");
161676
162064
  function toJSONSchema(input22, params) {
161677
162065
  if ("_idmap" in input22) {
161678
- const registry22 = input22;
162066
+ const registry32 = input22;
161679
162067
  const ctx2 = initializeContext({
161680
162068
  ...params,
161681
162069
  processors: allProcessors
161682
162070
  });
161683
162071
  const defs = {};
161684
- for (const entry of registry22._idmap.entries()) {
162072
+ for (const entry of registry32._idmap.entries()) {
161685
162073
  const [_, schema] = entry;
161686
162074
  processSchema(schema, ctx2);
161687
162075
  }
161688
162076
  const schemas = {};
161689
162077
  const external = {
161690
- registry: registry22,
162078
+ registry: registry32,
161691
162079
  uri: params?.uri,
161692
162080
  defs
161693
162081
  };
161694
162082
  ctx2.external = external;
161695
- for (const entry of registry22._idmap.entries()) {
162083
+ for (const entry of registry32._idmap.entries()) {
161696
162084
  const [key, schema] = entry;
161697
162085
  extractDefs(ctx2, schema);
161698
162086
  assignProp(schemas, key, finalize(ctx2, schema));
@@ -174519,6 +174907,84 @@ var init_get_world_lazy = __esm2({
174519
174907
  __name2(getWorldLazy, "getWorldLazy");
174520
174908
  }
174521
174909
  });
174910
+ function registry2() {
174911
+ const holder = globalThis;
174912
+ holder[REGISTRY_KEY] ??= {
174913
+ listeners: /* @__PURE__ */ new Map(),
174914
+ published: /* @__PURE__ */ new Map()
174915
+ };
174916
+ return holder[REGISTRY_KEY];
174917
+ }
174918
+ __name(registry2, "registry2");
174919
+ function keyOf(runId, streamName) {
174920
+ return `${runId}\0${streamName}`;
174921
+ }
174922
+ __name(keyOf, "keyOf");
174923
+ function prune(published, now22) {
174924
+ for (const [key, entry] of published) {
174925
+ if (now22 - entry.at < PUBLISHED_TTL_MS && published.size <= MAX_PUBLISHED) break;
174926
+ published.delete(key);
174927
+ }
174928
+ }
174929
+ __name(prune, "prune");
174930
+ function publishLocalAbort(runId, streamName, packet) {
174931
+ const { listeners, published } = registry2();
174932
+ const key = keyOf(runId, streamName);
174933
+ const now22 = Date.now();
174934
+ published.delete(key);
174935
+ published.set(key, {
174936
+ packet,
174937
+ at: now22
174938
+ });
174939
+ prune(published, now22);
174940
+ for (const listener of listeners.get(key) ?? []) {
174941
+ try {
174942
+ listener(packet);
174943
+ } catch {
174944
+ }
174945
+ }
174946
+ }
174947
+ __name(publishLocalAbort, "publishLocalAbort");
174948
+ function onLocalAbort(runId, streamName, listener) {
174949
+ const { listeners, published } = registry2();
174950
+ const key = keyOf(runId, streamName);
174951
+ prune(published, Date.now());
174952
+ const recent = published.get(key);
174953
+ if (recent) {
174954
+ listener(recent.packet);
174955
+ return () => {
174956
+ };
174957
+ }
174958
+ let set22 = listeners.get(key);
174959
+ if (!set22) {
174960
+ set22 = /* @__PURE__ */ new Set();
174961
+ listeners.set(key, set22);
174962
+ }
174963
+ set22.add(listener);
174964
+ return () => {
174965
+ const current22 = listeners.get(key);
174966
+ if (!current22) return;
174967
+ current22.delete(listener);
174968
+ if (current22.size === 0) listeners.delete(key);
174969
+ };
174970
+ }
174971
+ __name(onLocalAbort, "onLocalAbort");
174972
+ var REGISTRY_KEY;
174973
+ var PUBLISHED_TTL_MS;
174974
+ var MAX_PUBLISHED;
174975
+ var init_abort_local = __esm2({
174976
+ "../core/dist/serialization/abort-local.js"() {
174977
+ "use strict";
174978
+ REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@workflow/core//localAbortDelivery");
174979
+ PUBLISHED_TTL_MS = 6e4;
174980
+ MAX_PUBLISHED = 256;
174981
+ __name2(registry2, "registry");
174982
+ __name2(keyOf, "keyOf");
174983
+ __name2(prune, "prune");
174984
+ __name2(publishLocalAbort, "publishLocalAbort");
174985
+ __name2(onLocalAbort, "onLocalAbort");
174986
+ }
174987
+ });
174522
174988
  function frameAbortStreamPayload(payload) {
174523
174989
  if (payload.length < HEADER_SIZE || payload.length > MAX_PACKET_SIZE) {
174524
174990
  throw new StreamError("Invalid abort stream packet length");
@@ -175001,12 +175467,12 @@ var init_hardened = __esm2({
175001
175467
  });
175002
175468
  function getRegistry(global2 = globalThis) {
175003
175469
  const g = global2;
175004
- let registry22 = g[WORKFLOW_CLASS_REGISTRY];
175005
- if (!registry22) {
175006
- registry22 = /* @__PURE__ */ new Map();
175007
- g[WORKFLOW_CLASS_REGISTRY] = registry22;
175470
+ let registry32 = g[WORKFLOW_CLASS_REGISTRY];
175471
+ if (!registry32) {
175472
+ registry32 = /* @__PURE__ */ new Map();
175473
+ g[WORKFLOW_CLASS_REGISTRY] = registry32;
175008
175474
  }
175009
- return registry22;
175475
+ return registry32;
175010
175476
  }
175011
175477
  __name(getRegistry, "getRegistry");
175012
175478
  function getSerializationClass(classId, global2) {
@@ -179794,7 +180260,7 @@ var version2;
179794
180260
  var init_version = __esm2({
179795
180261
  "../core/dist/version.js"() {
179796
180262
  "use strict";
179797
- version2 = "5.7.0";
180263
+ version2 = "5.7.1";
179798
180264
  }
179799
180265
  });
179800
180266
  function safetyCheckDelayMs(index) {
@@ -217759,7 +218225,7 @@ var version3;
217759
218225
  var init_version2 = __esm2({
217760
218226
  "../world-vercel/dist/version.js"() {
217761
218227
  "use strict";
217762
- version3 = "5.7.0";
218228
+ version3 = "5.7.1";
217763
218229
  }
217764
218230
  });
217765
218231
  function getQueueAgentOptions2() {
@@ -230305,12 +230771,12 @@ ${content.join(`
230305
230771
  return this._map.has(schema);
230306
230772
  }
230307
230773
  };
230308
- function registry22() {
230774
+ function registry32() {
230309
230775
  return new $ZodRegistry22();
230310
230776
  }
230311
- __name(registry22, "registry2");
230312
- __name2(registry22, "registry");
230313
- (_a22 = globalThis).__zod_globalRegistry ?? (_a22.__zod_globalRegistry = registry22());
230777
+ __name(registry32, "registry3");
230778
+ __name2(registry32, "registry");
230779
+ (_a22 = globalThis).__zod_globalRegistry ?? (_a22.__zod_globalRegistry = registry32());
230314
230780
  var globalRegistry22 = globalThis.__zod_globalRegistry;
230315
230781
  function snapshotChecks22(def) {
230316
230782
  return def.checks && (def.checks = [
@@ -244587,10 +245053,10 @@ function registerHandlerForFile(filePath, handler, client, options) {
244587
245053
  const absolutePath = path7.isAbsolute(filePath) ? filePath : path7.resolve(process.cwd(), filePath);
244588
245054
  const fileMappings = findMappingsForFile(absolutePath);
244589
245055
  if (fileMappings.length === 0) return false;
244590
- const registry22 = getHandlerRegistry();
245056
+ const registry32 = getHandlerRegistry();
244591
245057
  for (const mapping of fileMappings) {
244592
245058
  const key = mapping.topic;
244593
- const existing = registry22.get(key) ?? [];
245059
+ const existing = registry32.get(key) ?? [];
244594
245060
  const nextEntry = {
244595
245061
  consumerGroup: mapping.consumer,
244596
245062
  handler,
@@ -244603,7 +245069,7 @@ function registerHandlerForFile(filePath, handler, client, options) {
244603
245069
  } else {
244604
245070
  existing.push(nextEntry);
244605
245071
  }
244606
- registry22.set(key, existing);
245072
+ registry32.set(key, existing);
244607
245073
  }
244608
245074
  return true;
244609
245075
  }
@@ -244638,9 +245104,9 @@ Add a trigger to vercel.json:
244638
245104
  }
244639
245105
  __name(registerDevHandler, "registerDevHandler");
244640
245106
  function lookupHandlers(topicName) {
244641
- const registry22 = getHandlerRegistry();
245107
+ const registry32 = getHandlerRegistry();
244642
245108
  const result2 = [];
244643
- for (const [pattern, handlers] of registry22) {
245109
+ for (const [pattern, handlers] of registry32) {
244644
245110
  const matches = pattern.includes("*") ? matchesWildcardPattern(topicName, pattern) : pattern === topicName;
244645
245111
  if (matches) {
244646
245112
  result2.push(...handlers);
@@ -256070,6 +256536,7 @@ function attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops, fram
256070
256536
  aborted: true,
256071
256537
  reason: signal.reason
256072
256538
  }, runId, key);
256539
+ publishLocalAbort(runId, streamName, payload);
256073
256540
  const writable = new WorkflowServerWritableStream(runId, streamName);
256074
256541
  const writer = writable.getWriter();
256075
256542
  await writer.write(framedAbortStreams ? frameAbortStreamPayload(payload) : payload);
@@ -256368,41 +256835,84 @@ function cancelAbortReaders(...values) {
256368
256835
  for (const v of values) walk(v);
256369
256836
  }
256370
256837
  __name(cancelAbortReaders, "cancelAbortReaders");
256371
- function setupAbortStreamReader(controller, runId, streamName, ops, cryptoKey) {
256838
+ function setupAbortStreamReader(controller, runId, streamName, ops, cryptoKey, untilCancelled) {
256372
256839
  const readerCancel = new AbortController();
256840
+ let resolveLocal;
256841
+ const localPacket = new Promise((resolve22) => {
256842
+ resolveLocal = resolve22;
256843
+ });
256844
+ const stopLocal = onLocalAbort(runId, streamName, (packet) => resolveLocal?.(packet));
256373
256845
  ops.push((async () => {
256374
256846
  let reader;
256847
+ let keepListening = false;
256375
256848
  try {
256376
- const readable = new WorkflowServerReadableStream(runId, streamName);
256377
- reader = readable.getReader();
256378
256849
  let keyPromise;
256379
256850
  let decoded;
256380
256851
  const decodePacket = /* @__PURE__ */ __name2(async (packet) => {
256381
256852
  keyPromise ??= resolveEncryptionKey(cryptoKey);
256382
256853
  decoded = await hydrateStepArguments(packet, runId, await keyPromise);
256383
256854
  }, "decodePacket");
256384
- const result2 = await Promise.race([
256385
- readAbortStreamPacket(reader, decodePacket),
256386
- new Promise((resolve22) => {
256387
- if (readerCancel.signal.aborted) {
256388
- resolve22(void 0);
256389
- return;
256390
- }
256391
- readerCancel.signal.addEventListener("abort", () => resolve22(void 0), {
256392
- once: true
256393
- });
256394
- })
256395
- ]);
256396
- if (result2) {
256855
+ const abortWith = /* @__PURE__ */ __name2(async (packet, already) => {
256397
256856
  try {
256398
- if (decoded === void 0) await decodePacket(result2);
256857
+ decoded = already;
256858
+ if (decoded === void 0) await decodePacket(packet);
256399
256859
  controller.abort(decoded?.reason);
256400
256860
  } catch {
256401
256861
  controller.abort();
256402
256862
  }
256863
+ }, "abortWith");
256864
+ const cancelled = new Promise((resolve22) => {
256865
+ if (readerCancel.signal.aborted) {
256866
+ resolve22(void 0);
256867
+ return;
256868
+ }
256869
+ readerCancel.signal.addEventListener("abort", () => resolve22(void 0), {
256870
+ once: true
256871
+ });
256872
+ });
256873
+ let streamPacket;
256874
+ try {
256875
+ const readable = new WorkflowServerReadableStream(runId, streamName);
256876
+ reader = readable.getReader();
256877
+ streamPacket = readAbortStreamPacket(reader, decodePacket);
256878
+ } catch {
256879
+ streamPacket = new Promise(() => {
256880
+ });
256881
+ }
256882
+ const local = localPacket.then((packet) => ({
256883
+ packet,
256884
+ local: true
256885
+ }));
256886
+ const winner = await Promise.race([
256887
+ local,
256888
+ untilCancelled ? streamPacket.then((packet) => packet ? {
256889
+ packet,
256890
+ local: false
256891
+ } : void 0, () => void 0) : streamPacket.then((packet) => packet ? {
256892
+ packet,
256893
+ local: false
256894
+ } : void 0),
256895
+ cancelled
256896
+ ]);
256897
+ if (winner) {
256898
+ await abortWith(winner.packet, winner.local ? void 0 : decoded);
256899
+ } else if (untilCancelled && !readerCancel.signal.aborted) {
256900
+ keepListening = true;
256901
+ const expiry = setTimeout(stopLocal, LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS);
256902
+ expiry.unref?.();
256903
+ void Promise.race([
256904
+ local,
256905
+ cancelled
256906
+ ]).then(async (late) => {
256907
+ clearTimeout(expiry);
256908
+ stopLocal();
256909
+ if (late) await abortWith(late.packet, void 0);
256910
+ }).catch(() => {
256911
+ });
256403
256912
  }
256404
256913
  } catch {
256405
256914
  } finally {
256915
+ if (!keepListening) stopLocal();
256406
256916
  void reader?.cancel().catch(() => {
256407
256917
  });
256408
256918
  }
@@ -256437,13 +256947,13 @@ function copyAbortInternals(src22, dest) {
256437
256947
  }
256438
256948
  }
256439
256949
  __name(copyAbortInternals, "copyAbortInternals");
256440
- function reviveAbortController(value, ops, runId, cryptoKey) {
256950
+ function reviveAbortController(value, ops, runId, cryptoKey, untilCancelled = false) {
256441
256951
  const controller = new AbortController();
256442
256952
  if (value.aborted) {
256443
256953
  tagAbortPair(controller, value);
256444
256954
  controller.abort(value.reason);
256445
256955
  } else if (value.streamName) {
256446
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
256956
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
256447
256957
  tagAbortPair(controller, value, readerCancel);
256448
256958
  } else {
256449
256959
  tagAbortPair(controller, value);
@@ -256460,6 +256970,7 @@ function reviveAbortController(value, ops, runId, cryptoKey) {
256460
256970
  aborted: true,
256461
256971
  reason
256462
256972
  }, ctx.workflowMetadata.workflowRunId, ctx.encryptionKey);
256973
+ publishLocalAbort(ctx.workflowMetadata.workflowRunId, value.streamName, payload);
256463
256974
  const writable = new WorkflowServerWritableStream(ctx.workflowMetadata.workflowRunId, value.streamName);
256464
256975
  const writer = writable.getWriter();
256465
256976
  await writer.write(frameAbortStreamPayload(payload));
@@ -256485,13 +256996,13 @@ function reviveAbortController(value, ops, runId, cryptoKey) {
256485
256996
  return controller;
256486
256997
  }
256487
256998
  __name(reviveAbortController, "reviveAbortController");
256488
- function reviveAbortSignal(value, ops, runId, cryptoKey) {
256999
+ function reviveAbortSignal(value, ops, runId, cryptoKey, untilCancelled = false) {
256489
257000
  const controller = new AbortController();
256490
257001
  if (value.aborted) {
256491
257002
  tagAbortPair(controller, value);
256492
257003
  controller.abort(value.reason);
256493
257004
  } else if (value.streamName) {
256494
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
257005
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
256495
257006
  tagAbortPair(controller, value, readerCancel);
256496
257007
  } else {
256497
257008
  tagAbortPair(controller, value);
@@ -257004,8 +257515,10 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
257004
257515
  }
257005
257516
  return writable;
257006
257517
  }, "WritableStream"),
257007
- AbortController: /* @__PURE__ */ __name2((value) => reviveAbortController(value, ops, runId, cryptoKey), "AbortController"),
257008
- AbortSignal: /* @__PURE__ */ __name2((value) => reviveAbortSignal(value, ops, runId, cryptoKey), "AbortSignal")
257518
+ // A step's readers are cancelled when the step returns
257519
+ // (`cancelAbortReaders`), so they may outlive an empty stream.
257520
+ AbortController: /* @__PURE__ */ __name2((value) => reviveAbortController(value, ops, runId, cryptoKey, true), "AbortController"),
257521
+ AbortSignal: /* @__PURE__ */ __name2((value) => reviveAbortSignal(value, ops, runId, cryptoKey, true), "AbortSignal")
257009
257522
  };
257010
257523
  }
257011
257524
  __name(getStepRevivers, "getStepRevivers");
@@ -257377,6 +257890,7 @@ var FRAMED_STREAM_MIN_STALL_SESSION_MS;
257377
257890
  var STREAM_FLUSH_INTERVAL_MS;
257378
257891
  var getEnvStreamFlushIntervalMs;
257379
257892
  var WorkflowServerWritableStream;
257893
+ var LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS;
257380
257894
  var prepareReplayPayload;
257381
257895
  var STREAM_AND_REQUEST_KEYS;
257382
257896
  var init_serialization2 = __esm2({
@@ -257394,6 +257908,7 @@ var init_serialization2 = __esm2({
257394
257908
  init_private();
257395
257909
  init_get_world_lazy();
257396
257910
  init_sealed_box();
257911
+ init_abort_local();
257397
257912
  init_abort_stream();
257398
257913
  init_client();
257399
257914
  init_compression();
@@ -257787,6 +258302,7 @@ var init_serialization2 = __esm2({
257787
258302
  __name2(getWorkflowReducers, "getWorkflowReducers");
257788
258303
  __name2(getStepReducers, "getStepReducers");
257789
258304
  __name2(cancelAbortReaders, "cancelAbortReaders");
258305
+ LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS = 60 * 60 * 1e3;
257790
258306
  __name2(setupAbortStreamReader, "setupAbortStreamReader");
257791
258307
  __name2(tagAbortPair, "tagAbortPair");
257792
258308
  __name2(copyAbortInternals, "copyAbortInternals");
@@ -265518,7 +266034,7 @@ __name(isPermanentWorldError, "isPermanentWorldError");
265518
266034
  __name2(isPermanentWorldError, "isPermanentWorldError");
265519
266035
  function assertDynamicWorkflowsEnabled() {
265520
266036
  if (!isDynamicWorkflowsEnabled()) {
265521
- throw dynamicStartRefusal(`Dynamic workflows are disabled on this deployment, so no run was created. Set ${DYNAMIC_WORKFLOWS_ENV}=1 on the deployment to enable them.`);
266037
+ throw new DynamicWorkflowsNotEnabledError("Dynamic workflows are not enabled for this project, so start() did not create a run for the given workflow source.");
265522
266038
  }
265523
266039
  }
265524
266040
  __name(assertDynamicWorkflowsEnabled, "assertDynamicWorkflowsEnabled");
@@ -266076,7 +266592,7 @@ __name2(start, "start");
266076
266592
  value: "start",
266077
266593
  configurable: true
266078
266594
  });
266079
- })(start, "step//@workflow/core/runtime/start@5.7.0//start");
266595
+ })(start, "step//@workflow/core/runtime/start@5.7.1//start");
266080
266596
  function isSingleOrchestratorRun(run22) {
266081
266597
  return (run22.specVersion ?? SPEC_VERSION_LEGACY) >= SPEC_VERSION_SINGLE_ORCHESTRATOR;
266082
266598
  }
@@ -266853,7 +267369,7 @@ var Run = class _Run {
266853
267369
  value: "readFinishedRunIds",
266854
267370
  configurable: true
266855
267371
  });
266856
- })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.0//Run.readFinishedRunIds");
267372
+ })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.1//Run.readFinishedRunIds");
266857
267373
  (function(__wf_fn, __wf_id) {
266858
267374
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266859
267375
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266862,7 +267378,7 @@ var Run = class _Run {
266862
267378
  value: "wakeUp",
266863
267379
  configurable: true
266864
267380
  });
266865
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.0//Run#wakeUp");
267381
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.1//Run#wakeUp");
266866
267382
  (function(__wf_fn, __wf_id) {
266867
267383
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266868
267384
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266871,7 +267387,7 @@ var Run = class _Run {
266871
267387
  value: "cancel",
266872
267388
  configurable: true
266873
267389
  });
266874
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.0//Run#cancel");
267390
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.1//Run#cancel");
266875
267391
  (function(__wf_fn, __wf_id) {
266876
267392
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266877
267393
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266880,7 +267396,7 @@ var Run = class _Run {
266880
267396
  value: "delete",
266881
267397
  configurable: true
266882
267398
  });
266883
- })(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.0//Run#delete");
267399
+ })(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.1//Run#delete");
266884
267400
  (function(__wf_fn, __wf_id) {
266885
267401
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266886
267402
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266889,7 +267405,7 @@ var Run = class _Run {
266889
267405
  value: "readReturnValue",
266890
267406
  configurable: true
266891
267407
  });
266892
- })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.0//Run#readReturnValue");
267408
+ })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.1//Run#readReturnValue");
266893
267409
  (function(__wf_fn, __wf_id) {
266894
267410
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266895
267411
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266898,7 +267414,7 @@ var Run = class _Run {
266898
267414
  value: "getReadable",
266899
267415
  configurable: true
266900
267416
  });
266901
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.0//Run#getReadable");
267417
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.1//Run#getReadable");
266902
267418
  (function(__wf_fn, __wf_id) {
266903
267419
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266904
267420
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266907,7 +267423,7 @@ var Run = class _Run {
266907
267423
  value: "getWritable",
266908
267424
  configurable: true
266909
267425
  });
266910
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.0//Run#getWritable");
267426
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.1//Run#getWritable");
266911
267427
  (function(__wf_fn, __wf_id) {
266912
267428
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266913
267429
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266916,7 +267432,7 @@ var Run = class _Run {
266916
267432
  value: "exists",
266917
267433
  configurable: true
266918
267434
  });
266919
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.0//Run#exists");
267435
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.1//Run#exists");
266920
267436
  (function(__wf_fn, __wf_id) {
266921
267437
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266922
267438
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266925,7 +267441,7 @@ var Run = class _Run {
266925
267441
  value: "status",
266926
267442
  configurable: true
266927
267443
  });
266928
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.0//Run#status");
267444
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.1//Run#status");
266929
267445
  (function(__wf_fn, __wf_id) {
266930
267446
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266931
267447
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266934,7 +267450,7 @@ var Run = class _Run {
266934
267450
  value: "workflowName",
266935
267451
  configurable: true
266936
267452
  });
266937
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.0//Run#workflowName");
267453
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.1//Run#workflowName");
266938
267454
  (function(__wf_fn, __wf_id) {
266939
267455
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266940
267456
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266943,7 +267459,7 @@ var Run = class _Run {
266943
267459
  value: "createdAt",
266944
267460
  configurable: true
266945
267461
  });
266946
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#createdAt");
267462
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#createdAt");
266947
267463
  (function(__wf_fn, __wf_id) {
266948
267464
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266949
267465
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266952,7 +267468,7 @@ var Run = class _Run {
266952
267468
  value: "startedAt",
266953
267469
  configurable: true
266954
267470
  });
266955
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#startedAt");
267471
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#startedAt");
266956
267472
  (function(__wf_fn, __wf_id) {
266957
267473
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266958
267474
  __wf_reg.set(__wf_id, __wf_fn);
@@ -266961,7 +267477,7 @@ var Run = class _Run {
266961
267477
  value: "completedAt",
266962
267478
  configurable: true
266963
267479
  });
266964
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#completedAt");
267480
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.1//Run#completedAt");
266965
267481
  (function(__wf_cls, __wf_id) {
266966
267482
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
266967
267483
  __wf_reg.set(__wf_id, __wf_cls);
@@ -266971,7 +267487,7 @@ var Run = class _Run {
266971
267487
  enumerable: false,
266972
267488
  configurable: false
266973
267489
  });
266974
- })(Run, "class//@workflow/core/runtime/run@5.7.0//Run");
267490
+ })(Run, "class//@workflow/core/runtime/run@5.7.1//Run");
266975
267491
  async function fetch2(...args) {
266976
267492
  return globalThis.fetch(...args);
266977
267493
  }
@@ -271679,6 +272195,8 @@ var WorkflowStartError = class extends WorkflowError {
271679
272195
  return isError(value) && value.name === "WorkflowStartError";
271680
272196
  }
271681
272197
  };
272198
+ var DYNAMIC_WORKFLOWS_ENV_VAR = "WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS";
272199
+ var DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT = \`Set the \${DYNAMIC_WORKFLOWS_ENV_VAR}=1 environment variable on your project, then redeploy (or restart your dev server) so the new value takes effect.\`;
271682
272200
  var WorkflowRuntimeError = class extends WorkflowError {
271683
272201
  static {
271684
272202
  __name(this, "WorkflowRuntimeError");
@@ -272169,14 +272687,14 @@ var Run = class _Run {
272169
272687
  return this.getWritable();
272170
272688
  }
272171
272689
  };
272172
- Run.readFinishedRunIds = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run.readFinishedRunIds");
272173
- Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#wakeUp");
272174
- Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#cancel");
272175
- Run.prototype["delete"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#delete");
272176
- Run.prototype["readReturnValue"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#readReturnValue");
272177
- Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#getReadable");
272178
- Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#getWritable");
272179
- var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#exists");
272690
+ Run.readFinishedRunIds = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run.readFinishedRunIds");
272691
+ Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#wakeUp");
272692
+ Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#cancel");
272693
+ Run.prototype["delete"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#delete");
272694
+ Run.prototype["readReturnValue"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#readReturnValue");
272695
+ Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#getReadable");
272696
+ Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#getWritable");
272697
+ var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#exists");
272180
272698
  Object.defineProperty(Run.prototype, "exists", {
272181
272699
  get() {
272182
272700
  return __step_Run$exists.call(this);
@@ -272184,7 +272702,7 @@ Object.defineProperty(Run.prototype, "exists", {
272184
272702
  configurable: true,
272185
272703
  enumerable: false
272186
272704
  });
272187
- var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#status");
272705
+ var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#status");
272188
272706
  Object.defineProperty(Run.prototype, "status", {
272189
272707
  get() {
272190
272708
  return __step_Run$status.call(this);
@@ -272192,7 +272710,7 @@ Object.defineProperty(Run.prototype, "status", {
272192
272710
  configurable: true,
272193
272711
  enumerable: false
272194
272712
  });
272195
- var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#workflowName");
272713
+ var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#workflowName");
272196
272714
  Object.defineProperty(Run.prototype, "workflowName", {
272197
272715
  get() {
272198
272716
  return __step_Run$workflowName.call(this);
@@ -272200,7 +272718,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
272200
272718
  configurable: true,
272201
272719
  enumerable: false
272202
272720
  });
272203
- var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#createdAt");
272721
+ var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#createdAt");
272204
272722
  Object.defineProperty(Run.prototype, "createdAt", {
272205
272723
  get() {
272206
272724
  return __step_Run$createdAt.call(this);
@@ -272208,7 +272726,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
272208
272726
  configurable: true,
272209
272727
  enumerable: false
272210
272728
  });
272211
- var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#startedAt");
272729
+ var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#startedAt");
272212
272730
  Object.defineProperty(Run.prototype, "startedAt", {
272213
272731
  get() {
272214
272732
  return __step_Run$startedAt.call(this);
@@ -272216,7 +272734,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
272216
272734
  configurable: true,
272217
272735
  enumerable: false
272218
272736
  });
272219
- var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.0//Run#completedAt");
272737
+ var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.7.1//Run#completedAt");
272220
272738
  Object.defineProperty(Run.prototype, "completedAt", {
272221
272739
  get() {
272222
272740
  return __step_Run$completedAt.call(this);
@@ -272233,7 +272751,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
272233
272751
  enumerable: false,
272234
272752
  configurable: false
272235
272753
  });
272236
- })(Run, "class//@workflow/core/runtime/run@5.7.0//Run");
272754
+ })(Run, "class//@workflow/core/runtime/run@5.7.1//Run");
272237
272755
 
272238
272756
  // ../core/dist/workflow/create-hook.js
272239
272757
  aliasSerializationClass(RUN_CLASS_ID, Run);
@@ -295729,7 +296247,7 @@ var latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1,
295729
296247
  var probeMissWarning = globalSingleton("@workflow/core//crossDeploymentProbeMissWarning", 1, () => ({
295730
296248
  warned: false
295731
296249
  }));
295732
- var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.7.0//start");
296250
+ var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.7.1//start");
295733
296251
 
295734
296252
  // workflows/lineage.ts
295735
296253
  var noop = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//./workflows/lineage//noop");