@workflow/web 5.0.0-beta.13 → 5.0.0-beta.14

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.
@@ -14,7 +14,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
14
14
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
15
15
  var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
16
16
  var _a2, _b, _c, _d, _listeners, _onabort, _reader, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn, _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn, _worldPromise, _Run_instances, lazyWorldPromise_get, _encryptionKeyPromise, _resilientStart, getEncryptionKey_fn, getEncryptionKeyLazily_fn, pollReturnValue_fn;
17
- 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-eXXkzWLS.js";
17
+ 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-BKJ-G0q_.js";
18
18
  import require$$0$4, { PassThrough } from "node:stream";
19
19
  import require$$0 from "util";
20
20
  import require$$1 from "crypto";
@@ -24066,10 +24066,10 @@ const computePosition$1 = async (reference, floating, config2) => {
24066
24066
  const {
24067
24067
  placement = "bottom",
24068
24068
  strategy = "absolute",
24069
- middleware: middleware2 = [],
24069
+ middleware = [],
24070
24070
  platform: platform2
24071
24071
  } = config2;
24072
- const validMiddleware = middleware2.filter(Boolean);
24072
+ const validMiddleware = middleware.filter(Boolean);
24073
24073
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
24074
24074
  let rects = await platform2.getElementRects({
24075
24075
  reference,
@@ -25551,7 +25551,7 @@ function useFloating(options) {
25551
25551
  const {
25552
25552
  placement = "bottom",
25553
25553
  strategy = "absolute",
25554
- middleware: middleware2 = [],
25554
+ middleware = [],
25555
25555
  platform: platform2,
25556
25556
  elements: {
25557
25557
  reference: externalReference,
@@ -25569,9 +25569,9 @@ function useFloating(options) {
25569
25569
  middlewareData: {},
25570
25570
  isPositioned: false
25571
25571
  });
25572
- const [latestMiddleware, setLatestMiddleware] = reactExports.useState(middleware2);
25573
- if (!deepEqual(latestMiddleware, middleware2)) {
25574
- setLatestMiddleware(middleware2);
25572
+ const [latestMiddleware, setLatestMiddleware] = reactExports.useState(middleware);
25573
+ if (!deepEqual(latestMiddleware, middleware)) {
25574
+ setLatestMiddleware(middleware);
25575
25575
  }
25576
25576
  const [_reference, _setReference] = reactExports.useState(null);
25577
25577
  const [_floating, _setFloating] = reactExports.useState(null);
@@ -30734,6 +30734,41 @@ function formatDuration(ms2, compact = false) {
30734
30734
  parts.push(`${seconds}s`);
30735
30735
  return parts.join(" ");
30736
30736
  }
30737
+ const preciseSecondsFormatter = new Intl.NumberFormat(void 0, {
30738
+ minimumFractionDigits: 2,
30739
+ maximumFractionDigits: 2
30740
+ });
30741
+ function formatDurationPrecise(ms2) {
30742
+ if (ms2 === 0) {
30743
+ return "0s";
30744
+ }
30745
+ if (ms2 < MS_IN_SECOND) {
30746
+ const roundedMs = Math.round(ms2);
30747
+ if (roundedMs < MS_IN_SECOND) {
30748
+ return `${roundedMs}ms`;
30749
+ }
30750
+ }
30751
+ const normalizedMs = Math.round(ms2 / 10) * 10;
30752
+ if (normalizedMs < MS_IN_MINUTE) {
30753
+ return `${preciseSecondsFormatter.format(normalizedMs / MS_IN_SECOND)}s`;
30754
+ }
30755
+ const days = Math.floor(normalizedMs / MS_IN_DAY);
30756
+ const hours = Math.floor(normalizedMs % MS_IN_DAY / MS_IN_HOUR);
30757
+ const minutes = Math.floor(normalizedMs % MS_IN_HOUR / MS_IN_MINUTE);
30758
+ const seconds = normalizedMs % MS_IN_MINUTE / MS_IN_SECOND;
30759
+ const parts = [];
30760
+ if (days > 0) {
30761
+ parts.push(`${days}d`);
30762
+ }
30763
+ if (hours > 0) {
30764
+ parts.push(`${hours}h`);
30765
+ }
30766
+ if (minutes > 0) {
30767
+ parts.push(`${minutes}m`);
30768
+ }
30769
+ parts.push(`${preciseSecondsFormatter.format(seconds)}s`);
30770
+ return parts.join(" ");
30771
+ }
30737
30772
  function isDoStreamStep(stepName) {
30738
30773
  return stepName.endsWith("//doStreamStep");
30739
30774
  }
@@ -48944,11 +48979,30 @@ const HookSchema = object$1({
48944
48979
  isWebhook: boolean$3().optional(),
48945
48980
  isSystem: boolean$3().optional()
48946
48981
  });
48947
- const QueuePrefix = union([
48948
- literal("__wkf_step_"),
48949
- literal("__wkf_workflow_")
48950
- ]);
48951
- const ValidQueueName = templateLiteral([QueuePrefix, string$3()]);
48982
+ const QueuePrefix = string$3().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_$/, "Must match __wkf_{workflow|step}_ or __{namespace}_wkf_{workflow|step}_");
48983
+ const ValidQueueName = string$3().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_.+$/, "Must be a valid queue name with a recognized prefix");
48984
+ const QueueNamespace = string$3().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
48985
+ function resolveQueueNamespace(namespace2) {
48986
+ return namespace2 ?? process.env.WORKFLOW_QUEUE_NAMESPACE ?? void 0;
48987
+ }
48988
+ function getQueueTopicPrefix(kind, namespace2) {
48989
+ if (namespace2 !== void 0) {
48990
+ QueueNamespace.parse(namespace2);
48991
+ return `__${namespace2}_wkf_${kind}_`;
48992
+ }
48993
+ return `__wkf_${kind}_`;
48994
+ }
48995
+ function parseQueueName(name2) {
48996
+ const match2 = name2.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_(workflow|step)_)(.+)$/);
48997
+ if (!match2) {
48998
+ throw new Error(`Invalid queue name: ${name2}`);
48999
+ }
49000
+ return {
49001
+ prefix: QueuePrefix.parse(match2[1]),
49002
+ kind: match2[2],
49003
+ id: match2[3]
49004
+ };
49005
+ }
48952
49006
  const MessageId = string$3().brand().describe("A stored queue message ID");
48953
49007
  const TraceCarrierSchema = record(string$3(), string$3());
48954
49008
  const RunInputSchema = object$1({
@@ -78252,17 +78306,17 @@ function trough() {
78252
78306
  return pipeline;
78253
78307
  }
78254
78308
  }
78255
- function wrap(middleware2, callback) {
78309
+ function wrap(middleware, callback) {
78256
78310
  let called;
78257
78311
  return wrapped;
78258
78312
  function wrapped(...parameters) {
78259
- const fnExpectsCallback = middleware2.length > parameters.length;
78313
+ const fnExpectsCallback = middleware.length > parameters.length;
78260
78314
  let result;
78261
78315
  if (fnExpectsCallback) {
78262
78316
  parameters.push(done);
78263
78317
  }
78264
78318
  try {
78265
- result = middleware2.apply(this, parameters);
78319
+ result = middleware.apply(this, parameters);
78266
78320
  } catch (error2) {
78267
78321
  const exception = (
78268
78322
  /** @type {Error} */
@@ -80651,7 +80705,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
80651
80705
  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 });
80652
80706
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
80653
80707
  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 }) });
80654
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DMxq-VLe.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
80708
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-Frh10t8y.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
80655
80709
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
80656
80710
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
80657
80711
  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 }) })] }) });
@@ -80973,7 +81027,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
80973
81027
  }, []), 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] });
80974
81028
  };
80975
81029
  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 }) })] });
