@workflow/world-testing 5.0.1 → 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
@@ -26425,7 +26445,7 @@ function readToStringTag(value) {
26425
26445
  const tag = readProperty(value, Symbol.toStringTag);
26426
26446
  return typeof tag === "string" ? tag : void 0;
26427
26447
  }
26428
- 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;
26429
26449
  var init_hardened = __esm({
26430
26450
  "../core/dist/serialization/hardened.js"() {
26431
26451
  "use strict";
@@ -26461,6 +26481,9 @@ var init_hardened = __esm({
26461
26481
  typedArrayByteOffset = protoGetter(TypedArrayPrototype, "byteOffset");
26462
26482
  typedArrayByteLength = protoGetter(TypedArrayPrototype, "byteLength");
26463
26483
  typedArrayLength = protoGetter(TypedArrayPrototype, "length");
26484
+ typedArraySet = uncurryThis(TypedArrayPrototype.set);
26485
+ HostArrayBuffer = ArrayBuffer;
26486
+ HostUint8Array = Uint8Array;
26464
26487
  dataViewBuffer = protoGetter(DataView.prototype, "buffer");
26465
26488
  dataViewByteOffset = protoGetter(DataView.prototype, "byteOffset");
26466
26489
  dataViewByteLength = protoGetter(DataView.prototype, "byteLength");
@@ -26554,12 +26577,23 @@ var init_hardened = __esm({
26554
26577
  entriesOf: /* @__PURE__ */ __name((map2) => mapToEntries(map2), "entriesOf"),
26555
26578
  viewInfo: /* @__PURE__ */ __name((view) => {
26556
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));
26557
26591
  return {
26558
- ...info,
26559
- // devalue only reads `length` for typed-array subviews; DataView
26560
- // subviews are encoded from `byteLength`.
26561
- length: types.isDataView(view) ? 0 : typedArrayLength(view),
26562
- 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
26563
26597
  };
26564
26598
  }, "viewInfo"),
26565
26599
  shapeOf: /* @__PURE__ */ __name((value) => {
@@ -27380,20 +27414,22 @@ function recordStats(stats, codec2, uncompressedBytes, storedBytes) {
27380
27414
  stats.uncompressedBytes = uncompressedBytes;
27381
27415
  stats.storedBytes = storedBytes;
27382
27416
  }
27383
- function selectWriteCodec() {
27417
+ function selectWriteCodec(mode) {
27384
27418
  const override = codecOverrideFromEnv();
27385
- if (override === "gzip") return isGzipAvailable() ? "gzip" : "none";
27419
+ if (mode === "gzip" || override === "gzip") {
27420
+ return isGzipAvailable() ? "gzip" : "none";
27421
+ }
27386
27422
  if (isZstdAvailable()) return "zstd";
27387
27423
  if (isGzipAvailable()) return "gzip";
27388
27424
  return "none";
27389
27425
  }
27390
- async function compress(data2, enabled, stats, opts) {
27426
+ async function compress(data2, mode, stats, opts) {
27391
27427
  if (!(data2 instanceof Uint8Array)) return data2;
27392
- if (!enabled || data2.length < COMPRESSION_MIN_BYTES || isCompressionDisabledByEnv()) {
27428
+ if (!mode || data2.length < COMPRESSION_MIN_BYTES || isCompressionDisabledByEnv()) {
27393
27429
  recordStats(stats, "none", data2.length, data2.length);
27394
27430
  return data2;
27395
27431
  }
27396
- const codec2 = selectWriteCodec();
27432
+ const codec2 = selectWriteCodec(mode);
27397
27433
  if (codec2 === "none") {
27398
27434
  recordStats(stats, "none", data2.length, data2.length);
27399
27435
  return data2;
@@ -30249,7 +30285,7 @@ async function serialize(value, encryptionKey, options) {
30249
30285
  try {
30250
30286
  const payload = devalueCodec.serialize(value, "client", options);
30251
30287
  const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
30252
- const compressed = await compress(prefixed, options?.compression === true, options?.compressionStats);
30288
+ const compressed = await compress(prefixed, options?.compression ?? false, options?.compressionStats);
30253
30289
  return encrypt2(compressed, encryptionKey);
30254
30290
  } catch (error61) {
30255
30291
  rethrowIfRuntimeError(error61);
@@ -30294,7 +30330,7 @@ async function serialize2(value, encryptionKey, options) {
30294
30330
  try {
30295
30331
  const payload = devalueCodec.serialize(value, "step", options);
30296
30332
  const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
30297
- const compressed = await compress(prefixed, options?.compression === true, options?.compressionStats);
30333
+ const compressed = await compress(prefixed, options?.compression ?? false, options?.compressionStats);
30298
30334
  return encrypt2(compressed, encryptionKey);
30299
30335
  } catch (error61) {
30300
30336
  rethrowIfRuntimeError(error61);
@@ -32437,7 +32473,22 @@ var require_semver3 = __commonJS({
32437
32473
  });
32438
32474
 
32439
32475
  // ../core/dist/capabilities.js
32440
- 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) {
32441
32492
  if (!workflowCoreVersion || !import_semver.default.valid(workflowCoreVersion)) {
32442
32493
  return {
32443
32494
  supportedFormats: BASELINE_FORMATS,
@@ -32450,6 +32501,9 @@ function getRunCapabilities(workflowCoreVersion) {
32450
32501
  formats.add(format);
32451
32502
  }
32452
32503
  }
32504
+ if (!nodeVersionSupportsZstd(nodeVersion)) {
32505
+ formats.delete(SerializationFormat.ZSTD);
32506
+ }
32453
32507
  const result = {
32454
32508
  supportedFormats: formats,
32455
32509
  framedByteStreams: false
@@ -32461,7 +32515,13 @@ function getRunCapabilities(workflowCoreVersion) {
32461
32515
  }
32462
32516
  return result;
32463
32517
  }
32464
- 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;
32465
32525
  var init_capabilities = __esm({
32466
32526
  "../core/dist/capabilities.js"() {
32467
32527
  "use strict";
@@ -32477,7 +32537,8 @@ var init_capabilities = __esm({
32477
32537
  // bump to the next beta. A too-low cutoff makes new producers write
32478
32538
  // compressed payloads to consumers that cannot decompress them; too-high
32479
32539
  // merely delays the optimization (safe). gzip and zstd ship together, so
32480
- // 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`.
32481
32542
  {
32482
32543
  format: SerializationFormat.GZIP,
32483
32544
  minVersion: "5.0.0-beta.18"
@@ -32510,7 +32571,11 @@ var init_capabilities = __esm({
32510
32571
  BASELINE_FORMATS = /* @__PURE__ */ new Set([
32511
32572
  SerializationFormat.DEVALUE_V1
32512
32573
  ]);
32574
+ ZSTD_NODE_RANGE = "^22.15.0 || >=23.8.0";
32575
+ __name(nodeVersionSupportsZstd, "nodeVersionSupportsZstd");
32576
+ __name(getCurrentNodeVersion, "getCurrentNodeVersion");
32513
32577
  __name(getRunCapabilities, "getRunCapabilities");
32578
+ __name(getCompressionMode, "getCompressionMode");
32514
32579
  }
32515
32580
  });
32516
32581
 
@@ -32519,7 +32584,7 @@ var version2;
32519
32584
  var init_version = __esm({
32520
32585
  "../core/dist/version.js"() {
32521
32586
  "use strict";
32522
- version2 = "5.0.1";
32587
+ version2 = "5.1.0";
32523
32588
  }
32524
32589
  });
32525
32590
 
@@ -32631,6 +32696,9 @@ function parseHealthCheckResponse(chunks) {
32631
32696
  if (typeof r.workflowCoreVersion === "string") {
32632
32697
  parsed.workflowCoreVersion = r.workflowCoreVersion;
32633
32698
  }
32699
+ if (typeof r.nodeVersion === "string") {
32700
+ parsed.nodeVersion = r.nodeVersion;
32701
+ }
32634
32702
  if (typeof r.encryptionPublicKey === "string") {
32635
32703
  parsed.encryptionPublicKey = r.encryptionPublicKey;
32636
32704
  }
@@ -32705,6 +32773,7 @@ var init_helpers = __esm({
32705
32773
  init_dist2();
32706
32774
  init_dist4();
32707
32775
  init_node();
32776
+ init_capabilities();
32708
32777
  init_logger();
32709
32778
  init_sealed_box();
32710
32779
  init_encryption2();
@@ -37790,11 +37859,13 @@ function resumeContextFromRun(run2) {
37790
37859
  const coreVersion = run2.executionContext?.workflowCoreVersion;
37791
37860
  const traceCarrier = run2.executionContext?.traceCarrier;
37792
37861
  const hookResumeInputVersion = run2.executionContext?.hookResumeInputVersion;
37862
+ const nodeVersion = run2.executionContext?.nodeVersion;
37793
37863
  return {
37794
37864
  deploymentId: run2.deploymentId,
37795
37865
  workflowName: run2.workflowName,
37796
37866
  runSpecVersion: run2.specVersion,
37797
37867
  workflowCoreVersion: typeof coreVersion === "string" ? coreVersion : void 0,
37868
+ nodeVersion: typeof nodeVersion === "string" ? nodeVersion : void 0,
37798
37869
  traceCarrier: traceCarrier && typeof traceCarrier === "object" ? traceCarrier : void 0,
37799
37870
  encryptionPublicKey: run2.encryptionPublicKey,
37800
37871
  hookResumeInputVersion: typeof hookResumeInputVersion === "number" ? hookResumeInputVersion : void 0
@@ -37991,7 +38062,7 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
37991
38062
  if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
37992
38063
  throw new HookNotFoundError(hook.token);
37993
38064
  }
37994
- const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
38065
+ const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion, resumeContext.nodeVersion);
37995
38066
  let payloadKey;
37996
38067
  const runPublicKey = encryptionKeyOverride ? (
37997
38068
  // hydrate hook metadata), so sealing would add an ECDH for no
@@ -38007,7 +38078,7 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
38007
38078
  }
38008
38079
  payloadKey = encryptionKey;
38009
38080
  }
38010
- 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;
38011
38082
  const ops = [];
38012
38083
  const readbackOps = [];
38013
38084
  const v1Compat = isLegacySpecVersion(hook.specVersion);
@@ -39370,7 +39441,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
39370
39441
  AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId), "AbortSignal")
39371
39442
  };
39372
39443
  }
39373
- function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deploymentId, streamStates) {
39444
+ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deploymentId, streamStates, runReadyBarrier) {
39374
39445
  return {
39375
39446
  ...getCommonRevivers2(global2),
39376
39447
  // StepFunction reviver for step context - returns raw step function
@@ -39489,7 +39560,7 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
39489
39560
  pollReadableLock(userReadable, state);
39490
39561
  return userReadable;
39491
39562
  } else {
39492
- const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey, deploymentId), cryptoKey);
39563
+ const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey, deploymentId, streamStates, runReadyBarrier), cryptoKey);
39493
39564
  const state = createFlushableState();
39494
39565
  ops.push(state.promise);
39495
39566
  flushablePipe(readable, transform2.writable, state).catch(() => {
@@ -39502,8 +39573,9 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
39502
39573
  const targetRunId = typeof value.runId === "string" ? value.runId : runId;
39503
39574
  const targetDeploymentId = typeof value.deploymentId === "string" ? value.deploymentId : targetRunId === runId ? deploymentId : void 0;
39504
39575
  const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey(targetRunId, targetDeploymentId, value.encryptionPublicKey);
39505
- const serialize3 = getSerializeStream(getStepReducers(global2, ops, targetRunId, targetKey), targetKey);
39506
- 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);
39507
39579
  const state = createFlushableState();
39508
39580
  state.deferReleaseSettlement = streamStates !== void 0;
39509
39581
  streamStates?.push(state);
@@ -39613,12 +39685,12 @@ async function dehydrateStepArguments(value, _runId, key, global2 = globalThis,
39613
39685
  });
39614
39686
  }
39615
39687
  }
39616
- 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) {
39617
39689
  const compressionStats = {};
39618
39690
  const result = await deserialize2(value, key, {
39619
39691
  global: global2,
39620
39692
  extraRevivers: {
39621
- ...getStreamAndRequestRevivers(getStepRevivers(global2, ops, runId, key, deploymentId, streamStates)),
39693
+ ...getStreamAndRequestRevivers(getStepRevivers(global2, ops, runId, key, deploymentId, streamStates, runReadyBarrier)),
39622
39694
  ...extraRevivers
39623
39695
  },
39624
39696
  compressionStats
@@ -40067,6 +40139,14 @@ var init_serialization2 = __esm({
40067
40139
  enumerable: false,
40068
40140
  writable: false
40069
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
+ });
40070
40150
  }
40071
40151
  };
40072
40152
  __name(getAllBaseReducers, "getAllBaseReducers");
@@ -47414,20 +47494,23 @@ async function start(workflow, argsOrOptions, options) {
47414
47494
  throw dynamicStartRefusal("Dynamic workflows require a World that declares `capabilities.dynamicWorkflowCode`. This World does not, so no run was created.");
47415
47495
  }
47416
47496
  let framedByteStreams;
47417
- let targetSupportsCompression;
47497
+ let targetCompression;
47498
+ let targetNodeVersion;
47418
47499
  let targetHookResumeInputVersion;
47419
47500
  let probedRunPublicKey;
47420
47501
  let targetSpecVersion;
47421
47502
  let specVersionSource;
47422
47503
  if (!crossDeployment) {
47423
47504
  framedByteStreams = true;
47424
- targetSupportsCompression = true;
47505
+ targetCompression = true;
47506
+ targetNodeVersion = getCurrentNodeVersion();
47425
47507
  targetHookResumeInputVersion = HOOK_RESUME_INPUT_VERSION;
47426
47508
  targetSpecVersion = world.specVersion;
47427
47509
  specVersionSource = "same-deployment";
47428
47510
  } else if (typeof world.streams?.get !== "function") {
47429
47511
  framedByteStreams = false;
47430
- targetSupportsCompression = false;
47512
+ targetCompression = false;
47513
+ targetNodeVersion = void 0;
47431
47514
  targetHookResumeInputVersion = void 0;
47432
47515
  ({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(void 0, world.specVersion));
47433
47516
  } else {
@@ -47437,9 +47520,10 @@ async function start(workflow, argsOrOptions, options) {
47437
47520
  namespace: opts.namespace
47438
47521
  });
47439
47522
  probedRunPublicKey = probe?.encryptionPublicKey;
47440
- const capabilities = getRunCapabilities(probe?.workflowCoreVersion);
47523
+ const capabilities = getRunCapabilities(probe?.workflowCoreVersion, probe?.nodeVersion);
47441
47524
  framedByteStreams = capabilities.framedByteStreams;
47442
- targetSupportsCompression = capabilities.supportedFormats.has(SerializationFormat.GZIP);
47525
+ targetCompression = getCompressionMode(capabilities);
47526
+ targetNodeVersion = probe?.nodeVersion;
47443
47527
  targetHookResumeInputVersion = probe?.hookResumeInputVersion;
47444
47528
  ({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(probe, world.specVersion));
47445
47529
  span?.setAttributes({
@@ -47531,6 +47615,9 @@ async function start(workflow, argsOrOptions, options) {
47531
47615
  const executionContext = {
47532
47616
  traceCarrier,
47533
47617
  workflowCoreVersion: version2,
47618
+ ...targetNodeVersion ? {
47619
+ nodeVersion: targetNodeVersion
47620
+ } : {},
47534
47621
  features: {
47535
47622
  encryption: !!encryptionKey
47536
47623
  },
@@ -47557,7 +47644,7 @@ async function start(workflow, argsOrOptions, options) {
47557
47644
  throw dynamicStartRefusalFrom(err);
47558
47645
  }
47559
47646
  }
47560
- const compression = targetSupportsCompression && specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION;
47647
+ const compression = specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION ? targetCompression : false;
47561
47648
  const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat, framedByteStreams, compression);
47562
47649
  let dynamicWorkflowCode;
47563
47650
  let dynamicWorkflowCodeRef;
@@ -47692,7 +47779,7 @@ __name(start, "start");
47692
47779
  value: "start",
47693
47780
  configurable: true
47694
47781
  });
47695
- })(start, "step//@workflow/core/runtime/start@5.0.1//start");
47782
+ })(start, "step//@workflow/core/runtime/start@5.1.0//start");
47696
47783
 
47697
47784
  // ../core/dist/runtime/runs.js
47698
47785
  async function wakeUpRun(world, runId, options) {
@@ -48166,7 +48253,7 @@ var Run = class _Run {
48166
48253
  value: "wakeUp",
48167
48254
  configurable: true
48168
48255
  });
48169
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.1//Run#wakeUp");
48256
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.1.0//Run#wakeUp");
48170
48257
  (function(__wf_fn, __wf_id) {
48171
48258
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48172
48259
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48175,7 +48262,7 @@ var Run = class _Run {
48175
48262
  value: "cancel",
48176
48263
  configurable: true
48177
48264
  });
48178
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.1//Run#cancel");
48265
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.1.0//Run#cancel");
48179
48266
  (function(__wf_fn, __wf_id) {
48180
48267
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48181
48268
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48184,7 +48271,7 @@ var Run = class _Run {
48184
48271
  value: "getReadable",
48185
48272
  configurable: true
48186
48273
  });
48187
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.1//Run#getReadable");
48274
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.1.0//Run#getReadable");
48188
48275
  (function(__wf_fn, __wf_id) {
48189
48276
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48190
48277
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48193,7 +48280,7 @@ var Run = class _Run {
48193
48280
  value: "getWritable",
48194
48281
  configurable: true
48195
48282
  });
48196
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.1//Run#getWritable");
48283
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.1.0//Run#getWritable");
48197
48284
  (function(__wf_fn, __wf_id) {
48198
48285
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48199
48286
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48202,7 +48289,7 @@ var Run = class _Run {
48202
48289
  value: "exists",
48203
48290
  configurable: true
48204
48291
  });
48205
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.1//Run#exists");
48292
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.1.0//Run#exists");
48206
48293
  (function(__wf_fn, __wf_id) {
48207
48294
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48208
48295
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48211,7 +48298,7 @@ var Run = class _Run {
48211
48298
  value: "status",
48212
48299
  configurable: true
48213
48300
  });
48214
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.1//Run#status");
48301
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.1.0//Run#status");
48215
48302
  (function(__wf_fn, __wf_id) {
48216
48303
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48217
48304
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48220,7 +48307,7 @@ var Run = class _Run {
48220
48307
  value: "returnValue",
48221
48308
  configurable: true
48222
48309
  });
48223
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.1//Run#returnValue");
48310
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.1.0//Run#returnValue");
48224
48311
  (function(__wf_fn, __wf_id) {
48225
48312
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48226
48313
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48229,7 +48316,7 @@ var Run = class _Run {
48229
48316
  value: "workflowName",
48230
48317
  configurable: true
48231
48318
  });
48232
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.1//Run#workflowName");
48319
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.1.0//Run#workflowName");
48233
48320
  (function(__wf_fn, __wf_id) {
48234
48321
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48235
48322
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48238,7 +48325,7 @@ var Run = class _Run {
48238
48325
  value: "createdAt",
48239
48326
  configurable: true
48240
48327
  });
48241
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.1//Run#createdAt");
48328
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#createdAt");
48242
48329
  (function(__wf_fn, __wf_id) {
48243
48330
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48244
48331
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48247,7 +48334,7 @@ var Run = class _Run {
48247
48334
  value: "startedAt",
48248
48335
  configurable: true
48249
48336
  });
48250
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.1//Run#startedAt");
48337
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#startedAt");
48251
48338
  (function(__wf_fn, __wf_id) {
48252
48339
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48253
48340
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48256,7 +48343,7 @@ var Run = class _Run {
48256
48343
  value: "completedAt",
48257
48344
  configurable: true
48258
48345
  });
48259
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.1//Run#completedAt");
48346
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.1.0//Run#completedAt");
48260
48347
  (function(__wf_cls, __wf_id) {
48261
48348
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48262
48349
  __wf_reg.set(__wf_id, __wf_cls);
@@ -48266,7 +48353,7 @@ var Run = class _Run {
48266
48353
  enumerable: false,
48267
48354
  configurable: false
48268
48355
  });
48269
- })(Run, "class//@workflow/core/runtime/run@5.0.1//Run");
48356
+ })(Run, "class//@workflow/core/runtime/run@5.1.0//Run");
48270
48357
 
48271
48358
  // ../workflow/dist/stdlib.js
48272
48359
  async function fetch2(...args) {