@workflow/web 5.0.0-beta.34 → 5.0.0-beta.36

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-B1QFlETT.js → arrow-up-right-Dv3gGqIf.js} +1 -1
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-Br23zjGQ.js → highlighted-body-B3W2YXNL-C5gyMelW.js} +1 -1
  3. package/build/client/assets/{home-rmBMtWNr.js → home-0OfTSXd1.js} +2 -2
  4. package/build/client/assets/{manifest-9dd3e2d8.js → manifest-485c4078.js} +1 -1
  5. package/build/client/assets/{mermaid-3ZIDBTTL-CQtb_4FN.js → mermaid-3ZIDBTTL-C_EWPx9a.js} +104 -23
  6. package/build/client/assets/root-15oK726f.css +1 -0
  7. package/build/client/assets/{root-CraFPjyT.js → root-BPK1T9Ck.js} +2 -2
  8. package/build/client/assets/{run-detail-BGHjSgVx.js → run-detail-CrqNzQ_y.js} +33 -27
  9. package/build/client/assets/server-build-DblSGQ6A.css +1 -0
  10. package/build/client/assets/{workflow-graph-viewer-Cn2fThMy.js → workflow-graph-viewer-DrfqsDRu.js} +1 -1
  11. package/build/client/assets/{zstd-browser-decoder-BjHfY5Rj.js → zstd-browser-decoder-Ds2MNSdp.js} +1 -1
  12. package/build/server/assets/{app-i2AZJqU9.js → app-BSsmG188.js} +1 -1
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-CLwuqern.js → highlighted-body-B3W2YXNL-C7tx66m_.js} +2 -2
  14. package/build/server/assets/{index-CDZXmART.js → index-Cnj8rNtV.js} +60 -57
  15. package/build/server/assets/{mermaid-3ZIDBTTL-D9aZdQJZ.js → mermaid-3ZIDBTTL-DStR4R-M.js} +2 -2
  16. package/build/server/assets/{server-build-DIxG6FRI.js → server-build-4Pq8AwvA.js} +1089 -514
  17. package/build/server/assets/{token-Ni6JMJBG.js → token-CYc8-6E0.js} +2 -2
  18. package/build/server/assets/{token-util-DXRPWBKh.js → token-util-D94FNaX0.js} +2 -2
  19. package/build/server/assets/{zstd-browser-decoder-Do5u42Eg.js → zstd-browser-decoder-DXnLXD-w.js} +2 -2
  20. package/build/server/index.js +1 -1
  21. package/package.json +8 -8
  22. package/build/client/assets/root-CQggqXow.css +0 -1
  23. package/build/client/assets/server-build-C5ehvmav.css +0 -1
@@ -18,7 +18,7 @@ import { createRequire as __wkfCreateRequire } from "node:module";
18
18
  if (typeof require === "undefined") {
19
19
  globalThis.require = __wkfCreateRequire(import.meta.url);
20
20
  }
21
- import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-i2AZJqU9.js";
21
+ import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-BSsmG188.js";
22
22
  import require$$0$4, { PassThrough } from "node:stream";
23
23
  import require$$0 from "util";
24
24
  import require$$1 from "crypto";
@@ -47781,6 +47781,8 @@ const z$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty(
47781
47781
  xor: xor$1
47782
47782
  }, Symbol.toStringTag, { value: "Module" }));
47783
47783
  const RESERVED_ATTRIBUTE_KEY_PREFIX = "$";
47784
+ const ROOT_RUN_ID_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}rootRunId`;
47785
+ const PARENT_RUN_ID_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}parentRunId`;
47784
47786
  const ATTRIBUTE_KEY_MAX_LENGTH = 256;
47785
47787
  const ATTRIBUTE_VALUE_MAX_BYTES = 256;
47786
47788
  const ATTRIBUTE_MAX_PER_RUN = 64;
@@ -48030,6 +48032,17 @@ const stepLatencyTelemetryFields = {
48030
48032
  // stso.
48031
48033
  stepCount: number$3().int().positive().optional(),
48032
48034
  eventCount: number$3().int().positive().optional(),
48035
+ // Run-started-to-first-step: milliseconds from the `run_started` response
48036
+ // landing (or, under turbo, the local run synthesis instant) until this
48037
+ // step's start POST was issued. A sub-window of ttfs. Only reported
48038
+ // alongside the same eligibility as ttfs.
48039
+ rsfs: number$3().optional(),
48040
+ // Synchronous workflow-function replay duration of only the FINAL replay
48041
+ // pass within the rsfs window (the pass that scheduled the first step),
48042
+ // excluding awaited network I/O — not accumulated across earlier
48043
+ // pre-first-step passes, so it is not "the replay portion of rsfs". Only
48044
+ // present alongside rsfs, and only for the run's first step.
48045
+ finalSchedulingReplay: number$3().optional(),
48033
48046
  // Names of the runtime's optional startup-latency optimizations that were
48034
48047
  // active for this measurement (e.g. 'turbo', 'lazyStepStart',
48035
48048
  // 'optimisticStart'), so latency metrics can be segmented by them.
@@ -48111,6 +48124,7 @@ const HookCreatedEventSchema = BaseEventSchema.extend({
48111
48124
  correlationId: string$3(),
48112
48125
  eventData: object$1({
48113
48126
  token: string$3(),
48127
+ tokenRetentionUntil: date$2().optional(),
48114
48128
  metadata: SerializedDataSchema.optional(),
48115
48129
  isWebhook: boolean$3().optional(),
48116
48130
  isSystem: boolean$3().optional()
@@ -48738,7 +48752,7 @@ const PaginatedResponseSchema = (dataSchema) => object$1({
48738
48752
  hasMore: boolean$3(),
48739
48753
  pageInfo: PageInfoSchema.optional()
48740
48754
  });
48741
- object$1({
48755
+ const StructuredErrorSchema = object$1({
48742
48756
  message: string$3(),
48743
48757
  stack: string$3().optional(),
48744
48758
  code: string$3().optional()
@@ -50156,7 +50170,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
50156
50170
  }
50157
50171
  async function hydrateResourceIOAsync(resource, key) {
50158
50172
  const { hydrateDataWithKey: hydrateDataWithKey2 } = await Promise.resolve().then(() => serializationFormat);
50159
- const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-Do5u42Eg.js");
50173
+ const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-DXnLXD-w.js");
50160
50174
  ensureZstdDecoderRegistered();
50161
50175
  const cryptoKey = key ? await Promise.resolve().then(() => encryption).then(({ importKey: importKey2 }) => importKey2(key)) : void 0;
50162
50176
  const revivers = getRevivers();
@@ -52449,7 +52463,7 @@ const rowValueVariants = cva("min-w-0 flex-1 truncate text-right text-copy-13 te
52449
52463
  variant: "default"
52450
52464
  }
52451
52465
  });
52452
- const rowCopyValueVariants = cva("flex min-w-0 items-center justify-end gap-1 text-copy-13 text-gray-1000", {
52466
+ const rowCopyValueVariants = cva("flex min-w-0 flex-1 items-center justify-end gap-1 overflow-hidden text-copy-13 text-gray-1000", {
52453
52467
  variants: {
52454
52468
  variant: {
52455
52469
  default: "",
@@ -83121,7 +83135,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
83121
83135
  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 });
83122
83136
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
83123
83137
  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 }) });
83124
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-CLwuqern.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
83138
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-C7tx66m_.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
83125
83139
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
83126
83140
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
83127
83141
  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 }) })] }) });
@@ -83443,7 +83457,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
83443
83457
  }, []), 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] });
83444
83458
  };
83445
83459
  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 }) })] });
83446
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-D9aZdQJZ.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
83460
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-DStR4R-M.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
83447
83461
  function ke(e, t) {
83448
83462
  if (!(e != null && e.position || t != null && t.position)) return true;
83449
83463
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -84322,7 +84336,8 @@ const copyableBasicAttributes = /* @__PURE__ */ new Set([
84322
84336
  "hookId",
84323
84337
  "eventId",
84324
84338
  "deploymentId",
84325
- "moduleSpecifier"
84339
+ "moduleSpecifier",
84340
+ "token"
84326
84341
  ]);
84327
84342
  const loadingSectionLabels = {
84328
84343
  input: "Input",
@@ -86765,6 +86780,9 @@ function computeTimeMarkers(viewDuration, offset2) {
86765
86780
  }
86766
86781
  return markers2;
86767
86782
  }
86783
+ function toViewportFrac(ms2, viewStart, range2) {
86784
+ return Math.min(Math.max((ms2 - viewStart) / range2, 0), 1);
86785
+ }
86768
86786
  function computeSpanGaps(spans, viewStart, viewEnd) {
86769
86787
  const range2 = viewEnd - viewStart;
86770
86788
  if (range2 <= 0)
@@ -86776,14 +86794,40 @@ function computeSpanGaps(spans, viewStart, viewEnd) {
86776
86794
  const gapMs = startTime - endTime;
86777
86795
  if (gapMs <= 0)
86778
86796
  continue;
86779
- const leftFrac = Math.min(Math.max((endTime - viewStart) / range2, 0), 1);
86780
- const rightFrac = Math.min(Math.max((startTime - viewStart) / range2, 0), 1);
86797
+ const leftFrac = toViewportFrac(endTime, viewStart, range2);
86798
+ const rightFrac = toViewportFrac(startTime, viewStart, range2);
86781
86799
  if (rightFrac - leftFrac < 1e-3)
86782
86800
  continue;
86783
86801
  gaps.push({ gapMs, leftFrac, rightFrac, rowIndex: i });
86784
86802
  }
86785
86803
  return gaps;
86786
86804
  }
86805
+ function computeSpanDelta(anchor, hovered, viewStart, viewEnd) {
86806
+ const range2 = viewEnd - viewStart;
86807
+ if (range2 <= 0)
86808
+ return null;
86809
+ const anchorStart = getHighResInMs(anchor.startTime);
86810
+ const hoveredStart = getHighResInMs(hovered.startTime);
86811
+ const anchorIsEarlier = anchorStart <= hoveredStart;
86812
+ const earlierStart = anchorIsEarlier ? anchorStart : hoveredStart;
86813
+ const earlierEnd = getHighResInMs(anchorIsEarlier ? anchor.endTime : hovered.endTime);
86814
+ const laterStart = anchorIsEarlier ? hoveredStart : anchorStart;
86815
+ const originMs = earlierEnd <= laterStart ? earlierEnd : earlierStart;
86816
+ const deltaMs = laterStart - originMs;
86817
+ if (laterStart < viewStart || originMs > viewEnd) {
86818
+ return null;
86819
+ }
86820
+ const originFrac = toViewportFrac(originMs, viewStart, range2);
86821
+ const laterFrac = toViewportFrac(laterStart, viewStart, range2);
86822
+ const hoveredEnd = getHighResInMs(hovered.endTime);
86823
+ return {
86824
+ deltaMs,
86825
+ anchorFrac: anchorIsEarlier ? originFrac : laterFrac,
86826
+ hoveredFrac: anchorIsEarlier ? laterFrac : originFrac,
86827
+ anchorEdge: anchorIsEarlier && earlierEnd <= laterStart ? "end" : "start",
86828
+ hoveredOffscreen: hoveredStart > viewEnd ? "right" : hoveredEnd < viewStart ? "left" : null
86829
+ };
86830
+ }
86787
86831
  const RESOURCE_COLORS = {
86788
86832
  run: {
86789
86833
  bg: "var(--ds-blue-200)",
@@ -86797,9 +86841,10 @@ const RESOURCE_COLORS = {
86797
86841
  errorBg: "var(--ds-red-200)",
86798
86842
  errorBorder: "var(--ds-red-500)"
86799
86843
  },
86844
+ // Passive spans (hooks) stay gray — matches event-list icons and the minimap.
86800
86845
  hook: {
86801
- bg: "var(--ds-amber-200)",
86802
- border: "var(--ds-amber-500)",
86846
+ bg: "var(--ds-gray-200)",
86847
+ border: "var(--ds-gray-500)",
86803
86848
  errorBg: "var(--ds-red-200)",
86804
86849
  errorBorder: "var(--ds-red-500)"
86805
86850
  },
@@ -87097,28 +87142,30 @@ function scrollRowIntoView(listEl, index2, rowHeight, opts) {
87097
87142
  });
87098
87143
  }
87099
87144
  const eventStyles = {
87100
- run: { icon: WorkflowIcon, className: "text-blue-900" },
87101
- step: { icon: StepForwardIcon, className: "text-green-900" },
87102
- hook: { icon: WebhookIcon, className: "text-gray-900" },
87103
- sleep: { icon: SleepIcon, className: "text-gray-900" }
87145
+ run: { icon: WorkflowIcon, className: "text-blue-900", label: "Workflow" },
87146
+ step: { icon: StepForwardIcon, className: "text-green-900", label: "Step" },
87147
+ hook: { icon: WebhookIcon, className: "text-gray-900", label: "Hook" },
87148
+ sleep: { icon: SleepIcon, className: "text-gray-900", label: "Sleep" }
87104
87149
  };
87105
87150
  const defaultStyle = {
87106
87151
  icon: Circle,
87107
- className: "text-gray-900"
87152
+ className: "text-gray-900",
87153
+ label: "Event"
87108
87154
  };
87109
87155
  const ROW_HEIGHT_CLASS = "h-10";
87110
87156
  function getEventStyle(resource, isErrored) {
87111
87157
  const style2 = eventStyles[resource] ?? defaultStyle;
87112
87158
  return {
87113
87159
  icon: style2.icon,
87114
- className: cn$4(isErrored ? "text-red-900" : style2.className)
87160
+ className: cn$4(isErrored ? "text-red-900" : style2.className),
87161
+ label: style2.label
87115
87162
  };
87116
87163
  }
87117
87164
  const EventRow = ({ span, isSelected, isDimmed, onSelectSpan }) => {
87118
87165
  const durationMs = getSpanDurationMs(span);
87119
87166
  const isErrored = isSpanErrored(span);
87120
- const { icon: Icon2, className: tagClassName } = getEventStyle(span.resource, isErrored);
87121
- return jsxRuntimeExports.jsx("li", { className: cn$4("relative overflow-clip group transition-opacity", ROW_HEIGHT_CLASS, isDimmed && "opacity-35"), role: "treeitem", "aria-selected": isSelected, "aria-expanded": isSelected, "aria-level": 1, onClick: () => onSelectSpan(span.spanId), children: jsxRuntimeExports.jsx("div", { className: "h-full hover:bg-gray-100 group-aria-selected:bg-gray-100 group-aria-selected:hover:bg-gray-200", children: jsxRuntimeExports.jsxs("div", { className: "flex h-full min-w-0 items-center pl-4 pr-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [jsxRuntimeExports.jsx("span", { className: cn$4("shrink-0", tagClassName), children: jsxRuntimeExports.jsx(Icon2, { className: "w-4 h-4" }) }), jsxRuntimeExports.jsx("span", { className: "min-w-0 text-label-14", children: jsxRuntimeExports.jsx(MiddleTruncate, { value: span.name }) })] }), jsxRuntimeExports.jsx("div", { className: "ml-2 shrink-0", children: jsxRuntimeExports.jsx("span", { className: "text-label-14 text-gray-900 tabular-nums", children: formatDurationPrecise(durationMs) }) })] }) }) });
87167
+ const { icon: Icon2, className: tagClassName, label: iconLabel } = getEventStyle(span.resource, isErrored);
87168
+ return jsxRuntimeExports.jsx("li", { className: cn$4("relative overflow-clip group transition-opacity", ROW_HEIGHT_CLASS, isDimmed && "opacity-35"), role: "treeitem", "aria-selected": isSelected, "aria-expanded": isSelected, "aria-level": 1, onClick: () => onSelectSpan(span.spanId), children: jsxRuntimeExports.jsx("div", { className: "h-full hover:bg-gray-100 group-aria-selected:bg-gray-100 group-aria-selected:hover:bg-gray-200", children: jsxRuntimeExports.jsxs("div", { className: "flex h-full min-w-0 items-center pl-4 pr-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [jsxRuntimeExports.jsxs(Tooltip$1, { delayDuration: 500, children: [jsxRuntimeExports.jsx(TooltipTrigger$1, { asChild: true, children: jsxRuntimeExports.jsx("span", { className: cn$4("shrink-0", tagClassName), children: jsxRuntimeExports.jsx(Icon2, { className: "w-4 h-4" }) }) }), jsxRuntimeExports.jsx(TooltipContent$1, { side: "top", children: iconLabel })] }), jsxRuntimeExports.jsx("span", { className: "min-w-0 text-label-14", children: jsxRuntimeExports.jsx(MiddleTruncate, { value: span.name }) })] }), jsxRuntimeExports.jsx("div", { className: "ml-2 shrink-0", children: jsxRuntimeExports.jsx("span", { className: "text-label-14 text-gray-900 tabular-nums", children: formatDurationPrecise(durationMs) }) })] }) }) });
87122
87169
  };
87123
87170
  const EventList = ({ spans, activeSpanId, searchResult, onSelectSpan }) => {
87124
87171
  const listRef = reactExports.useRef(null);
@@ -87268,6 +87315,9 @@ function projectSegments(segments, spanStartMs, spanDurationMs, geometry) {
87268
87315
  ];
87269
87316
  });
87270
87317
  }
87318
+ function estimateLabelWidthPx(label) {
87319
+ return label.length * 6 + 12;
87320
+ }
87271
87321
  function DurationLabel({ label, className }) {
87272
87322
  return jsxRuntimeExports.jsx("span", { className: cn$4("pointer-events-none absolute inset-0 flex items-center justify-start overflow-hidden px-1 text-[10px] font-mono font-medium leading-none whitespace-nowrap text-left text-gray-1000 tabular-nums opacity-0 group-hover/timeline-row:opacity-100", className), children: label });
87273
87323
  }
@@ -87288,14 +87338,14 @@ function SegmentBar({ segments, showLabels = true }) {
87288
87338
  return jsxRuntimeExports.jsx("div", { className: "relative h-6 w-full", children: segments.map((seg, i) => {
87289
87339
  if (seg.status === "queued") {
87290
87340
  const leadInLabel = formatDurationPrecise(seg.fullDurationMs);
87291
- const showLeadInLabel = showLabels && seg.pixelWidth >= Math.max(40, leadInLabel.length * 6 + 12);
87341
+ const showLeadInLabel = showLabels && seg.pixelWidth >= Math.max(40, estimateLabelWidthPx(leadInLabel));
87292
87342
  const isFullWidthQueued = segments.length === 1;
87293
87343
  return jsxRuntimeExports.jsxs(reactExports.Fragment, { children: [jsxRuntimeExports.jsx(LeadInConnector, { leftPct: seg.leftPct, widthPct: seg.widthPct, label: showLeadInLabel ? leadInLabel : null }), isFullWidthQueued ? jsxRuntimeExports.jsx("div", { className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-gray-500", style: {
87294
87344
  left: `calc(${seg.leftPct + seg.widthPct}% - 1.5px)`
87295
87345
  } }) : null] }, i);
87296
87346
  }
87297
87347
  const label = formatDurationPrecise(seg.fullDurationMs);
87298
- const showLabel = showLabels && seg.pixelWidth >= Math.max(40, label.length * 6 + 12);
87348
+ const showLabel = showLabels && seg.pixelWidth >= Math.max(40, estimateLabelWidthPx(label));
87299
87349
  return jsxRuntimeExports.jsxs("div", { className: cn$4("absolute h-full overflow-hidden rounded-[0.25rem]", SEGMENT_CLASSES[seg.status]), style: {
87300
87350
  // 1px gap between adjacent segments, distributed equally.
87301
87351
  left: `calc(${seg.leftPct}% + 0.5px)`,
@@ -87320,7 +87370,7 @@ const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, v
87320
87370
  const fallbackBg = isErrored ? colors.errorBg ?? "var(--ds-red-200)" : colors.bg;
87321
87371
  const fallbackBorder = isErrored ? colors.errorBorder ?? "var(--ds-red-500)" : colors.border;
87322
87372
  const totalLabel = formatDurationPrecise(totalDurationMs);
87323
- const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, totalLabel.length * 6 + 12);
87373
+ const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, estimateLabelWidthPx(totalLabel));
87324
87374
  const handleClick = reactExports.useCallback(() => {
87325
87375
  onSelect(span.spanId);
87326
87376
  }, [onSelect, span.spanId]);
@@ -87330,21 +87380,35 @@ const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, v
87330
87380
  className: offscreen.left ? "pl-10" : void 0
87331
87381
  }) : null] }) : null] }) });
87332
87382
  });
87333
- const DELTA_CAP_HEIGHT_PX = 8;
87334
- const DELTA_ROW_OFFSET_PX = 8;
87335
- const DeltaIndicator = reactExports.memo(function DeltaIndicator2({ leftFrac, rightFrac, label, rowIndex }) {
87336
- const centerY = DELTA_ROW_OFFSET_PX + (rowIndex + 1) * ROW_HEIGHT_PX;
87337
- return jsxRuntimeExports.jsxs("div", { className: "absolute pointer-events-none", style: {
87338
- left: `${leftFrac * 100}%`,
87339
- width: `${(rightFrac - leftFrac) * 100}%`,
87340
- top: centerY - DELTA_CAP_HEIGHT_PX / 2,
87341
- height: DELTA_CAP_HEIGHT_PX
87342
- }, children: [jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute left-0 right-0 top-1/2 h-px bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-label-12 leading-none whitespace-nowrap rounded-xs px-1 py-0.5 text-gray-100 bg-amber-800", children: label })] });
87383
+ const MEASURE_GUIDE_OUTSET_PX = 4;
87384
+ const DeltaMeasureLine = reactExports.memo(function DeltaMeasureLine2({ delta, anchorRowIndex, hoveredRowIndex, timelineWidth }) {
87385
+ const anchorCenterY = anchorRowIndex * ROW_HEIGHT_PX + ROW_HEIGHT_PX / 2;
87386
+ const lineY = hoveredRowIndex * ROW_HEIGHT_PX + ROW_HEIGHT_PX / 2;
87387
+ const guideTop = Math.min(anchorCenterY, lineY);
87388
+ const guideBottom = Math.max(anchorCenterY, lineY);
87389
+ const anchorX = delta.anchorFrac * timelineWidth;
87390
+ const guideX = anchorX + (delta.anchorEdge === "end" ? MEASURE_GUIDE_OUTSET_PX : -MEASURE_GUIDE_OUTSET_PX);
87391
+ const arrowClearance = delta.hoveredOffscreen === "right" ? -28 : delta.hoveredOffscreen === "left" ? TINY_BAR_BOX_SIZE_PX + 4 : 0;
87392
+ const hoveredX = delta.hoveredFrac * timelineWidth + arrowClearance;
87393
+ const startX = Math.min(guideX, hoveredX);
87394
+ const endX = Math.max(guideX, hoveredX);
87395
+ const label = formatDurationPrecise(delta.deltaMs);
87396
+ const labelWidthPx = estimateLabelWidthPx(label);
87397
+ const labelPlacement = endX - startX >= labelWidthPx ? { left: (startX + endX) / 2, translate: "-translate-x-1/2" } : endX + 4 + labelWidthPx <= timelineWidth ? { left: endX + 4, translate: "" } : { left: startX - 4, translate: "-translate-x-full" };
87398
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "absolute h-px bg-amber-800", style: {
87399
+ left: Math.min(anchorX, guideX),
87400
+ width: MEASURE_GUIDE_OUTSET_PX,
87401
+ top: anchorCenterY
87402
+ } }), jsxRuntimeExports.jsx("div", { className: "absolute w-px bg-amber-800", style: {
87403
+ left: guideX,
87404
+ top: guideTop,
87405
+ height: guideBottom - guideTop
87406
+ } }), jsxRuntimeExports.jsx("div", { className: "absolute h-px bg-amber-800", style: { left: startX, width: Math.max(endX - startX, 1), top: lineY } }), jsxRuntimeExports.jsx("span", { className: cn$4("absolute -translate-y-1/2 font-mono text-[10px] font-medium leading-none tabular-nums whitespace-nowrap rounded-xs bg-background-100 px-1 py-0.5 text-amber-800", labelPlacement.translate), style: { left: labelPlacement.left, top: lineY }, children: label })] });
87343
87407
  });
87344
87408
  function TimelineHeader({ markers: markers2, hoverInfo: hoverInfo2 }) {
87345
87409
  return jsxRuntimeExports.jsx("div", { className: "relative bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-end px-4 pb-1", children: jsxRuntimeExports.jsxs("div", { className: "relative h-full flex-1", children: [markers2.map((m2) => jsxRuntimeExports.jsx("span", { className: "absolute bottom-1 font-mono text-xs font-normal leading-4 text-gray-900 whitespace-nowrap", style: { left: `${m2.position * 100}%` }, children: m2.label }, String(m2.value))), hoverInfo2 && jsxRuntimeExports.jsx("span", { className: "absolute top-1 pointer-events-none z-10 font-mono text-[11px] leading-4 text-gray-1000 whitespace-nowrap bg-background-100 border border-gray-alpha-400 rounded px-1 -translate-x-1/2", style: { left: `${hoverInfo2.fraction * 100}%` }, children: hoverInfo2.label })] }) });
87346
87410
  }
87347
- function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, searchResult, onSelect, onRevealTime, hoverFraction, altHeld = false }) {
87411
+ function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, searchResult, onSelect, onRevealTime, hover, altHeld = false }) {
87348
87412
  const containerRef = reactExports.useRef(null);
87349
87413
  const [containerWidth, setContainerWidth] = reactExports.useState(0);
87350
87414
  const viewDuration = viewEnd - viewStart;
@@ -87360,11 +87424,33 @@ function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, se
87360
87424
  ro2.observe(el);
87361
87425
  return () => ro2.disconnect();
87362
87426
  }, []);
