@workflow/web 5.0.0-beta.43 → 5.0.0-beta.46

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.
Files changed (23) hide show
  1. package/build/client/assets/{arrow-up-right-D39pnGsD.js → arrow-up-right-UOc2WcaC.js} +1 -1
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-Dc1dLaUr.js → highlighted-body-B3W2YXNL-D78gcP7S.js} +1 -1
  3. package/build/client/assets/{home-C6CuMqQu.js → home-DYB1uz9w.js} +3 -3
  4. package/build/client/assets/{loader-circle-BOxaTUjK.js → loader-circle-oscnpy3L.js} +1 -1
  5. package/build/client/assets/{manifest-157e28f1.js → manifest-a701502a.js} +1 -1
  6. package/build/client/assets/{mermaid-3ZIDBTTL-gEw-Ch1C.js → mermaid-3ZIDBTTL-BKGEyEYb.js} +463 -334
  7. package/build/client/assets/{root-BfhMCbkz.js → root-Zvnb602n.js} +3 -3
  8. package/build/client/assets/{run-detail-BG_1K2Hq.js → run-detail-CedyZW9h.js} +54 -31
  9. package/build/client/assets/{workflow-graph-viewer-CxrWityD.js → workflow-graph-viewer-Du0ztkb8.js} +1 -1
  10. package/build/client/assets/{zstd-browser-decoder-CAEVa0bm.js → zstd-browser-decoder-DafWVuEG.js} +1 -1
  11. package/build/server/assets/{app-_xgEuKqE.js → app-BpmEMaiu.js} +1162 -852
  12. package/build/server/assets/{highlighted-body-B3W2YXNL-B1Smd86a.js → highlighted-body-B3W2YXNL-C6ES2Pzm.js} +1 -1
  13. package/build/server/assets/{index-CSsrecUx.js → index-BtQfiVUN.js} +75 -73
  14. package/build/server/assets/{index-Ck5CB_wQ.js → index-QOlZC9D-.js} +1 -1
  15. package/build/server/assets/{mermaid-3ZIDBTTL-CwYR558N.js → mermaid-3ZIDBTTL-X6IEJ8gj.js} +1 -1
  16. package/build/server/assets/{token-COK7oHMh.js → token-CrxXUTBD.js} +1 -1
  17. package/build/server/assets/{token-util-BhmVdeCX.js → token-util-DuToe55u.js} +1 -1
  18. package/build/server/assets/{websocket-server-ByjlHAhQ.js → websocket-server-CTnzV_B7.js} +1 -1
  19. package/build/server/assets/{wrapper-DWeVTope.js → wrapper-Bjff6YRz.js} +3 -3
  20. package/build/server/assets/{ws-transport-BCfcEhAO.js → ws-transport-ByYax88V.js} +40 -22
  21. package/build/server/assets/{zstd-browser-decoder-D8JD_nwS.js → zstd-browser-decoder-Bfk1d5vU.js} +1 -1
  22. package/build/server/index.js +3 -3
  23. package/package.json +8 -8
@@ -16912,9 +16912,9 @@ function requireReactDomServer_node_production() {
16912
16912
  function unsupportedSetOptimisticState() {
16913
16913
  throw Error("Cannot update optimistic state while rendering.");
16914
16914
  }
16915
- function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
16915
+ function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex2) {
16916
16916
  if (void 0 !== permalink) return "p" + permalink;
16917
- permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
16917
+ permalink = JSON.stringify([componentKeyPath, null, hookIndex2]);
16918
16918
  componentKeyPath = crypto2.createHash("md5");
16919
16919
  componentKeyPath.update(permalink);
16920
16920
  return "k" + componentKeyPath.digest("hex");
@@ -28574,9 +28574,9 @@ function requireReactDomServer_node_development() {
28574
28574
  function unsupportedSetOptimisticState() {
28575
28575
  throw Error("Cannot update optimistic state while rendering.");
28576
28576
  }
28577
- function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
28577
+ function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex2) {
28578
28578
  if (void 0 !== permalink) return "p" + permalink;
28579
- permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
28579
+ permalink = JSON.stringify([componentKeyPath, null, hookIndex2]);
28580
28580
  componentKeyPath = crypto2.createHash("md5");
28581
28581
  componentKeyPath.update(permalink);
28582
28582
  return "k" + componentKeyPath.digest("hex");
@@ -44191,7 +44191,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
44191
44191
  const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
44192
44192
  const cuid$1 = /^[cC][^\s-]{8,}$/;
44193
44193
  const cuid2$1 = /^[0-9a-z]+$/;
44194
- const ulid$5 = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
44194
+ const ulid$3 = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
44195
44195
  const xid$1 = /^[0-9a-vA-V]{20}$/;
44196
44196
  const ksuid$1 = /^[A-Za-z0-9]{27}$/;
44197
44197
  const nanoid$1 = /^[a-zA-Z0-9_-]{21}$/;
@@ -44334,7 +44334,7 @@ const regexes = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
44334
44334
  sha512_hex,
44335
44335
  string: string$4,
44336
44336
  time: time$1,
44337
- ulid: ulid$5,
44337
+ ulid: ulid$3,
44338
44338
  undefined: _undefined$2,
44339
44339
  unicodeEmail,
44340
44340
  uppercase,
@@ -45165,7 +45165,7 @@ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
45165
45165
  $ZodStringFormat.init(inst, def);
45166
45166
  });
45167
45167
  const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
45168
- def.pattern ?? (def.pattern = ulid$5);
45168
+ def.pattern ?? (def.pattern = ulid$3);
45169
45169
  $ZodStringFormat.init(inst, def);
45170
45170
  });
45171
45171
  const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
@@ -55086,7 +55086,7 @@ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
55086
55086
  $ZodULID.init(inst, def);
55087
55087
  ZodStringFormat.init(inst, def);
55088
55088
  });
