@workflow/world-testing 5.0.0-beta.23 → 5.0.0-beta.25

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.
@@ -21648,10 +21648,11 @@ function matchesDebugNamespace(namespace, patternList) {
21648
21648
  }
21649
21649
  return enabled;
21650
21650
  }
21651
- function createLogger(namespace) {
21651
+ function createLogger(namespace, options = {}) {
21652
21652
  const build = /* @__PURE__ */ __name((parentMetadata) => {
21653
+ const getDebugNamespace = /* @__PURE__ */ __name((level) => options.debugNamespace ?? `workflow:${namespace}:${level}`, "getDebugNamespace");
21653
21654
  const logger = /* @__PURE__ */ __name((level) => {
21654
- const debugNamespace = `workflow:${namespace}:${level}`;
21655
+ const debugNamespace = getDebugNamespace(level);
21655
21656
  return (message, metadata) => {
21656
21657
  const hasParent = Object.keys(parentMetadata).length > 0;
21657
21658
  const hasCallSite = metadata && Object.keys(metadata).length > 0;
@@ -21697,7 +21698,7 @@ function createLogger(namespace) {
21697
21698
  }, "build");
21698
21699
  return build({});
21699
21700
  }
21700
- var stepLogger, runtimeLogger, webhookLogger, eventsLogger, adapterLogger;
21701
+ var stepLogger, runtimeLogger, webhookLogger, eventsLogger, adapterLogger, buildLogger;
21701
21702
  var init_logger = __esm({
21702
21703
  "../core/dist/logger.js"() {
21703
21704
  "use strict";
@@ -21710,6 +21711,9 @@ var init_logger = __esm({
21710
21711
  webhookLogger = createLogger("webhook");
21711
21712
  eventsLogger = createLogger("events");
21712
21713
  adapterLogger = createLogger("adapter");
21714
+ buildLogger = createLogger("build", {
21715
+ debugNamespace: "workflow:build"
21716
+ });
21713
21717
  }
21714
21718
  });
21715
21719
 
@@ -24003,7 +24007,7 @@ var version2;
24003
24007
  var init_version = __esm({
24004
24008
  "../core/dist/version.js"() {
24005
24009
  "use strict";
24006
- version2 = "5.0.0-beta.23";
24010
+ version2 = "5.0.0-beta.25";
24007
24011
  }
24008
24012
  });
24009
24013
 
@@ -25917,7 +25921,7 @@ function attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops) {
25917
25921
  once: true
25918
25922
  });
25919
25923
  }
25920
- function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey, framedByteStreams = false) {
25924
+ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey, framedByteStreams = false, runReadyBarrier) {
25921
25925
  return {
25922
25926
  ...getAllBaseReducers(global2),
25923
25927
  ReadableStream: /* @__PURE__ */ __name((value) => {
@@ -25930,7 +25934,7 @@ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey, framed
25930
25934
  const streamId = (global2[STABLE_ULID] || defaultUlid)();
25931
25935
  const name = `strm_${streamId}`;
25932
25936
  const type = getStreamType(value);
25933
- const writable = new WorkflowServerWritableStream(runId, name);
25937
+ const writable = new WorkflowServerWritableStream(runId, name, runReadyBarrier);
25934
25938
  if (type === "bytes") {
25935
25939
  if (framedByteStreams) {
25936
25940
  ops.push(value.pipeThrough(getByteFramingStream()).pipeTo(writable));
@@ -25938,7 +25942,7 @@ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey, framed
25938
25942
  ops.push(value.pipeTo(writable));
25939
25943
  }
25940
25944
  } else {
25941
- ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey, framedByteStreams), cryptoKey)).pipeTo(writable));
25945
+ ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey, framedByteStreams, runReadyBarrier), cryptoKey)).pipeTo(writable));
25942
25946
  }
25943
25947
  const s = {
25944
25948
  name
@@ -26044,7 +26048,7 @@ function getWorkflowReducers(global2 = globalThis) {
26044
26048
  }, "AbortSignal")
26045
26049
  };
26046
26050
  }
26047
- function getStepReducers(global2 = globalThis, ops, runId, cryptoKey, framedByteStreams = false) {
26051
+ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey, framedByteStreams = false, runReadyBarrier) {
26048
26052
  return {
26049
26053
  ...getAllBaseReducers(global2),
26050
26054
  ReadableStream: /* @__PURE__ */ __name((value) => {
@@ -26062,7 +26066,7 @@ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey, framedByte
26062
26066
  name = `strm_${streamId}`;
26063
26067
  type = getStreamType(value);
26064
26068
  framing = type === "bytes" && framedByteStreams ? "framed-v1" : framing;
26065
- const writable = new WorkflowServerWritableStream(runId, name);
26069
+ const writable = new WorkflowServerWritableStream(runId, name, runReadyBarrier);
26066
26070
  if (type === "bytes") {
26067
26071
  if (framing === "framed-v1") {
26068
26072
  ops.push(value.pipeThrough(getByteFramingStream()).pipeTo(writable));
@@ -26070,7 +26074,7 @@ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey, framedByte
26070
26074
  ops.push(value.pipeTo(writable));
26071
26075
  }
26072
26076
  } else {
26073
- ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey, framedByteStreams), cryptoKey)).pipeTo(writable));
26077
+ ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey, framedByteStreams, runReadyBarrier), cryptoKey)).pipeTo(writable));
26074
26078
  }