87363
- const gaps = reactExports.useMemo(() => computeSpanGaps(spans, viewStart, viewEnd), [spans, viewStart, viewEnd]);
87427
+ const gapMeasurements = reactExports.useMemo(() => computeSpanGaps(spans, viewStart, viewEnd).map((gap) => ({
87428
+ delta: {
87429
+ deltaMs: gap.gapMs,
87430
+ anchorFrac: gap.leftFrac,
87431
+ hoveredFrac: gap.rightFrac,
87432
+ anchorEdge: "end",
87433
+ hoveredOffscreen: null
87434
+ },
87435
+ anchorRowIndex: gap.rowIndex,
87436
+ hoveredRowIndex: gap.rowIndex + 1
87437
+ })), [spans, viewStart, viewEnd]);
87438
+ const anchorIndex = reactExports.useMemo(() => selectedId ? spans.findIndex((s2) => s2.spanId === selectedId) : -1, [spans, selectedId]);
87439
+ const measurement = reactExports.useMemo(() => {
87440
+ if (!altHeld || hover == null || hover.rowIndex === anchorIndex) {
87441
+ return null;
87442
+ }
87443
+ const anchorSpan = spans[anchorIndex];
87444
+ const hoveredSpan = spans[hover.rowIndex];
87445
+ if (!anchorSpan || !hoveredSpan)
87446
+ return null;
87447
+ const delta = computeSpanDelta(anchorSpan, hoveredSpan, viewStart, viewEnd);
87448
+ return delta ? { delta, anchorRowIndex: anchorIndex, hoveredRowIndex: hover.rowIndex } : null;
87449
+ }, [altHeld, anchorIndex, hover, spans, viewStart, viewEnd]);
87364
87450
  return jsxRuntimeExports.jsxs("div", { ref: containerRef, className: "relative h-full overflow-hidden", style: { minHeight: spans.length * ROW_HEIGHT_PX }, children: [jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: markers2.map((marker2) => (
87365
87451
  // Skip the "0s" origin marker since the left edge already implies it.
87366
87452
  Math.abs(marker2.value) > 1e-6 ? jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-300", style: { left: `${marker2.position * 100}%` } }, String(marker2.value)) : null
87367
- )) }), hoverFraction != null && jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0 pointer-events-none z-10", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-500", style: { left: `${hoverFraction * 100}%` } }) }), jsxRuntimeExports.jsx("div", { style: { transform: `translateY(${start2 * ROW_HEIGHT_PX}px)` }, children: spans.slice(start2, end).map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelect, onRevealTime }, span.spanId)) }), altHeld && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: gaps.map((gap) => jsxRuntimeExports.jsx(DeltaIndicator, { leftFrac: gap.leftFrac, rightFrac: gap.rightFrac, label: formatDurationPrecise(gap.gapMs), rowIndex: gap.rowIndex }, gap.rowIndex)) })] });
87453
+ )) }), hover != null && jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0 pointer-events-none z-10", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-500", style: { left: `${hover.fraction * 100}%` } }) }), jsxRuntimeExports.jsx("div", { style: { transform: `translateY(${start2 * ROW_HEIGHT_PX}px)` }, children: spans.slice(start2, end).map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelect, onRevealTime }, span.spanId)) }), altHeld && anchorIndex < 0 && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: gapMeasurements.map((gap) => jsxRuntimeExports.jsx(DeltaMeasureLine, { ...gap, timelineWidth }, gap.anchorRowIndex)) }), measurement && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none z-20", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx(DeltaMeasureLine, { ...measurement, timelineWidth }) })] });
87368
87454
  }
87369
87455
  const CANVAS_PAD_Y_PX = 6;
87370
87456
  const MIN_LINE_HEIGHT_PX = 1.5;
