@workflow/world-testing 5.0.0-beta.47 → 5.0.0-beta.48

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.
@@ -370,6 +370,8 @@ var init_error_codes = __esm({
370
370
  MAX_EVENTS_EXCEEDED: "MAX_EVENTS_EXCEEDED",
371
371
  /** Workflow replay exceeded the maximum allowed duration */
372
372
  REPLAY_TIMEOUT: "REPLAY_TIMEOUT",
373
+ /** Workflow stream infrastructure failed while reading or writing data */
374
+ STREAM_ERROR: "STREAM_ERROR",
373
375
  /** World response violated the SDK contract and cannot be retried safely */
374
376
  WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR",
375
377
  /** Run was delivered to a deployment other than the one it is pinned to */
@@ -410,12 +412,13 @@ function buildFramedDetails(hint2, slug) {
410
412
  });
411
413
  return out;
412
414
  }
413
- var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
415
+ var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY, STREAM_ERROR_KEY;
414
416
  var init_dist2 = __esm({
415
417
  "../errors/dist/index.js"() {
416
418
  "use strict";
417
419
  init_dist();
418
420
  init_error_codes();
421
+ init_error_codes();
419
422
  BASE_URL = "https://workflow-sdk.dev/err";
420
423
  __name(isError, "isError");
421
424
  __name(appendFramedDetails, "appendFramedDetails");
@@ -467,6 +470,12 @@ Caused by: ${options.cause.stack}`;
467
470
  url;
468
471
  /** Retry-After value in seconds, present on 429 and 425 responses */
469
472
  retryAfter;
473
+ /**
474
+ * The offending argument, present on client-side validation failures
475
+ * (`code: 'INVALID_ARGUMENT'`). Lets a caller correct the specific
476
+ * parameter without parsing the message.
477
+ */
478
+ field;
470
479
  constructor(message, options) {
471
480
  super(message, {
472
481
  cause: options?.cause
@@ -476,6 +485,7 @@ Caused by: ${options.cause.stack}`;
476
485
  this.code = options?.code;
477
486
  this.url = options?.url;
478
487
  this.retryAfter = options?.retryAfter;
488
+ this.field = options?.field;
479
489
  }
480
490
  static is(value) {
481
491
  return isError(value) && value.name === "WorkflowWorldError";
@@ -686,6 +696,23 @@ Caused by: ${options.cause.stack}`;
686
696
  return isError(value) && value.name === "RunExpiredError";
687
697
  }
688
698
  };
699
+ StreamError = class extends WorkflowWorldError {
700
+ static {
701
+ __name(this, "StreamError");
702
+ }
703
+ constructor(message, options) {
704
+ super(message, {
705
+ code: RUN_ERROR_CODES.STREAM_ERROR,
706
+ cause: options?.cause,
707
+ url: options?.url,
708
+ status: options?.status
709
+ });
710
+ this.name = "StreamError";
711
+ }
712
+ static is(value) {
713
+ return isError(value) && value.name === "StreamError";
714
+ }
715
+ };
689
716
  StreamExpiredError = class extends WorkflowWorldError {
690
717
  static {
691
718
  __name(this, "StreamExpiredError");
@@ -775,6 +802,7 @@ Caused by: ${options.cause.stack}`;
775
802
  RETRYABLE_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//RetryableError");
776
803
  HOOK_CONFLICT_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//HookConflictError");
777
804
  RUNTIME_DECRYPTION_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//RuntimeDecryptionError");
805
+ STREAM_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//StreamError");
778
806
  if (typeof globalThis !== "undefined") {
779
807
  if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) {
780
808
  Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
@@ -808,6 +836,14 @@ Caused by: ${options.cause.stack}`;
808
836
  configurable: false
809
837
  });
810
838
  }
839
+ if (!Object.hasOwn(globalThis, STREAM_ERROR_KEY)) {
840
+ Object.defineProperty(globalThis, STREAM_ERROR_KEY, {
841
+ value: StreamError,
842
+ writable: false,
843
+ enumerable: false,
844
+ configurable: false
845
+ });
846
+ }
811
847
  }
812
848
  }
813
849
  });
@@ -19109,7 +19145,7 @@ var init_runs = __esm({
19109
19145
  // Completed state - output can be v1 or v2 format
19110
19146
  WorkflowRunBaseSchema.extend({
19111
19147
  status: external_exports.literal("completed"),
19112
- output: SerializedDataSchema,
19148
+ output: SerializedDataSchema.optional(),
19113
19149
  error: external_exports.undefined().optional(),
19114
19150
  completedAt: external_exports.coerce.date()
19115
19151
  }),
@@ -19117,7 +19153,7 @@ var init_runs = __esm({
19117
19153
  WorkflowRunBaseSchema.extend({
19118
19154
  status: external_exports.literal("failed"),
19119
19155
  output: external_exports.undefined().optional(),
19120
- error: SerializedDataSchema,
19156
+ error: SerializedDataSchema.optional(),
19121
19157
  completedAt: external_exports.coerce.date()
19122
19158
  })
19123
19159
  ]);
@@ -19373,8 +19409,8 @@ var init_analytics = __esm({
19373
19409
  AnalyticsAttributeKeySchema = external_exports.object({
19374
19410
  key: external_exports.string(),
19375
19411
  runCount: external_exports.coerce.number(),
19376
- firstSeenAt: external_exports.coerce.date(),
19377
- lastSeenAt: external_exports.coerce.date()
19412
+ firstSeenAt: UTCDateSchema,
19413
+ lastSeenAt: UTCDateSchema
19378
19414
  });
19379
19415
  }
19380
19416
  });
@@ -20442,6 +20478,18 @@ function getCommonReducers(_global = globalThis) {
20442
20478
  }
20443
20479
  return reduced;
20444
20480
  }, "RuntimeDecryptionError"),
20481
+ StreamError: /* @__PURE__ */ __name((value) => {
20482
+ const base = reduceNamedErrorSubclassBase("StreamError", value);
20483
+ if (!base) return false;
20484
+ const reduced = {
20485
+ ...base
20486
+ };
20487
+ const status = readProperty(value, "status");
20488
+ const url2 = readProperty(value, "url");
20489
+ if (typeof status === "number") reduced.status = status;
20490
+ if (typeof url2 === "string") reduced.url = url2;
20491
+ return reduced;
20492
+ }, "StreamError"),
20445
20493
  SyntaxError: makeErrorSubclassReducer("SyntaxError"),
20446
20494
  TypeError: makeErrorSubclassReducer("TypeError"),
20447
20495
  URIError: makeErrorSubclassReducer("URIError"),
@@ -20575,6 +20623,18 @@ function getCommonRevivers(global2 = globalThis) {
20575
20623
  if (value.stack !== void 0) error48.stack = value.stack;
20576
20624
  return error48;
20577
20625
  }, "RuntimeDecryptionError"),
20626
+ StreamError: /* @__PURE__ */ __name((value) => {
20627
+ const Ctor = global2[/* @__PURE__ */ Symbol.for("@workflow/errors//StreamError")] ?? StreamError;
20628
+ const error48 = new Ctor(value.message, {
20629
+ ..."cause" in value ? {
20630
+ cause: value.cause
20631
+ } : {},
20632
+ status: value.status,
20633
+ url: value.url
20634
+ });
20635
+ if (value.stack !== void 0) error48.stack = value.stack;
20636
+ return error48;
20637
+ }, "StreamError"),
20578
20638
  SyntaxError: makeErrorSubclassReviver(global2, "SyntaxError"),
20579
20639
  TypeError: makeErrorSubclassReviver(global2, "TypeError"),
20580
20640
  URIError: makeErrorSubclassReviver(global2, "URIError"),
@@ -25982,7 +26042,7 @@ var version2;
25982
26042
  var init_version = __esm({
25983
26043
  "../core/dist/version.js"() {
25984
26044
  "use strict";
25985
- version2 = "5.0.0-beta.47";
26045
+ version2 = "5.0.0-beta.48";
25986
26046
  }
25987
26047
  });
25988
26048
 
@@ -31690,6 +31750,18 @@ function recordReadTimeToFirstChunk(startEpochMs, runId, name, startIndex, conne
31690
31750
  });
31691
31751
  })();
31692
31752
  }
31753
+ function recordStreamReadKeyResolution(startEpochMs, runId, name, succeeded) {
31754
+ void (async () => {
31755
+ await recordElapsedSpan("workflow.stream.read.resolve_key", startEpochMs, {
31756
+ kind: await getSpanKind("CLIENT"),
31757
+ attributes: {
31758
+ "workflow.run.id": runId,
31759
+ "workflow.stream.name": name,
31760
+ "workflow.stream.read.key_succeeded": succeeded
31761
+ }
31762
+ });
31763
+ })();
31764
+ }
31693
31765
  function recordStreamReadComplete(startEpochMs, runId, name, chunkCount, byteCount, reconnects) {
31694
31766
  void (async () => {
31695
31767
  await recordElapsedSpan("workflow.stream.read.complete", startEpochMs, {
@@ -31708,26 +31780,46 @@ function recordStreamReadComplete(startEpochMs, runId, name, chunkCount, byteCou
31708
31780
  });
31709
31781
  })();
31710
31782
  }
31711
- function createReconnectingFramedStream(runId, name, startIndex) {
31783
+ function createReconnectingFramedStream(runId, name, startIndex, prefetchEncryptionKey = async () => void 0) {
31712
31784
  const reconnectSupported = startIndex === void 0 || startIndex >= 0;
31713
31785
  let currentStartIndex = startIndex ?? 0;
31714
31786
  let consumedFrames = 0;
31715
31787
  let reconnectCount = 0;
31716
31788
  let totalReconnectCount = 0;
31717
31789
  let reader;
31790
+ let canceled = false;
31791
+ let cancelReason;
31718
31792
  let buffer2 = new Uint8Array(0);
31719
31793
  let readStart;
31720
31794
  let connectMs;
31721
31795
  let firstChunkReported = false;
31722
31796
  let chunksDelivered = 0;
31723
31797
  let bytesDelivered = 0;
31798
+ let keyPrefetched = false;
31799
+ function prefetchKey() {
31800
+ if (keyPrefetched) return;
31801
+ keyPrefetched = true;
31802
+ const keyStart = Date.now();
31803
+ void prefetchEncryptionKey().then((key) => {
31804
+ if (key) recordStreamReadKeyResolution(keyStart, runId, name, true);
31805
+ }, () => recordStreamReadKeyResolution(keyStart, runId, name, false));
31806
+ }
31807
+ __name(prefetchKey, "prefetchKey");
31724
31808
  async function connect() {
31809
+ if (canceled) return false;
31725
31810
  const world = await getWorldLazy();
31811
+ if (canceled) return false;
31726
31812
  const effectiveStartIndex = reconnectSupported ? currentStartIndex + consumedFrames : startIndex;
31727
31813
  const connectStart = Date.now();
31728
31814
  const stream = await world.streams.get(runId, name, effectiveStartIndex);
31815
+ if (canceled) {
31816
+ await stream.cancel(cancelReason).catch(() => {
31817
+ });
31818
+ return false;
31819
+ }
31729
31820
  if (connectMs === void 0) connectMs = Date.now() - connectStart;
31730
31821
  reader = stream.getReader();
31822
+ return true;
31731
31823
  }
31732
31824
  __name(connect, "connect");
31733
31825
  async function isVerifiedComplete() {
@@ -31741,11 +31833,13 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31741
31833
  }
31742
31834
  __name(isVerifiedComplete, "isVerifiedComplete");
31743
31835
  async function reconnect() {
31836
+ if (canceled) return false;
31744
31837
  if (reader) {
31745
31838
  await reader.cancel().catch(() => {
31746
31839
  });
31747
31840
  reader = void 0;
31748
31841
  }
31842
+ if (canceled) return false;
31749
31843
  currentStartIndex += consumedFrames;
31750
31844
  consumedFrames = 0;
31751
31845
  buffer2 = new Uint8Array(0);
@@ -31755,15 +31849,16 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31755
31849
  reconnectCount++;
31756
31850
  totalReconnectCount++;
31757
31851
  if (reconnectCount > maxReconnects) {
31758
- throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${maxReconnects})`);
31852
+ throw new StreamError(`Stream "${name}" exceeded maximum reconnection attempts (${maxReconnects})`);
31759
31853
  }
31760
31854
  if (totalReconnectCount > maxTotalReconnects) {
31761
- throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${maxTotalReconnects})`);
31855
+ throw new StreamError(`Stream "${name}" exceeded maximum total reconnection attempts (${maxTotalReconnects})`);
31762
31856
  }
31763
31857
  try {
31764
- await connect();
31765
- return;
31858
+ if (!await connect()) return false;
31859
+ return true;
31766
31860
  } catch (error48) {
31861
+ if (canceled) return false;
31767
31862
  if (StreamExpiredError.is(error48)) throw error48;
31768
31863
  }
31769
31864
  }
@@ -31771,12 +31866,15 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31771
31866
  __name(reconnect, "reconnect");
31772
31867
  return new ReadableStream({
31773
31868
  pull: /* @__PURE__ */ __name(async (controller) => {
31869
+ if (canceled) return;
31774
31870
  if (readStart === void 0) readStart = Date.now();
31871
+ prefetchKey();
31775
31872
  for (; ; ) {
31776
31873
  if (!reader) {
31777
31874
  try {
31778
- await connect();
31875
+ if (!await connect()) return;
31779
31876
  } catch (err) {
31877
+ if (canceled) return;
31780
31878
  controller.error(err);
31781
31879
  return;
31782
31880
  }
@@ -31785,23 +31883,27 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31785
31883
  try {
31786
31884
  result = await reader.read();
31787
31885
  } catch (err) {
31886
+ if (canceled) return;
31788
31887
  if (!reconnectSupported) {
31789
31888
  controller.error(err);
31790
31889
  return;
31791
31890
  }
31792
31891
  try {
31793
- await reconnect();
31892
+ if (!await reconnect()) return;
31794
31893
  } catch (reconnectErr) {
31795
31894
  controller.error(reconnectErr);
31796
31895
  return;
31797
31896
  }
31798
31897
  continue;
31799
31898
  }
31899
+ if (canceled) return;
31800
31900
  if (result.done || !result.value) {
31801
31901
  reader = void 0;
31802
- if (reconnectSupported && !await isVerifiedComplete()) {
31902
+ const verifiedComplete = !reconnectSupported || await isVerifiedComplete();
31903
+ if (canceled) return;
31904
+ if (!verifiedComplete) {
31803
31905
  try {
31804
- await reconnect();
31906
+ if (!await reconnect()) return;
31805
31907
  } catch (reconnectErr) {
31806
31908
  controller.error(reconnectErr);
31807
31909
  return;
@@ -31843,12 +31945,15 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31843
31945
  }
31844
31946
  }
31845
31947
  }, "pull"),
31846
- cancel: /* @__PURE__ */ __name(async () => {
31847
- if (reader) {
31848
- await reader.cancel().catch((err) => {
31948
+ cancel: /* @__PURE__ */ __name(async (reason) => {
31949
+ canceled = true;
31950
+ cancelReason = reason;
31951
+ const currentReader = reader;
31952
+ reader = void 0;
31953
+ if (currentReader) {
31954
+ await currentReader.cancel(reason).catch((err) => {
31849
31955
  console.warn("Error closing ReadableStream reader:", err);
31850
31956
  });
31851
- reader = void 0;
31852
31957
  }
31853
31958
  }, "cancel")
31854
31959
  });
@@ -32353,7 +32458,51 @@ async function getForwardedWritableEncryptionKey(runId, deploymentId, encryption
32353
32458
  "encrypt"
32354
32459
  ]) : void 0;
32355
32460
  }
32356
- function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
32461
+ function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey) {
32462
+ let reader;
32463
+ let lockState;
32464
+ let lockPollingStarted = false;
32465
+ let userReadable;
32466
+ userReadable = new ReadableStream(
32467
+ {
32468
+ async pull(controller) {
32469
+ try {
32470
+ if (!reader) {
32471
+ const stream = getExternalRevivers(global2, ops, runId, cryptoKey, {
32472
+ onReadableState: /* @__PURE__ */ __name((state) => {
32473
+ lockState = state;
32474
+ }, "onReadableState")
32475
+ }).ReadableStream({
32476
+ name,
32477
+ startIndex
32478
+ });
32479
+ reader = stream.getReader();
32480
+ if (lockState && !lockPollingStarted) {
32481
+ lockPollingStarted = true;
32482
+ pollReadableLock(userReadable, lockState);
32483
+ }
32484
+ }
32485
+ const result = await reader.read();
32486
+ if (result.done) controller.close();
32487
+ else controller.enqueue(result.value);
32488
+ } catch (error48) {
32489
+ controller.error(error48);
32490
+ }
32491
+ },
32492
+ async cancel(reason) {
32493
+ await reader?.cancel(reason).catch(() => {
32494
+ });
32495
+ }
32496
+ },
32497
+ // A positive default high-water mark would run pull at construction to
32498
+ // fill the queue, turning an unread Run.getReadable() into I/O.
32499
+ {
32500
+ highWaterMark: 0
32501
+ }
32502
+ );
32503
+ return userReadable;
32504
+ }
32505
+ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, options) {
32357
32506
  return {
32358
32507
  ...getCommonRevivers2(global2),
32359
32508
  // StepFunction should not be returned from workflows to clients
@@ -32401,16 +32550,23 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
32401
32550
  const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
32402
32551
  flushablePipe(readable, writable, state).catch(() => {
32403
32552
  });
32404
- pollReadableLock(userReadable, state);
32553
+ if (options?.onReadableState) options.onReadableState(state);
32554
+ else pollReadableLock(userReadable, state);
32405
32555
  return userReadable;
32406
32556
  } else {
32407
- const readable = createReconnectingFramedStream(runId, value.name, value.startIndex);
32408
- const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, cryptoKey), cryptoKey);
32557
+ let keyPromise;
32558
+ const resolveKey = /* @__PURE__ */ __name(() => {
32559
+ keyPromise ??= resolveEncryptionKey(cryptoKey);
32560
+ return keyPromise;
32561
+ }, "resolveKey");
32562
+ const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
32563
+ const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey), resolveKey);
32409
32564
  const state = createFlushableState();
32410
32565
  ops.push(state.promise);
32411
32566
  flushablePipe(readable, transform2.writable, state).catch(() => {
32412
32567
  });
32413
- pollReadableLock(transform2.readable, state);
32568
+ if (options?.onReadableState) options.onReadableState(state);
32569
+ else pollReadableLock(transform2.readable, state);
32414
32570
  return transform2.readable;
32415
32571
  }
32416
32572
  }, "ReadableStream"),
@@ -32806,6 +32962,7 @@ var init_serialization2 = __esm({
32806
32962
  __name(getByteFramingStream, "getByteFramingStream");
32807
32963
  __name(getByteUnframingStream, "getByteUnframingStream");
32808
32964
  __name(recordReadTimeToFirstChunk, "recordReadTimeToFirstChunk");
32965
+ __name(recordStreamReadKeyResolution, "recordStreamReadKeyResolution");
32809
32966
  __name(recordStreamReadComplete, "recordStreamReadComplete");
32810
32967
  WorkflowServerReadableStream = class extends ReadableStream {
32811
32968
  static {
@@ -33120,6 +33277,7 @@ var init_serialization2 = __esm({
33120
33277
  __name(reviveAbortSignal, "reviveAbortSignal");
33121
33278
  __name(getCommonRevivers2, "getCommonRevivers");
33122
33279
  __name(getForwardedWritableEncryptionKey, "getForwardedWritableEncryptionKey");
33280
+ __name(getRunReadableStream, "getRunReadableStream");
33123
33281
  __name(getExternalRevivers, "getExternalRevivers");
33124
33282
  __name(getStepRevivers, "getStepRevivers");
33125
33283
  __name(dehydrateWorkflowArguments, "dehydrateWorkflowArguments");
@@ -33298,7 +33456,8 @@ var WORLD_CONTRACT_ERROR_CODES = /* @__PURE__ */ new Set([
33298
33456
  ]);
33299
33457
  var RETRYABLE_WORLD_ERROR_CODES = /* @__PURE__ */ new Set([
33300
33458
  "TRANSPORT",
33301
- "TIMEOUT"
33459
+ "TIMEOUT",
33460
+ RUN_ERROR_CODES.STREAM_ERROR
33302
33461
  ]);
33303
33462
  var RUNTIME_ERROR_CHECKS = [
33304
33463
  WorkflowRuntimeError.is,
@@ -33314,6 +33473,9 @@ function isRetryableWorldError(err) {
33314
33473
  if (ThrottleError.is(err)) {
33315
33474
  return true;
33316
33475
  }
33476
+ if (StreamError.is(err)) {
33477
+ return err.status === void 0 || err.status >= 500;
33478
+ }
33317
33479
  if (!WorkflowWorldError.is(err)) {
33318
33480
  return false;
33319
33481
  }
@@ -33613,7 +33775,7 @@ __name(start, "start");
33613
33775
  value: "start",
33614
33776
  configurable: true
33615
33777
  });
33616
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.47//start");
33778
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.48//start");
33617
33779
 
33618
33780
  // ../core/dist/runtime/runs.js
33619
33781
  async function wakeUpRun(world, runId, options) {
@@ -33797,9 +33959,9 @@ var Run = class _Run {
33797
33959
  return this.#encryptionKeyPromise;
33798
33960
  }
33799
33961
  /**
33800
- * Defer fetching the run and its encryption key until serialized stream data
33801
- * is actually read. An empty or metadata-only stream must not start an
33802
- * unobserved run lookup.
33962
+ * Defers fetching the run and its encryption key until a readable is first
33963
+ * consumed. The first pull prefetches it so an encrypted first frame can join
33964
+ * the lookup; this also applies to an empty consumed stream.
33803
33965
  * @internal
33804
33966
  */
33805
33967
  #getEncryptionKeyLazily() {
@@ -33910,10 +34072,7 @@ var Run = class _Run {
33910
34072
  const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
33911
34073
  const name = getWorkflowRunStreamId(this.runId, namespace);
33912
34074
  const encryptionKey = this.#getEncryptionKeyLazily();
33913
- const stream = getExternalRevivers(global2, ops, this.runId, encryptionKey).ReadableStream({
33914
- name,
33915
- startIndex
33916
- });
34075
+ const stream = getRunReadableStream(global2, ops, this.runId, name, startIndex, encryptionKey);
33917
34076
  const worldPromise = this.#lazyWorldPromise;
33918
34077
  const runId = this.runId;
33919
34078
  return Object.assign(stream, {
@@ -34012,7 +34171,7 @@ var Run = class _Run {
34012
34171
  value: "wakeUp",
34013
34172
  configurable: true
34014
34173
  });
34015
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#wakeUp");
34174
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#wakeUp");
34016
34175
  (function(__wf_fn, __wf_id) {
34017
34176
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34018
34177
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34021,7 +34180,7 @@ var Run = class _Run {
34021
34180
  value: "cancel",
34022
34181
  configurable: true
34023
34182
  });
34024
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#cancel");
34183
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#cancel");
34025
34184
  (function(__wf_fn, __wf_id) {
34026
34185
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34027
34186
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34030,7 +34189,7 @@ var Run = class _Run {
34030
34189
  value: "getReadable",
34031
34190
  configurable: true
34032
34191
  });
34033
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#getReadable");
34192
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#getReadable");
34034
34193
  (function(__wf_fn, __wf_id) {
34035
34194
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34036
34195
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34039,7 +34198,7 @@ var Run = class _Run {
34039
34198
  value: "exists",
34040
34199
  configurable: true
34041
34200
  });
34042
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#exists");
34201
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#exists");
34043
34202
  (function(__wf_fn, __wf_id) {
34044
34203
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34045
34204
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34048,7 +34207,7 @@ var Run = class _Run {
34048
34207
  value: "status",
34049
34208
  configurable: true
34050
34209
  });
34051
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#status");
34210
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#status");
34052
34211
  (function(__wf_fn, __wf_id) {
34053
34212
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34054
34213
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34057,7 +34216,7 @@ var Run = class _Run {
34057
34216
  value: "returnValue",
34058
34217
  configurable: true
34059
34218
  });
34060
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#returnValue");
34219
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#returnValue");
34061
34220
  (function(__wf_fn, __wf_id) {
34062
34221
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34063
34222
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34066,7 +34225,7 @@ var Run = class _Run {
34066
34225
  value: "workflowName",
34067
34226
  configurable: true
34068
34227
  });
34069
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#workflowName");
34228
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#workflowName");
34070
34229
  (function(__wf_fn, __wf_id) {
34071
34230
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34072
34231
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34075,7 +34234,7 @@ var Run = class _Run {
34075
34234
  value: "createdAt",
34076
34235
  configurable: true
34077
34236
  });
34078
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#createdAt");
34237
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#createdAt");
34079
34238
  (function(__wf_fn, __wf_id) {
34080
34239
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34081
34240
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34084,7 +34243,7 @@ var Run = class _Run {
34084
34243
  value: "startedAt",
34085
34244
  configurable: true
34086
34245
  });
34087
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#startedAt");
34246
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#startedAt");
34088
34247
  (function(__wf_fn, __wf_id) {
34089
34248
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34090
34249
  __wf_reg.set(__wf_id, __wf_fn);
@@ -34093,7 +34252,7 @@ var Run = class _Run {
34093
34252
  value: "completedAt",
34094
34253
  configurable: true
34095
34254
  });
34096
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.47//Run#completedAt");
34255
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.48//Run#completedAt");
34097
34256
  (function(__wf_cls, __wf_id) {
34098
34257
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
34099
34258
  __wf_reg.set(__wf_id, __wf_cls);
@@ -34103,7 +34262,7 @@ var Run = class _Run {
34103
34262
  enumerable: false,
34104
34263
  configurable: false
34105
34264
  });
34106
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.47//Run");
34265
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.48//Run");
34107
34266
 
34108
34267
  // ../workflow/dist/stdlib.js
34109
34268
  async function fetch2(...args) {