26075
26079
  }
26076
26080
  const s = {
@@ -26576,16 +26580,16 @@ async function hydrateStepArguments(value, runId, key, ops = [], global2 = globa
26576
26580
  await recordCompression(compressionStats, "deserialize");
26577
26581
  return result;
26578
26582
  }
26579
- async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = globalThis, v1Compat = false, framedByteStreams = false, compression = false) {
26583
+ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = globalThis, v1Compat = false, framedByteStreams = false, compression = false, runReadyBarrier) {
26580
26584
  if (v1Compat) {
26581
- const str = stringify(value, getStepReducers(global2, ops, runId, key, framedByteStreams));
26585
+ const str = stringify(value, getStepReducers(global2, ops, runId, key, framedByteStreams, runReadyBarrier));
26582
26586
  return revive(str);
26583
26587
  }
26584
26588
  try {
26585
26589
  const compressionStats = {};
26586
26590
  const result = await serialize2(value, key, {
26587
26591
  global: global2,
26588
- extraReducers: getStreamAndRequestReducers(getStepReducers(global2, ops, runId, key, framedByteStreams)),
26592
+ extraReducers: getStreamAndRequestReducers(getStepReducers(global2, ops, runId, key, framedByteStreams, runReadyBarrier)),
26589
26593
  compression,
26590
26594
  compressionStats
26591
26595
  });
@@ -26725,7 +26729,16 @@ var init_serialization2 = __esm({
26725
26729
  static {
26726
26730
  __name(this, "WorkflowServerWritableStream");
26727
26731
  }
26728
- constructor(runId, name) {
26732
+ /**
26733
+ * @param runReadyBarrier Turbo mode only: a promise that resolves once the
26734
+ * backgrounded `run_started` has landed. When the step body runs
26735
+ * optimistically (before `run_started` is durable), the first chunk write to
26736
+ * a brand-new stream would otherwise reach the World before the run exists
26737
+ * and be rejected as run-not-found. Awaiting this once before the first
26738
+ * flush/close orders the write after the run's creation. `undefined` outside
26739
+ * turbo and on the await path, where the run was already durable.
26740
+ */
26741
+ constructor(runId, name, runReadyBarrier) {
26729
26742
  if (typeof runId !== "string") {
26730
26743
  throw new WorkflowRuntimeError(`"runId" must be a string, got "${typeof runId}"`);
26731
26744
  }
@@ -26733,6 +26746,16 @@ var init_serialization2 = __esm({
26733
26746
  throw new WorkflowRuntimeError(`"name" is required, got "${name}"`);
26734
26747
  }
26735
26748
  const worldPromise = getWorldLazy();
26749
+ let pendingRunReady = runReadyBarrier;
26750
+ const ensureRunReady = /* @__PURE__ */ __name(async () => {
26751
+ if (pendingRunReady) {
26752
+ try {
26753
+ await pendingRunReady;
26754
+ } catch {
26755
+ }
26756
+ pendingRunReady = void 0;
26757
+ }
26758
+ }, "ensureRunReady");
26736
26759
  let buffer2 = [];
26737
26760
  let flushTimer = null;
26738
26761
  let flushPromise = null;
@@ -26743,6 +26766,7 @@ var init_serialization2 = __esm({
26743
26766
  flushTimer = null;
26744
26767
  }
26745
26768
  if (buffer2.length === 0) return;
26769
+ await ensureRunReady();
26746
26770
  const chunksToFlush = buffer2.slice();
26747
26771
  const world = await worldPromise;
26748
26772
  if (resolvedFlushIntervalMs === void 0) {
@@ -26792,6 +26816,7 @@ var init_serialization2 = __esm({
26792
26816
  flushPromise = null;
26793
26817
  }
26794
26818
  await flush();
26819
+ await ensureRunReady();
26795
26820
  const world = await worldPromise;
26796
26821
  await world.streams.close(runId, name);
26797
26822
  },
@@ -27186,7 +27211,7 @@ __name(start, "start");
27186
27211
  value: "start",
27187
27212
  configurable: true
27188
27213
  });
27189
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.23//start");
27214
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.25//start");
27190
27215
  function isRetryableStartError(err) {
27191
27216
  if (ThrottleError.is(err)) return true;
27192
27217
  if (WorkflowWorldError.is(err) && err.status && err.status >= 500) return true;
@@ -27519,7 +27544,7 @@ var Run = class _Run {
27519
27544
  value: "wakeUp",
27520
27545
  configurable: true
27521
27546
  });
27522
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#wakeUp");
27547
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#wakeUp");
27523
27548
  (function(__wf_fn, __wf_id) {
27524
27549
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27525
27550
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27528,7 +27553,7 @@ var Run = class _Run {
27528
27553
  value: "cancel",
27529
27554
  configurable: true
27530
27555
  });
27531
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#cancel");
27556
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#cancel");
27532
27557
  (function(__wf_fn, __wf_id) {
27533
27558
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27534
27559
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27537,7 +27562,7 @@ var Run = class _Run {
27537
27562
  value: "getReadable",
27538
27563
  configurable: true
27539
27564
  });
27540
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#getReadable");
27565
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#getReadable");
27541
27566
  (function(__wf_fn, __wf_id) {
27542
27567
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27543
27568
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27546,7 +27571,7 @@ var Run = class _Run {
27546
27571
  value: "exists",
27547
27572
  configurable: true
27548
27573
  });
27549
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#exists");
27574
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#exists");
27550
27575
  (function(__wf_fn, __wf_id) {
27551
27576
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27552
27577
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27555,7 +27580,7 @@ var Run = class _Run {
27555
27580
  value: "status",
27556
27581
  configurable: true
27557
27582
  });
27558
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#status");
27583
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#status");
27559
27584
  (function(__wf_fn, __wf_id) {
27560
27585
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27561
27586
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27564,7 +27589,7 @@ var Run = class _Run {
27564
27589
  value: "returnValue",
27565
27590
  configurable: true
27566
27591
  });
27567
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#returnValue");
27592
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#returnValue");
27568
27593
  (function(__wf_fn, __wf_id) {
27569
27594
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27570
27595
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27573,7 +27598,7 @@ var Run = class _Run {
27573
27598
  value: "workflowName",
27574
27599
  configurable: true
27575
27600
  });
27576
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#workflowName");
27601
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#workflowName");
27577
27602
  (function(__wf_fn, __wf_id) {
27578
27603
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27579
27604
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27582,7 +27607,7 @@ var Run = class _Run {
27582
27607
  value: "createdAt",
27583
27608
  configurable: true
27584
27609
  });
27585
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#createdAt");
27610
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#createdAt");
27586
27611
  (function(__wf_fn, __wf_id) {
27587
27612
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27588
27613
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27591,7 +27616,7 @@ var Run = class _Run {
27591
27616
  value: "startedAt",
27592
27617
  configurable: true
27593
27618
  });
27594
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#startedAt");
27619
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#startedAt");
27595
27620
  (function(__wf_fn, __wf_id) {
27596
27621
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27597
27622
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27600,7 +27625,7 @@ var Run = class _Run {
27600
27625
  value: "completedAt",
27601
27626
  configurable: true
27602
27627
  });
27603
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.23//Run#completedAt");
27628
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#completedAt");
27604
27629
  (function(__wf_cls, __wf_id) {
27605
27630
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27606
27631
  __wf_reg.set(__wf_id, __wf_cls);
@@ -27610,7 +27635,7 @@ var Run = class _Run {
27610
27635
  enumerable: false,
27611
27636
  configurable: false
27612
27637
  });
27613
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.23//Run");
27638
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.25//Run");
27614
27639
 
27615
27640
  // ../workflow/dist/stdlib.js
27616
27641
  async function fetch2(...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/world-testing",
3
- "version": "5.0.0-beta.23",
3
+ "version": "5.0.0-beta.25",
4
4
  "description": "Testing utilities and World implementation for Workflow SDK",
5
5
  "main": "dist/src/index.mjs",
6
6
  "files": [
@@ -20,11 +20,11 @@
20
20
  "chalk": "5.6.2",
21
21
  "hono": "4.12.25",
22
22
  "jsonlines": "0.1.1",
23
- "zod": "4.3.6",
24
- "@workflow/cli": "5.0.0-beta.23",
25
- "@workflow/core": "5.0.0-beta.23",
26
- "@workflow/world": "5.0.0-beta.13",
27
- "workflow": "5.0.0-beta.23"
23
+ "zod": "~4.3.6",
24
+ "@workflow/cli": "5.0.0-beta.25",
25
+ "@workflow/core": "5.0.0-beta.25",
26
+ "@workflow/world": "5.0.0-beta.14",
27
+ "workflow": "5.0.0-beta.25"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/jsonlines": "0.1.5",