@@ -87646,10 +87732,10 @@ const Minimap = reactExports.memo(function Minimap2({ spans, root: root2, viewpo
87646
87732
  const SPLIT_PANE_START_ID = "trace-split-start";
87647
87733
  function SplitPane({ children: children2, className, startHeader, endHeader, scrollContainerRef }) {
87648
87734
  const parts = reactExports.Children.toArray(children2);
87649
- if (parts.length !== 2) {
87650
- throw new Error("SplitPane expects exactly two children");
87735
+ if (parts.length !== 3) {
87736
+ throw new Error("SplitPane expects exactly three children");
87651
87737
  }
87652
- const [start2, end] = parts;
87738
+ const [start2, end, endOverlay] = parts;
87653
87739
  const [startPx, setStartPx] = reactExports.useState(DEFAULT_START_PX);
87654
87740
  const containerRef = reactExports.useRef(null);
87655
87741
  const startRef = reactExports.useRef(null);
@@ -87672,7 +87758,7 @@ function SplitPane({ children: children2, className, startHeader, endHeader, scr
87672
87758
  const effectiveStartPx = containerWidth > 0 ? Math.max(MIN_PX, Math.min(containerWidth - MIN_PX - GUTTER_PX, startPx)) : startPx;
87673
87759
  const colTemplate = paneColTemplate(effectiveStartPx);
87674
87760
  const maxStartPx = Math.max(MIN_PX, containerWidth > 0 ? containerWidth - MIN_PX - GUTTER_PX : startPx);
87675
- return jsxRuntimeExports.jsxs("div", { className: cn$4("flex flex-col h-full min-h-0", className), children: [jsxRuntimeExports.jsxs("div", { className: "shrink-0 grid", style: { gridTemplateColumns: colTemplate }, children: [jsxRuntimeExports.jsx("div", { children: startHeader }), jsxRuntimeExports.jsx("div", { className: "flex justify-center", children: jsxRuntimeExports.jsx("span", { className: "h-full w-px bg-gray-alpha-400", "aria-hidden": true }) }), jsxRuntimeExports.jsx("div", { children: endHeader })] }), jsxRuntimeExports.jsxs("div", { ref: setContainerRef, className: "grid flex-1 min-h-0 overflow-x-hidden overflow-y-auto", style: { gridTemplateColumns: colTemplate }, children: [jsxRuntimeExports.jsx("div", { ref: startRef, id: SPLIT_PANE_START_ID, className: "min-w-0", children: start2 }), jsxRuntimeExports.jsxs("div", { className: "relative z-20 isolate flex shrink-0 justify-center", children: [jsxRuntimeExports.jsx("span", { className: "pointer-events-none relative z-10 h-full w-px shrink-0 bg-gray-alpha-400", "aria-hidden": true }), jsxRuntimeExports.jsx(DraggableBorder, { element: startRef, position: "right", onWidthChange: handleWidthChange, onReset: handleReset, "aria-label": "Resize event list", "aria-controls": SPLIT_PANE_START_ID, "aria-valuemin": MIN_PX, "aria-valuemax": maxStartPx, "aria-valuenow": Math.min(Math.max(Math.round(effectiveStartPx), MIN_PX), maxStartPx) })] }), end] })] });
87761
+ return jsxRuntimeExports.jsxs("div", { className: cn$4("relative flex flex-col h-full min-h-0", className), children: [jsxRuntimeExports.jsxs("div", { className: "shrink-0 grid", style: { gridTemplateColumns: colTemplate }, children: [jsxRuntimeExports.jsx("div", { children: startHeader }), jsxRuntimeExports.jsx("div", { className: "flex justify-center", children: jsxRuntimeExports.jsx("span", { className: "h-full w-px bg-gray-alpha-400", "aria-hidden": true }) }), jsxRuntimeExports.jsx("div", { children: endHeader })] }), jsxRuntimeExports.jsxs("div", { ref: setContainerRef, className: "grid flex-1 min-h-0 overflow-x-hidden overflow-y-auto", style: { gridTemplateColumns: colTemplate }, children: [jsxRuntimeExports.jsx("div", { ref: startRef, id: SPLIT_PANE_START_ID, className: "min-w-0", children: start2 }), jsxRuntimeExports.jsxs("div", { className: "relative z-20 isolate flex shrink-0 justify-center", children: [jsxRuntimeExports.jsx("span", { className: "pointer-events-none relative z-10 h-full w-px shrink-0 bg-gray-alpha-400", "aria-hidden": true }), jsxRuntimeExports.jsx(DraggableBorder, { element: startRef, position: "right", onWidthChange: handleWidthChange, onReset: handleReset, "aria-label": "Resize event list", "aria-controls": SPLIT_PANE_START_ID, "aria-valuemin": MIN_PX, "aria-valuemax": maxStartPx, "aria-valuenow": Math.min(Math.max(Math.round(effectiveStartPx), MIN_PX), maxStartPx) })] }), end] }), jsxRuntimeExports.jsxs("div", { className: "pointer-events-none absolute inset-x-0 bottom-3 z-[5] grid", style: { gridTemplateColumns: colTemplate }, children: [jsxRuntimeExports.jsx("div", {}), jsxRuntimeExports.jsx("div", {}), jsxRuntimeExports.jsx("div", { className: "flex min-w-0 items-center justify-between gap-3 pl-4 pr-3", children: endOverlay })] })] });
87676
87762
  }
87677
87763
  const hint$1 = "_hint_1dmsq_3";
87678
87764
  const styles$1 = {
@@ -87723,7 +87809,7 @@ function TraceShortcutHelper({ hasMultipleSpans, reducedMotion }) {
87723
87809
  }
87724
87810
  setVisible(false);
87725
87811
  };
87726
- return jsxRuntimeExports.jsxs("div", { className: "group sticky bottom-3 z-10 ml-4 mb-3 hidden h-8 w-fit items-center gap-1 text-xs leading-none text-gray-900 @min-[480px]:flex", children: [jsxRuntimeExports.jsx("span", { "aria-live": "polite", "aria-atomic": "true", className: "inline-flex items-center whitespace-nowrap", children: reducedMotion ? jsxRuntimeExports.jsx(AltHint, {}) : jsxRuntimeExports.jsx("span", { className: `inline-flex items-center ${styles$1.hint}`, children: index2 === 0 ? jsxRuntimeExports.jsx(AltHint, {}) : jsxRuntimeExports.jsx(NavHint, {}) }, index2) }), jsxRuntimeExports.jsx("button", { type: "button", className: "inline-flex h-5 w-5 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none", onClick: dismiss, "aria-label": "Dismiss trace shortcuts helper", children: jsxRuntimeExports.jsx(X$3, { className: "h-3 w-3" }) })] });
87812
+ return jsxRuntimeExports.jsxs("div", { className: "group pointer-events-auto hidden h-8 w-fit items-center gap-1 text-xs leading-none text-gray-900 @min-[480px]:flex", children: [jsxRuntimeExports.jsx("span", { "aria-live": "polite", "aria-atomic": "true", className: "inline-flex items-center whitespace-nowrap", children: reducedMotion ? jsxRuntimeExports.jsx(AltHint, {}) : jsxRuntimeExports.jsx("span", { className: `inline-flex items-center ${styles$1.hint}`, children: index2 === 0 ? jsxRuntimeExports.jsx(AltHint, {}) : jsxRuntimeExports.jsx(NavHint, {}) }, index2) }), jsxRuntimeExports.jsx("button", { type: "button", className: "inline-flex h-5 w-5 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none", onClick: dismiss, "aria-label": "Dismiss trace shortcuts helper", children: jsxRuntimeExports.jsx(X$3, { className: "h-3 w-3" }) })] });
87727
87813
  }
87728
87814
  const MIN_VIEWPORT_MS = 1e-3;
87729
87815
  const ZOOM_DEBOUNCE_MS = 150;
@@ -87949,14 +88035,14 @@ function NewTraceViewerContent({ trace: trace2, onLoadMore, hasMore, isLoadingMo
87949
88035
  };
87950
88036
  }, [handleClearActiveSpan]);
87951
88037
  const timelineRef = reactExports.useRef(null);
87952
- const [hoverFraction, setHoverFraction] = reactExports.useState(null);
88038
+ const [hover, setHover] = reactExports.useState(null);
87953
88039
  const hoverInfo2 = reactExports.useMemo(() => {
87954
- if (hoverFraction == null)
88040
+ if (hover == null)
87955
88041
  return null;
87956
- const absTime = viewport.start + hoverFraction * viewDuration;
88042
+ const absTime = viewport.start + hover.fraction * viewDuration;
87957
88043
  const offset2 = absTime - root2.startTime;
87958
- return { fraction: hoverFraction, label: formatDurationPrecise(offset2) };
87959
- }, [hoverFraction, viewport.start, viewDuration, root2.startTime]);
88044
+ return { fraction: hover.fraction, label: formatDurationPrecise(offset2) };
88045
+ }, [hover, viewport.start, viewDuration, root2.startTime]);
87960
88046
  const handleTimelineMouseMove = reactExports.useCallback((e) => {
87961
88047
  const el = timelineRef.current;
87962
88048
  if (!el)
@@ -87966,10 +88052,13 @@ function NewTraceViewerContent({ trace: trace2, onLoadMore, hasMore, isLoadingMo
87966
88052
  if (contentWidth <= 0)
87967
88053
  return;
87968
88054
  const fraction = Math.max(0, Math.min(1, (e.clientX - rect.left - TIMELINE_PADDING_PX) / contentWidth));
87969
- setHoverFraction(fraction);
88055
+ setHover({
88056
+ fraction,
88057
+ rowIndex: Math.floor((e.clientY - rect.top) / ROW_HEIGHT_PX)
88058
+ });
87970
88059
  }, []);
87971
88060
  const handleTimelineMouseLeave = reactExports.useCallback(() => {
87972
- setHoverFraction(null);
88061
+ setHover(null);
87973
88062
  }, []);
87974
88063
  reactExports.useEffect(() => {
87975
88064
  const el = timelineRef.current;
@@ -88011,13 +88100,13 @@ function NewTraceViewerContent({ trace: trace2, onLoadMore, hasMore, isLoadingMo
88011
88100
  el.addEventListener("wheel", onWheel, { passive: false });
88012
88101
  return () => el.removeEventListener("wheel", onWheel);
88013
88102
  }, [root2.duration, setViewport, clampToRoot]);
88014
- return jsxRuntimeExports.jsxs("div", { ref: paneRootRef, "data-pane": "pane-root", className: "relative flex w-full h-full max-h-full", children: [jsxRuntimeExports.jsxs("div", { id: "trace-parent", className: "flex-1 min-w-0 grid grid-rows-[auto_1fr] h-full min-h-0 overflow-hidden relative bg-background-100", children: [jsxRuntimeExports.jsx(Minimap, { spans: trace2.spans, root: root2, viewport, minViewportMs: MIN_VIEWPORT_MS, onViewportChange: setViewport, onAnimateTo: animateTo }), jsxRuntimeExports.jsxs(SplitPane, { scrollContainerRef, startHeader: jsxRuntimeExports.jsxs("div", { className: "bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-center pl-4 pr-2 gap-1.5", children: [jsxRuntimeExports.jsx(Search, { className: "w-3.5 h-3.5 shrink-0 text-gray-800" }), jsxRuntimeExports.jsx("input", { id: "trace-viewer-search", name: "trace-viewer-search", type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), onKeyDown: (e) => {
88103
+ return jsxRuntimeExports.jsxs("div", { ref: paneRootRef, "data-pane": "pane-root", className: "relative flex w-full h-full max-h-full", children: [jsxRuntimeExports.jsxs("div", { id: "trace-parent", className: "@container flex-1 min-w-0 grid grid-rows-[auto_1fr] h-full min-h-0 overflow-hidden relative bg-background-100", children: [jsxRuntimeExports.jsx(Minimap, { spans: trace2.spans, root: root2, viewport, minViewportMs: MIN_VIEWPORT_MS, onViewportChange: setViewport, onAnimateTo: animateTo }), jsxRuntimeExports.jsxs(SplitPane, { scrollContainerRef, startHeader: jsxRuntimeExports.jsxs("div", { className: "bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-center pl-4 pr-2 gap-1.5", children: [jsxRuntimeExports.jsx(Search, { className: "w-3.5 h-3.5 shrink-0 text-gray-800" }), jsxRuntimeExports.jsx("input", { id: "trace-viewer-search", name: "trace-viewer-search", type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), onKeyDown: (e) => {
88015
88104
  if (e.key === "Escape" && searchQuery) {
88016
88105
  e.preventDefault();
88017
88106
  e.stopPropagation();
88018
88107
  setSearchQuery("");
88019
88108
  }
88020
- }, placeholder: "Search spans...", "aria-label": "Search spans", className: "flex-1 min-w-0 bg-transparent text-sm text-gray-1000 placeholder:text-gray-800 outline-none" }), searchQuery && jsxRuntimeExports.jsx("button", { type: "button", "aria-label": "Clear search", onClick: () => setSearchQuery(""), className: "-mr-2 hidden h-full max-w-full shrink-0 cursor-pointer items-center rounded-r-md border-0 bg-transparent px-2.5 font-inherit text-base text-gray-900 no-underline transition-colors duration-150 ease-in hover:text-gray-1000 focus-visible:-outline-offset-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ds-focus-color)] min-[961px]:flex", children: jsxRuntimeExports.jsx(Kbd, { variant: "outline", size: "search", children: "Esc" }) })] }), endHeader: jsxRuntimeExports.jsx(TimelineHeader, { markers: timeMarkers, hoverInfo: hoverInfo2 }), children: [jsxRuntimeExports.jsxs("div", { className: "block overflow-visible", children: [jsxRuntimeExports.jsx(EventList, { spans: trace2.spans, activeSpanId, searchResult, onSelectSpan: handleSelectSpan }), jsxRuntimeExports.jsx("div", { ref: loadMoreSentinelRef, className: "flex justify-center", children: isLoadingMore ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-2 py-3 text-sm text-gray-800", children: [jsxRuntimeExports.jsx(Spinner, { size: 14 }), jsxRuntimeExports.jsx("span", { children: "Loading spans…" })] }) : null })] }), jsxRuntimeExports.jsxs("div", { ref: timelineRef, id: "trace-timeline", className: "@container block min-h-0 overflow-visible relative", onDoubleClick: resetZoom, onMouseMove: handleTimelineMouseMove, onMouseLeave: handleTimelineMouseLeave, children: [jsxRuntimeExports.jsx(Timeline, { spans: trace2.spans, viewStart: viewport.start, viewEnd: viewport.end, markers: timeMarkers, selectedId: activeSpanId, searchResult, onSelect: handleSelectSpan, onRevealTime: handleRevealTime, hoverFraction, altHeld }), jsxRuntimeExports.jsx(TraceShortcutHelper, { hasMultipleSpans: trace2.spans.length > 1, reducedMotion })] })] }), jsxRuntimeExports.jsxs("div", { className: "absolute right-3 bottom-3 z-[5] flex items-center border border-gray-alpha-400 rounded-md bg-background-100 shadow-sm overflow-hidden divide-x divide-gray-alpha-400", children: [jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: zoomOut, disabled: isAtMinZoom, "aria-label": "Zoom out", children: jsxRuntimeExports.jsx(ZoomOut, { className: "w-4 h-4" }) }), jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: resetZoom, "aria-label": "Reset zoom", children: jsxRuntimeExports.jsx(RotateCcw, { className: "w-3.5 h-3.5" }) }), jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: zoomIn, disabled: isAtMaxZoom, "aria-label": "Zoom in", children: jsxRuntimeExports.jsx(ZoomIn, { className: "w-4 h-4" }) })] })] }), jsxRuntimeExports.jsx(TraceDetailPanel, { containerRef: paneRootRef, onNavigateToSpan: navigateToSpan, onClose: handleClearActiveSpan })] });
88109
+ }, placeholder: "Search spans...", "aria-label": "Search spans", className: "flex-1 min-w-0 bg-transparent text-sm text-gray-1000 placeholder:text-gray-800 outline-none" }), searchQuery && jsxRuntimeExports.jsx("button", { type: "button", "aria-label": "Clear search", onClick: () => setSearchQuery(""), className: "-mr-2 hidden h-full max-w-full shrink-0 cursor-pointer items-center rounded-r-md border-0 bg-transparent px-2.5 font-inherit text-base text-gray-900 no-underline transition-colors duration-150 ease-in hover:text-gray-1000 focus-visible:-outline-offset-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ds-focus-color)] min-[961px]:flex", children: jsxRuntimeExports.jsx(Kbd, { variant: "outline", size: "search", children: "Esc" }) })] }), endHeader: jsxRuntimeExports.jsx(TimelineHeader, { markers: timeMarkers, hoverInfo: hoverInfo2 }), children: [jsxRuntimeExports.jsxs("div", { className: "block overflow-visible", children: [jsxRuntimeExports.jsx(EventList, { spans: trace2.spans, activeSpanId, searchResult, onSelectSpan: handleSelectSpan }), jsxRuntimeExports.jsx("div", { ref: loadMoreSentinelRef, className: "flex justify-center", children: isLoadingMore ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-2 py-3 text-sm text-gray-800", children: [jsxRuntimeExports.jsx(Spinner, { size: 14 }), jsxRuntimeExports.jsx("span", { children: "Loading spans…" })] }) : null })] }), jsxRuntimeExports.jsx("div", { ref: timelineRef, id: "trace-timeline", className: "@container block min-h-0 overflow-visible relative", onDoubleClick: resetZoom, onMouseMove: handleTimelineMouseMove, onMouseLeave: handleTimelineMouseLeave, children: jsxRuntimeExports.jsx(Timeline, { spans: trace2.spans, viewStart: viewport.start, viewEnd: viewport.end, markers: timeMarkers, selectedId: activeSpanId, searchResult, onSelect: handleSelectSpan, onRevealTime: handleRevealTime, hover, altHeld }) }), jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TraceShortcutHelper, { hasMultipleSpans: trace2.spans.length > 1, reducedMotion }), jsxRuntimeExports.jsxs("div", { className: "pointer-events-auto flex items-center border border-gray-alpha-400 rounded-md bg-background-100 shadow-sm overflow-hidden divide-x divide-gray-alpha-400", children: [jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: zoomOut, disabled: isAtMinZoom, "aria-label": "Zoom out", children: jsxRuntimeExports.jsx(ZoomOut, { className: "w-4 h-4" }) }), jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: resetZoom, "aria-label": "Reset zoom", children: jsxRuntimeExports.jsx(RotateCcw, { className: "w-3.5 h-3.5" }) }), jsxRuntimeExports.jsx(IconButton, { variant: "muted", size: "small", onClick: zoomIn, disabled: isAtMaxZoom, "aria-label": "Zoom in", children: jsxRuntimeExports.jsx(ZoomIn, { className: "w-4 h-4" }) })] })] })] })] }), jsxRuntimeExports.jsx(TraceDetailPanel, { containerRef: paneRootRef, onNavigateToSpan: navigateToSpan, onClose: handleClearActiveSpan })] });
88021
88110
  }
88022
88111
  const NewTraceViewer = ({ run: run2, events: events2, sidebarData, onLoadMore, hasMore, isLoadingMore, loading = false }) => {
88023
88112
  const trace2 = reactExports.useMemo(() => {
@@ -91321,6 +91410,15 @@ class ThrottleError extends WorkflowWorldError {
91321
91410
  return isError(value) && value.name === "ThrottleError";
91322
91411
  }
91323
91412
  }
91413
+ class PreconditionFailedError extends WorkflowWorldError {
91414
+ constructor(message2, options) {
91415
+ super(message2, { status: 412, retryAfter: options == null ? void 0 : options.retryAfter });
91416
+ this.name = "PreconditionFailedError";
91417
+ }
91418
+ static is(value) {
91419
+ return isError(value) && value.name === "PreconditionFailedError";
91420
+ }
91421
+ }
91324
91422
  class WorkflowRunCancelledError extends WorkflowError {
91325
91423
  constructor(runId) {
91326
91424
  super(`Workflow run "${runId}" cancelled`, {});
@@ -92005,166 +92103,35 @@ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
92005
92103
  encrypt: encrypt$1,
92006
92104
  importKey
92007
92105
  }, Symbol.toStringTag, { value: "Module" }));
92008
- const version$1 = "5.0.0-beta.34";
92009
- function assertWorldSupportsRuntimeProtocol(world) {
92010
- if (world.specVersion === SPEC_VERSION_CURRENT) {
92011
- return;
92012
- }
92013
- const supportedVersion = world.specVersion ?? "none";
92014
- throw new WorkflowRuntimeError(`This Workflow runtime requires a World with matching spec version ${SPEC_VERSION_CURRENT}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
92015
- }
92016
- const WorldCacheKey = Symbol.for("@workflow/world//cache");
92017
- const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
92018
- const GetWorldFnKey$1 = Symbol.for("@workflow/world//getWorldFn");
92019
- async function getWorldLazy() {
92020
- const g2 = globalThis;
92021
- if (g2[WorldCacheKey]) {
92022
- assertWorldSupportsRuntimeProtocol(g2[WorldCacheKey]);
92023
- return g2[WorldCacheKey];
92024
- }
92025
- if (g2[WorldCachePromiseKey]) {
92026
- g2[WorldCacheKey] = await g2[WorldCachePromiseKey];
92027
- assertWorldSupportsRuntimeProtocol(g2[WorldCacheKey]);
92028
- return g2[WorldCacheKey];
92029
- }
92030
- const getWorldFn = g2[GetWorldFnKey$1];
92031
- if (getWorldFn) {
92032
- const world = await getWorldFn();
92033
- assertWorldSupportsRuntimeProtocol(world);
92034
- return world;
92035
- }
92036
- 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.");
92037
- }
92038
- const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
92039
- const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
92040
- function getWorkflowQueueName(workflowName, namespace2) {
92041
- if (!SAFE_WORKFLOW_NAME_PATTERN.test(workflowName)) {
92042
- throw new Error(`Invalid workflow name "${workflowName}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);
92043
- }
92044
- const prefix = getQueueTopicPrefix("workflow", resolveQueueNamespace(namespace2));
92045
- return `${prefix}${workflowName}`;
92046
- }
92047
- const generateId = monotonicFactory();
92048
- function getHealthCheckStreamName(correlationId) {
92049
- return `__health_check__${correlationId}`;
92050
- }
92051
- function generateHealthCheckRunId(correlationId) {
92052
- return `wrun_hc_${correlationId}`;
92053
- }
92054
- const HEALTH_CHECK_POLL_INTERVAL = 100;
92055
- const HEALTH_CHECK_READ_TIMEOUT = 500;
92056
- function withDeadline(promise2, ms2) {
92057
- let timer2;
92058
- return Promise.race([
92059
- promise2,
92060
- new Promise((_2, reject) => {
92061
- timer2 = setTimeout(() => reject(new Error(`Operation timed out after ${ms2}ms`)), ms2);
92062
- })
92063
- ]).finally(() => clearTimeout(timer2));
92064
- }
92065
- async function readStreamWithTimeout(reader, readTimeout) {
92066
- const chunks = [];
92067
- let done = false;
92068
- let timedOut = false;
92069
- while (!done && !timedOut) {
92070
- const readPromise = reader.read();
92071
- const timeoutPromise = new Promise((resolve2) => setTimeout(() => {
92072
- timedOut = true;
92073
- resolve2({ done: true, value: void 0 });
92074
- }, readTimeout));
92075
- const result = await Promise.race([readPromise, timeoutPromise]);
92076
- done = result.done;
92077
- if (result.value)
92078
- chunks.push(result.value);
92079
- }
92080
- return { chunks, timedOut };
92081
- }
92082
- function parseHealthCheckResponse(chunks) {
92083
- if (chunks.length === 0)
92084
- return null;
92085
- const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
92086
- const combined = new Uint8Array(totalLength);
92087
- let offset2 = 0;
92088
- for (const chunk of chunks) {
92089
- combined.set(chunk, offset2);
92090
- offset2 += chunk.length;
92091
- }
92092
- const responseText = new TextDecoder().decode(combined);
92093
- let response2;
92094
- try {
92095
- response2 = JSON.parse(responseText);
92096
- } catch {
92097
- if (responseText.length > 0) {
92098
- return { healthy: true };
92099
- }
92100
- return null;
92101
- }
92102
- if (typeof response2 !== "object" || response2 === null || !("healthy" in response2) || typeof response2.healthy !== "boolean") {
92103
- return null;
92104
- }
92105
- const r2 = response2;
92106
- const parsed = {
92107
- healthy: r2.healthy
92108
- };
92109
- if (typeof r2.specVersion === "number") {
92110
- parsed.specVersion = r2.specVersion;
92111
- }
92112
- if (typeof r2.workflowCoreVersion === "string") {
92113
- parsed.workflowCoreVersion = r2.workflowCoreVersion;
92114
- }
92115
- return parsed;
92116
- }
92117
- async function healthCheck(world, endpoint, options) {
92118
- var _a3;
92119
- const timeout2 = (options == null ? void 0 : options.timeout) ?? DEFAULT_HEALTH_CHECK_TIMEOUT;
92120
- const correlationId = ((_a3 = world.createRunId) == null ? void 0 : _a3.call(world)) ?? generateId();
92121
- const streamName = getHealthCheckStreamName(correlationId);
92122
- const queueName = `${getQueueTopicPrefix(endpoint, resolveQueueNamespace(options == null ? void 0 : options.namespace))}health_check`;
92123
- const startTime = Date.now();
92124
- try {
92125
- await world.queue(queueName, { __healthCheck: true, correlationId }, {
92126
- // Use JSON transport so the health check works against both
92127
- // old (JSON-only) and new (dual) deployments.
92128
- specVersion: SPEC_VERSION_LEGACY,
92129
- deploymentId: options == null ? void 0 : options.deploymentId
92130
- });
92131
- while (Date.now() - startTime < timeout2) {
92132
- try {
92133
- const remainingMs = timeout2 - (Date.now() - startTime);
92134
- const stream = await withDeadline(world.streams.get(generateHealthCheckRunId(correlationId), streamName), remainingMs);
92135
- const reader = stream.getReader();
92136
- const { chunks, timedOut } = await readStreamWithTimeout(reader, HEALTH_CHECK_READ_TIMEOUT);
92137
- if (timedOut) {
92138
- try {
92139
- reader.cancel();
92140
- } catch {
92141
- }
92142
- await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
92143
- continue;
92144
- }
92145
- const response2 = parseHealthCheckResponse(chunks);
92146
- if (response2) {
92147
- return {
92148
- ...response2,
92149
- latencyMs: Date.now() - startTime
92150
- };
92151
- }
92152
- await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
92153
- } catch {
92154
- await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
92155
- }
92156
- }
92157
- return {
92158
- healthy: false,
92159
- error: `Health check timed out after ${timeout2}ms`
92160
- };
92161
- } catch (error2) {
92162
- return {
92163
- healthy: false,
92164
- error: error2 instanceof Error ? error2.message : String(error2)
92165
- };
92166
- }
92167
- }
92106
+ const STABLE_ULID = Symbol.for("WORKFLOW_STABLE_ULID");
92107
+ const STREAM_NAME_SYMBOL = Symbol.for("WORKFLOW_STREAM_NAME");
92108
+ const STREAM_TYPE_SYMBOL = Symbol.for("WORKFLOW_STREAM_TYPE");
92109
+ const STREAM_FRAMING_SYMBOL = Symbol.for("WORKFLOW_STREAM_FRAMING");
92110
+ const STREAM_SERVER_RUN_ID_SYMBOL = Symbol.for("WORKFLOW_STREAM_SERVER_RUN_ID");
92111
+ const STREAM_SERVER_DEPLOYMENT_ID_SYMBOL = Symbol.for("WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID");
92112
+ const STREAM_WRITE_BATCH_SYMBOL = Symbol.for("WORKFLOW_STREAM_WRITE_BATCH");
92113
+ const BODY_INIT_SYMBOL = Symbol.for("BODY_INIT");
92114
+ const WEBHOOK_RESPONSE_WRITABLE = Symbol.for("WEBHOOK_RESPONSE_WRITABLE");
92115
+ const WORKFLOW_CLASS_REGISTRY = Symbol.for("workflow-class-registry");
92116
+ const ABORT_STREAM_NAME = Symbol.for("WORKFLOW_ABORT_STREAM_NAME");
92117
+ const ABORT_HOOK_TOKEN = Symbol.for("WORKFLOW_ABORT_HOOK_TOKEN");
92118
+ const ABORT_LISTENER_ATTACHED = Symbol.for("WORKFLOW_ABORT_LISTENER_ATTACHED");
92119
+ const ABORT_READER_CANCEL = Symbol.for("WORKFLOW_ABORT_READER_CANCEL");
92120
+ const MAX_INFLIGHT_CHUNKS = 1e3;
92121
+ const getMaxInflightChunks = () => envNumber("WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS", MAX_INFLIGHT_CHUNKS, {
92122
+ integer: true,
92123
+ min: 1
92124
+ });
92125
+ const MAX_CHUNKS_PER_BATCH = 1e3;
92126
+ const getMaxChunksPerBatch = () => envNumber("WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH", MAX_CHUNKS_PER_BATCH, {
92127
+ integer: true,
92128
+ min: 1
92129
+ });
92130
+ const MAX_BYTES_PER_BATCH = 1024 * 1024;
92131
+ const getMaxBytesPerBatch = () => envNumber("WORKFLOW_STREAM_MAX_BYTES_PER_BATCH", MAX_BYTES_PER_BATCH, {
92132
+ integer: true,
92133
+ min: 1
92134
+ });
92168
92135
  const LOCK_POLL_INTERVAL_MS = 10;
92169
92136
  const getLockPollIntervalMs = () => envNumber("WORKFLOW_LOCK_POLL_INTERVAL_MS", LOCK_POLL_INTERVAL_MS, {
92170
92137
  integer: true,
@@ -92251,7 +92218,11 @@ function pollReadableLock(readable2, state) {
92251
92218
  }, getLockPollIntervalMs());
92252
92219
  state.readablePollingInterval = intervalId;
92253
92220
  }
92254
- async function flushablePipe(source, sink, state) {
92221
+ function flushablePipe(source, sink, state) {
92222
+ const batchWrite = sink[STREAM_WRITE_BATCH_SYMBOL];
92223
+ return typeof batchWrite === "function" ? flushablePipeCoalescing(source, sink, state, batchWrite) : flushablePipePerChunk(source, sink, state);
92224
+ }
92225
+ async function flushablePipePerChunk(source, sink, state) {
92255
92226
  const reader = source.getReader();
92256
92227
  const writer = sink.getWriter();
92257
92228
  let cancelReason;
@@ -92300,6 +92271,124 @@ async function flushablePipe(source, sink, state) {
92300
92271
  writer.releaseLock();
92301
92272
  }
92302
92273
  }
92274
+ function wake$1(ctx, which) {
92275
+ const resolve2 = ctx[which];
92276
+ if (resolve2) {
92277
+ ctx[which] = null;
92278
+ resolve2();
92279
+ }
92280
+ }
92281
+ function nextBatchSize(ctx) {
92282
+ let count2 = 0;
92283
+ let bytes = 0;
92284
+ for (const chunk of ctx.queue) {
92285
+ if (count2 >= ctx.maxChunksPerBatch)
92286
+ break;
92287
+ if (count2 > 0 && bytes + chunk.byteLength > ctx.maxBytesPerBatch)
92288
+ break;
92289
+ count2++;
92290
+ bytes += chunk.byteLength;
92291
+ }
92292
+ return count2;
92293
+ }
92294
+ async function drainBatches(ctx) {
92295
+ while (true) {
92296
+ if (ctx.queue.length === 0) {
92297
+ if (ctx.sourceDone)
92298
+ return;
92299
+ await new Promise((resolve2) => {
92300
+ ctx.wakeConsumer = resolve2;
92301
+ });
92302
+ continue;
92303
+ }
92304
+ const count2 = nextBatchSize(ctx);
92305
+ const batch = ctx.queue.slice(0, count2);
92306
+ ctx.queue = ctx.queue.slice(count2);
92307
+ await ctx.batchWrite(batch);
92308
+ ctx.state.pendingOps -= batch.length;
92309
+ wake$1(ctx, "wakeProducer");
92310
+ }
92311
+ }
92312
+ function readNextChunk(reader, writer, consumer) {
92313
+ return Promise.race([
92314
+ reader.read(),
92315
+ writer.closed.then(() => {
92316
+ throw new WorkflowRuntimeError("Writable stream closed prematurely");
92317
+ }),
92318
+ consumer.then(() => {
92319
+ throw new WorkflowRuntimeError("Stream consumer ended prematurely");
92320
+ }, (err) => {
92321
+ throw err;
92322
+ })
92323
+ ]);
92324
+ }
92325
+ async function awaitBackpressureRelief(ctx, consumer, maxInflight) {
92326
+ if (ctx.state.pendingOps < maxInflight)
92327
+ return;
92328
+ await Promise.race([
92329
+ new Promise((resolve2) => {
92330
+ ctx.wakeProducer = resolve2;
92331
+ }),
92332
+ consumer.then(() => void 0, () => void 0)
92333
+ ]);
92334
+ }
92335
+ async function flushablePipeCoalescing(source, sink, state, batchWrite) {
92336
+ const reader = source.getReader();
92337
+ const writer = sink.getWriter();
92338
+ const maxInflight = getMaxInflightChunks();
92339
+ let cancelReason;
92340
+ const ctx = {
92341
+ state,
92342
+ batchWrite,
92343
+ queue: [],
92344
+ sourceDone: false,
92345
+ wakeConsumer: null,
92346
+ wakeProducer: null,
92347
+ maxChunksPerBatch: getMaxChunksPerBatch(),
92348
+ maxBytesPerBatch: getMaxBytesPerBatch()
92349
+ };
92350
+ const consumer = drainBatches(ctx);
92351
+ try {
92352
+ while (!state.streamEnded) {
92353
+ const readResult = await readNextChunk(reader, writer, consumer);
92354
+ if (state.streamEnded)
92355
+ return;
92356
+ if (readResult.done) {
92357
+ ctx.sourceDone = true;
92358
+ wake$1(ctx, "wakeConsumer");
92359
+ await consumer;
92360
+ state.streamEnded = true;
92361
+ await writer.close();
92362
+ if (!state.doneResolved) {
92363
+ state.doneResolved = true;
92364
+ state.resolve();
92365
+ }
92366
+ return;
92367
+ }
92368
+ ctx.queue.push(readResult.value);
92369
+ state.pendingOps++;
92370
+ wake$1(ctx, "wakeConsumer");
92371
+ await awaitBackpressureRelief(ctx, consumer, maxInflight);
92372
+ }
92373
+ } catch (err) {
92374
+ state.streamEnded = true;
92375
+ cancelReason = err;
92376
+ ctx.sourceDone = true;
92377
+ wake$1(ctx, "wakeConsumer");
92378
+ await consumer.catch(() => {
92379
+ });
92380
+ if (!state.doneResolved) {
92381
+ state.doneResolved = true;
92382
+ state.reject(err);
92383
+ }
92384
+ throw err;
92385
+ } finally {
92386
+ reader.cancel(cancelReason).catch(() => {
92387
+ });
92388
+ reader.releaseLock();
92389
+ writer.releaseLock();
92390
+ }
92391
+ }
92303
92392
  const RegisteredStepsKey = Symbol.for("@workflow/core//registeredSteps");
92304
92393
  const globalSymbols$1 = globalThis;
92305
92394
  const registeredSteps = globalSymbols$1[RegisteredStepsKey] ?? (globalSymbols$1[RegisteredStepsKey] = /* @__PURE__ */ new Map());
@@ -92364,21 +92453,37 @@ function getStepFunction(stepId) {
92364
92453
  }
92365
92454
  return void 0;
92366
92455
  }
92456
+ function assertWorldSupportsRuntimeProtocol(world) {
92457
+ if (world.specVersion === SPEC_VERSION_CURRENT) {
92458
+ return;
92459
+ }
92460
+ const supportedVersion = world.specVersion ?? "none";
92461
+ throw new WorkflowRuntimeError(`This Workflow runtime requires a World with matching spec version ${SPEC_VERSION_CURRENT}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
92462
+ }
92463
+ const WorldCacheKey = Symbol.for("@workflow/world//cache");
92464
+ const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
92465
+ const GetWorldFnKey$1 = Symbol.for("@workflow/world//getWorldFn");
92466
+ async function getWorldLazy() {
92467
+ const g2 = globalThis;
92468
+ if (g2[WorldCacheKey]) {
92469
+ assertWorldSupportsRuntimeProtocol(g2[WorldCacheKey]);
92470
+ return g2[WorldCacheKey];
92471
+ }
92472
+ if (g2[WorldCachePromiseKey]) {
92473
+ g2[WorldCacheKey] = await g2[WorldCachePromiseKey];
92474
+ assertWorldSupportsRuntimeProtocol(g2[WorldCacheKey]);
92475
+ return g2[WorldCacheKey];
92476
+ }
92477
+ const getWorldFn = g2[GetWorldFnKey$1];
92478
+ if (getWorldFn) {
92479
+ const world = await getWorldFn();
92480
+ assertWorldSupportsRuntimeProtocol(world);
92481
+ return world;
92482
+ }
92483
+ 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.");
92484
+ }
92367
92485
  const WORKFLOW_SERIALIZE = Symbol.for("workflow-serialize");
92368
92486
  const WORKFLOW_DESERIALIZE = Symbol.for("workflow-deserialize");
92369
- const STABLE_ULID = Symbol.for("WORKFLOW_STABLE_ULID");
92370
- const STREAM_NAME_SYMBOL = Symbol.for("WORKFLOW_STREAM_NAME");
92371
- const STREAM_TYPE_SYMBOL = Symbol.for("WORKFLOW_STREAM_TYPE");
92372
- const STREAM_FRAMING_SYMBOL = Symbol.for("WORKFLOW_STREAM_FRAMING");
92373
- const STREAM_SERVER_RUN_ID_SYMBOL = Symbol.for("WORKFLOW_STREAM_SERVER_RUN_ID");
92374
- const STREAM_SERVER_DEPLOYMENT_ID_SYMBOL = Symbol.for("WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID");
92375
- const BODY_INIT_SYMBOL = Symbol.for("BODY_INIT");
92376
- const WEBHOOK_RESPONSE_WRITABLE = Symbol.for("WEBHOOK_RESPONSE_WRITABLE");
92377
- const WORKFLOW_CLASS_REGISTRY = Symbol.for("workflow-class-registry");
92378
- const ABORT_STREAM_NAME = Symbol.for("WORKFLOW_ABORT_STREAM_NAME");
92379
- const ABORT_HOOK_TOKEN = Symbol.for("WORKFLOW_ABORT_HOOK_TOKEN");
92380
- const ABORT_LISTENER_ATTACHED = Symbol.for("WORKFLOW_ABORT_LISTENER_ATTACHED");
92381
- const ABORT_READER_CANCEL = Symbol.for("WORKFLOW_ABORT_READER_CANCEL");
92382
92487
  function getRegistry(global2 = globalThis) {
92383
92488
  const g2 = global2;
92384
92489
  let registry2 = g2[WORKFLOW_CLASS_REGISTRY];
@@ -93879,6 +93984,19 @@ class WorkflowServerWritableStream extends WritableStream {
93879
93984
  w2.reject(abortError);
93880
93985
  }
93881
93986
  });
93987
+ Object.defineProperty(this, STREAM_WRITE_BATCH_SYMBOL, {
93988
+ value: async (chunks) => {
93989
+ if (chunks.length === 0)
93990
+ return;
93991
+ if (batchStartAt === void 0)
93992
+ batchStartAt = Date.now();
93993
+ for (const chunk of chunks)
93994
+ buffer2.push(chunk);
93995
+ await flush();
93996
+ },
93997
+ enumerable: false,
93998
+ writable: false
93999
+ });
93882
94000
  }
93883
94001
  }
93884
94002
  function getAllBaseReducers(global2 = globalThis) {
@@ -94666,8 +94784,20 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
94666
94784
  AbortSignal: (value) => reviveAbortSignal(value, ops, runId)
94667
94785
  };
94668
94786
  }
94669
- async function maybeDecrypt(data, key) {
94670
- return decrypt(data, key);
94787
+ const prepareReplayPayload = async (value, key) => {
94788
+ const compressionStats = {};
94789
+ const prepared = await decompress$2(await decrypt(value, key), compressionStats);
94790
+ await recordCompression(compressionStats, "deserialize");
94791
+ return { data: prepared };
94792
+ };
94793
+ function deserializePreparedReplayPayload(prepared, global2 = globalThis, extraRevivers = {}) {
94794
+ return deserialize(prepared.data, {
94795
+ global: global2,
94796
+ extraRevivers: {
94797
+ ...getStreamAndRequestRevivers(getWorkflowRevivers(global2)),
94798
+ ...extraRevivers
94799
+ }
94800
+ });
94671
94801
  }
94672
94802
  async function dehydrateWorkflowArguments(value, runId, key, ops = [], global2 = globalThis, v1Compat = false, framedByteStreams = false, compression = false) {
94673
94803
  if (v1Compat) {
@@ -94690,17 +94820,8 @@ async function dehydrateWorkflowArguments(value, runId, key, ops = [], global2 =
94690
94820
  throw new SerializationError(message2, { hint: hint2, cause });
94691
94821
  }
94692
94822
  }
94693
- async function hydrateWorkflowArguments(value, _runId, key, global2 = globalThis, extraRevivers = {}) {
94694
- const compressionStats = {};
94695
- const inflated = await decompress$2(await maybeDecrypt(value, key), compressionStats);
94696
- await recordCompression(compressionStats, "deserialize");
94697
- return deserialize(inflated, {
94698
- global: global2,
94699
- extraRevivers: {
94700
- ...getStreamAndRequestRevivers(getWorkflowRevivers(global2)),
94701
- ...extraRevivers
94702
- }
94703
- });
94823
+ async function hydrateWorkflowArguments(value, _runId, key, global2 = globalThis, extraRevivers = {}, prepared) {
94824
+ return deserializePreparedReplayPayload(await prepareReplayPayload(value, key), global2, extraRevivers);
94704
94825
  }
94705
94826
  async function hydrateWorkflowReturnValue(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
94706
94827
  const compressionStats = {};
@@ -94772,7 +94893,7 @@ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = g
94772
94893
  }
94773
94894
  async function hydrateRunError(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
94774
94895
  const compressionStats = {};
94775
- const decrypted = await decompress$2(await maybeDecrypt(value, key), compressionStats);
94896
+ const decrypted = await decompress$2(await decrypt(value, key), compressionStats);
94776
94897
  await recordCompression(compressionStats, "deserialize");
94777
94898
  if (!(decrypted instanceof Uint8Array)) {
94778
94899
  return unflatten(decrypted, {
@@ -94821,6 +94942,137 @@ function getStreamAndRequestRevivers(allRevivers) {
94821
94942
  }
94822
94943
  return extra;
94823
94944
  }
94945
+ const version$1 = "5.0.0-beta.36";
94946
+ const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
94947
+ const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
94948
+ function getWorkflowQueueName(workflowName, namespace2) {
94949
+ if (!SAFE_WORKFLOW_NAME_PATTERN.test(workflowName)) {
94950
+ throw new Error(`Invalid workflow name "${workflowName}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);
94951
+ }
94952
+ const prefix = getQueueTopicPrefix("workflow", resolveQueueNamespace(namespace2));
94953
+ return `${prefix}${workflowName}`;
94954
+ }
94955
+ const generateId = monotonicFactory();
94956
+ function getHealthCheckStreamName(correlationId) {
94957
+ return `__health_check__${correlationId}`;
94958
+ }
94959
+ function generateHealthCheckRunId(correlationId) {
94960
+ return `wrun_hc_${correlationId}`;
94961
+ }
94962
+ const HEALTH_CHECK_POLL_INTERVAL = 100;
94963
+ const HEALTH_CHECK_READ_TIMEOUT = 500;
94964
+ function withDeadline(promise2, ms2) {
94965
+ let timer2;
94966
+ return Promise.race([
94967
+ promise2,
94968
+ new Promise((_2, reject) => {
94969
+ timer2 = setTimeout(() => reject(new Error(`Operation timed out after ${ms2}ms`)), ms2);
94970
+ })
94971
+ ]).finally(() => clearTimeout(timer2));
94972
+ }
94973
+ async function readStreamWithTimeout(reader, readTimeout) {
94974
+ const chunks = [];
94975
+ let done = false;
94976
+ let timedOut = false;
94977
+ while (!done && !timedOut) {
94978
+ const readPromise = reader.read();
94979
+ const timeoutPromise = new Promise((resolve2) => setTimeout(() => {
94980
+ timedOut = true;
94981
+ resolve2({ done: true, value: void 0 });
94982
+ }, readTimeout));
94983
+ const result = await Promise.race([readPromise, timeoutPromise]);
94984
+ done = result.done;
94985
+ if (result.value)
94986
+ chunks.push(result.value);
94987
+ }
94988
+ return { chunks, timedOut };
94989
+ }
94990
+ function parseHealthCheckResponse(chunks) {
94991
+ if (chunks.length === 0)
94992
+ return null;
94993
+ const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
94994
+ const combined = new Uint8Array(totalLength);
94995
+ let offset2 = 0;
94996
+ for (const chunk of chunks) {
94997
+ combined.set(chunk, offset2);
94998
+ offset2 += chunk.length;
94999
+ }
95000
+ const responseText = new TextDecoder().decode(combined);
95001
+ let response2;
95002
+ try {
95003
+ response2 = JSON.parse(responseText);
95004
+ } catch {
95005
+ if (responseText.length > 0) {
95006
+ return { healthy: true };
95007
+ }
95008
+ return null;
95009
+ }
95010
+ if (typeof response2 !== "object" || response2 === null || !("healthy" in response2) || typeof response2.healthy !== "boolean") {
95011
+ return null;
95012
+ }
95013
+ const r2 = response2;
95014
+ const parsed = {
95015
+ healthy: r2.healthy
95016
+ };
95017
+ if (typeof r2.specVersion === "number") {
95018
+ parsed.specVersion = r2.specVersion;
95019
+ }
95020
+ if (typeof r2.workflowCoreVersion === "string") {
95021
+ parsed.workflowCoreVersion = r2.workflowCoreVersion;
95022
+ }
95023
+ return parsed;
95024
+ }
95025
+ async function healthCheck(world, endpoint, options) {
95026
+ var _a3;
95027
+ const timeout2 = (options == null ? void 0 : options.timeout) ?? DEFAULT_HEALTH_CHECK_TIMEOUT;
95028
+ const correlationId = ((_a3 = world.createRunId) == null ? void 0 : _a3.call(world)) ?? generateId();
95029
+ const streamName = getHealthCheckStreamName(correlationId);
95030
+ const queueName = `${getQueueTopicPrefix(endpoint, resolveQueueNamespace(options == null ? void 0 : options.namespace))}health_check`;
95031
+ const startTime = Date.now();
95032
+ try {
95033
+ await world.queue(queueName, { __healthCheck: true, correlationId }, {
95034
+ // Use JSON transport so the health check works against both
95035
+ // old (JSON-only) and new (dual) deployments.
95036
+ specVersion: SPEC_VERSION_LEGACY,
95037
+ deploymentId: options == null ? void 0 : options.deploymentId
95038
+ });
95039
+ while (Date.now() - startTime < timeout2) {
95040
+ try {
95041
+ const remainingMs = timeout2 - (Date.now() - startTime);
95042
+ const stream = await withDeadline(world.streams.get(generateHealthCheckRunId(correlationId), streamName), remainingMs);
95043
+ const reader = stream.getReader();
95044
+ const { chunks, timedOut } = await readStreamWithTimeout(reader, HEALTH_CHECK_READ_TIMEOUT);
95045
+ if (timedOut) {
95046
+ try {
95047
+ reader.cancel();
95048
+ } catch {
95049
+ }
95050
+ await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
95051
+ continue;
95052
+ }
95053
+ const response2 = parseHealthCheckResponse(chunks);
95054
+ if (response2) {
95055
+ return {
95056
+ ...response2,
95057
+ latencyMs: Date.now() - startTime
95058
+ };
95059
+ }
95060
+ await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
95061
+ } catch {
95062
+ await new Promise((resolve2) => setTimeout(resolve2, HEALTH_CHECK_POLL_INTERVAL));
95063
+ }
95064
+ }
95065
+ return {
95066
+ healthy: false,
95067
+ error: `Health check timed out after ${timeout2}ms`
95068
+ };
95069
+ } catch (error2) {
95070
+ return {
95071
+ healthy: false,
95072
+ error: error2 instanceof Error ? error2.message : String(error2)
95073
+ };
95074
+ }
95075
+ }
94824
95076
  function throwMissingStaticInjection() {
94825
95077
  throw new Error("Workflow target world was not statically injected. Configure a Workflow builder/framework plugin so @workflow/core/runtime/world-target is aliased to the selected world package.");
94826
95078
  }
@@ -94882,6 +95134,171 @@ const getWorld = async () => {
94882
95134
  };
94883
95135
  const GetWorldFnKey = Symbol.for("@workflow/world//getWorldFn");
94884
95136
  globalThis[GetWorldFnKey] ?? (globalThis[GetWorldFnKey] = getWorld);
95137
+ const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
95138
+ const DECODE_TABLE = (() => {
95139
+ const table2 = new Int8Array(128).fill(-1);
95140
+ for (let i = 0; i < ENCODING.length; i++) {
95141
+ table2[ENCODING.charCodeAt(i)] = i;
95142
+ }
95143
+ for (let i = 0; i < ENCODING.length; i++) {
95144
+ const lower2 = ENCODING[i].toLowerCase();
95145
+ if (lower2 !== ENCODING[i]) {
95146
+ table2[lower2.charCodeAt(0)] = i;
95147
+ }
95148
+ }
95149
+ return table2;
95150
+ })();
95151
+ const ULID_LENGTH = 26;
95152
+ const ULID_BYTE_LENGTH = 16;
95153
+ const TAG_BIT_MASK = 128;
95154
+ const REGION_MASK = 252;
95155
+ const VERSION_HIGH_MASK = 3;
95156
+ const VERSION_LOW_MASK = 224;
95157
+ const REGION_BYTE_INDEX = 6;
95158
+ const VERSION_LOW_BYTE_INDEX = 7;
95159
+ const VERSION_BIT_WIDTH = 5;
95160
+ const REGION_BIT_WIDTH = 6;
95161
+ const MAX_VERSION = (1 << VERSION_BIT_WIDTH) - 1;
95162
+ const MAX_REGION = (1 << REGION_BIT_WIDTH) - 1;
95163
+ function ulidToBytes(ulid2) {
95164
+ if (typeof ulid2 !== "string") {
95165
+ throw new TypeError(`Expected ULID string, got ${typeof ulid2}`);
95166
+ }
95167
+ if (ulid2.length !== ULID_LENGTH) {
95168
+ throw new Error(`Invalid ULID length: expected ${ULID_LENGTH}, got ${ulid2.length}`);
95169
+ }
95170
+ const values = new Uint8Array(ULID_LENGTH);
95171
+ for (let i = 0; i < ULID_LENGTH; i++) {
95172
+ const code2 = ulid2.charCodeAt(i);
95173
+ const v2 = code2 < 128 ? DECODE_TABLE[code2] : -1;
95174
+ if (v2 < 0) {
95175
+ throw new Error(`Invalid Crockford-Base32 character at index ${i}: ${JSON.stringify(ulid2[i])}`);
95176
+ }
95177
+ values[i] = v2;
95178
+ }
95179
+ if ((values[0] & 24) !== 0) {
95180
+ throw new Error(`Invalid ULID: top 2 bits must be zero (first char > '7'): ${JSON.stringify(ulid2[0])}`);
95181
+ }
95182
+ const out = new Uint8Array(ULID_BYTE_LENGTH);
95183
+ let bitBuf = values[0] & 7;
95184
+ let bitCount = 3;
95185
+ let outIdx = 0;
95186
+ for (let i = 1; i < ULID_LENGTH; i++) {
95187
+ bitBuf = bitBuf << 5 | values[i];
95188
+ bitCount += 5;
95189
+ while (bitCount >= 8) {
95190
+ bitCount -= 8;
95191
+ out[outIdx++] = bitBuf >> bitCount & 255;
95192
+ }
95193
+ }
95194
+ if (outIdx !== ULID_BYTE_LENGTH || bitCount !== 0) {
95195
+ throw new Error("Internal error: ULID bit packing did not consume cleanly");
95196
+ }
95197
+ return out;
95198
+ }
95199
+ function bytesToUlid(bytes) {
95200
+ if (bytes.length !== ULID_BYTE_LENGTH) {
95201
+ throw new Error(`Invalid byte length: expected ${ULID_BYTE_LENGTH}, got ${bytes.length}`);
95202
+ }
95203
+ let bitBuf = 0;
95204
+ let bitCount = 0;
95205
+ bitBuf = 0;
95206
+ bitCount = 2;
95207
+ let out = "";
95208
+ for (let i = 0; i < ULID_BYTE_LENGTH; i++) {
95209
+ bitBuf = bitBuf << 8 | bytes[i];
95210
+ bitCount += 8;
95211
+ while (bitCount >= 5) {
95212
+ bitCount -= 5;
95213
+ out += ENCODING[bitBuf >> bitCount & 31];
95214
+ }
95215
+ }
95216
+ if (out.length !== ULID_LENGTH || bitCount !== 0) {
95217
+ throw new Error("Internal error: ULID bit packing did not flush cleanly");
95218
+ }
95219
+ return out;
95220
+ }
95221
+ const REGION_IDS = {
95222
+ unknown: 0,
95223
+ iad1: 1,
95224
+ sfo1: 2,
95225
+ pdx1: 3,
95226
+ cle1: 4,
95227
+ yul1: 5,
95228
+ gru1: 6,
95229
+ dub1: 7,
95230
+ lhr1: 8,
95231
+ cdg1: 9,
95232
+ fra1: 10,
95233
+ bru1: 11,
95234
+ arn1: 12,
95235
+ hel1: 13,
95236
+ zrh1: 14,
95237
+ cpt1: 15,
95238
+ dxb1: 16,
95239
+ bom1: 17,
95240
+ sin1: 18,
95241
+ hkg1: 19,
95242
+ hnd1: 20,
95243
+ icn1: 21,
95244
+ kix1: 22,
95245
+ syd1: 23
95246
+ };
95247
+ const DEFAULT_REGION_CODE = "iad1";
95248
+ const REGION_CODES_BY_ID = new Map(Object.entries(REGION_IDS).filter((entry2) => entry2[0] !== "unknown").map(([code2, id2]) => [id2, code2]));
95249
+ function lookupRegion(regionId) {
95250
+ return REGION_CODES_BY_ID.get(regionId) ?? null;
95251
+ }
95252
+ function isKnownRegionCode(code2) {
95253
+ return code2 !== void 0 && code2 !== "unknown" && Object.hasOwn(REGION_IDS, code2);
95254
+ }
95255
+ const CURRENT_VERSION = 1;
95256
+ function isRegionCode(value) {
95257
+ return typeof value === "string" && value !== "unknown" && Object.hasOwn(REGION_IDS, value);
95258
+ }
95259
+ function encode(ulid2, region, options = {}) {
95260
+ let regionId;
95261
+ if (typeof region === "number") {
95262
+ if (!Number.isInteger(region) || region < 0 || region > MAX_REGION) {
95263
+ throw new RangeError(`regionId must be an integer in [0, ${MAX_REGION}]; got ${region}`);
95264
+ }
95265
+ regionId = region;
95266
+ } else if (isRegionCode(region)) {
95267
+ regionId = REGION_IDS[region];
95268
+ } else {
95269
+ throw new Error(`Unknown region: ${String(region)}`);
95270
+ }
95271
+ const version2 = options.version ?? CURRENT_VERSION;
95272
+ if (!Number.isInteger(version2) || version2 < 0 || version2 > MAX_VERSION) {
95273
+ throw new RangeError(`version must be an integer in [0, ${MAX_VERSION}]; got ${version2}`);
95274
+ }
95275
+ const bytes = ulidToBytes(ulid2);
95276
+ bytes[0] = bytes[0] | TAG_BIT_MASK;
95277
+ const regionShifted = (regionId & MAX_REGION) << 2;
95278
+ const versionHigh = version2 >> 3 & VERSION_HIGH_MASK;
95279
+ const versionLow = (version2 & 7) << 5;
95280
+ bytes[REGION_BYTE_INDEX] = bytes[REGION_BYTE_INDEX] & -256 | regionShifted | versionHigh;
95281
+ bytes[VERSION_LOW_BYTE_INDEX] = bytes[VERSION_LOW_BYTE_INDEX] & ~VERSION_LOW_MASK | versionLow;
95282
+ return bytesToUlid(bytes);
95283
+ }
95284
+ function decode(taggedUlid) {
95285
+ const bytes = ulidToBytes(taggedUlid);
95286
+ const tagged = (bytes[0] & TAG_BIT_MASK) !== 0;
95287
+ bytes[0] = bytes[0] & ~TAG_BIT_MASK;
95288
+ const ulid2 = bytesToUlid(bytes);
95289
+ if (!tagged) {
95290
+ return { tagged: false, ulid: ulid2, version: null, regionId: null, region: null };
95291
+ }
95292
+ const regionId = (bytes[REGION_BYTE_INDEX] & REGION_MASK) >> 2;
95293
+ const version2 = (bytes[REGION_BYTE_INDEX] & VERSION_HIGH_MASK) << 3 | (bytes[VERSION_LOW_BYTE_INDEX] & VERSION_LOW_MASK) >> 5;
95294
+ return {
95295
+ tagged: true,
95296
+ ulid: ulid2,
95297
+ version: version2,
95298
+ regionId,
95299
+ region: lookupRegion(regionId)
95300
+ };
95301
+ }
94885
95302
  function waitUntil(promise2) {
94886
95303
  void import("./index-DIXsjgfZ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
94887
95304
  waitUntil2(promise2);
@@ -97565,17 +97982,21 @@ function getRunCapabilities(workflowCoreVersion) {
97565
97982
  }
97566
97983
  return result;
97567
97984
  }
97568
- async function getHookByTokenWithKey(token) {
97569
- var _a3;
97985
+ async function getHookAndRun(token) {
97570
97986
  const world = await getWorldLazy();
97571
97987
  const hook = await world.hooks.getByToken(token);
97572
97988
  const run2 = await world.runs.get(hook.runId);
97573
- const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run2));
97989
+ return { hook, run: run2 };
97990
+ }
97991
+ async function getHookByTokenWithKey(token) {
97992
+ var _a3, _b2;
97993
+ const { hook, run: run2 } = await getHookAndRun(token);
97994
+ const rawKey = await ((_b2 = (_a3 = await getWorldLazy()).getEncryptionKeyForRun) == null ? void 0 : _b2.call(_a3, run2));
97574
97995
  const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
97575
97996
  if (typeof hook.metadata !== "undefined") {
97576
97997
  hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId, encryptionKey);
97577
97998
  }
97578
- return { hook, run: run2, encryptionKey };
97999
+ return { hook, encryptionKey };
97579
98000
  }
97580
98001
  async function getHookByToken$1(token) {
97581
98002
  const { hook } = await getHookByTokenWithKey(token);
@@ -97589,27 +98010,27 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
97589
98010
  try {
97590
98011
  let hook;
97591
98012
  let workflowRun;
97592
- let encryptionKey;
97593
98013
  if (typeof tokenOrHook === "string") {
97594
- const result = await getHookByTokenWithKey(tokenOrHook);
98014
+ const result = await getHookAndRun(tokenOrHook);
97595
98015
  hook = result.hook;
97596
98016
  workflowRun = result.run;
97597
- encryptionKey = encryptionKeyOverride ?? result.encryptionKey;
97598
98017
  } else {
97599
98018
  hook = tokenOrHook;
97600
98019
  workflowRun = await world.runs.get(hook.runId);
97601
- if (encryptionKeyOverride) {
97602
- encryptionKey = encryptionKeyOverride;
97603
- } else {
97604
- const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, workflowRun));
97605
- encryptionKey = rawKey ? await importKey(rawKey) : void 0;
97606
- }
97607
98020
  }
97608
98021
  span == null ? void 0 : span.setAttributes({
97609
98022
  ...HookToken(hook.token),
97610
98023
  ...HookId(hook.hookId),
97611
98024
  ...WorkflowRunId$2(hook.runId)
97612
98025
  });
98026
+ if (isTerminalWorkflowRunStatus(workflowRun.status)) {
98027
+ throw new HookNotFoundError(hook.token);
98028
+ }
98029
+ let encryptionKey = encryptionKeyOverride;
98030
+ if (!encryptionKey) {
98031
+ const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, workflowRun));
98032
+ encryptionKey = rawKey ? await importKey(rawKey) : void 0;
98033
+ }
97613
98034
  const rawVersion = (_b2 = workflowRun.executionContext) == null ? void 0 : _b2.workflowCoreVersion;
97614
98035
  const capabilities = getRunCapabilities(typeof rawVersion === "string" ? rawVersion : void 0);
97615
98036
  if (!capabilities.supportedFormats.has(SerializationFormat.ENCRYPTED)) {
@@ -97728,6 +98149,17 @@ function normalizeAttributeChanges(attrs, options = {}) {
97728
98149
  }
97729
98150
  const CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS = 2e3;
97730
98151
  const ulid$2 = monotonicFactory();
98152
+ function resolveLineageAttributes() {
98153
+ var _a3;
98154
+ const store = contextStorage.getStore();
98155
+ const parentRunId = (_a3 = store == null ? void 0 : store.workflowMetadata) == null ? void 0 : _a3.workflowRunId;
98156
+ if (!parentRunId)
98157
+ return void 0;
98158
+ return {
98159
+ [ROOT_RUN_ID_ATTRIBUTE]: store.rootRunId ?? parentRunId,
98160
+ [PARENT_RUN_ID_ATTRIBUTE]: parentRunId
98161
+ };
98162
+ }
97731
98163
  let hasWarnedLatestNoOp = false;
97732
98164
  async function start$1(workflow, argsOrOptions, options) {
97733
98165
  "use step";
@@ -97807,9 +98239,11 @@ async function start$1(workflow, argsOrOptions, options) {
97807
98239
  });
97808
98240
  attributes = Object.fromEntries(changes.map(({ key, value }) => [key, value]));
97809
98241
  }
97810
- const attributeSeed = attributes ? {
97811
- attributes,
97812
- ...allowReservedAttributes ? { allowReservedAttributes: true } : {}
98242
+ const lineage = specVersion >= SPEC_VERSION_SUPPORTS_ATTRIBUTES ? resolveLineageAttributes() : void 0;
98243
+ const runAttributes = lineage ? { ...lineage, ...attributes } : attributes;
98244
+ const attributeSeed = runAttributes ? {
98245
+ attributes: runAttributes,
98246
+ ...allowReservedAttributes || lineage != null ? { allowReservedAttributes: true } : {}
97813
98247
  } : {};
97814
98248
  if (opts.replayedFromRunId !== void 0 && !workflowRunIdSchema.safeParse(opts.replayedFromRunId).success) {
97815
98249
  throw new WorkflowRuntimeError(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(opts.replayedFromRunId).slice(0, 64))}.`);
@@ -98595,6 +99029,18 @@ const config = once(() => {
98595
99029
  const baseUrl = getBaseUrlFromEnv();
98596
99030
  return { dataDir, baseUrl };
98597
99031
  });
99032
+ function resolveRecoverActiveRuns(config2) {
99033
+ var _a3;
99034
+ if (config2.recoverActiveRuns !== void 0) {
99035
+ return config2.recoverActiveRuns;
99036
+ }
99037
+ const raw2 = (_a3 = process.env.WORKFLOW_LOCAL_RECOVER_ACTIVE_RUNS) == null ? void 0 : _a3.toLowerCase();
99038
+ if (raw2 === "0" || raw2 === "false")
99039
+ return false;
99040
+ if (raw2 === "1" || raw2 === "true")
99041
+ return true;
99042
+ return true;
99043
+ }
98598
99044
  function resolveDirectBaseUrl(config2) {
98599
99045
  return config2.baseUrl ?? process.env.WORKFLOW_LOCAL_BASE_URL ?? createWorkflowBaseUrl("http://localhost");
98600
99046
  }
@@ -98852,6 +99298,20 @@ async function writeExclusive(filePath, data) {
98852
99298
  }
98853
99299
  }
98854
99300
  }
99301
+ async function promoteExclusive(stagedPath, filePath) {
99302
+ try {
99303
+ await withEnsuredDirectory(path$3.dirname(filePath), () => withWindowsRetry(() => promises.link(stagedPath, filePath)));
99304
+ return "linked";
99305
+ } catch (error2) {
99306
+ if (error2.code === "EEXIST") {
99307
+ return "exists";
99308
+ }
99309
+ if (error2.code === "ENOENT") {
99310
+ return "missing";
99311
+ }
99312
+ throw error2;
99313
+ }
99314
+ }
98855
99315
  async function listJSONFiles(dirPath) {
98856
99316
  return listFilesByExtension(dirPath, ".json");
98857
99317
  }
@@ -125125,6 +125585,98 @@ async function isHookDisposalCommitted(basedir, hookId, tag) {
125125
125585
  }
125126
125586
  return false;
125127
125587
  }
125588
+ function runTerminalMarkerPath(basedir, runId, tag) {
125589
+ const name2 = tag ? `${runId}.terminal.${tag}` : `${runId}.terminal`;
125590
+ return resolveWithinBase(basedir, ".locks", "runs", name2);
125591
+ }
125592
+ async function isRunTerminalCommitted(basedir, runId, tag) {
125593
+ const candidates = [runTerminalMarkerPath(basedir, runId)];
125594
+ if (tag) {
125595
+ candidates.push(runTerminalMarkerPath(basedir, runId, tag));
125596
+ }
125597
+ for (const markerPath of candidates) {
125598
+ try {
125599
+ await fs$1.access(markerPath);
125600
+ return true;
125601
+ } catch (error2) {
125602
+ if (error2.code !== "ENOENT") {
125603
+ throw error2;
125604
+ }
125605
+ }
125606
+ }
125607
+ return false;
125608
+ }
125609
+ function pendingHookEventDir(basedir, runId, tag) {
125610
+ const name2 = tag ? `${runId}.pending.${tag}` : `${runId}.pending`;
125611
+ return resolveWithinBase(basedir, ".locks", "runs", name2);
125612
+ }
125613
+ function pendingHookEventPath(basedir, runId, eventId, tag) {
125614
+ return path$3.join(pendingHookEventDir(basedir, runId, tag), `${eventId}.json`);
125615
+ }
125616
+ async function reapPendingHookEvents(basedir, runId, tag) {
125617
+ const dirs = [pendingHookEventDir(basedir, runId)];
125618
+ if (tag) {
125619
+ dirs.push(pendingHookEventDir(basedir, runId, tag));
125620
+ }
125621
+ for (const dir of dirs) {
125622
+ let entries;
125623
+ try {
125624
+ entries = await fs$1.readdir(dir);
125625
+ } catch (error2) {
125626
+ if (error2.code === "ENOENT") {
125627
+ continue;
125628
+ }
125629
+ throw error2;
125630
+ }
125631
+ for (const entry2 of entries) {
125632
+ try {
125633
+ await withWindowsRetry(() => fs$1.unlink(path$3.join(dir, entry2)));
125634
+ } catch (error2) {
125635
+ if (error2.code !== "ENOENT") {
125636
+ throw error2;
125637
+ }
125638
+ }
125639
+ }
125640
+ await fs$1.rmdir(dir).catch(() => {
125641
+ });
125642
+ }
125643
+ }
125644
+ async function mintRunDominantEventKey(basedir, runId, tag) {
125645
+ let files = [];
125646
+ try {
125647
+ files = await fs$1.readdir(path$3.join(basedir, "events"));
125648
+ } catch (error2) {
125649
+ if (error2.code !== "ENOENT") {
125650
+ throw error2;
125651
+ }
125652
+ }
125653
+ const prefix = `${runId}-`;
125654
+ let maxUlid = null;
125655
+ for (const file2 of files) {
125656
+ if (!file2.startsWith(prefix) || !file2.endsWith(".json")) {
125657
+ continue;
125658
+ }
125659
+ const fileId = file2.slice(0, -".json".length);
125660
+ if (!isUntagged(fileId) && !(tag && hasTag(fileId, tag))) {
125661
+ continue;
125662
+ }
125663
+ const candidate = stripTag(fileId).slice(prefix.length);
125664
+ if (!maxUlid || candidate > maxUlid) {
125665
+ maxUlid = candidate;
125666
+ }
125667
+ }
125668
+ let ts = Date.now();
125669
+ if (maxUlid) {
125670
+ try {
125671
+ const maxTs = decodeTime(maxUlid.replace(/^evnt_/, ""));
125672
+ if (ts <= maxTs) {
125673
+ ts = maxTs + 1;
125674
+ }
125675
+ } catch {
125676
+ }
125677
+ }
125678
+ return { eventId: `evnt_${monotonicUlid$1(ts)}`, createdAt: new Date(ts) };
125679
+ }
125128
125680
  function hookTokenClaimPath(basedir, token) {
125129
125681
  return path$3.join(basedir, "hooks", "tokens", `${hashToken(token)}.json`);
125130
125682
  }
@@ -125553,11 +126105,32 @@ async function deleteAllHooksForRun(basedir, runId) {
125553
126105
  await deleteHookByRunMarkerFile(basedir, marker2.fileId);
125554
126106
  }
125555
126107
  }
126108
+ async function publishLegacyHookReceived(basedir, runId, eventId, serializedEvent, eventPath, currentRun) {
126109
+ if (isTerminalWorkflowRunStatus(currentRun.status) || await isRunTerminalCommitted(basedir, runId)) {
126110
+ throw new RunExpiredError(`Workflow run "${runId}" is already in a terminal state`);
126111
+ }
126112
+ const stagedPath = pendingHookEventPath(basedir, runId, eventId);
126113
+ await writeExclusive(stagedPath, serializedEvent);
126114
+ try {
126115
+ if (await isRunTerminalCommitted(basedir, runId)) {
126116
+ throw new RunExpiredError(`Workflow run "${runId}" is already in a terminal state`);
126117
+ }
126118
+ const promoted = await promoteExclusive(stagedPath, eventPath);
126119
+ if (promoted !== "linked") {
126120
+ throw new RunExpiredError(`Workflow run "${runId}" is already in a terminal state`);
126121
+ }
126122
+ } finally {
126123
+ await fs$1.unlink(stagedPath).catch(() => {
126124
+ });
126125
+ }
126126
+ }
125556
126127
  async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
125557
126128
  assertSafeEntityId("runId", runId);
125558
126129
  const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
125559
126130
  switch (data.eventType) {
125560
126131
  case "run_cancelled": {
126132
+ await writeExclusive(runTerminalMarkerPath(basedir, runId), "");
126133
+ await reapPendingHookEvents(basedir, runId);
125561
126134
  const now2 = /* @__PURE__ */ new Date();
125562
126135
  const run2 = {
125563
126136
  runId: currentRun.runId,
@@ -125597,7 +126170,11 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
125597
126170
  };
125598
126171
  const compositeKey = `${runId}-${eventId}`;
125599
126172
  const eventPath = resolveWithinBase(basedir, "events", `${compositeKey}.json`);
125600
- await writeJSON(eventPath, event);
126173
+ if (data.eventType === "hook_received") {
126174
+ await publishLegacyHookReceived(basedir, runId, eventId, JSON.stringify(event, jsonReplacer, 2), eventPath, currentRun);
126175
+ } else {
126176
+ await writeJSON(eventPath, event);
126177
+ }
125601
126178
  return { event: stripEventDataRefs(event, resolveData) };
125602
126179
  }
125603
126180
  default:
@@ -125624,15 +126201,31 @@ function withRunFileLock(key, fn2) {
125624
126201
  return task;
125625
126202
  }
125626
126203
  function createRunsStorage(basedir, tag) {
126204
+ const get2 = (async (id2, params) => {
126205
+ assertSafeEntityId("runId", id2);
126206
+ const run2 = await readJSONWithFallback(basedir, "runs", id2, WorkflowRunSchema, tag);
126207
+ if (!run2) {
126208
+ throw new WorkflowRunNotFoundError(id2);
126209
+ }
126210
+ const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
126211
+ return filterRunData$1(run2, resolveData);
126212
+ });
125627
126213
  return {
125628
- get: (async (id2, params) => {
125629
- assertSafeEntityId("runId", id2);
125630
- const run2 = await readJSONWithFallback(basedir, "runs", id2, WorkflowRunSchema, tag);
125631
- if (!run2) {
125632
- throw new WorkflowRunNotFoundError(id2);
125633
- }
125634
- const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
125635
- return filterRunData$1(run2, resolveData);
126214
+ get: get2,
126215
+ getMany: (async (ids, params) => {
126216
+ const uniqueIds = [...new Set(ids)];
126217
+ const runs = await Promise.all(uniqueIds.map(async (id2) => {
126218
+ try {
126219
+ return await get2(id2, params);
126220
+ } catch (error2) {
126221
+ if (error2 instanceof WorkflowRunNotFoundError) {
126222
+ return null;
126223
+ }
126224
+ throw error2;
126225
+ }
126226
+ }));
126227
+ const runById = new Map(uniqueIds.map((id2, i) => [id2, runs[i]]));
126228
+ return ids.map((id2) => runById.get(id2) ?? null);
125636
126229
  }),
125637
126230
  list: (async (params) => {
125638
126231
  var _a3, _b2, _c2;
@@ -125703,6 +126296,12 @@ function createRunsStorage(basedir, tag) {
125703
126296
  }
125704
126297
  };
125705
126298
  }
126299
+ const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
126300
+ function getMaxEventsPerRun() {
126301
+ const raw2 = process.env.WORKFLOW_MAX_EVENTS;
126302
+ const parsed = raw2 !== void 0 ? Number(raw2) : Number.NaN;
126303
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_EVENTS_PER_RUN;
126304
+ }
125706
126305
  const HookTokenClaimSchema = object$1({
125707
126306
  // The token-claim writer below has always persisted `hookId`, but
125708
126307
  // this read schema previously omitted it, which is the bug fixed
@@ -126038,7 +126637,8 @@ function createEventsStorage(basedir, tag) {
126038
126637
  const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
126039
126638
  return {
126040
126639
  event: stripEventDataRefs(event2, resolveData2),
126041
- run: currentRun
126640
+ run: currentRun,
126641
+ ...currentRun ? { maxEvents: getMaxEventsPerRun() } : {}
126042
126642
  };
126043
126643
  }
126044
126644
  if (data.eventType === "run_started") {
@@ -126105,6 +126705,13 @@ function createEventsStorage(basedir, tag) {
126105
126705
  let wait;
126106
126706
  let stepCreatedLazily = false;
126107
126707
  let hookEntityWriteOptions;
126708
+ if (isTerminalRunEventType(data.eventType) && currentRun) {
126709
+ await writeExclusive(runTerminalMarkerPath(basedir, effectiveRunId, tag), "");
126710
+ await reapPendingHookEvents(basedir, effectiveRunId, tag);
126711
+ const dominantKey = await mintRunDominantEventKey(basedir, effectiveRunId, tag);
126712
+ eventId = dominantKey.eventId;
126713
+ event = { ...event, eventId, createdAt: dominantKey.createdAt };
126714
+ }
126108
126715
  if (data.eventType === "run_created" && "eventData" in data) {
126109
126716
  const runData = data.eventData;
126110
126717
  validateAttributeChanges(Object.entries(runData.attributes ?? {}).map(([key, value]) => ({
@@ -126138,7 +126745,7 @@ function createEventsStorage(basedir, tag) {
126138
126745
  } else if (data.eventType === "run_started") {
126139
126746
  if (currentRun) {
126140
126747
  if (currentRun.status === "running") {
126141
- return { run: currentRun };
126748
+ return { run: currentRun, maxEvents: getMaxEventsPerRun() };
126142
126749
  }
126143
126750
  run2 = await writeRunUnderLifecycleLock(basedir, effectiveRunId, tag, {
126144
126751
  runId: currentRun.runId,
@@ -126588,7 +127195,34 @@ function createEventsStorage(basedir, tag) {
126588
127195
  const compositeKey = `${effectiveRunId}-${eventId}`;
126589
127196
  const eventPath = taggedPath(basedir, "events", compositeKey, tag);
126590
127197
  const serializedEvent = JSON.stringify(event, jsonReplacer, 2);
126591
- const eventPublished = await writeExclusive(eventPath, serializedEvent);
127198
+ let eventPublished;
127199
+ if (data.eventType === "hook_received") {
127200
+ const terminalByMarker = await isRunTerminalCommitted(basedir, effectiveRunId, tag);
127201
+ const runNow = terminalByMarker ? null : await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
127202
+ if (terminalByMarker || runNow && isTerminalWorkflowRunStatus(runNow.status)) {
127203
+ throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
127204
+ }
127205
+ const stagedPath = pendingHookEventPath(basedir, effectiveRunId, eventId, tag);
127206
+ const staged = await writeExclusive(stagedPath, serializedEvent);
127207
+ if (!staged) {
127208
+ throw new EntityConflictError(`Event "${eventId}" already exists for run "${effectiveRunId}"`);
127209
+ }
127210
+ try {
127211
+ if (await isRunTerminalCommitted(basedir, effectiveRunId, tag)) {
127212
+ throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
127213
+ }
127214
+ const promoted = await promoteExclusive(stagedPath, eventPath);
127215
+ if (promoted === "missing") {
127216
+ throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
127217
+ }
127218
+ eventPublished = promoted === "linked";
127219
+ } finally {
127220
+ await deleteJSON(stagedPath).catch(() => {
127221
+ });
127222
+ }
127223
+ } else {
127224
+ eventPublished = await writeExclusive(eventPath, serializedEvent);
127225
+ }
126592
127226
  if (!eventPublished) {
126593
127227
  if (data.eventType === "hook_created" && data.correlationId) {
126594
127228
  await repairHookEntityFromPersistedEvent(basedir, effectiveRunId, data.correlationId, eventId, tag);
@@ -126643,7 +127277,9 @@ function createEventsStorage(basedir, tag) {
126643
127277
  events: events2,
126644
127278
  cursor,
126645
127279
  hasMore,
126646
- ...stepCreatedLazily ? { stepCreated: true } : {}
127280
+ ...stepCreatedLazily ? { stepCreated: true } : {},
127281
+ // Per-run event ceiling (mirrors the Vercel World).
127282
+ ...run2 ? { maxEvents: getMaxEventsPerRun() } : {}
126647
127283
  };
126648
127284
  }
126649
127285
  },
@@ -127145,7 +127781,7 @@ function createWorld$1(args) {
127145
127781
  const tag = mergedConfig.tag;
127146
127782
  const queue = createQueue$2(mergedConfig);
127147
127783
  const { clearCache: clearStorageCache, ...storage } = createStorage$1(mergedConfig.dataDir, tag);
127148
- const recoverActiveRuns = mergedConfig.recoverActiveRuns ?? true;
127784
+ const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
127149
127785
  return {
127150
127786
  specVersion: SPEC_VERSION_CURRENT,
127151
127787
  ...queue,
@@ -127181,7 +127817,7 @@ function createWorld$1(args) {
127181
127817
  const basedir = mergedConfig.dataDir;
127182
127818
  const hooksDir = path$3.join(basedir, "hooks");
127183
127819
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
127184
- const { HookSchema: HookSchema2 } = await import("./index-CDZXmART.js");
127820
+ const { HookSchema: HookSchema2 } = await import("./index-Cnj8rNtV.js");
127185
127821
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
127186
127822
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
127187
127823
  if (hook == null ? void 0 : hook.token) {
@@ -127364,8 +128000,8 @@ function requireGetVercelOidcToken() {
127364
128000
  }
127365
128001
  try {
127366
128002
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
127367
- await import("./token-util-DXRPWBKh.js").then((n) => n.t),
127368
- await import("./token-Ni6JMJBG.js").then((n) => n.t)
128003
+ await import("./token-util-D94FNaX0.js").then((n) => n.t),
128004
+ await import("./token-CYc8-6E0.js").then((n) => n.t)
127369
128005
  ]);
127370
128006
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
127371
128007
  await refreshToken(options);
@@ -127931,6 +128567,7 @@ var distExports = requireDist();
127931
128567
  let _dispatcher;
127932
128568
  let _eventsDispatcher;
127933
128569
  let _streamDispatcher;
128570
+ let _streamCloseDispatcher;
127934
128571
  const BASE_AGENT_OPTIONS = {
127935
128572
  connections: 8,
127936
128573
  keepAliveTimeout: 1e4,
@@ -127965,6 +128602,11 @@ const STREAM_RETRY_OPTIONS = {
127965
128602
  methods: ["PUT"],
127966
128603
  statusCodes: [429]
127967
128604
  };
128605
+ const STREAM_CLOSE_RETRY_OPTIONS = {
128606
+ retryAfter: true,
128607
+ methods: ["PUT"],
128608
+ statusCodes: [429, 500, 502, 503, 504]
128609
+ };
127968
128610
  function getDispatcher(config2) {
127969
128611
  return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
127970
128612
  }
@@ -127974,6 +128616,9 @@ function getEventsDispatcher(config2) {
127974
128616
  function getStreamDispatcher(config2) {
127975
128617
  return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamDispatcher();
127976
128618
  }
128619
+ function getStreamCloseDispatcher(config2) {
128620
+ return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamCloseDispatcher();
128621
+ }
127977
128622
  function makeRetryDispatcher(agentOptions, retryOptions) {
127978
128623
  return new undiciExports.RetryAgent(new undiciExports.Agent(agentOptions), retryOptions);
127979
128624
  }
@@ -127989,6 +128634,10 @@ function getDefaultStreamDispatcher() {
127989
128634
  _streamDispatcher ?? (_streamDispatcher = makeRetryDispatcher(EVENTS_AGENT_OPTIONS, STREAM_RETRY_OPTIONS));
127990
128635
  return _streamDispatcher;
127991
128636
  }
128637
+ function getDefaultStreamCloseDispatcher() {
128638
+ _streamCloseDispatcher ?? (_streamCloseDispatcher = makeRetryDispatcher(EVENTS_AGENT_OPTIONS, STREAM_CLOSE_RETRY_OPTIONS));
128639
+ return _streamCloseDispatcher;
128640
+ }
127992
128641
  let otelApiPromise$1 = null;
127993
128642
  async function getOtelApi$1() {
127994
128643
  if (!otelApiPromise$1) {
@@ -128147,6 +128796,8 @@ function errorForResponse(status, message2, opts = {}) {
128147
128796
  return new EntityConflictError(message2);
128148
128797
  if (status === 410)
128149
128798
  return new RunExpiredError(message2);
128799
+ if (status === 412)
128800
+ return new PreconditionFailedError(message2, { retryAfter });
128150
128801
  if (status === 425)
128151
128802
  return new TooEarlyError(message2, { retryAfter });
128152
128803
  if (status === 429) {
@@ -128260,7 +128911,7 @@ async function instrumentedFetch(opts) {
128260
128911
  return response2;
128261
128912
  });
128262
128913
  }
128263
- const version = "5.0.0-beta.30";
128914
+ const version = "5.0.0-beta.32";
128264
128915
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
128265
128916
  const MAX_BODY_PARSE_RETRIES = 2;
128266
128917
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -128301,6 +128952,7 @@ const DEFAULT_RESOLVE_DATA_OPTION = "all";
128301
128952
  function deserializeError(obj) {
128302
128953
  return obj;
128303
128954
  }
128955
+ const joinUserAgentProducts = (...products) => products.filter(Boolean).join(" ");
128304
128956
  const getUserAgent = () => {
128305
128957
  const deploymentId = process.env.VERCEL_DEPLOYMENT_ID;
128306
128958
  if (deploymentId) {
@@ -128320,7 +128972,7 @@ const getHttpUrl = (config2) => {
128320
128972
  const getHeaders = (config2, options) => {
128321
128973
  const projectConfig = config2 == null ? void 0 : config2.projectConfig;
128322
128974
  const headers2 = new Headers(config2 == null ? void 0 : config2.headers);
128323
- headers2.set("User-Agent", getUserAgent());
128975
+ headers2.set("User-Agent", joinUserAgentProducts(getUserAgent(), headers2.get("User-Agent")));
128324
128976
  const testLimitOverrides = getTestLimitOverridesHeader();
128325
128977
  if (testLimitOverrides) {
128326
128978
  headers2.set(TEST_LIMIT_OVERRIDES_HEADER, testLimitOverrides);
@@ -128364,7 +129016,7 @@ async function getHttpConfig(config2) {
128364
129016
  }
128365
129017
  return { baseUrl, headers: headers2, usingProxy };
128366
129018
  }
128367
- async function makeRequest({ endpoint, options = {}, config: config2 = {}, schema, data, onResponse }) {
129019
+ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schema, data, onResponse, retryConnectTimeout = false }) {
128368
129020
  const method = options.method || "GET";
128369
129021
  const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
128370
129022
  const url2 = `${baseUrl}${endpoint}`;
@@ -128382,7 +129034,7 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
128382
129034
  headers2.set("Content-Type", "application/cbor");
128383
129035
  body2 = encode$1(data);
128384
129036
  }
128385
- const canRetryBody = IDEMPOTENT_METHODS.has(method.toUpperCase());
129037
+ const canRetryRead = IDEMPOTENT_METHODS.has(method.toUpperCase());
128386
129038
  let parseResult;
128387
129039
  let responseDiagnostics = "";
128388
129040
  for (let attempt = 0; ; attempt++) {
@@ -128411,6 +129063,10 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
128411
129063
  }
128412
129064
  const transportCode = getTransientTransportCode(error2);
128413
129065
  if (transportCode) {
129066
+ if (retryConnectTimeout && canRetryRead && transportCode === "UND_ERR_CONNECT_TIMEOUT" && attempt === 0) {
129067
+ await new Promise((resolve2) => setTimeout(resolve2, BODY_PARSE_RETRY_BASE_MS));
129068
+ continue;
129069
+ }
128414
129070
  const transportError = new WorkflowWorldError(`${method} ${endpoint} transport failure after ${elapsed}ms (${transportCode})`, { url: url2, code: "TRANSPORT", cause: error2 });
128415
129071
  span == null ? void 0 : span.setAttributes({ ...ErrorType("TRANSPORT") });
128416
129072
  (_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, transportError);
@@ -128455,7 +129111,7 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
128455
129111
  });
128456
129112
  break;
128457
129113
  } catch (error2) {
128458
- if (canRetryBody && attempt < MAX_BODY_PARSE_RETRIES) {
129114
+ if (canRetryRead && attempt < MAX_BODY_PARSE_RETRIES) {
128459
129115
  const backoffMs = BODY_PARSE_RETRY_BASE_MS * 2 ** attempt;
128460
129116
  span == null ? void 0 : span.setAttributes({
128461
129117
  ...ErrorType("PARSE_ERROR_RETRYING")
@@ -128673,171 +129329,6 @@ function createAnalytics(config2) {
128673
129329
  }
128674
129330
  };
128675
129331
  }
128676
- const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
128677
- const DECODE_TABLE = (() => {
128678
- const table2 = new Int8Array(128).fill(-1);
128679
- for (let i = 0; i < ENCODING.length; i++) {
128680
- table2[ENCODING.charCodeAt(i)] = i;
128681
- }
128682
- for (let i = 0; i < ENCODING.length; i++) {
128683
- const lower2 = ENCODING[i].toLowerCase();
128684
- if (lower2 !== ENCODING[i]) {
128685
- table2[lower2.charCodeAt(0)] = i;
128686
- }
128687
- }
128688
- return table2;
128689
- })();
128690
- const ULID_LENGTH = 26;
128691
- const ULID_BYTE_LENGTH = 16;
128692
- const TAG_BIT_MASK = 128;
128693
- const REGION_MASK = 252;
128694
- const VERSION_HIGH_MASK = 3;
128695
- const VERSION_LOW_MASK = 224;
128696
- const REGION_BYTE_INDEX = 6;
128697
- const VERSION_LOW_BYTE_INDEX = 7;
128698
- const VERSION_BIT_WIDTH = 5;
128699
- const REGION_BIT_WIDTH = 6;
128700
- const MAX_VERSION = (1 << VERSION_BIT_WIDTH) - 1;
128701
- const MAX_REGION = (1 << REGION_BIT_WIDTH) - 1;
128702
- function ulidToBytes(ulid2) {
128703
- if (typeof ulid2 !== "string") {
128704
- throw new TypeError(`Expected ULID string, got ${typeof ulid2}`);
128705
- }
128706
- if (ulid2.length !== ULID_LENGTH) {
128707
- throw new Error(`Invalid ULID length: expected ${ULID_LENGTH}, got ${ulid2.length}`);
128708
- }
128709
- const values = new Uint8Array(ULID_LENGTH);
128710
- for (let i = 0; i < ULID_LENGTH; i++) {
128711
- const code2 = ulid2.charCodeAt(i);
128712
- const v2 = code2 < 128 ? DECODE_TABLE[code2] : -1;
128713
- if (v2 < 0) {
128714
- throw new Error(`Invalid Crockford-Base32 character at index ${i}: ${JSON.stringify(ulid2[i])}`);
128715
- }
128716
- values[i] = v2;
128717
- }
128718
- if ((values[0] & 24) !== 0) {
128719
- throw new Error(`Invalid ULID: top 2 bits must be zero (first char > '7'): ${JSON.stringify(ulid2[0])}`);
128720
- }
128721
- const out = new Uint8Array(ULID_BYTE_LENGTH);
128722
- let bitBuf = values[0] & 7;
128723
- let bitCount = 3;
128724
- let outIdx = 0;
128725
- for (let i = 1; i < ULID_LENGTH; i++) {
128726
- bitBuf = bitBuf << 5 | values[i];
128727
- bitCount += 5;
128728
- while (bitCount >= 8) {
128729
- bitCount -= 8;
128730
- out[outIdx++] = bitBuf >> bitCount & 255;
128731
- }
128732
- }
128733
- if (outIdx !== ULID_BYTE_LENGTH || bitCount !== 0) {
128734
- throw new Error("Internal error: ULID bit packing did not consume cleanly");
128735
- }
128736
- return out;
128737
- }
128738
- function bytesToUlid(bytes) {
128739
- if (bytes.length !== ULID_BYTE_LENGTH) {
128740
- throw new Error(`Invalid byte length: expected ${ULID_BYTE_LENGTH}, got ${bytes.length}`);
128741
- }
128742
- let bitBuf = 0;
128743
- let bitCount = 0;
128744
- bitBuf = 0;
128745
- bitCount = 2;
128746
- let out = "";
128747
- for (let i = 0; i < ULID_BYTE_LENGTH; i++) {
128748
- bitBuf = bitBuf << 8 | bytes[i];
128749
- bitCount += 8;
128750
- while (bitCount >= 5) {
128751
- bitCount -= 5;
128752
- out += ENCODING[bitBuf >> bitCount & 31];
128753
- }
128754
- }
128755
- if (out.length !== ULID_LENGTH || bitCount !== 0) {
128756
- throw new Error("Internal error: ULID bit packing did not flush cleanly");
128757
- }
128758
- return out;
128759
- }
128760
- const REGION_IDS = {
128761
- unknown: 0,
128762
- iad1: 1,
128763
- sfo1: 2,
128764
- pdx1: 3,
128765
- cle1: 4,
128766
- yul1: 5,
128767
- gru1: 6,
128768
- dub1: 7,
128769
- lhr1: 8,
128770
- cdg1: 9,
128771
- fra1: 10,
128772
- bru1: 11,
128773
- arn1: 12,
128774
- hel1: 13,
128775
- zrh1: 14,
128776
- cpt1: 15,
128777
- dxb1: 16,
128778
- bom1: 17,
128779
- sin1: 18,
128780
- hkg1: 19,
128781
- hnd1: 20,
128782
- icn1: 21,
128783
- kix1: 22,
128784
- syd1: 23
128785
- };
128786
- const DEFAULT_REGION_CODE = "iad1";
128787
- const REGION_CODES_BY_ID = new Map(Object.entries(REGION_IDS).filter((entry2) => entry2[0] !== "unknown").map(([code2, id2]) => [id2, code2]));
128788
- function lookupRegion(regionId) {
128789
- return REGION_CODES_BY_ID.get(regionId) ?? null;
128790
- }
128791
- function isKnownRegionCode(code2) {
128792
- return code2 !== void 0 && code2 !== "unknown" && Object.hasOwn(REGION_IDS, code2);
128793
- }
128794
- const CURRENT_VERSION = 1;
128795
- function isRegionCode(value) {
128796
- return typeof value === "string" && value !== "unknown" && Object.hasOwn(REGION_IDS, value);
128797
- }
128798
- function encode(ulid2, region, options = {}) {
128799
- let regionId;
128800
- if (typeof region === "number") {
128801
- if (!Number.isInteger(region) || region < 0 || region > MAX_REGION) {
128802
- throw new RangeError(`regionId must be an integer in [0, ${MAX_REGION}]; got ${region}`);
128803
- }
128804
- regionId = region;
128805
- } else if (isRegionCode(region)) {
128806
- regionId = REGION_IDS[region];
128807
- } else {
128808
- throw new Error(`Unknown region: ${String(region)}`);
128809
- }
128810
- const version2 = options.version ?? CURRENT_VERSION;
128811
- if (!Number.isInteger(version2) || version2 < 0 || version2 > MAX_VERSION) {
128812
- throw new RangeError(`version must be an integer in [0, ${MAX_VERSION}]; got ${version2}`);
128813
- }
128814
- const bytes = ulidToBytes(ulid2);
128815
- bytes[0] = bytes[0] | TAG_BIT_MASK;
128816
- const regionShifted = (regionId & MAX_REGION) << 2;
128817
- const versionHigh = version2 >> 3 & VERSION_HIGH_MASK;
128818
- const versionLow = (version2 & 7) << 5;
128819
- bytes[REGION_BYTE_INDEX] = bytes[REGION_BYTE_INDEX] & -256 | regionShifted | versionHigh;
128820
- bytes[VERSION_LOW_BYTE_INDEX] = bytes[VERSION_LOW_BYTE_INDEX] & ~VERSION_LOW_MASK | versionLow;
128821
- return bytesToUlid(bytes);
128822
- }
128823
- function decode(taggedUlid) {
128824
- const bytes = ulidToBytes(taggedUlid);
128825
- const tagged = (bytes[0] & TAG_BIT_MASK) !== 0;
128826
- bytes[0] = bytes[0] & ~TAG_BIT_MASK;
128827
- const ulid2 = bytesToUlid(bytes);
128828
- if (!tagged) {
128829
- return { tagged: false, ulid: ulid2, version: null, regionId: null, region: null };
128830
- }
128831
- const regionId = (bytes[REGION_BYTE_INDEX] & REGION_MASK) >> 2;
128832
- const version2 = (bytes[REGION_BYTE_INDEX] & VERSION_HIGH_MASK) << 3 | (bytes[VERSION_LOW_BYTE_INDEX] & VERSION_LOW_MASK) >> 5;
128833
- return {
128834
- tagged: true,
128835
- ulid: ulid2,
128836
- version: version2,
128837
- regionId,
128838
- region: lookupRegion(regionId)
128839
- };
128840
- }
128841
129332
  const ulid = monotonicFactory();
128842
129333
  let lastRunId;
128843
129334
  function bumpAboveMetadata(ulidStr) {
@@ -133938,11 +134429,7 @@ function getHeadersFromPayload(payload) {
133938
134429
  const FLOW_TOPIC_PATTERN = /^__([a-z][a-z0-9]*_)?wkf_workflow_/;
133939
134430
  let loggedSequentialReplays = false;
133940
134431
  function isSequentialReplaysEnabled() {
133941
- const explicit = process.env.WORKFLOW_SEQUENTIAL_REPLAYS;
133942
- if (explicit !== void 0 && explicit !== "") {
133943
- return explicit === "1";
133944
- }
133945
- return process.env.WORKFLOW_SAFE_MODE === "1";
134432
+ return process.env.WORKFLOW_SEQUENTIAL_REPLAYS === "1";
133946
134433
  }
133947
134434
  function getPhysicalQueueName(queueName, payload) {
133948
134435
  if (!isSequentialReplaysEnabled() || !FLOW_TOPIC_PATTERN.test(queueName)) {
@@ -134063,9 +134550,11 @@ function createQueue$1(config2) {
134063
134550
  // with jitter so an outage or poison message cannot hot-loop or
134064
134551
  // redrive in lockstep. Workflow handlers are event-sourced and must
134065
134552
  // remain idempotent because queue retries can happen close together.
134066
- retry: (_error, { deliveryCount }) => ({
134067
- afterSeconds: getHandlerErrorRetryAfterSeconds(deliveryCount)
134068
- })
134553
+ retry: (error2, { messageId, deliveryCount }) => {
134554
+ const afterSeconds = getHandlerErrorRetryAfterSeconds(deliveryCount);
134555
+ console.error(`[workflow] Queue handler failed for message "${messageId}" on delivery attempt ${deliveryCount}; retrying in ${afterSeconds}s:`, error2);
134556
+ return { afterSeconds };
134557
+ }
134069
134558
  });
134070
134559
  return async (req) => {
134071
134560
  const rawId = req.headers.get("x-vercel-id");
@@ -134433,6 +134922,9 @@ function buildPostFrameMeta(input) {
134433
134922
  meta2.retryAfter = input.retryAfter;
134434
134923
  if (input.hookToken !== void 0)
134435
134924
  meta2.hookToken = input.hookToken;
134925
+ if (input.hookTokenRetentionUntil !== void 0) {
134926
+ meta2.hookTokenRetentionUntil = input.hookTokenRetentionUntil;
134927
+ }
134436
134928
  if (input.hookIsWebhook !== void 0)
134437
134929
  meta2.hookIsWebhook = input.hookIsWebhook;
134438
134930
  if (input.hookIsSystem !== void 0)
@@ -134464,6 +134956,11 @@ function buildPostFrameMeta(input) {
134464
134956
  meta2.stepCount = input.stepCount;
134465
134957
  if (input.eventCount !== void 0)
134466
134958
  meta2.eventCount = input.eventCount;
134959
+ if (input.rsfs !== void 0)
134960
+ meta2.rsfs = input.rsfs;
134961
+ if (input.finalSchedulingReplay !== void 0) {
134962
+ meta2.finalSchedulingReplay = input.finalSchedulingReplay;
134963
+ }
134467
134964
  if (input.optimizations !== void 0) {
134468
134965
  meta2.optimizations = input.optimizations;
134469
134966
  }
@@ -134471,6 +134968,9 @@ function buildPostFrameMeta(input) {
134471
134968
  meta2.sinceCursor = input.sinceCursor;
134472
134969
  if (input.skipPreload !== void 0)
134473
134970
  meta2.skipPreload = input.skipPreload;
134971
+ if (input.stateUpdatedAt !== void 0) {
134972
+ meta2.stateUpdatedAt = input.stateUpdatedAt;
134973
+ }
134474
134974
  return meta2;
134475
134975
  }
134476
134976
  function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url2) {
@@ -134598,9 +135098,17 @@ async function getEventsByCorrelationIdV4(correlationId, params = {}, config2) {
134598
135098
  return consumeListFrameStream(url2, headers2, config2, "listEventsByCorrelationId");
134599
135099
  }
134600
135100
  const FORMAT_PREFIX_LENGTH = 4;
135101
+ const DEVALUE_FORMAT_PREFIX = "devl";
135102
+ const ENCRYPTED_FORMAT_PREFIX = "encr";
134601
135103
  const GZIP_FORMAT_PREFIX = "gzip";
134602
135104
  const ZSTD_FORMAT_PREFIX = "zstd";
134603
135105
  const formatDecoder = new TextDecoder();
135106
+ const SERIALIZED_DATA_FORMAT_PREFIXES = /* @__PURE__ */ new Set([
135107
+ DEVALUE_FORMAT_PREFIX,
135108
+ ENCRYPTED_FORMAT_PREFIX,
135109
+ GZIP_FORMAT_PREFIX,
135110
+ ZSTD_FORMAT_PREFIX
135111
+ ]);
134604
135112
  function getNodeZlib() {
134605
135113
  var _a3, _b2;
134606
135114
  try {
@@ -134615,6 +135123,10 @@ function peekFormatPrefix(value) {
134615
135123
  }
134616
135124
  return formatDecoder.decode(value.subarray(0, FORMAT_PREFIX_LENGTH));
134617
135125
  }
135126
+ function hasSerializedDataFormatPrefix(value) {
135127
+ const format2 = peekFormatPrefix(value);
135128
+ return format2 !== null && SERIALIZED_DATA_FORMAT_PREFIXES.has(format2);
135129
+ }
134618
135130
  function decompress(format2, payload) {
134619
135131
  const zlib = getNodeZlib();
134620
135132
  const decompress2 = format2 === ZSTD_FORMAT_PREFIX ? zlib == null ? void 0 : zlib.zstdDecompressSync : zlib == null ? void 0 : zlib.gunzipSync;
@@ -134762,6 +135274,7 @@ async function getWorkflowRun(id2, params, config2) {
134762
135274
  endpoint,
134763
135275
  options: { method: "GET" },
134764
135276
  config: config2,
135277
+ retryConnectTimeout: true,
134765
135278
  schema: remoteRefBehavior === "lazy" ? WorkflowRunWireWithRefsSchema : WorkflowRunWireSchema
134766
135279
  });
134767
135280
  return filterRunData(run2, resolveData);
@@ -134772,6 +135285,21 @@ async function getWorkflowRun(id2, params, config2) {
134772
135285
  throw error2;
134773
135286
  }
134774
135287
  }
135288
+ async function getWorkflowRuns(ids, params, config2) {
135289
+ const uniqueIds = [...new Set(ids)];
135290
+ const runs = await Promise.all(uniqueIds.map(async (id2) => {
135291
+ try {
135292
+ return await getWorkflowRun(id2, params, config2);
135293
+ } catch (error2) {
135294
+ if (error2 instanceof WorkflowRunNotFoundError) {
135295
+ return null;
135296
+ }
135297
+ throw error2;
135298
+ }
135299
+ }));
135300
+ const runById = new Map(uniqueIds.map((id2, i) => [id2, runs[i]]));
135301
+ return ids.map((id2) => runById.get(id2) ?? null);
135302
+ }
134775
135303
  async function cancelWorkflowRunV1(id2, params, config2) {
134776
135304
  const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
134777
135305
  const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
@@ -134906,6 +135434,11 @@ const eventsNeedingResolve = /* @__PURE__ */ new Set([
134906
135434
  "step_started"
134907
135435
  // runtime reads result.step (checks attempt, state)
134908
135436
  ]);
135437
+ const legacyStructuredErrorEventTypes = /* @__PURE__ */ new Set([
135438
+ "run_failed",
135439
+ "step_failed",
135440
+ "step_retrying"
135441
+ ]);
134909
135442
  function splitEventDataForV4(data) {
134910
135443
  var _a3;
134911
135444
  const eventData = data.eventData ?? {};
@@ -134940,6 +135473,9 @@ function splitEventDataForV4(data) {
134940
135473
  if (typeof eventData.token === "string") {
134941
135474
  meta2.hookToken = eventData.token;
134942
135475
  }
135476
+ if (eventData.tokenRetentionUntil instanceof Date) {
135477
+ meta2.hookTokenRetentionUntil = eventData.tokenRetentionUntil;
135478
+ }
134943
135479
  if (typeof eventData.isWebhook === "boolean") {
134944
135480
  meta2.hookIsWebhook = eventData.isWebhook;
134945
135481
  }
@@ -134982,6 +135518,12 @@ function splitEventDataForV4(data) {
134982
135518
  if (typeof eventData.eventCount === "number" && Number.isSafeInteger(eventData.eventCount) && eventData.eventCount > 0) {
134983
135519
  meta2.eventCount = eventData.eventCount;
134984
135520
  }
135521
+ if (typeof eventData.rsfs === "number") {
135522
+ meta2.rsfs = eventData.rsfs;
135523
+ }
135524
+ if (typeof eventData.finalSchedulingReplay === "number") {
135525
+ meta2.finalSchedulingReplay = eventData.finalSchedulingReplay;
135526
+ }
134985
135527
  if (Array.isArray(eventData.optimizations) && eventData.optimizations.every((o) => typeof o === "string")) {
134986
135528
  meta2.optimizations = eventData.optimizations;
134987
135529
  }
@@ -135009,13 +135551,24 @@ function coerceEventDates(raw2) {
135009
135551
  function coerceNormalizedEvent(raw2) {
135010
135552
  return coerceEventDates(normalizeEventData(raw2));
135011
135553
  }
135554
+ function decodeLegacyStructuredError(payload) {
135555
+ if (hasSerializedDataFormatPrefix(payload)) {
135556
+ return payload;
135557
+ }
135558
+ try {
135559
+ const parsed = StructuredErrorSchema.safeParse(decode$1(payload.slice()));
135560
+ return parsed.success ? parsed.data : payload;
135561
+ } catch {
135562
+ return payload;
135563
+ }
135564
+ }
135012
135565
  function buildEventFromV4(decoded, payloadBody, resolveData) {
135013
135566
  const eventData = decoded.eventData ?? {};
135014
135567
  if (payloadBody.byteLength > 0) {
135015
135568
  const payloadField = getEventDataPayloadField(decoded.eventType);
135016
135569
  const normalizedPayload = normalizeSerializedData(payloadBody);
135017
135570
  if (payloadField && normalizedPayload instanceof Uint8Array) {
135018
- eventData[payloadField] = normalizedPayload;
135571
+ eventData[payloadField] = legacyStructuredErrorEventTypes.has(decoded.eventType) ? decodeLegacyStructuredError(normalizedPayload) : normalizedPayload;
135019
135572
  }
135020
135573
  }
135021
135574
  const raw2 = {
@@ -135107,6 +135660,7 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
135107
135660
  specVersion: data.specVersion ?? 2,
135108
135661
  ...data.correlationId ? { correlationId: data.correlationId } : {},
135109
135662
  ...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
135663
+ ...(params == null ? void 0 : params.stateUpdatedAt) !== void 0 ? { stateUpdatedAt: params.stateUpdatedAt } : {},
135110
135664
  occurredAt: (params == null ? void 0 : params.occurredAt) ?? /* @__PURE__ */ new Date(),
135111
135665
  // Opt-in inline-delta: forward the cursor the runtime held before
135112
135666
  // this write so the server can return the authoritative event-log
@@ -135138,7 +135692,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
135138
135692
  // Lazy step start: thread the server's "I created the step on this call"
135139
135693
  // signal through so the owned-inline runtime path can gate body execution
135140
135694
  // on it. Absent from older servers → undefined → safe default.
135141
- ...body2.stepCreated ? { stepCreated: true } : {}
135695
+ ...body2.stepCreated ? { stepCreated: true } : {},
135696
+ // Server-supplied per-run event ceiling; absent from older servers.
135697
+ ...typeof body2.maxEvents === "number" ? { maxEvents: body2.maxEvents } : {}
135142
135698
  };
135143
135699
  }
135144
135700
  function filterHookData(hook, resolveData) {
@@ -135212,6 +135768,7 @@ function createStorage(config2) {
135212
135768
  // Storage interface with namespaced methods
135213
135769
  runs: {
135214
135770
  get: ((id2, params) => getWorkflowRun(id2, params, config2)),
135771
+ getMany: ((ids, params) => getWorkflowRuns(ids, params, config2)),
135215
135772
  list: ((params) => listWorkflowRuns(params, config2)),
135216
135773
  experimentalSetAttributes: (runId, changes, options) => experimentalSetAttributes(runId, changes, options, config2)
135217
135774
  },
@@ -135363,7 +135920,11 @@ function createStreamer(config2) {
135363
135920
  method: "PUT",
135364
135921
  url: url2.toString(),
135365
135922
  headers: httpConfig.headers,
135366
- dispatcher: getStreamDispatcher(config2),
135923
+ // Close is idempotent (unlike chunk appends), so its dispatcher
135924
+ // retries 5xx — required by the server's close-barrier protocol,
135925
+ // which surfaces transient reconciliation states as retriable
135926
+ // 503s with the stream left durably closing.
135927
+ dispatcher: getStreamCloseDispatcher(config2),
135367
135928
  timeoutMs: null,
135368
135929
  logLabel: url2.pathname,
135369
135930
  spanName: "workflow.stream.write",
@@ -135457,6 +136018,17 @@ function createWorld(config2) {
135457
136018
  // at least it — workflow-server declared spec-5 support in
135458
136019
  // vercel/workflow-server#520.
135459
136020
  specVersion: SPEC_VERSION_SUPPORTS_COMPRESSION,
136021
+ capabilities: {
136022
+ // workflow-server enforces the `stateUpdatedAt` optimistic-concurrency
136023
+ // guard: creations carrying a stale snapshot are rejected with 412
136024
+ // (PreconditionFailedError) when the run's outside-event marker is
136025
+ // newer. See vercel/workflow-server#484.
136026
+ preconditionGuard: true,
136027
+ // Vercel Queues supports maxConcurrency-limited consumers, which
136028
+ // WORKFLOW_SEQUENTIAL_REPLAYS=1 uses for per-run `maxConcurrency: 1`
136029
+ // flow topics (see queue.ts and @workflow/builders).
136030
+ maxConcurrency: true
136031
+ },
135460
136032
  // On Vercel the platform fails the function invocation when the
135461
136033
  // process exits non-zero, and VQS redelivers the queue message via a
135462
136034
  // fresh invocation. The core runtime uses this to decide whether
@@ -158577,7 +159149,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
158577
159149
  __proto__: null,
158578
159150
  loader
158579
159151
  }, Symbol.toStringTag, { value: "Module" }));
158580
- const serverManifest = { "entry": { "module": "/assets/entry.client-Q4eUIqMI.js", "imports": ["/assets/index-Q81MFBxC.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-CraFPjyT.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/mermaid-3ZIDBTTL-CQtb_4FN.js", "/assets/arrow-up-right-B1QFlETT.js"], "css": ["/assets/root-CQggqXow.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-rmBMtWNr.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/workflow-graph-viewer-Cn2fThMy.js", "/assets/mermaid-3ZIDBTTL-CQtb_4FN.js", "/assets/index-STTN0-2V.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-BGHjSgVx.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/workflow-graph-viewer-Cn2fThMy.js", "/assets/mermaid-3ZIDBTTL-CQtb_4FN.js", "/assets/arrow-up-right-B1QFlETT.js", "/assets/encryption-CLVP4klT.js", "/assets/index-STTN0-2V.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-9dd3e2d8.js", "version": "9dd3e2d8", "sri": void 0 };
159152
+ const serverManifest = { "entry": { "module": "/assets/entry.client-Q4eUIqMI.js", "imports": ["/assets/index-Q81MFBxC.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-BPK1T9Ck.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/mermaid-3ZIDBTTL-C_EWPx9a.js", "/assets/arrow-up-right-Dv3gGqIf.js"], "css": ["/assets/root-15oK726f.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-0OfTSXd1.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/workflow-graph-viewer-DrfqsDRu.js", "/assets/mermaid-3ZIDBTTL-C_EWPx9a.js", "/assets/index-STTN0-2V.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-CrqNzQ_y.js", "imports": ["/assets/index-Q81MFBxC.js", "/assets/workflow-graph-viewer-DrfqsDRu.js", "/assets/mermaid-3ZIDBTTL-C_EWPx9a.js", "/assets/arrow-up-right-Dv3gGqIf.js", "/assets/encryption-CLVP4klT.js", "/assets/index-STTN0-2V.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DDxQhcP4.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-485c4078.js", "version": "485c4078", "sri": void 0 };
158581
159153
  const assetsBuildDirectory = "build/client";
158582
159154
  const basename = "/";
158583
159155
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -158646,74 +159218,77 @@ const serverBuild = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
158646
159218
  ssr
158647
159219
  }, Symbol.toStringTag, { value: "Module" }));
158648
159220
  export {
158649
- WaitStatusSchema as $,
159221
+ ValidQueueName as $,
158650
159222
  ATTRIBUTE_KEY_MAX_LENGTH as A,
158651
159223
  BaseEventSchema as B,
158652
159224
  CHILD_ENTITY_CREATION_EVENT_TYPES as C,
158653
159225
  DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS as D,
158654
159226
  EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE as E,
158655
- SerializedDataSchema as F,
158656
- StepInvokePayloadSchema as G,
159227
+ SPEC_VERSION_SUPPORTS_COMPRESSION as F,
159228
+ STEP_EVENT_TYPES as G,
158657
159229
  HookSchema as H,
158658
- StepSchema as I,
158659
- StepStatusSchema as J,
158660
- TERMINAL_STEP_EVENT_TYPES as K,
159230
+ SerializedDataSchema as I,
159231
+ StepInvokePayloadSchema as J,
159232
+ StepSchema as K,
158661
159233
  LegacySerializedDataSchemaV1 as L,
158662
159234
  MessageId as M,
158663
159235
  Nt as N,
158664
- TERMINAL_STEP_STATUSES as O,
158665
- PaginatedResponseSchema as P,
159236
+ StepStatusSchema as O,
159237
+ PARENT_RUN_ID_ATTRIBUTE as P,
158666
159238
  QueuePayloadSchema as Q,
158667
159239
  RESERVED_ATTRIBUTE_KEY_PREFIX as R,
158668
159240
  SPEC_VERSION_CURRENT as S,
158669
- TERMINAL_RUN_EVENT_TYPES as T,
158670
- TERMINAL_WORKFLOW_RUN_STATUSES as U,
158671
- TerminalRunEventTypeSchema as V,
158672
- TerminalStepStatusSchema as W,
158673
- TerminalWorkflowRunStatusSchema as X,
158674
- ValidQueueName as Y,
158675
- WAIT_EVENT_TYPES as Z,
158676
- WaitSchema as _,
159241
+ StructuredErrorSchema as T,
159242
+ TERMINAL_RUN_EVENT_TYPES as U,
159243
+ TERMINAL_STEP_EVENT_TYPES as V,
159244
+ TERMINAL_STEP_STATUSES as W,
159245
+ TERMINAL_WORKFLOW_RUN_STATUSES as X,
159246
+ TerminalRunEventTypeSchema as Y,
159247
+ TerminalStepStatusSchema as Z,
159248
+ TerminalWorkflowRunStatusSchema as _,
158677
159249
  ATTRIBUTE_MAX_PER_RUN as a,
158678
- WorkflowInvokePayloadSchema as a0,
158679
- WorkflowRunBaseSchema as a1,
158680
- WorkflowRunSchema as a2,
158681
- WorkflowRunStatusSchema as a3,
158682
- applyAttributeChanges as a4,
158683
- envNumber as a5,
158684
- getEventDataPayloadField as a6,
158685
- getEventDataRefFields as a7,
158686
- getQueueTopicPrefix as a8,
158687
- isChildEntityCreationEvent as a9,
158688
- requireTokenUtil as aA,
158689
- requireTokenError as aB,
158690
- serverBuild as aC,
158691
- isChildEntityCreationEventType as aa,
158692
- isHookEventRequiringExistence as ab,
158693
- isHookLifecycleEventType as ac,
158694
- isLegacySpecVersion as ad,
158695
- isStepEventType as ae,
158696
- isTerminalRunEventType as af,
158697
- isTerminalStepEventType as ag,
158698
- isTerminalStepStatus as ah,
158699
- isTerminalWorkflowRunStatus as ai,
158700
- isWaitEventType as aj,
158701
- parseQueueName as ak,
158702
- reenqueueActiveRuns as al,
158703
- requiresNewerWorld as am,
158704
- resolveQueueNamespace as an,
158705
- stripEventDataRefs as ao,
158706
- ulidToDate as ap,
158707
- validateAttributeChanges as aq,
158708
- validateAttributeKey as ar,
158709
- validateAttributeValue as as,
158710
- validateUlidTimestamp as at,
158711
- workflowRunIdSchema as au,
158712
- R as av,
158713
- Ks as aw,
158714
- jsxRuntimeExports as ax,
158715
- Qe as ay,
158716
- registerZstdDecoder as az,
159250
+ WAIT_EVENT_TYPES as a0,
159251
+ WaitSchema as a1,
159252
+ WaitStatusSchema as a2,
159253
+ WorkflowInvokePayloadSchema as a3,
159254
+ WorkflowRunBaseSchema as a4,
159255
+ WorkflowRunSchema as a5,
159256
+ WorkflowRunStatusSchema as a6,
159257
+ applyAttributeChanges as a7,
159258
+ envNumber as a8,
159259
+ getEventDataPayloadField as a9,
159260
+ jsxRuntimeExports as aA,
159261
+ Qe as aB,
159262
+ registerZstdDecoder as aC,
159263
+ requireTokenUtil as aD,
159264
+ requireTokenError as aE,
159265
+ serverBuild as aF,
159266
+ getEventDataRefFields as aa,
159267
+ getQueueTopicPrefix as ab,
159268
+ isChildEntityCreationEvent as ac,
159269
+ isChildEntityCreationEventType as ad,
159270
+ isHookEventRequiringExistence as ae,
159271
+ isHookLifecycleEventType as af,
159272
+ isLegacySpecVersion as ag,
159273
+ isStepEventType as ah,
159274
+ isTerminalRunEventType as ai,
159275
+ isTerminalStepEventType as aj,
159276
+ isTerminalStepStatus as ak,
159277
+ isTerminalWorkflowRunStatus as al,
159278
+ isWaitEventType as am,
159279
+ parseQueueName as an,
159280
+ reenqueueActiveRuns as ao,
159281
+ requiresNewerWorld as ap,
159282
+ resolveQueueNamespace as aq,
159283
+ stripEventDataRefs as ar,
159284
+ ulidToDate as as,
159285
+ validateAttributeChanges as at,
159286
+ validateAttributeKey as au,
159287
+ validateAttributeValue as av,
159288
+ validateUlidTimestamp as aw,
159289
+ workflowRunIdSchema as ax,
159290
+ R as ay,
159291
+ Ks as az,
158717
159292
  ATTRIBUTE_VALUE_MAX_BYTES as b,
158718
159293
  AnalyticsAttributeKeySchema as c,
158719
159294
  AnalyticsEventSchema as d,
@@ -158732,11 +159307,11 @@ export {
158732
159307
  HOOK_LIFECYCLE_EVENT_TYPES as q,
158733
159308
  HealthCheckPayloadSchema as r,
158734
159309
  HookCreatedEventSchema as s,
158735
- QueuePrefix as t,
158736
- RunInputSchema as u,
158737
- SPEC_VERSION_LEGACY as v,
158738
- SPEC_VERSION_SUPPORTS_ATTRIBUTES as w,
158739
- SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as x,
158740
- SPEC_VERSION_SUPPORTS_COMPRESSION as y,
158741
- STEP_EVENT_TYPES as z
159310
+ PaginatedResponseSchema as t,
159311
+ QueuePrefix as u,
159312
+ ROOT_RUN_ID_ATTRIBUTE as v,
159313
+ RunInputSchema as w,
159314
+ SPEC_VERSION_LEGACY as x,
159315
+ SPEC_VERSION_SUPPORTS_ATTRIBUTES as y,
159316
+ SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as z
158742
159317
  };