80976
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-DNPNsNRF.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
81030
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-BtSvadnb.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
80977
81031
  function ke(e, t) {
80978
81032
  if (!(e != null && e.position || t != null && t.position)) return true;
80979
81033
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -81667,6 +81721,7 @@ const attributeOrder = [
81667
81721
  "eventData",
81668
81722
  "input",
81669
81723
  "output",
81724
+ "attributes",
81670
81725
  "resumeAt"
81671
81726
  ];
81672
81727
  const sortByAttributeOrder = (a2, b2) => {
@@ -81685,6 +81740,7 @@ const attributeDisplayNames = {
81685
81740
  runId: "Run ID",
81686
81741
  token: "Token",
81687
81742
  eventType: "Event Type",
81743
+ errorCode: "Error Code",
81688
81744
  correlationId: "Correlation ID",
81689
81745
  deploymentId: "Deployment ID",
81690
81746
  specVersion: "Spec Version",
@@ -81783,12 +81839,12 @@ const attributeToDisplayFn = {
81783
81839
  environment: (_value) => null,
81784
81840
  executionContext: (_value) => null,
81785
81841
  // Attributes MVP — string-string metadata attached to the run.
81786
- // Rendered as a JSON block; if empty/missing, hidden by the
81787
- // hasDisplayContent gate above.
81842
+ // Rendered in its own collapsible DetailCard; if empty/missing, hidden
81843
+ // by the hasDisplayContent gate.
81788
81844
  attributes: (value) => {
81789
81845
  if (!hasDisplayContent(value))
81790
81846
  return null;
81791
- return JsonBlock(value);
81847
+ return jsxRuntimeExports.jsx(DetailCard, { summary: "Attributes", children: JsonBlock(value) });
81792
81848
  },
81793
81849
  // Dates — wrapped with TimestampTooltip showing UTC/local + relative time
81794
81850
  createdAt: timestampWithTooltipOrNull,
@@ -81879,12 +81935,14 @@ const resolvableAttributes = [
81879
81935
  "output",
81880
81936
  "error",
81881
81937
  "metadata",
81938
+ "attributes",
81882
81939
  "eventData"
81883
81940
  ];
81884
81941
  const selfHeaderedAttributes = /* @__PURE__ */ new Set([
81885
81942
  "input",
81886
81943
  "output",
81887
81944
  "error",
81945
+ "attributes",
81888
81946
  "eventData"
81889
81947
  ]);
81890
81948
  const ExpiredDataMessage = () => jsxRuntimeExports.jsx("div", { className: "text-copy-12 rounded-md border p-4 my-2", style: {
@@ -82113,13 +82171,13 @@ function EventDataBlock({ eventType, data }) {
82113
82171
  }
82114
82172
  return jsxRuntimeExports.jsx(CopyableDataBlock, { data });
82115
82173
  }
82116
- function EventsList({ events: events2, isLoading = false, error: error2, onLoadEventData, encryptionKey }) {
82174
+ function EventsList({ events: events2, isLoading = false, error: error2, onLoadEventData, onStreamClick, onRunClick, encryptionKey }) {
82117
82175
  const sortedEvents2 = reactExports.useMemo(() => [...events2].sort((a2, b2) => new Date(a2.createdAt).getTime() - new Date(b2.createdAt).getTime()), [events2]);
82118
82176
  const hasEvents = sortedEvents2.length > 0 && !error2;
82119
82177
  if (!hasEvents && !isLoading) {
82120
82178
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Events", disabled: true });
82121
82179
  }
82122
- return jsxRuntimeExports.jsx(DetailCard, { summary: "Events", contentClassName: "mb-0", defaultOpen: true, children: isLoading ? jsxRuntimeExports.jsx("div", { className: "flex flex-col -mx-4", children: [0, 1, 2].map((i) => jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-3 bg-background-200 px-4 py-2", children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-4 w-32 rounded" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-3 w-16 rounded" })] }, i)) }) : jsxRuntimeExports.jsx("div", { className: "flex flex-col -mx-4", children: sortedEvents2.map((event) => jsxRuntimeExports.jsx(EventItem, { event, onLoadEventData, encryptionKey }, event.eventId)) }) });
82180
+ return jsxRuntimeExports.jsx(RunClickContext.Provider, { value: onRunClick, children: jsxRuntimeExports.jsx(StreamClickContext.Provider, { value: onStreamClick, children: jsxRuntimeExports.jsx(DetailCard, { summary: "Events", contentClassName: "mb-0", defaultOpen: true, children: isLoading ? jsxRuntimeExports.jsx("div", { className: "flex flex-col -mx-4", children: [0, 1, 2].map((i) => jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-3 bg-background-200 px-4 py-2", children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-4 w-32 rounded" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-3 w-16 rounded" })] }, i)) }) : jsxRuntimeExports.jsx("div", { className: "flex flex-col -mx-4", children: sortedEvents2.map((event) => jsxRuntimeExports.jsx(EventItem, { event, onLoadEventData, encryptionKey }, event.eventId)) }) }) }) });
82123
82181
  }
82124
82182
  const SidebarDataContext = reactExports.createContext(null);
82125
82183
  SidebarDataContext.displayName = "SidebarDataContext";
@@ -82136,6 +82194,39 @@ function useSidebarData() {
82136
82194
  function useSidebarDataOptional() {
82137
82195
  return reactExports.useContext(SidebarDataContext);
82138
82196
  }
82197
+ const hasField = (value, key) => key in value;
82198
+ function spanDetailMatchesSelection(detail, resource, resourceId) {
82199
+ if (!detail || typeof detail !== "object" || !resource || !resourceId) {
82200
+ return false;
82201
+ }
82202
+ switch (resource) {
82203
+ case "step":
82204
+ return hasField(detail, "stepId") && detail.stepId === resourceId;
82205
+ case "hook":
82206
+ return hasField(detail, "hookId") && detail.hookId === resourceId;
82207
+ case "sleep":
82208
+ return hasField(detail, "waitId") && detail.waitId === resourceId;
82209
+ case "run":
82210
+ return hasField(detail, "runId") && !("stepId" in detail) && !("hookId" in detail) && !("waitId" in detail) && detail.runId === resourceId;
82211
+ default:
82212
+ return false;
82213
+ }
82214
+ }
82215
+ function mergeSpanDetail(spanData, detail) {
82216
+ if (!detail || typeof detail !== "object") {
82217
+ return spanData;
82218
+ }
82219
+ if (!spanData || typeof spanData !== "object") {
82220
+ return detail;
82221
+ }
82222
+ const merged = { ...detail };
82223
+ for (const [key, value] of Object.entries(spanData)) {
82224
+ if (value !== void 0) {
82225
+ merged[key] = value;
82226
+ }
82227
+ }
82228
+ return merged;
82229
+ }
82139
82230
  function isStep(data) {
82140
82231
  return data !== null && typeof data === "object" && "stepId" in data;
82141
82232
  }
@@ -82225,17 +82316,18 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, spanDetailDat
82225
82316
  ]);
82226
82317
  const error2 = spanDetailError ?? void 0;
82227
82318
  const loading = spanDetailLoading ?? false;
82319
+ const matchedSpanDetailData = reactExports.useMemo(() => spanDetailMatchesSelection(spanDetailData, resource, resourceId) ? spanDetailData : null, [spanDetailData, resource, resourceId]);
82228
82320
  const hookToken = reactExports.useMemo(() => {
82229
82321
  if (resource !== "hook" || !resourceId)
82230
82322
  return void 0;
82231
- if (isHook(spanDetailData) && spanDetailData.token) {
82232
- return spanDetailData.token;
82323
+ if (isHook(matchedSpanDetailData) && matchedSpanDetailData.token) {
82324
+ return matchedSpanDetailData.token;
82233
82325
  }
82234
82326
  if (isHook(data) && data.token) {
82235
82327
  return data.token;
82236
82328
  }
82237
82329
  return void 0;
82238
- }, [resource, resourceId, spanDetailData, data]);
82330
+ }, [resource, resourceId, matchedSpanDetailData, data]);
82239
82331
  reactExports.useEffect(() => {
82240
82332
  if (error2 && selectedSpan && resource) {
82241
82333
  toast2.error(`Failed to load ${resource} details`, {
@@ -82290,7 +82382,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, spanDetailDat
82290
82382
  }
82291
82383
  try {
82292
82384
  setResolvingHook(true);
82293
- const candidate = spanDetailData ?? data;
82385
+ const candidate = matchedSpanDetailData ?? data;
82294
82386
  const hook = isHook(candidate) ? candidate : void 0;
82295
82387
  await onResolveHook(hookToken, payload, hook);
82296
82388
  toast2.success("Hook resolved", {
@@ -82308,8 +82400,8 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, spanDetailDat
82308
82400
  } finally {
82309
82401
  setResolvingHook(false);
82310
82402
  }
82311
- }, [onResolveHook, hookToken, resolvingHook, spanDetailData, data]);
82312
- const displayData = spanDetailData ?? data;
82403
+ }, [onResolveHook, hookToken, resolvingHook, matchedSpanDetailData, data]);
82404
+ const displayData = reactExports.useMemo(() => mergeSpanDetail(data, matchedSpanDetailData), [data, matchedSpanDetailData]);
82313
82405
  const moduleSpecifier = reactExports.useMemo(() => {
82314
82406
  const displayRecord = displayData;
82315
82407
  const displayStepName = displayRecord.stepName;
@@ -82338,7 +82430,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, spanDetailDat
82338
82430
  }, children: [jsxRuntimeExports.jsx(Zap, { className: "h-4 w-4" }), stoppingSleep ? "Waking up..." : "Wake Up Sleep"] }), resource === "hook" && canResolveHook && jsxRuntimeExports.jsxs("button", { type: "button", onClick: () => setShowResolveHookModal(true), disabled: resolvingHook, className: clsx("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium", "disabled:opacity-50 disabled:cursor-not-allowed transition-colors", resolvingHook ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), style: {
82339
82431
  background: "var(--ds-gray-1000)",
82340
82432
  color: "var(--ds-background-100)"
82341
- }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, expiredAt: run2.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick, onRunClick, onDecrypt, isDecrypting, resource }), resource !== "run" && rawEvents && jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData, encryptionKey })] }) }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
82433
+ }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, expiredAt: run2.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick, onRunClick, onDecrypt, isDecrypting, resource }), resource !== "run" && rawEvents && jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData, onStreamClick, onRunClick, encryptionKey })] }) }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
82342
82434
  }
82343
82435
  const MAP_HEIGHT = 56;
82344
82436
  const TIMELINE_PADDING = 8;
@@ -84228,7 +84320,7 @@ const EventRow = ({ span, isSelected, isDimmed, onSelectSpan }) => {
84228
84320
  const workflowStatus = (_a3 = span.attributes.data) == null ? void 0 : _a3.status;
84229
84321
  const isErrored = span.status.code === 2 || workflowStatus === "failed";
84230
84322
  const { icon: Icon2, className: tagClassName } = getEventStyle(span.resource, isErrored);
84231
- 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: formatDuration(durationMs) }) })] }) }) });
84323
+ 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) }) })] }) }) });
84232
84324
  };
