@workflow/world-testing 5.0.0-beta.30 → 5.0.0-beta.32

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.
@@ -15431,7 +15431,7 @@ var init_runs2 = __esm({
15431
15431
  errorCode: external_exports2.string().optional(),
15432
15432
  /**
15433
15433
  * Plaintext string-string metadata attached to the run via
15434
- * `experimental_setAttributes()` (or, in the future, materialized
15434
+ * `setAttributes()` (or, in the future, materialized
15435
15435
  * from `attr_set` events). Stored unencrypted alongside other
15436
15436
  * plaintext fields so observability surfaces can read it without
15437
15437
  * going through the decryption pipeline.
@@ -15856,7 +15856,8 @@ var init_queue2 = __esm({
15856
15856
  });
15857
15857
 
15858
15858
  // ../world/dist/recovery.js
15859
- async function reenqueueActiveRuns(runs, enqueue, label) {
15859
+ async function reenqueueActiveRuns(runs, enqueue, label, namespace) {
15860
+ const workflowQueuePrefix = getQueueTopicPrefix2("workflow", resolveQueueNamespace2(namespace));
15860
15861
  let reenqueued = 0;
15861
15862
  for (const status of ["pending", "running"]) {
15862
15863
  let cursor;
@@ -15869,7 +15870,7 @@ async function reenqueueActiveRuns(runs, enqueue, label) {
15869
15870
  });
15870
15871
  for (const run3 of page.data) {
15871
15872
  try {
15872
- const queueName = `__wkf_workflow_${run3.workflowName}`;
15873
+ const queueName = `${workflowQueuePrefix}${run3.workflowName}`;
15873
15874
  await enqueue(queueName, { runId: run3.runId });
15874
15875
  reenqueued++;
15875
15876
  } catch (err) {
@@ -15887,6 +15888,7 @@ async function reenqueueActiveRuns(runs, enqueue, label) {
15887
15888
  var init_recovery2 = __esm({
15888
15889
  "../world/dist/recovery.js"() {
15889
15890
  "use strict";
15891
+ init_queue2();
15890
15892
  __name(reenqueueActiveRuns, "reenqueueActiveRuns");
15891
15893
  }
15892
15894
  });
@@ -45574,7 +45576,7 @@ var version4;
45574
45576
  var init_version3 = __esm({
45575
45577
  "../core/dist/version.js"() {
45576
45578
  "use strict";
45577
- version4 = "5.0.0-beta.30";
45579
+ version4 = "5.0.0-beta.32";
45578
45580
  }
45579
45581
  });
45580
45582
 
@@ -51842,6 +51844,21 @@ function createReconnectingFramedStream2(runId, name, startIndex) {
51842
51844
  }, "cancel")
51843
51845
  });
51844
51846
  }
51847
+ function recordStreamWriteFlush2(startEpochMs, dispatchEpochMs, runId, name, chunkCount, byteCount) {
51848
+ void (async () => {
51849
+ await recordElapsedSpan2("workflow.stream.flush", startEpochMs, {
51850
+ kind: await getSpanKind3("CLIENT"),
51851
+ attributes: {
51852
+ "workflow.run.id": runId,
51853
+ "workflow.stream.name": name,
51854
+ "workflow.stream.operation": "flush",
51855
+ "workflow.stream.flush.buffer_dwell_ms": dispatchEpochMs - startEpochMs,
51856
+ "workflow.stream.flush.chunks": chunkCount,
51857
+ "workflow.stream.flush.bytes": byteCount
51858
+ }
51859
+ });
51860
+ })();
51861
+ }
51845
51862
  function getAllBaseReducers2(global2 = globalThis) {
51846
51863
  return {
51847
51864
  ...getClassReducers2(),
@@ -52985,6 +53002,7 @@ var init_serialization4 = __esm({
52985
53002
  getStreamFlushIntervalMs2 = /* @__PURE__ */ __name(() => envNumber2("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS2, {
52986
53003
  integer: true
52987
53004
  }), "getStreamFlushIntervalMs");
53005
+ __name(recordStreamWriteFlush2, "recordStreamWriteFlush");
52988
53006
  WorkflowServerWritableStream2 = class extends WritableStream {
52989
53007
  static {
52990
53008
  __name(this, "WorkflowServerWritableStream");
@@ -53020,6 +53038,7 @@ var init_serialization4 = __esm({
53020
53038
  let flushTimer = null;
53021
53039
  let flushPromise = null;
53022
53040
  let resolvedFlushIntervalMs;
53041
+ let batchStartAt;
53023
53042
  const flush = /* @__PURE__ */ __name(async () => {
53024
53043
  if (flushTimer) {
53025
53044
  clearTimeout(flushTimer);
@@ -53029,16 +53048,29 @@ var init_serialization4 = __esm({
53029
53048
  return;
53030
53049
  await ensureRunReady();
53031
53050
  const chunksToFlush = buffer3.slice();
53051
+ const batchStart = batchStartAt;
53052
+ batchStartAt = void 0;
53053
+ const dispatchAt = Date.now();
53032
53054
  const world = await worldPromise;
53033
53055
  if (resolvedFlushIntervalMs === void 0) {
53034
53056
  resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs2();
53035
53057
  }
53036
- if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
53037
- await world.streams.writeMulti(runId, name, chunksToFlush);
53038
- } else {
53039
- for (const chunk of chunksToFlush) {
53040
- await world.streams.write(runId, name, chunk);
53058
+ try {
53059
+ if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
53060
+ await world.streams.writeMulti(runId, name, chunksToFlush);
53061
+ } else {
53062
+ for (const chunk of chunksToFlush) {
53063
+ await world.streams.write(runId, name, chunk);
53064
+ }
53065
+ }
53066
+ } catch (error95) {
53067
+ if (batchStart !== void 0) {
53068
+ batchStartAt = batchStartAt === void 0 ? batchStart : Math.min(batchStartAt, batchStart);
53041
53069
  }
53070
+ throw error95;
53071
+ }
53072
+ if (batchStart !== void 0) {
53073
+ recordStreamWriteFlush2(batchStart, dispatchAt, runId, name, chunksToFlush.length, chunksToFlush.reduce((sum, c) => sum + c.byteLength, 0));
53042
53074
  }
53043
53075
  buffer3 = [];
53044
53076
  }, "flush");
@@ -53061,6 +53093,8 @@ var init_serialization4 = __esm({
53061
53093
  }, "scheduleFlush");
53062
53094
  super({
53063
53095
  async write(chunk) {
53096
+ if (batchStartAt === void 0)
53097
+ batchStartAt = Date.now();
53064
53098
  if (flushPromise) {
53065
53099
  await flushPromise;
53066
53100
  flushPromise = null;
@@ -71535,7 +71569,7 @@ var init_runs = __esm2({
71535
71569
  errorCode: external_exports.string().optional(),
71536
71570
  /**
71537
71571
  * Plaintext string-string metadata attached to the run via
71538
- * `experimental_setAttributes()` (or, in the future, materialized
71572
+ * `setAttributes()` (or, in the future, materialized
71539
71573
  * from `attr_set` events). Stored unencrypted alongside other
71540
71574
  * plaintext fields so observability surfaces can read it without
71541
71575
  * going through the decryption pipeline.
@@ -71952,6 +71986,7 @@ var init_queue = __esm2({
71952
71986
  var init_recovery = __esm2({
71953
71987
  "../world/dist/recovery.js"() {
71954
71988
  "use strict";
71989
+ init_queue();
71955
71990
  }
71956
71991
  });
71957
71992
  var zodJsonSchema;
@@ -79120,7 +79155,7 @@ var version2;
79120
79155
  var init_version = __esm2({
79121
79156
  "../core/dist/version.js"() {
79122
79157
  "use strict";
79123
- version2 = "5.0.0-beta.30";
79158
+ version2 = "5.0.0-beta.32";
79124
79159
  }
79125
79160
  });
79126
79161
  function getWorkflowQueueName(workflowName, namespace) {
@@ -80988,6 +81023,22 @@ function createReconnectingFramedStream(runId, name, startIndex) {
80988
81023
  });
80989
81024
  }
80990
81025
  __name(createReconnectingFramedStream, "createReconnectingFramedStream");
81026
+ function recordStreamWriteFlush(startEpochMs, dispatchEpochMs, runId, name, chunkCount, byteCount) {
81027
+ void (async () => {
81028
+ await recordElapsedSpan("workflow.stream.flush", startEpochMs, {
81029
+ kind: await getSpanKind("CLIENT"),
81030
+ attributes: {
81031
+ "workflow.run.id": runId,
81032
+ "workflow.stream.name": name,
81033
+ "workflow.stream.operation": "flush",
81034
+ "workflow.stream.flush.buffer_dwell_ms": dispatchEpochMs - startEpochMs,
81035
+ "workflow.stream.flush.chunks": chunkCount,
81036
+ "workflow.stream.flush.bytes": byteCount
81037
+ }
81038
+ });
81039
+ })();
81040
+ }
81041
+ __name(recordStreamWriteFlush, "recordStreamWriteFlush");
80991
81042
  function getAllBaseReducers(global2 = globalThis) {
80992
81043
  return {
80993
81044
  ...getClassReducers(),
@@ -81954,6 +82005,7 @@ var init_serialization2 = __esm2({
81954
82005
  getStreamFlushIntervalMs = /* @__PURE__ */ __name2(() => envNumber("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS, {
81955
82006
  integer: true
81956
82007
  }), "getStreamFlushIntervalMs");
82008
+ __name2(recordStreamWriteFlush, "recordStreamWriteFlush");
81957
82009
  WorkflowServerWritableStream = class extends WritableStream {
81958
82010
  static {
81959
82011
  __name(this, "WorkflowServerWritableStream");
@@ -81992,6 +82044,7 @@ var init_serialization2 = __esm2({
81992
82044
  let flushTimer = null;
81993
82045
  let flushPromise = null;
81994
82046
  let resolvedFlushIntervalMs;
82047
+ let batchStartAt;
81995
82048
  const flush = /* @__PURE__ */ __name2(async () => {
81996
82049
  if (flushTimer) {
81997
82050
  clearTimeout(flushTimer);
@@ -82000,16 +82053,29 @@ var init_serialization2 = __esm2({
82000
82053
  if (buffer22.length === 0) return;
82001
82054
  await ensureRunReady();
82002
82055
  const chunksToFlush = buffer22.slice();
82056
+ const batchStart = batchStartAt;
82057
+ batchStartAt = void 0;
82058
+ const dispatchAt = Date.now();
82003
82059
  const world = await worldPromise;
82004
82060
  if (resolvedFlushIntervalMs === void 0) {
82005
82061
  resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs();
82006
82062
  }
82007
- if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
82008
- await world.streams.writeMulti(runId, name, chunksToFlush);
82009
- } else {
82010
- for (const chunk of chunksToFlush) {
82011
- await world.streams.write(runId, name, chunk);
82063
+ try {
82064
+ if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
82065
+ await world.streams.writeMulti(runId, name, chunksToFlush);
82066
+ } else {
82067
+ for (const chunk of chunksToFlush) {
82068
+ await world.streams.write(runId, name, chunk);
82069
+ }
82070
+ }
82071
+ } catch (error482) {
82072
+ if (batchStart !== void 0) {
82073
+ batchStartAt = batchStartAt === void 0 ? batchStart : Math.min(batchStartAt, batchStart);
82012
82074
  }
82075
+ throw error482;
82076
+ }
82077
+ if (batchStart !== void 0) {
82078
+ recordStreamWriteFlush(batchStart, dispatchAt, runId, name, chunksToFlush.length, chunksToFlush.reduce((sum, c) => sum + c.byteLength, 0));
82013
82079
  }
82014
82080
  buffer22 = [];
82015
82081
  }, "flush");
@@ -82029,6 +82095,7 @@ var init_serialization2 = __esm2({
82029
82095
  }, "scheduleFlush");
82030
82096
  super({
82031
82097
  async write(chunk) {
82098
+ if (batchStartAt === void 0) batchStartAt = Date.now();
82032
82099
  if (flushPromise) {
82033
82100
  await flushPromise;
82034
82101
  flushPromise = null;
@@ -82218,7 +82285,7 @@ init_dist2();
82218
82285
  init_dist4();
82219
82286
  function normalizeAttributeChanges(attrs, options = {}) {
82220
82287
  if (attrs === null || typeof attrs !== "object" || Array.isArray(attrs)) {
82221
- throw new FatalError(`experimental_setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
82288
+ throw new FatalError(`setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
82222
82289
  }
82223
82290
  const changes = Object.entries(attrs).map(([key, value]) => ({
82224
82291
  key,
@@ -82481,7 +82548,7 @@ __name2(start, "start");
82481
82548
  value: "start",
82482
82549
  configurable: true
82483
82550
  });
82484
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.30//start");
82551
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.32//start");
82485
82552
  async function wakeUpRun(world, runId, options) {
82486
82553
  try {
82487
82554
  const run22 = await world.runs.get(runId, {
@@ -82817,7 +82884,7 @@ var Run = class _Run {
82817
82884
  value: "wakeUp",
82818
82885
  configurable: true
82819
82886
  });
82820
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#wakeUp");
82887
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#wakeUp");
82821
82888
  (function(__wf_fn, __wf_id) {
82822
82889
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82823
82890
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82826,7 +82893,7 @@ var Run = class _Run {
82826
82893
  value: "cancel",
82827
82894
  configurable: true
82828
82895
  });
82829
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#cancel");
82896
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#cancel");
82830
82897
  (function(__wf_fn, __wf_id) {
82831
82898
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82832
82899
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82835,7 +82902,7 @@ var Run = class _Run {
82835
82902
  value: "getReadable",
82836
82903
  configurable: true
82837
82904
  });
82838
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#getReadable");
82905
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#getReadable");
82839
82906
  (function(__wf_fn, __wf_id) {
82840
82907
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82841
82908
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82844,7 +82911,7 @@ var Run = class _Run {
82844
82911
  value: "exists",
82845
82912
  configurable: true
82846
82913
  });
82847
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#exists");
82914
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#exists");
82848
82915
  (function(__wf_fn, __wf_id) {
82849
82916
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82850
82917
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82853,7 +82920,7 @@ var Run = class _Run {
82853
82920
  value: "status",
82854
82921
  configurable: true
82855
82922
  });
82856
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#status");
82923
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#status");
82857
82924
  (function(__wf_fn, __wf_id) {
82858
82925
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82859
82926
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82862,7 +82929,7 @@ var Run = class _Run {
82862
82929
  value: "returnValue",
82863
82930
  configurable: true
82864
82931
  });
82865
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#returnValue");
82932
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#returnValue");
82866
82933
  (function(__wf_fn, __wf_id) {
82867
82934
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82868
82935
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82871,7 +82938,7 @@ var Run = class _Run {
82871
82938
  value: "workflowName",
82872
82939
  configurable: true
82873
82940
  });
82874
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#workflowName");
82941
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#workflowName");
82875
82942
  (function(__wf_fn, __wf_id) {
82876
82943
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82877
82944
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82880,7 +82947,7 @@ var Run = class _Run {
82880
82947
  value: "createdAt",
82881
82948
  configurable: true
82882
82949
  });
82883
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#createdAt");
82950
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#createdAt");
82884
82951
  (function(__wf_fn, __wf_id) {
82885
82952
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82886
82953
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82889,7 +82956,7 @@ var Run = class _Run {
82889
82956
  value: "startedAt",
82890
82957
  configurable: true
82891
82958
  });
82892
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#startedAt");
82959
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#startedAt");
82893
82960
  (function(__wf_fn, __wf_id) {
82894
82961
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82895
82962
  __wf_reg.set(__wf_id, __wf_fn);
@@ -82898,7 +82965,7 @@ var Run = class _Run {
82898
82965
  value: "completedAt",
82899
82966
  configurable: true
82900
82967
  });
82901
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#completedAt");
82968
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#completedAt");
82902
82969
  (function(__wf_cls, __wf_id) {
82903
82970
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
82904
82971
  __wf_reg.set(__wf_id, __wf_cls);
@@ -82908,7 +82975,7 @@ var Run = class _Run {
82908
82975
  enumerable: false,
82909
82976
  configurable: false
82910
82977
  });
82911
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.30//Run");
82978
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.32//Run");
82912
82979
  async function fetch2(...args) {
82913
82980
  return globalThis.fetch(...args);
82914
82981
  }
@@ -88164,7 +88231,7 @@ async function executeStep(params) {
88164
88231
  encryptionKey,
88165
88232
  // Turbo optimistic start runs this body before `run_started` is
88166
88233
  // durable. Expose the barrier so a direct step-body world write
88167
- // (e.g. `experimental_setAttributes`) can order itself after the
88234
+ // (e.g. `setAttributes`) can order itself after the
88168
88235
  // run exists. Undefined on the await path (run already durable).
88169
88236
  runReadyBarrier: optimisticStart ? params.runReadyBarrier : void 0
88170
88237
  }, () => stepFn.apply(thisVal, args));
@@ -88798,7 +88865,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId,
88798
88865
  message: err.message
88799
88866
  });
88800
88867
  } else if (isAttributeValidationFailure(err)) {
88801
- const fatal = new FatalError2(`experimental_setAttributes failed World validation: ${err instanceof Error ? err.message : String(err)}`);
88868
+ const fatal = new FatalError2(`setAttributes failed World validation: ${err instanceof Error ? err.message : String(err)}`);
88802
88869
  fatal.cause = err;
88803
88870
  throw fatal;
88804
88871
  } else {
@@ -93246,6 +93313,179 @@ if (typeof globalThis !== "undefined") {
93246
93313
  }
93247
93314
  }
93248
93315
 
93316
+ // ../core/dist/symbols.js
93317
+ var WORKFLOW_CREATE_HOOK = /* @__PURE__ */ Symbol.for("WORKFLOW_CREATE_HOOK");
93318
+ var WORKFLOW_SLEEP = /* @__PURE__ */ Symbol.for("WORKFLOW_SLEEP");
93319
+ var WORKFLOW_GET_STREAM_ID = /* @__PURE__ */ Symbol.for("WORKFLOW_GET_STREAM_ID");
93320
+ var STREAM_NAME_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_NAME");
93321
+ var WORKFLOW_CLASS_REGISTRY = /* @__PURE__ */ Symbol.for("workflow-class-registry");
93322
+
93323
+ // ../core/dist/sleep.js
93324
+ async function sleep(param) {
93325
+ const sleepFn = globalThis[WORKFLOW_SLEEP];
93326
+ if (!sleepFn) {
93327
+ throwNotInWorkflowContext("sleep()", "https://workflow-sdk.dev/docs/api-reference/workflow/sleep", sleep);
93328
+ }
93329
+ return sleepFn(param);
93330
+ }
93331
+ __name(sleep, "sleep");
93332
+
93333
+ // ../core/dist/class-serialization.js
93334
+ function getRegistry(global = globalThis) {
93335
+ const g = global;
93336
+ let registry2 = g[WORKFLOW_CLASS_REGISTRY];
93337
+ if (!registry2) {
93338
+ registry2 = /* @__PURE__ */ new Map();
93339
+ g[WORKFLOW_CLASS_REGISTRY] = registry2;
93340
+ }
93341
+ return registry2;
93342
+ }
93343
+ __name(getRegistry, "getRegistry");
93344
+ var RUN_CLASS_ID = "class//workflow//Run";
93345
+ function aliasSerializationClass(classId, cls, global = globalThis) {
93346
+ getRegistry(global).set(classId, cls);
93347
+ }
93348
+ __name(aliasSerializationClass, "aliasSerializationClass");
93349
+
93350
+ // ../serde/dist/index.js
93351
+ var WORKFLOW_SERIALIZE = /* @__PURE__ */ Symbol.for("workflow-serialize");
93352
+ var WORKFLOW_DESERIALIZE = /* @__PURE__ */ Symbol.for("workflow-deserialize");
93353
+
93354
+ // ../core/dist/runtime/run.js
93355
+ var Run = class _Run {
93356
+ static {
93357
+ __name(this, "Run");
93358
+ }
93359
+ static [WORKFLOW_SERIALIZE](instance) {
93360
+ return {
93361
+ runId: instance.runId,
93362
+ resilientStart: instance.#resilientStart
93363
+ };
93364
+ }
93365
+ static [WORKFLOW_DESERIALIZE](data) {
93366
+ return new _Run(data.runId, {
93367
+ resilientStart: data.resilientStart
93368
+ });
93369
+ }
93370
+ /**
93371
+ * The ID of the workflow run.
93372
+ */
93373
+ runId;
93374
+ /**
93375
+ * When true, run_created failed and the run may not exist yet (the
93376
+ * resilient start path will create it via run_started). pollReturnValue
93377
+ * retries on WorkflowRunNotFoundError only when this flag is set so
93378
+ * that normal runs fail fast on 404.
93379
+ * @internal
93380
+ */
93381
+ #resilientStart = false;
93382
+ constructor(runId, opts) {
93383
+ this.runId = runId;
93384
+ this.#resilientStart = opts?.resilientStart ?? false;
93385
+ }
93386
+ /**
93387
+ * The readable stream of the workflow run.
93388
+ */
93389
+ get readable() {
93390
+ return this.getReadable();
93391
+ }
93392
+ };
93393
+ Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#wakeUp");
93394
+ Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#cancel");
93395
+ Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#getReadable");
93396
+ var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#exists");
93397
+ Object.defineProperty(Run.prototype, "exists", {
93398
+ get() {
93399
+ return __step_Run$exists.call(this);
93400
+ },
93401
+ configurable: true,
93402
+ enumerable: false
93403
+ });
93404
+ var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#status");
93405
+ Object.defineProperty(Run.prototype, "status", {
93406
+ get() {
93407
+ return __step_Run$status.call(this);
93408
+ },
93409
+ configurable: true,
93410
+ enumerable: false
93411
+ });
93412
+ var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#returnValue");
93413
+ Object.defineProperty(Run.prototype, "returnValue", {
93414
+ get() {
93415
+ return __step_Run$returnValue.call(this);
93416
+ },
93417
+ configurable: true,
93418
+ enumerable: false
93419
+ });
93420
+ var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#workflowName");
93421
+ Object.defineProperty(Run.prototype, "workflowName", {
93422
+ get() {
93423
+ return __step_Run$workflowName.call(this);
93424
+ },
93425
+ configurable: true,
93426
+ enumerable: false
93427
+ });
93428
+ var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#createdAt");
93429
+ Object.defineProperty(Run.prototype, "createdAt", {
93430
+ get() {
93431
+ return __step_Run$createdAt.call(this);
93432
+ },
93433
+ configurable: true,
93434
+ enumerable: false
93435
+ });
93436
+ var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#startedAt");
93437
+ Object.defineProperty(Run.prototype, "startedAt", {
93438
+ get() {
93439
+ return __step_Run$startedAt.call(this);
93440
+ },
93441
+ configurable: true,
93442
+ enumerable: false
93443
+ });
93444
+ var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.32//Run#completedAt");
93445
+ Object.defineProperty(Run.prototype, "completedAt", {
93446
+ get() {
93447
+ return __step_Run$completedAt.call(this);
93448
+ },
93449
+ configurable: true,
93450
+ enumerable: false
93451
+ });
93452
+ (function(__wf_cls, __wf_id) {
93453
+ var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
93454
+ __wf_reg.set(__wf_id, __wf_cls);
93455
+ Object.defineProperty(__wf_cls, "classId", {
93456
+ value: __wf_id,
93457
+ writable: false,
93458
+ enumerable: false,
93459
+ configurable: false
93460
+ });
93461
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.32//Run");
93462
+
93463
+ // ../core/dist/workflow/create-hook.js
93464
+ aliasSerializationClass(RUN_CLASS_ID, Run);
93465
+ function createHook(options) {
93466
+ const createHookFn = globalThis[WORKFLOW_CREATE_HOOK];
93467
+ if (!createHookFn) {
93468
+ throwNotInWorkflowContext("createHook()", "https://workflow-sdk.dev/docs/api-reference/workflow/create-hook", createHook);
93469
+ }
93470
+ return createHookFn(options);
93471
+ }
93472
+ __name(createHook, "createHook");
93473
+
93474
+ // ../core/dist/workflow/define-hook.js
93475
+ function defineHook() {
93476
+ function resume(_token, _payload) {
93477
+ throwUnavailableInWorkflowContext("defineHook().resume()", "https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook", resume);
93478
+ }
93479
+ __name(resume, "resume");
93480
+ return {
93481
+ create(options) {
93482
+ return createHook(options);
93483
+ },
93484
+ resume
93485
+ };
93486
+ }
93487
+ __name(defineHook, "defineHook");
93488
+
93249
93489
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
93250
93490
  var external_exports = {};
93251
93491
  __export(external_exports, {
@@ -108683,7 +108923,7 @@ var WorkflowRunBaseSchema = external_exports.object({
108683
108923
  errorCode: external_exports.string().optional(),
108684
108924
  /**
108685
108925
  * Plaintext string-string metadata attached to the run via
108686
- * \`experimental_setAttributes()\` (or, in the future, materialized
108926
+ * \`setAttributes()\` (or, in the future, materialized
108687
108927
  * from \`attr_set\` events). Stored unencrypted alongside other
108688
108928
  * plaintext fields so observability surfaces can read it without
108689
108929
  * going through the decryption pipeline.
@@ -109015,179 +109255,6 @@ var workflowRunIdSchema = external_exports.templateLiteral([
109015
109255
  var DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS = 24 * 60 * 60 * 1e3;
109016
109256
  var DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS = 5 * 60 * 1e3;
109017
109257
 
109018
- // ../core/dist/symbols.js
109019
- var WORKFLOW_CREATE_HOOK = /* @__PURE__ */ Symbol.for("WORKFLOW_CREATE_HOOK");
109020
- var WORKFLOW_SLEEP = /* @__PURE__ */ Symbol.for("WORKFLOW_SLEEP");
109021
- var WORKFLOW_GET_STREAM_ID = /* @__PURE__ */ Symbol.for("WORKFLOW_GET_STREAM_ID");
109022
- var STREAM_NAME_SYMBOL = /* @__PURE__ */ Symbol.for("WORKFLOW_STREAM_NAME");
109023
- var WORKFLOW_CLASS_REGISTRY = /* @__PURE__ */ Symbol.for("workflow-class-registry");
109024
-
109025
- // ../core/dist/sleep.js
109026
- async function sleep(param) {
109027
- const sleepFn = globalThis[WORKFLOW_SLEEP];
109028
- if (!sleepFn) {
109029
- throwNotInWorkflowContext("sleep()", "https://workflow-sdk.dev/docs/api-reference/workflow/sleep", sleep);
109030
- }
109031
- return sleepFn(param);
109032
- }
109033
- __name(sleep, "sleep");
109034
-
109035
- // ../core/dist/class-serialization.js
109036
- function getRegistry(global = globalThis) {
109037
- const g = global;
109038
- let registry2 = g[WORKFLOW_CLASS_REGISTRY];
109039
- if (!registry2) {
109040
- registry2 = /* @__PURE__ */ new Map();
109041
- g[WORKFLOW_CLASS_REGISTRY] = registry2;
109042
- }
109043
- return registry2;
109044
- }
109045
- __name(getRegistry, "getRegistry");
109046
- var RUN_CLASS_ID = "class//workflow//Run";
109047
- function aliasSerializationClass(classId, cls, global = globalThis) {
109048
- getRegistry(global).set(classId, cls);
109049
- }
109050
- __name(aliasSerializationClass, "aliasSerializationClass");
109051
-
109052
- // ../serde/dist/index.js
109053
- var WORKFLOW_SERIALIZE = /* @__PURE__ */ Symbol.for("workflow-serialize");
109054
- var WORKFLOW_DESERIALIZE = /* @__PURE__ */ Symbol.for("workflow-deserialize");
109055
-
109056
- // ../core/dist/runtime/run.js
109057
- var Run = class _Run {
109058
- static {
109059
- __name(this, "Run");
109060
- }
109061
- static [WORKFLOW_SERIALIZE](instance) {
109062
- return {
109063
- runId: instance.runId,
109064
- resilientStart: instance.#resilientStart
109065
- };
109066
- }
109067
- static [WORKFLOW_DESERIALIZE](data) {
109068
- return new _Run(data.runId, {
109069
- resilientStart: data.resilientStart
109070
- });
109071
- }
109072
- /**
109073
- * The ID of the workflow run.
109074
- */
109075
- runId;
109076
- /**
109077
- * When true, run_created failed and the run may not exist yet (the
109078
- * resilient start path will create it via run_started). pollReturnValue
109079
- * retries on WorkflowRunNotFoundError only when this flag is set so
109080
- * that normal runs fail fast on 404.
109081
- * @internal
109082
- */
109083
- #resilientStart = false;
109084
- constructor(runId, opts) {
109085
- this.runId = runId;
109086
- this.#resilientStart = opts?.resilientStart ?? false;
109087
- }
109088
- /**
109089
- * The readable stream of the workflow run.
109090
- */
109091
- get readable() {
109092
- return this.getReadable();
109093
- }
109094
- };
109095
- Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#wakeUp");
109096
- Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#cancel");
109097
- Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#getReadable");
109098
- var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#exists");
109099
- Object.defineProperty(Run.prototype, "exists", {
109100
- get() {
109101
- return __step_Run$exists.call(this);
109102
- },
109103
- configurable: true,
109104
- enumerable: false
109105
- });
109106
- var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#status");
109107
- Object.defineProperty(Run.prototype, "status", {
109108
- get() {
109109
- return __step_Run$status.call(this);
109110
- },
109111
- configurable: true,
109112
- enumerable: false
109113
- });
109114
- var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#returnValue");
109115
- Object.defineProperty(Run.prototype, "returnValue", {
109116
- get() {
109117
- return __step_Run$returnValue.call(this);
109118
- },
109119
- configurable: true,
109120
- enumerable: false
109121
- });
109122
- var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#workflowName");
109123
- Object.defineProperty(Run.prototype, "workflowName", {
109124
- get() {
109125
- return __step_Run$workflowName.call(this);
109126
- },
109127
- configurable: true,
109128
- enumerable: false
109129
- });
109130
- var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#createdAt");
109131
- Object.defineProperty(Run.prototype, "createdAt", {
109132
- get() {
109133
- return __step_Run$createdAt.call(this);
109134
- },
109135
- configurable: true,
109136
- enumerable: false
109137
- });
109138
- var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#startedAt");
109139
- Object.defineProperty(Run.prototype, "startedAt", {
109140
- get() {
109141
- return __step_Run$startedAt.call(this);
109142
- },
109143
- configurable: true,
109144
- enumerable: false
109145
- });
109146
- var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.30//Run#completedAt");
109147
- Object.defineProperty(Run.prototype, "completedAt", {
109148
- get() {
109149
- return __step_Run$completedAt.call(this);
109150
- },
109151
- configurable: true,
109152
- enumerable: false
109153
- });
109154
- (function(__wf_cls, __wf_id) {
109155
- var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
109156
- __wf_reg.set(__wf_id, __wf_cls);
109157
- Object.defineProperty(__wf_cls, "classId", {
109158
- value: __wf_id,
109159
- writable: false,
109160
- enumerable: false,
109161
- configurable: false
109162
- });
109163
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.30//Run");
109164
-
109165
- // ../core/dist/workflow/create-hook.js
109166
- aliasSerializationClass(RUN_CLASS_ID, Run);
109167
- function createHook(options) {
109168
- const createHookFn = globalThis[WORKFLOW_CREATE_HOOK];
109169
- if (!createHookFn) {
109170
- throwNotInWorkflowContext("createHook()", "https://workflow-sdk.dev/docs/api-reference/workflow/create-hook", createHook);
109171
- }
109172
- return createHookFn(options);
109173
- }
109174
- __name(createHook, "createHook");
109175
-
109176
- // ../core/dist/workflow/define-hook.js
109177
- function defineHook() {
109178
- function resume(_token, _payload) {
109179
- throwUnavailableInWorkflowContext("defineHook().resume()", "https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook", resume);
109180
- }
109181
- __name(resume, "resume");
109182
- return {
109183
- create(options) {
109184
- return createHook(options);
109185
- },
109186
- resume
109187
- };
109188
- }
109189
- __name(defineHook, "defineHook");
109190
-
109191
109258
  // ../core/dist/workflow/writable-stream.js
109192
109259
  function getWritable(options = {}) {
109193
109260
  const { namespace } = options;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
- "workflows/null-byte.ts": {
5
- "nullByteStep": {
6
- "stepId": "step//./workflows/null-byte//nullByteStep"
4
+ "workflows/signal-cost.ts": {
5
+ "trivialStep": {
6
+ "stepId": "step//./workflows/signal-cost//trivialStep"
7
7
  }
8
8
  },
9
9
  "workflows/addition.ts": {
@@ -24,9 +24,20 @@
24
24
  "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
25
25
  }
26
26
  },
27
- "workflows/signal-cost.ts": {
28
- "trivialStep": {
29
- "stepId": "step//./workflows/signal-cost//trivialStep"
27
+ "workflows/null-byte.ts": {
28
+ "nullByteStep": {
29
+ "stepId": "step//./workflows/null-byte//nullByteStep"
30
+ }
31
+ },
32
+ "workflows/inline-execution.ts": {
33
+ "add": {
34
+ "stepId": "step//./workflows/inline-execution//add"
35
+ },
36
+ "closeOutputStream": {
37
+ "stepId": "step//./workflows/inline-execution//closeOutputStream"
38
+ },
39
+ "writeToStream": {
40
+ "stepId": "step//./workflows/inline-execution//writeToStream"
30
41
  }
31
42
  },
32
43
  "workflow/dist/stdlib.js": {
@@ -39,11 +50,6 @@
39
50
  "stepId": "step//./workflows/noop//noop"
40
51
  }
41
52
  },
42
- "core/dist/runtime/start.js": {
43
- "start": {
44
- "stepId": "step//@workflow/core/runtime/start@5.0.0-beta.30//start"
45
- }
46
- },
47
53
  "workflow/dist/internal/builtins.js": {
48
54
  "__builtin_response_array_buffer": {
49
55
  "stepId": "__builtin_response_array_buffer"
@@ -58,61 +64,55 @@
58
64
  "stepId": "__builtin_set_attributes"
59
65
  }
60
66
  },
61
- "workflows/inline-execution.ts": {
62
- "add": {
63
- "stepId": "step//./workflows/inline-execution//add"
64
- },
65
- "closeOutputStream": {
66
- "stepId": "step//./workflows/inline-execution//closeOutputStream"
67
- },
68
- "writeToStream": {
69
- "stepId": "step//./workflows/inline-execution//writeToStream"
67
+ "core/dist/runtime/start.js": {
68
+ "start": {
69
+ "stepId": "step//@workflow/core/runtime/start@5.0.0-beta.32//start"
70
70
  }
71
71
  },
72
72
  "core/dist/runtime/run.js": {
73
73
  "Run#cancel": {
74
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#cancel"
74
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#cancel"
75
75
  },
76
76
  "Run#completedAt": {
77
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#completedAt"
77
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#completedAt"
78
78
  },
79
79
  "Run#createdAt": {
80
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#createdAt"
80
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#createdAt"
81
81
  },
82
82
  "Run#exists": {
83
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#exists"
83
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#exists"
84
84
  },
85
85
  "Run#getReadable": {
86
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#getReadable"
86
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#getReadable"
87
87
  },
88
88
  "Run#returnValue": {
89
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#returnValue"
89
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#returnValue"
90
90
  },
91
91
  "Run#startedAt": {
92
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#startedAt"
92
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#startedAt"
93
93
  },
94
94
  "Run#status": {
95
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#status"
95
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#status"
96
96
  },
97
97
  "Run#wakeUp": {
98
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#wakeUp"
98
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#wakeUp"
99
99
  },
100
100
  "Run#workflowName": {
101
- "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#workflowName"
101
+ "stepId": "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#workflowName"
102
102
  }
103
103
  }
104
104
  },
105
105
  "workflows": {
106
- "workflows/null-byte.ts": {
107
- "nullByteWorkflow": {
108
- "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
106
+ "workflows/signal-cost.ts": {
107
+ "signalCostWorkflow": {
108
+ "workflowId": "workflow//./workflows/signal-cost//signalCostWorkflow",
109
109
  "graph": {
110
110
  "nodes": [
111
111
  {
112
112
  "id": "start",
113
113
  "type": "workflowStart",
114
114
  "data": {
115
- "label": "Start: nullByteWorkflow",
115
+ "label": "Start: signalCostWorkflow",
116
116
  "nodeKind": "workflow_start"
117
117
  }
118
118
  },
@@ -120,9 +120,12 @@
120
120
  "id": "node_0",
121
121
  "type": "step",
122
122
  "data": {
123
- "label": "nullByteStep",
123
+ "label": "trivialStep",
124
124
  "nodeKind": "step",
125
- "stepId": "step//./workflows/null-byte//nullByteStep"
125
+ "stepId": "step//./workflows/signal-cost//trivialStep"
126
+ },
127
+ "metadata": {
128
+ "loopId": "loop_0"
126
129
  }
127
130
  },
128
131
  {
@@ -135,6 +138,12 @@
135
138
  }
136
139
  ],
137
140
  "edges": [
141
+ {
142
+ "id": "e_node_0_back_node_0",
143
+ "source": "node_0",
144
+ "target": "node_0",
145
+ "type": "loop"
146
+ },
138
147
  {
139
148
  "id": "e_start_node_0",
140
149
  "source": "start",
@@ -396,16 +405,16 @@
396
405
  }
397
406
  }
398
407
  },
399
- "workflows/signal-cost.ts": {
400
- "signalCostWorkflow": {
401
- "workflowId": "workflow//./workflows/signal-cost//signalCostWorkflow",
408
+ "workflows/null-byte.ts": {
409
+ "nullByteWorkflow": {
410
+ "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
402
411
  "graph": {
403
412
  "nodes": [
404
413
  {
405
414
  "id": "start",
406
415
  "type": "workflowStart",
407
416
  "data": {
408
- "label": "Start: signalCostWorkflow",
417
+ "label": "Start: nullByteWorkflow",
409
418
  "nodeKind": "workflow_start"
410
419
  }
411
420
  },
@@ -413,12 +422,9 @@
413
422
  "id": "node_0",
414
423
  "type": "step",
415
424
  "data": {
416
- "label": "trivialStep",
425
+ "label": "nullByteStep",
417
426
  "nodeKind": "step",
418
- "stepId": "step//./workflows/signal-cost//trivialStep"
419
- },
420
- "metadata": {
421
- "loopId": "loop_0"
427
+ "stepId": "step//./workflows/null-byte//nullByteStep"
422
428
  }
423
429
  },
424
430
  {
@@ -431,12 +437,6 @@
431
437
  }
432
438
  ],
433
439
  "edges": [
434
- {
435
- "id": "e_node_0_back_node_0",
436
- "source": "node_0",
437
- "target": "node_0",
438
- "type": "loop"
439
- },
440
440
  {
441
441
  "id": "e_start_node_0",
442
442
  "source": "start",
@@ -453,69 +453,6 @@
453
453
  }
454
454
  }
455
455
  },
456
- "workflows/noop.ts": {
457
- "brokenWf": {
458
- "workflowId": "workflow//./workflows/noop//brokenWf",
459
- "graph": {
460
- "nodes": [
461
- {
462
- "id": "start",
463
- "type": "workflowStart",
464
- "data": {
465
- "label": "Start: brokenWf",
466
- "nodeKind": "workflow_start"
467
- }
468
- },
469
- {
470
- "id": "node_0",
471
- "type": "step",
472
- "data": {
473
- "label": "noop",
474
- "nodeKind": "step",
475
- "stepId": "step//./workflows/noop//noop"
476
- }
477
- },
478
- {
479
- "id": "node_1",
480
- "type": "step",
481
- "data": {
482
- "label": "noop",
483
- "nodeKind": "step",
484
- "stepId": "step//./workflows/noop//noop"
485
- }
486
- },
487
- {
488
- "id": "end",
489
- "type": "workflowEnd",
490
- "data": {
491
- "label": "Return",
492
- "nodeKind": "workflow_end"
493
- }
494
- }
495
- ],
496
- "edges": [
497
- {
498
- "id": "e_start_node_0",
499
- "source": "start",
500
- "target": "node_0",
501
- "type": "default"
502
- },
503
- {
504
- "id": "e_node_0_node_1",
505
- "source": "node_0",
506
- "target": "node_1",
507
- "type": "default"
508
- },
509
- {
510
- "id": "e_node_1_end",
511
- "source": "node_1",
512
- "target": "end",
513
- "type": "default"
514
- }
515
- ]
516
- }
517
- }
518
- },
519
456
  "workflows/inline-execution.ts": {
520
457
  "hookWorkflow": {
521
458
  "workflowId": "workflow//./workflows/inline-execution//hookWorkflow",
@@ -1415,12 +1352,75 @@
1415
1352
  ]
1416
1353
  }
1417
1354
  }
1355
+ },
1356
+ "workflows/noop.ts": {
1357
+ "brokenWf": {
1358
+ "workflowId": "workflow//./workflows/noop//brokenWf",
1359
+ "graph": {
1360
+ "nodes": [
1361
+ {
1362
+ "id": "start",
1363
+ "type": "workflowStart",
1364
+ "data": {
1365
+ "label": "Start: brokenWf",
1366
+ "nodeKind": "workflow_start"
1367
+ }
1368
+ },
1369
+ {
1370
+ "id": "node_0",
1371
+ "type": "step",
1372
+ "data": {
1373
+ "label": "noop",
1374
+ "nodeKind": "step",
1375
+ "stepId": "step//./workflows/noop//noop"
1376
+ }
1377
+ },
1378
+ {
1379
+ "id": "node_1",
1380
+ "type": "step",
1381
+ "data": {
1382
+ "label": "noop",
1383
+ "nodeKind": "step",
1384
+ "stepId": "step//./workflows/noop//noop"
1385
+ }
1386
+ },
1387
+ {
1388
+ "id": "end",
1389
+ "type": "workflowEnd",
1390
+ "data": {
1391
+ "label": "Return",
1392
+ "nodeKind": "workflow_end"
1393
+ }
1394
+ }
1395
+ ],
1396
+ "edges": [
1397
+ {
1398
+ "id": "e_start_node_0",
1399
+ "source": "start",
1400
+ "target": "node_0",
1401
+ "type": "default"
1402
+ },
1403
+ {
1404
+ "id": "e_node_0_node_1",
1405
+ "source": "node_0",
1406
+ "target": "node_1",
1407
+ "type": "default"
1408
+ },
1409
+ {
1410
+ "id": "e_node_1_end",
1411
+ "source": "node_1",
1412
+ "target": "end",
1413
+ "type": "default"
1414
+ }
1415
+ ]
1416
+ }
1417
+ }
1418
1418
  }
1419
1419
  },
1420
1420
  "classes": {
1421
1421
  "core/dist/runtime/run.js": {
1422
1422
  "Run": {
1423
- "classId": "class//@workflow/core/runtime/run@5.0.0-beta.30//Run"
1423
+ "classId": "class//@workflow/core/runtime/run@5.0.0-beta.32//Run"
1424
1424
  }
1425
1425
  }
1426
1426
  }
@@ -16934,7 +16934,7 @@ var init_runs = __esm({
16934
16934
  errorCode: external_exports.string().optional(),
16935
16935
  /**
16936
16936
  * Plaintext string-string metadata attached to the run via
16937
- * `experimental_setAttributes()` (or, in the future, materialized
16937
+ * `setAttributes()` (or, in the future, materialized
16938
16938
  * from `attr_set` events). Stored unencrypted alongside other
16939
16939
  * plaintext fields so observability surfaces can read it without
16940
16940
  * going through the decryption pipeline.
@@ -17345,6 +17345,7 @@ var init_queue = __esm({
17345
17345
  var init_recovery = __esm({
17346
17346
  "../world/dist/recovery.js"() {
17347
17347
  "use strict";
17348
+ init_queue();
17348
17349
  }
17349
17350
  });
17350
17351
 
@@ -24373,7 +24374,7 @@ var version2;
24373
24374
  var init_version = __esm({
24374
24375
  "../core/dist/version.js"() {
24375
24376
  "use strict";
24376
- version2 = "5.0.0-beta.30";
24377
+ version2 = "5.0.0-beta.32";
24377
24378
  }
24378
24379
  });
24379
24380
 
@@ -26219,6 +26220,21 @@ function createReconnectingFramedStream(runId, name, startIndex) {
26219
26220
  }, "cancel")
26220
26221
  });
26221
26222
  }
26223
+ function recordStreamWriteFlush(startEpochMs, dispatchEpochMs, runId, name, chunkCount, byteCount) {
26224
+ void (async () => {
26225
+ await recordElapsedSpan("workflow.stream.flush", startEpochMs, {
26226
+ kind: await getSpanKind("CLIENT"),
26227
+ attributes: {
26228
+ "workflow.run.id": runId,
26229
+ "workflow.stream.name": name,
26230
+ "workflow.stream.operation": "flush",
26231
+ "workflow.stream.flush.buffer_dwell_ms": dispatchEpochMs - startEpochMs,
26232
+ "workflow.stream.flush.chunks": chunkCount,
26233
+ "workflow.stream.flush.bytes": byteCount
26234
+ }
26235
+ });
26236
+ })();
26237
+ }
26222
26238
  function getAllBaseReducers(global2 = globalThis) {
26223
26239
  return {
26224
26240
  ...getClassReducers(),
@@ -27146,6 +27162,7 @@ var init_serialization2 = __esm({
27146
27162
  getStreamFlushIntervalMs = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS, {
27147
27163
  integer: true
27148
27164
  }), "getStreamFlushIntervalMs");
27165
+ __name(recordStreamWriteFlush, "recordStreamWriteFlush");
27149
27166
  WorkflowServerWritableStream = class extends WritableStream {
27150
27167
  static {
27151
27168
  __name(this, "WorkflowServerWritableStream");
@@ -27181,6 +27198,7 @@ var init_serialization2 = __esm({
27181
27198
  let flushTimer = null;
27182
27199
  let flushPromise = null;
27183
27200
  let resolvedFlushIntervalMs;
27201
+ let batchStartAt;
27184
27202
  const flush = /* @__PURE__ */ __name(async () => {
27185
27203
  if (flushTimer) {
27186
27204
  clearTimeout(flushTimer);
@@ -27189,16 +27207,29 @@ var init_serialization2 = __esm({
27189
27207
  if (buffer2.length === 0) return;
27190
27208
  await ensureRunReady();
27191
27209
  const chunksToFlush = buffer2.slice();
27210
+ const batchStart = batchStartAt;
27211
+ batchStartAt = void 0;
27212
+ const dispatchAt = Date.now();
27192
27213
  const world = await worldPromise;
27193
27214
  if (resolvedFlushIntervalMs === void 0) {
27194
27215
  resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs();
27195
27216
  }
27196
- if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27197
- await world.streams.writeMulti(runId, name, chunksToFlush);
27198
- } else {
27199
- for (const chunk of chunksToFlush) {
27200
- await world.streams.write(runId, name, chunk);
27217
+ try {
27218
+ if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27219
+ await world.streams.writeMulti(runId, name, chunksToFlush);
27220
+ } else {
27221
+ for (const chunk of chunksToFlush) {
27222
+ await world.streams.write(runId, name, chunk);
27223
+ }
27224
+ }
27225
+ } catch (error48) {
27226
+ if (batchStart !== void 0) {
27227
+ batchStartAt = batchStartAt === void 0 ? batchStart : Math.min(batchStartAt, batchStart);
27201
27228
  }
27229
+ throw error48;
27230
+ }
27231
+ if (batchStart !== void 0) {
27232
+ recordStreamWriteFlush(batchStart, dispatchAt, runId, name, chunksToFlush.length, chunksToFlush.reduce((sum, c) => sum + c.byteLength, 0));
27202
27233
  }
27203
27234
  buffer2 = [];
27204
27235
  }, "flush");
@@ -27218,6 +27249,7 @@ var init_serialization2 = __esm({
27218
27249
  }, "scheduleFlush");
27219
27250
  super({
27220
27251
  async write(chunk) {
27252
+ if (batchStartAt === void 0) batchStartAt = Date.now();
27221
27253
  if (flushPromise) {
27222
27254
  await flushPromise;
27223
27255
  flushPromise = null;
@@ -27412,7 +27444,7 @@ init_dist2();
27412
27444
  init_dist4();
27413
27445
  function normalizeAttributeChanges(attrs, options = {}) {
27414
27446
  if (attrs === null || typeof attrs !== "object" || Array.isArray(attrs)) {
27415
- throw new FatalError(`experimental_setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
27447
+ throw new FatalError(`setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
27416
27448
  }
27417
27449
  const changes = Object.entries(attrs).map(([key, value]) => ({
27418
27450
  key,
@@ -27678,7 +27710,7 @@ __name(start, "start");
27678
27710
  value: "start",
27679
27711
  configurable: true
27680
27712
  });
27681
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.30//start");
27713
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.32//start");
27682
27714
 
27683
27715
  // ../core/dist/runtime/runs.js
27684
27716
  async function wakeUpRun(world, runId, options) {
@@ -28014,7 +28046,7 @@ var Run = class _Run {
28014
28046
  value: "wakeUp",
28015
28047
  configurable: true
28016
28048
  });
28017
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#wakeUp");
28049
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#wakeUp");
28018
28050
  (function(__wf_fn, __wf_id) {
28019
28051
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28020
28052
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28023,7 +28055,7 @@ var Run = class _Run {
28023
28055
  value: "cancel",
28024
28056
  configurable: true
28025
28057
  });
28026
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#cancel");
28058
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#cancel");
28027
28059
  (function(__wf_fn, __wf_id) {
28028
28060
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28029
28061
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28032,7 +28064,7 @@ var Run = class _Run {
28032
28064
  value: "getReadable",
28033
28065
  configurable: true
28034
28066
  });
28035
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#getReadable");
28067
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#getReadable");
28036
28068
  (function(__wf_fn, __wf_id) {
28037
28069
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28038
28070
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28041,7 +28073,7 @@ var Run = class _Run {
28041
28073
  value: "exists",
28042
28074
  configurable: true
28043
28075
  });
28044
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#exists");
28076
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#exists");
28045
28077
  (function(__wf_fn, __wf_id) {
28046
28078
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28047
28079
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28050,7 +28082,7 @@ var Run = class _Run {
28050
28082
  value: "status",
28051
28083
  configurable: true
28052
28084
  });
28053
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#status");
28085
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#status");
28054
28086
  (function(__wf_fn, __wf_id) {
28055
28087
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28056
28088
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28059,7 +28091,7 @@ var Run = class _Run {
28059
28091
  value: "returnValue",
28060
28092
  configurable: true
28061
28093
  });
28062
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#returnValue");
28094
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#returnValue");
28063
28095
  (function(__wf_fn, __wf_id) {
28064
28096
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28065
28097
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28068,7 +28100,7 @@ var Run = class _Run {
28068
28100
  value: "workflowName",
28069
28101
  configurable: true
28070
28102
  });
28071
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#workflowName");
28103
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#workflowName");
28072
28104
  (function(__wf_fn, __wf_id) {
28073
28105
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28074
28106
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28077,7 +28109,7 @@ var Run = class _Run {
28077
28109
  value: "createdAt",
28078
28110
  configurable: true
28079
28111
  });
28080
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#createdAt");
28112
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#createdAt");
28081
28113
  (function(__wf_fn, __wf_id) {
28082
28114
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28083
28115
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28086,7 +28118,7 @@ var Run = class _Run {
28086
28118
  value: "startedAt",
28087
28119
  configurable: true
28088
28120
  });
28089
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#startedAt");
28121
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#startedAt");
28090
28122
  (function(__wf_fn, __wf_id) {
28091
28123
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28092
28124
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28095,7 +28127,7 @@ var Run = class _Run {
28095
28127
  value: "completedAt",
28096
28128
  configurable: true
28097
28129
  });
28098
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.30//Run#completedAt");
28130
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#completedAt");
28099
28131
  (function(__wf_cls, __wf_id) {
28100
28132
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28101
28133
  __wf_reg.set(__wf_id, __wf_cls);
@@ -28105,7 +28137,7 @@ var Run = class _Run {
28105
28137
  enumerable: false,
28106
28138
  configurable: false
28107
28139
  });
28108
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.30//Run");
28140
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.32//Run");
28109
28141
 
28110
28142
  // ../workflow/dist/stdlib.js
28111
28143
  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.30",
3
+ "version": "5.0.0-beta.32",
4
4
  "description": "Testing utilities and World implementation for Workflow SDK",
5
5
  "main": "dist/src/index.mjs",
6
6
  "files": [
@@ -21,12 +21,12 @@
21
21
  "hono": "4.12.25",
22
22
  "jsonlines": "0.1.1",
23
23
  "zod": "~4.3.6",
24
- "@workflow/cli": "5.0.0-beta.30",
25
- "@workflow/core": "5.0.0-beta.30",
24
+ "@workflow/cli": "5.0.0-beta.32",
25
+ "@workflow/core": "5.0.0-beta.32",
26
26
  "@workflow/utils": "5.0.0-beta.6",
27
- "@workflow/world": "5.0.0-beta.18",
28
- "@workflow/world-local": "5.0.0-beta.26",
29
- "workflow": "5.0.0-beta.30"
27
+ "@workflow/world": "5.0.0-beta.19",
28
+ "@workflow/world-local": "5.0.0-beta.27",
29
+ "workflow": "5.0.0-beta.32"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jsonlines": "0.1.5",