@workflow/world-testing 5.0.0 → 5.0.2

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.
@@ -312,6 +312,13 @@ var require_ms = __commonJS({
312
312
 
313
313
  // ../utils/dist/time.js
314
314
  function parseDurationToDate(param) {
315
+ const date5 = durationToDate(param);
316
+ if (Number.isNaN(date5.getTime())) {
317
+ throw new Error(typeof param === "object" ? "Invalid date: the Date object does not hold a valid time." : `Invalid duration: ${JSON.stringify(param)} ends past the latest time a Date can represent.`);
318
+ }
319
+ return date5;
320
+ }
321
+ function durationToDate(param) {
315
322
  if (typeof param === "string") {
316
323
  const durationMs = (0, import_ms.default)(param);
317
324
  if (typeof durationMs !== "number" || durationMs < 0) {
@@ -335,6 +342,7 @@ var init_time = __esm({
335
342
  "use strict";
336
343
  import_ms = __toESM(require_ms(), 1);
337
344
  __name(parseDurationToDate, "parseDurationToDate");
345
+ __name(durationToDate, "durationToDate");
338
346
  }
339
347
  });
340
348
 
@@ -2508,7 +2516,7 @@ var init_node = __esm({
2508
2516
  });
2509
2517
 
2510
2518
  // ../core/dist/symbols.js
2511
- var STABLE_ULID, STREAM_NAME_SYMBOL, STREAM_TYPE_SYMBOL, STREAM_FRAMING_SYMBOL, STREAM_SERVER_RUN_ID_SYMBOL, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL, STREAM_SERVER_PUBLIC_KEY_SYMBOL, STREAM_DRAIN_SYMBOL, BODY_INIT_SYMBOL, WEBHOOK_RESPONSE_WRITABLE, WORKFLOW_CLASS_REGISTRY, ABORT_STREAM_NAME, ABORT_HOOK_TOKEN, ABORT_LISTENER_ATTACHED, ABORT_READER_CANCEL;
2519
+ var STABLE_ULID, STREAM_NAME_SYMBOL, STREAM_TYPE_SYMBOL, STREAM_FRAMING_SYMBOL, STREAM_SERVER_RUN_ID_SYMBOL, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL, STREAM_SERVER_PUBLIC_KEY_SYMBOL, STREAM_DRAIN_SYMBOL, STREAM_RELEASE_SYMBOL, BODY_INIT_SYMBOL, WEBHOOK_RESPONSE_WRITABLE, WORKFLOW_CLASS_REGISTRY, ABORT_STREAM_NAME, ABORT_HOOK_TOKEN, ABORT_LISTENER_ATTACHED, ABORT_READER_CANCEL;
2512
2520
  var init_symbols = __esm({
2513
2521
  "../core/dist/symbols.js"() {
2514
2522
  "use strict";
@@ -2520,6 +2528,7 @@ var init_symbols = __esm({
2520
2528
  STREAM_SERVER_DEPLOYMENT_ID_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID");
2521
2529
  STREAM_SERVER_PUBLIC_KEY_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_SERVER_PUBLIC_KEY");
2522
2530
  STREAM_DRAIN_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_DRAIN");
2531
+ STREAM_RELEASE_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_RELEASE");
2523
2532
  BODY_INIT_SYMBOL = /* @__PURE__ */ Symbol.for("BODY_INIT");
2524
2533
  WEBHOOK_RESPONSE_WRITABLE = /* @__PURE__ */ Symbol.for("WEBHOOK_RESPONSE_WRITABLE");
2525
2534
  WORKFLOW_CLASS_REGISTRY = /* @__PURE__ */ Symbol.for("workflow-class-registry");
@@ -2576,12 +2585,11 @@ function isReadableUnlockedNotClosed(readable) {
2576
2585
  return true;
2577
2586
  }
2578
2587
  function resolveAfterDrain(state) {
2579
- const barrier = state.drainBarrier;
2580
- if (!barrier) {
2581
- state.resolve();
2582
- return;
2583
- }
2584
- barrier().then(() => state.resolve(), (err) => state.reject(err));
2588
+ const release = /* @__PURE__ */ __name(async () => {
2589
+ await state.drainBarrier?.();
2590
+ await state.releaseTransport?.();
2591
+ }, "release");
2592
+ release().then(() => state.resolve(), (err) => state.reject(err));
2585
2593
  }
2586
2594
  function markFlushableFrameProduced(state) {
2587
2595
  state.producedFrames++;
@@ -2674,6 +2682,7 @@ function trackFlushableWritable(writable, state, WritableStreamConstructor = Wri
2674
2682
  }
2675
2683
  }
2676
2684
  await drainFlushableSnapshot(state);
2685
+ await state.releaseTransport?.();
2677
2686
  if (!state.doneResolved) {
2678
2687
  state.doneResolved = true;
2679
2688
  state.resolve();
@@ -2745,6 +2754,10 @@ function flushablePipe(source, sink, state) {
2745
2754
  if (typeof drain === "function") {
2746
2755
  state.drainBarrier = drain;
2747
2756
  }
2757
+ const release = sink[STREAM_RELEASE_SYMBOL];
2758
+ if (typeof release === "function") {
2759
+ state.releaseTransport = release;
2760
+ }
2748
2761
  return flushablePipePerChunk(source, sink, state);
2749
2762
  }
2750
2763
  async function flushablePipePerChunk(source, sink, state) {
@@ -2796,6 +2809,8 @@ async function flushablePipePerChunk(source, sink, state) {
2796
2809
  await state.drainBarrier().catch(() => {
2797
2810
  });
2798
2811
  }
2812
+ await writer.abort(err).catch(() => {
2813
+ });
2799
2814
  if (!state.doneResolved) {
2800
2815
  state.doneResolved = true;
2801
2816
  state.reject(err);
@@ -25914,6 +25929,11 @@ var init_hooks = __esm({
25914
25929
  // Named `runSpecVersion` to distinguish it from the hook's own `specVersion`.
25915
25930
  runSpecVersion: external_exports.number().optional(),
25916
25931
  workflowCoreVersion: external_exports.string().optional(),
25932
+ // Node.js version of the run's creating deployment, mirrored from
25933
+ // `executionContext.nodeVersion`. Decides whether a resume may write zstd
25934
+ // (which needs Node.js >= 22.15) or must use gzip. Absent on runs created
25935
+ // before the field existed and on non-Node runtimes, where writers use gzip.
25936
+ nodeVersion: external_exports.string().optional(),
25917
25937
  traceCarrier: TraceCarrierSchema.optional(),
25918
25938
  // The run's published X25519 public key (base64), mirrored from the run
25919
25939
  // entity. Lets a resume seal (`encp`) its payload to the run without reading
@@ -26042,6 +26062,88 @@ var init_slot_identity = __esm({
26042
26062
  }
26043
26063
  });
26044
26064
 
26065
+ // ../world/dist/snapshots.js
26066
+ var SnapshotMetadataSchema;
26067
+ var init_snapshots = __esm({
26068
+ "../world/dist/snapshots.js"() {
26069
+ "use strict";
26070
+ init_zod();
26071
+ SnapshotMetadataSchema = external_exports.object({
26072
+ /**
26073
+ * Pagination cursor for events.list() — the snapshot was taken at
26074
+ * this point in the event log. On restore, only events AFTER this
26075
+ * cursor need to be fetched.
26076
+ */
26077
+ eventsCursor: external_exports.string().nullable(),
26078
+ /** Timestamp when the snapshot was created */
26079
+ createdAt: external_exports.coerce.date(),
26080
+ /**
26081
+ * Number of events the run had processed when the snapshot was taken.
26082
+ * Restores see only the delta after `eventsCursor`, so guards that need
26083
+ * the TOTAL log size (the server-supplied max-events ceiling) add this
26084
+ * to the delta. Optional for snapshots written before the field existed
26085
+ * (treated as 0 — the ceiling degrades to delta-only for those, exactly
26086
+ * the pre-field behavior).
26087
+ */
26088
+ eventCount: external_exports.number().int().nonnegative().optional(),
26089
+ /**
26090
+ * Number of draws the run's seeded PRNG had consumed when the snapshot
26091
+ * was taken. On restore the runtime re-seeds from the run's BASE seed
26092
+ * and fast-forwards this many draws, so correlation-id generation
26093
+ * continues at the exact position full replay would have reached —
26094
+ * keeping ids identical across snapshot generations AND identical to a
26095
+ * no-snapshot run (which is what makes concurrent invocations restored
26096
+ * from different snapshots of the same run still collide on the world's
26097
+ * per-(runId, correlationId) dedup).
26098
+ */
26099
+ rngDraws: external_exports.number().int().nonnegative().optional(),
26100
+ /**
26101
+ * Snapshot-portable token of the engine's host-serde capture root: the
26102
+ * container of pristine intrinsics/samples/symbols captured before any
26103
+ * user code ran, whose box lives inside the snapshot's memory image. A
26104
+ * restore re-adopts it by this token so serde initialization executes
26105
+ * no guest code after user code has run. Required to restore (format
26106
+ * version >= 2); snapshots without it are treated as a miss.
26107
+ */
26108
+ serdeRootPtr: external_exports.number().int().optional(),
26109
+ /**
26110
+ * The monotonic correlation-id ULID factory's last output when the
26111
+ * snapshot was taken (undefined if the run had drawn none). The
26112
+ * factory's state lives host-side and does not survive into the memory
26113
+ * image; on restore the runtime continues the sequence from this value
26114
+ * (same-timestamp base32 increment), so a restored invocation emits
26115
+ * the exact ids a full replay would — keeping concurrent invocations
26116
+ * of the same run dedupable via per-(runId, correlationId) uniqueness.
26117
+ */
26118
+ lastUlid: external_exports.string().optional(),
26119
+ /**
26120
+ * Exact engine build (quickjs-wasi package version) that captured the
26121
+ * heap image. The image's own QJSS header is identical across builds,
26122
+ * so restoring under a different build would pass deserialization and
26123
+ * execute as undefined behavior in the interpreter — a real hazard
26124
+ * during a rolling deploy that bumps quickjs-wasi, when live snapshots
26125
+ * from the old build meet instances running the new one. Readers MUST
26126
+ * treat a mismatch (or absence) as a clean miss.
26127
+ */
26128
+ engineVersion: external_exports.string().optional(),
26129
+ /**
26130
+ * The deterministic replay clock's high-water mark (ms since epoch) at
26131
+ * capture. The clock lives host-side; without this a restored VM's
26132
+ * `Date.now()` regresses to the run-creation time until the first
26133
+ * delta event advances it, so restores initialize the clock to
26134
+ * `max(derived, clockMs)`.
26135
+ */
26136
+ clockMs: external_exports.number().optional(),
26137
+ /**
26138
+ * Snapshot format tag. A reader that doesn't recognize the version
26139
+ * treats the snapshot as a clean miss (full replay) instead of handing
26140
+ * an incompatible heap to the WASM engine.
26141
+ */
26142
+ formatVersion: external_exports.number().int().optional()
26143
+ });
26144
+ }
26145
+ });
26146
+
26045
26147
  // ../world/dist/spec-version.js
26046
26148
  function isLegacySpecVersion(v) {
26047
26149
  return v === void 0 || v === null || v <= SPEC_VERSION_LEGACY;
@@ -26097,6 +26199,7 @@ var init_dist4 = __esm({
26097
26199
  init_serialization();
26098
26200
  init_shared();
26099
26201
  init_slot_identity();
26202
+ init_snapshots();
26100
26203
  init_spec_version();
26101
26204
  init_steps();
26102
26205
  init_ulid();
@@ -26281,9 +26384,15 @@ function headersToEntries(value) {
26281
26384
  recordProxy(value);
26282
26385
  return Array.from(value);
26283
26386
  }
26284
- return [
26285
- ...headersIterator(value)
26286
- ];
26387
+ try {
26388
+ return [
26389
+ ...headersIterator(value)
26390
+ ];
26391
+ } catch (error61) {
26392
+ if (!(error61 instanceof TypeError)) throw error61;
26393
+ recordGuestCode("method", "Headers[Symbol.iterator]");
26394
+ return Array.from(value);
26395
+ }
26287
26396
  }
26288
26397
  function mapToEntries(value) {
26289
26398
  return [
@@ -26336,7 +26445,7 @@ function readToStringTag(value) {
26336
26445
  const tag = readProperty(value, Symbol.toStringTag);
26337
26446
  return typeof tag === "string" ? tag : void 0;
26338
26447
  }
26339
- var GUEST_CODE_EXECUTION_SAMPLE_LIMIT, activeStats, reportedProxies, useStepClosures, uncurryThis, dateGetDate, dateGetTime, dateToISOString, regExpSource, regExpFlags, arrayBufferByteLength, mapEntries, setValues, numberValueOf, stringValueOf, booleanValueOf, bigIntValueOf, TypedArrayPrototype, typedArrayTag, typedArrayBuffer, typedArrayByteOffset, typedArrayByteLength, typedArrayLength, dataViewBuffer, dataViewByteOffset, dataViewByteLength, sharedArrayBufferByteLength, headersIterator, urlHrefGetter, urlSearchParamsToStringMethod, isProxy, functionToString, KNOWN_VIEW_TAGS, BRAND_DECIDED_TAGS, hardenedStringifyOperations;
26448
+ var GUEST_CODE_EXECUTION_SAMPLE_LIMIT, activeStats, reportedProxies, useStepClosures, uncurryThis, dateGetDate, dateGetTime, dateToISOString, regExpSource, regExpFlags, arrayBufferByteLength, mapEntries, setValues, numberValueOf, stringValueOf, booleanValueOf, bigIntValueOf, TypedArrayPrototype, typedArrayTag, typedArrayBuffer, typedArrayByteOffset, typedArrayByteLength, typedArrayLength, typedArraySet, HostArrayBuffer, HostUint8Array, dataViewBuffer, dataViewByteOffset, dataViewByteLength, sharedArrayBufferByteLength, headersIterator, urlHrefGetter, urlSearchParamsToStringMethod, isProxy, functionToString, KNOWN_VIEW_TAGS, BRAND_DECIDED_TAGS, hardenedStringifyOperations;
26340
26449
  var init_hardened = __esm({
26341
26450
  "../core/dist/serialization/hardened.js"() {
26342
26451
  "use strict";
@@ -26372,6 +26481,9 @@ var init_hardened = __esm({
26372
26481
  typedArrayByteOffset = protoGetter(TypedArrayPrototype, "byteOffset");
26373
26482
  typedArrayByteLength = protoGetter(TypedArrayPrototype, "byteLength");
26374
26483
  typedArrayLength = protoGetter(TypedArrayPrototype, "length");
26484
+ typedArraySet = uncurryThis(TypedArrayPrototype.set);
26485
+ HostArrayBuffer = ArrayBuffer;
26486
+ HostUint8Array = Uint8Array;
26375
26487
  dataViewBuffer = protoGetter(DataView.prototype, "buffer");
26376
26488
  dataViewByteOffset = protoGetter(DataView.prototype, "byteOffset");
26377
26489
  dataViewByteLength = protoGetter(DataView.prototype, "byteLength");
@@ -26465,12 +26577,23 @@ var init_hardened = __esm({
26465
26577
  entriesOf: /* @__PURE__ */ __name((map2) => mapToEntries(map2), "entriesOf"),
26466
26578
  viewInfo: /* @__PURE__ */ __name((view) => {
26467
26579
  const info = viewInfo(view);
26580
+ const length = types.isDataView(view) ? 0 : typedArrayLength(view);
26581
+ const bufferByteLength = types.isSharedArrayBuffer(info.buffer) ? sharedArrayBufferByteLength(info.buffer) : arrayBufferByteLength(info.buffer);
26582
+ if (info.byteLength === bufferByteLength) {
26583
+ return {
26584
+ ...info,
26585
+ length,
26586
+ bufferByteLength
26587
+ };
26588
+ }
26589
+ const copy = new HostArrayBuffer(info.byteLength);
26590
+ typedArraySet(new HostUint8Array(copy), new HostUint8Array(info.buffer, info.byteOffset, info.byteLength));
26468
26591
  return {
26469
- ...info,
26470
- // devalue only reads `length` for typed-array subviews; DataView
26471
- // subviews are encoded from `byteLength`.
26472
- length: types.isDataView(view) ? 0 : typedArrayLength(view),
26473
- bufferByteLength: types.isSharedArrayBuffer(info.buffer) ? sharedArrayBufferByteLength(info.buffer) : arrayBufferByteLength(info.buffer)
26592
+ buffer: copy,
26593
+ byteOffset: 0,
26594
+ byteLength: info.byteLength,
26595
+ length,
26596
+ bufferByteLength: info.byteLength
26474
26597
  };
26475
26598
  }, "viewInfo"),
26476
26599
  shapeOf: /* @__PURE__ */ __name((value) => {
@@ -27206,7 +27329,7 @@ function isZstdAvailable() {
27206
27329
  function isGzipAvailable() {
27207
27330
  return typeof CompressionStream === "function" && typeof DecompressionStream === "function";
27208
27331
  }
27209
- async function pipeThroughTransform(data2, transform2) {
27332
+ async function pipeThroughTransform(data2, transform2, maxOutputBytes) {
27210
27333
  const writer = transform2.writable.getWriter();
27211
27334
  const writePromise = writer.write(data2).then(() => writer.close());
27212
27335
  writePromise.catch(() => {
@@ -27219,6 +27342,11 @@ async function pipeThroughTransform(data2, transform2) {
27219
27342
  if (done) break;
27220
27343
  chunks.push(value);
27221
27344
  total += value.length;
27345
+ if (maxOutputBytes !== void 0 && total > maxOutputBytes) {
27346
+ await reader.cancel().catch(() => {
27347
+ });
27348
+ throw new DecompressedSizeLimitError(maxOutputBytes);
27349
+ }
27222
27350
  }
27223
27351
  await writePromise;
27224
27352
  const out = new Uint8Array(total);
@@ -27232,25 +27360,51 @@ async function pipeThroughTransform(data2, transform2) {
27232
27360
  async function gzipBytes(data2) {
27233
27361
  return pipeThroughTransform(data2, new CompressionStream("gzip"));
27234
27362
  }
27235
- async function gunzipBytes(data2) {
27236
- return pipeThroughTransform(data2, new DecompressionStream("gzip"));
27363
+ async function gunzipBytes(data2, maxOutputBytes) {
27364
+ return pipeThroughTransform(data2, new DecompressionStream("gzip"), maxOutputBytes);
27237
27365
  }
27238
- function zstdBytes(data2) {
27239
- const z2 = getNodeZlib();
27366
+ function zstdOpts(z2) {
27240
27367
  const level = z2?.constants?.ZSTD_c_compressionLevel;
27241
- const opts = level !== void 0 ? {
27368
+ return level !== void 0 ? {
27242
27369
  params: {
27243
27370
  [level]: ZSTD_LEVEL
27244
27371
  }
27245
27372
  } : void 0;
27246
- return new Uint8Array(z2.zstdCompressSync(data2, opts));
27247
27373
  }
27248
- function unzstdBytes(data2) {
27374
+ function zstdBytes(data2) {
27375
+ const z2 = getNodeZlib();
27376
+ return new Uint8Array(z2.zstdCompressSync(data2, zstdOpts(z2)));
27377
+ }
27378
+ function zstdBytesAsync(data2) {
27379
+ const z2 = getNodeZlib();
27380
+ if (typeof z2?.zstdCompress !== "function") {
27381
+ return Promise.resolve(zstdBytes(data2));
27382
+ }
27383
+ return new Promise((resolve, reject) => {
27384
+ z2.zstdCompress(data2, zstdOpts(z2), (err, result) => {
27385
+ if (err) reject(err);
27386
+ else resolve(new Uint8Array(result));
27387
+ });
27388
+ });
27389
+ }
27390
+ function unzstdBytes(data2, maxOutputBytes) {
27249
27391
  const z2 = getNodeZlib();
27250
27392
  if (!z2?.zstdDecompressSync) {
27251
27393
  throw new Error("Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).");
27252
27394
  }
27253
- return new Uint8Array(z2.zstdDecompressSync(data2));
27395
+ if (maxOutputBytes === void 0) {
27396
+ return new Uint8Array(z2.zstdDecompressSync(data2));
27397
+ }
27398
+ try {
27399
+ return new Uint8Array(z2.zstdDecompressSync(data2, {
27400
+ maxOutputLength: maxOutputBytes
27401
+ }));
27402
+ } catch (err) {
27403
+ if (err?.code === "ERR_BUFFER_TOO_LARGE") {
27404
+ throw new DecompressedSizeLimitError(maxOutputBytes);
27405
+ }
27406
+ throw err;
27407
+ }
27254
27408
  }
27255
27409
  function recordStats(stats, codec2, uncompressedBytes, storedBytes) {
27256
27410
  if (!stats) return;
@@ -27260,25 +27414,27 @@ function recordStats(stats, codec2, uncompressedBytes, storedBytes) {
27260
27414
  stats.uncompressedBytes = uncompressedBytes;
27261
27415
  stats.storedBytes = storedBytes;
27262
27416
  }
27263
- function selectWriteCodec() {
27417
+ function selectWriteCodec(mode) {
27264
27418
  const override = codecOverrideFromEnv();
27265
- if (override === "gzip") return isGzipAvailable() ? "gzip" : "none";
27419
+ if (mode === "gzip" || override === "gzip") {
27420
+ return isGzipAvailable() ? "gzip" : "none";
27421
+ }
27266
27422
  if (isZstdAvailable()) return "zstd";
27267
27423
  if (isGzipAvailable()) return "gzip";
27268
27424
  return "none";
27269
27425
  }
27270
- async function compress(data2, enabled, stats) {
27426
+ async function compress(data2, mode, stats, opts) {
27271
27427
  if (!(data2 instanceof Uint8Array)) return data2;
27272
- if (!enabled || data2.length < COMPRESSION_MIN_BYTES || isCompressionDisabledByEnv()) {
27428
+ if (!mode || data2.length < COMPRESSION_MIN_BYTES || isCompressionDisabledByEnv()) {
27273
27429
  recordStats(stats, "none", data2.length, data2.length);
27274
27430
  return data2;
27275
27431
  }
27276
- const codec2 = selectWriteCodec();
27432
+ const codec2 = selectWriteCodec(mode);
27277
27433
  if (codec2 === "none") {
27278
27434
  recordStats(stats, "none", data2.length, data2.length);
27279
27435
  return data2;
27280
27436
  }
27281
- const compressed = codec2 === "zstd" ? zstdBytes(data2) : await gzipBytes(data2);
27437
+ const compressed = codec2 === "zstd" ? opts?.preferAsync ? await zstdBytesAsync(data2) : zstdBytes(data2) : await gzipBytes(data2);
27282
27438
  const format = codec2 === "zstd" ? SerializationFormat.ZSTD : SerializationFormat.GZIP;
27283
27439
  const wrappedLength = 4 + compressed.length;
27284
27440
  if (wrappedLength >= data2.length * (1 - COMPRESSION_MIN_SAVINGS_RATIO)) {
@@ -27288,12 +27444,12 @@ async function compress(data2, enabled, stats) {
27288
27444
  recordStats(stats, codec2, data2.length, wrappedLength);
27289
27445
  return encodeWithFormatPrefix(format, compressed);
27290
27446
  }
27291
- async function decompress(data2, stats) {
27447
+ async function decompress(data2, stats, opts) {
27292
27448
  if (!(data2 instanceof Uint8Array)) return data2;
27293
27449
  const prefix = peekFormatPrefix(data2);
27294
27450
  if (prefix === SerializationFormat.ZSTD) {
27295
27451
  const { payload } = decodeFormatPrefix(data2);
27296
- const inflated = unzstdBytes(payload);
27452
+ const inflated = unzstdBytes(payload, opts?.maxOutputBytes);
27297
27453
  recordStats(stats, "zstd", inflated.length, data2.length);
27298
27454
  return inflated;
27299
27455
  }
@@ -27302,14 +27458,14 @@ async function decompress(data2, stats) {
27302
27458
  throw new Error("Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.");
27303
27459
  }
27304
27460
  const { payload } = decodeFormatPrefix(data2);
27305
- const inflated = await gunzipBytes(payload);
27461
+ const inflated = await gunzipBytes(payload, opts?.maxOutputBytes);
27306
27462
  recordStats(stats, "gzip", inflated.length, data2.length);
27307
27463
  return inflated;
27308
27464
  }
27309
27465
  recordStats(stats, "none", data2.length, data2.length);
27310
27466
  return data2;
27311
27467
  }
27312
- var COMPRESSION_MIN_BYTES, COMPRESSION_MIN_SAVINGS_RATIO, ZSTD_LEVEL;
27468
+ var COMPRESSION_MIN_BYTES, COMPRESSION_MIN_SAVINGS_RATIO, ZSTD_LEVEL, DecompressedSizeLimitError;
27313
27469
  var init_compression = __esm({
27314
27470
  "../core/dist/serialization/compression.js"() {
27315
27471
  "use strict";
@@ -27326,7 +27482,20 @@ var init_compression = __esm({
27326
27482
  __name(pipeThroughTransform, "pipeThroughTransform");
27327
27483
  __name(gzipBytes, "gzipBytes");
27328
27484
  __name(gunzipBytes, "gunzipBytes");
27485
+ DecompressedSizeLimitError = class extends Error {
27486
+ static {
27487
+ __name(this, "DecompressedSizeLimitError");
27488
+ }
27489
+ maxOutputBytes;
27490
+ constructor(maxOutputBytes) {
27491
+ super(`Decompressed payload exceeds ${maxOutputBytes} bytes`);
27492
+ this.maxOutputBytes = maxOutputBytes;
27493
+ this.name = "DecompressedSizeLimitError";
27494
+ }
27495
+ };
27496
+ __name(zstdOpts, "zstdOpts");
27329
27497
  __name(zstdBytes, "zstdBytes");
27498
+ __name(zstdBytesAsync, "zstdBytesAsync");
27330
27499
  __name(unzstdBytes, "unzstdBytes");
27331
27500
  __name(recordStats, "recordStats");
27332
27501
  __name(selectWriteCodec, "selectWriteCodec");
@@ -27615,7 +27784,7 @@ function SemanticConvention(...names) {
27615
27784
  value
27616
27785
  ]));
27617
27786
  }
27618
- var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowDynamic, WorkflowDynamicSourceHash, WorkflowDynamicCodeBytes, WorkflowDynamicCodeStorage, WorkflowBundleCompileCacheHit, WorkflowReplayLoadSource, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowStepsFailedSerialization, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowDispatchRepublishSkipped, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepStartStrategy, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, MessagingBatchMessageCount, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, WorkflowRunSpecVersion, WorkflowRunSpecVersionSource, WorkflowCapabilityProbeLatencyMs, WorkflowCapabilityProbeCached, WorkflowCapabilityProbeError, HookToken, HookId, HookFound, HookResilientResume, HookResumeCommitted, HookWakePublished, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, StepDispatchPrologue, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
27787
+ var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowDynamic, WorkflowDynamicSourceHash, WorkflowDynamicCodeBytes, WorkflowDynamicCodeStorage, WorkflowBundleCompileCacheHit, WorkflowReplayLoadSource, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, QuickJSSnapshotRestored, QuickJSSnapshotDeltaEvents, QuickJSSnapshotRestoreMs, QuickJSSnapshotFallbackReason, QuickJSSnapshotSaveMs, QuickJSSnapshotPlaintextBytes, QuickJSSnapshotStoredBytes, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowStepsFailedSerialization, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowDispatchRepublishSkipped, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepStartStrategy, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, MessagingBatchMessageCount, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, WorkflowRunSpecVersion, WorkflowRunSpecVersionSource, WorkflowCapabilityProbeLatencyMs, WorkflowCapabilityProbeCached, WorkflowCapabilityProbeError, HookToken, HookId, HookFound, HookResilientResume, HookResumeCommitted, HookWakePublished, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, StepDispatchPrologue, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
27619
27788
  var init_semantic_conventions = __esm({
27620
27789
  "../core/dist/telemetry/semantic-conventions.js"() {
27621
27790
  "use strict";
@@ -27646,6 +27815,13 @@ var init_semantic_conventions = __esm({
27646
27815
  QuickJSEventsFetchedPages = SemanticConvention("workflow.vm.events.fetched_pages");
27647
27816
  QuickJSPendingOpsCount = SemanticConvention("workflow.vm.pending_ops_count");
27648
27817
  QuickJSInlineSteps = SemanticConvention("quickjs.inline_steps");
27818
+ QuickJSSnapshotRestored = SemanticConvention("workflow.quickjs.snapshot.restored");
27819
+ QuickJSSnapshotDeltaEvents = SemanticConvention("workflow.quickjs.snapshot.delta_events");
27820
+ QuickJSSnapshotRestoreMs = SemanticConvention("workflow.quickjs.snapshot.restore_ms");
27821
+ QuickJSSnapshotFallbackReason = SemanticConvention("workflow.quickjs.snapshot.fallback_reason");
27822
+ QuickJSSnapshotSaveMs = SemanticConvention("workflow.quickjs.snapshot.save_ms");
27823
+ QuickJSSnapshotPlaintextBytes = SemanticConvention("workflow.quickjs.snapshot.plaintext_bytes");
27824
+ QuickJSSnapshotStoredBytes = SemanticConvention("workflow.quickjs.snapshot.stored_bytes");
27649
27825
  WorkflowTraceMode = SemanticConvention("workflow.trace.mode");
27650
27826
  WorkflowTurbo = SemanticConvention("workflow.turbo");
27651
27827
  WorkflowErrorName = SemanticConvention("workflow.error.name");
@@ -29982,7 +30158,7 @@ var init_telemetry = __esm({
29982
30158
 
29983
30159
  // ../core/dist/logger.js
29984
30160
  function matchesDebugNamespace(namespace, patternList) {
29985
- if (!patternList) {
30161
+ if (typeof patternList !== "string" || !patternList) {
29986
30162
  return false;
29987
30163
  }
29988
30164
  let enabled = false;
@@ -30109,7 +30285,7 @@ async function serialize(value, encryptionKey, options) {
30109
30285
  try {
30110
30286
  const payload = devalueCodec.serialize(value, "client", options);
30111
30287
  const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
30112
- const compressed = await compress(prefixed, options?.compression === true, options?.compressionStats);
30288
+ const compressed = await compress(prefixed, options?.compression ?? false, options?.compressionStats);
30113
30289
  return encrypt2(compressed, encryptionKey);
30114
30290
  } catch (error61) {
30115
30291
  rethrowIfRuntimeError(error61);
@@ -30154,7 +30330,7 @@ async function serialize2(value, encryptionKey, options) {
30154
30330
  try {
30155
30331
  const payload = devalueCodec.serialize(value, "step", options);
30156
30332
  const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
30157
- const compressed = await compress(prefixed, options?.compression === true, options?.compressionStats);
30333
+ const compressed = await compress(prefixed, options?.compression ?? false, options?.compressionStats);
30158
30334
  return encrypt2(compressed, encryptionKey);
30159
30335
  } catch (error61) {
30160
30336
  rethrowIfRuntimeError(error61);
@@ -32297,7 +32473,22 @@ var require_semver3 = __commonJS({
32297
32473
  });
32298
32474
 
32299
32475
  // ../core/dist/capabilities.js
32300
- function getRunCapabilities(workflowCoreVersion) {
32476
+ function nodeVersionSupportsZstd(nodeVersion) {
32477
+ if (typeof nodeVersion !== "string" || !import_semver.default.valid(nodeVersion)) {
32478
+ return false;
32479
+ }
32480
+ return import_semver.default.satisfies(nodeVersion, ZSTD_NODE_RANGE);
32481
+ }
32482
+ function getCurrentNodeVersion() {
32483
+ try {
32484
+ const versions = globalThis.process?.versions;
32485
+ if (!versions || versions.bun || versions.deno) return void 0;
32486
+ return typeof versions.node === "string" ? versions.node : void 0;
32487
+ } catch {
32488
+ return void 0;
32489
+ }
32490
+ }
32491
+ function getRunCapabilities(workflowCoreVersion, nodeVersion) {
32301
32492
  if (!workflowCoreVersion || !import_semver.default.valid(workflowCoreVersion)) {
32302
32493
  return {
32303
32494
  supportedFormats: BASELINE_FORMATS,
@@ -32310,6 +32501,9 @@ function getRunCapabilities(workflowCoreVersion) {
32310
32501
  formats.add(format);
32311
32502
  }
32312
32503
  }
32504
+ if (!nodeVersionSupportsZstd(nodeVersion)) {
32505
+ formats.delete(SerializationFormat.ZSTD);
32506
+ }
32313
32507
  const result = {
32314
32508
  supportedFormats: formats,
32315
32509
  framedByteStreams: false
@@ -32321,7 +32515,13 @@ function getRunCapabilities(workflowCoreVersion) {
32321
32515
  }
32322
32516
  return result;
32323
32517
  }
32324
- var import_semver, FORMAT_VERSION_TABLE, CAPABILITY_VERSION_TABLE, BASELINE_FORMATS;
32518
+ function getCompressionMode(capabilities) {
32519
+ if (!capabilities.supportedFormats.has(SerializationFormat.GZIP)) {
32520
+ return false;
32521
+ }
32522
+ return capabilities.supportedFormats.has(SerializationFormat.ZSTD) ? true : "gzip";
32523
+ }
32524
+ var import_semver, FORMAT_VERSION_TABLE, CAPABILITY_VERSION_TABLE, BASELINE_FORMATS, ZSTD_NODE_RANGE;
32325
32525
  var init_capabilities = __esm({
32326
32526
  "../core/dist/capabilities.js"() {
32327
32527
  "use strict";
@@ -32337,7 +32537,8 @@ var init_capabilities = __esm({
32337
32537
  // bump to the next beta. A too-low cutoff makes new producers write
32338
32538
  // compressed payloads to consumers that cannot decompress them; too-high
32339
32539
  // merely delays the optimization (safe). gzip and zstd ship together, so
32340
- // they share a min version: a run that can read one can read both.
32540
+ // they share a min version. zstd additionally requires the run's runtime to
32541
+ // decode it; see `getRunCapabilities`.
32341
32542
  {
32342
32543
  format: SerializationFormat.GZIP,
32343
32544
  minVersion: "5.0.0-beta.18"
@@ -32370,7 +32571,11 @@ var init_capabilities = __esm({
32370
32571
  BASELINE_FORMATS = /* @__PURE__ */ new Set([
32371
32572
  SerializationFormat.DEVALUE_V1
32372
32573
  ]);
32574
+ ZSTD_NODE_RANGE = "^22.15.0 || >=23.8.0";
32575
+ __name(nodeVersionSupportsZstd, "nodeVersionSupportsZstd");
32576
+ __name(getCurrentNodeVersion, "getCurrentNodeVersion");
32373
32577
  __name(getRunCapabilities, "getRunCapabilities");
32578
+ __name(getCompressionMode, "getCompressionMode");
32374
32579
  }
32375
32580
  });
32376
32581
 
@@ -32379,7 +32584,7 @@ var version2;
32379
32584
  var init_version = __esm({
32380
32585
  "../core/dist/version.js"() {
32381
32586
  "use strict";
32382
- version2 = "5.0.0";
32587
+ version2 = "5.1.0";
32383
32588
  }
32384
32589
  });
32385
32590
 
@@ -32491,6 +32696,9 @@ function parseHealthCheckResponse(chunks) {
32491
32696
  if (typeof r.workflowCoreVersion === "string") {
32492
32697
  parsed.workflowCoreVersion = r.workflowCoreVersion;
32493
32698
  }
32699
+ if (typeof r.nodeVersion === "string") {
32700
+ parsed.nodeVersion = r.nodeVersion;
32701
+ }
32494
32702
  if (typeof r.encryptionPublicKey === "string") {
32495
32703
  parsed.encryptionPublicKey = r.encryptionPublicKey;
32496
32704
  }
@@ -32565,6 +32773,7 @@ var init_helpers = __esm({
32565
32773
  init_dist2();
32566
32774
  init_dist4();
32567
32775
  init_node();
32776
+ init_capabilities();
32568
32777
  init_logger();
32569
32778
  init_sealed_box();
32570
32779
  init_encryption2();
@@ -37650,11 +37859,13 @@ function resumeContextFromRun(run2) {
37650
37859
  const coreVersion = run2.executionContext?.workflowCoreVersion;
37651
37860
  const traceCarrier = run2.executionContext?.traceCarrier;
37652
37861
  const hookResumeInputVersion = run2.executionContext?.hookResumeInputVersion;
37862
+ const nodeVersion = run2.executionContext?.nodeVersion;
37653
37863
  return {
37654
37864
  deploymentId: run2.deploymentId,
37655
37865
  workflowName: run2.workflowName,
37656
37866
  runSpecVersion: run2.specVersion,
37657
37867
  workflowCoreVersion: typeof coreVersion === "string" ? coreVersion : void 0,
37868
+ nodeVersion: typeof nodeVersion === "string" ? nodeVersion : void 0,
37658
37869
  traceCarrier: traceCarrier && typeof traceCarrier === "object" ? traceCarrier : void 0,
37659
37870
  encryptionPublicKey: run2.encryptionPublicKey,
37660
37871
  hookResumeInputVersion: typeof hookResumeInputVersion === "number" ? hookResumeInputVersion : void 0
@@ -37851,7 +38062,7 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
37851
38062
  if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
37852
38063
  throw new HookNotFoundError(hook.token);
37853
38064
  }
37854
- const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
38065
+ const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion, resumeContext.nodeVersion);
37855
38066
  let payloadKey;
37856
38067
  const runPublicKey = encryptionKeyOverride ? (
37857
38068
  // hydrate hook metadata), so sealing would add an ECDH for no
@@ -37867,7 +38078,7 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
37867
38078
  }
37868
38079
  payloadKey = encryptionKey;
37869
38080
  }
37870
- const compression = (resumeContext.runSpecVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION && capabilities.supportedFormats.has(SerializationFormat.GZIP);
38081
+ const compression = (resumeContext.runSpecVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION ? getCompressionMode(capabilities) : false;
37871
38082
  const ops = [];
37872
38083
  const readbackOps = [];
37873
38084
  const v1Compat = isLegacySpecVersion(hook.specVersion);
@@ -39230,7 +39441,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
39230
39441
  AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId), "AbortSignal")
39231
39442
  };
39232
39443
  }
39233
- function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deploymentId, streamStates) {
39444
+ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deploymentId, streamStates, runReadyBarrier) {
39234
39445
  return {
39235
39446
  ...getCommonRevivers2(global2),
39236
39447
  // StepFunction reviver for step context - returns raw step function
@@ -39349,7 +39560,7 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
39349
39560
  pollReadableLock(userReadable, state);
39350
39561
  return userReadable;
39351
39562
  } else {
39352
- const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey, deploymentId), cryptoKey);
39563
+ const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey, deploymentId, streamStates, runReadyBarrier), cryptoKey);
39353
39564
  const state = createFlushableState();
39354
39565
  ops.push(state.promise);
39355
39566
  flushablePipe(readable, transform2.writable, state).catch(() => {
@@ -39362,8 +39573,9 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
39362
39573
  const targetRunId = typeof value.runId === "string" ? value.runId : runId;
39363
39574
  const targetDeploymentId = typeof value.deploymentId === "string" ? value.deploymentId : targetRunId === runId ? deploymentId : void 0;
39364
39575
  const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey(targetRunId, targetDeploymentId, value.encryptionPublicKey);
39365
- const serialize3 = getSerializeStream(getStepReducers(global2, ops, targetRunId, targetKey), targetKey);
39366
- const serverWritable = new WorkflowServerWritableStream(targetRunId, value.name);
39576
+ const targetRunReady = targetRunId === runId ? runReadyBarrier : void 0;
39577
+ const serialize3 = getSerializeStream(getStepReducers(global2, ops, targetRunId, targetKey, false, targetRunReady), targetKey);
39578
+ const serverWritable = new WorkflowServerWritableStream(targetRunId, value.name, targetRunReady);
39367
39579
  const state = createFlushableState();
39368
39580
  state.deferReleaseSettlement = streamStates !== void 0;
39369
39581
  streamStates?.push(state);
@@ -39473,12 +39685,12 @@ async function dehydrateStepArguments(value, _runId, key, global2 = globalThis,
39473
39685
  });
39474
39686
  }
39475
39687
  }
39476
- async function hydrateStepArguments(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}, deploymentId, streamStates) {
39688
+ async function hydrateStepArguments(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}, deploymentId, streamStates, runReadyBarrier) {
39477
39689
  const compressionStats = {};
39478
39690
  const result = await deserialize2(value, key, {
39479
39691
  global: global2,
39480
39692
  extraRevivers: {
39481
- ...getStreamAndRequestRevivers(getStepRevivers(global2, ops, runId, key, deploymentId, streamStates)),
39693
+ ...getStreamAndRequestRevivers(getStepRevivers(global2, ops, runId, key, deploymentId, streamStates, runReadyBarrier)),
39482
39694
  ...extraRevivers
39483
39695
  },
39484
39696
  compressionStats
@@ -39927,6 +40139,14 @@ var init_serialization2 = __esm({
39927
40139
  enumerable: false,
39928
40140
  writable: false
39929
40141
  });
40142
+ Object.defineProperty(this, STREAM_RELEASE_SYMBOL, {
40143
+ value: /* @__PURE__ */ __name(async () => {
40144
+ const session = await writeSessionPromise.catch(() => void 0);
40145
+ await session?.release?.();
40146
+ }, "value"),
40147
+ enumerable: false,
40148
+ writable: false
40149
+ });
39930
40150
  }
39931
40151
  };
39932
40152
  __name(getAllBaseReducers, "getAllBaseReducers");
@@ -46760,14 +46980,27 @@ function parse6(input2, options) {
46760
46980
  __name(parse6, "parse");
46761
46981
 
46762
46982
  // ../core/dist/runtime/dynamic-workflow.js
46983
+ function dynamicStartRefusal(message, options) {
46984
+ return Object.assign(new WorkflowRuntimeError(message, options), {
46985
+ fatal: true
46986
+ });
46987
+ }
46988
+ __name(dynamicStartRefusal, "dynamicStartRefusal");
46989
+ function dynamicStartRefusalFrom(error61) {
46990
+ return dynamicStartRefusal(error61 instanceof Error ? error61.message : String(error61), {
46991
+ cause: error61
46992
+ });
46993
+ }
46994
+ __name(dynamicStartRefusalFrom, "dynamicStartRefusalFrom");
46763
46995
  var DYNAMIC_WORKFLOW_SOURCE_MAX_BYTES = 128 * 1024;
46764
46996
  var DYNAMIC_WORKFLOW_CODE_INLINE_MAX_BYTES = 24 * 1024;
46765
46997
  var SAFE_DYNAMIC_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
46998
+ var DYNAMIC_WORKFLOW_EXPORT_NAME_MAX_LENGTH = 64;
46766
46999
  var SAFE_DYNAMIC_EXPORT_NAME = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
46767
47000
  var UNSUPPORTED_DYNAMIC_MODULE_SYNTAX = /^[ \t]*(?:import(?:\s+[\w$]|\s*(?:[*{(]|['"]))|export(?:\s+(?:async\s+)?(?:function|const|let|var|class|default)\b|\s*[{*]))/m;
46768
47001
  function assertDynamicWorkflowIdentifier(kind, value) {
46769
47002
  if (!SAFE_DYNAMIC_IDENTIFIER.test(value)) {
46770
- throw new WorkflowRuntimeError(`Invalid dynamic workflow ${kind} ${JSON.stringify(value)}. Use a valid JavaScript identifier: letters, digits, "_" and "$", not starting with a digit.`);
47003
+ throw dynamicStartRefusal(`Invalid dynamic workflow ${kind} ${JSON.stringify(value)}. Use a valid JavaScript identifier: letters, digits, "_" and "$", not starting with a digit.`);
46771
47004
  }
46772
47005
  }
46773
47006
  __name(assertDynamicWorkflowIdentifier, "assertDynamicWorkflowIdentifier");
@@ -46787,7 +47020,7 @@ async function sha256Hex(input2) {
46787
47020
  }
46788
47021
  __name(sha256Hex, "sha256Hex");
46789
47022
  var DYNAMIC_WORKFLOW_ECMA_VERSION = 2024;
46790
- function parseDynamicWorkflowSource(source) {
47023
+ function parseDynamicWorkflowSource(source, exportName) {
46791
47024
  try {
46792
47025
  return parse6(source, {
46793
47026
  ecmaVersion: DYNAMIC_WORKFLOW_ECMA_VERSION,
@@ -46795,7 +47028,7 @@ function parseDynamicWorkflowSource(source) {
46795
47028
  });
46796
47029
  } catch (error61) {
46797
47030
  const message = error61 instanceof Error ? error61.message : String(error61);
46798
- throw new WorkflowRuntimeError(`Dynamic workflow source is not valid JavaScript: ${message}. The source is evaluated as-is, so it cannot contain TypeScript syntax or module declarations.`);
47031
+ throw dynamicStartRefusal(`Dynamic workflow source is not valid JavaScript: ${message}. The source is evaluated as-is, so it cannot contain TypeScript syntax or module declarations. If the error is at an \`await\`, declare the function as \`async function ${exportName}(...)\`.`);
46799
47032
  }
46800
47033
  }
46801
47034
  __name(parseDynamicWorkflowSource, "parseDynamicWorkflowSource");
@@ -46807,37 +47040,77 @@ function assertGeneratedWorkflowCodeParses(workflowCode) {
46807
47040
  });
46808
47041
  } catch (error61) {
46809
47042
  const message = error61 instanceof Error ? error61.message : String(error61);
46810
- throw new WorkflowRuntimeError(`Generated dynamic workflow code is not valid JavaScript: ${message}.`);
47043
+ throw dynamicStartRefusal(`Generated dynamic workflow code is not valid JavaScript: ${message}.`);
46811
47044
  }
46812
47045
  }
46813
47046
  __name(assertGeneratedWorkflowCodeParses, "assertGeneratedWorkflowCodeParses");
46814
47047
  function validateDynamicWorkflowSource(source, exportName) {
46815
47048
  const byteLength = new TextEncoder().encode(source).byteLength;
46816
47049
  if (byteLength > DYNAMIC_WORKFLOW_SOURCE_MAX_BYTES) {
46817
- throw new WorkflowRuntimeError(`Dynamic workflow source is ${byteLength} bytes, over the ${DYNAMIC_WORKFLOW_SOURCE_MAX_BYTES}-byte limit.`);
47050
+ throw dynamicStartRefusal(`Dynamic workflow source is ${byteLength} bytes, over the ${DYNAMIC_WORKFLOW_SOURCE_MAX_BYTES}-byte limit.`);
46818
47051
  }
46819
47052
  if (UNSUPPORTED_DYNAMIC_MODULE_SYNTAX.test(source)) {
46820
- throw new WorkflowRuntimeError("Dynamic workflow source cannot use `import` or `export`. Reach registered steps through the injected `steps` object instead.");
46821
- }
46822
- const program = parseDynamicWorkflowSource(source);
46823
- const declarations = program.body.filter((node2) => node2.type === "FunctionDeclaration" && node2.id.name === exportName);
46824
- const declaration = declarations.length === 1 ? declarations[0] : void 0;
46825
- if (!declaration || !declaration.async || declaration.generator) {
46826
- throw new WorkflowRuntimeError(`Dynamic workflow source must declare \`async function ${exportName}(...)\` at top level.`);
47053
+ throw dynamicStartRefusal("Dynamic workflow source cannot use `import` or `export`. Reach registered steps through the injected `steps` object instead.");
46827
47054
  }
47055
+ const program = parseDynamicWorkflowSource(source, exportName);
47056
+ const declaration = findWorkflowDeclaration(program, exportName);
46828
47057
  const firstStatement = declaration.body.body[0];
46829
47058
  if (firstStatement?.type !== "ExpressionStatement" || firstStatement.directive !== "use workflow") {
46830
- throw new WorkflowRuntimeError(`Dynamic workflow function ${JSON.stringify(exportName)} must open with a "use workflow" directive.`);
47059
+ throw dynamicStartRefusal(`Dynamic workflow function ${JSON.stringify(exportName)} must open with a "use workflow" directive.`);
46831
47060
  }
46832
- if (/(?:"use step"|'use step')/.test(source)) {
46833
- throw new WorkflowRuntimeError('Dynamic workflow source cannot declare "use step" functions. Register the step with the deployment and expose it through `experimental_dynamic.steps` instead.');
47061
+ if (hasDirective(program, "use step")) {
47062
+ throw dynamicStartRefusal('Dynamic workflow source cannot declare "use step" functions. Register the step with the deployment and expose it through `experimental_dynamic.steps` instead.');
46834
47063
  }
46835
47064
  }
46836
47065
  __name(validateDynamicWorkflowSource, "validateDynamicWorkflowSource");
47066
+ function findWorkflowDeclaration(program, exportName) {
47067
+ const expected = `Dynamic workflow source must declare \`async function ${exportName}(...)\` at top level`;
47068
+ const declarations = program.body.filter((node2) => node2.type === "FunctionDeclaration" && node2.id.name === exportName);
47069
+ const [declaration] = declarations;
47070
+ let problem = "";
47071
+ if (declarations.length > 1) {
47072
+ problem = ` exactly once, but declares \`function ${exportName}\` ${declarations.length} times`;
47073
+ } else if (declaration?.generator) {
47074
+ problem = `, but \`${exportName}\` is a generator function`;
47075
+ } else if (declaration && !declaration.async) {
47076
+ problem = `, but \`${exportName}\` is not async`;
47077
+ }
47078
+ if (!declaration || problem) {
47079
+ throw dynamicStartRefusal(`${expected}${problem}.`);
47080
+ }
47081
+ return declaration;
47082
+ }
47083
+ __name(findWorkflowDeclaration, "findWorkflowDeclaration");
47084
+ function hasDirective(program, directive) {
47085
+ const pending = [
47086
+ program
47087
+ ];
47088
+ while (pending.length > 0) {
47089
+ const node2 = pending.pop();
47090
+ if (node2.directive === directive) return true;
47091
+ for (const child of childNodes(node2)) pending.push(child);
47092
+ }
47093
+ return false;
47094
+ }
47095
+ __name(hasDirective, "hasDirective");
47096
+ function childNodes(node2) {
47097
+ const children = [];
47098
+ for (const value of Object.values(node2)) {
47099
+ for (const child of Array.isArray(value) ? value : [
47100
+ value
47101
+ ]) {
47102
+ if (child && typeof child === "object" && "type" in child) {
47103
+ children.push(child);
47104
+ }
47105
+ }
47106
+ }
47107
+ return children;
47108
+ }
47109
+ __name(childNodes, "childNodes");
46837
47110
  function resolveStepId(alias, value) {
46838
47111
  const stepId = value && typeof value === "object" || typeof value === "function" ? value.stepId : void 0;
46839
47112
  if (typeof stepId !== "string" || stepId.length === 0) {
46840
- throw new WorkflowRuntimeError(`Dynamic workflow step ${JSON.stringify(alias)} must be an imported step function or an object with a non-empty \`stepId\`.`);
47113
+ throw dynamicStartRefusal(`Dynamic workflow step ${JSON.stringify(alias)} must be an imported step function or an object with a non-empty \`stepId\`.`);
46841
47114
  }
46842
47115
  return stepId;
46843
47116
  }
@@ -46848,13 +47121,16 @@ function dynamicWorkflowName(metadata) {
46848
47121
  __name(dynamicWorkflowName, "dynamicWorkflowName");
46849
47122
  async function compileDynamicWorkflow(source, options) {
46850
47123
  const exportName = options.exportName ?? "workflow";
47124
+ if (exportName.length > DYNAMIC_WORKFLOW_EXPORT_NAME_MAX_LENGTH) {
47125
+ throw dynamicStartRefusal(`Dynamic workflow exportName is ${exportName.length} characters, over the ${DYNAMIC_WORKFLOW_EXPORT_NAME_MAX_LENGTH}-character limit. It becomes part of the workflow id and queue name.`);
47126
+ }
46851
47127
  assertDynamicWorkflowIdentifier("exportName", exportName);
46852
47128
  if (!SAFE_DYNAMIC_EXPORT_NAME.test(exportName)) {
46853
- throw new WorkflowRuntimeError(`Invalid dynamic workflow exportName ${JSON.stringify(exportName)}. Use letters, digits, and "_", not starting with a digit; "$" cannot appear in workflow queue names.`);
47129
+ throw dynamicStartRefusal(`Invalid dynamic workflow exportName ${JSON.stringify(exportName)}. Use letters, digits, and "_", not starting with a digit; "$" cannot appear in workflow queue names.`);
46854
47130
  }
46855
47131
  validateDynamicWorkflowSource(source, exportName);
46856
47132
  if (!options.steps || Object.keys(options.steps).length === 0) {
46857
- throw new WorkflowRuntimeError("Dynamic workflow options must expose at least one registered step through `experimental_dynamic.steps`.");
47133
+ throw dynamicStartRefusal("Dynamic workflow options must expose at least one registered step through `experimental_dynamic.steps`.");
46858
47134
  }
46859
47135
  const stepEntries = Object.entries(options.steps).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([alias, value]) => {
46860
47136
  assertDynamicWorkflowIdentifier("step alias", alias);
@@ -47025,6 +47301,16 @@ function getWorkflowVmFromEnv(env = process.env) {
47025
47301
  throw new WorkflowRuntimeError(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS.join(", ")}.`);
47026
47302
  }
47027
47303
  __name(getWorkflowVmFromEnv, "getWorkflowVmFromEnv");
47304
+ function getSnapshotThresholdFromEnv(env = process.env) {
47305
+ const raw = env.WORKFLOW_SNAPSHOT_THRESHOLD;
47306
+ if (raw === void 0 || raw === "") return void 0;
47307
+ const parsed = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
47308
+ if (!Number.isSafeInteger(parsed)) {
47309
+ throw new WorkflowRuntimeError(`Invalid WORKFLOW_SNAPSHOT_THRESHOLD value: "${raw}". Expected a non-negative integer (0 disables snapshotting).`);
47310
+ }
47311
+ return parsed;
47312
+ }
47313
+ __name(getSnapshotThresholdFromEnv, "getSnapshotThresholdFromEnv");
47028
47314
 
47029
47315
  // ../core/dist/runtime/start.js
47030
47316
  init_wait_until();
@@ -47121,7 +47407,7 @@ async function probeCrossDeployment(world, options) {
47121
47407
  __name(probeCrossDeployment, "probeCrossDeployment");
47122
47408
  function assertDynamicWorkflowsEnabled() {
47123
47409
  if (!isDynamicWorkflowsEnabled()) {
47124
- throw new WorkflowRuntimeError(`Dynamic workflows are disabled on this deployment, so no run was created. Set ${DYNAMIC_WORKFLOWS_ENV}=1 on the deployment to enable them.`);
47410
+ 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.`);
47125
47411
  }
47126
47412
  }
47127
47413
  __name(assertDynamicWorkflowsEnabled, "assertDynamicWorkflowsEnabled");
@@ -47139,7 +47425,7 @@ async function start(workflow, argsOrOptions, options) {
47139
47425
  if (typeof workflow === "string") {
47140
47426
  const dynamicOptions = opts.experimental_dynamic;
47141
47427
  if (!dynamicOptions) {
47142
- throw new WorkflowRuntimeError("'start' was given workflow source but no `experimental_dynamic` options. Pass `{ experimental_dynamic: { steps } }` to declare which registered steps the source may call.");
47428
+ throw dynamicStartRefusal("'start' was given workflow source but no `experimental_dynamic` options. Pass `{ experimental_dynamic: { steps } }` to declare which registered steps the source may call.");
47143
47429
  }
47144
47430
  const compiled = await compileDynamicWorkflow(workflow, dynamicOptions);
47145
47431
  assertDynamicWorkflowsEnabled();
@@ -47200,28 +47486,31 @@ async function start(workflow, argsOrOptions, options) {
47200
47486
  }
47201
47487
  const crossDeployment = deploymentId !== currentDeploymentId;
47202
47488
  if (dynamicWorkflow && crossDeployment) {
47203
- const current2 = currentDeploymentId === void 0 ? "an unknown current deployment" : JSON.stringify(currentDeploymentId);
47204
- throw new WorkflowRuntimeError(`Dynamic workflows can only start on the current deployment. This start targets ${JSON.stringify(deploymentId)} from ${current2}, so no run was created.`);
47489
+ const message = `Dynamic workflows can only start on the current deployment. This start targets ${JSON.stringify(deploymentId)} from ${currentDeploymentId === void 0 ? "an unknown current deployment" : JSON.stringify(currentDeploymentId)}, so no run was created.`;
47490
+ throw currentDeploymentId === void 0 ? new WorkflowRuntimeError(message) : dynamicStartRefusal(message);
47205
47491
  }
47206
47492
  const runId = `wrun_${world.createRunId ? world.createRunId(opts) : ulid3()}`;
47207
47493
  if (dynamicWorkflow && !world.capabilities?.dynamicWorkflowCode) {
47208
- throw new WorkflowRuntimeError("Dynamic workflows require a World that declares `capabilities.dynamicWorkflowCode`. This World does not, so no run was created.");
47494
+ throw dynamicStartRefusal("Dynamic workflows require a World that declares `capabilities.dynamicWorkflowCode`. This World does not, so no run was created.");
47209
47495
  }
47210
47496
  let framedByteStreams;
47211
- let targetSupportsCompression;
47497
+ let targetCompression;
47498
+ let targetNodeVersion;
47212
47499
  let targetHookResumeInputVersion;
47213
47500
  let probedRunPublicKey;
47214
47501
  let targetSpecVersion;
47215
47502
  let specVersionSource;
47216
47503
  if (!crossDeployment) {
47217
47504
  framedByteStreams = true;
47218
- targetSupportsCompression = true;
47505
+ targetCompression = true;
47506
+ targetNodeVersion = getCurrentNodeVersion();
47219
47507
  targetHookResumeInputVersion = HOOK_RESUME_INPUT_VERSION;
47220
47508
  targetSpecVersion = world.specVersion;
47221
47509
  specVersionSource = "same-deployment";
47222
47510
  } else if (typeof world.streams?.get !== "function") {
47223
47511
  framedByteStreams = false;
47224
- targetSupportsCompression = false;
47512
+ targetCompression = false;
47513
+ targetNodeVersion = void 0;
47225
47514
  targetHookResumeInputVersion = void 0;
47226
47515
  ({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(void 0, world.specVersion));
47227
47516
  } else {
@@ -47231,9 +47520,10 @@ async function start(workflow, argsOrOptions, options) {
47231
47520
  namespace: opts.namespace
47232
47521
  });
47233
47522
  probedRunPublicKey = probe?.encryptionPublicKey;
47234
- const capabilities = getRunCapabilities(probe?.workflowCoreVersion);
47523
+ const capabilities = getRunCapabilities(probe?.workflowCoreVersion, probe?.nodeVersion);
47235
47524
  framedByteStreams = capabilities.framedByteStreams;
47236
- targetSupportsCompression = capabilities.supportedFormats.has(SerializationFormat.GZIP);
47525
+ targetCompression = getCompressionMode(capabilities);
47526
+ targetNodeVersion = probe?.nodeVersion;
47237
47527
  targetHookResumeInputVersion = probe?.hookResumeInputVersion;
47238
47528
  ({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(probe, world.specVersion));
47239
47529
  span?.setAttributes({
@@ -47321,9 +47611,13 @@ async function start(workflow, argsOrOptions, options) {
47321
47611
  encryptionPublicKey = rawKey ? bytesToBase64((await deriveRunKeyPair(rawKey)).publicKey) : void 0;
47322
47612
  }
47323
47613
  const workflowVm = getWorkflowVmFromEnv();
47614
+ const snapshotThreshold = getSnapshotThresholdFromEnv();
47324
47615
  const executionContext = {
47325
47616
  traceCarrier,
47326
47617
  workflowCoreVersion: version2,
47618
+ ...targetNodeVersion ? {
47619
+ nodeVersion: targetNodeVersion
47620
+ } : {},
47327
47621
  features: {
47328
47622
  encryption: !!encryptionKey
47329
47623
  },
@@ -47333,6 +47627,9 @@ async function start(workflow, argsOrOptions, options) {
47333
47627
  ...workflowVm ? {
47334
47628
  workflowVm
47335
47629
  } : {},
47630
+ ...snapshotThreshold !== void 0 ? {
47631
+ snapshotThreshold
47632
+ } : {},
47336
47633
  ...opts.replayedFromRunId ? {
47337
47634
  replayedFromRunId: opts.replayedFromRunId
47338
47635
  } : {},
@@ -47341,9 +47638,13 @@ async function start(workflow, argsOrOptions, options) {
47341
47638
  } : {}
47342
47639
  };
47343
47640
  if (dynamicWorkflow) {
47344
- world.validateRunExecutionContext?.(executionContext);
47641
+ try {
47642
+ world.validateRunExecutionContext?.(executionContext);
47643
+ } catch (err) {
47644
+ throw dynamicStartRefusalFrom(err);
47645
+ }
47345
47646
  }
47346
- const compression = targetSupportsCompression && specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION;
47647
+ const compression = specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION ? targetCompression : false;
47347
47648
  const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat, framedByteStreams, compression);
47348
47649
  let dynamicWorkflowCode;
47349
47650
  let dynamicWorkflowCodeRef;
@@ -47373,24 +47674,31 @@ async function start(workflow, argsOrOptions, options) {
47373
47674
  } : {}
47374
47675
  } : {};
47375
47676
  const creatorEnvironment = world.getEnvironment?.();
47677
+ const runCreated = world.events.create(runId, {
47678
+ eventType: "run_created",
47679
+ specVersion,
47680
+ eventData: {
47681
+ deploymentId,
47682
+ workflowName,
47683
+ input: workflowArguments,
47684
+ executionContext,
47685
+ ...encryptionPublicKey ? {
47686
+ encryptionPublicKey
47687
+ } : {},
47688
+ ...attributeSeed,
47689
+ ...dynamicWorkflowSeed
47690
+ }
47691
+ }, {
47692
+ v1Compat
47693
+ });
47694
+ if (dynamicWorkflow) {
47695
+ const { run: run2 } = await runCreated;
47696
+ if (run2.dynamicWorkflowCode === void 0) {
47697
+ throw new WorkflowRuntimeError(`Workflow run ${runId} was created, but this deployment's Workflow backend did not store its dynamic workflow code, so the run can never be replayed. It was not queued, so it will not execute. Dynamic workflows require a backend with encrypted dynamic-source storage; upgrade it, or start a workflow function from the build-time manifest instead.`);
47698
+ }
47699
+ }
47376
47700
  const [runCreatedResult, queueResult] = await Promise.allSettled([
47377
- world.events.create(runId, {
47378
- eventType: "run_created",
47379
- specVersion,
47380
- eventData: {
47381
- deploymentId,
47382
- workflowName,
47383
- input: workflowArguments,
47384
- executionContext,
47385
- ...encryptionPublicKey ? {
47386
- encryptionPublicKey
47387
- } : {},
47388
- ...attributeSeed,
47389
- ...dynamicWorkflowSeed
47390
- }
47391
- }, {
47392
- v1Compat
47393
- }),
47701
+ runCreated,
47394
47702
  world.queue(queueName, {
47395
47703
  runId,
47396
47704
  traceCarrier,
@@ -47444,9 +47752,6 @@ async function start(workflow, argsOrOptions, options) {
47444
47752
  if (!v1Compat && result.run.runId !== runId) {
47445
47753
  throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
47446
47754
  }
47447
- if (dynamicWorkflow && result.run.dynamicWorkflowCode === void 0) {
47448
- throw new WorkflowRuntimeError(`Workflow run ${runId} was created, but this deployment's Workflow backend did not store its dynamic workflow code, so the run can never be replayed. Dynamic workflows require a backend with encrypted dynamic-source storage; upgrade it, or start a workflow function from the build-time manifest instead.`);
47449
- }
47450
47755
  }
47451
47756
  safeWaitUntil(Promise.all(ops), (err) => {
47452
47757
  runtimeLogger.warn("Background flush of workflow argument streams failed", {
@@ -47474,7 +47779,7 @@ __name(start, "start");
47474
47779
  value: "start",
47475
47780
  configurable: true
47476
47781
  });
47477
- })(start, "step//@workflow/core/runtime/start@5.0.0//start");
47782
+ })(start, "step//@workflow/core/runtime/start@5.1.0//start");
47478
47783
 
47479
47784
  // ../core/dist/runtime/runs.js
47480
47785
  async function wakeUpRun(world, runId, options) {
@@ -47948,7 +48253,7 @@ var Run = class _Run {
47948
48253
  value: "wakeUp",
47949
48254
  configurable: true
47950
48255
  });
47951
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0//Run#wakeUp");
48256
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.1.0//Run#wakeUp");
47952
48257
  (function(__wf_fn, __wf_id) {
47953
48258
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47954
48259
  __wf_reg.set(__wf_id, __wf_fn);
@@ -47957,7 +48262,7 @@ var Run = class _Run {
47957
48262
  value: "cancel",
47958
48263
  configurable: true
47959
48264
  });
47960
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0//Run#cancel");
48265
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.1.0//Run#cancel");
47961
48266
  (function(__wf_fn, __wf_id) {
47962
48267
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47963
48268
  __wf_reg.set(__wf_id, __wf_fn);
@@ -47966,7 +48271,7 @@ var Run = class _Run {
47966
48271
  value: "getReadable",
47967
48272
  configurable: true
47968
48273
  });
47969
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0//Run#getReadable");
48274
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.1.0//Run#getReadable");
47970
48275
  (function(__wf_fn, __wf_id) {
47971
48276
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47972
48277
  __wf_reg.set(__wf_id, __wf_fn);
@@ -47975,7 +48280,7 @@ var Run = class _Run {
47975
48280
  value: "getWritable",
47976
48281
  configurable: true
47977
48282
  });
47978
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0//Run#getWritable");
48283
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.1.0//Run#getWritable");
47979
48284
  (function(__wf_fn, __wf_id) {
47980
48285
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47981
48286
  __wf_reg.set(__wf_id, __wf_fn);
@@ -47984,7 +48289,7 @@ var Run = class _Run {
47984
48289
  value: "exists",
47985
48290
  configurable: true
47986
48291
  });
47987
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0//Run#exists");
48292
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.1.0//Run#exists");
47988
48293
  (function(__wf_fn, __wf_id) {
47989
48294
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47990
48295
  __wf_reg.set(__wf_id, __wf_fn);
@@ -47993,7 +48298,7 @@ var Run = class _Run {
47993
48298
  value: "status",
47994
48299
  configurable: true
47995
48300
  });
47996
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0//Run#status");
48301
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.1.0//Run#status");
47997
48302
  (function(__wf_fn, __wf_id) {
47998
48303
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
47999
48304
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48002,7 +48307,7 @@ var Run = class _Run {
48002
48307
  value: "returnValue",
48003
48308
  configurable: true
48004
48309
  });
48005
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0//Run#returnValue");
48310
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.1.0//Run#returnValue");
48006
48311
  (function(__wf_fn, __wf_id) {
48007
48312
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48008
48313
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48011,7 +48316,7 @@ var Run = class _Run {
48011
48316
  value: "workflowName",
48012
48317
  configurable: true
48013
48318
  });
48014
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0//Run#workflowName");
48319
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.1.0//Run#workflowName");
48015
48320
  (function(__wf_fn, __wf_id) {
48016
48321
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48017
48322
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48020,7 +48325,7 @@ var Run = class _Run {
48020
48325
  value: "createdAt",
48021
48326
  configurable: true
48022
48327
  });
48023
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0//Run#createdAt");
48328
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#createdAt");
48024
48329
  (function(__wf_fn, __wf_id) {
48025
48330
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48026
48331
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48029,7 +48334,7 @@ var Run = class _Run {
48029
48334
  value: "startedAt",
48030
48335
  configurable: true
48031
48336
  });
48032
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0//Run#startedAt");
48337
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#startedAt");
48033
48338
  (function(__wf_fn, __wf_id) {
48034
48339
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48035
48340
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48038,7 +48343,7 @@ var Run = class _Run {
48038
48343
  value: "completedAt",
48039
48344
  configurable: true
48040
48345
  });
48041
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0//Run#completedAt");
48346
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#completedAt");
48042
48347
  (function(__wf_cls, __wf_id) {
48043
48348
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48044
48349
  __wf_reg.set(__wf_id, __wf_cls);
@@ -48048,7 +48353,7 @@ var Run = class _Run {
48048
48353
  enumerable: false,
48049
48354
  configurable: false
48050
48355
  });
48051
- })(Run, "class//@workflow/core/runtime/run@5.0.0//Run");
48356
+ })(Run, "class//@workflow/core/runtime/run@5.1.0//Run");
48052
48357
 
48053
48358
  // ../workflow/dist/stdlib.js
48054
48359
  async function fetch2(...args) {