84233
84325
  const EventList = ({ spans, activeSpanId, searchResult, onSelectSpan }) => {
84234
84326
  const listRef = reactExports.useRef(null);
@@ -84426,7 +84518,7 @@ function PlainBar({ bg: bg2, border, label }) {
84426
84518
  }
84427
84519
  function SegmentBar({ segments }) {
84428
84520
  return jsxRuntimeExports.jsx("div", { className: "relative h-6 w-full", children: segments.map((seg, i) => {
84429
- const label = formatDuration(seg.fullDurationMs);
84521
+ const label = formatDurationPrecise(seg.fullDurationMs);
84430
84522
  const showLabel = seg.pixelWidth >= Math.max(40, label.length * 6 + 12);
84431
84523
  const isNarrowQueued = seg.status === "queued" && seg.pixelWidth < 20;
84432
84524
  const overrideBg = isNarrowQueued ? "var(--ds-gray-400)" : void 0;
@@ -84454,7 +84546,7 @@ const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, v
84454
84546
  const colors = getResourceColor(span.resource);
84455
84547
  const fallbackBg = isErrored ? colors.errorBg ?? "var(--ds-red-200)" : colors.bg;
84456
84548
  const fallbackBorder = isErrored ? colors.errorBorder ?? "var(--ds-red-500)" : colors.border;
84457
- const totalLabel = formatDuration(totalDurationMs);
84549
+ const totalLabel = formatDurationPrecise(totalDurationMs);
84458
84550
  const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, totalLabel.length * 6 + 12);
84459
84551
  const handleClick = reactExports.useCallback(() => {
84460
84552
  onSelect(span.spanId);
@@ -88887,7 +88979,7 @@ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
88887
88979
  encrypt: encrypt$1,
88888
88980
  importKey
88889
88981
  }, Symbol.toStringTag, { value: "Module" }));
88890
- const version$1 = "5.0.0-beta.13";
88982
+ const version$1 = "5.0.0-beta.14";
88891
88983
  const WorldCacheKey = Symbol.for("@workflow/world//cache");
88892
88984
  const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
88893
88985
  const GetWorldFnKey$1 = Symbol.for("@workflow/world//getWorldFn");
@@ -88908,11 +89000,12 @@ async function getWorldLazy() {
88908
89000
  }
88909
89001
  const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
88910
89002
  const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
88911
- function getWorkflowQueueName(workflowName) {
89003
+ function getWorkflowQueueName(workflowName, namespace2) {
88912
89004
  if (!SAFE_WORKFLOW_NAME_PATTERN.test(workflowName)) {
88913
89005
  throw new Error(`Invalid workflow name "${workflowName}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);
88914
89006
  }
88915
- return `__wkf_workflow_${workflowName}`;
89007
+ const prefix = getQueueTopicPrefix("workflow", resolveQueueNamespace(namespace2));
89008
+ return `${prefix}${workflowName}`;
88916
89009
  }
88917
89010
  const generateId = monotonicFactory();
88918
89011
  function getHealthCheckStreamName(correlationId) {
@@ -88979,7 +89072,7 @@ async function healthCheck(world, endpoint, options) {
88979
89072
  const timeout2 = (options == null ? void 0 : options.timeout) ?? DEFAULT_HEALTH_CHECK_TIMEOUT;
88980
89073
  const correlationId = generateId();
88981
89074
  const streamName = getHealthCheckStreamName(correlationId);
88982
- const queueName = endpoint === "workflow" ? "__wkf_workflow_health_check" : "__wkf_step_health_check";
89075
+ const queueName = `${getQueueTopicPrefix(endpoint, resolveQueueNamespace(options == null ? void 0 : options.namespace))}health_check`;
88983
89076
  const startTime = Date.now();
88984
89077
  try {
88985
89078
  await world.queue(queueName, { __healthCheck: true, correlationId }, {
@@ -89922,1098 +90015,6 @@ function deserialize(data, options) {
89922
90015
  }
89923
90016
  const CONTEXT_STORAGE_SYMBOL = Symbol.for("WORKFLOW_STEP_CONTEXT_STORAGE");
89924
90017
  const contextStorage = globalThis[CONTEXT_STORAGE_SYMBOL] ?? (globalThis[CONTEXT_STORAGE_SYMBOL] = new AsyncLocalStorage());
89925
- var headers$1;
89926
- var hasRequiredHeaders$1;
89927
- function requireHeaders$1() {
89928
- if (hasRequiredHeaders$1) return headers$1;
89929
- hasRequiredHeaders$1 = 1;
89930
- var __defProp3 = Object.defineProperty;
89931
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
89932
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
89933
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
89934
- var __export2 = (target2, all2) => {
89935
- for (var name2 in all2)
89936
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
89937
- };
89938
- var __copyProps2 = (to2, from, except, desc) => {
89939
- if (from && typeof from === "object" || typeof from === "function") {
89940
- for (let key of __getOwnPropNames2(from))
89941
- if (!__hasOwnProp2.call(to2, key) && key !== except)
89942
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
89943
- }
89944
- return to2;
89945
- };
89946
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
89947
- var headers_exports = {};
89948
- __export2(headers_exports, {
89949
- CITY_HEADER_NAME: () => CITY_HEADER_NAME,
89950
- COUNTRY_HEADER_NAME: () => COUNTRY_HEADER_NAME,
89951
- EMOJI_FLAG_UNICODE_STARTING_POSITION: () => EMOJI_FLAG_UNICODE_STARTING_POSITION,
89952
- IP_HEADER_NAME: () => IP_HEADER_NAME,
89953
- LATITUDE_HEADER_NAME: () => LATITUDE_HEADER_NAME,
89954
- LONGITUDE_HEADER_NAME: () => LONGITUDE_HEADER_NAME,
89955
- POSTAL_CODE_HEADER_NAME: () => POSTAL_CODE_HEADER_NAME,
89956
- REGION_HEADER_NAME: () => REGION_HEADER_NAME,
89957
- REQUEST_ID_HEADER_NAME: () => REQUEST_ID_HEADER_NAME,
89958
- geolocation: () => geolocation,
89959
- ipAddress: () => ipAddress
89960
- });
89961
- headers$1 = __toCommonJS(headers_exports);
89962
- const CITY_HEADER_NAME = "x-vercel-ip-city";
89963
- const COUNTRY_HEADER_NAME = "x-vercel-ip-country";
89964
- const IP_HEADER_NAME = "x-real-ip";
89965
- const LATITUDE_HEADER_NAME = "x-vercel-ip-latitude";
89966
- const LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
89967
- const REGION_HEADER_NAME = "x-vercel-ip-country-region";
89968
- const POSTAL_CODE_HEADER_NAME = "x-vercel-ip-postal-code";
89969
- const REQUEST_ID_HEADER_NAME = "x-vercel-id";
89970
- const EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397;
89971
- function getHeader2(headers2, key) {
89972
- return headers2.get(key) ?? void 0;
89973
- }
89974
- function getHeaderWithDecode(request2, key) {
89975
- const header = getHeader2(request2.headers, key);
89976
- return header ? decodeURIComponent(header) : void 0;
89977
- }
89978
- function getFlag(countryCode) {
89979
- const regex = new RegExp("^[A-Z]{2}$").test(countryCode);
89980
- if (!countryCode || !regex)
89981
- return void 0;
89982
- return String.fromCodePoint(
89983
- ...countryCode.split("").map((char) => EMOJI_FLAG_UNICODE_STARTING_POSITION + char.charCodeAt(0))
89984
- );
89985
- }
89986
- function ipAddress(input) {
89987
- const headers2 = "headers" in input ? input.headers : input;
89988
- return getHeader2(headers2, IP_HEADER_NAME);
89989
- }
89990
- function getRegionFromRequestId(requestId) {
89991
- if (!requestId) {
89992
- return "dev1";
89993
- }
89994
- return requestId.split(":")[0];
89995
- }
89996
- function geolocation(request2) {
89997
- return {
89998
- // city name may be encoded to support multi-byte characters
89999
- city: getHeaderWithDecode(request2, CITY_HEADER_NAME),
90000
- country: getHeader2(request2.headers, COUNTRY_HEADER_NAME),
90001
- flag: getFlag(getHeader2(request2.headers, COUNTRY_HEADER_NAME)),
90002
- countryRegion: getHeader2(request2.headers, REGION_HEADER_NAME),
90003
- region: getRegionFromRequestId(
90004
- getHeader2(request2.headers, REQUEST_ID_HEADER_NAME)
90005
- ),
90006
- latitude: getHeader2(request2.headers, LATITUDE_HEADER_NAME),
90007
- longitude: getHeader2(request2.headers, LONGITUDE_HEADER_NAME),
90008
- postalCode: getHeader2(request2.headers, POSTAL_CODE_HEADER_NAME)
90009
- };
90010
- }
90011
- return headers$1;
90012
- }
90013
- var getEnv_1;
90014
- var hasRequiredGetEnv;
90015
- function requireGetEnv() {
90016
- if (hasRequiredGetEnv) return getEnv_1;
90017
- hasRequiredGetEnv = 1;
90018
- var __defProp3 = Object.defineProperty;
90019
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90020
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90021
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90022
- var __export2 = (target2, all2) => {
90023
- for (var name2 in all2)
90024
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90025
- };
90026
- var __copyProps2 = (to2, from, except, desc) => {
90027
- if (from && typeof from === "object" || typeof from === "function") {
90028
- for (let key of __getOwnPropNames2(from))
90029
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90030
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90031
- }
90032
- return to2;
90033
- };
90034
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90035
- var get_env_exports = {};
90036
- __export2(get_env_exports, {
90037
- getEnv: () => getEnv
90038
- });
90039
- getEnv_1 = __toCommonJS(get_env_exports);
90040
- const getEnv = (env2 = process.env) => ({
90041
- /**
90042
- * An indicator to show that System Environment Variables have been exposed to your project's Deployments.
90043
- * @example "1"
90044
- */
90045
- VERCEL: get2(env2, "VERCEL"),
90046
- /**
90047
- * An indicator that the code is running in a Continuous Integration environment.
90048
- * @example "1"
90049
- */
90050
- CI: get2(env2, "CI"),
90051
- /**
90052
- * The Environment that the app is deployed and running on.
90053
- * @example "production"
90054
- */
90055
- VERCEL_ENV: get2(env2, "VERCEL_ENV"),
90056
- /**
90057
- * The domain name of the generated deployment URL. The value does not include the protocol scheme https://.
90058
- * NOTE: This Variable cannot be used in conjunction with Standard Deployment Protection.
90059
- * @example "*.vercel.app"
90060
- */
90061
- VERCEL_URL: get2(env2, "VERCEL_URL"),
90062
- /**
90063
- * The domain name of the generated Git branch URL. The value does not include the protocol scheme https://.
90064
- * @example "*-git-*.vercel.app"
90065
- */
90066
- VERCEL_BRANCH_URL: get2(env2, "VERCEL_BRANCH_URL"),
90067
- /**
90068
- * A production domain name of the project. This is useful to reliably generate links that point to production such as OG-image URLs.
90069
- * The value does not include the protocol scheme https://.
90070
- * @example "myproject.vercel.app"
90071
- */
90072
- VERCEL_PROJECT_PRODUCTION_URL: get2(env2, "VERCEL_PROJECT_PRODUCTION_URL"),
90073
- /**
90074
- * The ID of the Region where the app is running.
90075
- *
90076
- * Possible values:
90077
- * - arn1 (Stockholm, Sweden)
90078
- * - bom1 (Mumbai, India)
90079
- * - cdg1 (Paris, France)
90080
- * - cle1 (Cleveland, USA)
90081
- * - cpt1 (Cape Town, South Africa)
90082
- * - dub1 (Dublin, Ireland)
90083
- * - fra1 (Frankfurt, Germany)
90084
- * - gru1 (São Paulo, Brazil)
90085
- * - hkg1 (Hong Kong)
90086
- * - hnd1 (Tokyo, Japan)
90087
- * - iad1 (Washington, D.C., USA)
90088
- * - icn1 (Seoul, South Korea)
90089
- * - kix1 (Osaka, Japan)
90090
- * - lhr1 (London, United Kingdom)
90091
- * - pdx1 (Portland, USA)
90092
- * - sfo1 (San Francisco, USA)
90093
- * - sin1 (Singapore)
90094
- * - syd1 (Sydney, Australia)
90095
- * - dev1 (Development Region)
90096
- *
90097
- * @example "iad1"
90098
- */
90099
- VERCEL_REGION: get2(env2, "VERCEL_REGION"),
90100
- /**
90101
- * The unique identifier for the deployment, which can be used to implement Skew Protection.
90102
- * @example "dpl_7Gw5ZMBpQA8h9GF832KGp7nwbuh3"
90103
- */
90104
- VERCEL_DEPLOYMENT_ID: get2(env2, "VERCEL_DEPLOYMENT_ID"),
90105
- /**
90106
- * When Skew Protection is enabled in Project Settings, this value is set to 1.
90107
- * @example "1"
90108
- */
90109
- VERCEL_SKEW_PROTECTION_ENABLED: get2(env2, "VERCEL_SKEW_PROTECTION_ENABLED"),
90110
- /**
90111
- * The Protection Bypass for Automation value, if the secret has been generated in the project's Deployment Protection settings.
90112
- */
90113
- VERCEL_AUTOMATION_BYPASS_SECRET: get2(env2, "VERCEL_AUTOMATION_BYPASS_SECRET"),
90114
- /**
90115
- * The Git Provider the deployment is triggered from.
90116
- * @example "github"
90117
- */
90118
- VERCEL_GIT_PROVIDER: get2(env2, "VERCEL_GIT_PROVIDER"),
90119
- /**
90120
- * The origin repository the deployment is triggered from.
90121
- * @example "my-site"
90122
- */
90123
- VERCEL_GIT_REPO_SLUG: get2(env2, "VERCEL_GIT_REPO_SLUG"),
90124
- /**
90125
- * The account that owns the repository the deployment is triggered from.
90126
- * @example "acme"
90127
- */
90128
- VERCEL_GIT_REPO_OWNER: get2(env2, "VERCEL_GIT_REPO_OWNER"),
90129
- /**
90130
- * The ID of the repository the deployment is triggered from.
90131
- * @example "117716146"
90132
- */
90133
- VERCEL_GIT_REPO_ID: get2(env2, "VERCEL_GIT_REPO_ID"),
90134
- /**
90135
- * The git branch of the commit the deployment was triggered by.
90136
- * @example "improve-about-page"
90137
- */
90138
- VERCEL_GIT_COMMIT_REF: get2(env2, "VERCEL_GIT_COMMIT_REF"),
90139
- /**
90140
- * The git SHA of the commit the deployment was triggered by.
90141
- * @example "fa1eade47b73733d6312d5abfad33ce9e4068081"
90142
- */
90143
- VERCEL_GIT_COMMIT_SHA: get2(env2, "VERCEL_GIT_COMMIT_SHA"),
90144
- /**
90145
- * The message attached to the commit the deployment was triggered by.
90146
- * @example "Update about page"
90147
- */
90148
- VERCEL_GIT_COMMIT_MESSAGE: get2(env2, "VERCEL_GIT_COMMIT_MESSAGE"),
90149
- /**
90150
- * The username attached to the author of the commit that the project was deployed by.
90151
- * @example "johndoe"
90152
- */
90153
- VERCEL_GIT_COMMIT_AUTHOR_LOGIN: get2(env2, "VERCEL_GIT_COMMIT_AUTHOR_LOGIN"),
90154
- /**
90155
- * The name attached to the author of the commit that the project was deployed by.
90156
- * @example "John Doe"
90157
- */
90158
- VERCEL_GIT_COMMIT_AUTHOR_NAME: get2(env2, "VERCEL_GIT_COMMIT_AUTHOR_NAME"),
90159
- /**
90160
- * The git SHA of the last successful deployment for the project and branch.
90161
- * NOTE: This Variable is only exposed when an Ignored Build Step is provided.
90162
- * @example "fa1eade47b73733d6312d5abfad33ce9e4068080"
90163
- */
90164
- VERCEL_GIT_PREVIOUS_SHA: get2(env2, "VERCEL_GIT_PREVIOUS_SHA"),
90165
- /**
90166
- * The pull request id the deployment was triggered by. If a deployment is created on a branch before a pull request is made, this value will be an empty string.
90167
- * @example "23"
90168
- */
90169
- VERCEL_GIT_PULL_REQUEST_ID: get2(env2, "VERCEL_GIT_PULL_REQUEST_ID")
90170
- });
90171
- const get2 = (env2, key) => {
90172
- const value = env2[key];
90173
- return value === "" ? void 0 : value;
90174
- };
90175
- return getEnv_1;
90176
- }
90177
- var getContext_1$1;
90178
- var hasRequiredGetContext$1;
90179
- function requireGetContext$1() {
90180
- if (hasRequiredGetContext$1) return getContext_1$1;
90181
- hasRequiredGetContext$1 = 1;
90182
- var __defProp3 = Object.defineProperty;
90183
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90184
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90185
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90186
- var __export2 = (target2, all2) => {
90187
- for (var name2 in all2)
90188
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90189
- };
90190
- var __copyProps2 = (to2, from, except, desc) => {
90191
- if (from && typeof from === "object" || typeof from === "function") {
90192
- for (let key of __getOwnPropNames2(from))
90193
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90194
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90195
- }
90196
- return to2;
90197
- };
90198
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90199
- var get_context_exports = {};
90200
- __export2(get_context_exports, {
90201
- SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
90202
- getContext: () => getContext
90203
- });
90204
- getContext_1$1 = __toCommonJS(get_context_exports);
90205
- const SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
90206
- function getContext() {
90207
- var _a3, _b2;
90208
- const fromSymbol = globalThis;
90209
- return ((_b2 = (_a3 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a3.get) == null ? void 0 : _b2.call(_a3)) ?? {};
90210
- }
90211
- return getContext_1$1;
90212
- }
90213
- var waitUntil_1;
90214
- var hasRequiredWaitUntil;
90215
- function requireWaitUntil() {
90216
- if (hasRequiredWaitUntil) return waitUntil_1;
90217
- hasRequiredWaitUntil = 1;
90218
- var __defProp3 = Object.defineProperty;
90219
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90220
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90221
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90222
- var __export2 = (target2, all2) => {
90223
- for (var name2 in all2)
90224
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90225
- };
90226
- var __copyProps2 = (to2, from, except, desc) => {
90227
- if (from && typeof from === "object" || typeof from === "function") {
90228
- for (let key of __getOwnPropNames2(from))
90229
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90230
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90231
- }
90232
- return to2;
90233
- };
90234
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90235
- var wait_until_exports = {};
90236
- __export2(wait_until_exports, {
90237
- waitUntil: () => waitUntil
90238
- });
90239
- waitUntil_1 = __toCommonJS(wait_until_exports);
90240
- var import_get_context = requireGetContext$1();
90241
- const waitUntil = (promise2) => {
90242
- var _a3, _b2;
90243
- if (promise2 === null || typeof promise2 !== "object" || typeof promise2.then !== "function") {
90244
- throw new TypeError(
90245
- `waitUntil can only be called with a Promise, got ${typeof promise2}`
90246
- );
90247
- }
90248
- return (_b2 = (_a3 = (0, import_get_context.getContext)()).waitUntil) == null ? void 0 : _b2.call(_a3, promise2);
90249
- };
90250
- return waitUntil_1;
90251
- }
90252
- var middleware;
90253
- var hasRequiredMiddleware;
90254
- function requireMiddleware() {
90255
- if (hasRequiredMiddleware) return middleware;
90256
- hasRequiredMiddleware = 1;
90257
- var __defProp3 = Object.defineProperty;
90258
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90259
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90260
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90261
- var __export2 = (target2, all2) => {
90262
- for (var name2 in all2)
90263
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90264
- };
90265
- var __copyProps2 = (to2, from, except, desc) => {
90266
- if (from && typeof from === "object" || typeof from === "function") {
90267
- for (let key of __getOwnPropNames2(from))
90268
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90269
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90270
- }
90271
- return to2;
90272
- };
90273
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90274
- var middleware_exports = {};
90275
- __export2(middleware_exports, {
90276
- next: () => next2,
90277
- rewrite: () => rewrite
90278
- });
90279
- middleware = __toCommonJS(middleware_exports);
90280
- function handleMiddlewareField(init2, headers2) {
90281
- var _a3;
90282
- if ((_a3 = init2 == null ? void 0 : init2.request) == null ? void 0 : _a3.headers) {
90283
- if (!(init2.request.headers instanceof Headers)) {
90284
- throw new Error("request.headers must be an instance of Headers");
90285
- }
90286
- const keys2 = [];
90287
- for (const [key, value] of init2.request.headers) {
90288
- headers2.set("x-middleware-request-" + key, value);
90289
- keys2.push(key);
90290
- }
90291
- headers2.set("x-middleware-override-headers", keys2.join(","));
90292
- }
90293
- }
90294
- function rewrite(destination, init2) {
90295
- const headers2 = new Headers((init2 == null ? void 0 : init2.headers) ?? {});
90296
- headers2.set("x-middleware-rewrite", String(destination));
90297
- handleMiddlewareField(init2, headers2);
90298
- return new Response(null, {
90299
- ...init2,
90300
- headers: headers2
90301
- });
90302
- }
90303
- function next2(init2) {
90304
- const headers2 = new Headers((init2 == null ? void 0 : init2.headers) ?? {});
90305
- headers2.set("x-middleware-next", "1");
90306
- handleMiddlewareField(init2, headers2);
90307
- return new Response(null, {
90308
- ...init2,
90309
- headers: headers2
90310
- });
90311
- }
90312
- return middleware;
90313
- }
90314
- var inMemoryCache;
90315
- var hasRequiredInMemoryCache;
90316
- function requireInMemoryCache() {
90317
- if (hasRequiredInMemoryCache) return inMemoryCache;
90318
- hasRequiredInMemoryCache = 1;
90319
- var __defProp3 = Object.defineProperty;
90320
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90321
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90322
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90323
- var __export2 = (target2, all2) => {
90324
- for (var name2 in all2)
90325
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90326
- };
90327
- var __copyProps2 = (to2, from, except, desc) => {
90328
- if (from && typeof from === "object" || typeof from === "function") {
90329
- for (let key of __getOwnPropNames2(from))
90330
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90331
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90332
- }
90333
- return to2;
90334
- };
90335
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90336
- var in_memory_cache_exports = {};
90337
- __export2(in_memory_cache_exports, {
90338
- InMemoryCache: () => InMemoryCache
90339
- });
90340
- inMemoryCache = __toCommonJS(in_memory_cache_exports);
90341
- class InMemoryCache {
90342
- constructor() {
90343
- this.cache = {};
90344
- }
90345
- async get(key) {
90346
- const entry2 = this.cache[key];
90347
- if (entry2) {
90348
- if (entry2.ttl && entry2.lastModified + entry2.ttl * 1e3 < Date.now()) {
90349
- await this.delete(key);
90350
- return null;
90351
- }
90352
- return JSON.parse(entry2.value);
90353
- }
90354
- return null;
90355
- }
90356
- async set(key, value, options) {
90357
- const serialized = JSON.stringify(value ?? null);
90358
- this.cache[key] = {
90359
- value: serialized,
90360
- lastModified: Date.now(),
90361
- ttl: options == null ? void 0 : options.ttl,
90362
- tags: new Set((options == null ? void 0 : options.tags) || [])
90363
- };
90364
- }
90365
- async delete(key) {
90366
- delete this.cache[key];
90367
- }
90368
- async expireTag(tag) {
90369
- const tags = Array.isArray(tag) ? tag : [tag];
90370
- for (const key in this.cache) {
90371
- if (Object.prototype.hasOwnProperty.call(this.cache, key)) {
90372
- const entry2 = this.cache[key];
90373
- if (tags.some((t) => entry2.tags.has(t))) {
90374
- delete this.cache[key];
90375
- }
90376
- }
90377
- }
90378
- }
90379
- }
90380
- return inMemoryCache;
90381
- }
90382
- var buildClient;
90383
- var hasRequiredBuildClient;
90384
- function requireBuildClient() {
90385
- if (hasRequiredBuildClient) return buildClient;
90386
- hasRequiredBuildClient = 1;
90387
- var __defProp3 = Object.defineProperty;
90388
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90389
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90390
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90391
- var __export2 = (target2, all2) => {
90392
- for (var name2 in all2)
90393
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90394
- };
90395
- var __copyProps2 = (to2, from, except, desc) => {
90396
- if (from && typeof from === "object" || typeof from === "function") {
90397
- for (let key of __getOwnPropNames2(from))
90398
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90399
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90400
- }
90401
- return to2;
90402
- };
90403
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90404
- var build_client_exports = {};
90405
- __export2(build_client_exports, {
90406
- BuildCache: () => BuildCache
90407
- });
90408
- buildClient = __toCommonJS(build_client_exports);
90409
- var import_index = requireCache$3();
90410
- class BuildCache {
90411
- constructor({
90412
- endpoint,
90413
- headers: headers2,
90414
- onError,
90415
- timeout: timeout2 = 500
90416
- }) {
90417
- this.get = async (key) => {
90418
- var _a3, _b2, _c2, _d2;
90419
- const controller = new AbortController();
90420
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
90421
- try {
90422
- const res = await fetch(`${this.endpoint}${key}`, {
90423
- headers: this.headers,
90424
- method: "GET",
90425
- signal: controller.signal
90426
- });
90427
- if (res.status === 404) {
90428
- clearTimeout(timeoutId);
90429
- return null;
90430
- }
90431
- if (res.status === 200) {
90432
- const cacheState = res.headers.get(
90433
- import_index.HEADERS_VERCEL_CACHE_STATE
90434
- );
90435
- if (cacheState !== import_index.PkgCacheState.Fresh) {
90436
- (_b2 = (_a3 = res.body) == null ? void 0 : _a3.cancel) == null ? void 0 : _b2.call(_a3);
90437
- clearTimeout(timeoutId);
90438
- return null;
90439
- }
90440
- const result = await res.json();
90441
- clearTimeout(timeoutId);
90442
- return result;
90443
- } else {
90444
- clearTimeout(timeoutId);
90445
- throw new Error(`Failed to get cache: ${res.statusText}`);
90446
- }
90447
- } catch (error2) {
90448
- clearTimeout(timeoutId);
90449
- if (error2.name === "AbortError") {
90450
- const timeoutError = new Error(
90451
- `Cache request timed out after ${this.timeout}ms`
90452
- );
90453
- timeoutError.stack = error2.stack;
90454
- (_c2 = this.onError) == null ? void 0 : _c2.call(this, timeoutError);
90455
- } else {
90456
- (_d2 = this.onError) == null ? void 0 : _d2.call(this, error2);
90457
- }
90458
- return null;
90459
- }
90460
- };
90461
- this.set = async (key, value, options) => {
90462
- var _a3, _b2;
90463
- const controller = new AbortController();
90464
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
90465
- try {
90466
- const optionalHeaders = {};
90467
- if (options == null ? void 0 : options.ttl) {
90468
- optionalHeaders[import_index.HEADERS_VERCEL_REVALIDATE] = options.ttl.toString();
90469
- }
90470
- if ((options == null ? void 0 : options.tags) && options.tags.length > 0) {
90471
- optionalHeaders[import_index.HEADERS_VERCEL_CACHE_TAGS] = options.tags.join(",");
90472
- }
90473
- if (options == null ? void 0 : options.name) {
90474
- optionalHeaders[import_index.HEADERS_VERCEL_CACHE_ITEM_NAME] = options.name;
90475
- }
90476
- const res = await fetch(`${this.endpoint}${key}`, {
90477
- method: "POST",
90478
- headers: {
90479
- ...this.headers,
90480
- ...optionalHeaders
90481
- },
90482
- body: JSON.stringify(value),
90483
- signal: controller.signal
90484
- });
90485
- clearTimeout(timeoutId);
90486
- if (res.status !== 200) {
90487
- throw new Error(`Failed to set cache: ${res.status} ${res.statusText}`);
90488
- }
90489
- } catch (error2) {
90490
- clearTimeout(timeoutId);
90491
- if (error2.name === "AbortError") {
90492
- const timeoutError = new Error(
90493
- `Cache request timed out after ${this.timeout}ms`
90494
- );
90495
- timeoutError.stack = error2.stack;
90496
- (_a3 = this.onError) == null ? void 0 : _a3.call(this, timeoutError);
90497
- } else {
90498
- (_b2 = this.onError) == null ? void 0 : _b2.call(this, error2);
90499
- }
90500
- }
90501
- };
90502
- this.delete = async (key) => {
90503
- var _a3, _b2;
90504
- const controller = new AbortController();
90505
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
90506
- try {
90507
- const res = await fetch(`${this.endpoint}${key}`, {
90508
- method: "DELETE",
90509
- headers: this.headers,
90510
- signal: controller.signal
90511
- });
90512
- clearTimeout(timeoutId);
90513
- if (res.status !== 200) {
90514
- throw new Error(`Failed to delete cache: ${res.statusText}`);
90515
- }
90516
- } catch (error2) {
90517
- clearTimeout(timeoutId);
90518
- if (error2.name === "AbortError") {
90519
- const timeoutError = new Error(
90520
- `Cache request timed out after ${this.timeout}ms`
90521
- );
90522
- timeoutError.stack = error2.stack;
90523
- (_a3 = this.onError) == null ? void 0 : _a3.call(this, timeoutError);
90524
- } else {
90525
- (_b2 = this.onError) == null ? void 0 : _b2.call(this, error2);
90526
- }
90527
- }
90528
- };
90529
- this.expireTag = async (tag) => {
90530
- var _a3, _b2;
90531
- const controller = new AbortController();
90532
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
90533
- try {
90534
- if (Array.isArray(tag)) {
90535
- tag = tag.join(",");
90536
- }
90537
- const res = await fetch(`${this.endpoint}revalidate?tags=${tag}`, {
90538
- method: "POST",
90539
- headers: this.headers,
90540
- signal: controller.signal
90541
- });
90542
- clearTimeout(timeoutId);
90543
- if (res.status !== 200) {
90544
- throw new Error(`Failed to revalidate tag: ${res.statusText}`);
90545
- }
90546
- } catch (error2) {
90547
- clearTimeout(timeoutId);
90548
- if (error2.name === "AbortError") {
90549
- const timeoutError = new Error(
90550
- `Cache request timed out after ${this.timeout}ms`
90551
- );
90552
- timeoutError.stack = error2.stack;
90553
- (_a3 = this.onError) == null ? void 0 : _a3.call(this, timeoutError);
90554
- } else {
90555
- (_b2 = this.onError) == null ? void 0 : _b2.call(this, error2);
90556
- }
90557
- }
90558
- };
90559
- this.endpoint = endpoint;
90560
- this.headers = headers2;
90561
- this.onError = onError;
90562
- this.timeout = timeout2;
90563
- }
90564
- }
90565
- return buildClient;
90566
- }
90567
- var cache$3;
90568
- var hasRequiredCache$3;
90569
- function requireCache$3() {
90570
- if (hasRequiredCache$3) return cache$3;
90571
- hasRequiredCache$3 = 1;
90572
- var __defProp3 = Object.defineProperty;
90573
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90574
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90575
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90576
- var __export2 = (target2, all2) => {
90577
- for (var name2 in all2)
90578
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90579
- };
90580
- var __copyProps2 = (to2, from, except, desc) => {
90581
- if (from && typeof from === "object" || typeof from === "function") {
90582
- for (let key of __getOwnPropNames2(from))
90583
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90584
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90585
- }
90586
- return to2;
90587
- };
90588
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90589
- var cache_exports = {};
90590
- __export2(cache_exports, {
90591
- HEADERS_VERCEL_CACHE_ITEM_NAME: () => HEADERS_VERCEL_CACHE_ITEM_NAME,
90592
- HEADERS_VERCEL_CACHE_STATE: () => HEADERS_VERCEL_CACHE_STATE,
90593
- HEADERS_VERCEL_CACHE_TAGS: () => HEADERS_VERCEL_CACHE_TAGS,
90594
- HEADERS_VERCEL_REVALIDATE: () => HEADERS_VERCEL_REVALIDATE,
90595
- PkgCacheState: () => PkgCacheState,
90596
- getCache: () => getCache
90597
- });
90598
- cache$3 = __toCommonJS(cache_exports);
90599
- var import_get_context = requireGetContext$1();
90600
- var import_in_memory_cache = requireInMemoryCache();
90601
- var import_build_client = requireBuildClient();
90602
- const defaultKeyHashFunction = (key) => {
90603
- let hash2 = 5381;
90604
- for (let i = 0; i < key.length; i++) {
90605
- hash2 = hash2 * 33 ^ key.charCodeAt(i);
90606
- }
90607
- return (hash2 >>> 0).toString(16);
90608
- };
90609
- const defaultNamespaceSeparator = "$";
90610
- let inMemoryCacheInstance = null;
90611
- let buildCacheInstance = null;
90612
- const getCache = (cacheOptions) => {
90613
- const resolveCache = () => {
90614
- let cache2;
90615
- if ((0, import_get_context.getContext)().cache) {
90616
- cache2 = (0, import_get_context.getContext)().cache;
90617
- } else {
90618
- cache2 = getCacheImplementation(
90619
- process.env.SUSPENSE_CACHE_DEBUG === "true"
90620
- );
90621
- }
90622
- return cache2;
90623
- };
90624
- return wrapWithKeyTransformation(
90625
- resolveCache,
90626
- createKeyTransformer(cacheOptions)
90627
- );
90628
- };
90629
- function createKeyTransformer(cacheOptions) {
90630
- const hashFunction = (cacheOptions == null ? void 0 : cacheOptions.keyHashFunction) || defaultKeyHashFunction;
90631
- return (key) => {
90632
- if (!(cacheOptions == null ? void 0 : cacheOptions.namespace))
90633
- return hashFunction(key);
90634
- const separator = cacheOptions.namespaceSeparator || defaultNamespaceSeparator;
90635
- return `${cacheOptions.namespace}${separator}${hashFunction(key)}`;
90636
- };
90637
- }
90638
- function wrapWithKeyTransformation(resolveCache, makeKey) {
90639
- return {
90640
- get: (key) => {
90641
- return resolveCache().get(makeKey(key));
90642
- },
90643
- set: (key, value, options) => {
90644
- return resolveCache().set(makeKey(key), value, options);
90645
- },
90646
- delete: (key) => {
90647
- return resolveCache().delete(makeKey(key));
90648
- },
90649
- expireTag: (tag) => {
90650
- return resolveCache().expireTag(tag);
90651
- }
90652
- };
90653
- }
90654
- let warnedCacheUnavailable = false;
90655
- function getCacheImplementation(debug) {
90656
- if (!inMemoryCacheInstance) {
90657
- inMemoryCacheInstance = new import_in_memory_cache.InMemoryCache();
90658
- }
90659
- if (process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE === "true") {
90660
- debug && console.log("Using InMemoryCache as build cache is disabled");
90661
- return inMemoryCacheInstance;
90662
- }
90663
- const { RUNTIME_CACHE_ENDPOINT, RUNTIME_CACHE_HEADERS } = process.env;
90664
- if (debug) {
90665
- console.log("Runtime cache environment variables:", {
90666
- RUNTIME_CACHE_ENDPOINT,
90667
- RUNTIME_CACHE_HEADERS
90668
- });
90669
- }
90670
- if (!RUNTIME_CACHE_ENDPOINT || !RUNTIME_CACHE_HEADERS) {
90671
- if (!warnedCacheUnavailable) {
90672
- console.warn(
90673
- "Runtime Cache unavailable in this environment. Falling back to in-memory cache."
90674
- );
90675
- warnedCacheUnavailable = true;
90676
- }
90677
- return inMemoryCacheInstance;
90678
- }
90679
- if (!buildCacheInstance) {
90680
- let parsedHeaders = {};
90681
- try {
90682
- parsedHeaders = JSON.parse(RUNTIME_CACHE_HEADERS);
90683
- } catch (e) {
90684
- console.error("Failed to parse RUNTIME_CACHE_HEADERS:", e);
90685
- return inMemoryCacheInstance;
90686
- }
90687
- let timeout2 = 500;
90688
- if (process.env.RUNTIME_CACHE_TIMEOUT) {
90689
- const parsed = parseInt(process.env.RUNTIME_CACHE_TIMEOUT, 10);
90690
- if (!isNaN(parsed) && parsed > 0) {
90691
- timeout2 = parsed;
90692
- } else {
90693
- console.warn(
90694
- `Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${timeout2}ms`
90695
- );
90696
- }
90697
- }
90698
- buildCacheInstance = new import_build_client.BuildCache({
90699
- endpoint: RUNTIME_CACHE_ENDPOINT,
90700
- headers: parsedHeaders,
90701
- onError: (error2) => console.error(error2),
90702
- timeout: timeout2
90703
- });
90704
- }
90705
- return buildCacheInstance;
90706
- }
90707
- var PkgCacheState = /* @__PURE__ */ ((PkgCacheState2) => {
90708
- PkgCacheState2["Fresh"] = "fresh";
90709
- PkgCacheState2["Stale"] = "stale";
90710
- PkgCacheState2["Expired"] = "expired";
90711
- PkgCacheState2["NotFound"] = "notFound";
90712
- PkgCacheState2["Error"] = "error";
90713
- return PkgCacheState2;
90714
- })(PkgCacheState || {});
90715
- const HEADERS_VERCEL_CACHE_STATE = "x-vercel-cache-state";
90716
- const HEADERS_VERCEL_REVALIDATE = "x-vercel-revalidate";
90717
- const HEADERS_VERCEL_CACHE_TAGS = "x-vercel-cache-tags";
90718
- const HEADERS_VERCEL_CACHE_ITEM_NAME = "x-vercel-cache-item-name";
90719
- return cache$3;
90720
- }
90721
- var dbConnections;
90722
- var hasRequiredDbConnections;
90723
- function requireDbConnections() {
90724
- if (hasRequiredDbConnections) return dbConnections;
90725
- hasRequiredDbConnections = 1;
90726
- var __defProp3 = Object.defineProperty;
90727
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90728
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90729
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90730
- var __export2 = (target2, all2) => {
90731
- for (var name2 in all2)
90732
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90733
- };
90734
- var __copyProps2 = (to2, from, except, desc) => {
90735
- if (from && typeof from === "object" || typeof from === "function") {
90736
- for (let key of __getOwnPropNames2(from))
90737
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90738
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90739
- }
90740
- return to2;
90741
- };
90742
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90743
- var db_connections_exports = {};
90744
- __export2(db_connections_exports, {
90745
- attachDatabasePool: () => attachDatabasePool,
90746
- experimental_attachDatabasePool: () => experimental_attachDatabasePool
90747
- });
90748
- dbConnections = __toCommonJS(db_connections_exports);
90749
- var import_get_context = requireGetContext$1();
90750
- const DEBUG = !!process.env.DEBUG;
90751
- function getIdleTimeout(dbPool) {
90752
- if ("options" in dbPool && dbPool.options) {
90753
- if ("idleTimeoutMillis" in dbPool.options) {
90754
- return typeof dbPool.options.idleTimeoutMillis === "number" ? dbPool.options.idleTimeoutMillis : 1e4;
90755
- }
90756
- if ("maxIdleTimeMS" in dbPool.options) {
90757
- return typeof dbPool.options.maxIdleTimeMS === "number" ? dbPool.options.maxIdleTimeMS : 0;
90758
- }
90759
- if ("status" in dbPool) {
90760
- return 5e3;
90761
- }
90762
- if ("connect" in dbPool && "execute" in dbPool) {
90763
- return 3e4;
90764
- }
90765
- }
90766
- if ("config" in dbPool && dbPool.config) {
90767
- if ("connectionConfig" in dbPool.config && dbPool.config.connectionConfig) {
90768
- return dbPool.config.connectionConfig.idleTimeout || 6e4;
90769
- }
90770
- if ("idleTimeout" in dbPool.config) {
90771
- return typeof dbPool.config.idleTimeout === "number" ? dbPool.config.idleTimeout : 6e4;
90772
- }
90773
- }
90774
- if ("poolTimeout" in dbPool) {
90775
- return typeof dbPool.poolTimeout === "number" ? dbPool.poolTimeout : 6e4;
90776
- }
90777
- if ("idleTimeout" in dbPool) {
90778
- return typeof dbPool.idleTimeout === "number" ? dbPool.idleTimeout : 0;
90779
- }
90780
- return 1e4;
90781
- }
90782
- let idleTimeout = null;
90783
- let idleTimeoutResolve = () => {
90784
- };
90785
- const bootTime = Date.now();
90786
- const maximumDuration = 15 * 60 * 1e3 - 1e3;
90787
- function waitUntilIdleTimeout(dbPool) {
90788
- if (!process.env.VERCEL_URL || // This is not set during builds where we don't need to wait for idle connections using the mechanism
90789
- !process.env.VERCEL_REGION) {
90790
- return;
90791
- }
90792
- if (idleTimeout) {
90793
- clearTimeout(idleTimeout);
90794
- idleTimeoutResolve();
90795
- }
90796
- const promise2 = new Promise((resolve2) => {
90797
- idleTimeoutResolve = resolve2;
90798
- });
90799
- const waitTime = Math.min(
90800
- getIdleTimeout(dbPool) + 100,
90801
- Math.max(100, maximumDuration - (Date.now() - bootTime))
90802
- );
90803
- idleTimeout = setTimeout(() => {
90804
- idleTimeoutResolve == null ? void 0 : idleTimeoutResolve();
90805
- if (DEBUG) {
90806
- console.log("Database pool idle timeout reached. Releasing connections.");
90807
- }
90808
- }, waitTime);
90809
- const requestContext = (0, import_get_context.getContext)();
90810
- if (requestContext == null ? void 0 : requestContext.waitUntil) {
90811
- requestContext.waitUntil(promise2);
90812
- } else {
90813
- console.warn("Pool release event triggered outside of request scope.");
90814
- }
90815
- }
90816
- function attachDatabasePool(dbPool) {
90817
- if (idleTimeout) {
90818
- idleTimeoutResolve == null ? void 0 : idleTimeoutResolve();
90819
- clearTimeout(idleTimeout);
90820
- }
90821
- if ("on" in dbPool && dbPool.on && "options" in dbPool && "idleTimeoutMillis" in dbPool.options) {
90822
- const pgPool = dbPool;
90823
- pgPool.on("release", () => {
90824
- if (DEBUG) {
90825
- console.log("Client released from pool");
90826
- }
90827
- waitUntilIdleTimeout(dbPool);
90828
- });
90829
- return;
90830
- } else if ("on" in dbPool && dbPool.on && "config" in dbPool && dbPool.config && "connectionConfig" in dbPool.config) {
90831
- const mysqlPool = dbPool;
90832
- mysqlPool.on("release", () => {
90833
- if (DEBUG) {
90834
- console.log("MySQL client released from pool");
90835
- }
90836
- waitUntilIdleTimeout(dbPool);
90837
- });
90838
- return;
90839
- } else if ("on" in dbPool && dbPool.on && "config" in dbPool && dbPool.config && "idleTimeout" in dbPool.config) {
90840
- const mysql2Pool = dbPool;
90841
- mysql2Pool.on("release", () => {
90842
- if (DEBUG) {
90843
- console.log("MySQL2/MariaDB client released from pool");
90844
- }
90845
- waitUntilIdleTimeout(dbPool);
90846
- });
90847
- return;
90848
- }
90849
- if ("on" in dbPool && dbPool.on && "options" in dbPool && dbPool.options && "maxIdleTimeMS" in dbPool.options) {
90850
- const mongoPool = dbPool;
90851
- mongoPool.on("connectionCheckedOut", () => {
90852
- if (DEBUG) {
90853
- console.log("MongoDB connection checked out");
90854
- }
90855
- waitUntilIdleTimeout(dbPool);
90856
- });
90857
- return;
90858
- }
90859
- if ("on" in dbPool && dbPool.on && "options" in dbPool && dbPool.options && "socket" in dbPool.options) {
90860
- const redisPool = dbPool;
90861
- redisPool.on("end", () => {
90862
- if (DEBUG) {
90863
- console.log("Redis connection ended");
90864
- }
90865
- waitUntilIdleTimeout(dbPool);
90866
- });
90867
- return;
90868
- }
90869
- throw new Error("Unsupported database pool type");
90870
- }
90871
- const experimental_attachDatabasePool = attachDatabasePool;
90872
- return dbConnections;
90873
- }
90874
- var purge;
90875
- var hasRequiredPurge;
90876
- function requirePurge() {
90877
- if (hasRequiredPurge) return purge;
90878
- hasRequiredPurge = 1;
90879
- var __defProp3 = Object.defineProperty;
90880
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90881
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90882
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90883
- var __export2 = (target2, all2) => {
90884
- for (var name2 in all2)
90885
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90886
- };
90887
- var __copyProps2 = (to2, from, except, desc) => {
90888
- if (from && typeof from === "object" || typeof from === "function") {
90889
- for (let key of __getOwnPropNames2(from))
90890
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90891
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90892
- }
90893
- return to2;
90894
- };
90895
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90896
- var purge_exports = {};
90897
- __export2(purge_exports, {
90898
- dangerouslyDeleteBySrcImage: () => dangerouslyDeleteBySrcImage,
90899
- dangerouslyDeleteByTag: () => dangerouslyDeleteByTag,
90900
- invalidateBySrcImage: () => invalidateBySrcImage,
90901
- invalidateByTag: () => invalidateByTag
90902
- });
90903
- purge = __toCommonJS(purge_exports);
90904
- var import_get_context = requireGetContext$1();
90905
- const invalidateByTag = (tag) => {
90906
- const api2 = (0, import_get_context.getContext)().purge;
90907
- if (api2) {
90908
- return api2.invalidateByTag(tag);
90909
- }
90910
- return Promise.resolve();
90911
- };
90912
- const dangerouslyDeleteByTag = (tag, options) => {
90913
- const api2 = (0, import_get_context.getContext)().purge;
90914
- if (api2) {
90915
- return api2.dangerouslyDeleteByTag(tag, options);
90916
- }
90917
- return Promise.resolve();
90918
- };
90919
- const invalidateBySrcImage = (src2) => {
90920
- const api2 = (0, import_get_context.getContext)().purge;
90921
- return api2 ? api2.invalidateBySrcImage(src2) : Promise.resolve();
90922
- };
90923
- const dangerouslyDeleteBySrcImage = (src2, options) => {
90924
- const api2 = (0, import_get_context.getContext)().purge;
90925
- return api2 ? api2.dangerouslyDeleteBySrcImage(src2, options) : Promise.resolve();
90926
- };
90927
- return purge;
90928
- }
90929
- var addcachetag;
90930
- var hasRequiredAddcachetag;
90931
- function requireAddcachetag() {
90932
- if (hasRequiredAddcachetag) return addcachetag;
90933
- hasRequiredAddcachetag = 1;
90934
- var __defProp3 = Object.defineProperty;
90935
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90936
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90937
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90938
- var __export2 = (target2, all2) => {
90939
- for (var name2 in all2)
90940
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90941
- };
90942
- var __copyProps2 = (to2, from, except, desc) => {
90943
- if (from && typeof from === "object" || typeof from === "function") {
90944
- for (let key of __getOwnPropNames2(from))
90945
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90946
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90947
- }
90948
- return to2;
90949
- };
90950
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90951
- var addcachetag_exports = {};
90952
- __export2(addcachetag_exports, {
90953
- addCacheTag: () => addCacheTag
90954
- });
90955
- addcachetag = __toCommonJS(addcachetag_exports);
90956
- var import_get_context = requireGetContext$1();
90957
- const addCacheTag = (tag) => {
90958
- const addCacheTag2 = (0, import_get_context.getContext)().addCacheTag;
90959
- if (addCacheTag2) {
90960
- return addCacheTag2(tag);
90961
- }
90962
- return Promise.resolve();
90963
- };
90964
- return addcachetag;
90965
- }
90966
- var functions;
90967
- var hasRequiredFunctions;
90968
- function requireFunctions() {
90969
- if (hasRequiredFunctions) return functions;
90970
- hasRequiredFunctions = 1;
90971
- var __defProp3 = Object.defineProperty;
90972
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
90973
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
90974
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90975
- var __export2 = (target2, all2) => {
90976
- for (var name2 in all2)
90977
- __defProp3(target2, name2, { get: all2[name2], enumerable: true });
90978
- };
90979
- var __copyProps2 = (to2, from, except, desc) => {
90980
- if (from && typeof from === "object" || typeof from === "function") {
90981
- for (let key of __getOwnPropNames2(from))
90982
- if (!__hasOwnProp2.call(to2, key) && key !== except)
90983
- __defProp3(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
90984
- }
90985
- return to2;
90986
- };
90987
- var __toCommonJS = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
90988
- var src_exports = {};
90989
- __export2(src_exports, {
90990
- addCacheTag: () => import_addcachetag.addCacheTag,
90991
- attachDatabasePool: () => import_db_connections.attachDatabasePool,
90992
- dangerouslyDeleteBySrcImage: () => import_purge.dangerouslyDeleteBySrcImage,
90993
- dangerouslyDeleteByTag: () => import_purge.dangerouslyDeleteByTag,
90994
- experimental_attachDatabasePool: () => import_db_connections.experimental_attachDatabasePool,
90995
- geolocation: () => import_headers.geolocation,
90996
- getCache: () => import_cache.getCache,
90997
- getEnv: () => import_get_env.getEnv,
90998
- invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
90999
- invalidateByTag: () => import_purge.invalidateByTag,
91000
- ipAddress: () => import_headers.ipAddress,
91001
- next: () => import_middleware.next,
91002
- rewrite: () => import_middleware.rewrite,
91003
- waitUntil: () => import_wait_until.waitUntil
91004
- });
91005
- functions = __toCommonJS(src_exports);
91006
- var import_headers = requireHeaders$1();
91007
- var import_get_env = requireGetEnv();
91008
- var import_wait_until = requireWaitUntil();
91009
- var import_middleware = requireMiddleware();
91010
- var import_cache = requireCache$3();
91011
- var import_db_connections = requireDbConnections();
91012
- var import_purge = requirePurge();
91013
- var import_addcachetag = requireAddcachetag();
91014
- return functions;
91015
- }
91016
- var functionsExports = requireFunctions();
91017
90018
  function getWorkflowRunStreamId(runId, namespace2) {
91018
90019
  const streamId = `${runId.replace("wrun_", "strm_")}_user`;
91019
90020
  if (!namespace2) {
@@ -91025,12 +90026,6 @@ function getWorkflowRunStreamId(runId, namespace2) {
91025
90026
  function getAbortStreamId(id2) {
91026
90027
  return `strm_${id2}_system_abort`;
91027
90028
  }
91028
- async function waitedUntil(fn2) {
91029
- const result = fn2();
91030
- functionsExports.waitUntil(result.catch(() => {
91031
- }));
91032
- return result;
91033
- }
91034
90029
  var EventConsumerResult;
91035
90030
  (function(EventConsumerResult2) {
91036
90031
  EventConsumerResult2[EventConsumerResult2["Consumed"] = 0] = "Consumed";
@@ -91271,6 +90266,107 @@ class WorkflowServerReadableStream extends ReadableStream {
91271
90266
  }
91272
90267
  }
91273
90268
  _reader = new WeakMap();
90269
+ const FRAMED_STREAM_MAX_RECONNECTS = 50;
90270
+ const FRAMED_STREAM_MAX_TOTAL_RECONNECTS = 1e3;
90271
+ function createReconnectingFramedStream(runId, name2, startIndex) {
90272
+ const reconnectSupported = startIndex === void 0 || startIndex >= 0;
90273
+ let currentStartIndex = startIndex ?? 0;
90274
+ let consumedFrames = 0;
90275
+ let reconnectCount = 0;
90276
+ let totalReconnectCount = 0;
90277
+ let reader;
90278
+ let buffer2 = new Uint8Array(0);
90279
+ async function connect2() {
90280
+ const world = await getWorldLazy();
90281
+ const effectiveStartIndex = reconnectSupported ? currentStartIndex + consumedFrames : startIndex;
90282
+ const stream = await world.streams.get(runId, name2, effectiveStartIndex);
90283
+ reader = stream.getReader();
90284
+ }
90285
+ async function reconnect() {
90286
+ reconnectCount++;
90287
+ totalReconnectCount++;
90288
+ if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS) {
90289
+ throw new Error(`Stream "${name2}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS})`);
90290
+ }
90291
+ if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS) {
90292
+ throw new Error(`Stream "${name2}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS})`);
90293
+ }
90294
+ if (reader) {
90295
+ await reader.cancel().catch(() => {
90296
+ });
90297
+ reader = void 0;
90298
+ }
90299
+ currentStartIndex += consumedFrames;
90300
+ consumedFrames = 0;
90301
+ buffer2 = new Uint8Array(0);
90302
+ await connect2();
90303
+ }
90304
+ return new ReadableStream({
90305
+ pull: async (controller) => {
90306
+ for (; ; ) {
90307
+ if (!reader) {
90308
+ try {
90309
+ await connect2();
90310
+ } catch (err) {
90311
+ controller.error(err);
90312
+ return;
90313
+ }
90314
+ }
90315
+ let result;
90316
+ try {
90317
+ result = await reader.read();
90318
+ } catch (err) {
90319
+ if (!reconnectSupported) {
90320
+ controller.error(err);
90321
+ return;
90322
+ }
90323
+ try {
90324
+ await reconnect();
90325
+ } catch (reconnectErr) {
90326
+ controller.error(reconnectErr);
90327
+ return;
90328
+ }
90329
+ continue;
90330
+ }
90331
+ if (result.done || !result.value) {
90332
+ reader = void 0;
90333
+ controller.close();
90334
+ return;
90335
+ }
90336
+ const incoming = result.value;
90337
+ if (incoming.length > 0) {
90338
+ const combined = new Uint8Array(buffer2.length + incoming.length);
90339
+ combined.set(buffer2, 0);
90340
+ combined.set(incoming, buffer2.length);
90341
+ buffer2 = combined;
90342
+ }
90343
+ let emitted = false;
90344
+ while (buffer2.length >= FRAME_HEADER_SIZE$1) {
90345
+ const frameLength = new DataView(buffer2.buffer, buffer2.byteOffset, buffer2.byteLength).getUint32(0, false);
90346
+ const total = FRAME_HEADER_SIZE$1 + frameLength;
90347
+ if (buffer2.length < total)
90348
+ break;
90349
+ controller.enqueue(buffer2.slice(0, total));
90350
+ buffer2 = buffer2.slice(total);
90351
+ consumedFrames++;
90352
+ emitted = true;
90353
+ }
90354
+ if (emitted) {
90355
+ reconnectCount = 0;
90356
+ return;
90357
+ }
90358
+ }
90359
+ },
90360
+ cancel: async () => {
90361
+ if (reader) {
90362
+ await reader.cancel().catch((err) => {
90363
+ console.warn("Error closing ReadableStream reader:", err);
90364
+ });
90365
+ reader = void 0;
90366
+ }
90367
+ }
90368
+ });
90369
+ }
91274
90370
  const STREAM_FLUSH_INTERVAL_MS = 10;
91275
90371
  class WorkflowServerWritableStream extends WritableStream {
91276
90372
  constructor(runId, name2) {
@@ -91806,8 +90902,8 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
91806
90902
  const response2 = new global2.Response(bodyInit);
91807
90903
  return response2.body;
91808
90904
  }
91809
- const readable2 = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
91810
90905
  if (value.type === "bytes") {
90906
+ const readable2 = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
91811
90907
  const state = createFlushableState();
91812
90908
  ops.push(state.promise);
91813
90909
  const { readable: userReadable, writable } = new global2.TransformStream();
@@ -91816,6 +90912,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
91816
90912
  pollReadableLock(userReadable, state);
91817
90913
  return userReadable;
91818
90914
  } else {
90915
+ const readable2 = createReconnectingFramedStream(runId, value.name, value.startIndex);
91819
90916
  const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, cryptoKey), cryptoKey);
91820
90917
  const state = createFlushableState();
91821
90918
  ops.push(state.promise);
@@ -118490,13 +117587,11 @@ function isDetachedArrayBufferQueueError(error2) {
118490
117587
  return false;
118491
117588
  }
118492
117589
  function getQueueRoute(queueName) {
118493
- if (queueName.startsWith("__wkf_step_")) {
118494
- return { pathname: "step", prefix: "__wkf_step_" };
118495
- }
118496
- if (queueName.startsWith("__wkf_workflow_")) {
118497
- return { pathname: "flow", prefix: "__wkf_workflow_" };
118498
- }
118499
- throw new Error("Unknown queue name prefix");
117590
+ const { kind, prefix } = parseQueueName(queueName);
117591
+ return {
117592
+ pathname: kind === "workflow" ? "flow" : "step",
117593
+ prefix
117594
+ };
118500
117595
  }
118501
117596
  function createQueue$2(config2) {
118502
117597
  const httpAgent = new undiciExports.Agent({
@@ -120059,7 +119154,7 @@ function createLocalWorld(args) {
120059
119154
  const basedir = mergedConfig.dataDir;
120060
119155
  const hooksDir = path$3.join(basedir, "hooks");
120061
119156
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
120062
- const { HookSchema: HookSchema2 } = await import("./index-BjEgWhxl.js");
119157
+ const { HookSchema: HookSchema2 } = await import("./index-GhULR6rc.js");
120063
119158
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
120064
119159
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
120065
119160
  if (hook == null ? void 0 : hook.token) {
@@ -120211,8 +119306,8 @@ function requireGetVercelOidcToken() {
120211
119306
  }
120212
119307
  try {
120213
119308
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
120214
- await import("./token-util-Hv7wRzsW.js").then((n) => n.t),
120215
- await import("./token-DOrkjd5O.js").then((n) => n.t)
119309
+ await import("./token-util-FXtXbDcd.js").then((n) => n.t),
119310
+ await import("./token-CpI-8AoV.js").then((n) => n.t)
120216
119311
  ]);
120217
119312
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
120218
119313
  await refreshToken(options);
@@ -125402,7 +124497,7 @@ var QueueClient = class {
125402
124497
  setApi(this, new ApiClient({ ...options, region }));
125403
124498
  }
125404
124499
  };
125405
- const version = "5.0.0-beta.12";
124500
+ const version = "5.0.0-beta.13";
125406
124501
  const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
125407
124502
  function httpLog(method, endpoint, response2, ms2) {
125408
124503
  if (HTTP_DEBUG_ENABLED) {
@@ -126885,6 +125980,28 @@ const getWorld = async () => {
126885
125980
  };
126886
125981
  const GetWorldFnKey = Symbol.for("@workflow/world//getWorldFn");
126887
125982
  globalThis[GetWorldFnKey] ?? (globalThis[GetWorldFnKey] = getWorld);
125983
+ function waitUntil(promise2) {
125984
+ void import("./index-B8YoYr9f.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
125985
+ waitUntil2(promise2);
125986
+ });
125987
+ }
125988
+ function safeWaitUntil(promise2, onError) {
125989
+ waitUntil(promise2.catch((err) => {
125990
+ const isAbortError = (err == null ? void 0 : err.name) === "AbortError" || (err == null ? void 0 : err.name) === "ResponseAborted";
125991
+ if (!isAbortError) {
125992
+ try {
125993
+ onError(err);
125994
+ } catch {
125995
+ }
125996
+ }
125997
+ }));
125998
+ }
125999
+ async function waitedUntil(fn2) {
126000
+ const result = fn2();
126001
+ waitUntil(result.catch(() => {
126002
+ }));
126003
+ return result;
126004
+ }
126888
126005
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
126889
126006
  var intToChar = new Uint8Array(64);
126890
126007
  var charToInt = new Uint8Array(128);
@@ -129578,10 +128695,15 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
129578
128695
  const ops = [];
129579
128696
  const v1Compat = isLegacySpecVersion(hook.specVersion);
129580
128697
  const dehydratedPayload = await dehydrateStepReturnValue(payload, hook.runId, encryptionKey, ops, globalThis, v1Compat);
129581
- functionsExports.waitUntil(Promise.all(ops).catch((err) => {
129582
- if (err !== void 0)
129583
- throw err;
129584
- }));
128698
+ safeWaitUntil(Promise.all(ops), (err) => {
128699
+ if (err === void 0)
128700
+ return;
128701
+ runtimeLogger.warn("Background flush of hook payload ops failed", {
128702
+ workflowRunId: hook.runId,
128703
+ hookId: hook.hookId,
128704
+ error: err instanceof Error ? err.message : String(err)
128705
+ });
128706
+ });
129585
128707
  await world.events.create(hook.runId, {
129586
128708
  eventType: "hook_received",
129587
128709
  specVersion: SPEC_VERSION_CURRENT,
@@ -129760,11 +128882,12 @@ async function start$1(workflow, argsOrOptions, options) {
129760
128882
  throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
129761
128883
  }
129762
128884
  }
129763
- functionsExports.waitUntil(Promise.all(ops).catch((err) => {
129764
- const isAbortError = (err == null ? void 0 : err.name) === "AbortError" || (err == null ? void 0 : err.name) === "ResponseAborted";
129765
- if (!isAbortError)
129766
- throw err;
129767
- }));
128885
+ safeWaitUntil(Promise.all(ops), (err) => {
128886
+ runtimeLogger.warn("Background flush of workflow argument streams failed", {
128887
+ workflowRunId: runId,
128888
+ error: err instanceof Error ? err.message : String(err)
128889
+ });
128890
+ });
129768
128891
  span == null ? void 0 : span.setAttributes({
129769
128892
  ...WorkflowRunId(runId),
129770
128893
  ...DeploymentId(deploymentId),
@@ -132884,9 +132007,9 @@ function useMergeRefs(refs, defaultValue) {
132884
132007
  function ItoI(a2) {
132885
132008
  return a2;
132886
132009
  }
132887
- function innerCreateMedium(defaults2, middleware2) {
132888
- if (middleware2 === void 0) {
132889
- middleware2 = ItoI;
132010
+ function innerCreateMedium(defaults2, middleware) {
132011
+ if (middleware === void 0) {
132012
+ middleware = ItoI;
132890
132013
  }
132891
132014
  var buffer2 = [];
132892
132015
  var assigned = false;
@@ -132901,7 +132024,7 @@ function innerCreateMedium(defaults2, middleware2) {
132901
132024
  return defaults2;
132902
132025
  },
132903
132026
  useMedium: function(data) {
132904
- var item = middleware2(data, assigned);
132027
+ var item = middleware(data, assigned);
132905
132028
  buffer2.push(item);
132906
132029
  return function() {
132907
132030
  buffer2 = buffer2.filter(function(x2) {
@@ -147013,8 +146136,8 @@ function BatchProvider({ children: children2 }) {
147013
146136
  items: next2,
147014
146137
  lookup: nodeLookup
147015
146138
  });
147016
- for (const middleware2 of onNodesChangeMiddlewareMap.values()) {
147017
- changes = middleware2(changes);
146139
+ for (const middleware of onNodesChangeMiddlewareMap.values()) {
146140
+ changes = middleware(changes);
147018
146141
  }
147019
146142
  if (hasDefaultNodes) {
147020
146143
  setNodes(next2);
@@ -148967,8 +148090,8 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
148967
148090
  const parentExpandChanges = handleExpandParent(parentExpandChildren, nodeLookup, parentLookup, nodeOrigin2);
148968
148091
  changes.push(...parentExpandChanges);
148969
148092
  }
148970
- for (const middleware2 of onNodesChangeMiddlewareMap.values()) {
148971
- changes = middleware2(changes);
148093
+ for (const middleware of onNodesChangeMiddlewareMap.values()) {
148094
+ changes = middleware(changes);
148972
148095
  }
148973
148096
  triggerNodeChanges(changes);
148974
148097
  },
@@ -153462,7 +152585,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
153462
152585
  __proto__: null,
153463
152586
  loader
153464
152587
  }, Symbol.toStringTag, { value: "Module" }));
153465
- const serverManifest = { "entry": { "module": "/assets/entry.client-DOJDY_4b.js", "imports": ["/assets/index-BXZSIDEp.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-C5RLIKj5.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/mermaid-3ZIDBTTL-BDM4-x6u.js"], "css": ["/assets/root-Bqr5evzw.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-1yC3MOjQ.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/workflow-graph-viewer-C8H50hkM.js", "/assets/mermaid-3ZIDBTTL-BDM4-x6u.js", "/assets/index-B6-SzLmT.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-DM1PDAnQ.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/workflow-graph-viewer-C8H50hkM.js", "/assets/mermaid-3ZIDBTTL-BDM4-x6u.js", "/assets/encryption-g14N5vQl.js", "/assets/index-B6-SzLmT.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-9f37c22f.js", "version": "9f37c22f", "sri": void 0 };
152588
+ const serverManifest = { "entry": { "module": "/assets/entry.client-DOJDY_4b.js", "imports": ["/assets/index-BXZSIDEp.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-Dduz44vX.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/mermaid-3ZIDBTTL-C02sm-ZS.js"], "css": ["/assets/root-Bqr5evzw.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-D9oyGYfj.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/workflow-graph-viewer-CU0UU458.js", "/assets/mermaid-3ZIDBTTL-C02sm-ZS.js", "/assets/index-B6-SzLmT.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-uOQTua8_.js", "imports": ["/assets/index-BXZSIDEp.js", "/assets/workflow-graph-viewer-CU0UU458.js", "/assets/mermaid-3ZIDBTTL-C02sm-ZS.js", "/assets/encryption-g14N5vQl.js", "/assets/index-B6-SzLmT.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.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-6fc92124.js", "version": "6fc92124", "sri": void 0 };
153466
152589
  const assetsBuildDirectory = "build/client";
153467
152590
  const basename = "/";
153468
152591
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -153531,33 +152654,36 @@ const serverBuild = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
153531
152654
  ssr
153532
152655
  }, Symbol.toStringTag, { value: "Module" }));
153533
152656
  export {
152657
+ requireTokenError as $,
153534
152658
  ATTRIBUTE_KEY_MAX_LENGTH as A,
153535
152659
  BaseEventSchema as B,
153536
- ulidToDate as C,
152660
+ requiresNewerWorld as C,
153537
152661
  DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS as D,
153538
152662
  EVENT_DATA_REF_FIELDS as E,
153539
- validateAttributeChanges as F,
153540
- validateAttributeKey as G,
152663
+ resolveQueueNamespace as F,
152664
+ stripEventDataRefs as G,
153541
152665
  HookSchema as H,
153542
- validateAttributeValue as I,
153543
- validateUlidTimestamp as J,
153544
- R as K,
152666
+ ulidToDate as I,
152667
+ validateAttributeChanges as J,
152668
+ validateAttributeKey as K,
153545
152669
  LegacySerializedDataSchemaV1 as L,
153546
152670
  MessageId as M,
153547
152671
  Nt as N,
153548
- Ks as O,
152672
+ validateAttributeValue as O,
153549
152673
  PaginatedResponseSchema as P,
153550
152674
  QueuePayloadSchema as Q,
153551
152675
  RESERVED_ATTRIBUTE_KEY_PREFIX as R,
153552
152676
  SPEC_VERSION_CURRENT as S,
153553
- jsxRuntimeExports as T,
153554
- Qe as U,
152677
+ validateUlidTimestamp as T,
152678
+ R as U,
153555
152679
  ValidQueueName as V,
153556
152680
  WaitSchema as W,
153557
- requireTokenUtil as X,
153558
- requireTokenError as Y,
153559
- serverBuild as Z,
152681
+ Ks as X,
152682
+ jsxRuntimeExports as Y,
152683
+ Qe as Z,
152684
+ requireTokenUtil as _,
153560
152685
  ATTRIBUTE_MAX_PER_RUN as a,
152686
+ serverBuild as a0,
153561
152687
  ATTRIBUTE_VALUE_MAX_BYTES as b,
153562
152688
  AttributeValidationError as c,
153563
152689
  DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS as d,
@@ -153579,8 +152705,8 @@ export {
153579
152705
  WorkflowRunSchema as t,
153580
152706
  WorkflowRunStatusSchema as u,
153581
152707
  applyAttributeChanges as v,
153582
- isLegacySpecVersion as w,
153583
- reenqueueActiveRuns as x,
153584
- requiresNewerWorld as y,
153585
- stripEventDataRefs as z
152708
+ getQueueTopicPrefix as w,
152709
+ isLegacySpecVersion as x,
152710
+ parseQueueName as y,
152711
+ reenqueueActiveRuns as z
153586
152712
  };