55089
- function ulid$4(params) {
55089
+ function ulid$2(params) {
55090
55090
  return /* @__PURE__ */ _ulid(ZodULID, params);
55091
55091
  }
55092
55092
  const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
@@ -56096,7 +56096,7 @@ const _schemas = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
56096
56096
  tuple,
56097
56097
  uint32,
56098
56098
  uint64,
56099
- ulid: ulid$4,
56099
+ ulid: ulid$2,
56100
56100
  undefined: _undefined,
56101
56101
  union,
56102
56102
  unknown: unknown$1,
@@ -56855,7 +56855,7 @@ const z$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty(
56855
56855
  tuple,
56856
56856
  uint32,
56857
56857
  uint64,
56858
- ulid: ulid$4,
56858
+ ulid: ulid$2,
56859
56859
  undefined: _undefined,
56860
56860
  union,
56861
56861
  unknown: unknown$1,
@@ -56876,76 +56876,64 @@ const PARENT_RUN_ID_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}parentRunId`;
56876
56876
  const ATTRIBUTE_KEY_MAX_LENGTH = 256;
56877
56877
  const ATTRIBUTE_VALUE_MAX_BYTES = 256;
56878
56878
  const ATTRIBUTE_MAX_PER_RUN = 64;
56879
- const AttributeChangeSchema = object$1({
56880
- key: string$3(),
56881
- value: union([string$3(), _null()])
56882
- });
56883
- const AttributeChangesSchema = array$1(AttributeChangeSchema);
56879
+ const textEncoder$2 = new TextEncoder();
56884
56880
  class AttributeValidationError extends Error {
56885
56881
  constructor(message2) {
56886
56882
  super(message2);
56887
56883
  this.name = "AttributeValidationError";
56888
56884
  }
56889
56885
  }
56890
- const valueByteLength = (value) => new TextEncoder().encode(value).length;
56891
- function validateAttributeKey(key, options = {}) {
56886
+ function assertValidAttributeKey(key, allowReservedAttributes) {
56892
56887
  if (typeof key !== "string") {
56893
- return new AttributeValidationError(`Attribute key must be a string, got ${typeof key}`);
56888
+ throw new AttributeValidationError(`Attribute key must be a string, got ${typeof key}`);
56894
56889
  }
56895
56890
  if (key.length === 0) {
56896
- return new AttributeValidationError("Attribute key must not be empty");
56891
+ throw new AttributeValidationError("Attribute key must not be empty");
56897
56892
  }
56898
56893
  if (key.length > ATTRIBUTE_KEY_MAX_LENGTH) {
56899
- return new AttributeValidationError(`Attribute key length ${key.length} exceeds limit ${ATTRIBUTE_KEY_MAX_LENGTH}: ${JSON.stringify(key.slice(0, 32))}…`);
56894
+ throw new AttributeValidationError(`Attribute key length ${key.length} exceeds limit ${ATTRIBUTE_KEY_MAX_LENGTH}: ${JSON.stringify(key.slice(0, 32))}…`);
56900
56895
  }
56901
- if (!options.allowReservedAttributes && key.startsWith(RESERVED_ATTRIBUTE_KEY_PREFIX)) {
56902
- return new AttributeValidationError(`Attribute key ${JSON.stringify(key)} starts with reserved prefix "${RESERVED_ATTRIBUTE_KEY_PREFIX}" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`);
56896
+ if (!allowReservedAttributes && key.startsWith(RESERVED_ATTRIBUTE_KEY_PREFIX)) {
56897
+ throw new AttributeValidationError(`Attribute key ${JSON.stringify(key)} starts with reserved prefix "${RESERVED_ATTRIBUTE_KEY_PREFIX}" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`);
56903
56898
  }
56904
- return null;
56905
56899
  }
56906
- function validateAttributeValue(value) {
56907
- if (value === null)
56908
- return null;
56909
- if (typeof value !== "string") {
56910
- return new AttributeValidationError(`Attribute value must be a string or null, got ${typeof value}`);
56900
+ function assertValidAttributeValue(value) {
56901
+ if (value !== null && typeof value !== "string") {
56902
+ throw new AttributeValidationError(`Attribute value must be a string or null, got ${typeof value}`);
56911
56903
  }
56912
- const bytes = valueByteLength(value);
56904
+ if (value === null)
56905
+ return;
56906
+ const bytes = textEncoder$2.encode(value).length;
56913
56907
  if (bytes > ATTRIBUTE_VALUE_MAX_BYTES) {
56914
- return new AttributeValidationError(`Attribute value byte length ${bytes} exceeds limit ${ATTRIBUTE_VALUE_MAX_BYTES}`);
56908
+ throw new AttributeValidationError(`Attribute value byte length ${bytes} exceeds limit ${ATTRIBUTE_VALUE_MAX_BYTES}`);
56915
56909
  }
56916
- return null;
56917
56910
  }
56918
- function validateAttributeChanges(changes, context = {}) {
56911
+ function attributeCountDelta(key, value, existingKeys) {
56912
+ if (value === null)
56913
+ return (existingKeys == null ? void 0 : existingKeys.has(key)) ? -1 : 0;
56914
+ return existingKeys === void 0 || !existingKeys.has(key) ? 1 : 0;
56915
+ }
56916
+ function validateAttributeBatchConstraints(changes, context = {}) {
56919
56917
  const seenKeys = /* @__PURE__ */ new Set();
56920
56918
  const existingKeys = context.existingKeys === void 0 ? void 0 : context.existingKeys instanceof Set ? context.existingKeys : new Set(context.existingKeys);
56921
- let netAdds = 0;
56922
- let netDeletes = 0;
56923
- for (const change of changes) {
56924
- const keyError = validateAttributeKey(change.key, {
56925
- allowReservedAttributes: context.allowReservedAttributes
56926
- });
56927
- if (keyError)
56928
- throw keyError;
56929
- const valueError = validateAttributeValue(change.value);
56930
- if (valueError)
56931
- throw valueError;
56932
- if (seenKeys.has(change.key)) {
56933
- throw new AttributeValidationError(`Attribute key ${JSON.stringify(change.key)} appears more than once in the same batch`);
56934
- }
56935
- seenKeys.add(change.key);
56936
- if (change.value !== null) {
56937
- if (existingKeys === void 0 || !existingKeys.has(change.key)) {
56938
- netAdds += 1;
56939
- }
56940
- } else if (existingKeys === void 0 || existingKeys.has(change.key)) {
56941
- netDeletes += 1;
56919
+ let postMergeCount = (existingKeys == null ? void 0 : existingKeys.size) ?? 0;
56920
+ for (const { key, value } of changes) {
56921
+ if (seenKeys.has(key)) {
56922
+ throw new AttributeValidationError(`Attribute key ${JSON.stringify(key)} appears more than once in the same batch`);
56942
56923
  }
56924
+ seenKeys.add(key);
56925
+ postMergeCount += attributeCountDelta(key, value, existingKeys);
56926
+ }
56927
+ if (postMergeCount > ATTRIBUTE_MAX_PER_RUN) {
56928
+ throw new AttributeValidationError(`Run attribute count would exceed limit ${ATTRIBUTE_MAX_PER_RUN} (post-merge ${postMergeCount})`);
56943
56929
  }
56944
- const existing = existingKeys === void 0 ? 0 : existingKeys.size;
56945
- const postMerge = existing + netAdds - netDeletes;
56946
- if (postMerge > ATTRIBUTE_MAX_PER_RUN) {
56947
- throw new AttributeValidationError(`Run attribute count would exceed limit ${ATTRIBUTE_MAX_PER_RUN} (post-merge ${postMerge})`);
56930
+ }
56931
+ function validateAttributeChanges(changes, context = {}) {
56932
+ for (const { key, value } of changes) {
56933
+ assertValidAttributeKey(key, context.allowReservedAttributes === true);
56934
+ assertValidAttributeValue(value);
56948
56935
  }
56936
+ validateAttributeBatchConstraints(changes, context);
56949
56937
  }
56950
56938
  function applyAttributeChanges(existing, changes) {
56951
56939
  const next2 = { ...existing ?? {} };
@@ -56958,6 +56946,71 @@ function applyAttributeChanges(existing, changes) {
56958
56946
  }
56959
56947
  return next2;
56960
56948
  }
56949
+ const textEncoder$1 = new TextEncoder();
56950
+ const AttributeKeySchema = string$3().min(1, { error: "Attribute key must not be empty" }).max(ATTRIBUTE_KEY_MAX_LENGTH, {
56951
+ error: `Attribute key exceeds limit ${ATTRIBUTE_KEY_MAX_LENGTH}`
56952
+ });
56953
+ const AttributeValueSchema = string$3().refine((value) => textEncoder$1.encode(value).length <= ATTRIBUTE_VALUE_MAX_BYTES, {
56954
+ error: `Attribute value exceeds limit ${ATTRIBUTE_VALUE_MAX_BYTES} UTF-8 bytes`
56955
+ }).nullable();
56956
+ const AttributeChangeSchema = object$1({
56957
+ key: AttributeKeySchema,
56958
+ value: AttributeValueSchema
56959
+ });
56960
+ const AttributeChangesSchema = array$1(AttributeChangeSchema).superRefine((changes, context) => {
56961
+ try {
56962
+ validateAttributeBatchConstraints(changes);
56963
+ } catch (error2) {
56964
+ if (!(error2 instanceof AttributeValidationError))
56965
+ throw error2;
56966
+ context.addIssue({
56967
+ code: "custom",
56968
+ message: error2.message,
56969
+ input: changes
56970
+ });
56971
+ }
56972
+ });
56973
+ function getOwnProperty$1(object2, key) {
56974
+ return Object.hasOwn(object2, key) ? object2[key] : void 0;
56975
+ }
56976
+ function isSealedNoopEvent$1(event) {
56977
+ return event.eventType === "noop";
56978
+ }
56979
+ const ENTITY_EVENT_CLASS_BY_TYPE = {
56980
+ step_created: "step_created",
56981
+ step_started: "step_started",
56982
+ step_retrying: "step_retrying",
56983
+ step_completed: "step_terminal",
56984
+ step_failed: "step_terminal",
56985
+ wait_created: "wait_created",
56986
+ wait_completed: "wait_completed",
56987
+ hook_created: "hook_created",
56988
+ hook_disposed: "hook_disposed",
56989
+ run_started: "run_started"
56990
+ };
56991
+ function entityEventClass(eventType) {
56992
+ return getOwnProperty$1(ENTITY_EVENT_CLASS_BY_TYPE, eventType);
56993
+ }
56994
+ const EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE = {
56995
+ run_created: ["input"],
56996
+ run_started: ["input"],
56997
+ run_completed: ["output"],
56998
+ run_failed: ["error"],
56999
+ step_created: ["input"],
57000
+ step_started: ["input"],
57001
+ step_completed: ["result"],
57002
+ step_failed: ["error"],
57003
+ step_retrying: ["error"],
57004
+ hook_created: ["metadata"],
57005
+ hook_received: ["payload"]
57006
+ };
57007
+ const NO_EVENT_DATA_REF_FIELDS = [];
57008
+ function getEventDataRefFields(eventType) {
57009
+ return getOwnProperty$1(EVENT_DATA_REF_FIELDS_BY_EVENT_TYPE, eventType) ?? NO_EVENT_DATA_REF_FIELDS;
57010
+ }
57011
+ function getEventDataPayloadField(eventType) {
57012
+ return getEventDataRefFields(eventType)[0];
57013
+ }
56961
57014
  const BinarySerializedDataSchema = _instanceof(Uint8Array);
56962
57015
  const LegacySerializedDataSchemaV1 = any();
56963
57016
  const SerializedDataSchema = union([
@@ -56987,7 +57040,11 @@ const EventTypeSchema = _enum([
56987
57040
  // Created by world when hook token already exists
56988
57041
  // Wait lifecycle events
56989
57042
  "wait_created",
56990
- "wait_completed"
57043
+ "wait_completed",
57044
+ // Sealed-log filler (specVersion >= 7): written ONLY by the World's backend
57045
+ // to occupy a slot whose writer allocated it and died. Carries no workflow
57046
+ // meaning; replay skips it (see EventsConsumer). Never user-creatable.
57047
+ "noop"
56991
57048
  ]);
56992
57049
  const RunEventTypeSchema = EventTypeSchema.extract([
56993
57050
  "run_created",
@@ -57025,21 +57082,6 @@ const TERMINAL_STEP_EVENT_TYPES = TerminalStepEventTypeSchema.options;
57025
57082
  function isTerminalStepEventType(eventType) {
57026
57083
  return TERMINAL_STEP_EVENT_TYPES.includes(eventType);
57027
57084
  }
57028
- const ENTITY_EVENT_CLASS_BY_TYPE = {
57029
- step_created: "step_created",
57030
- step_started: "step_started",
57031
- step_retrying: "step_retrying",
57032
- step_completed: "step_terminal",
57033
- step_failed: "step_terminal",
57034
- wait_created: "wait_created",
57035
- wait_completed: "wait_completed",
57036
- hook_created: "hook_created",
57037
- hook_disposed: "hook_disposed",
57038
- run_started: "run_started"
57039
- };
57040
- function entityEventClass(eventType) {
57041
- return ENTITY_EVENT_CLASS_BY_TYPE[eventType];
57042
- }
57043
57085
  const HookLifecycleEventTypeSchema = EventTypeSchema.extract([
57044
57086
  "hook_created",
57045
57087
  "hook_received",
@@ -57074,26 +57116,6 @@ const CHILD_ENTITY_CREATION_EVENT_TYPES = ChildEntityCreationEventTypeSchema.opt
57074
57116
  function isChildEntityCreationEventType(eventType) {
57075
57117
  return CHILD_ENTITY_CREATION_EVENT_TYPES.includes(eventType);
57076
57118
  }
57077
- const EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE = {
57078
- run_created: "input",
57079
- run_started: "input",
57080
- run_completed: "output",
57081
- run_failed: "error",
57082
- step_created: "input",
57083
- step_started: "input",
57084
- step_completed: "result",
57085
- step_failed: "error",
57086
- step_retrying: "error",
57087
- hook_created: "metadata",
57088
- hook_received: "payload"
57089
- };
57090
- const EVENT_DATA_REF_FIELDS = Object.fromEntries(Object.entries(EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE).map(([eventType, field]) => [eventType, [field]]));
57091
- function getEventDataRefFields(eventType) {
57092
- return EVENT_DATA_REF_FIELDS[eventType] ?? [];
57093
- }
57094
- function getEventDataPayloadField(eventType) {
57095
- return EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE[eventType];
57096
- }
57097
57119
  function stripEventDataRefs(event, resolveData) {
57098
57120
  if (resolveData !== "none")
57099
57121
  return event;
@@ -57144,7 +57166,7 @@ const stepLatencyTelemetryFields = {
57144
57166
  rsfs: number$3().optional(),
57145
57167
  // Synchronous workflow-function replay duration of only the FINAL replay
57146
57168
  // pass within the rsfs window (the pass that scheduled the first step),
57147
- // excluding awaited network I/O not accumulated across earlier
57169
+ // excluding awaited network I/O. Not accumulated across earlier
57148
57170
  // pre-first-step passes, so it is not "the replay portion of rsfs". Only
57149
57171
  // present alongside rsfs, and only for the run's first step.
57150
57172
  finalSchedulingReplay: number$3().optional(),
@@ -57204,7 +57226,7 @@ const StepStartedEventSchema = BaseEventSchema.extend({
57204
57226
  // handler is executing this step's body inline. Stamped on the lazy
57205
57227
  // step_started (and re-stamped on an owner-recovery bare start) so
57206
57228
  // that a wake replay can tell "this attempt is in flight in a live
57207
- // invocation" apart from "this attempt died with its process" the
57229
+ // invocation" apart from "this attempt died with its process": the
57208
57230
  // owner's queue message doubles as the liveness lease (a crash means
57209
57231
  // the queue redelivers that same messageId, which is allowed to
57210
57232
  // re-execute). Ownership derives from the step's LATEST step_started:
@@ -57260,6 +57282,12 @@ const HookConflictEventSchema = BaseEventSchema.extend({
57260
57282
  conflictingRunId: string$3().optional()
57261
57283
  })
57262
57284
  });
57285
+ const NoopEventSchema = BaseEventSchema.extend({
57286
+ eventType: literal("noop"),
57287
+ eventData: object$1({
57288
+ sealed: boolean$3().optional()
57289
+ }).passthrough().optional()
57290
+ });
57263
57291
  const WaitCreatedEventSchema = BaseEventSchema.extend({
57264
57292
  eventType: literal("wait_created"),
57265
57293
  correlationId: string$3(),
@@ -57306,7 +57334,7 @@ const RunCreatedEventSchema = BaseEventSchema.extend({
57306
57334
  * The run's X25519 public key (base64), stamped by SDKs that support
57307
57335
  * sealed (`encp`) envelopes. Persisted onto the run entity so that
57308
57336
  * cross-run writers can seal payloads to this run without holding its
57309
- * symmetric key. Not secret see `WorkflowRunBaseSchema`.
57337
+ * symmetric key. Not secret. See `WorkflowRunBaseSchema`.
57310
57338
  */
57311
57339
  encryptionPublicKey: string$3().optional()
57312
57340
  })
@@ -57401,7 +57429,9 @@ const AllEventsSchema = discriminatedUnion("eventType", [
57401
57429
  // World-only: created when hook token conflicts
57402
57430
  // Wait lifecycle events
57403
57431
  WaitCreatedEventSchema,
57404
- WaitCompletedEventSchema
57432
+ WaitCompletedEventSchema,
57433
+ NoopEventSchema
57434
+ // World-only: sealed-log filler for an abandoned slot
57405
57435
  ]);
57406
57436
  const EventSchema = AllEventsSchema.and(object$1({
57407
57437
  runId: string$3(),
@@ -57465,7 +57495,7 @@ const WorkflowRunBaseSchema = object$1({
57465
57495
  * ```
57466
57496
  */
57467
57497
  workflowName: string$3(),
57468
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
57498
+ // Optional in database for backward compatibility, defaults to 1 (legacy) when reading
57469
57499
  specVersion: number$3().optional(),
57470
57500
  executionContext: record(string$3(), any()).optional(),
57471
57501
  input: SerializedDataSchema.optional(),
@@ -57493,12 +57523,12 @@ const WorkflowRunBaseSchema = object$1({
57493
57523
  *
57494
57524
  * Defaults to `{}` after schema parsing so consumers always receive
57495
57525
  * a record regardless of world. World adapters need not initialize
57496
- * the field on disk `world-local` JSON files written before this
57526
+ * the field on disk: `world-local` JSON files written before this
57497
57527
  * field existed, and rows from any other adapter that omits the
57498
57528
  * column, both read as `{}` after Zod parses them.
57499
57529
  *
57500
57530
  * EXPERIMENTAL (MVP): the full Workflow Attributes feature replaces
57501
- * the direct-mutation MVP path with an event-sourced model — see
57531
+ * the direct-mutation MVP path with an event-sourced model. See
57502
57532
  * the attributes-mvp changelog entry.
57503
57533
  */
57504
57534
  attributes: record(string$3(), string$3()).default({}),
@@ -57506,12 +57536,12 @@ const WorkflowRunBaseSchema = object$1({
57506
57536
  * The run's X25519 public key, base64-encoded (~44 chars).
57507
57537
  *
57508
57538
  * Lets any party that can read this run seal a payload *to* it without
57509
- * being able to read the run's data used for cross-run writes such as a
57510
- * hook resumption from another deployment, or a child workflow writing into
57511
- * a forwarded stream. The matching private scalar is never stored: it is
57512
- * re-derived on demand from the deployment's own key material, so this
57513
- * field is not secret and its presence does not weaken the run's
57514
- * confidentiality.
57539
+ * being able to read the run's data. This is used for cross-run writes
57540
+ * such as a hook resumption from another deployment, or a child workflow
57541
+ * writing into a forwarded stream. The matching private scalar is never
57542
+ * stored: it is re-derived on demand from the deployment's own key
57543
+ * material, so this field is not secret and its presence does not weaken
57544
+ * the run's confidentiality.
57515
57545
  *
57516
57546
  * Stamped at run creation by SDKs that support sealed (`encp`) envelopes.
57517
57547
  * **Presence is the writer-side gate**: a run only carries a public key if
@@ -57768,7 +57798,9 @@ const AnalyticsAttributeKeySchema = object$1({
57768
57798
  lastSeenAt: date$2()
57769
57799
  });
57770
57800
  const ANALYTICS_EVENTS_GET_MANY_LIMIT = 100;
57771
- const warnedEnvValues = /* @__PURE__ */ new Set();
57801
+ const WarnedEnvValuesKey = Symbol.for("@workflow/world//warnedEnvValues/v1");
57802
+ const globalStore = globalThis;
57803
+ const warnedEnvValues = globalStore[WarnedEnvValuesKey] ?? (globalStore[WarnedEnvValuesKey] = /* @__PURE__ */ new Set());
57772
57804
  function warnOnce(key, message2) {
57773
57805
  if (warnedEnvValues.has(key))
57774
57806
  return;
@@ -57862,12 +57894,12 @@ const RunInputSchema = object$1({
57862
57894
  * two can disagree: if the message is consumed by a deployment in a
57863
57895
  * DIFFERENT environment, that consumer's `run_started` re-creates the run
57864
57896
  * under ITS tenant, so the same client-minted `wrun_` id ends up existing
57865
- * in two environments one stuck pending forever, the other executing.
57897
+ * in two environments: one stuck pending forever, the other executing.
57866
57898
  * Carrying the creator's environment lets the consumer compare it against
57867
57899
  * its own and refuse the delivery instead of forking the run.
57868
57900
  *
57869
57901
  * Absent for worlds with no environment dimension (local, Postgres), and
57870
- * for older SDKs consumers must treat it as advisory and skip the check
57902
+ * for older SDKs. Consumers must treat it as advisory and skip the check
57871
57903
  * when it is missing.
57872
57904
  */
57873
57905
  environment: string$3().optional()
@@ -57892,8 +57924,8 @@ const HookResumeInputSchema = object$1({
57892
57924
  hookId: string$3(),
57893
57925
  /**
57894
57926
  * The hook's token, written into the `hook_received` event's `eventData` so
57895
- * the consumer's re-ensured event carries the same token the producer would
57896
- * replay validates `eventData.token` against the `createHook` token.
57927
+ * the consumer's re-ensured event carries the same token the producer
57928
+ * would. Replay validates `eventData.token` against the `createHook` token.
57897
57929
  */
57898
57930
  token: string$3(),
57899
57931
  /** The serialized resume payload, reused verbatim from the direct write. */
@@ -57903,7 +57935,7 @@ const HookResumeInputSchema = object$1({
57903
57935
  * serialized bytes and forwarded verbatim on both the direct `events.create`
57904
57936
  * and this queue message. The consumer forwards it back to the server so both
57905
57937
  * writers of the same `resumeId` record an identical digest on the
57906
- * `(runId, resumeId)` constraint required because the v4 payload ref is not
57938
+ * `(runId, resumeId)` constraint, required because the v4 payload ref is not
57907
57939
  * content-stable server-side.
57908
57940
  */
57909
57941
  payloadDigest: string$3(),
@@ -57911,19 +57943,22 @@ const HookResumeInputSchema = object$1({
57911
57943
  * The deployment the run is pinned to, from the producer's resume context.
57912
57944
  * Lets the consumer detect a misrouted delivery with a cheap ambient
57913
57945
  * deployment-id comparison BEFORE its hoisted `hook_received` replay-preload
57914
- * write only a detected mismatch pays for the authoritative run fetch and
57946
+ * write: only a detected mismatch pays for the authoritative run fetch and
57915
57947
  * the deployment-affinity guard. Optional for queued-message compatibility:
57916
- * messages from older producers omit it and simply skip the pre-write
57948
+ * messages from older producers omit it and skip the pre-write
57917
57949
  * check (the authoritative guard before replay still protects them).
57918
57950
  */
57919
57951
  deploymentId: string$3().optional()
57920
57952
  });
57921
57953
  const HookResumeTimingSchema = object$1({
57922
- /** Epoch ms at entry into `resumeHook()` the start of the TTR window. */
57954
+ /** Epoch ms at entry into `resumeHook()`: the start of the TTR window. */
57923
57955
  resumeRequestedAtMs: number$3(),
57924
57956
  /** Epoch ms immediately before the queue publish was requested. */
57925
57957
  queuePublishRequestedAtMs: number$3(),
57926
- /** Which `resumeHook()` dispatch path ran: `parallel` or `sequential`. */
57958
+ /**
57959
+ * Which `resumeHook()` dispatch path ran: `lazy` or `sequential` (`parallel`
57960
+ * from producers predating lazy-only resume).
57961
+ */
57927
57962
  strategy: string$3().optional(),
57928
57963
  /** Epoch ms the final consumer's queue handler was entered. */
57929
57964
  consumerStartedAtMs: number$3().optional(),
@@ -57955,10 +57990,41 @@ const WorkflowInvokePayloadSchema = object$1({
57955
57990
  serverErrorRetryCount: number$3().int().optional(),
57956
57991
  /** Number of times this message has been re-routed after a deployment mismatch */
57957
57992
  deploymentMismatchRetryCount: number$3().int().nonnegative().optional(),
57993
+ /**
57994
+ * The wait this message is the delayed continuation for, and which attempt
57995
+ * in that wait's chain it is.
57996
+ *
57997
+ * Present only on wait-continuation messages. It exists so the invocation a
57998
+ * continuation wakes can recognize itself as that continuation: if the wait
57999
+ * is STILL pending when it replays — the continuation arrived before its
58000
+ * deadline — then its own idempotency key is already spent, and re-enqueueing
58001
+ * under the same key is silently dropped by the world's dedupe window. The
58002
+ * attempt number is what makes the next key fresh, so an early delivery
58003
+ * costs one extra hop instead of losing the wait's timer permanently.
58004
+ *
58005
+ * Counted on the message for the same reason as
58006
+ * {@link WorkflowInvokePayloadSchema.shape.preconditionReinvocations}: the
58007
+ * budget has to survive across invocations, and a fresh enqueue resets
58008
+ * anything the queue tracks itself. Absent on the first continuation, so a
58009
+ * producer that predates this field is indistinguishable from attempt 0 and
58010
+ * a consumer that predates it simply ignores the field.
58011
+ */
58012
+ /**
58013
+ * `.catch(undefined)` for the reason `hookResumeTiming` has it: this field
58014
+ * must never be able to fail the parse of the invocation payload. A
58015
+ * malformed value would otherwise throw on every delivery of the message
58016
+ * and burn the run's delivery budget. Degrading to `undefined` reads as
58017
+ * "not a continuation", which costs at worst the pre-attempt behavior for
58018
+ * that one wait rather than killing the run.
58019
+ */
58020
+ waitContinuation: object$1({
58021
+ correlationId: string$3(),
58022
+ attempt: number$3().int().nonnegative()
58023
+ }).optional().catch(void 0),
57958
58024
  /** Step ID for inline step execution in combined handler. If provided, the flow execution
57959
58025
  * will jump directly to execute the step with the given ID before doing an event replay. */
57960
58026
  stepId: string$3().optional(),
57961
- /** Step name, sent alongside stepId to avoid loading the event log just to resolve the name. */
58027
+ /** Step name, sent alongside stepId to avoid loading the event log to resolve the name. */
57962
58028
  stepName: string$3().optional(),
57963
58029
  /** Run creation data, only present on the first queue delivery from start() */
57964
58030
  runInput: RunInputSchema.optional(),
@@ -57977,10 +58043,10 @@ const WorkflowInvokePayloadSchema = object$1({
57977
58043
  stepInput: StepDispatchInputSchema.optional(),
57978
58044
  /**
57979
58045
  * Hook-resume TTR timing. Present on both `resumeHook()` dispatch paths
57980
- * (unlike `hookInput`, which only rides the parallel fast path), and
58046
+ * (unlike `hookInput`, which only rides the lazy path), and
57981
58047
  * forwarded onto a dispatched step message when the resuming invocation
57982
- * hands the next durable step to another invocation. Purely observational
57983
- * see {@link HookResumeTimingSchema}.
58048
+ * hands the next durable step to another invocation. Purely observational.
58049
+ * See {@link HookResumeTimingSchema}.
57984
58050
  *
57985
58051
  * `.catch(undefined)` because this field must never be able to fail the
57986
58052
  * parse of the invocation payload: a malformed value (a NaN boundary, a
@@ -58025,9 +58091,9 @@ const HookResumeContextSchema = object$1({
58025
58091
  // Feature marker: the version of the lazy-hook-resume consumer protocol the
58026
58092
  // run's creating deployment supports. Present (>= 1) means that deployment's
58027
58093
  // `@workflow/core` re-ensures the `hook_received` event from the queue
58028
- // message's `hookInput` on replay, so `resumeHook()`'s parallel fast path is
58029
- // safe to use. Because a run is pinned to its creating deployment, this
58030
- // marker is a reliable per-run attestation unlike inferring support from a
58094
+ // message's `hookInput` on replay, so `resumeHook()`'s lazy path is safe to
58095
+ // use. Because a run is pinned to its creating deployment, this
58096
+ // marker is a reliable per-run attestation, unlike inferring support from a
58031
58097
  // version compare against a predicted release cutoff. Absent on runs created
58032
58098
  // before the marker existed (fall back to the sequential path).
58033
58099
  hookResumeInputVersion: number$3().optional()
@@ -58050,7 +58116,7 @@ const HookSchema = object$1({
58050
58116
  environment: string$3(),
58051
58117
  metadata: SerializedDataSchema.optional(),
58052
58118
  createdAt: date$2(),
58053
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
58119
+ // Optional in database for backward compatibility, defaults to 1 (legacy) when reading
58054
58120
  specVersion: number$3().optional(),
58055
58121
  isWebhook: boolean$3().optional(),
58056
58122
  isSystem: boolean$3().optional(),
@@ -58062,10 +58128,10 @@ const HookSchema = object$1({
58062
58128
  // falls back to `runs.get`.
58063
58129
  resumeContext: HookResumeContextSchema.optional(),
58064
58130
  // Backend dedup capability, computed FRESH by the server on every by-token
58065
- // lookup RESPONSE-ONLY and TRANSIENT. Never persisted on the hook entity
58131
+ // lookup: RESPONSE-ONLY and TRANSIENT. Never persisted on the hook entity
58066
58132
  // and never part of `resumeContext`, so a server rollback or kill switch
58067
- // takes effect on the very next lookup (the field simply stops appearing).
58068
- // `resumeHook()` gates its parallel fast path on this being present and
58133
+ // takes effect on the next lookup (the field stops appearing).
58134
+ // `resumeHook()` gates its lazy path on this being present and
58069
58135
  // current. Absent against an older/rolled-back server or when the kill switch
58070
58136
  // is active.
58071
58137
  resumeCapabilities: HookResumeCapabilitiesSchema.optional()
@@ -58176,8 +58242,13 @@ const SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
58176
58242
  const SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
58177
58243
  const SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
58178
58244
  const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
58179
- const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
58180
- const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
58245
+ const SPEC_VERSION_SUPPORTS_SEALED_LOG = 7;
58246
+ const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SEALED_LOG;
58247
+ const SEALED_LOG_ENV_VAR = "WORKFLOW_SEALED_LOG";
58248
+ function mintedSpecVersion(env2 = process.env) {
58249
+ return envFlag(SEALED_LOG_ENV_VAR, true, env2) ? SPEC_VERSION_CURRENT : SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
58250
+ }
58251
+ const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SEALED_LOG;
58181
58252
  function isLegacySpecVersion(v2) {
58182
58253
  return v2 === void 0 || v2 === null || v2 <= SPEC_VERSION_LEGACY;
58183
58254
  }
@@ -58330,13 +58401,13 @@ function monotonicFactory(prng) {
58330
58401
  return encodeTime(seed, TIME_LEN) + newRandom;
58331
58402
  };
58332
58403
  }
58333
- function ulid$3(seedTime, prng) {
58404
+ function ulid$1(seedTime, prng) {
58334
58405
  const currentPRNG = detectPRNG();
58335
58406
  const seed = Date.now();
58336
58407
  return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
58337
58408
  }
58338
58409
  const UlidSchema = string$3().ulid();
58339
- const workflowRunIdSchema = templateLiteral(["wrun_", ulid$4()]);
58410
+ const workflowRunIdSchema = templateLiteral(["wrun_", ulid$2()]);
58340
58411
  const DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS = 24 * 60 * 60 * 1e3;
58341
58412
  const DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS = 5 * 60 * 1e3;
58342
58413
  function ulidToDate(maybeUlid) {
@@ -58465,6 +58536,218 @@ function looksLikeWorkflowIdSearchInput(query) {
58465
58536
  }
58466
58537
  return /\d/.test(trimmed);
58467
58538
  }
58539
+ function globalSingleton(name2, shapeVersion, create2) {
58540
+ const key = Symbol.for(`${name2}/v${shapeVersion}`);
58541
+ const store = globalThis;
58542
+ const existing = store[key];
58543
+ if (existing !== void 0) {
58544
+ return existing;
58545
+ }
58546
+ const created = create2();
58547
+ store[key] = created;
58548
+ return created;
58549
+ }
58550
+ function pluralize(singular, plural, count2) {
58551
+ return count2 === 1 ? singular : plural;
58552
+ }
58553
+ function withResolvers$1() {
58554
+ let resolve2;
58555
+ let reject;
58556
+ const promise2 = new Promise((_resolve, _reject) => {
58557
+ resolve2 = _resolve;
58558
+ reject = _reject;
58559
+ });
58560
+ return { promise: promise2, resolve: resolve2, reject };
58561
+ }
58562
+ function once$1(fn2) {
58563
+ const result = {
58564
+ get value() {
58565
+ const value = fn2();
58566
+ Object.defineProperty(result, "value", { value });
58567
+ return value;
58568
+ }
58569
+ };
58570
+ return result;
58571
+ }
58572
+ var ms$1;
58573
+ var hasRequiredMs;
58574
+ function requireMs() {
58575
+ if (hasRequiredMs) return ms$1;
58576
+ hasRequiredMs = 1;
58577
+ var s2 = 1e3;
58578
+ var m2 = s2 * 60;
58579
+ var h2 = m2 * 60;
58580
+ var d2 = h2 * 24;
58581
+ var w2 = d2 * 7;
58582
+ var y2 = d2 * 365.25;
58583
+ ms$1 = function(val, options) {
58584
+ options = options || {};
58585
+ var type = typeof val;
58586
+ if (type === "string" && val.length > 0) {
58587
+ return parse2(val);
58588
+ } else if (type === "number" && isFinite(val)) {
58589
+ return options.long ? fmtLong(val) : fmtShort(val);
58590
+ }
58591
+ throw new Error(
58592
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
58593
+ );
58594
+ };
58595
+ function parse2(str) {
58596
+ str = String(str);
58597
+ if (str.length > 100) {
58598
+ return;
58599
+ }
58600
+ var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
58601
+ str
58602
+ );
58603
+ if (!match2) {
58604
+ return;
58605
+ }
58606
+ var n = parseFloat(match2[1]);
58607
+ var type = (match2[2] || "ms").toLowerCase();
58608
+ switch (type) {
58609
+ case "years":
58610
+ case "year":
58611
+ case "yrs":
58612
+ case "yr":
58613
+ case "y":
58614
+ return n * y2;
58615
+ case "weeks":
58616
+ case "week":
58617
+ case "w":
58618
+ return n * w2;
58619
+ case "days":
58620
+ case "day":
58621
+ case "d":
58622
+ return n * d2;
58623
+ case "hours":
58624
+ case "hour":
58625
+ case "hrs":
58626
+ case "hr":
58627
+ case "h":
58628
+ return n * h2;
58629
+ case "minutes":
58630
+ case "minute":
58631
+ case "mins":
58632
+ case "min":
58633
+ case "m":
58634
+ return n * m2;
58635
+ case "seconds":
58636
+ case "second":
58637
+ case "secs":
58638
+ case "sec":
58639
+ case "s":
58640
+ return n * s2;
58641
+ case "milliseconds":
58642
+ case "millisecond":
58643
+ case "msecs":
58644
+ case "msec":
58645
+ case "ms":
58646
+ return n;
58647
+ default:
58648
+ return void 0;
58649
+ }
58650
+ }
58651
+ function fmtShort(ms2) {
58652
+ var msAbs = Math.abs(ms2);
58653
+ if (msAbs >= d2) {
58654
+ return Math.round(ms2 / d2) + "d";
58655
+ }
58656
+ if (msAbs >= h2) {
58657
+ return Math.round(ms2 / h2) + "h";
58658
+ }
58659
+ if (msAbs >= m2) {
58660
+ return Math.round(ms2 / m2) + "m";
58661
+ }
58662
+ if (msAbs >= s2) {
58663
+ return Math.round(ms2 / s2) + "s";
58664
+ }
58665
+ return ms2 + "ms";
58666
+ }
58667
+ function fmtLong(ms2) {
58668
+ var msAbs = Math.abs(ms2);
58669
+ if (msAbs >= d2) {
58670
+ return plural(ms2, msAbs, d2, "day");
58671
+ }
58672
+ if (msAbs >= h2) {
58673
+ return plural(ms2, msAbs, h2, "hour");
58674
+ }
58675
+ if (msAbs >= m2) {
58676
+ return plural(ms2, msAbs, m2, "minute");
58677
+ }
58678
+ if (msAbs >= s2) {
58679
+ return plural(ms2, msAbs, s2, "second");
58680
+ }
58681
+ return ms2 + " ms";
58682
+ }
58683
+ function plural(ms2, msAbs, n, name2) {
58684
+ var isPlural = msAbs >= n * 1.5;
58685
+ return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
58686
+ }
58687
+ return ms$1;
58688
+ }
58689
+ var msExports = requireMs();
58690
+ const ms = /* @__PURE__ */ getDefaultExportFromCjs(msExports);
58691
+ function parseDurationToDate(param) {
58692
+ if (typeof param === "string") {
58693
+ const durationMs = ms(param);
58694
+ if (typeof durationMs !== "number" || durationMs < 0) {
58695
+ throw new Error(`Invalid duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`);
58696
+ }
58697
+ return new Date(Date.now() + durationMs);
58698
+ } else if (typeof param === "number") {
58699
+ if (param < 0 || !Number.isFinite(param)) {
58700
+ throw new Error(`Invalid duration: ${param}. Expected a non-negative finite number of milliseconds.`);
58701
+ }
58702
+ return new Date(Date.now() + param);
58703
+ } else if (param instanceof Date || param && typeof param === "object" && typeof param.getTime === "function") {
58704
+ return param instanceof Date ? param : new Date(param.getTime());
58705
+ } else {
58706
+ throw new Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`);
58707
+ }
58708
+ }
58709
+ const WORKFLOW_ROUTE_BASE = "/.well-known/workflow/v1";
58710
+ const BASE_PATH_SYMBOL = Symbol.for("@workflow/core/basePath");
58711
+ const globalConfig = globalThis;
58712
+ function getWorkflowBasePath() {
58713
+ return globalConfig[BASE_PATH_SYMBOL] ?? "";
58714
+ }
58715
+ function createWorkflowBaseUrl(origin) {
58716
+ new URL(origin);
58717
+ return `${origin.replace(/[?#].*$/, "").replace(/\/+$/, "")}${getWorkflowBasePath()}`;
58718
+ }
58719
+ function createWorkflowUrl(baseUrl, route) {
58720
+ const url2 = new URL(baseUrl);
58721
+ url2.pathname = `${url2.pathname.replace(/\/+$/, "")}${WORKFLOW_ROUTE_BASE}/${getWorkflowRouteEndpoint(route)}`;
58722
+ url2.search = route.type === "health" ? "__health" : "";
58723
+ url2.hash = "";
58724
+ return url2.toString();
58725
+ }
58726
+ function getWorkflowRouteEndpoint(route) {
58727
+ switch (route.type) {
58728
+ case "flow":
58729
+ case "health":
58730
+ return "flow";
58731
+ case "manifest":
58732
+ return "manifest.json";
58733
+ case "webhook":
58734
+ return `webhook/${encodeURIComponent(route.token)}`;
58735
+ }
58736
+ throw new Error(`Unsupported workflow route: ${String(route.type)}`);
58737
+ }
58738
+ function createWorkflowHealthEndpoint() {
58739
+ return `${getWorkflowBasePath()}${WORKFLOW_ROUTE_BASE}/flow?__health`;
58740
+ }
58741
+ function resolveWorkflowTargetWorld(env2 = process.env) {
58742
+ const configuredWorld = env2.WORKFLOW_TARGET_WORLD;
58743
+ if (configuredWorld) {
58744
+ return configuredWorld;
58745
+ }
58746
+ return env2.VERCEL_DEPLOYMENT_ID ? "vercel" : "local";
58747
+ }
58748
+ function isVercelWorldTarget(targetWorld) {
58749
+ return targetWorld === "vercel" || targetWorld === "@workflow/world-vercel";
58750
+ }
58468
58751
  const UNDEFINED$2 = -1;
58469
58752
  const HOLE = -2;
58470
58753
  const NAN = -3;
@@ -59123,207 +59406,6 @@ function stringify_primitive(thing) {
59123
59406
  if (type === "bigint") return `["BigInt","${thing}"]`;
59124
59407
  return String(thing);
59125
59408
  }
59126
- function pluralize(singular, plural, count2) {
59127
- return count2 === 1 ? singular : plural;
59128
- }
59129
- function withResolvers$1() {
59130
- let resolve2;
59131
- let reject;
59132
- const promise2 = new Promise((_resolve, _reject) => {
59133
- resolve2 = _resolve;
59134
- reject = _reject;
59135
- });
59136
- return { promise: promise2, resolve: resolve2, reject };
59137
- }
59138
- function once$1(fn2) {
59139
- const result = {
59140
- get value() {
59141
- const value = fn2();
59142
- Object.defineProperty(result, "value", { value });
59143
- return value;
59144
- }
59145
- };
59146
- return result;
59147
- }
59148
- var ms$1;
59149
- var hasRequiredMs;
59150
- function requireMs() {
59151
- if (hasRequiredMs) return ms$1;
59152
- hasRequiredMs = 1;
59153
- var s2 = 1e3;
59154
- var m2 = s2 * 60;
59155
- var h2 = m2 * 60;
59156
- var d2 = h2 * 24;
59157
- var w2 = d2 * 7;
59158
- var y2 = d2 * 365.25;
59159
- ms$1 = function(val, options) {
59160
- options = options || {};
59161
- var type = typeof val;
59162
- if (type === "string" && val.length > 0) {
59163
- return parse2(val);
59164
- } else if (type === "number" && isFinite(val)) {
59165
- return options.long ? fmtLong(val) : fmtShort(val);
59166
- }
59167
- throw new Error(
59168
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
59169
- );
59170
- };
59171
- function parse2(str) {
59172
- str = String(str);
59173
- if (str.length > 100) {
59174
- return;
59175
- }
59176
- var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
59177
- str
59178
- );
59179
- if (!match2) {
59180
- return;
59181
- }
59182
- var n = parseFloat(match2[1]);
59183
- var type = (match2[2] || "ms").toLowerCase();
59184
- switch (type) {
59185
- case "years":
59186
- case "year":
59187
- case "yrs":
59188
- case "yr":
59189
- case "y":
59190
- return n * y2;
59191
- case "weeks":
59192
- case "week":
59193
- case "w":
59194
- return n * w2;
59195
- case "days":
59196
- case "day":
59197
- case "d":
59198
- return n * d2;
59199
- case "hours":
59200
- case "hour":
59201
- case "hrs":
59202
- case "hr":
59203
- case "h":
59204
- return n * h2;
59205
- case "minutes":
59206
- case "minute":
59207
- case "mins":
59208
- case "min":
59209
- case "m":
59210
- return n * m2;
59211
- case "seconds":
59212
- case "second":
59213
- case "secs":
59214
- case "sec":
59215
- case "s":
59216
- return n * s2;
59217
- case "milliseconds":
59218
- case "millisecond":
59219
- case "msecs":
59220
- case "msec":
59221
- case "ms":
59222
- return n;
59223
- default:
59224
- return void 0;
59225
- }
59226
- }
59227
- function fmtShort(ms2) {
59228
- var msAbs = Math.abs(ms2);
59229
- if (msAbs >= d2) {
59230
- return Math.round(ms2 / d2) + "d";
59231
- }
59232
- if (msAbs >= h2) {
59233
- return Math.round(ms2 / h2) + "h";
59234
- }
59235
- if (msAbs >= m2) {
59236
- return Math.round(ms2 / m2) + "m";
59237
- }
59238
- if (msAbs >= s2) {
59239
- return Math.round(ms2 / s2) + "s";
59240
- }
59241
- return ms2 + "ms";
59242
- }
59243
- function fmtLong(ms2) {
59244
- var msAbs = Math.abs(ms2);
59245
- if (msAbs >= d2) {
59246
- return plural(ms2, msAbs, d2, "day");
59247
- }
59248
- if (msAbs >= h2) {
59249
- return plural(ms2, msAbs, h2, "hour");
59250
- }
59251
- if (msAbs >= m2) {
59252
- return plural(ms2, msAbs, m2, "minute");
59253
- }
59254
- if (msAbs >= s2) {
59255
- return plural(ms2, msAbs, s2, "second");
59256
- }
59257
- return ms2 + " ms";
59258
- }
59259
- function plural(ms2, msAbs, n, name2) {
59260
- var isPlural = msAbs >= n * 1.5;
59261
- return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
59262
- }
59263
- return ms$1;
59264
- }
59265
- var msExports = requireMs();
59266
- const ms = /* @__PURE__ */ getDefaultExportFromCjs(msExports);
59267
- function parseDurationToDate(param) {
59268
- if (typeof param === "string") {
59269
- const durationMs = ms(param);
59270
- if (typeof durationMs !== "number" || durationMs < 0) {
59271
- throw new Error(`Invalid duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`);
59272
- }
59273
- return new Date(Date.now() + durationMs);
59274
- } else if (typeof param === "number") {
59275
- if (param < 0 || !Number.isFinite(param)) {
59276
- throw new Error(`Invalid duration: ${param}. Expected a non-negative finite number of milliseconds.`);
59277
- }
59278
- return new Date(Date.now() + param);
59279
- } else if (param instanceof Date || param && typeof param === "object" && typeof param.getTime === "function") {
59280
- return param instanceof Date ? param : new Date(param.getTime());
59281
- } else {
59282
- throw new Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`);
59283
- }
59284
- }
59285
- const WORKFLOW_ROUTE_BASE = "/.well-known/workflow/v1";
59286
- const BASE_PATH_SYMBOL = Symbol.for("@workflow/core/basePath");
59287
- const globalConfig = globalThis;
59288
- function getWorkflowBasePath() {
59289
- return globalConfig[BASE_PATH_SYMBOL] ?? "";
59290
- }
59291
- function createWorkflowBaseUrl(origin) {
59292
- new URL(origin);
59293
- return `${origin.replace(/[?#].*$/, "").replace(/\/+$/, "")}${getWorkflowBasePath()}`;
59294
- }
59295
- function createWorkflowUrl(baseUrl, route) {
59296
- const url2 = new URL(baseUrl);
59297
- url2.pathname = `${url2.pathname.replace(/\/+$/, "")}${WORKFLOW_ROUTE_BASE}/${getWorkflowRouteEndpoint(route)}`;
59298
- url2.search = route.type === "health" ? "__health" : "";
59299
- url2.hash = "";
59300
- return url2.toString();
59301
- }
59302
- function getWorkflowRouteEndpoint(route) {
59303
- switch (route.type) {
59304
- case "flow":
59305
- case "health":
59306
- return "flow";
59307
- case "manifest":
59308
- return "manifest.json";
59309
- case "webhook":
59310
- return `webhook/${encodeURIComponent(route.token)}`;
59311
- }
59312
- throw new Error(`Unsupported workflow route: ${String(route.type)}`);
59313
- }
59314
- function createWorkflowHealthEndpoint() {
59315
- return `${getWorkflowBasePath()}${WORKFLOW_ROUTE_BASE}/flow?__health`;
59316
- }
59317
- function resolveWorkflowTargetWorld(env2 = process.env) {
59318
- const configuredWorld = env2.WORKFLOW_TARGET_WORLD;
59319
- if (configuredWorld) {
59320
- return configuredWorld;
59321
- }
59322
- return env2.VERCEL_DEPLOYMENT_ID ? "vercel" : "local";
59323
- }
59324
- function isVercelWorldTarget(targetWorld) {
59325
- return targetWorld === "vercel" || targetWorld === "@workflow/world-vercel";
59326
- }
59327
59409
  const BASE_URL = "https://workflow-sdk.dev/err";
59328
59410
  function isError(value) {
59329
59411
  return typeof value === "object" && value !== null && "name" in value && "message" in value;
@@ -59461,7 +59543,7 @@ class SerializationError extends WorkflowError {
59461
59543
  super(body2, { cause: options == null ? void 0 : options.cause });
59462
59544
  __publicField(this, "hint");
59463
59545
  /**
59464
- * Serialization errors are deterministic if a step returns a non-POJO,
59546
+ * Serialization errors are deterministic: if a step returns a non-POJO,
59465
59547
  * replaying the step will always produce the same non-serializable value.
59466
59548
  * Retrying is guaranteed to fail, so these errors are surfaced as fatal
59467
59549
  * and skip the step-retry loop. `FatalError.is()` recognizes any error
@@ -59826,7 +59908,7 @@ function importPublicKey(publicKey) {
59826
59908
  { name: "X25519" },
59827
59909
  /* extractable */
59828
59910
  true,
59829
- // Public keys carry no usages for X25519 the private key does the
59911
+ // Public keys carry no usages for X25519: the private key does the
59830
59912
  // deriving; the public key is only ever an argument to it.
59831
59913
  []
59832
59914
  );
@@ -60054,7 +60136,7 @@ const SerializationFormat$1 = {
60054
60136
  /** Encrypted payload (inner payload has its own format prefix) */
60055
60137
  ENCRYPTED: "encr",
60056
60138
  /**
60057
- * Sealed payload asymmetrically encrypted to a run's X25519 public key
60139
+ * Sealed payload: asymmetrically encrypted to a run's X25519 public key
60058
60140
  * (inner payload has its own format prefix).
60059
60141
  *
60060
60142
  * Used for *cross-run* writes (hook payloads, forwarded stream frames),
@@ -60218,7 +60300,7 @@ const SerializationFormat = {
60218
60300
  /** Encrypted payload (inner payload has its own format prefix after decryption) */
60219
60301
  ENCRYPTED: "encr",
60220
60302
  /**
60221
- * Sealed payload asymmetrically encrypted to a run's X25519 public key
60303
+ * Sealed payload: asymmetrically encrypted to a run's X25519 public key
60222
60304
  * (inner payload has its own format prefix after opening).
60223
60305
  *
60224
60306
  * Written by cross-run writers that hold only the recipient run's public
@@ -60312,17 +60394,19 @@ function decompressSyncIfAvailable(format2, payload) {
60312
60394
  }
60313
60395
  return void 0;
60314
60396
  }
60315
- let zstdBrowserDecoder;
60397
+ const zstd = globalSingleton("@workflow/core//zstd.decoder", 1, () => ({
60398
+ decoder: void 0
60399
+ }));
60316
60400
  function registerZstdDecoder(decoder2) {
60317
- zstdBrowserDecoder = decoder2;
60401
+ zstd.decoder = decoder2;
60318
60402
  }
60319
60403
  async function decompressAsync(format2, payload) {
60320
60404
  if (format2 === SerializationFormat.ZSTD) {
60321
60405
  const sync = decompressSyncIfAvailable(format2, payload);
60322
60406
  if (sync)
60323
60407
  return sync;
60324
- if (zstdBrowserDecoder)
60325
- return zstdBrowserDecoder(payload);
60408
+ if (zstd.decoder)
60409
+ return zstd.decoder(payload);
60326
60410
  throw new Error("zstd-compressed workflow data encountered but no zstd decoder is available. Node.js 22.15+ decodes natively; in the browser register one via registerZstdDecoder (the web o11y package does this).");
60327
60411
  }
60328
60412
  const transform2 = new DecompressionStream("gzip");
@@ -60466,7 +60550,7 @@ const observabilityRevivers = {
60466
60550
  // throws on the `["DOMException", ...]` tag and `hydrateStepIO`'s
60467
60551
  // try/catch leaves the raw flat-encoded string in the UI. AbortController
60468
60552
  // synthesizes a DOMException as the default `signal.reason` when abort()
60469
- // is called with no arg so any abort that round-trips through a step
60553
+ // is called with no arg, so any abort that round-trips through a step
60470
60554
  // boundary surfaces here. Reconstruct as a real DOMException when the
60471
60555
  // global is available (modern browsers + Node 18+), else fall back to
60472
60556
  // an Error preserving name/message/stack/cause for display.
@@ -60675,8 +60759,8 @@ function getWebRevivers() {
60675
60759
  // entry for each built-in Error subclass plus the workflow-specific
60676
60760
  // `FatalError` / `RetryableError` / `HookConflictError` /
60677
60761
  // `RuntimeDecryptionError` and `AggregateError`. Without
60678
- // matching revivers here, `devalue.unflatten` throws "Unknown type X"
60679
- // which surfaces in the web o11y UI as "Failed to load resource
60762
+ // matching revivers here, `devalue.unflatten` throws "Unknown type X",
60763
+ // which surfaces in the web o11y UI as "Failed to load resource
60680
60764
  // details: Unknown type FatalError".
60681
60765
  Error: (value) => {
60682
60766
  const opts = "cause" in value ? { cause: value.cause } : void 0;
@@ -60706,7 +60790,7 @@ function getWebRevivers() {
60706
60790
  // `FatalError` and `RetryableError` are not built-in browser globals,
60707
60791
  // so we can't resolve a constructor from globalThis. The web o11y UI
60708
60792
  // doesn't need `instanceof FatalError` to pass (no user code runs
60709
- // here) it just needs `name`, `message`, `stack`, and any extra
60793
+ // here). The web o11y UI needs `name`, `message`, `stack`, and any extra
60710
60794
  // enumerable fields to render. Construct a plain `Error` with `name`
60711
60795
  // set; ObjectInspector reads `constructor.name` for the displayed
60712
60796
  // class label, but we don't have the real class, so we emit a tagged
@@ -60904,7 +60988,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
60904
60988
  }
60905
60989
  async function hydrateResourceIOAsync(resource, key) {
60906
60990
  const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
60907
- const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-D8JD_nwS.js");
60991
+ const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-Bfk1d5vU.js");
60908
60992
  ensureZstdDecoderRegistered();
60909
60993
  const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
60910
60994
  const revivers = getRevivers();
@@ -60957,6 +61041,10 @@ function hasEncryptedFields(resource) {
60957
61041
  }
60958
61042
  return false;
60959
61043
  }
61044
+ const SEALED_EVENT_MESSAGE = "No-op events are written by the backend to seal an abandoned log position";
61045
+ function isSealedNoopEvent(event) {
61046
+ return isSealedNoopEvent$1(event);
61047
+ }
60960
61048
  function __insertCSS(code2) {
60961
61049
  if (typeof document == "undefined") return;
60962
61050
  let head = document.head || document.getElementsByTagName("head")[0];
@@ -62862,7 +62950,7 @@ const RunClickContext = reactExports.createContext(void 0);
62862
62950
  function EncryptedInlineLabel() {
62863
62951
  const ctx = reactExports.useContext(DecryptClickContext);
62864
62952
  if (ctx) {
62865
- return jsxRuntimeExports.jsxs(Button$1, { size: "xs", className: "align-baseline gap-x-1", disabled: ctx.isDecrypting, onClick: (e) => {
62953
+ return jsxRuntimeExports.jsxs(Button$1, { size: "xs", className: "align-baseline gap-x-1", disabled: ctx.isDecrypting || ctx.isDecryptDisabled, title: ctx.isDecryptDisabled ? ctx.decryptDisabledReason : void 0, onClick: (e) => {
62866
62954
  e.stopPropagation();
62867
62955
  ctx.onDecrypt();
62868
62956
  }, children: [ctx.isDecrypting ? jsxRuntimeExports.jsx(Spinner, { size: 10 }) : jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { children: "Decrypt" })] });
@@ -63135,7 +63223,7 @@ function collapseRefs(data) {
63135
63223
  }
63136
63224
  return result;
63137
63225
  }
63138
- function DataInspector({ data, expandLevel = 2, name: name2, onStreamClick, onRunClick, onDecrypt, isDecrypting = false }) {
63226
+ function DataInspector({ data, expandLevel = 2, name: name2, onStreamClick, onRunClick, onDecrypt, isDecrypting = false, isDecryptDisabled = false, decryptDisabledReason }) {
63139
63227
  const collapsedData = reactExports.useMemo(() => collapseRefs(data), [data]);
63140
63228
  const stableData = useStableInspectorData(collapsedData);
63141
63229
  let content2 = jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { href: "wf-json-view", precedence: "default", children: JSON_VIEW_STYLES }), jsxRuntimeExports.jsx(JsonTree, { data: stableData, name: name2, expandLevel })] });
@@ -63146,7 +63234,12 @@ function DataInspector({ data, expandLevel = 2, name: name2, onStreamClick, onRu
63146
63234
  content2 = jsxRuntimeExports.jsx(RunClickContext.Provider, { value: onRunClick, children: content2 });
63147
63235
  }
63148
63236
  if (onDecrypt) {
63149
- content2 = jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: { onDecrypt, isDecrypting }, children: content2 });
63237
+ content2 = jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: {
63238
+ onDecrypt,
63239
+ isDecrypting,
63240
+ isDecryptDisabled,
63241
+ decryptDisabledReason
63242
+ }, children: content2 });
63150
63243
  }
63151
63244
  return content2;
63152
63245
  }
@@ -63231,7 +63324,7 @@ const encryptedPlaceholderPreview = `{
63231
63324
  }`;
63232
63325
  function EncryptedDataBlock() {
63233
63326
  const ctx = reactExports.useContext(DecryptClickContext);
63234
- return jsxRuntimeExports.jsxs("div", { className: "relative min-h-20 overflow-hidden rounded-md border border-gray-alpha-400 bg-background-100", children: [jsxRuntimeExports.jsx("pre", { "aria-hidden": "true", className: "pointer-events-none m-0 select-none p-3 font-mono text-label-12 text-gray-900 blur-[4px]", children: encryptedPlaceholderPreview }), jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: ctx ? jsxRuntimeExports.jsxs(Button$1, { onClick: ctx.onDecrypt, disabled: ctx.isDecrypting, size: "xs", children: [ctx.isDecrypting ? jsxRuntimeExports.jsx(Spinner, { size: 10 }) : jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { children: "Decrypt" })] }) : jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 rounded border border-gray-alpha-400 bg-gray-100 px-1.5 py-0.5 text-button-12 font-medium text-gray-700", children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), "Encrypted"] }) })] });
63327
+ return jsxRuntimeExports.jsxs("div", { className: "relative min-h-20 overflow-hidden rounded-md border border-gray-alpha-400 bg-background-100", children: [jsxRuntimeExports.jsx("pre", { "aria-hidden": "true", className: "pointer-events-none m-0 select-none p-3 font-mono text-label-12 text-gray-900 blur-[4px]", children: encryptedPlaceholderPreview }), jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: ctx ? jsxRuntimeExports.jsxs(Button$1, { onClick: ctx.onDecrypt, disabled: ctx.isDecrypting || ctx.isDecryptDisabled, title: ctx.isDecryptDisabled ? ctx.decryptDisabledReason : void 0, size: "xs", children: [ctx.isDecrypting ? jsxRuntimeExports.jsx(Spinner, { size: 10 }) : jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { children: "Decrypt" })] }) : jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 rounded border border-gray-alpha-400 bg-gray-100 px-1.5 py-0.5 text-button-12 font-medium text-gray-700", children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), "Encrypted"] }) })] });
63235
63328
  }
63236
63329
  const serializeForClipboard = (value) => {
63237
63330
  if (typeof value === "string")
@@ -64069,19 +64162,19 @@ function ContextCardTrigger({ content: content2, children: children2, side = "ri
64069
64162
  const Comp = asChild ? Root$6 : "div";
64070
64163
  return jsxRuntimeExports.jsxs(Comp, { className: cn$4("inline-flex cursor-pointer flex-[0_1_auto] overflow-hidden", className), onMouseEnter, onMouseLeave, onClick: handleClick, ref: triggerRef, children: [jsxRuntimeExports.jsx(Slottable$1, { children: children2 }), (portalRef == null ? void 0 : portalRef.current) && (localHover || persisting) ? reactDomExports.createPortal(jsxRuntimeExports.jsx("div", { className: cn$4("absolute top-0 p-3 left-0 max-w-max transition-[transform,width,height] duration-[250ms] ease-[easing-function:cubic-bezier(0.29,0.31,0.05,0.96)] will-change-[transform,width,height] motion-reduce:!transition-none", skipTransition && "!transition-none", noPadding && "p-0", rootVisible && visible && !ignoreCardPointerEvents ? "pointer-events-auto" : "pointer-events-none"), ref: contentRef, children: jsxRuntimeExports.jsx("div", { className: cn$4("min-w-max transition-all duration-150 ease-[easing-function:cubic-bezier(0.3,_0.57,_0.07,_0.95)] will-change-[transform,width,height] motion-reduce:!transition-none", skipTransition ? "!transition-none" : "transition-[transform,width,height] duration-[250ms] ease-[easing-function:cubic-bezier(0.29,0.31,0.05,0.96)] will-change-[transform,width,height] motion-reduce:!transition-none", visible ? "opacity-100" : "opacity-0"), ref: contentMeasureRef, children: content2 }) }, id2), portalRef.current) : null] });
64071
64164
  }
64072
- const STYLES$2 = `.wf-decrypt-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 12px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;cursor:pointer;white-space:nowrap;gap:6px;transition:background 150ms}.wf-decrypt-idle{color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400)}.wf-decrypt-idle:hover{background:var(--ds-gray-alpha-200)}.wf-decrypt-done{color:var(--ds-green-900);background:var(--ds-green-100);box-shadow:0 0 0 1px var(--ds-green-400);cursor:default}`;
64073
- function DecryptButton({ decrypted = false, loading = false, onClick }) {
64074
- return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { dangerouslySetInnerHTML: { __html: STYLES$2 } }), jsxRuntimeExports.jsxs("button", { type: "button", onClick: decrypted ? void 0 : onClick, disabled: decrypted || loading, className: `wf-decrypt-btn ${decrypted ? "wf-decrypt-done" : "wf-decrypt-idle"}`, children: [loading ? jsxRuntimeExports.jsx(Spinner, { size: 14 }) : decrypted ? jsxRuntimeExports.jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }), jsxRuntimeExports.jsx("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })] }) : jsxRuntimeExports.jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }), jsxRuntimeExports.jsx("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })] }), loading ? "Decrypting…" : decrypted ? "Decrypted" : "Decrypt"] })] });
64165
+ const STYLES$2 = `.wf-decrypt-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 12px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;cursor:pointer;white-space:nowrap;gap:6px;transition:background 150ms}.wf-decrypt-idle{color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400)}.wf-decrypt-idle:hover{background:var(--ds-gray-alpha-200)}.wf-decrypt-btn:disabled{cursor:not-allowed;opacity:.5}.wf-decrypt-done{color:var(--ds-green-900);background:var(--ds-green-100);box-shadow:0 0 0 1px var(--ds-green-400);cursor:default}`;
64166
+ function DecryptButton({ decrypted = false, loading = false, disabled = false, disabledReason, onClick }) {
64167
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { dangerouslySetInnerHTML: { __html: STYLES$2 } }), jsxRuntimeExports.jsxs("button", { type: "button", onClick: decrypted ? void 0 : onClick, disabled: decrypted || loading || disabled, title: disabled ? disabledReason : void 0, className: `wf-decrypt-btn ${decrypted ? "wf-decrypt-done" : "wf-decrypt-idle"}`, children: [loading ? jsxRuntimeExports.jsx(Spinner, { size: 14 }) : decrypted ? jsxRuntimeExports.jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }), jsxRuntimeExports.jsx("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })] }) : jsxRuntimeExports.jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }), jsxRuntimeExports.jsx("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })] }), loading ? "Decrypting…" : decrypted ? "Decrypted" : "Decrypt"] })] });
64075
64168
  }
64076
64169
  const TooltipProvider = Provider$2;
64077
64170
  const Tooltip$1 = Root3$1;
64078
64171
  const TooltipTrigger$1 = Trigger$4;
64079
64172
  const TooltipContent$1 = reactExports.forwardRef(({ className, sideOffset = 8, showArrow = true, children: children2, ...props }, ref) => jsxRuntimeExports.jsx(Portal$6, { children: jsxRuntimeExports.jsxs(Content2$4, { ref, sideOffset, className: cn$4("z-[99999] flex items-center gap-1 rounded-[10px] bg-gray-1000 px-2 py-1.5 !text-label-13 text-background-100 shadow-md select-none", className), ...props, children: [children2, showArrow ? jsxRuntimeExports.jsx(Arrow2$1, { width: 11, height: 5, className: "fill-gray-1000" }) : null] }) }));
64080
64173
  TooltipContent$1.displayName = Content2$4.displayName;
64081
- function DuplicateEventTooltip({ isDuplicate = false, children: children2 }) {
64082
- if (!isDuplicate)
64174
+ function EventNoticeTooltip({ notice, children: children2 }) {
64175
+ if (!notice)
64083
64176
  return children2;
64084
- return jsxRuntimeExports.jsx(TooltipProvider, { delayDuration: 300, children: jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: children2 }), jsxRuntimeExports.jsx(TooltipContent$1, { className: "max-w-[264px] leading-snug", collisionPadding: 8, side: "top", children: DUPLICATE_EVENT_MESSAGE })] }) });
64177
+ return jsxRuntimeExports.jsx(TooltipProvider, { delayDuration: 300, children: jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: children2 }), jsxRuntimeExports.jsx(TooltipContent$1, { className: "max-w-[264px] leading-snug", collisionPadding: 8, side: "top", children: notice })] }) });
64085
64178
  }
64086
64179
  function isStructuredError(value) {
64087
64180
  return value != null && typeof value === "object" && (typeof value.message === "string" || typeof value.stack === "string");
@@ -64106,7 +64199,7 @@ ${stack}` : body2;
64106
64199
  borderBottom: "1px solid var(--ds-red-400)"
64107
64200
  }, children: [jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4 shrink-0" }), jsxRuntimeExports.jsx("p", {
64108
64201
  className: "text-label-12 font-semibold m-0 truncate",
64109
- // The full message or stack is in the body below; the header just
64202
+ // The full message or stack is in the body below; the header
64110
64203
  // shows the first line, single-line, with overflow
64111
64204
  // ellipsised so a long title doesn't push the copy button or
64112
64205
  // wrap into the framed hint/docs lines.
@@ -64231,27 +64324,27 @@ function ZoneDateTimeRow({ date: date2, zone }) {
64231
64324
  });
64232
64325
  return jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-3", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5", children: [jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-4 px-1.5 bg-gray-200 rounded-xs", children: jsxRuntimeExports.jsx("span", { className: "text-label-12-mono text-gray-900", children: formattedZone }) }), jsxRuntimeExports.jsx("span", { className: "text-label-13 text-gray-1000", children: formattedDate })] }), jsxRuntimeExports.jsx("span", { className: "tabular-nums text-label-12-mono text-gray-900", children: formattedTime })] });
64233
64326
  }
64234
- function RelativeTimeContextCardContent({ date: date2 }) {
64327
+ function RelativeTimeContextCardContent({ date: date2, prefix }) {
64235
64328
  const localTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
64236
64329
  const timeAgo = useTimeAgo(date2);
64237
- return jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 min-w-[300px]", children: [jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-3", children: jsxRuntimeExports.jsx("span", { className: "tabular-nums text-label-13 text-gray-900", children: timeAgo }) }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx(ZoneDateTimeRow, { date: date2, zone: "UTC" }), jsxRuntimeExports.jsx(ZoneDateTimeRow, { date: date2, zone: localTimezone })] })] });
64330
+ return jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 min-w-[300px]", children: [jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-3", children: jsxRuntimeExports.jsx("span", { className: "tabular-nums text-label-13 text-gray-900", children: prefix ? `${prefix} ${timeAgo}` : timeAgo }) }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx(ZoneDateTimeRow, { date: date2, zone: "UTC" }), jsxRuntimeExports.jsx(ZoneDateTimeRow, { date: date2, zone: localTimezone })] })] });
64238
64331
  }
64239
64332
  function DefaultTimeText({ date: date2 }) {
64240
64333
  const shortTimeAgo = useShortTimeAgo(date2);
64241
64334
  return jsxRuntimeExports.jsx("span", { className: "text-label-14 text-gray-900", children: shortTimeAgo });
64242
64335
  }
64243
- function RelativeTimeCard({ date: date2, children: _children, ...props }) {
64336
+ function RelativeTimeCard({ date: date2, children: _children, prefix, ...props }) {
64244
64337
  const children2 = _children === void 0 ? jsxRuntimeExports.jsx(DefaultTimeText, { date: date2 }) : _children;
64245
64338
  if (!date2)
64246
64339
  return children2;
64247
- return jsxRuntimeExports.jsx(ContextCardTrigger, { content: jsxRuntimeExports.jsx(RelativeTimeContextCardContent, { date: date2 }), ...props, children: children2 });
64340
+ return jsxRuntimeExports.jsx(ContextCardTrigger, { content: jsxRuntimeExports.jsx(RelativeTimeContextCardContent, { date: date2, prefix }), ...props, children: children2 });
64248
64341
  }
64249
- function TimestampTooltip({ date: date2, children: children2, side = "top" }) {
64342
+ function TimestampTooltip({ date: date2, children: children2, side = "top", prefix }) {
64250
64343
  const hasProvider = useHasContextCardProvider();
64251
64344
  const ts = date2 == null ? null : typeof date2 === "number" ? date2 : new Date(date2).getTime();
64252
64345
  if (ts == null || Number.isNaN(ts))
64253
64346
  return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children2 });
64254
- const card = jsxRuntimeExports.jsx(RelativeTimeCard, { date: ts, side, asChild: true, children: children2 });
64347
+ const card = jsxRuntimeExports.jsx(RelativeTimeCard, { date: ts, side, prefix, asChild: true, children: children2 });
64255
64348
  return hasProvider ? card : jsxRuntimeExports.jsx(ContextCardProvider, { children: card });
64256
64349
  }
64257
64350
  const ERROR_EVENT_TYPES = /* @__PURE__ */ new Set([
@@ -64309,6 +64402,9 @@ function getStatusDotColor(eventType) {
64309
64402
  if (eventType === "step_started" || eventType === "run_started" || eventType === "workflow_started" || eventType === "hook_received") {
64310
64403
  return "var(--ds-blue-700)";
64311
64404
  }
64405
+ if (eventType === "noop") {
64406
+ return "var(--ds-gray-500)";
64407
+ }
64312
64408
  return "var(--ds-gray-600)";
64313
64409
  }
64314
64410
  function buildNameMaps(events2, run2) {
@@ -64318,7 +64414,7 @@ function buildNameMaps(events2, run2) {
64318
64414
  for (const event of events2) {
64319
64415
  if (event.eventType === "step_created" && event.correlationId) {
64320
64416
  const stepName = ((_a3 = event.eventData) == null ? void 0 : _a3.stepName) ?? "";
64321
- const parsed = parseStepName(String(stepName));
64417
+ const parsed = parseStepName(String(stepName)) ?? parseWorkflowName(String(stepName));
64322
64418
  correlationNameMap.set(event.correlationId, (parsed == null ? void 0 : parsed.shortName) ?? stepName);
64323
64419
  }
64324
64420
  }
@@ -64377,9 +64473,9 @@ function hasEncryptedValues(data) {
64377
64473
  return false;
64378
64474
  }
64379
64475
  function isRunLevel(eventType) {
64380
- return eventType === "run_created" || eventType === "run_started" || eventType === "run_completed" || eventType === "run_failed" || eventType === "run_cancelled" || eventType === "workflow_started" || eventType === "workflow_completed" || eventType === "workflow_failed" || // attr_set carries a dedup correlationId rather than a child entity ID,
64381
- // so it groups and labels with the run itself.
64382
- eventType === "attr_set";
64476
+ return eventType === "run_created" || eventType === "run_started" || eventType === "run_completed" || eventType === "run_failed" || eventType === "run_cancelled" || eventType === "workflow_started" || eventType === "workflow_completed" || eventType === "workflow_failed" || // attr_set and noop carry a dedup/positional correlationId rather than a
64477
+ // child entity ID, so they group and label with the run itself.
64478
+ eventType === "attr_set" || eventType === "noop";
64383
64479
  }
64384
64480
  const GUTTER_WIDTH = 36;
64385
64481
  const LANE_X = 20;
@@ -64587,6 +64683,8 @@ function EventRow$1({ event, index: index2, isFirst, isLast, isExpanded, onToggl
64587
64683
  }
64588
64684
  }, []);
64589
64685
  const rowGroupKey = isRunLevel(event.eventType) ? "__run__" : event.correlationId ?? void 0;
64686
+ const isSealed = isSealedNoopEvent(event);
64687
+ const rowNotice = isDuplicate ? DUPLICATE_EVENT_MESSAGE : isSealed ? SEALED_EVENT_MESSAGE : void 0;
64590
64688
  const statusDotColor = getStatusDotColor(event.eventType);
64591
64689
  const createdAt = new Date(event.createdAt);
64592
64690
  const occurredAt = parseEventDate(event.occurredAt);
@@ -64694,8 +64792,8 @@ function EventRow$1({ event, index: index2, isFirst, isLast, isExpanded, onToggl
64694
64792
  }, children: jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3 transition-transform", style: {
64695
64793
  color: "var(--ds-gray-900)",
64696
64794
  transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)"
64697
- } }) }), showSeparateEventOccurrenceTimestamps && jsxRuntimeExports.jsx("div", { className: "tabular-nums min-w-0 px-4", style: { color: "var(--ds-gray-900)", flex: "2 1 0%" }, children: occurredAt ? jsxRuntimeExports.jsx(TimestampTooltip, { date: occurredAt, children: jsxRuntimeExports.jsx("span", { children: formatEventTime(occurredAt) }) }) : "-" }), jsxRuntimeExports.jsx("div", { className: "tabular-nums min-w-0 px-4", style: { color: "var(--ds-gray-900)", flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(TimestampTooltip, { date: displayedCreatedAt, children: jsxRuntimeExports.jsx("span", { children: formatEventTime(displayedCreatedAt) }) }) }), jsxRuntimeExports.jsx("div", { className: "font-medium min-w-0 px-4", style: { flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(DuplicateEventTooltip, { isDuplicate, children: jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1.5", style: {
64698
- color: isDuplicate ? "var(--ds-gray-700)" : "var(--ds-gray-900)"
64795
+ } }) }), showSeparateEventOccurrenceTimestamps && jsxRuntimeExports.jsx("div", { className: "tabular-nums min-w-0 px-4", style: { color: "var(--ds-gray-900)", flex: "2 1 0%" }, children: occurredAt ? jsxRuntimeExports.jsx(TimestampTooltip, { date: occurredAt, children: jsxRuntimeExports.jsx("span", { children: formatEventTime(occurredAt) }) }) : "-" }), jsxRuntimeExports.jsx("div", { className: "tabular-nums min-w-0 px-4", style: { color: "var(--ds-gray-900)", flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(TimestampTooltip, { date: displayedCreatedAt, children: jsxRuntimeExports.jsx("span", { children: formatEventTime(displayedCreatedAt) }) }) }), jsxRuntimeExports.jsx("div", { className: "font-medium min-w-0 px-4", style: { flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(EventNoticeTooltip, { notice: rowNotice, children: jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1.5", style: {
64796
+ color: rowNotice ? "var(--ds-gray-700)" : "var(--ds-gray-900)"
64699
64797
  }, children: [jsxRuntimeExports.jsxs("span", { style: {
64700
64798
  position: "relative",
64701
64799
  display: "inline-flex",
@@ -64725,7 +64823,7 @@ function EventRow$1({ event, index: index2, isFirst, isLast, isExpanded, onToggl
64725
64823
  color: "var(--ds-red-900)"
64726
64824
  }, children: loadError }) : isLoading || loadedEventData === null && !hasAttemptedLoad && event.correlationId ? jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 p-3", children: [jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: "75%" } }), jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: "50%" } }), jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: "60%" } })] }) : jsxRuntimeExports.jsx("div", { className: "p-2 text-label-12", style: { color: "var(--ds-gray-900)" }, children: "No data" })] })] })] });
64727
64825
  }
64728
- function EventListViewInner({ events: events2, run: run2, onLoadEventData, hasMoreEvents = false, isLoadingMoreEvents = false, onLoadMoreEvents, encryptionKey, isLoading = false, sortOrder: sortOrderProp, onSortOrderChange, onDecrypt, isDecrypting = false, hasEncryptedData: hasEncryptedDataProp = false, onExactIdSearch, showSeparateEventOccurrenceTimestamps = false }) {
64826
+ function EventListViewInner({ events: events2, run: run2, onLoadEventData, hasMoreEvents = false, isLoadingMoreEvents = false, onLoadMoreEvents, encryptionKey, isLoading = false, sortOrder: sortOrderProp, onSortOrderChange, onDecrypt, isDecrypting = false, isDecryptDisabled = false, decryptDisabledReason, hasEncryptedData: hasEncryptedDataProp = false, onExactIdSearch, showSeparateEventOccurrenceTimestamps = false }) {
64729
64827
  const toast2 = useToast();
64730
64828
  const [internalSortOrder, setInternalSortOrder] = reactExports.useState("asc");
64731
64829
  const effectiveSortOrder = sortOrderProp ?? internalSortOrder;
@@ -64943,7 +65041,12 @@ function EventListViewInner({ events: events2, run: run2, onLoadEventData, hasMo
64943
65041
  if (isInitialLoad) {
64944
65042
  return jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col overflow-hidden", children: [jsxRuntimeExports.jsx("div", { style: { padding: 6 }, children: jsxRuntimeExports.jsx(Skeleton$1, { style: { height: 40, borderRadius: 6 } }) }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-0 h-10 border-b flex-shrink-0", style: { borderColor: "var(--ds-gray-alpha-200)" }, children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", style: { width: GUTTER_WIDTH } }), jsxRuntimeExports.jsx("div", { className: "w-5 flex-shrink-0" }), jsxRuntimeExports.jsx("div", { className: "min-w-0 px-4", style: { flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: 40 } }) }), jsxRuntimeExports.jsx("div", { className: "min-w-0 px-4", style: { flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: 72 } }) }), jsxRuntimeExports.jsx("div", { className: "min-w-0 px-4", style: { flex: "2 1 0%" }, children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: 44 } }) }), jsxRuntimeExports.jsx("div", { className: "min-w-0 px-4", style: { flex: "3 1 0%" }, children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: 92 } }) }), jsxRuntimeExports.jsx("div", { className: "min-w-0 px-4", style: { flex: "3 1 0%" }, children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: 60 } }) })] }), jsxRuntimeExports.jsx(RowsSkeleton, {})] });
64945
65043
  }
64946
- return jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: onDecrypt ? { onDecrypt, isDecrypting } : void 0, children: jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col overflow-hidden", children: [jsxRuntimeExports.jsx("style", { children: `@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}` }), jsxRuntimeExports.jsxs("div", { style: {
65044
+ return jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: onDecrypt ? {
65045
+ onDecrypt,
65046
+ isDecrypting,
65047
+ isDecryptDisabled,
65048
+ decryptDisabledReason
65049
+ } : void 0, children: jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col overflow-hidden", children: [jsxRuntimeExports.jsx("style", { children: `@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}` }), jsxRuntimeExports.jsxs("div", { style: {
64947
65050
  padding: 6,
64948
65051
  backgroundColor: "var(--ds-background-100)",
64949
65052
  display: "flex",
@@ -64978,7 +65081,7 @@ function EventListViewInner({ events: events2, run: run2, onLoadEventData, hasMo
64978
65081
  width: "100%",
64979
65082
  opacity: onExactIdSearch ? 1 : 0.5,
64980
65083
  cursor: onExactIdSearch ? "text" : "not-allowed"
64981
- } })] }), jsxRuntimeExports.jsx(MenuDropdown, { options: SORT_OPTIONS, value: effectiveSortOrder, onChange: handleSortOrderChange }), (hasEncryptedData || encryptionKey) && onDecrypt && jsxRuntimeExports.jsx(DecryptButton, { decrypted: !!encryptionKey, loading: isDecrypting, onClick: onDecrypt })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-0 text-label-13 font-medium h-10 border-b flex-shrink-0", style: {
65084
+ } })] }), jsxRuntimeExports.jsx(MenuDropdown, { options: SORT_OPTIONS, value: effectiveSortOrder, onChange: handleSortOrderChange }), (hasEncryptedData || encryptionKey) && onDecrypt && jsxRuntimeExports.jsx(DecryptButton, { decrypted: !!encryptionKey, loading: isDecrypting, disabled: isDecryptDisabled, disabledReason: decryptDisabledReason, onClick: onDecrypt })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-0 text-label-13 font-medium h-10 border-b flex-shrink-0", style: {
64982
65085
  borderColor: "var(--ds-gray-alpha-200)",
64983
65086
  color: "var(--ds-gray-900)",
64984
65087
  backgroundColor: "var(--ds-background-100)"
@@ -91755,7 +91858,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
91755
91858
  var et = ({ className: e, language: t, style: o, isIncomplete: n, ...s2 }) => jsxRuntimeExports.jsx("div", { className: f("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e), "data-incomplete": n || void 0, "data-language": t, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...o }, ...s2 });
91756
91859
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
91757
91860
  var ot = ({ language: e }) => jsxRuntimeExports.jsx("div", { className: "flex h-8 items-center text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: jsxRuntimeExports.jsx("span", { className: "ml-1 font-mono lowercase", children: e }) });
91758
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-B1Smd86a.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
91861
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-C6ES2Pzm.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
91759
91862
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
91760
91863
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
91761
91864
  return jsxRuntimeExports.jsx(Se.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(et, { isIncomplete: s2, language: t, children: [jsxRuntimeExports.jsx(ot, { language: t }), n ? jsxRuntimeExports.jsx("div", { className: "pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end", children: jsxRuntimeExports.jsx("div", { className: "pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur", "data-streamdown": "code-block-actions", children: n }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(Qe, { className: o, language: t, result: c, ...r2 }), children: jsxRuntimeExports.jsx(dn, { className: o, code: i, language: t, raw: c, ...r2 }) })] }) });
@@ -92077,7 +92180,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
92077
92180
  }, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
92078
92181
  };
92079
92182
  var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
92080
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CwYR558N.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
92183
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-X6IEJ8gj.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
92081
92184
  function ke(e, t) {
92082
92185
  if (!(e != null && e.position || t != null && t.position)) return true;
92083
92186
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -92835,7 +92938,7 @@ function stepToSpan(stepEvents, maxEndTime) {
92835
92938
  if (!step) {
92836
92939
  return null;
92837
92940
  }
92838
- const parsedName = parseStepName(String(step.stepName));
92941
+ const parsedName = parseStepName(String(step.stepName)) ?? parseWorkflowName(String(step.stepName));
92839
92942
  const attributes = {
92840
92943
  resource: "step",
92841
92944
  data: step
@@ -93048,7 +93151,7 @@ function buildTrace(run2, events2, now2, { isCompleteHistory = false } = {}) {
93048
93151
  const duplicateEventIds = findDuplicateEventIds(events2, {
93049
93152
  isCompleteHistory
93050
93153
  });
93051
- const actedOnEvents = duplicateEventIds.size === 0 ? events2 : events2.filter((event) => !duplicateEventIds.has(event.eventId));
93154
+ const actedOnEvents = events2.filter((event) => !duplicateEventIds.has(event.eventId) && !isSealedNoopEvent(event));
93052
93155
  const groupedEvents = groupEventsByCorrelation(actedOnEvents);
93053
93156
  const latestKnownTime = computeLatestKnownTime(actedOnEvents, run2);
93054
93157
  const { runSpan, spans } = buildSpans(run2, groupedEvents, now2, latestKnownTime);
@@ -95025,7 +95128,7 @@ const attributeToDisplayFn = {
95025
95128
  receivedCount: (value) => String(value),
95026
95129
  lastReceivedAt: localMillisecondTimeOrNull,
95027
95130
  disposedAt: localMillisecondTimeOrNull,
95028
- // Internal resume plumbing not surfaced in the UI
95131
+ // Internal resume plumbing, not surfaced in the UI
95029
95132
  resumeContext: (_value) => null,
95030
95133
  resumeId: (_value) => null,
95031
95134
  resumeCapabilities: (_value) => null,
@@ -95043,7 +95146,7 @@ const attributeToDisplayFn = {
95043
95146
  projectId: (_value) => null,
95044
95147
  environment: (_value) => null,
95045
95148
  executionContext: (_value) => null,
95046
- // Attributes string-string metadata attached to the run.
95149
+ // Attributes: string-string metadata attached to the run.
95047
95150
  // Rendered as key-value rows in its own collapsible section;
95048
95151
  // if empty/missing, hidden by the hasDisplayContent gate.
95049
95152
  attributes: (value) => {
@@ -95051,7 +95154,7 @@ const attributeToDisplayFn = {
95051
95154
  return null;
95052
95155
  return jsxRuntimeExports.jsx(RunAttributesCard, { attributes: value });
95053
95156
  },
95054
- // Dates wrapped with TimestampTooltip showing UTC/local + relative time
95157
+ // Dates: wrapped with TimestampTooltip showing UTC/local + relative time
95055
95158
  occurredAt: timestampWithTooltipOrNull,
95056
95159
  createdAt: timestampWithTooltipOrNull,
95057
95160
  startedAt: timestampWithTooltipOrNull,
@@ -95139,7 +95242,7 @@ const attributeToDisplayFn = {
95139
95242
  },
95140
95243
  // Internal encryption plumbing: the run's X25519 public key, used by
95141
95244
  // cross-run writers to seal payloads to this run. Not actionable for users
95142
- // and not secret hidden rather than rendered as 44 opaque base64 chars.
95245
+ // and not secret, so hidden rather than rendered as 44 opaque base64 chars.
95143
95246
  encryptionPublicKey: (_value) => null
95144
95247
  };
95145
95248
  const resolvableAttributes = [
@@ -95211,7 +95314,7 @@ const AttributeBlock = ({ attribute, value, isLoading, inline = false, context }
95211
95314
  }
95212
95315
  return jsxRuntimeExports.jsxs("div", { className: "relative", children: [typeof isLoading === "boolean" && isLoading && jsxRuntimeExports.jsx("div", { className: "absolute top-9 right-4", children: jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2", style: { borderColor: "var(--ds-gray-900)" } }) }), jsxRuntimeExports.jsxs("div", { className: "my-2 flex flex-col gap-0", children: [jsxRuntimeExports.jsx("span", { className: "text-label-14 text-gray-1000 font-medium first-letter:uppercase", children: attribute }), jsxRuntimeExports.jsx("span", { className: "text-label-12", style: { color: "var(--ds-gray-1000)" }, children: displayValue })] }, attribute)] });
95213
95316
  };
95214
- const AttributePanel = ({ data, moduleSpecifier, moduleSourceUrl, isLoading, error: error2, expiredAt, onStreamClick, onRunClick, onDecrypt, isDecrypting = false, resource }) => {
95317
+ const AttributePanel = ({ data, moduleSpecifier, moduleSourceUrl, isLoading, error: error2, expiredAt, onStreamClick, onRunClick, onDecrypt, isDecrypting = false, isDecryptDisabled = false, decryptDisabledReason, resource }) => {
95215
95318
  const displayData = reactExports.useMemo(() => {
95216
95319
  const result = { ...data };
95217
95320
  const execCtx = data.executionContext;
@@ -95277,6 +95380,8 @@ const AttributePanel = ({ data, moduleSpecifier, moduleSourceUrl, isLoading, err
95277
95380
  const decryptValue = onDecrypt ? {
95278
95381
  onDecrypt,
95279
95382
  isDecrypting,
95383
+ isDecryptDisabled,
95384
+ decryptDisabledReason,
95280
95385
  hasEncryptedData: outerDecryptCtx == null ? void 0 : outerDecryptCtx.hasEncryptedData
95281
95386
  } : outerDecryptCtx;
95282
95387
  return jsxRuntimeExports.jsx(ContextCardProvider, { children: jsxRuntimeExports.jsx(RunClickContext.Provider, { value: onRunClick, children: jsxRuntimeExports.jsx(StreamClickContext.Provider, { value: onStreamClick, children: jsxRuntimeExports.jsxs(DecryptClickContext.Provider, { value: decryptValue, children: [visibleBasicAttributes.length > 0 && jsxRuntimeExports.jsxs(CollapsibleRoot, { defaultOpen: true, children: [jsxRuntimeExports.jsx(CollapsibleTrigger, { children: "Metadata" }), jsxRuntimeExports.jsx(CollapsibleContent, { className: "mt-0 mb-2", children: jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [orderedBasicAttributes.map((attribute) => {
@@ -95343,6 +95448,7 @@ function EventItem({ event, onLoadEventData, encryptionKey, showSeparateEventOcc
95343
95448
  setLoadedData(null);
95344
95449
  void loadEventData(true);
95345
95450
  }, [encryptionKey, loadEventData]);
95451
+ const rowNotice = isDuplicate ? DUPLICATE_EVENT_MESSAGE : isSealedNoopEvent(event) ? SEALED_EVENT_MESSAGE : void 0;
95346
95452
  const createdAt = new Date(event.createdAt);
95347
95453
  const occurredAt = parseDateValue(event.occurredAt);
95348
95454
  const displayedCreatedAt = showSeparateEventOccurrenceTimestamps ? createdAt : getEffectiveEventDate(event);
@@ -95355,7 +95461,7 @@ function EventItem({ event, onLoadEventData, encryptionKey, showSeparateEventOcc
95355
95461
  return jsxRuntimeExports.jsxs(CollapsibleRoot, { variant: "card", onOpenChange: canHaveData ? (open2) => {
95356
95462
  if (open2)
95357
95463
  handleExpand();
95358
- } : void 0, children: [jsxRuntimeExports.jsx(CollapsibleTrigger, { className: "px-3 py-2", children: jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [jsxRuntimeExports.jsx(DuplicateEventTooltip, { isDuplicate, children: jsxRuntimeExports.jsx("span", { className: `text-label-12 font-mono ${isDuplicate ? "text-gray-700" : "text-gray-1000"}`, children: event.eventType }) }), jsxRuntimeExports.jsx("span", { className: "shrink-0 text-label-13 text-gray-900", children: displayedCreatedAtTime })] }) }), jsxRuntimeExports.jsxs(CollapsibleContent, { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col bg-background-200 [&:has(+_*)]:border-b [&:has(+_*)]:border-gray-alpha-400", children: [showSeparateEventOccurrenceTimestamps && occurredAt && jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Occurred" }), jsxRuntimeExports.jsx(TimestampTooltip, { date: occurredAt, children: jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: formatEventTimestamp(occurredAt) }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Event ID" }), jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: event.eventId })] }), event.correlationId && jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Correlation ID" }), jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: event.correlationId })] })] }), isLoading && jsxRuntimeExports.jsxs("div", { className: "p-3", children: [jsxRuntimeExports.jsx(Skeleton$1, { className: "h-4 w-[35%]" }), jsxRuntimeExports.jsx(Skeleton$1, { className: "mt-2 h-4 w-[90%]" }), jsxRuntimeExports.jsx(Skeleton$1, { className: "mt-2 h-4 w-[75%]" })] }), loadError && jsxRuntimeExports.jsx(ErrorCard, { title: "Failed to load event data", details: loadError, className: "mt-2" }), displayPayload != null && jsxRuntimeExports.jsx("div", { className: "[&>div]:border-none [&>div]:rounded-none", children: jsxRuntimeExports.jsx(EventDataBlock, { eventType: event.eventType, data: displayPayload }) })] })] });
95464
+ } : void 0, children: [jsxRuntimeExports.jsx(CollapsibleTrigger, { className: "px-3 py-2", children: jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [jsxRuntimeExports.jsx(EventNoticeTooltip, { notice: rowNotice, children: jsxRuntimeExports.jsx("span", { className: `text-label-12 font-mono ${rowNotice ? "text-gray-700" : "text-gray-1000"}`, children: event.eventType }) }), jsxRuntimeExports.jsx("span", { className: "shrink-0 text-label-13 text-gray-900", children: displayedCreatedAtTime })] }) }), jsxRuntimeExports.jsxs(CollapsibleContent, { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col bg-background-200 [&:has(+_*)]:border-b [&:has(+_*)]:border-gray-alpha-400", children: [showSeparateEventOccurrenceTimestamps && occurredAt && jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Occurred" }), jsxRuntimeExports.jsx(TimestampTooltip, { date: occurredAt, children: jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: formatEventTimestamp(occurredAt) }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Event ID" }), jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: event.eventId })] }), event.correlationId && jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 py-2 px-3", children: [jsxRuntimeExports.jsx("span", { className: "text-label-12 text-gray-900", children: "Correlation ID" }), jsxRuntimeExports.jsx("span", { className: "max-w-[70%] truncate text-right text-label-12 font-mono", children: event.correlationId })] })] }), isLoading && jsxRuntimeExports.jsxs("div", { className: "p-3", children: [jsxRuntimeExports.jsx(Skeleton$1, { className: "h-4 w-[35%]" }), jsxRuntimeExports.jsx(Skeleton$1, { className: "mt-2 h-4 w-[90%]" }), jsxRuntimeExports.jsx(Skeleton$1, { className: "mt-2 h-4 w-[75%]" })] }), loadError && jsxRuntimeExports.jsx(ErrorCard, { title: "Failed to load event data", details: loadError, className: "mt-2" }), displayPayload != null && jsxRuntimeExports.jsx("div", { className: "[&>div]:border-none [&>div]:rounded-none", children: jsxRuntimeExports.jsx(EventDataBlock, { eventType: event.eventType, data: displayPayload }) })] })] });
95359
95465
  }
95360
95466
  function hasOnlyExpiredFields(data, eventType) {
95361
95467
  if (data === null || typeof data !== "object" || Array.isArray(data)) {
@@ -95550,7 +95656,7 @@ function useSelectedSpanDetail(selectedSpan, fetchSpanDetail) {
95550
95656
  function isHook(data) {
95551
95657
  return data !== null && typeof data === "object" && "hookId" in data;
95552
95658
  }
95553
- function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDetail, onWakeUpSleep, onLoadEventData, onResolveHook, encryptionKey, onDecrypt, isDecrypting = false, selectedSpan, showSeparateEventOccurrenceTimestamps = false, getModuleSourceUrl }) {
95659
+ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDetail, onWakeUpSleep, onLoadEventData, onResolveHook, encryptionKey, onDecrypt, isDecrypting = false, isDecryptDisabled = false, decryptDisabledReason, selectedSpan, showSeparateEventOccurrenceTimestamps = false, getModuleSourceUrl }) {
95554
95660
  const toast2 = useToast();
95555
95661
  const [stoppingSleep, setStoppingSleep] = reactExports.useState(false);
95556
95662
  const [showResolveHookModal, setShowResolveHookModal] = reactExports.useState(false);
@@ -95708,7 +95814,13 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
95708
95814
  return null;
95709
95815
  }
95710
95816
  const hasPendingActions = resource === "sleep" && canWakeUp || resource === "hook" && canResolveHook;
95711
- return jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col", children: [jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: onDecrypt ? { onDecrypt, isDecrypting, hasEncryptedData } : void 0, children: jsxRuntimeExports.jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-8", children: [hasPendingActions && jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded-lg border p-2", style: {
95817
+ return jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col", children: [jsxRuntimeExports.jsx(DecryptClickContext.Provider, { value: onDecrypt ? {
95818
+ onDecrypt,
95819
+ isDecrypting,
95820
+ isDecryptDisabled,
95821
+ decryptDisabledReason,
95822
+ hasEncryptedData
95823
+ } : void 0, children: jsxRuntimeExports.jsxs("div", { className: "flex-1 overflow-y-auto px-4 pb-8", children: [hasPendingActions && jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded-lg border p-2", style: {
95712
95824
  borderColor: "var(--ds-gray-300)",
95713
95825
  backgroundColor: "var(--ds-gray-100)"
95714
95826
  }, children: [jsxRuntimeExports.jsx("p", { className: "mb-2 px-1 text-label-13 font-medium uppercase tracking-wide", style: { color: "var(--ds-gray-700)" }, children: "Actions" }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [resource === "sleep" && canWakeUp && jsxRuntimeExports.jsxs("button", { type: "button", onClick: handleWakeUp, disabled: stoppingSleep, className: clsx("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-button-14", "disabled:opacity-50 disabled:cursor-not-allowed transition-colors", stoppingSleep ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), style: {
@@ -95717,7 +95829,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
95717
95829
  }, children: [jsxRuntimeExports.jsx(Zap, { className: "h-4 w-4" }), stoppingSleep ? "Waking up..." : "Wake Up Sleep"] }), resource === "hook" && canResolveHook && jsxRuntimeExports.jsxs("button", { type: "button", onClick: () => setShowResolveHookModal(true), disabled: resolvingHook, className: clsx("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-button-14", "disabled:opacity-50 disabled:cursor-not-allowed transition-colors", resolvingHook ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), style: {
95718
95830
  background: "var(--ds-gray-1000)",
95719
95831
  color: "var(--ds-background-100)"
95720
- }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, moduleSourceUrl, expiredAt: run2.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick, onRunClick, onDecrypt, isDecrypting, resource }), rawEvents && jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData, onStreamClick, onRunClick, encryptionKey, showSeparateEventOccurrenceTimestamps, duplicateEventIds: selectedSpan == null ? void 0 : selectedSpan.duplicateEventIds })] }) }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
95832
+ }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, moduleSourceUrl, expiredAt: run2.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick, onRunClick, onDecrypt, isDecrypting, isDecryptDisabled, decryptDisabledReason, resource }), rawEvents && jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData, onStreamClick, onRunClick, encryptionKey, showSeparateEventOccurrenceTimestamps, duplicateEventIds: selectedSpan == null ? void 0 : selectedSpan.duplicateEventIds })] }) }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
95721
95833
  }
95722
95834
  const ActiveSpanContext = reactExports.createContext(null);
95723
95835
  ActiveSpanContext.displayName = "ActiveSpanContext";
@@ -96013,7 +96125,7 @@ function TraceDetailPanel({ containerRef, onNavigateToSpan, onClose }) {
96013
96125
  }, [selectedSpan == null ? void 0 : selectedSpan.data, selectedSpan == null ? void 0 : selectedSpan.resource]);
96014
96126
  if (!activeSpan)
96015
96127
  return null;
96016
- return jsxRuntimeExports.jsxs("aside", { ref: asideRef, id: DETAIL_PANEL_ID, className: "relative flex flex-col h-full max-h-full shrink-0 bg-background-100 border-l border-gray-alpha-400", style: { width: panelWidth }, children: [jsxRuntimeExports.jsx(DraggableBorder, { element: asideRef, position: "left", onWidthChange: handleResize, onReset: () => handleResize(PANEL_DEFAULT_WIDTH), "aria-label": "Resize span details panel", "aria-controls": DETAIL_PANEL_ID, "aria-valuemin": PANEL_MIN_WIDTH, "aria-valuemax": panelMaxWidth, "aria-valuenow": Math.min(Math.max(Math.round(panelWidth), PANEL_MIN_WIDTH), panelMaxWidth) }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 shrink-0 px-4 py-[7.5px]", children: [jsxRuntimeExports.jsx("span", { className: "text-label-14 font-medium text-gray-1000 truncate block", children: selectedSpanName }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: jsxRuntimeExports.jsx(IconButton, { "aria-label": "Navigate up", "aria-keyshortcuts": "K", onClick: handleSelectPrev, disabled: !prevSpanId, children: jsxRuntimeExports.jsx(ChevronUp, { className: "w-4 h-4" }) }) }), prevSpanId ? jsxRuntimeExports.jsxs(TooltipContent$1, { children: ["Navigate up", jsxRuntimeExports.jsx(Kbd, { children: "K" })] }) : null] }), jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: jsxRuntimeExports.jsx(IconButton, { "aria-label": "Navigate down", "aria-keyshortcuts": "J", onClick: handleSelectNext, disabled: !nextSpanId, children: jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) }) }), nextSpanId ? jsxRuntimeExports.jsxs(TooltipContent$1, { children: ["Navigate down", jsxRuntimeExports.jsx(Kbd, { children: "J" })] }) : null] }), jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "w-px h-4 bg-gray-alpha-400 mx-1" }), jsxRuntimeExports.jsx(IconButton, { "aria-label": "Close span details", "aria-keyshortcuts": "Escape", onClick: onClose, children: jsxRuntimeExports.jsx(X$3, { className: "w-4 h-4" }) })] })] }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: jsxRuntimeExports.jsx(ErrorBoundary$1, { children: jsxRuntimeExports.jsx(EntityDetailPanel, { run: sidebar.run, onStreamClick: sidebar.onStreamClick, onRunClick: sidebar.onRunClick, fetchSpanDetail: sidebar.fetchSpanDetail, onWakeUpSleep: sidebar.onWakeUpSleep, onLoadEventData: sidebar.onLoadEventData, onResolveHook: sidebar.onResolveHook, encryptionKey: sidebar.encryptionKey, onDecrypt: sidebar.onDecrypt, isDecrypting: sidebar.isDecrypting, selectedSpan, showSeparateEventOccurrenceTimestamps: sidebar.showSeparateEventOccurrenceTimestamps, getModuleSourceUrl: sidebar.getModuleSourceUrl }) }) })] });
96128
+ return jsxRuntimeExports.jsxs("aside", { ref: asideRef, id: DETAIL_PANEL_ID, className: "relative flex flex-col h-full max-h-full shrink-0 bg-background-100 border-l border-gray-alpha-400", style: { width: panelWidth }, children: [jsxRuntimeExports.jsx(DraggableBorder, { element: asideRef, position: "left", onWidthChange: handleResize, onReset: () => handleResize(PANEL_DEFAULT_WIDTH), "aria-label": "Resize span details panel", "aria-controls": DETAIL_PANEL_ID, "aria-valuemin": PANEL_MIN_WIDTH, "aria-valuemax": panelMaxWidth, "aria-valuenow": Math.min(Math.max(Math.round(panelWidth), PANEL_MIN_WIDTH), panelMaxWidth) }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2 shrink-0 px-4 py-[7.5px]", children: [jsxRuntimeExports.jsx("span", { className: "text-label-14 font-medium text-gray-1000 truncate block", children: selectedSpanName }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: jsxRuntimeExports.jsx(IconButton, { "aria-label": "Navigate up", "aria-keyshortcuts": "K", onClick: handleSelectPrev, disabled: !prevSpanId, children: jsxRuntimeExports.jsx(ChevronUp, { className: "w-4 h-4" }) }) }), prevSpanId ? jsxRuntimeExports.jsxs(TooltipContent$1, { children: ["Navigate up", jsxRuntimeExports.jsx(Kbd, { children: "K" })] }) : null] }), jsxRuntimeExports.jsxs(Tooltip$1, { children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: jsxRuntimeExports.jsx(IconButton, { "aria-label": "Navigate down", "aria-keyshortcuts": "J", onClick: handleSelectNext, disabled: !nextSpanId, children: jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4" }) }) }), nextSpanId ? jsxRuntimeExports.jsxs(TooltipContent$1, { children: ["Navigate down", jsxRuntimeExports.jsx(Kbd, { children: "J" })] }) : null] }), jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "w-px h-4 bg-gray-alpha-400 mx-1" }), jsxRuntimeExports.jsx(IconButton, { "aria-label": "Close span details", "aria-keyshortcuts": "Escape", onClick: onClose, children: jsxRuntimeExports.jsx(X$3, { className: "w-4 h-4" }) })] })] }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: jsxRuntimeExports.jsx(ErrorBoundary$1, { children: jsxRuntimeExports.jsx(EntityDetailPanel, { run: sidebar.run, onStreamClick: sidebar.onStreamClick, onRunClick: sidebar.onRunClick, fetchSpanDetail: sidebar.fetchSpanDetail, onWakeUpSleep: sidebar.onWakeUpSleep, onLoadEventData: sidebar.onLoadEventData, onResolveHook: sidebar.onResolveHook, encryptionKey: sidebar.encryptionKey, onDecrypt: sidebar.onDecrypt, isDecrypting: sidebar.isDecrypting, isDecryptDisabled: sidebar.isDecryptDisabled, decryptDisabledReason: sidebar.decryptDisabledReason, selectedSpan, showSeparateEventOccurrenceTimestamps: sidebar.showSeparateEventOccurrenceTimestamps, getModuleSourceUrl: sidebar.getModuleSourceUrl }) }) })] });
96017
96129
  }
96018
96130
  const WorkflowIcon = () => {
96019
96131
  return jsxRuntimeExports.jsx("svg", { "aria-hidden": "true", "data-testid": "geist-icon", height: "16", strokeLinejoin: "round", viewBox: "0 0 16 16", width: "16", children: jsxRuntimeExports.jsx("path", { d: "M5.75 7L6.4209 7.33594L4.85254 10.4717C5.38789 10.771 5.75 11.3431 5.75 12V14C5.75 14.9665 4.96648 15.75 4 15.75H2C1.03352 15.75 0.25 14.9665 0.25 14V12C0.25 11.0335 1.03352 10.25 2 10.25H3.28711L5.0791 6.66504L5.75 7ZM14 10.25C14.9665 10.25 15.75 11.0335 15.75 12V14C15.75 14.9665 14.9665 15.75 14 15.75H12C11.1185 15.75 10.3909 15.098 10.2695 14.25H7V12.75H10.25V12C10.25 11.0335 11.0335 10.25 12 10.25H14ZM2 11.75C1.86192 11.75 1.75 11.8619 1.75 12V14C1.75 14.1381 1.86192 14.25 2 14.25H4C4.13808 14.25 4.25 14.1381 4.25 14V12C4.25 11.8619 4.13808 11.75 4 11.75H2ZM12 11.75C11.8619 11.75 11.75 11.8619 11.75 12V14C11.75 14.1381 11.8619 14.25 12 14.25H14C14.1381 14.25 14.25 14.1381 14.25 14V12C14.25 11.8619 14.1381 11.75 14 11.75H12ZM9 0.25C9.96649 0.25 10.75 1.03351 10.75 2V4C10.75 4.44642 10.5808 4.85197 10.3057 5.16113L12.2041 8.6416L10.8877 9.36035L8.91895 5.75H7C6.03351 5.75 5.25 4.96649 5.25 4V2C5.25 1.03351 6.03351 0.25 7 0.25H9ZM7 1.75C6.86193 1.75 6.75 1.86193 6.75 2V4C6.75 4.13807 6.86193 4.25 7 4.25H9C9.13807 4.25 9.25 4.13807 9.25 4V2C9.25 1.86193 9.13807 1.75 9 1.75H7Z", fill: "currentColor" }) });
@@ -96312,7 +96424,7 @@ const RESOURCE_CLASS_NAMES = {
96312
96424
  className: "border-green-500 bg-green-200",
96313
96425
  errorClassName: "border-red-500 bg-red-200"
96314
96426
  },
96315
- // Passive spans (hooks) stay gray matches event-list icons and the minimap.
96427
+ // Passive spans (hooks) stay gray; matches event-list icons and the minimap.
96316
96428
  hook: {
96317
96429
  className: "border-gray-500 bg-gray-200",
96318
96430
  errorClassName: "border-red-500 bg-red-200"
@@ -96510,7 +96622,8 @@ function computeSpanSegments(span) {
96510
96622
  const MARKER_EVENT_NAMES = ["hook_received", "attr_set"];
96511
96623
  function computeSpanMarkers(span) {
96512
96624
  return sortedEventMarks(span.events, MARKER_EVENT_NAMES).map((mark2) => ({
96513
- timeMs: mark2.time
96625
+ timeMs: mark2.time,
96626
+ kind: mark2.type
96514
96627
  }));
96515
96628
  }
96516
96629
  function computeOffscreenMarkers(markers, visibleStartMs, visibleEndMs) {
@@ -96640,6 +96753,10 @@ const EventList = ({ spans, activeSpanId, searchResult, onSelectSpan }) => {
96640
96753
  paddingBottom: (spans.length - end) * ROW_HEIGHT_PX
96641
96754
  }, children: spans.slice(start2, end).map((span) => jsxRuntimeExports.jsx(EventRow, { span, isSelected: span.spanId === activeSpanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelectSpan }, span.spanId)) });
96642
96755
  };
96756
+ const MARKER_KIND_PREFIX = {
96757
+ hook_received: "Hook received",
96758
+ attr_set: "Attribute set"
96759
+ };
96643
96760
  function projectMarkers(markers, visibleStartMs, visibleEndMs) {
96644
96761
  const visibleDurationMs = visibleEndMs - visibleStartMs;
96645
96762
  if (visibleDurationMs <= 0)
@@ -96651,7 +96768,8 @@ function projectMarkers(markers, visibleStartMs, visibleEndMs) {
96651
96768
  return [
96652
96769
  {
96653
96770
  leftPct: (m2.timeMs - visibleStartMs) / visibleDurationMs * 100,
96654
- timeMs: m2.timeMs
96771
+ timeMs: m2.timeMs,
96772
+ kind: m2.kind
96655
96773
  }
96656
96774
  ];
96657
96775
  });
@@ -96673,7 +96791,7 @@ function MarkerTick({ className }) {
96673
96791
  return jsxRuntimeExports.jsx("span", { className: cn$4("block w-[3px] rounded-full bg-gray-1000", className) });
96674
96792
  }
96675
96793
  function MarkerLayer({ markers }) {
96676
- return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: markers.map((m2) => jsxRuntimeExports.jsx("span", { className: "pointer-events-auto absolute top-0 bottom-0 z-10 flex w-8 -translate-x-1/2 items-center justify-center", style: { left: `clamp(8px, ${m2.leftPct}%, calc(100% - 8px))` }, children: jsxRuntimeExports.jsx(TimestampTooltip, { date: m2.timeMs, children: jsxRuntimeExports.jsx("span", { className: "flex h-6 w-8 items-center justify-center", children: jsxRuntimeExports.jsx(MarkerTick, { className: "h-3" }) }) }) }, m2.timeMs)) });
96794
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: markers.map((m2, index2) => jsxRuntimeExports.jsx("span", { className: "pointer-events-auto absolute top-0 bottom-0 z-10 flex w-8 -translate-x-1/2 items-center justify-center", style: { left: `clamp(8px, ${m2.leftPct}%, calc(100% - 8px))` }, children: jsxRuntimeExports.jsx(TimestampTooltip, { date: m2.timeMs, prefix: MARKER_KIND_PREFIX[m2.kind], children: jsxRuntimeExports.jsx("span", { className: "flex h-6 w-8 items-center justify-center", children: jsxRuntimeExports.jsx(MarkerTick, { className: "h-3" }) }) }) }, `${m2.timeMs}-${index2}`)) });
96677
96795
  }
96678
96796
  function OffscreenMarkerIndicator({ direction, count: count2, targetMs, onReveal }) {
96679
96797
  const Chevron = direction === "right" ? ArrowRight : ArrowLeft;
@@ -100182,8 +100300,8 @@ async function fetchHook$1(worldEnv, hookId, resolveData = "all") {
100182
100300
  async function cancelRun$3(worldEnv, runId) {
100183
100301
  return rpc("cancelRun", { worldEnv, runId });
100184
100302
  }
100185
- async function bulkCancelRuns$2(worldEnv, runIds) {
100186
- return rpc("bulkCancelRuns", { worldEnv, runIds });
100303
+ async function bulkCancelRuns$2(worldEnv, runIds2) {
100304
+ return rpc("bulkCancelRuns", { worldEnv, runIds: runIds2 });
100187
100305
  }
100188
100306
  async function recreateRun$2(worldEnv, runId, deploymentId) {
100189
100307
  return rpc("recreateRun", { worldEnv, runId, deploymentId });
@@ -100499,15 +100617,15 @@ function magenta(str) {
100499
100617
  return chalk.magenta(str);
100500
100618
  }
100501
100619
  class WorkflowSuspension extends Error {
100502
- constructor(stepsInput, global2) {
100503
- const steps = [...stepsInput.values()];
100620
+ constructor(itemsInput, global2) {
100621
+ const items = [...itemsInput.values()];
100504
100622
  let stepCount = 0;
100505
100623
  let hookCount = 0;
100506
100624
  let waitCount = 0;
100507
100625
  let attributeCount = 0;
100508
100626
  let hookDisposedCount = 0;
100509
100627
  let abortCount = 0;
100510
- for (const item of steps) {
100628
+ for (const item of items) {
100511
100629
  if (item.type === "step")
100512
100630
  stepCount++;
100513
100631
  else if (item.type === "hook") {
@@ -100559,6 +100677,8 @@ class WorkflowSuspension extends Error {
100559
100677
  }
100560
100678
  const description = parts.length > 0 ? `${parts.join(" and ")} ${hasOrHave} not been ${action2} yet` : "0 steps have not been run yet";
100561
100679
  super(description);
100680
+ __publicField(this, "items");
100681
+ /** @deprecated Use `items` instead. */
100562
100682
  __publicField(this, "steps");
100563
100683
  __publicField(this, "globalThis");
100564
100684
  __publicField(this, "stepCount");
@@ -100568,7 +100688,8 @@ class WorkflowSuspension extends Error {
100568
100688
  __publicField(this, "hookDisposedCount");
100569
100689
  __publicField(this, "abortCount");
100570
100690
  this.name = "WorkflowSuspension";
100571
- this.steps = steps;
100691
+ this.items = items;
100692
+ this.steps = items;
100572
100693
  this.globalThis = global2;
100573
100694
  this.stepCount = stepCount;
100574
100695
  this.hookCount = hookCount;
@@ -100752,7 +100873,6 @@ const DeploymentId = SemanticConvention$2("deployment.id");
100752
100873
  const HookToken = SemanticConvention$2("workflow.hook.token");
100753
100874
  const HookId = SemanticConvention$2("workflow.hook.id");
100754
100875
  const HookFound = SemanticConvention$2("workflow.hook.found");
100755
- const HookResilientResume = SemanticConvention$2("workflow.hook.resilient_resume");
100756
100876
  const WorkflowSuspensionState = SemanticConvention$2("workflow.suspension.state");
100757
100877
  const WorkflowSuspensionHookCount = SemanticConvention$2("workflow.suspension.hook_count");
100758
100878
  const WorkflowSuspensionStepCount = SemanticConvention$2("workflow.suspension.step_count");
@@ -100765,19 +100885,20 @@ const SerializationStoredBytes = SemanticConvention$2("workflow.serialization.st
100765
100885
  const SerializationCompressionRatio = SemanticConvention$2("workflow.serialization.compression_ratio");
100766
100886
  const SerializationGuestCodeExecutions = SemanticConvention$2("workflow.serialization.guest_code_executions");
100767
100887
  const SerializationGuestCodeDetails = SemanticConvention$2("workflow.serialization.guest_code_details");
100888
+ globalSingleton("@workflow/core//traceModeWarnings", 1, () => ({ unrecognized: /* @__PURE__ */ new Set() }));
100768
100889
  async function serializeTraceCarrier() {
100769
- const otel = await OtelApi.value;
100770
- if (!otel)
100890
+ const otel2 = await OtelApi.value;
100891
+ if (!otel2)
100771
100892
  return {};
100772
100893
  const carrier = {};
100773
- otel.propagation.inject(otel.context.active(), carrier);
100894
+ otel2.propagation.inject(otel2.context.active(), carrier);
100774
100895
  return carrier;
100775
100896
  }
100776
100897
  async function deserializeTraceCarrier(traceCarrier) {
100777
- const otel = await OtelApi.value;
100778
- if (!otel)
100898
+ const otel2 = await OtelApi.value;
100899
+ if (!otel2)
100779
100900
  return;
100780
- return otel.propagation.extract(otel.context.active(), traceCarrier);
100901
+ return otel2.propagation.extract(otel2.context.active(), traceCarrier);
100781
100902
  }
100782
100903
  const OtelApi = once$1(async () => {
100783
100904
  try {
@@ -100796,7 +100917,7 @@ const Tracer = once$1(async () => {
100796
100917
  return tracer;
100797
100918
  });
100798
100919
  let otelDiagLogged$1 = false;
100799
- function logOtelDiagnosticOnce$1(otel, tracer) {
100920
+ function logOtelDiagnosticOnce$1(otel2, tracer) {
100800
100921
  var _a3, _b2, _c2, _d2, _e2;
100801
100922
  const debugEnabled = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
100802
100923
  if (otelDiagLogged$1 || !debugEnabled)
@@ -100804,7 +100925,7 @@ function logOtelDiagnosticOnce$1(otel, tracer) {
100804
100925
  otelDiagLogged$1 = true;
100805
100926
  try {
100806
100927
  const g2 = globalThis[Symbol.for("opentelemetry.js.api.1")];
100807
- const provider = otel.trace.getTracerProvider();
100928
+ const provider = otel2.trace.getTracerProvider();
100808
100929
  const delegate = ((_a3 = provider.getDelegate) == null ? void 0 : _a3.call(provider)) ?? provider;
100809
100930
  const probe = tracer.startSpan("workflow.otel.probe.core");
100810
100931
  console.warn("[workflow:otel-diag] core", JSON.stringify({
@@ -100821,25 +100942,25 @@ function logOtelDiagnosticOnce$1(otel, tracer) {
100821
100942
  }
100822
100943
  }
100823
100944
  async function trace$2(spanName, ...args) {
100824
- const [tracer, otel] = await Promise.all([Tracer.value, OtelApi.value]);
100945
+ const [tracer, otel2] = await Promise.all([Tracer.value, OtelApi.value]);
100825
100946
  const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
100826
100947
  if (!fn2)
100827
100948
  throw new Error("Function to trace must be provided");
100828
- if (!tracer || !otel) {
100949
+ if (!tracer || !otel2) {
100829
100950
  return await fn2();
100830
100951
  }
100831
100952
  return tracer.startActiveSpan(spanName, opts, async (span) => {
100832
100953
  try {
100833
100954
  const result = await fn2(span);
100834
- span.setStatus({ code: otel.SpanStatusCode.OK });
100955
+ span.setStatus({ code: otel2.SpanStatusCode.OK });
100835
100956
  return result;
100836
100957
  } catch (e) {
100837
100958
  if (WorkflowSuspension.is(e)) {
100838
- span.setStatus({ code: otel.SpanStatusCode.OK });
100959
+ span.setStatus({ code: otel2.SpanStatusCode.OK });
100839
100960
  applyWorkflowSuspensionToSpan(e, span);
100840
100961
  } else {
100841
100962
  span.setStatus({
100842
- code: otel.SpanStatusCode.ERROR,
100963
+ code: otel2.SpanStatusCode.ERROR,
100843
100964
  message: e.message
100844
100965
  });
100845
100966
  }
@@ -100864,36 +100985,36 @@ function applyWorkflowSuspensionToSpan(error2, span) {
100864
100985
  });
100865
100986
  }
100866
100987
  async function getSpanContextForTraceCarrier(carrier) {
100867
- const [deserialized, otel] = await Promise.all([
100988
+ const [deserialized, otel2] = await Promise.all([
100868
100989
  deserializeTraceCarrier(carrier),
100869
100990
  OtelApi.value
100870
100991
  ]);
100871
- if (!deserialized || !otel)
100992
+ if (!deserialized || !otel2)
100872
100993
  return;
100873
- return otel.trace.getSpanContext(deserialized);
100994
+ return otel2.trace.getSpanContext(deserialized);
100874
100995
  }
100875
100996
  async function getActiveSpan() {
100876
- return await withOtel((otel) => otel.trace.getActiveSpan());
100997
+ return await withOtel((otel2) => otel2.trace.getActiveSpan());
100877
100998
  }
100878
100999
  async function getSpanKind$2(field) {
100879
101000
  return withOtel((x2) => x2.SpanKind[field]);
100880
101001
  }
100881
101002
  async function withOtel(fn2) {
100882
- const otel = await OtelApi.value;
100883
- if (!otel)
101003
+ const otel2 = await OtelApi.value;
101004
+ if (!otel2)
100884
101005
  return void 0;
100885
- return await fn2(otel);
101006
+ return await fn2(otel2);
100886
101007
  }
100887
101008
  async function linkToTraceCarrier(carrier) {
100888
101009
  if (!carrier)
100889
101010
  return;
100890
- const [context, otel] = await Promise.all([
101011
+ const [context, otel2] = await Promise.all([
100891
101012
  getSpanContextForTraceCarrier(carrier),
100892
101013
  OtelApi.value
100893
101014
  ]);
100894
- if (!context || !otel)
101015
+ if (!context || !otel2)
100895
101016
  return;
100896
- if (!otel.trace.isSpanContextValid(context))
101017
+ if (!otel2.trace.isSpanContextValid(context))
100897
101018
  return;
100898
101019
  return { context };
100899
101020
  }
@@ -101218,11 +101339,11 @@ async function flushablePipePerChunk(source, sink, state) {
101218
101339
  }
101219
101340
  function assertWorldSupportsRuntimeProtocol(world) {
101220
101341
  const declared = world.specVersion;
101221
- if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_CURRENT && declared <= SPEC_VERSION_MAX_SUPPORTED) {
101342
+ if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_SUPPORTS_SLOT_IDENTITY && declared <= SPEC_VERSION_MAX_SUPPORTED) {
101222
101343
  return;
101223
101344
  }
101224
101345
  const supportedVersion = declared ?? "none";
101225
- throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_CURRENT} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
101346
+ throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_SUPPORTS_SLOT_IDENTITY} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
101226
101347
  }
101227
101348
  const WorldCacheKey = Symbol.for("@workflow/world//cache");
101228
101349
  const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
@@ -101246,6 +101367,7 @@ async function getWorldLazy() {
101246
101367
  }
101247
101368
  throw new Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.");
101248
101369
  }
101370
+ const GUEST_CODE_EXECUTION_SAMPLE_LIMIT = 5;
101249
101371
  let activeStats = null;
101250
101372
  let reportedProxies = null;
101251
101373
  function withGuestCodeStats(stats2, fn2) {
@@ -101260,13 +101382,17 @@ function withGuestCodeStats(stats2, fn2) {
101260
101382
  reportedProxies = previousProxies;
101261
101383
  }
101262
101384
  }
101263
- const useStepClosureFns = /* @__PURE__ */ new WeakSet();
101385
+ const useStepClosures = globalSingleton("@workflow/core//useStepClosures.fns", 1, () => ({ fns: /* @__PURE__ */ new WeakSet() }));
101264
101386
  function isUseStepClosureFn(fn2) {
101265
- return typeof fn2 === "function" && useStepClosureFns.has(fn2);
101387
+ return typeof fn2 === "function" && useStepClosures.fns.has(fn2);
101266
101388
  }
101267
101389
  function recordGuestCode(kind, detail) {
101268
101390
  if (!activeStats)
101269
101391
  return;
101392
+ activeStats.totalExecutions = (activeStats.totalExecutions ?? activeStats.executions.length) + 1;
101393
+ if (activeStats.executions.length >= GUEST_CODE_EXECUTION_SAMPLE_LIMIT) {
101394
+ return;
101395
+ }
101270
101396
  const execution = { kind };
101271
101397
  if (detail !== void 0)
101272
101398
  execution.detail = detail;
@@ -101710,7 +101836,7 @@ function getCommonReducers(_global = globalThis) {
101710
101836
  return {
101711
101837
  ArrayBuffer: (value) => types$3.isArrayBuffer(value) && arrayBufferToBase64(value, 0, arrayBufferByteLength(value)),
101712
101838
  BigInt: (value) => (
101713
- // String(bigint) is a spec-internal numeric conversion unlike
101839
+ // String(bigint) is a spec-internal numeric conversion: unlike
101714
101840
  // `value.toString()`, it never consults BigInt.prototype.
101715
101841
  typeof value === "bigint" && String(value)
101716
101842
  ),
@@ -101830,7 +101956,7 @@ function getCommonReducers(_global = globalThis) {
101830
101956
  errors: readProperty(value, "errors")
101831
101957
  };
101832
101958
  },
101833
- // Base Error reducer catch-all for any Error instance not matched by a
101959
+ // Base Error reducer: catch-all for any Error instance not matched by a
101834
101960
  // specific subclass reducer above (including user Error subclasses without
101835
101961
  // WORKFLOW_SERIALIZE). Preserves `name` so the error's identity is retained
101836
101962
  // even though the exact class cannot be reconstructed.
@@ -101850,7 +101976,7 @@ function getCommonReducers(_global = globalThis) {
101850
101976
  Float32Array: (value) => types$3.isFloat32Array(value) && viewToBase64(value),
101851
101977
  Float64Array: (value) => types$3.isFloat64Array(value) && viewToBase64(value),
101852
101978
  // Headers is a host class injected into the sandbox, so its (shared)
101853
- // prototype is reachable from workflow code iterate through the
101979
+ // prototype is reachable from workflow code; iterate through the
101854
101980
  // boot-captured iterator instead of a live Symbol.iterator lookup.
101855
101981
  Headers: (value) => isInstanceOfPrototype(value, Headers.prototype) && headersToEntries(value),
101856
101982
  Int8Array: (value) => types$3.isInt8Array(value) && viewToBase64(value),
@@ -101971,7 +102097,7 @@ function getCommonRevivers$1(global2 = globalThis) {
101971
102097
  error2.stack = value.stack;
101972
102098
  return error2;
101973
102099
  },
101974
- // Base Error reviver used for plain Error instances and unrecognized
102100
+ // Base Error reviver: used for plain Error instances and unrecognized
101975
102101
  // Error subclasses. Preserves `name` so the error's identity is retained.
101976
102102
  Error: (value) => {
101977
102103
  const opts = "cause" in value ? { cause: value.cause } : void 0;
@@ -102413,7 +102539,7 @@ class WorkflowAbortSignal {
102413
102539
  /**
102414
102540
  * @internal Sets aborted state and fires listeners.
102415
102541
  * Called by abort() on first-run, or by the events consumer on replay.
102416
- * Idempotent second call is a no-op.
102542
+ * Idempotent: second call is a no-op.
102417
102543
  */
102418
102544
  _setAborted(reason) {
102419
102545
  if (this.aborted)
@@ -102491,7 +102617,8 @@ async function recordCompression(stats2, operation) {
102491
102617
  }
102492
102618
  }
102493
102619
  async function recordGuestCodeExecutions(stats2) {
102494
- if (stats2.executions.length === 0)
102620
+ const totalExecutions = stats2.totalExecutions ?? stats2.executions.length;
102621
+ if (totalExecutions === 0)
102495
102622
  return;
102496
102623
  try {
102497
102624
  const span = await getActiveSpan();
@@ -102501,7 +102628,7 @@ async function recordGuestCodeExecutions(stats2) {
102501
102628
  ...new Set(stats2.executions.map((e) => e.detail ? `${e.kind} (${e.detail})` : e.kind))
102502
102629
  ];
102503
102630
  span.setAttributes({
102504
- ...SerializationGuestCodeExecutions(stats2.executions.length),
102631
+ ...SerializationGuestCodeExecutions(totalExecutions),
102505
102632
  ...SerializationGuestCodeDetails(details)
102506
102633
  });
102507
102634
  } catch {
@@ -103368,7 +103495,7 @@ function getWorkflowReducers(global2 = globalThis) {
103368
103495
  return {
103369
103496
  ...getAllBaseReducers(global2),
103370
103497
  // Readable/Writable streams from within the workflow execution environment
103371
- // are simply "handles" that can be passed around to other steps.
103498
+ // are "handles" that can be passed around to other steps.
103372
103499
  ReadableStream: (value) => {
103373
103500
  if (!isInstanceOfPrototype(value, readableStreamPrototype.value))
103374
103501
  return false;
@@ -103410,7 +103537,7 @@ function getWorkflowReducers(global2 = globalThis) {
103410
103537
  }
103411
103538
  return s2;
103412
103539
  },
103413
- // AbortController/AbortSignal in workflow context just read symbols (handles).
103540
+ // AbortController/AbortSignal in workflow context: read only symbols (handles).
103414
103541
  // In the workflow VM, global.AbortController is a class but global.AbortSignal
103415
103542
  // is a plain object (not a class), so instanceof checks won't work for signals.
103416
103543
  // Detect instances by the presence of the ABORT_STREAM_NAME symbol instead.
@@ -103607,8 +103734,8 @@ function reviveAbortController(value, ops, runId) {
103607
103734
  if (value.hookToken) {
103608
103735
  const hookResume = (async () => {
103609
103736
  try {
103610
- const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => resumeHook$3);
103611
- await resumeHookFn(value.hookToken, {
103737
+ const { resumeHookDurable: resumeHookDurable2 } = await Promise.resolve().then(() => resumeHook$3);
103738
+ await resumeHookDurable2(value.hookToken, {
103612
103739
  aborted: true,
103613
103740
  reason
103614
103741
  });
@@ -103767,7 +103894,7 @@ function getWorkflowRevivers(global2 = globalThis) {
103767
103894
  }
103768
103895
  return value;
103769
103896
  },
103770
- // Workflow function reviver for workflow context returns a function-like
103897
+ // Workflow function reviver for workflow context: returns a function-like
103771
103898
  // object with .workflowId that mimics what the SWC compiler produces,
103772
103899
  WorkflowFunction: (value) => Object.assign(() => {
103773
103900
  throw new SerializationError("Workflow functions cannot be called directly. Use start() to invoke them.", {
@@ -103800,7 +103927,7 @@ function getWorkflowRevivers(global2 = globalThis) {
103800
103927
  // that when the handle is later passed to a step (which reads
103801
103928
  // the actual bytes from the server) we know whether to unframe.
103802
103929
  // Defaults to undefined for streams whose serialized ref didn't
103803
- // carry the field those are treated as legacy raw bytes.
103930
+ // carry the field; those are treated as legacy raw bytes.
103804
103931
  [STREAM_FRAMING_SYMBOL]: {
103805
103932
  value: value.framing,
103806
103933
  writable: false
@@ -103837,9 +103964,9 @@ function getWorkflowRevivers(global2 = globalThis) {
103837
103964
  // AbortController/AbortSignal revived inside the workflow VM. Use the
103838
103965
  // real WorkflowAbortSignal class so addEventListener('abort', fn) actually
103839
103966
  // fires when the signal aborts (the previous no-op stub silently dropped
103840
- // listener registrations silent correctness bug for natural patterns
103967
+ // listener registrations, a silent correctness bug for natural patterns
103841
103968
  // like `signal.addEventListener('abort', fn)` after receiving a deserialized
103842
- // signal). The signal does not own a hook subscription here abort state
103969
+ // signal). The signal does not own a hook subscription here; abort state
103843
103970
  // is delivered via the existing replay machinery on the source side.
103844
103971
  AbortController: (value) => {
103845
103972
  const signal = new WorkflowAbortSignal(value.streamName, value.hookToken);
@@ -103876,7 +104003,7 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
103876
104003
  // arrow steps). The wrapper invokes the body via
103877
104004
  // `stepFn.apply(boundThis, args)` so the body sees the same
103878
104005
  // `this` it would have had in the workflow bundle. Property
103879
- // presence not truthiness is significant because
104006
+ // presence, not truthiness, is significant because
103880
104007
  // `bind(null)` and `bind(undefined)` are both legal and should
103881
104008
  // round-trip faithfully.
103882
104009
  // - `boundArgs`: prefilled args from
@@ -104192,8 +104319,13 @@ function getStreamAndRequestRevivers(allRevivers) {
104192
104319
  }
104193
104320
  return extra;
104194
104321
  }
104195
- `cinst_${ulid$3()}`;
104196
- const version$1 = "5.0.0-beta.43";
104322
+ `cinst_${ulid$1()}`;
104323
+ globalSingleton("@workflow/core//envWarnings", 1, () => ({
104324
+ replayTimeoutValues: /* @__PURE__ */ new Set(),
104325
+ maxInlineStepsValues: /* @__PURE__ */ new Set(),
104326
+ maxEventsValues: /* @__PURE__ */ new Set()
104327
+ }));
104328
+ const version$1 = "5.0.0-beta.46";
104197
104329
  const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
104198
104330
  const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
104199
104331
  function getWorkflowQueueName(workflowName, namespace2) {
@@ -104350,9 +104482,9 @@ const UNWRITABLE_DIR_CODES = /* @__PURE__ */ new Set(["EROFS", "EACCES", "EPERM"
104350
104482
  function isUnwritableDirCode(code2) {
104351
104483
  return code2 !== void 0 && UNWRITABLE_DIR_CODES.has(code2);
104352
104484
  }
104353
- let warnedAboutVercelDeployment = false;
104485
+ const warnings = globalSingleton("@workflow/world-local//buildTargetWarnings", 1, () => ({ warnedAboutVercelDeployment: false }));
104354
104486
  function warnIfRunningInVercelDeployment(dataDir) {
104355
- if (warnedAboutVercelDeployment || !process.env.VERCEL_DEPLOYMENT_ID) {
104487
+ if (warnings.warnedAboutVercelDeployment || !process.env.VERCEL_DEPLOYMENT_ID) {
104356
104488
  return;
104357
104489
  }
104358
104490
  const resolvedDataDir = path$3.resolve(dataDir);
@@ -104360,7 +104492,7 @@ function warnIfRunningInVercelDeployment(dataDir) {
104360
104492
  if (resolvedDataDir === tmp || resolvedDataDir.startsWith(`${tmp}${path$3.sep}`)) {
104361
104493
  return;
104362
104494
  }
104363
- warnedAboutVercelDeployment = true;
104495
+ warnings.warnedAboutVercelDeployment = true;
104364
104496
  console.warn(`[workflow] Warning: the local (filesystem) world is running inside a Vercel deployment, writing to ${resolvedDataDir}. That filesystem is read-only, so workflow runs will fail before their first step. ` + SELECT_VERCEL_WORLD_ADVICE);
104365
104497
  }
104366
104498
  function parsePort$2(value, radix = 10) {
@@ -104635,7 +104767,16 @@ async function resolveBaseUrl$1(config2) {
104635
104767
  }
104636
104768
  throw new Error("Unable to resolve base URL for workflow queue.");
104637
104769
  }
104638
- const ulid$2 = monotonicFactory(() => Math.random());
104770
+ const fsState = globalSingleton("@workflow/world-local//fs", 1, () => ({
104771
+ ulid: monotonicFactory(() => Math.random()),
104772
+ // In-memory cache of created files to avoid expensive fs.access() calls.
104773
+ // Safe because we only write once per file path (no overwrites without an
104774
+ // explicit flag).
104775
+ createdFilesCache: /* @__PURE__ */ new Set(),
104776
+ // Writes repeatedly target a small fixed set of entity directories. Once one
104777
+ // exists in this process, avoid another recursive mkdir syscall per event.
104778
+ createdDirectoriesCache: /* @__PURE__ */ new Set()
104779
+ }));
104639
104780
  function truncateForError(value) {
104640
104781
  const s2 = typeof value === "string" ? value : String(value);
104641
104782
  const MAX = 48;
@@ -104682,11 +104823,9 @@ async function withWindowsRetry(fn2, maxRetries = 5) {
104682
104823
  }
104683
104824
  throw new Error("Retry loop exited unexpectedly");
104684
104825
  }
104685
- const createdFilesCache = /* @__PURE__ */ new Set();
104686
- const createdDirectoriesCache = /* @__PURE__ */ new Set();
104687
104826
  function clearCreatedFilesCache() {
104688
- createdFilesCache.clear();
104689
- createdDirectoriesCache.clear();
104827
+ fsState.createdFilesCache.clear();
104828
+ fsState.createdDirectoriesCache.clear();
104690
104829
  }
104691
104830
  const TAG_PATTERN = /\.[a-zA-Z][a-zA-Z0-9-]*$/;
104692
104831
  function stripTag(fileId) {
@@ -104740,12 +104879,12 @@ async function listTaggedFilesByExtension(dirPath, tag, extension2) {
104740
104879
  }
104741
104880
  async function ensureDir(dirPath) {
104742
104881
  const resolvedPath = path$3.resolve(dirPath);
104743
- if (createdDirectoriesCache.has(resolvedPath)) {
104882
+ if (fsState.createdDirectoriesCache.has(resolvedPath)) {
104744
104883
  return;
104745
104884
  }
104746
104885
  try {
104747
104886
  await promises.mkdir(resolvedPath, { recursive: true });
104748
- createdDirectoriesCache.add(resolvedPath);
104887
+ fsState.createdDirectoriesCache.add(resolvedPath);
104749
104888
  } catch (error2) {
104750
104889
  const code2 = error2.code;
104751
104890
  if (isUnwritableDirCode(code2) && !await isExistingDirectory(resolvedPath)) {
@@ -104768,7 +104907,7 @@ async function withEnsuredDirectory(dirPath, operation) {
104768
104907
  if (error2.code !== "ENOENT") {
104769
104908
  throw error2;
104770
104909
  }
104771
- createdDirectoriesCache.delete(path$3.resolve(dirPath));
104910
+ fsState.createdDirectoriesCache.delete(path$3.resolve(dirPath));
104772
104911
  await ensureDir(dirPath);
104773
104912
  return operation();
104774
104913
  }
@@ -104793,12 +104932,12 @@ async function writeJSON(filePath, data, opts) {
104793
104932
  }
104794
104933
  async function write(filePath, data, opts) {
104795
104934
  if (!(opts == null ? void 0 : opts.overwrite)) {
104796
- if (createdFilesCache.has(filePath)) {
104935
+ if (fsState.createdFilesCache.has(filePath)) {
104797
104936
  throw new EntityConflictError(`File ${filePath} already exists and 'overwrite' is false`);
104798
104937
  }
104799
104938
  try {
104800
104939
  await promises.access(filePath);
104801
- createdFilesCache.add(filePath);
104940
+ fsState.createdFilesCache.add(filePath);
104802
104941
  throw new EntityConflictError(`File ${filePath} already exists and 'overwrite' is false`);
104803
104942
  } catch (error2) {
104804
104943
  if (error2.code !== "ENOENT") {
@@ -104806,7 +104945,7 @@ async function write(filePath, data, opts) {
104806
104945
  }
104807
104946
  }
104808
104947
  }
104809
- const tempPath = `${filePath}.tmp.${ulid$2()}`;
104948
+ const tempPath = `${filePath}.tmp.${fsState.ulid()}`;
104810
104949
  let tempFileCreated = false;
104811
104950
  try {
104812
104951
  await withEnsuredDirectory(path$3.dirname(filePath), async () => {
@@ -104814,7 +104953,7 @@ async function write(filePath, data, opts) {
104814
104953
  tempFileCreated = true;
104815
104954
  await withWindowsRetry(() => promises.rename(tempPath, filePath));
104816
104955
  });
104817
- createdFilesCache.add(filePath);
104956
+ fsState.createdFilesCache.add(filePath);
104818
104957
  } catch (error2) {
104819
104958
  if (tempFileCreated) {
104820
104959
  await withWindowsRetry(() => promises.unlink(tempPath), 3).catch(() => {
@@ -104856,7 +104995,7 @@ async function deleteJSON(filePath) {
104856
104995
  }
104857
104996
  }
104858
104997
  async function writeExclusive(filePath, data) {
104859
- const tempPath = `${filePath}.tmp.${ulid$2()}`;
104998
+ const tempPath = `${filePath}.tmp.${fsState.ulid()}`;
104860
104999
  let tempFileCreated = false;
104861
105000
  try {
104862
105001
  return await withEnsuredDirectory(path$3.dirname(filePath), async () => {
@@ -105051,7 +105190,7 @@ async function paginatedFileSystemQuery(config2) {
105051
105190
  };
105052
105191
  }
105053
105192
  const PACKAGE_NAME = "@workflow/world-local";
105054
- let cachedPackageInfo = null;
105193
+ const packageInfo = globalSingleton("@workflow/world-local//packageInfo", 1, () => ({ cached: null }));
105055
105194
  function getModuleDir() {
105056
105195
  if (typeof import.meta.url === "string" && import.meta.url) {
105057
105196
  return path$3.dirname(fileURLToPath(import.meta.url));
@@ -105059,23 +105198,23 @@ function getModuleDir() {
105059
105198
  return null;
105060
105199
  }
105061
105200
  async function getPackageInfo() {
105062
- if (cachedPackageInfo) {
105063
- return cachedPackageInfo;
105201
+ if (packageInfo.cached) {
105202
+ return packageInfo.cached;
105064
105203
  }
105065
105204
  const moduleDir = getModuleDir();
105066
105205
  if (moduleDir) {
105067
105206
  try {
105068
105207
  const content2 = await readFile(path$3.join(moduleDir, "../package.json"), "utf-8");
105069
- cachedPackageInfo = JSON.parse(content2);
105070
- return cachedPackageInfo;
105208
+ packageInfo.cached = JSON.parse(content2);
105209
+ return packageInfo.cached;
105071
105210
  } catch {
105072
105211
  }
105073
105212
  }
105074
- cachedPackageInfo = {
105213
+ packageInfo.cached = {
105075
105214
  name: PACKAGE_NAME,
105076
105215
  version: "bundled"
105077
105216
  };
105078
- return cachedPackageInfo;
105217
+ return packageInfo.cached;
105079
105218
  }
105080
105219
  const VERSION_FILENAME = "version.txt";
105081
105220
  class DataDirAccessError extends Error {
@@ -105179,8 +105318,8 @@ async function readVersionFile(dataDir) {
105179
105318
  }
105180
105319
  async function writeVersionFile(dataDir, version2) {
105181
105320
  const versionFilePath = path$3.join(path$3.resolve(dataDir), VERSION_FILENAME);
105182
- const packageInfo = await getPackageInfo();
105183
- const content2 = formatVersionFile(packageInfo.name, version2);
105321
+ const packageInfo2 = await getPackageInfo();
105322
+ const content2 = formatVersionFile(packageInfo2.name, version2);
105184
105323
  await writeFile(versionFilePath, content2);
105185
105324
  }
105186
105325
  function getSuggestedDowngradeVersion(oldVersion, suggestedVersion) {
@@ -105191,8 +105330,8 @@ function getSuggestedDowngradeVersion(oldVersion, suggestedVersion) {
105191
105330
  }
105192
105331
  async function initDataDir(dataDir) {
105193
105332
  await ensureDataDir(dataDir);
105194
- const packageInfo = await getPackageInfo();
105195
- const currentVersion = parseVersion(packageInfo.version);
105333
+ const packageInfo2 = await getPackageInfo();
105334
+ const currentVersion = parseVersion(packageInfo2.version);
105196
105335
  const existingVersionInfo = await readVersionFile(dataDir);
105197
105336
  if (existingVersionInfo === null) {
105198
105337
  await writeVersionFile(dataDir, currentVersion);
@@ -105209,40 +105348,42 @@ async function initDataDir(dataDir) {
105209
105348
  const suggestedVersion = error2 instanceof DataDirVersionError ? error2.suggestedVersion : void 0;
105210
105349
  const downgradeTarget = getSuggestedDowngradeVersion(oldVersion, suggestedVersion);
105211
105350
  console.error(`[world-local] Failed to upgrade data directory from version ${formatVersion(oldVersion)} to ${formatVersion(currentVersion)}:`, error2 instanceof Error ? error2.message : error2);
105212
- console.error(`[world-local] Data is not compatible with the current version. Please downgrade to ${packageInfo.name}@${downgradeTarget}`);
105351
+ console.error(`[world-local] Data is not compatible with the current version. Please downgrade to ${packageInfo2.name}@${downgradeTarget}`);
105213
105352
  throw error2;
105214
105353
  }
105215
105354
  }
105216
- let otelApiPromise$2 = null;
105355
+ const otel$1 = globalSingleton("@workflow/world-local//telemetry", 1, () => ({
105356
+ apiPromise: null,
105357
+ tracerPromise: null
105358
+ }));
105217
105359
  async function getOtelApi$2() {
105218
- if (!otelApiPromise$2) {
105219
- otelApiPromise$2 = import("./index-CETb4fkq.js").catch(() => null);
105360
+ if (!otel$1.apiPromise) {
105361
+ otel$1.apiPromise = import("./index-CETb4fkq.js").catch(() => null);
105220
105362
  }
105221
- return otelApiPromise$2;
105363
+ return otel$1.apiPromise;
105222
105364
  }
105223
- let tracerPromise$1 = null;
105224
105365
  async function getTracer$1() {
105225
- if (!tracerPromise$1) {
105226
- tracerPromise$1 = getOtelApi$2().then((otel) => otel ? otel.trace.getTracer("workflow") : null);
105366
+ if (!otel$1.tracerPromise) {
105367
+ otel$1.tracerPromise = getOtelApi$2().then((otelApi) => otelApi ? otelApi.trace.getTracer("workflow") : null);
105227
105368
  }
105228
- return tracerPromise$1;
105369
+ return otel$1.tracerPromise;
105229
105370
  }
105230
105371
  async function trace$1(spanName, ...args) {
105231
- const [tracer, otel] = await Promise.all([getTracer$1(), getOtelApi$2()]);
105372
+ const [tracer, otel2] = await Promise.all([getTracer$1(), getOtelApi$2()]);
105232
105373
  const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
105233
105374
  if (!fn2)
105234
105375
  throw new Error("Function to trace must be provided");
105235
- if (!tracer || !otel) {
105376
+ if (!tracer || !otel2) {
105236
105377
  return await fn2();
105237
105378
  }
105238
105379
  return tracer.startActiveSpan(spanName, opts, async (span) => {
105239
105380
  try {
105240
105381
  const result = await fn2(span);
105241
- span.setStatus({ code: otel.SpanStatusCode.OK });
105382
+ span.setStatus({ code: otel2.SpanStatusCode.OK });
105242
105383
  return result;
105243
105384
  } catch (e) {
105244
105385
  span.setStatus({
105245
- code: otel.SpanStatusCode.ERROR,
105386
+ code: otel2.SpanStatusCode.ERROR,
105246
105387
  message: e.message
105247
105388
  });
105248
105389
  throw e;
@@ -105252,10 +105393,10 @@ async function trace$1(spanName, ...args) {
105252
105393
  });
105253
105394
  }
105254
105395
  async function getSpanKind$1(field) {
105255
- const otel = await getOtelApi$2();
105256
- if (!otel)
105396
+ const otel2 = await getOtelApi$2();
105397
+ if (!otel2)
105257
105398
  return void 0;
105258
- return otel.SpanKind[field];
105399
+ return otel2.SpanKind[field];
105259
105400
  }
105260
105401
  function SemanticConvention$1(...names) {
105261
105402
  return (value) => Object.fromEntries(names.map((name2) => [name2, value]));
@@ -125483,7 +125624,7 @@ function requireResponse() {
125483
125624
  var request;
125484
125625
  var hasRequiredRequest;
125485
125626
  function requireRequest() {
125486
- var _signal, _dispatcher2, _headers, _state;
125627
+ var _signal, _dispatcher, _headers, _state;
125487
125628
  if (hasRequiredRequest) return request;
125488
125629
  hasRequiredRequest = 1;
125489
125630
  const { extractBody, mixinBody, cloneBody, bodyUnusable } = requireBody();
@@ -125553,7 +125694,7 @@ function requireRequest() {
125553
125694
  /** @type {AbortSignal} */
125554
125695
  __privateAdd(this, _signal);
125555
125696
  /** @type {import('../../dispatcher/dispatcher')} */
125556
- __privateAdd(this, _dispatcher2);
125697
+ __privateAdd(this, _dispatcher);
125557
125698
  /** @type {Headers} */
125558
125699
  __privateAdd(this, _headers);
125559
125700
  __privateAdd(this, _state);
@@ -125571,7 +125712,7 @@ function requireRequest() {
125571
125712
  const baseUrl = environmentSettingsObject.settingsObject.baseUrl;
125572
125713
  let signal = null;
125573
125714
  if (typeof input === "string") {
125574
- __privateSet(this, _dispatcher2, init2.dispatcher);
125715
+ __privateSet(this, _dispatcher, init2.dispatcher);
125575
125716
  let parsedURL;
125576
125717
  try {
125577
125718
  parsedURL = new URL(input, baseUrl);
@@ -125589,7 +125730,7 @@ function requireRequest() {
125589
125730
  assert2(webidl.is.Request(input));
125590
125731
  request2 = __privateGet(input, _state);
125591
125732
  signal = __privateGet(input, _signal);
125592
- __privateSet(this, _dispatcher2, init2.dispatcher || __privateGet(input, _dispatcher2));
125733
+ __privateSet(this, _dispatcher, init2.dispatcher || __privateGet(input, _dispatcher));
125593
125734
  }
125594
125735
  const origin = environmentSettingsObject.settingsObject.origin;
125595
125736
  let window2 = "client";
@@ -125966,7 +126107,7 @@ function requireRequest() {
125966
126107
  buildAbort(acRef)
125967
126108
  );
125968
126109
  }
125969
- return fromInnerRequest(clonedRequest, __privateGet(this, _dispatcher2), ac.signal, getHeadersGuard(__privateGet(this, _headers)));
126110
+ return fromInnerRequest(clonedRequest, __privateGet(this, _dispatcher), ac.signal, getHeadersGuard(__privateGet(this, _headers)));
125970
126111
  }
125971
126112
  [nodeUtil.inspect.custom](depth, options) {
125972
126113
  if (options.depth === null) {
@@ -126004,14 +126145,14 @@ function requireRequest() {
126004
126145
  * @param {Request} request
126005
126146
  */
126006
126147
  static getRequestDispatcher(request2) {
126007
- return __privateGet(request2, _dispatcher2);
126148
+ return __privateGet(request2, _dispatcher);
126008
126149
  }
126009
126150
  /**
126010
126151
  * @param {Request} request
126011
126152
  * @param {import('../../dispatcher/dispatcher')} newDispatcher
126012
126153
  */
126013
126154
  static setRequestDispatcher(request2, newDispatcher) {
126014
- __privateSet(request2, _dispatcher2, newDispatcher);
126155
+ __privateSet(request2, _dispatcher, newDispatcher);
126015
126156
  }
126016
126157
  /**
126017
126158
  * @param {Request} request
@@ -126035,7 +126176,7 @@ function requireRequest() {
126035
126176
  }
126036
126177
  };
126037
126178
  _signal = new WeakMap();
126038
- _dispatcher2 = new WeakMap();
126179
+ _dispatcher = new WeakMap();
126039
126180
  _headers = new WeakMap();
126040
126181
  _state = new WeakMap();
126041
126182
  let Request2 = _Request;
@@ -131206,7 +131347,7 @@ ${value}`;
131206
131347
  var eventsource;
131207
131348
  var hasRequiredEventsource;
131208
131349
  function requireEventsource() {
131209
- var _events, _url2, _withCredentials, _readyState, _request, _controller, _dispatcher2, _state, _EventSource_instances, connect_fn, reconnect_fn;
131350
+ var _events, _url2, _withCredentials, _readyState, _request, _controller, _dispatcher, _state, _EventSource_instances, connect_fn, reconnect_fn;
131210
131351
  if (hasRequiredEventsource) return eventsource;
131211
131352
  hasRequiredEventsource = 1;
131212
131353
  const { pipeline } = require$$0$5;
@@ -131249,7 +131390,7 @@ function requireEventsource() {
131249
131390
  __privateAdd(this, _readyState, CONNECTING);
131250
131391
  __privateAdd(this, _request, null);
131251
131392
  __privateAdd(this, _controller, null);
131252
- __privateAdd(this, _dispatcher2);
131393
+ __privateAdd(this, _dispatcher);
131253
131394
  /**
131254
131395
  * @type {import('./eventsource-stream').eventSourceSettings}
131255
131396
  */
@@ -131265,7 +131406,7 @@ function requireEventsource() {
131265
131406
  }
131266
131407
  url2 = webidl.converters.USVString(url2);
131267
131408
  eventSourceInitDict = webidl.converters.EventSourceInitDict(eventSourceInitDict, prefix, "eventSourceInitDict");
131268
- __privateSet(this, _dispatcher2, eventSourceInitDict.node.dispatcher || eventSourceInitDict.dispatcher);
131409
+ __privateSet(this, _dispatcher, eventSourceInitDict.node.dispatcher || eventSourceInitDict.dispatcher);
131269
131410
  __privateSet(this, _state, {
131270
131411
  lastEventId: "",
131271
131412
  reconnectionTime: eventSourceInitDict.node.reconnectionTime
@@ -131387,7 +131528,7 @@ function requireEventsource() {
131387
131528
  _readyState = new WeakMap();
131388
131529
  _request = new WeakMap();
131389
131530
  _controller = new WeakMap();
131390
- _dispatcher2 = new WeakMap();
131531
+ _dispatcher = new WeakMap();
131391
131532
  _state = new WeakMap();
131392
131533
  _EventSource_instances = new WeakSet();
131393
131534
  connect_fn = function() {
@@ -131395,7 +131536,7 @@ function requireEventsource() {
131395
131536
  __privateSet(this, _readyState, CONNECTING);
131396
131537
  const fetchParams = {
131397
131538
  request: __privateGet(this, _request),
131398
- dispatcher: __privateGet(this, _dispatcher2)
131539
+ dispatcher: __privateGet(this, _dispatcher)
131399
131540
  };
131400
131541
  const processEventSourceEndOfBody = (response2) => {
131401
131542
  if (!isNetworkError(response2)) {
@@ -131984,8 +132125,8 @@ function createQueue$2(config2) {
131984
132125
  };
131985
132126
  };
131986
132127
  const getDeploymentId = async () => {
131987
- const packageInfo = await getPackageInfo();
131988
- return `dpl_local@${packageInfo.version}`;
132128
+ const packageInfo2 = await getPackageInfo();
132129
+ return `dpl_local@${packageInfo2.version}`;
131989
132130
  };
131990
132131
  return {
131991
132132
  queue,
@@ -133075,17 +133216,17 @@ function requireSignalExit() {
133075
133216
  if (typeof EE !== "function") {
133076
133217
  EE = EE.EventEmitter;
133077
133218
  }
133078
- var emitter;
133219
+ var emitter2;
133079
133220
  if (process2.__signal_exit_emitter__) {
133080
- emitter = process2.__signal_exit_emitter__;
133221
+ emitter2 = process2.__signal_exit_emitter__;
133081
133222
  } else {
133082
- emitter = process2.__signal_exit_emitter__ = new EE();
133083
- emitter.count = 0;
133084
- emitter.emitted = {};
133223
+ emitter2 = process2.__signal_exit_emitter__ = new EE();
133224
+ emitter2.count = 0;
133225
+ emitter2.emitted = {};
133085
133226
  }
133086
- if (!emitter.infinite) {
133087
- emitter.setMaxListeners(Infinity);
133088
- emitter.infinite = true;
133227
+ if (!emitter2.infinite) {
133228
+ emitter2.setMaxListeners(Infinity);
133229
+ emitter2.infinite = true;
133089
133230
  }
133090
133231
  signalExit.exports = function(cb, opts) {
133091
133232
  if (!processOk(commonjsGlobal.process)) {
@@ -133101,12 +133242,12 @@ function requireSignalExit() {
133101
133242
  ev = "afterexit";
133102
133243
  }
133103
133244
  var remove2 = function() {
133104
- emitter.removeListener(ev, cb);
133105
- if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
133245
+ emitter2.removeListener(ev, cb);
133246
+ if (emitter2.listeners("exit").length === 0 && emitter2.listeners("afterexit").length === 0) {
133106
133247
  unload();
133107
133248
  }
133108
133249
  };
133109
- emitter.on(ev, cb);
133250
+ emitter2.on(ev, cb);
133110
133251
  return remove2;
133111
133252
  };
133112
133253
  var unload = function unload2() {
@@ -133122,15 +133263,15 @@ function requireSignalExit() {
133122
133263
  });
133123
133264
  process2.emit = originalProcessEmit;
133124
133265
  process2.reallyExit = originalProcessReallyExit;
133125
- emitter.count -= 1;
133266
+ emitter2.count -= 1;
133126
133267
  };
133127
133268
  signalExit.exports.unload = unload;
133128
133269
  var emit = function emit2(event, code2, signal) {
133129
- if (emitter.emitted[event]) {
133270
+ if (emitter2.emitted[event]) {
133130
133271
  return;
133131
133272
  }
133132
- emitter.emitted[event] = true;
133133
- emitter.emit(event, code2, signal);
133273
+ emitter2.emitted[event] = true;
133274
+ emitter2.emit(event, code2, signal);
133134
133275
  };
133135
133276
  var sigListeners = {};
133136
133277
  signals2.forEach(function(sig) {
@@ -133139,7 +133280,7 @@ function requireSignalExit() {
133139
133280
  return;
133140
133281
  }
133141
133282
  var listeners = process2.listeners(sig);
133142
- if (listeners.length === emitter.count) {
133283
+ if (listeners.length === emitter2.count) {
133143
133284
  unload();
133144
133285
  emit("exit", null, sig);
133145
133286
  emit("afterexit", null, sig);
@@ -133159,7 +133300,7 @@ function requireSignalExit() {
133159
133300
  return;
133160
133301
  }
133161
133302
  loaded = true;
133162
- emitter.count += 1;
133303
+ emitter2.count += 1;
133163
133304
  signals2 = signals2.filter(function(sig) {
133164
133305
  try {
133165
133306
  process2.on(sig, sigListeners[sig]);
@@ -133798,7 +133939,8 @@ function hookRecoveryMarkerPath(basedir, token, runId, hookId) {
133798
133939
  const key = createHash("sha256").update(`${token}\0${runId}\0${hookId}`).digest("hex");
133799
133940
  return path$3.join(basedir, "hooks", "tokens", `${key}.recovery.json`);
133800
133941
  }
133801
- const monotonicUlid$1 = monotonicFactory(() => Math.random());
133942
+ const ulids = globalSingleton("@workflow/world-local//storageMonotonicUlid", 1, () => ({ next: monotonicFactory(() => Math.random()) }));
133943
+ const monotonicUlid$1 = (seedTime) => ulids.next(seedTime);
133802
133944
  const getObjectCreatedAt = (idPrefix) => {
133803
133945
  const replaceRegex = new RegExp(`^${idPrefix}_`, "g");
133804
133946
  return (filename) => {
@@ -133902,19 +134044,19 @@ async function listHookByRunMarkers(basedir, runId) {
133902
134044
  async function deleteHookByRunMarkerFile(basedir, fileId) {
133903
134045
  await deleteJSON(path$3.join(byRunDir(basedir), `${fileId}.json`));
133904
134046
  }
133905
- const ensuredBasedirs = /* @__PURE__ */ new Map();
134047
+ const hookIndex = globalSingleton("@workflow/world-local//hookIndexEnsureCache", 1, () => ({ ensuredBasedirs: /* @__PURE__ */ new Map() }));
133906
134048
  function resetHookIndexEnsureCache() {
133907
- ensuredBasedirs.clear();
134049
+ hookIndex.ensuredBasedirs.clear();
133908
134050
  }
133909
134051
  async function ensureHookIndexes(basedir) {
133910
134052
  const key = path$3.resolve(basedir);
133911
- let pending = ensuredBasedirs.get(key);
134053
+ let pending = hookIndex.ensuredBasedirs.get(key);
133912
134054
  if (!pending) {
133913
134055
  pending = ensureHookIndexesImpl(key).catch((error2) => {
133914
- ensuredBasedirs.delete(key);
134056
+ hookIndex.ensuredBasedirs.delete(key);
133915
134057
  throw error2;
133916
134058
  });
133917
- ensuredBasedirs.set(key, pending);
134059
+ hookIndex.ensuredBasedirs.set(key, pending);
133918
134060
  }
133919
134061
  return pending;
133920
134062
  }
@@ -134218,6 +134360,35 @@ async function deleteAllHooksForRun(basedir, runId) {
134218
134360
  await deleteHookByRunMarkerFile(basedir, marker.fileId);
134219
134361
  }
134220
134362
  }
134363
+ const emitter = new EventEmitter();
134364
+ emitter.setMaxListeners(0);
134365
+ const RUN_STATUS_POLL_INTERVAL_MS = 100;
134366
+ function getRunStatusPollIntervalMs() {
134367
+ return envNumber("WORKFLOW_LOCAL_RUN_STATUS_POLL_INTERVAL_MS", RUN_STATUS_POLL_INTERVAL_MS, { integer: true, min: 1 });
134368
+ }
134369
+ function signalRunTerminal(runId) {
134370
+ emitter.emit(`run:${runId}`);
134371
+ }
134372
+ function waitForRunTerminalSignal(runId, timeoutMs, signal) {
134373
+ if (timeoutMs <= 0 || (signal == null ? void 0 : signal.aborted))
134374
+ return Promise.resolve();
134375
+ return new Promise((resolve2) => {
134376
+ const key = `run:${runId}`;
134377
+ let settled = false;
134378
+ const settle = () => {
134379
+ if (settled)
134380
+ return;
134381
+ settled = true;
134382
+ clearTimeout(timer2);
134383
+ emitter.off(key, settle);
134384
+ signal == null ? void 0 : signal.removeEventListener("abort", settle);
134385
+ resolve2();
134386
+ };
134387
+ const timer2 = setTimeout(settle, timeoutMs);
134388
+ emitter.once(key, settle);
134389
+ signal == null ? void 0 : signal.addEventListener("abort", settle, { once: true });
134390
+ });
134391
+ }
134221
134392
  async function publishLegacyHookReceived(basedir, runId, eventId, serializedEvent, eventPath, currentRun) {
134222
134393
  if (isTerminalWorkflowRunStatus(currentRun.status) || await isRunTerminalCommitted(basedir, runId)) {
134223
134394
  throw new RunExpiredError(`Workflow run "${runId}" is already in a terminal state`);
@@ -134264,6 +134435,7 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
134264
134435
  };
134265
134436
  const runPath = resolveWithinBase(basedir, "runs", `${runId}.json`);
134266
134437
  await writeJSON(runPath, run2, { overwrite: true });
134438
+ signalRunTerminal(runId);
134267
134439
  await deleteAllHooksForRun(basedir, runId);
134268
134440
  return {
134269
134441
  event: void 0,
@@ -134294,9 +134466,9 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
134294
134466
  throw new Error(`Event type '${data.eventType}' not supported for legacy runs (specVersion: ${currentRun.specVersion || "undefined"}). Please upgrade 'workflow' package.`);
134295
134467
  }
134296
134468
  }
134297
- const runFileLocks = /* @__PURE__ */ new Map();
134469
+ const runLocks = globalSingleton("@workflow/world-local//runFileLocks", 1, () => ({ byKey: /* @__PURE__ */ new Map() }));
134298
134470
  function withRunFileLock(key, fn2) {
134299
- const prev = runFileLocks.get(key);
134471
+ const prev = runLocks.byKey.get(key);
134300
134472
  const taskBox = {};
134301
134473
  const task = (async () => {
134302
134474
  if (prev)
@@ -134304,13 +134476,13 @@ function withRunFileLock(key, fn2) {
134304
134476
  try {
134305
134477
  return await fn2();
134306
134478
  } finally {
134307
- if (runFileLocks.get(key) === taskBox.task) {
134308
- runFileLocks.delete(key);
134479
+ if (runLocks.byKey.get(key) === taskBox.task) {
134480
+ runLocks.byKey.delete(key);
134309
134481
  }
134310
134482
  }
134311
134483
  })();
134312
134484
  taskBox.task = task;
134313
- runFileLocks.set(key, task);
134485
+ runLocks.byKey.set(key, task);
134314
134486
  return task;
134315
134487
  }
134316
134488
  function createRunsStorage(basedir, tag) {
@@ -134325,6 +134497,29 @@ function createRunsStorage(basedir, tag) {
134325
134497
  });
134326
134498
  return {
134327
134499
  get: get2,
134500
+ /**
134501
+ * Long poll for a terminal run status. See
134502
+ * `Storage['runs'].waitForTerminalStatus`.
134503
+ *
134504
+ * Reads the run, and while it is non-terminal waits for either an
134505
+ * in-process terminal signal or the short backstop interval before
134506
+ * reading again (see `run-status-signal.ts` for why both). Returns the
134507
+ * latest snapshot once `timeoutMs` is up, whatever its status, and
134508
+ * propagates `WorkflowRunNotFoundError` exactly as `get` does.
134509
+ */
134510
+ waitForTerminalStatus: (async (id2, params) => {
134511
+ var _a3;
134512
+ const deadline = Date.now() + ((params == null ? void 0 : params.timeoutMs) ?? 0);
134513
+ while (true) {
134514
+ const run2 = await get2(id2, params);
134515
+ if (isTerminalWorkflowRunStatus(run2.status))
134516
+ return run2;
134517
+ const remainingMs = deadline - Date.now();
134518
+ if (remainingMs <= 0 || ((_a3 = params == null ? void 0 : params.signal) == null ? void 0 : _a3.aborted))
134519
+ return run2;
134520
+ await waitForRunTerminalSignal(id2, Math.min(remainingMs, getRunStatusPollIntervalMs()), params == null ? void 0 : params.signal);
134521
+ }
134522
+ }),
134328
134523
  getMany: (async (ids, params) => {
134329
134524
  const uniqueIds = [...new Set(ids)];
134330
134525
  const runs = await Promise.all(uniqueIds.map(async (id2) => {
@@ -134551,6 +134746,9 @@ async function writeRunUnderLifecycleLock(basedir, runId, tag, proposed) {
134551
134746
  await writeJSON(taggedPath(basedir, "runs", runId, tag), next2, {
134552
134747
  overwrite: true
134553
134748
  });
134749
+ if (isTerminalWorkflowRunStatus(next2.status)) {
134750
+ signalRunTerminal(runId);
134751
+ }
134554
134752
  return next2;
134555
134753
  });
134556
134754
  }
@@ -135772,7 +135970,8 @@ function createStorage$1(basedir, tag) {
135772
135970
  clearCache: () => events2.clearCache()
135773
135971
  };
135774
135972
  }
135775
- const monotonicUlid = monotonicFactory(() => Math.random());
135973
+ const chunkIds = globalSingleton("@workflow/world-local//streamerMonotonicUlid", 1, () => ({ next: monotonicFactory(() => Math.random()) }));
135974
+ const monotonicUlid = (seedTime) => chunkIds.next(seedTime);
135776
135975
  const RunStreamsSchema = object$1({
135777
135976
  streams: array$1(string$3())
135778
135977
  });
@@ -135879,12 +136078,12 @@ function createStreamer$1(basedir, tag) {
135879
136078
  async writeMulti(_runId, name2, chunks) {
135880
136079
  if (chunks.length === 0)
135881
136080
  return;
135882
- const chunkIds = chunks.map(() => `chnk_${monotonicUlid()}`);
136081
+ const chunkIds2 = chunks.map(() => `chnk_${monotonicUlid()}`);
135883
136082
  const runId = await _runId;
135884
136083
  await registerStreamForRun(runId, name2);
135885
136084
  const chunkBuffers = chunks.map((chunk) => toBuffer(chunk));
135886
136085
  const writePromises = chunkBuffers.map(async (chunkBuffer, i) => {
135887
- const chunkId = chunkIds[i];
136086
+ const chunkId = chunkIds2[i];
135888
136087
  const serialized = serializeChunk({
135889
136088
  chunk: chunkBuffer,
135890
136089
  eof: false
@@ -136153,7 +136352,7 @@ function createWorld$2(args) {
136153
136352
  const { clearCache: clearStorageCache, ...storage } = createStorage$1(mergedConfig.dataDir, tag);
136154
136353
  const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
136155
136354
  return {
136156
- specVersion: SPEC_VERSION_CURRENT,
136355
+ specVersion: mintedSpecVersion(),
136157
136356
  capabilities: {
136158
136357
  hookRetention: { active: true },
136159
136358
  // world-local deduplicates concurrent `hook_received` writes sharing a
@@ -136195,7 +136394,7 @@ function createWorld$2(args) {
136195
136394
  const basedir = mergedConfig.dataDir;
136196
136395
  const hooksDir = path$3.join(basedir, "hooks");
136197
136396
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
136198
- const { HookSchema: HookSchema2 } = await import("./index-CSsrecUx.js");
136397
+ const { HookSchema: HookSchema2 } = await import("./index-BtQfiVUN.js");
136199
136398
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
136200
136399
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
136201
136400
  if (hook == null ? void 0 : hook.token) {
@@ -136378,8 +136577,8 @@ function requireGetVercelOidcToken() {
136378
136577
  }
136379
136578
  try {
136380
136579
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
136381
- await import("./token-util-BhmVdeCX.js").then((n) => n.t),
136382
- await import("./token-COK7oHMh.js").then((n) => n.t)
136580
+ await import("./token-util-DuToe55u.js").then((n) => n.t),
136581
+ await import("./token-CrxXUTBD.js").then((n) => n.t)
136383
136582
  ]);
136384
136583
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
136385
136584
  await refreshToken(options);
@@ -136942,10 +137141,13 @@ function requireDist() {
136942
137141
  return dist;
136943
137142
  }
136944
137143
  var distExports = requireDist();
136945
- let _dispatcher;
136946
- let _streamDispatcher;
136947
- let _streamCloseDispatcher;
136948
- let _nodeHttpAgents;
137144
+ const version = "5.0.0-beta.42";
137145
+ const pools = globalSingleton("@workflow/world-vercel//httpPools", 1, () => ({
137146
+ dispatcher: void 0,
137147
+ streamDispatcher: void 0,
137148
+ streamCloseDispatcher: void 0,
137149
+ nodeHttpAgents: void 0
137150
+ }));
136949
137151
  const BASE_AGENT_OPTIONS = {
136950
137152
  connections: 8,
136951
137153
  keepAliveTimeout: 1e4
@@ -136984,11 +137186,11 @@ const RETRY_AGENT_OPTIONS = {
136984
137186
  retryAfter: true,
136985
137187
  // Retry 5xx in-process (genuine transient blips recover fast), but NOT 429.
136986
137188
  // The Vercel firewall issues a challenge as a 429: our server-to-server
136987
- // client cannot solve a challenge, so in-process retries just re-trigger it
137189
+ // client cannot solve a challenge, so in-process retries re-trigger it
136988
137190
  // ~5× per request and amplify load against an already-overloaded firewall
136989
137191
  // during an incident. Letting 429 pass through surfaces it immediately to
136990
- // makeRequest which maps it to a ThrottleError carrying the
136991
- // `x-vercel-mitigated` / `x-vercel-id` headers and the queue does the
137192
+ // makeRequest, which maps it to a ThrottleError carrying the
137193
+ // `x-vercel-mitigated` / `x-vercel-id` headers, and the queue does the
136992
137194
  // (backed-off) retry instead. This is the long-standing "let 429s pass
136993
137195
  // through" intent. (undici default is [500, 502, 503, 504, 429].)
136994
137196
  statusCodes: [500, 502, 503, 504]
@@ -137107,7 +137309,17 @@ function createDispatcherRecycler(factory, label) {
137107
137309
  }
137108
137310
  };
137109
137311
  }
137110
- const eventsRecycler = createDispatcherRecycler(() => createEventsDispatcher(), "events transport");
137312
+ const eventsRecycler = globalSingleton(
137313
+ // Version-keyed for the same reason as the WS registry in `ws-transport.ts`:
137314
+ // this holds a recycler closed over *this* copy's `createEventsDispatcher`,
137315
+ // so an unversioned key would silently apply one published version's undici
137316
+ // and HTTP/2 options, and its failure accounting, to another's requests. The
137317
+ // plain connection pools above stay unversioned: sharing a keep-alive pool
137318
+ // across copies is the point, and they hold no module-local behavior.
137319
+ `@workflow/world-vercel//eventsDispatcherRecycler@${version}`,
137320
+ 1,
137321
+ () => createDispatcherRecycler(() => createEventsDispatcher(), "events transport")
137322
+ );
137111
137323
  function noteEventsTransportOutcome(dispatcher2, error2) {
137112
137324
  eventsRecycler.note(dispatcher2, error2);
137113
137325
  }
@@ -137121,11 +137333,11 @@ function getNodeHttpAgents(config2) {
137121
137333
  return void 0;
137122
137334
  if (!isNodeHttpEnabled())
137123
137335
  return void 0;
137124
- _nodeHttpAgents ?? (_nodeHttpAgents = createNodeHttpAgents({
137336
+ pools.nodeHttpAgents ?? (pools.nodeHttpAgents = createNodeHttpAgents({
137125
137337
  maxSockets: BASE_AGENT_OPTIONS.connections,
137126
137338
  keepAliveMs: BASE_AGENT_OPTIONS.keepAliveTimeout
137127
137339
  }));
137128
- return _nodeHttpAgents;
137340
+ return pools.nodeHttpAgents;
137129
137341
  }
137130
137342
  function getDispatcher(config2) {
137131
137343
  return resolveDispatcher(config2, getDefaultDispatcher);
@@ -137165,42 +137377,45 @@ function createStreamDispatcher(retryOptions, agentOverrides) {
137165
137377
  return new undiciExports.RetryAgent(new undiciExports.Agent({ ...STREAM_AGENT_OPTIONS, ...agentOverrides }), retryOptions);
137166
137378
  }
137167
137379
  function getDefaultDispatcher() {
137168
- _dispatcher ?? (_dispatcher = makeRetryDispatcher(DEFAULT_AGENT_OPTIONS, RETRY_AGENT_OPTIONS));
137169
- return _dispatcher;
137380
+ pools.dispatcher ?? (pools.dispatcher = makeRetryDispatcher(DEFAULT_AGENT_OPTIONS, RETRY_AGENT_OPTIONS));
137381
+ return pools.dispatcher;
137170
137382
  }
137171
137383
  function getDefaultStreamDispatcher() {
137172
- _streamDispatcher ?? (_streamDispatcher = createStreamDispatcher(STREAM_RETRY_OPTIONS));
137173
- return _streamDispatcher;
137384
+ pools.streamDispatcher ?? (pools.streamDispatcher = createStreamDispatcher(STREAM_RETRY_OPTIONS));
137385
+ return pools.streamDispatcher;
137174
137386
  }
137175
137387
  function getDefaultStreamCloseDispatcher() {
137176
- _streamCloseDispatcher ?? (_streamCloseDispatcher = createStreamDispatcher(STREAM_CLOSE_RETRY_OPTIONS));
137177
- return _streamCloseDispatcher;
137388
+ pools.streamCloseDispatcher ?? (pools.streamCloseDispatcher = createStreamDispatcher(STREAM_CLOSE_RETRY_OPTIONS));
137389
+ return pools.streamCloseDispatcher;
137178
137390
  }
137179
- let otelApiPromise$1 = null;
137391
+ const otel = globalSingleton("@workflow/world-vercel//telemetry", 1, () => ({
137392
+ // Lazy load OpenTelemetry API to make it optional
137393
+ apiPromise: null,
137394
+ tracerPromise: null
137395
+ }));
137180
137396
  async function getOtelApi$1() {
137181
- if (!otelApiPromise$1) {
137182
- otelApiPromise$1 = import("./index-CETb4fkq.js").catch((error2) => {
137397
+ if (!otel.apiPromise) {
137398
+ otel.apiPromise = import("./index-CETb4fkq.js").catch((error2) => {
137183
137399
  if (typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*")) {
137184
137400
  console.warn("[workflow] @opentelemetry/api unavailable — world-vercel spans disabled:", error2 instanceof Error ? error2.message : error2);
137185
137401
  }
137186
137402
  return null;
137187
137403
  });
137188
137404
  }
137189
- return otelApiPromise$1;
137405
+ return otel.apiPromise;
137190
137406
  }
137191
- let tracerPromise = null;
137192
137407
  function workflowDebugEnabled() {
137193
137408
  return typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
137194
137409
  }
137195
137410
  let otelDiagLogged = false;
137196
- function logOtelDiagnosticOnce(otel, tracer) {
137411
+ function logOtelDiagnosticOnce(otel2, tracer) {
137197
137412
  var _a3, _b2, _c2, _d2, _e2;
137198
137413
  if (otelDiagLogged || !workflowDebugEnabled())
137199
137414
  return;
137200
137415
  otelDiagLogged = true;
137201
137416
  try {
137202
137417
  const g2 = globalThis[Symbol.for("opentelemetry.js.api.1")];
137203
- const provider = otel.trace.getTracerProvider();
137418
+ const provider = otel2.trace.getTracerProvider();
137204
137419
  const delegate = ((_a3 = provider.getDelegate) == null ? void 0 : _a3.call(provider)) ?? provider;
137205
137420
  const probe = tracer.startSpan("workflow.otel.probe.world_vercel");
137206
137421
  console.warn("[workflow:otel-diag] world-vercel", JSON.stringify({
@@ -137217,33 +137432,33 @@ function logOtelDiagnosticOnce(otel, tracer) {
137217
137432
  }
137218
137433
  }
137219
137434
  async function getTracer() {
137220
- if (!tracerPromise) {
137221
- tracerPromise = getOtelApi$1().then((otel) => {
137222
- if (!otel)
137435
+ if (!otel.tracerPromise) {
137436
+ otel.tracerPromise = getOtelApi$1().then((otelApi) => {
137437
+ if (!otelApi)
137223
137438
  return null;
137224
- const tracer = otel.trace.getTracer("workflow");
137225
- logOtelDiagnosticOnce(otel, tracer);
137439
+ const tracer = otelApi.trace.getTracer("workflow");
137440
+ logOtelDiagnosticOnce(otelApi, tracer);
137226
137441
  return tracer;
137227
137442
  });
137228
137443
  }
137229
- return tracerPromise;
137444
+ return otel.tracerPromise;
137230
137445
  }
137231
137446
  async function trace(spanName, ...args) {
137232
- const [tracer, otel] = await Promise.all([getTracer(), getOtelApi$1()]);
137447
+ const [tracer, otel2] = await Promise.all([getTracer(), getOtelApi$1()]);
137233
137448
  const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
137234
137449
  if (!fn2)
137235
137450
  throw new Error("Function to trace must be provided");
137236
- if (!tracer || !otel) {
137451
+ if (!tracer || !otel2) {
137237
137452
  return await fn2();
137238
137453
  }
137239
137454
  return tracer.startActiveSpan(spanName, opts, async (span) => {
137240
137455
  try {
137241
137456
  const result = await fn2(span);
137242
- span.setStatus({ code: otel.SpanStatusCode.OK });
137457
+ span.setStatus({ code: otel2.SpanStatusCode.OK });
137243
137458
  return result;
137244
137459
  } catch (e) {
137245
137460
  span.setStatus({
137246
- code: otel.SpanStatusCode.ERROR,
137461
+ code: otel2.SpanStatusCode.ERROR,
137247
137462
  message: e.message
137248
137463
  });
137249
137464
  throw e;
@@ -137253,17 +137468,17 @@ async function trace(spanName, ...args) {
137253
137468
  });
137254
137469
  }
137255
137470
  async function getSpanKind(field) {
137256
- const otel = await getOtelApi$1();
137257
- if (!otel)
137471
+ const otel2 = await getOtelApi$1();
137472
+ if (!otel2)
137258
137473
  return void 0;
137259
- return otel.SpanKind[field];
137474
+ return otel2.SpanKind[field];
137260
137475
  }
137261
137476
  async function injectTraceContextIntoHeaders(headers2) {
137262
- const otel = await getOtelApi$1();
137263
- if (!otel)
137477
+ const otel2 = await getOtelApi$1();
137478
+ if (!otel2)
137264
137479
  return;
137265
137480
  const carrier = {};
137266
- otel.propagation.inject(otel.context.active(), carrier);
137481
+ otel2.propagation.inject(otel2.context.active(), carrier);
137267
137482
  for (const [key, value] of Object.entries(carrier)) {
137268
137483
  headers2.set(key, value);
137269
137484
  }
@@ -137300,7 +137515,8 @@ const WorkflowWsReconnectAttempt = SemanticConvention("workflow.events.ws.reconn
137300
137515
  const REQUEST_TIMEOUT_MS = 6e4;
137301
137516
  const getRequestTimeoutMs = () => envNumber("WORKFLOW_REQUEST_TIMEOUT_MS", REQUEST_TIMEOUT_MS, {
137302
137517
  integer: true,
137303
- min: 1
137518
+ min: 1e4,
137519
+ max: 12e4
137304
137520
  });
137305
137521
  const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
137306
137522
  const DIAGNOSTIC_HEADERS = [
@@ -137502,7 +137718,6 @@ async function instrumentedFetch(opts) {
137502
137718
  return response2;
137503
137719
  });
137504
137720
  }
137505
- const version = "5.0.0-beta.39";
137506
137721
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
137507
137722
  const MAX_BODY_PARSE_RETRIES = 2;
137508
137723
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -138127,8 +138342,10 @@ function decode(taggedUlid) {
138127
138342
  region: lookupRegion(regionId)
138128
138343
  };
138129
138344
  }
138130
- const ulid$1 = monotonicFactory();
138131
- let lastRunId;
138345
+ const runIds = globalSingleton("@workflow/world-vercel//runIdFactory", 1, () => ({
138346
+ ulid: monotonicFactory(),
138347
+ lastRunId: void 0
138348
+ }));
138132
138349
  function bumpAboveMetadata(ulidStr) {
138133
138350
  const bytes = ulidToBytes(ulidStr);
138134
138351
  let i = 5;
@@ -138156,13 +138373,13 @@ function resolveRegion$1(options) {
138156
138373
  function createRunId(options) {
138157
138374
  const region = resolveRegion$1(options);
138158
138375
  const regionId = REGION_IDS[region];
138159
- let candidate = encode(ulid$1(), regionId);
138160
- if (lastRunId !== void 0) {
138161
- while (candidate <= lastRunId) {
138162
- candidate = encode(bumpAboveMetadata(lastRunId), regionId);
138376
+ let candidate = encode(runIds.ulid(), regionId);
138377
+ if (runIds.lastRunId !== void 0) {
138378
+ while (candidate <= runIds.lastRunId) {
138379
+ candidate = encode(bumpAboveMetadata(runIds.lastRunId), regionId);
138163
138380
  }
138164
138381
  }
138165
- lastRunId = candidate;
138382
+ runIds.lastRunId = candidate;
138166
138383
  return candidate;
138167
138384
  }
138168
138385
  function regionForRunId(runId) {
@@ -138182,6 +138399,14 @@ function describeRun(run2) {
138182
138399
  return { region: regionForRunId(runId) };
138183
138400
  }
138184
138401
  const KEY_BYTES = 32;
138402
+ class RunKeyFetchError extends Error {
138403
+ constructor(message2, status) {
138404
+ super(message2);
138405
+ __publicField(this, "status");
138406
+ this.name = "RunKeyFetchError";
138407
+ this.status = status;
138408
+ }
138409
+ }
138185
138410
  async function deriveRunKey(deploymentKey, projectId, runId) {
138186
138411
  if (deploymentKey.length !== KEY_BYTES) {
138187
138412
  throw new Error(`Invalid deployment key length: expected ${KEY_BYTES} bytes for AES-256, got ${deploymentKey.length} bytes`);
@@ -138229,7 +138454,7 @@ async function fetchRunKey(deploymentId, projectId, runId, options) {
138229
138454
  } catch {
138230
138455
  body2 = "<unable to read response body>";
138231
138456
  }
138232
- return new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`);
138457
+ return new RunKeyFetchError(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`, res.status);
138233
138458
  }
138234
138459
  });
138235
138460
  const data = await response2.json();
@@ -138277,7 +138502,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
138277
138502
  };
138278
138503
  }
138279
138504
  async function getDeadline() {
138280
- const { getDeadline: getDeadline2 } = await import("./index-Ck5CB_wQ.js").then((n) => n.i);
138505
+ const { getDeadline: getDeadline2 } = await import("./index-QOlZC9D-.js").then((n) => n.i);
138281
138506
  return getDeadline2();
138282
138507
  }
138283
138508
  const WORKFLOW_SERVER_SERVICE = {
@@ -138382,8 +138607,8 @@ function instrumentObject(prefix, o) {
138382
138607
  "workflow.batch.size": events2.length,
138383
138608
  // Sorted by type, so the same batch composition always renders
138384
138609
  // the same string. Map iteration is first-seen order, which
138385
- // depends on frame order a pre-claimed fold leads with a
138386
- // pair while a pure eager fold leads with its creates and an
138610
+ // depends on frame order (a pre-claimed fold leads with a
138611
+ // pair while a pure eager fold leads with its creates), and an
138387
138612
  // unstable string is not groupable as a telemetry dimension.
138388
138613
  "workflow.batch.shape": [...counts].sort(([a2], [b2]) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0).map(([type, count2]) => `${type}:${count2}`).join(",")
138389
138614
  };
@@ -142173,11 +142398,11 @@ var INJECTED_CONTEXT_HEADERS = [
142173
142398
  async function injectTraceContext(headers2, telemetry) {
142174
142399
  if (isTracePropagationDisabled()) return;
142175
142400
  if (telemetry && !telemetry.isEnabled) return;
142176
- const otel = await getOtelApi();
142177
- if (!otel) return;
142401
+ const otel2 = await getOtelApi();
142402
+ if (!otel2) return;
142178
142403
  try {
142179
142404
  const carrier = {};
142180
- otel.propagation.inject(otel.context.active(), carrier);
142405
+ otel2.propagation.inject(otel2.context.active(), carrier);
142181
142406
  for (const name2 of INJECTED_CONTEXT_HEADERS) {
142182
142407
  const value = carrier[name2];
142183
142408
  if (value !== void 0) {
@@ -142187,10 +142412,10 @@ async function injectTraceContext(headers2, telemetry) {
142187
142412
  } catch {
142188
142413
  }
142189
142414
  }
142190
- function setSpanErrorSafely(otel, span, error2) {
142415
+ function setSpanErrorSafely(otel2, span, error2) {
142191
142416
  try {
142192
142417
  span.setStatus({
142193
- code: otel.SpanStatusCode.ERROR,
142418
+ code: otel2.SpanStatusCode.ERROR,
142194
142419
  message: error2 instanceof Error ? error2.message : String(error2)
142195
142420
  });
142196
142421
  } catch {
@@ -142205,11 +142430,11 @@ function endSpanSafely(span) {
142205
142430
  async function withSendSpan(queueName, fn2, telemetry) {
142206
142431
  if (isTracePropagationDisabled()) return fn2(null);
142207
142432
  if (telemetry && !telemetry.isEnabled) return fn2(null);
142208
- const otel = await getOtelApi();
142209
- if (!otel) return fn2(null);
142433
+ const otel2 = await getOtelApi();
142434
+ if (!otel2) return fn2(null);
142210
142435
  let started = null;
142211
142436
  try {
142212
- const tracer = (telemetry == null ? void 0 : telemetry.tracer) ?? otel.trace.getTracer("@vercel/queue");
142437
+ const tracer = (telemetry == null ? void 0 : telemetry.tracer) ?? otel2.trace.getTracer("@vercel/queue");
142213
142438
  const attributes = {
142214
142439
  "messaging.system": "vercel-queue",
142215
142440
  "messaging.destination.name": queueName
@@ -142220,16 +142445,16 @@ async function withSendSpan(queueName, fn2, telemetry) {
142220
142445
  }
142221
142446
  }
142222
142447
  const span2 = tracer.startSpan("vqs.send", {
142223
- kind: otel.SpanKind.PRODUCER,
142448
+ kind: otel2.SpanKind.PRODUCER,
142224
142449
  attributes
142225
142450
  });
142226
- started = { span: span2, ctx: otel.trace.setSpan(otel.context.active(), span2) };
142451
+ started = { span: span2, ctx: otel2.trace.setSpan(otel2.context.active(), span2) };
142227
142452
  } catch {
142228
142453
  }
142229
142454
  if (!started) return fn2(null);
142230
142455
  const { span, ctx } = started;
142231
142456
  try {
142232
- return await otel.context.with(
142457
+ return await otel2.context.with(
142233
142458
  ctx,
142234
142459
  () => fn2({
142235
142460
  setMessageId(messageId) {
@@ -142241,7 +142466,7 @@ async function withSendSpan(queueName, fn2, telemetry) {
142241
142466
  })
142242
142467
  );
142243
142468
  } catch (error2) {
142244
- setSpanErrorSafely(otel, span, error2);
142469
+ setSpanErrorSafely(otel2, span, error2);
142245
142470
  throw error2;
142246
142471
  } finally {
142247
142472
  endSpanSafely(span);
@@ -142253,13 +142478,13 @@ var CONSUMER_BAGGAGE_HEADER = "x-vercel-queue-baggage";
142253
142478
  async function withConsumerSpan(headers2, fn2, telemetry) {
142254
142479
  if (isTracePropagationDisabled()) return fn2();
142255
142480
  if (telemetry && !telemetry.isEnabled) return fn2();
142256
- const otel = await getOtelApi();
142257
- if (!otel) return fn2();
142481
+ const otel2 = await getOtelApi();
142482
+ if (!otel2) return fn2();
142258
142483
  let started = null;
142259
142484
  try {
142260
142485
  const carrier = headersToCarrier(headers2);
142261
- const links = extractProducerLink(otel, carrier);
142262
- const tracer = (telemetry == null ? void 0 : telemetry.tracer) ?? otel.trace.getTracer("@vercel/queue");
142486
+ const links = extractProducerLink(otel2, carrier);
142487
+ const tracer = (telemetry == null ? void 0 : telemetry.tracer) ?? otel2.trace.getTracer("@vercel/queue");
142263
142488
  const attributes = {
142264
142489
  "messaging.system": "vercel-queue",
142265
142490
  "messaging.operation": "process"
@@ -142270,25 +142495,25 @@ async function withConsumerSpan(headers2, fn2, telemetry) {
142270
142495
  }
142271
142496
  }
142272
142497
  const span2 = tracer.startSpan("vqs.process", {
142273
- kind: otel.SpanKind.CONSUMER,
142498
+ kind: otel2.SpanKind.CONSUMER,
142274
142499
  attributes,
142275
142500
  links
142276
142501
  });
142277
- started = { span: span2, ctx: otel.trace.setSpan(otel.context.active(), span2) };
142502
+ started = { span: span2, ctx: otel2.trace.setSpan(otel2.context.active(), span2) };
142278
142503
  } catch {
142279
142504
  }
142280
142505
  if (!started) return fn2();
142281
142506
  const { span, ctx } = started;
142282
142507
  try {
142283
- return await otel.context.with(ctx, fn2);
142508
+ return await otel2.context.with(ctx, fn2);
142284
142509
  } catch (error2) {
142285
- setSpanErrorSafely(otel, span, error2);
142510
+ setSpanErrorSafely(otel2, span, error2);
142286
142511
  throw error2;
142287
142512
  } finally {
142288
142513
  endSpanSafely(span);
142289
142514
  }
142290
142515
  }
142291
- function extractProducerLink(otel, carrier) {
142516
+ function extractProducerLink(otel2, carrier) {
142292
142517
  const traceparent = carrier[CONSUMER_TRACEPARENT_HEADER];
142293
142518
  if (!traceparent) return [];
142294
142519
  const standardCarrier = { traceparent };
@@ -142296,12 +142521,12 @@ function extractProducerLink(otel, carrier) {
142296
142521
  if (tracestate) standardCarrier.tracestate = tracestate;
142297
142522
  const baggage = carrier[CONSUMER_BAGGAGE_HEADER];
142298
142523
  if (baggage) standardCarrier.baggage = baggage;
142299
- const producerCtx = otel.propagation.extract(
142300
- otel.ROOT_CONTEXT,
142524
+ const producerCtx = otel2.propagation.extract(
142525
+ otel2.ROOT_CONTEXT,
142301
142526
  standardCarrier
142302
142527
  );
142303
- const producerSpanContext = otel.trace.getSpanContext(producerCtx);
142304
- if (!producerSpanContext || !otel.trace.isSpanContextValid(producerSpanContext)) {
142528
+ const producerSpanContext = otel2.trace.getSpanContext(producerCtx);
142529
+ if (!producerSpanContext || !otel2.trace.isSpanContextValid(producerSpanContext)) {
142305
142530
  return [];
142306
142531
  }
142307
142532
  return [{ context: producerSpanContext }];
@@ -143116,7 +143341,12 @@ function missingDeploymentIdMessage(operation) {
143116
143341
  return `${operation} requires VERCEL_DEPLOYMENT_ID, which Vercel sets in every deployment, so this process is not running inside one. The Vercel world is only selected automatically when that variable is set, so it was requested explicitly here — most often by WORKFLOW_TARGET_WORLD=vercel in a process that is not a deployment, such as a production server started locally or in CI. To use the local filesystem world instead, set WORKFLOW_TARGET_WORLD=local or unset it.`;
143117
143342
  }
143118
143343
  function isWsEventsTransportEnabled() {
143119
- return process.env.WORKFLOW_EVENTS_TRANSPORT === "ws";
143344
+ var _a3;
143345
+ return ((_a3 = process.env.WORKFLOW_EVENTS_TRANSPORT) == null ? void 0 : _a3.trim().toLowerCase()) !== "http";
143346
+ }
143347
+ function isWsEventsTransportStrict() {
143348
+ const raw2 = process.env.WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT;
143349
+ return raw2 === "1" || raw2 === "true";
143120
143350
  }
143121
143351
  class CborTransport {
143122
143352
  constructor() {
@@ -143218,14 +143448,14 @@ const wsEventsChannelForInvocation = (runId, config2) => {
143218
143448
  /**
143219
143449
  * Unawaited and failure-proof: callers treat the handshake as free. The
143220
143450
  * refcount therefore rises a microtask late, so a write racing the import
143221
- * finds no channel and goes over HTTP one frame, not the invocation,
143451
+ * finds no channel and goes over HTTP: one frame, not the invocation,
143222
143452
  * since `close` awaits this same promise and so cannot release ahead of
143223
143453
  * the claim it is releasing.
143224
143454
  */
143225
143455
  open() {
143226
143456
  if (!runId || !isWsEventsTransportEnabled())
143227
143457
  return;
143228
- claim = import("./ws-transport-BCfcEhAO.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
143458
+ claim = import("./ws-transport-ByYax88V.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
143229
143459
  },
143230
143460
  /**
143231
143461
  * Awaited, unlike the open: work scheduled after the handler returns is not
@@ -143233,8 +143463,8 @@ const wsEventsChannelForInvocation = (runId, config2) => {
143233
143463
  * stops the process exiting and keeps a server invocation pinned.
143234
143464
  *
143235
143465
  * Releases the claim the open returned rather than re-resolving the run,
143236
- * which is what keeps a channel this invocation never opened a later
143237
- * invocation's, registered under the same URL after ours was evicted out
143466
+ * which is what keeps a channel this invocation never opened (a later
143467
+ * invocation's, registered under the same URL after ours was evicted) out
143238
143468
  * of reach of our release.
143239
143469
  */
143240
143470
  async close() {
@@ -143281,7 +143511,7 @@ function getHeadersFromPayload(payload) {
143281
143511
  return Object.keys(headers2).length > 0 ? headers2 : void 0;
143282
143512
  }
143283
143513
  const FLOW_TOPIC_PATTERN = /^__([a-z][a-z0-9]*_)?wkf_workflow_/;
143284
- let loggedSequentialReplays = false;
143514
+ const queueLogs = globalSingleton("@workflow/world-vercel//queueLogLatches", 1, () => ({ loggedSequentialReplays: false }));
143285
143515
  function isSequentialReplaysEnabled() {
143286
143516
  return process.env.WORKFLOW_SEQUENTIAL_REPLAYS === "1";
143287
143517
  }
@@ -143289,8 +143519,8 @@ function getPhysicalQueueName(queueName, payload) {
143289
143519
  if (!isSequentialReplaysEnabled() || !FLOW_TOPIC_PATTERN.test(queueName)) {
143290
143520
  return queueName;
143291
143521
  }
143292
- if (!loggedSequentialReplays) {
143293
- loggedSequentialReplays = true;
143522
+ if (!queueLogs.loggedSequentialReplays) {
143523
+ queueLogs.loggedSequentialReplays = true;
143294
143524
  console.warn("[workflow] WORKFLOW_SEQUENTIAL_REPLAYS=1: routing flow messages to per-run queue topics");
143295
143525
  }
143296
143526
  if ("__healthCheck" in payload && typeof payload.correlationId === "string") {
@@ -143397,7 +143627,7 @@ function createQueue$1(config2) {
143397
143627
  }, {
143398
143628
  // Without an explicit retry directive, @vercel/queue leaves failed
143399
143629
  // handler messages invisible until the default 300s visibility timeout
143400
- // expires. Start retrying quickly, then back off by delivery count
143630
+ // expires. Start retrying after 1s, then back off by delivery count
143401
143631
  // with jitter so an outage or poison message cannot hot-loop or
143402
143632
  // redrive in lockstep. Workflow handlers are event-sourced and must
143403
143633
  // remain idempotent because queue retries can happen close together.
@@ -143527,7 +143757,7 @@ const EVENT_RETRY_ELIGIBILITY = {
143527
143757
  retryable: true,
143528
143758
  reason: "correlationId constraint reuses eventId (idempotent replay)"
143529
143759
  },
143530
- // NOT safe to retry see the module comment.
143760
+ // NOT safe to retry; see the module comment.
143531
143761
  step_started: {
143532
143762
  retryable: false,
143533
143763
  reason: "unconditional attempt increment → a retry double-counts attempts"
@@ -143544,6 +143774,12 @@ const EVENT_RETRY_ELIGIBILITY = {
143544
143774
  hook_conflict: {
143545
143775
  retryable: false,
143546
143776
  reason: "server-originated; never POSTed by the SDK"
143777
+ },
143778
+ // Server-originated sealed-log filler (specVersion 7); the SDK never
143779
+ // POSTs it. The server's read path writes it to seal an abandoned slot.
143780
+ noop: {
143781
+ retryable: false,
143782
+ reason: "server-originated; never POSTed by the SDK"
143547
143783
  }
143548
143784
  };
143549
143785
  const MAX_EVENT_POST_RETRIES = 2;
@@ -143568,11 +143804,11 @@ const TRANSIENT_CODES = /* @__PURE__ */ new Set([
143568
143804
  "UND_ERR_BODY_TIMEOUT",
143569
143805
  // Names (undici/Node surface these on the error or its cause).
143570
143806
  // `TimeoutError` is our own per-request deadline (`AbortSignal.timeout` in
143571
- // makeRequest) a genuinely ambiguous failure worth retrying. We deliberately
143807
+ // makeRequest), a genuinely ambiguous failure worth retrying. We deliberately
143572
143808
  // do NOT include `AbortError`: that is how an external/caller-supplied
143573
143809
  // cancellation surfaces (makeRequest composes the caller's signal via
143574
- // `AbortSignal.any`), and re-issuing a write the caller asked to cancel
143575
- // stalling the abort by the full backoff budget would be wrong.
143810
+ // `AbortSignal.any`), and re-issuing a write the caller asked to cancel
143811
+ // (stalling the abort by the full backoff budget) would be wrong.
143576
143812
  "TimeoutError",
143577
143813
  "RequestRetryError"
143578
143814
  ]);
@@ -143924,7 +144160,7 @@ async function fetchV4(url2, init2, config2, opName, attributes) {
143924
144160
  // Repeated transport failures retire the shared events pool and the next
143925
144161
  // request builds a fresh one. undici keeps a black-holed HTTP/2 session in
143926
144162
  // service indefinitely, so without this every request routed onto it fails
143927
- // until the compute instance is recycled see noteEventsTransportOutcome.
144163
+ // until the compute instance is recycled. See noteEventsTransportOutcome.
143928
144164
  onTransportOutcome: (error2) => noteEventsTransportOutcome(dispatcher2, error2),
143929
144165
  timeoutMs: null,
143930
144166
  logLabel: opName,
@@ -143988,7 +144224,10 @@ const CreateEventV4BodySchemas = {
143988
144224
  hook_disposed: CreateEventV4BodySchema,
143989
144225
  hook_conflict: CreateEventV4BodySchema,
143990
144226
  wait_created: CreateEventV4BodySchema,
143991
- wait_completed: CreateEventV4BodySchema
144227
+ wait_completed: CreateEventV4BodySchema,
144228
+ // Never POSTed by the SDK (server-originated sealed-log filler); present
144229
+ // only because the map is exhaustive over EventType.
144230
+ noop: CreateEventV4BodySchema
143992
144231
  };
143993
144232
  const MaxEventsHeaderSchema = number$2().int().positive();
143994
144233
  const EventStreamEndSchema = object$1({
@@ -144219,11 +144458,20 @@ async function postWorkflowRunEventV4(input, responseType, config2) {
144219
144458
  ...input.optimizations !== void 0 ? StepLatencyOptimizations(input.optimizations) : {}
144220
144459
  });
144221
144460
  }
144461
+ const STRICT_WS_EVENT_TYPES = /* @__PURE__ */ new Set(["step_completed"]);
144462
+ function assertWsFallbackAllowed(eventType) {
144463
+ if (!isWsEventsTransportStrict())
144464
+ return;
144465
+ if (!STRICT_WS_EVENT_TYPES.has(eventType))
144466
+ return;
144467
+ throw new Error(`world-vercel: ${eventType} fell back to the HTTP events transport while the WS gate was on. WORKFLOW_INTERNAL_EVENTS_TRANSPORT_STRICT is set, so this is a failure rather than a silent demotion: no channel was resolvable for this run at write time.`);
144468
+ }
144222
144469
  async function createWorkflowRunEventV4(input, config2) {
144223
144470
  if (isWsEventsTransportEnabled()) {
144224
144471
  const reply = await postEventFrameOverWs(input, config2);
144225
144472
  if (reply)
144226
144473
  return decodeCreateEventResponse(reply, input.eventType);
144474
+ assertWsFallbackAllowed(input.eventType);
144227
144475
  }
144228
144476
  const response2 = await postWorkflowRunEventV4(input, "materialized", config2);
144229
144477
  const contentType = response2.headers.get("content-type");
@@ -144329,7 +144577,7 @@ function wsReplyStatus(reply, endpoint) {
144329
144577
  return status;
144330
144578
  }
144331
144579
  async function postEventFrameOverWs(input, config2) {
144332
- const { resolveWsTransport } = await import("./ws-transport-BCfcEhAO.js");
144580
+ const { resolveWsTransport } = await import("./ws-transport-ByYax88V.js");
144333
144581
  const { runId } = input;
144334
144582
  const resolved = resolveWsTransport(runId, config2);
144335
144583
  if (!resolved)
@@ -144568,25 +144816,70 @@ async function createWorkflowRunV1(data, config2) {
144568
144816
  }
144569
144817
  async function getWorkflowRun(id2, params, config2) {
144570
144818
  const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
144819
+ try {
144820
+ return await readRun(id2, { resolveData }, config2);
144821
+ } catch (error2) {
144822
+ if (error2 instanceof WorkflowWorldError && error2.status === 404) {
144823
+ throw new WorkflowRunNotFoundError(id2);
144824
+ }
144825
+ throw error2;
144826
+ }
144827
+ }
144828
+ async function readRun(id2, params, config2) {
144829
+ const { resolveData, waitMs, signal } = params;
144571
144830
  const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
144572
144831
  const searchParams = new URLSearchParams();
144573
144832
  searchParams.set("remoteRefBehavior", remoteRefBehavior);
144833
+ if (waitMs !== void 0)
144834
+ searchParams.set("waitMs", String(waitMs));
144835
+ const path2 = waitMs === void 0 ? "" : "/status";
144574
144836
  const queryString = searchParams.toString();
144575
- const endpoint = `/v2/runs/${encodeURIComponent(id2)}${queryString ? `?${queryString}` : ""}`;
144837
+ const endpoint = `/v2/runs/${encodeURIComponent(id2)}${path2}${queryString ? `?${queryString}` : ""}`;
144838
+ const run2 = await makeRequest({
144839
+ endpoint,
144840
+ options: { method: "GET", ...signal ? { signal } : {} },
144841
+ config: config2,
144842
+ retryConnectTimeout: true,
144843
+ schema: remoteRefBehavior === "lazy" ? WorkflowRunWireWithRefsSchema : WorkflowRunWireSchema
144844
+ });
144845
+ return filterRunData(run2, resolveData);
144846
+ }
144847
+ const WAIT_TIMEOUT_HEADROOM_MS = 1e4;
144848
+ const LONG_POLL_UNSUPPORTED_TTL_MS = 5 * 60 * 1e3;
144849
+ const longPoll = globalSingleton("@workflow/world-vercel//runStatusLongPollSupport", 1, () => ({ unsupportedUntilByBaseUrl: /* @__PURE__ */ new Map() }));
144850
+ function isLongPollUnusable(error2) {
144851
+ if (error2.status === 404 || error2.status === 405 || error2.status === 501) {
144852
+ return true;
144853
+ }
144854
+ if (error2.status === 504)
144855
+ return true;
144856
+ return error2.status === void 0 && (error2.code === "TIMEOUT" || error2.code === "TRANSPORT");
144857
+ }
144858
+ async function waitForWorkflowRunTerminalStatus(id2, params, config2) {
144859
+ var _a3;
144860
+ const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
144861
+ const waitMs = Math.max(0, Math.min((params == null ? void 0 : params.timeoutMs) ?? 0, getRequestTimeoutMs() - WAIT_TIMEOUT_HEADROOM_MS));
144862
+ const { baseUrl } = getHttpUrl(config2);
144863
+ const unsupportedUntil = longPoll.unsupportedUntilByBaseUrl.get(baseUrl) ?? 0;
144864
+ if (waitMs === 0 || Date.now() < unsupportedUntil) {
144865
+ return getWorkflowRun(id2, { resolveData }, config2);
144866
+ }
144576
144867
  try {
144577
- const run2 = await makeRequest({
144578
- endpoint,
144579
- options: { method: "GET" },
144580
- config: config2,
144581
- retryConnectTimeout: true,
144582
- schema: remoteRefBehavior === "lazy" ? WorkflowRunWireWithRefsSchema : WorkflowRunWireSchema
144583
- });
144584
- return filterRunData(run2, resolveData);
144868
+ return await readRun(id2, {
144869
+ resolveData,
144870
+ waitMs,
144871
+ ...(params == null ? void 0 : params.signal) ? { signal: params.signal } : {}
144872
+ }, config2);
144585
144873
  } catch (error2) {
144586
- if (error2 instanceof WorkflowWorldError && error2.status === 404) {
144587
- throw new WorkflowRunNotFoundError(id2);
144874
+ if ((_a3 = params == null ? void 0 : params.signal) == null ? void 0 : _a3.aborted) {
144875
+ throw error2;
144588
144876
  }
144589
- throw error2;
144877
+ if (!(error2 instanceof WorkflowWorldError) || !isLongPollUnusable(error2)) {
144878
+ throw error2;
144879
+ }
144880
+ const run2 = await getWorkflowRun(id2, { resolveData }, config2);
144881
+ longPoll.unsupportedUntilByBaseUrl.set(baseUrl, Date.now() + LONG_POLL_UNSUPPORTED_TTL_MS);
144882
+ return run2;
144590
144883
  }
144591
144884
  }
144592
144885
  async function getWorkflowRuns(ids, params, config2) {
@@ -144627,20 +144920,20 @@ async function cancelWorkflowRunV1(id2, params, config2) {
144627
144920
  }
144628
144921
  }
144629
144922
  async function cancelWorkflowRuns(request2, config2) {
144630
- const { runIds, cancelReason } = BulkCancelWorkflowRunsRequestSchema.parse(request2);
144923
+ const { runIds: runIds2, cancelReason } = BulkCancelWorkflowRunsRequestSchema.parse(request2);
144631
144924
  const response2 = await makeRequest({
144632
144925
  endpoint: "/v4/runs/cancel",
144633
144926
  options: { method: "POST" },
144634
- data: cancelReason !== void 0 ? { runIds, cancelReason } : { runIds },
144927
+ data: cancelReason !== void 0 ? { runIds: runIds2, cancelReason } : { runIds: runIds2 },
144635
144928
  config: config2,
144636
144929
  schema: BulkCancelWorkflowRunsResultSchema
144637
144930
  });
144638
144931
  const resultByRunId = new Map(response2.results.map((result) => [result.runId, result]));
144639
- const isBijection = resultByRunId.size === response2.results.length && response2.results.length === runIds.length && runIds.every((runId) => resultByRunId.has(runId));
144932
+ const isBijection = resultByRunId.size === response2.results.length && response2.results.length === runIds2.length && runIds2.every((runId) => resultByRunId.has(runId));
144640
144933
  if (!isBijection) {
144641
- throw new WorkflowWorldError(`Bulk cancel response did not contain exactly one result per requested run ID (requested ${runIds.length}, received ${response2.results.length}).`);
144934
+ throw new WorkflowWorldError(`Bulk cancel response did not contain exactly one result per requested run ID (requested ${runIds2.length}, received ${response2.results.length}).`);
144642
144935
  }
144643
- const orderedResults = runIds.map((runId) => resultByRunId.get(runId));
144936
+ const orderedResults = runIds2.map((runId) => resultByRunId.get(runId));
144644
144937
  return { summary: response2.summary, results: orderedResults };
144645
144938
  }
144646
144939
  const ExperimentalSetAttributesResponseSchema = object$1({
@@ -144817,15 +145110,15 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
144817
145110
  // Under slot identity this is the source of the durable createdAt, so
144818
145111
  // the caller's logical time is what every replay observes.
144819
145112
  occurredAt: occurredAt ?? /* @__PURE__ */ new Date(),
144820
- // Per-event compute attribution (pre-claimed inline starts) rides the
145113
+ // Per-event compute attribution (pre-claimed inline starts); rides the
144821
145114
  // frame meta exactly like the single POST's CreateEventParams field.
144822
145115
  ...computeInstanceId !== void 0 ? { computeInstanceId } : {},
144823
- // Batch responses carry entities for bookkeeping, not payload reads
145116
+ // Batch responses carry entities for bookkeeping, not payload reads, so
144824
145117
  // default to lazy refs unless the caller explicitly asks for resolved
144825
145118
  // data (the same `resolveData` mapping the read paths use).
144826
145119
  remoteRefBehavior: (params == null ? void 0 : params.resolveData) === "all" ? "resolve" : "lazy",
144827
145120
  // Per-write request attribution, exactly like the single POST's
144828
- // `params.requestId` → `vercelId` threading stamped per frame so
145121
+ // `params.requestId` → `vercelId` threading, stamped per frame so
144829
145122
  // batched usage facts carry the same attribution.
144830
145123
  ...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
144831
145124
  payload,
@@ -144859,7 +145152,7 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
144859
145152
  const result = await withEventPostRetry(() => createWorkflowRunEventInner(id2, data, params, config2), data.eventType, {
144860
145153
  // The atomic lazy-resume shape is deduplicated server-side by the
144861
145154
  // (runId, resumeId) claim, so its POST is idempotent-on-retry even
144862
- // though plain hook_received is not see EVENT_RETRY_ELIGIBILITY.
145155
+ // though plain hook_received is not; see EVENT_RETRY_ELIGIBILITY.
144863
145156
  idempotentHookResume: data.eventType === "hook_received" && (params == null ? void 0 : params.resumeId) !== void 0 && (params == null ? void 0 : params.resumePayloadDigest) !== void 0
144864
145157
  });
144865
145158
  if (data.eventType === "run_created" && !result.run) {
@@ -144929,13 +145222,13 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
144929
145222
  // delta on the response (events/cursor/hasMore), letting the caller
144930
145223
  // skip a follow-up events.list. Outside turbo the runtime sends this on
144931
145224
  // every write, but a server may act on only some event types (or none);
144932
- // a response without a delta just means the runtime keeps its cursor
145225
+ // a response without a delta means the runtime keeps its cursor
144933
145226
  // and fetches when it next needs to.
144934
145227
  ...(params == null ? void 0 : params.sinceCursor) ? { sinceCursor: params.sinceCursor } : {},
144935
145228
  ...(params == null ? void 0 : params.resumeId) ? { resumeId: params.resumeId } : {},
144936
145229
  ...(params == null ? void 0 : params.resumePayloadDigest) ? { resumePayloadDigest: params.resumePayloadDigest } : {},
144937
- // Resilient step dispatch re-ensure marker (step_created only). Advisory
144938
- // the server MAY refuse it with 410 → RunExpiredError as
145230
+ // Resilient step dispatch re-ensure marker (step_created only).
145231
+ // Advisory: the server MAY refuse it with 410 → RunExpiredError as
144939
145232
  // defense-in-depth when it recorded a 412 rejection for this correlation
144940
145233
  // id and no step entity exists.
144941
145234
  ...(params == null ? void 0 : params.viaStepDispatch) ? { viaStepDispatch: true } : {},
@@ -145102,6 +145395,7 @@ function createStorage(config2) {
145102
145395
  // Storage interface with namespaced methods
145103
145396
  runs: {
145104
145397
  get: ((id2, params) => getWorkflowRun(id2, params, config2)),
145398
+ waitForTerminalStatus: ((id2, params) => waitForWorkflowRunTerminalStatus(id2, params, config2)),
145105
145399
  getMany: ((ids, params) => getWorkflowRuns(ids, params, config2)),
145106
145400
  list: ((params) => listWorkflowRuns(params, config2)),
145107
145401
  experimentalSetAttributes: (runId, changes, options) => experimentalSetAttributes(runId, changes, options, config2),
@@ -145268,7 +145562,7 @@ function createStreamer(config2) {
145268
145562
  url: url2.toString(),
145269
145563
  headers: httpConfig.headers,
145270
145564
  // Close is idempotent (unlike chunk appends), so its dispatcher
145271
- // retries 5xx required by the server's close-barrier protocol,
145565
+ // retries 5xx, as required by the server's close-barrier protocol,
145272
145566
  // which surfaces transient reconciliation states as retriable
145273
145567
  // 503s with the stream left durably closing.
145274
145568
  dispatcher: getStreamCloseDispatcher(config2),
@@ -145367,7 +145661,7 @@ function createWorld$1(config2) {
145367
145661
  // version that introduced slots: a bump has to move this declaration with
145368
145662
  // it, or the runtime's compatibility floor rises past the adapter shipped
145369
145663
  // alongside it and rejects it (see `assertWorldSupportsRuntimeProtocol`).
145370
- specVersion: SPEC_VERSION_CURRENT,
145664
+ specVersion: mintedSpecVersion(),
145371
145665
  capabilities: {
145372
145666
  hookRetention: { active: true },
145373
145667
  // Vercel Queues supports maxConcurrency-limited consumers, which
@@ -145377,8 +145671,8 @@ function createWorld$1(config2) {
145377
145671
  // Vercel deployments are atomic and immutable, so a deployment id names
145378
145672
  // one fixed build for its whole lifetime.
145379
145673
  deploymentAffinity: true
145380
- // NOTE: the backend half of resumeHook()'s parallel fast path that
145381
- // the server enforces the `(runId, resumeId)` dedup constraint is
145674
+ // NOTE: the backend half of resumeHook()'s lazy path (that
145675
+ // the server enforces the `(runId, resumeId)` dedup constraint) is
145382
145676
  // NO LONGER a static world capability here. It is attested per-lookup by
145383
145677
  // the server via `Hook.resumeCapabilities.hookResumeDedupVersion`
145384
145678
  // (response-only, recomputed every by-token read). This lets a server
@@ -145526,8 +145820,13 @@ const getWorld = async () => {
145526
145820
  };
145527
145821
  const GetWorldFnKey = Symbol.for("@workflow/world//getWorldFn");
145528
145822
  globalThis[GetWorldFnKey] ?? (globalThis[GetWorldFnKey] = getWorld);
145823
+ globalSingleton("@workflow/core//devServerPort", 1, () => ({
145824
+ getPort: void 0,
145825
+ cachedPort: void 0,
145826
+ inFlight: void 0
145827
+ }));
145529
145828
  function waitUntil(promise2) {
145530
- void import("./index-Ck5CB_wQ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
145829
+ void import("./index-QOlZC9D-.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
145531
145830
  waitUntil2(promise2);
145532
145831
  });
145533
145832
  }
@@ -145548,6 +145847,7 @@ async function waitedUntil(fn2) {
145548
145847
  }));
145549
145848
  return result;
145550
145849
  }
145850
+ globalSingleton("@workflow/core//stepSingleFlight", 1, () => ({ inFlight: /* @__PURE__ */ new Map() }));
145551
145851
  const WORKFLOW_VMS = ["node", "quickjs"];
145552
145852
  function getWorkflowVmFromEnv(env2 = process.env) {
145553
145853
  const raw2 = env2.WORKFLOW_VM;
@@ -145566,6 +145866,9 @@ for (let i = 0; i < chars.length; i++) {
145566
145866
  intToChar[i] = c;
145567
145867
  charToInt[c] = i;
145568
145868
  }
145869
+ globalSingleton("@workflow/core//sourceMapTracers", 1, () => ({
145870
+ byCode: /* @__PURE__ */ new Map()
145871
+ }));
145569
145872
  var alea$1 = { exports: {} };
145570
145873
  var alea = alea$1.exports;
145571
145874
  var hasRequiredAlea;
@@ -146243,6 +146546,9 @@ const BASE64_LOOKUP = new Uint8Array(128).fill(255);
146243
146546
  for (let i = 0; i < BASE64_CHARS.length; i++) {
146244
146547
  BASE64_LOOKUP[BASE64_CHARS.charCodeAt(i)] = i;
146245
146548
  }
146549
+ globalSingleton("@workflow/core//vmScriptCache", 1, () => ({
146550
+ byCode: /* @__PURE__ */ new Map()
146551
+ }));
146246
146552
  var re = { exports: {} };
146247
146553
  var constants;
146248
146554
  var hasRequiredConstants;
@@ -148184,7 +148490,7 @@ const FORMAT_VERSION_TABLE = [
148184
148490
  // bump to the next beta. A too-low cutoff makes new producers write
148185
148491
  // compressed payloads to consumers that cannot decompress them; too-high
148186
148492
  // merely delays the optimization (safe). gzip and zstd ship together, so
148187
- // they share a min version a run that can read one can read both.
148493
+ // they share a min version: a run that can read one can read both.
148188
148494
  { format: SerializationFormat$1.GZIP, minVersion: "5.0.0-beta.18" },
148189
148495
  { format: SerializationFormat$1.ZSTD, minVersion: "5.0.0-beta.18" },
148190
148496
  // TODO(release): verify this matches the actual version that ships sealed-box
@@ -148209,7 +148515,7 @@ const CAPABILITY_VERSION_TABLE = [
148209
148515
  // version-compare against a predicted release cutoff is a guess; instead the
148210
148516
  // run's creating deployment stamps an explicit `hookResumeInputVersion`
148211
148517
  // marker into its execution context, which the server mirrors onto the hook's
148212
- // resumeContext. `resumeHook()` gates the parallel fast path on that marker.
148518
+ // resumeContext. `resumeHook()` gates the lazy path on that marker.
148213
148519
  ];
148214
148520
  const BASELINE_FORMATS = /* @__PURE__ */ new Set([
148215
148521
  SerializationFormat$1.DEVALUE_V1
@@ -148303,9 +148609,12 @@ async function getHookByToken(token) {
148303
148609
  return hook;
148304
148610
  }
148305
148611
  async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
148306
- return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now());
148612
+ return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now(), false);
148613
+ }
148614
+ async function resumeHookDurable(tokenOrHook, payload, encryptionKeyOverride) {
148615
+ return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now(), true);
148307
148616
  }
148308
- async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs) {
148617
+ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs, requireDurableWrite) {
148309
148618
  return await waitedUntil(() => {
148310
148619
  return trace$2("hook.resume", async (span) => {
148311
148620
  var _a3, _b2, _c2;
@@ -148362,31 +148671,36 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
148362
148671
  if (originLink) {
148363
148672
  (_a3 = span == null ? void 0 : span.addLink) == null ? void 0 : _a3.call(span, originLink);
148364
148673
  }
148365
- const eventData = {
148366
- ...v1Compat ? {} : { token: hook.token },
148367
- payload: dehydratedPayload
148368
- };
148369
148674
  const queueName = getWorkflowQueueName(resumeContext.workflowName);
148370
148675
  const queueOptions = {
148371
148676
  deploymentId: resumeContext.deploymentId,
148372
148677
  specVersion: resumeContext.runSpecVersion ?? SPEC_VERSION_LEGACY
148373
148678
  };
148374
- const parallelResumeDisabled = process.env.WORKFLOW_DISABLE_LAZY_HOOK_RESUME === "1";
148679
+ const lazyResumeDisabled = process.env.WORKFLOW_DISABLE_LAZY_HOOK_RESUME === "1";
148375
148680
  const backendDedupSupported = (hookResumeCapabilitiesAreFresh ? ((_b2 = hook.resumeCapabilities) == null ? void 0 : _b2.hookResumeDedupVersion) ?? 0 : 0) >= HOOK_RESUME_DEDUP_VERSION || ((_c2 = world.capabilities) == null ? void 0 : _c2.hookResumeDedup) === true;
148376
- const fallbackReason = parallelResumeDisabled ? "disabled" : !backendDedupSupported ? "backend_unsupported" : (resumeContext.hookResumeInputVersion ?? 0) < HOOK_RESUME_INPUT_VERSION ? "consumer_unsupported" : v1Compat ? "legacy" : (resumeContext.runSpecVersion ?? 0) < SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT ? "non_cbor_transport" : !(dehydratedPayload instanceof Uint8Array) ? "non_bytes" : dehydratedPayload.byteLength > MAX_INLINE_RESUME_PAYLOAD_BYTES ? "oversized" : null;
148377
- const useParallelResume = fallbackReason === null;
148681
+ const fallbackReason = requireDurableWrite ? (
148682
+ // An internal caller needs the event committed before this
148683
+ // resolves (an ordering barrier), which only the eager write
148684
+ // provides. Checked first so the span names the real reason
148685
+ // rather than whichever gate happens to fail alongside it.
148686
+ "durable_required"
148687
+ ) : lazyResumeDisabled ? "disabled" : !backendDedupSupported ? "backend_unsupported" : (resumeContext.hookResumeInputVersion ?? 0) < HOOK_RESUME_INPUT_VERSION ? "consumer_unsupported" : v1Compat ? "legacy" : (resumeContext.runSpecVersion ?? 0) < SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT ? "non_cbor_transport" : !(dehydratedPayload instanceof Uint8Array) ? "non_bytes" : dehydratedPayload.byteLength > MAX_INLINE_RESUME_PAYLOAD_BYTES ? "oversized" : null;
148688
+ const useLazyResume = fallbackReason === null;
148378
148689
  span == null ? void 0 : span.setAttributes({
148379
- "workflow.hook.resume_strategy": useParallelResume ? "parallel" : "sequential",
148690
+ "workflow.hook.resume_strategy": useLazyResume ? "lazy" : "sequential",
148380
148691
  ...fallbackReason ? { "workflow.hook.resume_fallback_reason": fallbackReason } : {}
148381
148692
  });
148382
- const isHookGoneError = (err) => HookNotFoundError.is(err) || EntityConflictError.is(err) || RunExpiredError.is(err);
148383
- if (!useParallelResume) {
148693
+ if (!useLazyResume) {
148694
+ const isHookGoneError = (err) => HookNotFoundError.is(err) || EntityConflictError.is(err) || RunExpiredError.is(err);
148384
148695
  try {
148385
148696
  await world.events.create(hook.runId, {
148386
148697
  eventType: "hook_received",
148387
148698
  specVersion: SPEC_VERSION_CURRENT,
148388
148699
  correlationId: hook.hookId,
148389
- eventData
148700
+ eventData: {
148701
+ ...v1Compat ? {} : { token: hook.token },
148702
+ payload: dehydratedPayload
148703
+ }
148390
148704
  }, { v1Compat });
148391
148705
  } catch (err) {
148392
148706
  if (isHookGoneError(err)) {
@@ -148394,13 +148708,13 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
148394
148708
  }
148395
148709
  throw err;
148396
148710
  }
148397
- const queuePublishRequestedAtMs = Date.now();
148711
+ const queuePublishRequestedAtMs2 = Date.now();
148398
148712
  await world.queue(queueName, {
148399
148713
  runId: hook.runId,
148400
148714
  traceCarrier: resumeContext.traceCarrier ?? void 0,
148401
148715
  hookResumeTiming: {
148402
148716
  resumeRequestedAtMs,
148403
- queuePublishRequestedAtMs,
148717
+ queuePublishRequestedAtMs: queuePublishRequestedAtMs2,
148404
148718
  strategy: "sequential"
148405
148719
  }
148406
148720
  }, queueOptions);
@@ -148409,65 +148723,28 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
148409
148723
  const resumeId = generateResumeId();
148410
148724
  const payloadDigest = await computeResumePayloadDigest(dehydratedPayload);
148411
148725
  span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_id": resumeId });
148412
- const publishInvocation = () => {
148413
- const queuePublishRequestedAtMs = Date.now();
148414
- return world.queue(queueName, {
148415
- runId: hook.runId,
148416
- traceCarrier: resumeContext.traceCarrier ?? void 0,
148417
- hookInput: {
148418
- resumeId,
148419
- hookId: hook.hookId,
148420
- token: hook.token,
148421
- payload: dehydratedPayload,
148422
- payloadDigest,
148423
- // Deployment affinity for the consumer's cheap pre-write
148424
- // check: lets a misrouted delivery re-route before its
148425
- // hoisted hook_received write instead of after.
148426
- deploymentId: resumeContext.deploymentId
148427
- },
148428
- hookResumeTiming: {
148429
- resumeRequestedAtMs,
148430
- queuePublishRequestedAtMs,
148431
- strategy: "parallel"
148432
- }
148433
- }, queueOptions);
148434
- };
148435
- const [eventResult, queueResult] = await Promise.allSettled([
148436
- world.events.create(hook.runId, {
148437
- eventType: "hook_received",
148438
- specVersion: SPEC_VERSION_CURRENT,
148439
- correlationId: hook.hookId,
148440
- eventData
148441
- }, { v1Compat, resumeId, resumePayloadDigest: payloadDigest }),
148442
- publishInvocation()
148443
- ]);
148444
- if (queueResult.status === "rejected") {
148445
- throw queueResult.reason;
148446
- }
148447
- let resilientResume = false;
148448
- if (eventResult.status === "rejected") {
148449
- const err = eventResult.reason;
148450
- if (HookNotFoundError.is(err) || RunExpiredError.is(err)) {
148451
- throw new HookNotFoundError(hook.token);
148452
- }
148453
- if (EntityConflictError.is(err) || isRetryableWorldError(err)) {
148454
- resilientResume = true;
148455
- span == null ? void 0 : span.setAttributes({
148456
- ...HookResilientResume(true),
148457
- "workflow.hook.resume_event_write_recovered": true,
148458
- "workflow.hook.resume_event_write_error": err instanceof Error ? err.name : "unknown"
148459
- });
148460
- runtimeLogger.warn("Hook resume event write failed, but the run was re-triggered via the queue. The hook_received event will be ensured by the queue consumer.", {
148461
- workflowRunId: hook.runId,
148462
- hookId: hook.hookId,
148463
- resumeId,
148464
- error: err instanceof Error ? err.message : String(err)
148465
- });
148466
- } else {
148467
- throw err;
148726
+ const queuePublishRequestedAtMs = Date.now();
148727
+ await world.queue(queueName, {
148728
+ runId: hook.runId,
148729
+ traceCarrier: resumeContext.traceCarrier ?? void 0,
148730
+ hookInput: {
148731
+ resumeId,
148732
+ hookId: hook.hookId,
148733
+ token: hook.token,
148734
+ payload: dehydratedPayload,
148735
+ payloadDigest,
148736
+ // Deployment affinity for the consumer's cheap pre-write
148737
+ // check: lets a misrouted delivery re-route before its
148738
+ // hoisted hook_received write instead of after.
148739
+ deploymentId: resumeContext.deploymentId
148740
+ },
148741
+ hookResumeTiming: {
148742
+ resumeRequestedAtMs,
148743
+ queuePublishRequestedAtMs,
148744
+ strategy: "lazy"
148468
148745
  }
148469
- }
148470
- return resilientResume ? { ...hook, resilientResume: true } : hook;
148746
+ }, queueOptions);
148747
+ return hook;
148471
148748
  } catch (err) {
148472
148749
  span == null ? void 0 : span.setAttributes({
148473
148750
  ...HookToken(typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token),
@@ -148499,7 +148776,7 @@ async function resumeWebhook(token, request2) {
148499
148776
  } else {
148500
148777
  response2 = new Response(null, { status: 202 });
148501
148778
  }
148502
- await resumeHookImpl(hook, request2, encryptionKey, true, resumeRequestedAtMs);
148779
+ await resumeHookImpl(hook, request2, encryptionKey, true, resumeRequestedAtMs, false);
148503
148780
  if (responseReadable) {
148504
148781
  const reader = responseReadable.getReader();
148505
148782
  const chunk = await reader.read();
@@ -148519,6 +148796,7 @@ const resumeHook$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
148519
148796
  __proto__: null,
148520
148797
  getHookByToken,
148521
148798
  resumeHook: resumeHook$2,
148799
+ resumeHookDurable,
148522
148800
  resumeWebhook
148523
148801
  }, Symbol.toStringTag, { value: "Module" }));
148524
148802
  function normalizeAttributeChanges(attrs, options = {}) {
@@ -148555,7 +148833,7 @@ function resolveLineageAttributes() {
148555
148833
  [PARENT_RUN_ID_ATTRIBUTE]: parentRunId
148556
148834
  };
148557
148835
  }
148558
- let hasWarnedLatestNoOp = false;
148836
+ const latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
148559
148837
  async function start$1(workflow, argsOrOptions, options) {
148560
148838
  "use step";
148561
148839
  return await waitedUntil(() => {
@@ -148588,8 +148866,8 @@ async function start$1(workflow, argsOrOptions, options) {
148588
148866
  if (world.resolveLatestDeploymentId) {
148589
148867
  deploymentId = await world.resolveLatestDeploymentId();
148590
148868
  } else {
148591
- if (!hasWarnedLatestNoOp) {
148592
- hasWarnedLatestNoOp = true;
148869
+ if (!latestNoOpWarning.warned) {
148870
+ latestNoOpWarning.warned = true;
148593
148871
  runtimeLogger.warn("deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.", { currentDeploymentId });
148594
148872
  }
148595
148873
  deploymentId = currentDeploymentId;
@@ -148678,7 +148956,7 @@ async function start$1(workflow, argsOrOptions, options) {
148678
148956
  // resumeContext by the server) to decide whether the parallel fast
148679
148957
  // path is safe. For a cross-deployment start the consumer is the
148680
148958
  // target deployment, so we stamp the *target's* value carried back on
148681
- // the health-check probe never the caller's. Omitted when we could
148959
+ // the health-check probe, never the caller's. Omitted when we could
148682
148960
  // not attest the target (older target, timeout, or no probe channel),
148683
148961
  // which fails the resume gate closed to the sequential path.
148684
148962
  ...targetHookResumeInputVersion !== void 0 ? { hookResumeInputVersion: targetHookResumeInputVersion } : {},
@@ -148797,30 +149075,30 @@ async function cancelRun$2(world, runId, options) {
148797
149075
  }
148798
149076
  }
148799
149077
  const CANCEL_RUNS_FALLBACK_CONCURRENCY = 20;
148800
- async function cancelRuns(world, runIds, options) {
148801
- if (runIds.length === 0) {
149078
+ async function cancelRuns(world, runIds2, options) {
149079
+ if (runIds2.length === 0) {
148802
149080
  throw new Error("cancelRuns requires at least one run ID.");
148803
149081
  }
148804
- if (runIds.length > BULK_CANCEL_MAX_RUN_IDS) {
148805
- throw new Error(`cancelRuns accepts at most ${BULK_CANCEL_MAX_RUN_IDS} run IDs (received ${runIds.length}).`);
149082
+ if (runIds2.length > BULK_CANCEL_MAX_RUN_IDS) {
149083
+ throw new Error(`cancelRuns accepts at most ${BULK_CANCEL_MAX_RUN_IDS} run IDs (received ${runIds2.length}).`);
148806
149084
  }
148807
- if (new Set(runIds).size !== runIds.length) {
149085
+ if (new Set(runIds2).size !== runIds2.length) {
148808
149086
  throw new Error("cancelRuns requires unique run IDs (duplicates found).");
148809
149087
  }
148810
149088
  if (world.runs.cancelMany) {
148811
149089
  return world.runs.cancelMany({
148812
- runIds,
149090
+ runIds: runIds2,
148813
149091
  ...{}
148814
149092
  });
148815
149093
  }
148816
- const results = new Array(runIds.length);
149094
+ const results = new Array(runIds2.length);
148817
149095
  let nextIndex = 0;
148818
149096
  const worker = async () => {
148819
149097
  while (true) {
148820
149098
  const index2 = nextIndex++;
148821
- if (index2 >= runIds.length)
149099
+ if (index2 >= runIds2.length)
148822
149100
  return;
148823
- const runId = runIds[index2];
149101
+ const runId = runIds2[index2];
148824
149102
  try {
148825
149103
  await cancelRun$2(world, runId, options);
148826
149104
  results[index2] = { runId, outcome: "cancelled" };
@@ -148834,10 +149112,10 @@ async function cancelRuns(world, runIds, options) {
148834
149112
  }
148835
149113
  }
148836
149114
  };
148837
- const workerCount = Math.min(CANCEL_RUNS_FALLBACK_CONCURRENCY, runIds.length);
149115
+ const workerCount = Math.min(CANCEL_RUNS_FALLBACK_CONCURRENCY, runIds2.length);
148838
149116
  await Promise.all(Array.from({ length: workerCount }, () => worker()));
148839
149117
  const summary = {
148840
- requested: runIds.length,
149118
+ requested: runIds2.length,
148841
149119
  cancelled: 0,
148842
149120
  alreadyCancelled: 0,
148843
149121
  notCancellable: 0,
@@ -148954,6 +149232,20 @@ const PAYLOAD_TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set([
148954
149232
  function getReturnValuePollIntervalMs() {
148955
149233
  return envNumber("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS, { integer: true, min: 1 });
148956
149234
  }
149235
+ const RETURN_VALUE_WAIT_TIMEOUT_MS = 5e4;
149236
+ function getReturnValueWaitTimeoutMs() {
149237
+ return envNumber("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS, { integer: true, min: 1 });
149238
+ }
149239
+ const RETURN_VALUE_MAX_LONG_POLLS = 10;
149240
+ function getReturnValueMaxLongPolls() {
149241
+ return envNumber("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS, { integer: true, min: 1 });
149242
+ }
149243
+ function isReturnValueLongPollEnabled() {
149244
+ const raw2 = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
149245
+ if (raw2 === void 0 || raw2 === "")
149246
+ return true;
149247
+ return !(raw2 === "0" || raw2.toLowerCase() === "false");
149248
+ }
148957
149249
  const _Run = class _Run {
148958
149250
  constructor(runId, opts) {
148959
149251
  __privateAdd(this, _Run_instances);
@@ -149037,7 +149329,7 @@ const _Run = class _Run {
149037
149329
  }
149038
149330
  /**
149039
149331
  * The return value of the workflow run.
149040
- * Polls the workflow return value until it is completed.
149332
+ * Polls the workflow return value until the workflow run completes.
149041
149333
  */
149042
149334
  get returnValue() {
149043
149335
  "use step";
@@ -149170,13 +149462,24 @@ resolveTerminalReturnValue_fn = async function(run2) {
149170
149462
  throw new WorkflowRunNotCompletedError(this.runId, run2.status);
149171
149463
  };
149172
149464
  pollReturnValue_fn = async function() {
149465
+ var _a3;
149173
149466
  const world = await __privateGet(this, _Run_instances, lazyWorldPromise_get);
149174
149467
  let notFoundRetries = 0;
149175
149468
  const NOT_FOUND_MAX_RETRIES = __privateGet(this, _resilientStart) ? 3 : 0;
149176
149469
  const NOT_FOUND_DELAYS = [1e3, 3e3, 6e3];
149470
+ const waitForTerminalStatus = isReturnValueLongPollEnabled() ? (_a3 = world.runs.waitForTerminalStatus) == null ? void 0 : _a3.bind(world.runs) : void 0;
149471
+ let longPolls = 0;
149472
+ const maxLongPolls = getReturnValueMaxLongPolls();
149177
149473
  while (true) {
149474
+ const iterationStartedAt = Date.now();
149178
149475
  try {
149179
- const runMetadata = await world.runs.get(this.runId, {
149476
+ const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
149477
+ if (useLongPoll)
149478
+ longPolls++;
149479
+ const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
149480
+ timeoutMs: getReturnValueWaitTimeoutMs(),
149481
+ resolveData: "none"
149482
+ }) : await world.runs.get(this.runId, {
149180
149483
  resolveData: "none"
149181
149484
  });
149182
149485
  if (runMetadata.status === "cancelled") {
@@ -149191,7 +149494,10 @@ pollReturnValue_fn = async function() {
149191
149494
  throw new WorkflowRunNotCompletedError(this.runId, runMetadata.status);
149192
149495
  } catch (error2) {
149193
149496
  if (WorkflowRunNotCompletedError.is(error2)) {
149194
- await new Promise((resolve2) => setTimeout(resolve2, getReturnValuePollIntervalMs()));
149497
+ const remainingIntervalMs = getReturnValuePollIntervalMs() - (Date.now() - iterationStartedAt);
149498
+ if (remainingIntervalMs > 0) {
149499
+ await new Promise((resolve2) => setTimeout(resolve2, remainingIntervalMs));
149500
+ }
149195
149501
  continue;
149196
149502
  }
149197
149503
  if (WorkflowRunNotFoundError.is(error2) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
@@ -149931,16 +150237,16 @@ async function cancelRun$1(worldEnv, runId) {
149931
150237
  });
149932
150238
  }
149933
150239
  }
149934
- async function bulkCancelRuns$1(worldEnv, runIds) {
150240
+ async function bulkCancelRuns$1(worldEnv, runIds2) {
149935
150241
  try {
149936
150242
  const world = await getWorldFromEnv(worldEnv);
149937
- const result = await cancelRuns(world, runIds);
150243
+ const result = await cancelRuns(world, runIds2);
149938
150244
  return createResponse(result);
149939
150245
  } catch (error2) {
149940
150246
  return createServerActionError(
149941
150247
  error2,
149942
150248
  "world.runs.cancelMany",
149943
- { runIdCount: runIds.length }
150249
+ { runIdCount: runIds2.length }
149944
150250
  );
149945
150251
  }
149946
150252
  }
@@ -155955,8 +156261,8 @@ function useWorkflowStreams(env2, runId, refreshInterval = STREAMS_REFRESH_INTER
155955
156261
  async function cancelRun(env2, runId) {
155956
156262
  await unwrapOrThrow(cancelRun$3(env2, runId));
155957
156263
  }
155958
- async function bulkCancelRuns(env2, runIds) {
155959
- return unwrapOrThrow(bulkCancelRuns$2(env2, runIds));
156264
+ async function bulkCancelRuns(env2, runIds2) {
156265
+ return unwrapOrThrow(bulkCancelRuns$2(env2, runIds2));
155960
156266
  }
155961
156267
  async function recreateRun(env2, runId) {
155962
156268
  return unwrapOrThrow(recreateRun$2(env2, runId));
@@ -172416,7 +172722,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
172416
172722
  __proto__: null,
172417
172723
  loader
172418
172724
  }, Symbol.toStringTag, { value: "Module" }));
172419
- const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-BfhMCbkz.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/root-Bl5xphvU.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-C6CuMqQu.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-BG_1K2Hq.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-157e28f1.js", "version": "157e28f1", "sri": void 0 };
172725
+ const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-Zvnb602n.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/mermaid-3ZIDBTTL-BKGEyEYb.js", "/assets/loader-circle-oscnpy3L.js", "/assets/arrow-up-right-UOc2WcaC.js"], "css": ["/assets/root-Bl5xphvU.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-DYB1uz9w.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-Du0ztkb8.js", "/assets/mermaid-3ZIDBTTL-BKGEyEYb.js", "/assets/loader-circle-oscnpy3L.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-CedyZW9h.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-Du0ztkb8.js", "/assets/mermaid-3ZIDBTTL-BKGEyEYb.js", "/assets/arrow-up-right-UOc2WcaC.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-a701502a.js", "version": "a701502a", "sri": void 0 };
172420
172726
  const assetsBuildDirectory = "build/client";
172421
172727
  const basename = "/";
172422
172728
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -172625,12 +172931,12 @@ function createFetchHandler(basename2 = "/") {
172625
172931
  return (request2) => handler(request2, loadContext);
172626
172932
  }
172627
172933
  export {
172628
- SPEC_VERSION_SUPPORTS_COMPRESSION as $,
172934
+ SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as $,
172629
172935
  ANALYTICS_EVENTS_GET_MANY_LIMIT as A,
172630
172936
  BULK_CANCEL_MAX_RUN_IDS as B,
172631
172937
  CHILD_ENTITY_CREATION_EVENT_TYPES as C,
172632
172938
  DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS as D,
172633
- EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE as E,
172939
+ EVENT_ID_BODY_LENGTH as E,
172634
172940
  FIRST_EVENT_SLOT as F,
172635
172941
  HealthCheckPayloadSchema as G,
172636
172942
  HookSchema as H,
@@ -172648,94 +172954,98 @@ export {
172648
172954
  RESERVED_ATTRIBUTE_KEY_PREFIX as T,
172649
172955
  ROOT_RUN_ID_ATTRIBUTE as U,
172650
172956
  RunInputSchema as V,
172651
- SPEC_VERSION_CURRENT as W,
172652
- SPEC_VERSION_LEGACY as X,
172653
- SPEC_VERSION_MAX_SUPPORTED as Y,
172654
- SPEC_VERSION_SUPPORTS_ATTRIBUTES as Z,
172655
- SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as _,
172957
+ SEALED_LOG_ENV_VAR as W,
172958
+ SPEC_VERSION_CURRENT as X,
172959
+ SPEC_VERSION_LEGACY as Y,
172960
+ SPEC_VERSION_MAX_SUPPORTED as Z,
172961
+ SPEC_VERSION_SUPPORTS_ATTRIBUTES as _,
172656
172962
  ATTRIBUTE_KEY_MAX_LENGTH as a,
172657
- getHttpUrl as a$,
172658
- SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as a0,
172659
- STEP_EVENT_TYPES as a1,
172660
- SerializedDataSchema as a2,
172661
- StepSchema as a3,
172662
- StepStatusSchema as a4,
172663
- StructuredErrorSchema as a5,
172664
- TERMINAL_RUN_EVENT_TYPES as a6,
172665
- TERMINAL_STEP_EVENT_TYPES as a7,
172666
- TERMINAL_STEP_STATUSES as a8,
172667
- TERMINAL_WORKFLOW_RUN_STATUSES as a9,
172668
- isSlotBody as aA,
172669
- isSlotEventId as aB,
172670
- isStepEventType as aC,
172671
- isTerminalRunEventType as aD,
172672
- isTerminalStepEventType as aE,
172673
- isTerminalStepStatus as aF,
172674
- isTerminalWorkflowRunStatus as aG,
172675
- isWaitEventType as aH,
172676
- parseQueueName as aI,
172677
- reenqueueActiveRuns as aJ,
172678
- requiresNewerWorld as aK,
172679
- resolveQueueNamespace as aL,
172680
- slotToEventId as aM,
172681
- stripEventDataRefs as aN,
172682
- ulidToDate as aO,
172683
- validateAttributeChanges as aP,
172684
- validateAttributeKey as aQ,
172685
- validateAttributeValue as aR,
172686
- validateUlidTimestamp as aS,
172687
- workflowRunIdSchema as aT,
172688
- reactExports as aU,
172689
- R as aV,
172690
- Ks as aW,
172691
- jsxRuntimeExports as aX,
172692
- Qe as aY,
172693
- registerZstdDecoder as aZ,
172694
- isWsEventsTransportEnabled as a_,
172695
- TerminalRunEventTypeSchema as aa,
172696
- TerminalStepStatusSchema as ab,
172697
- TerminalWorkflowRunStatusSchema as ac,
172698
- ValidQueueName as ad,
172699
- WAIT_EVENT_TYPES as ae,
172700
- WaitSchema as af,
172701
- WaitStatusSchema as ag,
172702
- WorkflowInvokePayloadSchema as ah,
172703
- WorkflowRunBaseSchema as ai,
172704
- WorkflowRunSchema as aj,
172705
- WorkflowRunStatusSchema as ak,
172706
- applyAttributeChanges as al,
172707
- entityEventClass as am,
172708
- envFlag as an,
172709
- envNumber as ao,
172710
- eventIdToSlot as ap,
172711
- getEventDataPayloadField as aq,
172712
- getEventDataRefFields as ar,
172713
- getMaxEventsPerRun as as,
172714
- getQueueTopicPrefix as at,
172715
- isChildEntityCreationEvent as au,
172716
- isChildEntityCreationEventType as av,
172717
- isHookEventRequiringExistence as aw,
172718
- isHookLifecycleEventType as ax,
172719
- isLegacySpecVersion as ay,
172720
- isNodeHttpEnabled as az,
172963
+ registerZstdDecoder as a$,
172964
+ SPEC_VERSION_SUPPORTS_COMPRESSION as a0,
172965
+ SPEC_VERSION_SUPPORTS_SEALED_LOG as a1,
172966
+ SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as a2,
172967
+ STEP_EVENT_TYPES as a3,
172968
+ SerializedDataSchema as a4,
172969
+ StepSchema as a5,
172970
+ StepStatusSchema as a6,
172971
+ StructuredErrorSchema as a7,
172972
+ TERMINAL_RUN_EVENT_TYPES as a8,
172973
+ TERMINAL_STEP_EVENT_TYPES as a9,
172974
+ isLegacySpecVersion as aA,
172975
+ isNodeHttpEnabled as aB,
172976
+ isSealedNoopEvent$1 as aC,
172977
+ isSlotBody as aD,
172978
+ isSlotEventId as aE,
172979
+ isStepEventType as aF,
172980
+ isTerminalRunEventType as aG,
172981
+ isTerminalStepEventType as aH,
172982
+ isTerminalStepStatus as aI,
172983
+ isTerminalWorkflowRunStatus as aJ,
172984
+ isWaitEventType as aK,
172985
+ mintedSpecVersion as aL,
172986
+ parseQueueName as aM,
172987
+ reenqueueActiveRuns as aN,
172988
+ requiresNewerWorld as aO,
172989
+ resolveQueueNamespace as aP,
172990
+ slotToEventId as aQ,
172991
+ stripEventDataRefs as aR,
172992
+ ulidToDate as aS,
172993
+ validateAttributeChanges as aT,
172994
+ validateUlidTimestamp as aU,
172995
+ workflowRunIdSchema as aV,
172996
+ reactExports as aW,
172997
+ R as aX,
172998
+ Ks as aY,
172999
+ jsxRuntimeExports as aZ,
173000
+ Qe as a_,
173001
+ TERMINAL_STEP_STATUSES as aa,
173002
+ TERMINAL_WORKFLOW_RUN_STATUSES as ab,
173003
+ TerminalRunEventTypeSchema as ac,
173004
+ TerminalStepStatusSchema as ad,
173005
+ TerminalWorkflowRunStatusSchema as ae,
173006
+ ValidQueueName as af,
173007
+ WAIT_EVENT_TYPES as ag,
173008
+ WaitSchema as ah,
173009
+ WaitStatusSchema as ai,
173010
+ WorkflowInvokePayloadSchema as aj,
173011
+ WorkflowRunBaseSchema as ak,
173012
+ WorkflowRunSchema as al,
173013
+ WorkflowRunStatusSchema as am,
173014
+ applyAttributeChanges as an,
173015
+ entityEventClass as ao,
173016
+ envFlag as ap,
173017
+ envNumber as aq,
173018
+ eventIdToSlot as ar,
173019
+ getEventDataPayloadField as as,
173020
+ getEventDataRefFields as at,
173021
+ getMaxEventsPerRun as au,
173022
+ getQueueTopicPrefix as av,
173023
+ isChildEntityCreationEvent as aw,
173024
+ isChildEntityCreationEventType as ax,
173025
+ isHookEventRequiringExistence as ay,
173026
+ isHookLifecycleEventType as az,
172721
173027
  ATTRIBUTE_MAX_PER_RUN as b,
172722
- getHttpConfig as b0,
172723
- headersToRecord as b1,
172724
- getRequestTimeoutMs as b2,
172725
- injectTraceContextIntoHeaders as b3,
172726
- withHttpClientSpan as b4,
172727
- ErrorType as b5,
172728
- WorkflowWsReconnectAttempt as b6,
172729
- NetworkProtocolName as b7,
172730
- WorkflowEventsTransport as b8,
172731
- distExports as b9,
172732
- decodeFrames as ba,
172733
- getDefaultExportFromCjs as bb,
172734
- requireTokenUtil as bc,
172735
- requireTokenError as bd,
172736
- getAugmentedNamespace as be,
172737
- app as bf,
172738
- createFetchHandler as bg,
173028
+ isWsEventsTransportEnabled as b0,
173029
+ getHttpUrl as b1,
173030
+ globalSingleton as b2,
173031
+ version as b3,
173032
+ getHttpConfig as b4,
173033
+ headersToRecord as b5,
173034
+ getRequestTimeoutMs as b6,
173035
+ injectTraceContextIntoHeaders as b7,
173036
+ withHttpClientSpan as b8,
173037
+ ErrorType as b9,
173038
+ WorkflowWsReconnectAttempt as ba,
173039
+ NetworkProtocolName as bb,
173040
+ WorkflowEventsTransport as bc,
173041
+ distExports as bd,
173042
+ decodeFrames as be,
173043
+ getDefaultExportFromCjs as bf,
173044
+ requireTokenUtil as bg,
173045
+ requireTokenError as bh,
173046
+ getAugmentedNamespace as bi,
173047
+ app as bj,
173048
+ createFetchHandler as bk,
172739
173049
  ATTRIBUTE_VALUE_MAX_BYTES as c,
172740
173050
  AnalyticsAttributeKeySchema as d,
172741
173051
  AnalyticsEventSchema as e,
@@ -172745,14 +173055,14 @@ export {
172745
173055
  AnalyticsWaitSchema as i,
172746
173056
  AttributeChangeSchema as j,
172747
173057
  AttributeChangesSchema as k,
172748
- AttributeValidationError as l,
172749
- BaseEventSchema as m,
172750
- BulkCancelWorkflowRunResultSchema as n,
172751
- BulkCancelWorkflowRunsRequestSchema as o,
172752
- BulkCancelWorkflowRunsResultSchema as p,
172753
- DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS as q,
172754
- EVENT_DATA_REF_FIELDS as r,
172755
- EVENT_ID_BODY_LENGTH as s,
173058
+ AttributeKeySchema as l,
173059
+ AttributeValidationError as m,
173060
+ AttributeValueSchema as n,
173061
+ BaseEventSchema as o,
173062
+ BulkCancelWorkflowRunResultSchema as p,
173063
+ BulkCancelWorkflowRunsRequestSchema as q,
173064
+ BulkCancelWorkflowRunsResultSchema as r,
173065
+ DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS as s,
172756
173066
  EVENT_ID_PREFIX as t,
172757
173067
  EventSchema as u,
172758
173068
  EventTypeSchema as v,